Skip to content

Commit 2d2e0ea

Browse files
Merge branch 'ftr/phase-10-source-panel' into development
2 parents 514a5c6 + d823008 commit 2d2e0ea

39 files changed

+3726
-234
lines changed

.planning/REQUIREMENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,11 +1751,11 @@ This document defines formal requirements for Holmes v1. Requirements are derive
17511751

17521752
### REQ-SOURCE: Source Panel
17531753

1754-
#### REQ-SOURCE-005: Citation Navigation — ⏳ NOT_STARTED
1754+
#### REQ-SOURCE-005: Citation Navigation — ✅ COMPLETE
17551755

1756-
Evidence source panel exists (`evidence-source-panel.tsx`) but citation navigation not implemented.
1756+
Citation-to-source navigation wired across all 4 views (KG, Geospatial, Verdict, Timeline). Shared hooks: `useSourceNavigation` (citation -> SourceViewerModal), `useEntityResolver` (UUID -> name/type/color). Reusable components: `CitationLink`, `EntityBadge`.
17571757

1758-
**Files:** `frontend/src/components/app/evidence-source-panel.tsx`
1758+
**Files:** `frontend/src/lib/citation-utils.ts`, `frontend/src/hooks/useSourceNavigation.ts`, `frontend/src/hooks/useEntityResolver.ts`, `frontend/src/components/ui/citation-link.tsx`, `frontend/src/components/ui/entity-badge.tsx`
17591759

17601760
---
17611761

.planning/ROADMAP.md

Lines changed: 48 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
| 8 | Synthesis Agent & Intelligence Layer | Cross-referencing, hypotheses, contradictions, gaps, timeline, case summary/verdict | REQ-AGENT-008, REQ-HYPO-*, REQ-WOW-*, REQ-VIS-004/005/006, REQ-TASK-001/002 | ✅ COMPLETE |
3737
| 8.1 | Geospatial Agent & Map View | Location intelligence, geocoding, movement patterns, Earth Engine | REQ-GEO-* | ✅ COMPLETE |
3838
| 9 | Chat Interface & Research | Multi-source tool-based Q&A, research/discovery, context caching | REQ-CHAT-*, REQ-RESEARCH-*, REQ-HYPO-007/008 | 🟡 FRONTEND_DONE |
39-
| 10 | Source Panel & Agent Flow Polish | Source viewers, citation navigation, task panel, narrative generation | REQ-SOURCE-*, REQ-VIS-*, REQ-TASK-003-007 | 🟡 FRONTEND_DONE |
39+
| 10 | Source Panel & Entity Resolution | Citation-to-source wiring, entity name resolution across all views | REQ-SOURCE-* | ✅ COMPLETE |
4040
| 11 | Corrections & Refinement | Error flagging, Verification, Regeneration | REQ-CORR-* | ⏳ NOT_STARTED |
4141
| 12 | Demo Preparation | Demo case showcasing all integration features | Demo readiness, REQ-RESEARCH-004, REQ-AGENT-007i | ⏳ NOT_STARTED |
4242

4343
> **Status Legend:** ✅ COMPLETE | 🟡 FRONTEND_DONE (backend pending) | ⏳ NOT_STARTED | ⏳ PLANNED
44-
> **Note:** Phase 6 complete (2026-02-06, 35 commits). Architecture redesigned 2026-02-07: Phases 7-9 restructured with KG-as-Memory pattern, hybrid storage (PG + Vector), programmatic KG Builder, Synthesis Agent, tool-based Chat Agent. Architecture revised 2026-02-08: Programmatic KG Builder replaced with LLM-based KG Builder Agent (Approach 4); D3.js retained and enhanced (Epstein-inspired); vis-network deferred to optional Phase 7.3.
44+
> **Note:** Phase 10 complete (2026-02-09). Citation-to-source navigation wired across all 4 views (KG, Geospatial, Verdict, Timeline) with shared hooks and entity resolution. Known issues: PDF viewer has rendering bugs, audio viewer untested. Architecture revised 2026-02-08: Programmatic KG Builder replaced with LLM-based KG Builder Agent (Approach 4); D3.js retained and enhanced (Epstein-inspired); vis-network deferred to optional Phase 7.3.
4545
4646
**Post-MVP:**
4747
| Phase | Name | Focus | Requirements |
@@ -1252,78 +1252,61 @@ Plans:
12521252

12531253
---
12541254

1255-
## Phase 10: Agent Flow & Source Panel
1255+
## Phase 10: Source Panel & Entity Resolution
12561256

1257-
**Goal:** Full-featured source viewers, Agent Flow refinements, and task panel.
1257+
**Goal:** Wire citation-to-source navigation across all views and resolve all entity IDs to human-readable names with type badges.
12581258

1259-
**Requirements:** REQ-SOURCE-001 (complete), REQ-SOURCE-002 (complete), REQ-SOURCE-003 (complete), REQ-SOURCE-004 (complete), REQ-VIS-001, REQ-VIS-001a, REQ-VIS-002, REQ-VIS-004, REQ-VIS-007, REQ-WOW-004, REQ-TASK-003, REQ-TASK-004, REQ-TASK-005, REQ-TASK-006, REQ-TASK-007
1259+
**Requirements:** REQ-SOURCE-001 (complete), REQ-SOURCE-002 (complete), REQ-SOURCE-003 (complete), REQ-SOURCE-004 (complete)
12601260

1261-
**Status:** 🟡 FRONTEND_DONE (Timeline) — Source viewers + Task Panel pending
1261+
**Status:** ✅ COMPLETE (2026-02-09)
12621262

1263-
### Frontend Completed (Yatharth, 2026-02-02)
1264-
- ✅ Timeline view with events (`Timeline/`)
1265-
- Day/week/month/year zoom levels
1266-
- Layer filtering (evidence/legal/strategy)
1267-
- Event cards with click-to-detail
1268-
- Search with debouncing
1269-
- SSE hooks ready (`useTimelineSSE.ts`)
1270-
- React Query with caching (`useTimelineData.ts`)
1271-
- Skeleton loading states
1272-
- Framer Motion animations
1273-
- ✅ Evidence source panel exists (`evidence-source-panel.tsx`)
1274-
1275-
### Backend Work Remaining
1276-
- ⏳ Timeline API endpoints (CRUD + SSE stream)
1277-
- ⏳ PDF viewer with excerpt highlighting
1278-
- ⏳ Video player with timestamp markers
1279-
- ⏳ Audio player with waveform and transcript sync
1280-
- ⏳ Image viewer with bounding box annotations
1281-
- ⏳ Citation navigation (click → exact location)
1282-
- ⏳ Narrative generation (executive summary, detailed)
1283-
- ⏳ Export as PDF/DOCX
1284-
- ⏳ Agent Flow refinements (most items)
1285-
- ⏳ Investigation Task Panel (all items)
1263+
**Plans:** 3 plans in 3 waves
1264+
1265+
Plans:
1266+
- [x] 10-01-PLAN.md -- Shared utilities: citation-utils, useSourceNavigation hook, useEntityResolver hook, CitationLink + EntityBadge components
1267+
- [x] 10-02-PLAN.md -- Wire KG entity panel, EntityTimelineEntry, and Geospatial detail panel
1268+
- [x] 10-03-PLAN.md -- Wire Verdict detail panels (hypothesis, contradiction, gap) and Timeline event cards
1269+
1270+
**Scope (narrowed from original Phase 10 via CONTEXT.md):**
1271+
- **Track 1 -- Source Viewer Wiring:** Connect citations across ALL views to open SourceViewerModal with real source files at exact page/timestamp locations. Components already built in Phase 7.2 (SourceViewerModal, PdfViewer, AudioViewer, VideoViewer, ImageViewer); only the data pipeline needs wiring.
1272+
- **Track 2 -- Entity Name Resolution:** Resolve ALL entity integer IDs and UUIDs to human-readable names + type badges across every view (KG, Geospatial, Verdict, Timeline).
1273+
1274+
**Deferred (out of scope for this phase):**
1275+
- Agent Flow refinements (thinking overlay, task badges, time-scrubbing, playback, pause/resume, fullscreen)
1276+
- Investigation Task Panel
1277+
- Narrative generation (executive summary, reports)
1278+
- PDF/DOCX export
1279+
- Image bounding box annotations
1280+
- Audio transcript sync highlighting
12861281

12871282
**Deliverables:**
1288-
- **KG Source Viewer wiring (deferred from Phase 7.2):** Wire `source_finding_ids``case_findings``agent_executions``case_files` → signed download URL chain so that clicking "View source" in KG EntityTimelineEntry opens the SourceViewerModal with the actual document/audio/video/image content. Components already built in Phase 7.2 (SourceViewerModal, PdfViewer, AudioViewer, VideoViewer, ImageViewer); only the data pipeline needs wiring.
1289-
- PDF viewer with excerpt highlighting
1290-
- Video player with timestamp markers
1291-
- Audio player with waveform and transcript sync
1292-
- Image viewer with bounding box annotations
1293-
- Citation navigation (click → exact location)
1294-
- ~~Timeline view with events~~
1295-
- Narrative generation (executive summary, detailed)
1296-
- Export as PDF/DOCX
1297-
- **Agent Flow refinements:**
1298-
- ~~ReactFlow agent pipeline visualization~~ ✅ (@xyflow/react + dagre, done in Phase 4.1)
1299-
- ~~Custom node components per agent type~~ ✅ (DecisionNode, FileGroupNode, Phase 4.1)
1300-
- ~~Agent color coding~~ ✅ (muted palette, Phase 4.1)
1301-
- **Task count badges on agent nodes** (pending)
1302-
- Thinking overlay with streaming thoughts
1303-
- Interactive time-scrubbing
1304-
- Pause/resume workflow
1305-
- Workflow playback with speed control
1306-
- Frontend confirmation dialogs for sensitive operations
1307-
- Fullscreen mode
1308-
- **Investigation Task Panel:** (all pending)
1283+
- Shared useSourceNavigation hook: citation {file_id, locator, excerpt} -> SourceViewerContent with signed URL
1284+
- Shared useEntityResolver hook: entity UUID -> {name, entity_type, color} via cached graph data
1285+
- citation-utils.ts: locator parser (page:N, ts:HH:MM:SS, region:x,y,w,h), category-to-viewer mapper
1286+
- Reusable CitationLink and EntityBadge UI components
1287+
- KG entity panel: source finding IDs clickable -> opens SourceViewerModal
1288+
- EntityTimelineEntry: "View source evidence" replaces "Source not yet available"
1289+
- Geospatial detail panel: citations open SourceViewerModal, entity IDs show resolved names + type badges
1290+
- Verdict hypothesis evidence items clickable -> two-hop finding -> citation -> source navigation
1291+
- Verdict contradiction source excerpts clickable
1292+
- Verdict gap entity badges use consistent getEntityColor styling
1293+
- Timeline event card source count expandable with clickable source links
13091294

13101295
**Technical Notes:**
1311-
- PDF: react-pdf or pdf.js
1312-
- Audio: wavesurfer.js
1313-
- Video: native HTML5 with custom controls
1314-
- ~~Timeline: D3.js or vis-timeline~~ → Custom React implementation ✅
1315-
- Narrative: Gemini generates from Synthesis output
1316-
- **Task count badges update in real-time via SSE**
1317-
- **Frontend files:** `frontend/src/components/Timeline/`, `frontend/src/hooks/useTimelineData.ts`, `frontend/src/hooks/useTimelineFilters.ts`, `frontend/src/hooks/useTimelineSSE.ts`
1296+
- Frontend-only phase: no new backend endpoints needed (all data accessible via existing APIs)
1297+
- Two-hop resolution for findings: finding_id -> GET /findings/:id -> citations[] -> file_id -> signed URL
1298+
- Entity resolution via cached graph data: GET /graph returns all entities, cached per case session
1299+
- File metadata cached via React Query (staleTime: 5 min)
1300+
- Signed URLs cached via existing useFileUrlCache hook (1h cache, 24h expiry)
1301+
- Race condition prevention via request counter ref in useSourceNavigation
1302+
- PDF highlight: first 100 chars of excerpt for search match reliability
13181303

13191304
**Exit Criteria:**
1320-
- All source types viewable with full features
1321-
- Citations navigate to exact locations
1322-
- ~~Timeline shows chronological events~~
1323-
- Narrative generation works with citations
1324-
- **Task panel shows pending investigation tasks**
1325-
- **Task count badges visible on agent nodes**
1326-
- **Task completion workflow functional**
1305+
- Citations clickable from ALL views: KG entity panel, KG timeline entry, Verdict (hypothesis/contradiction), Geospatial detail, Timeline cards
1306+
- Clicking any citation opens SourceViewerModal at correct page/timestamp with excerpt highlighting
1307+
- Entity IDs resolved to human-readable names + type badges in Geospatial and across all views
1308+
- No "Source not yet available" placeholders remain in KG views
1309+
- All type checking and build pass
13271310

13281311
---
13291312

@@ -1552,3 +1535,4 @@ For 2 developers working simultaneously:
15521535
*Phase 7.3 (vis-network, optional) renumbered: 2026-02-08
15531536
*Phase 7.2 (D3.js Enhancement) planned: 2026-02-08 (5 plans in 3 waves)
15541537
*Phase 7.2 (D3.js Enhancement) complete: 2026-02-08 (5 plans + 28 post-plan polish, 46 total commits; source viewer deferred to Phase 10)
1538+
*Phase 10 planned: 2026-02-09 (3 plans in 2 waves -- source viewer wiring + entity resolution)

.planning/STATE.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Holmes Project State
22

33
**Last Updated:** 2026-02-09
4-
**Current Phase:** 8.1 of 12 (Geospatial Agent & Map View) — COMPLETE (5/5 plans)
5-
**Next Phase:** 9 (Chat Interface)
4+
**Current Phase:** 10 of 12 (Source Panel & Entity Resolution) — COMPLETE (3/3 plans)
5+
**Next Phase:** 11 (Corrections & Refinement)
66
**Current Milestone:** M1 - Holmes v1.0
77

88
## Progress Overview
@@ -24,7 +24,7 @@
2424
| 8 | Synthesis Agent & Intelligence Layer | COMPLETE | 2026-02-08 | 2026-02-09 | 7 plans (16 commits) + 3 bugfix commits: DB models + schemas, agent runner/prompt/factory, pipeline Stage 8, SSE events, 8 API endpoints, frontend types/api/hooks, 7 Verdict components, 3 detail panels, CC tab toggle + SSE synthesis readiness, timeline API wiring, verdict badges. Post-fix: Gemini schema compat, pipeline crash fixes, gap entity resolution with names/types, KG event routing |
2525
| 8.1 | Geospatial Agent & Map View | COMPLETE | 2026-02-09 | 2026-02-09 | 5 plans (5 commits): GeocodingService, GeospatialAgentRunner + pipeline Stage 9, 6 REST API endpoints, frontend API client + hook + trigger UI, enhanced detail panel with 4 sections |
2626
| 9 | Chat Interface & Research | FRONTEND_DONE | - | - | Backend API needed |
27-
| 10 | Agent Flow & Source Panel | FRONTEND_DONE | - | - | Timeline done, Source viewers pending |
27+
| 10 | Source Panel & Entity Resolution | COMPLETE | 2026-02-09 | 2026-02-09 | 3 plans (9 commits), 9/9 verified: shared citation utils + hooks, KG + Geospatial source wiring + entity resolution, Verdict + Timeline citation navigation |
2828
| 11 | Corrections & Refinement | NOT_STARTED | - | - | |
2929
| 12 | Demo Preparation | NOT_STARTED | - | - | |
3030

@@ -35,6 +35,12 @@
3535
## Current Context
3636

3737
**What was just completed:**
38+
- **Phase 10 COMPLETE** (2026-02-09): Source Panel & Entity Resolution -- 3 plans, 9 commits, 9/9 verified
39+
- Plan 01: Shared foundation (citation-utils, useSourceNavigation, useEntityResolver, CitationLink, EntityBadge)
40+
- Plan 02: KG entity panel source docs clickable, EntityTimelineEntry "View source evidence", Geospatial entity resolution + citation-to-source
41+
- Plan 03: Verdict hypothesis/contradiction evidence clickable, GapDetailPanel EntityBadge, Timeline expandable citation list
42+
- All 4 target views have functional citation-to-source navigation: KG, Geospatial, Verdict, Timeline
43+
3844
- **Phase 8.1 Complete** (2026-02-09): Geospatial Agent & Map View — 5 plans, 15 commits, 15/15 verified
3945
- Plan 01: GeocodingService with Google Maps API integration (forward/reverse/batch geocoding + in-memory caching)
4046
- Plan 02: GeospatialAgentRunner (text-only input from 6 DB sources, Flash model, pipeline Stage 9, auto-geocoding)
@@ -182,9 +188,10 @@
182188
- Known limitations: Paths not rendered (v1), no SSE streaming (polling-based), entity names not resolved (UUIDs only)
183189

184190
**What's next:**
185-
- Phase 9 (Chat Interface) -- backend API + tool integration (query_kg, search_findings, get_synthesis, generate_geospatial, run_domain_agent)
186-
- Phase 10 (Source Panel) -- wire KG/Geospatial/Timeline citations to source viewers: source_finding_ids → case_findings → agent_executions → case_files → signed download URL
187-
- Phase 10 geospatial enhancements: entity name resolution (currently shows UUIDs), location filtering, movement path visualization
191+
- Phase 11 (Corrections & Refinement) -- polish, bug fixes, integration testing
192+
- Phase 12 (Demo Preparation) -- demo scenarios, sample data, walkthrough
193+
- Phase 9 (Chat Interface) -- backend API + tool integration still needed
194+
- Chat message citations deferred to Phase 9+ (backend does not yet produce structured citations)
188195

189196
---
190197

@@ -235,7 +242,7 @@
235242

236243
---
237244

238-
### REQ-VIS-003: Knowledge Graph — COMPLETE (Source viewer wiring deferred to Phase 10)
245+
### REQ-VIS-003: Knowledge Graph — COMPLETE (Source viewer wired in Phase 10 Plan 02)
239246

240247
| Component | File Path |
241248
|-----------|-----------|
@@ -585,6 +592,25 @@ All frontend features need these backend endpoints:
585592
| Geospatial detail loading | Upfront vs Lazy on-demand | Lazy on marker click | LocationResponse list lightweight (coordinates+counts); detail API heavy (full events/citations arrays); faster initial render |
586593
| Geospatial entity display | Resolve names vs Show IDs | Show UUIDs only | Entity name resolution requires additional API or preloading; deferred to Phase 10 with KG navigation |
587594
| Citation excerpt quotes | Literal vs HTML entities | “ / ” entities | React react/no-unescaped-entities lint rule rejects literal quotes in JSX text |
595+
| File lookup map pattern | useRef vs useMemo | useMemo derived from React Query data | React Compiler's react-hooks/refs rule forbids ref mutation during render; useMemo is the correct pattern for derived data |
596+
| Entity resolution caching | Dedicated endpoint vs Graph endpoint | Graph endpoint (fetchGraph) | All entities already returned by /graph; 5-min stale time cache; avoids new backend endpoint |
597+
| Unresolved entity fallback | Throw error vs Graceful degradation | Graceful fallback (Unknown Entity, type=other) | Missing entities should not crash UI; fallback allows partial resolution |
598+
| PDF highlight excerpt length | Full excerpt vs Truncated | Truncated to 100 chars | Shorter text matches more reliably in @react-pdf-viewer/search plugin |
599+
| KG Canvas caseId passing | useParams inside vs Prop from page | Prop from page | Keeps canvas component decoupled from routing; page is the routing boundary |
600+
| KG source navigation callback stability | Direct callback vs Stable ref pattern | Stable ref pattern (openFromFindingRef) | Prevents sidebar content effect re-triggering on every openFromFinding recreation |
601+
| Geospatial file name lookup type | Map<string, string> vs Record<string, string> | Record<string, string> | Map import from @vis.gl/react-google-maps shadows global Map constructor |
602+
| Geospatial source navigation | Prop-based (onViewSource) vs Self-contained hook | Self-contained useSourceNavigation hook | Component manages its own SourceViewerModal portal; no prop drilling |
603+
| SourceViewerModal layering in geospatial | Same z-index as dialog vs Higher | z-[60] above z-50 dialog | Source viewer must appear above the detail dialog without closing it |
604+
| Verdict source navigation wiring | Direct hook in panels vs Callback threading | Callback threading via sidebar descriptors | Detail panels render inside DetailSidebar without caseId access; callback threaded from page through VerdictView -> descriptor props |
605+
| Timeline citation source | event.sourceIds vs event.metadata.citations | event.metadata.citations | sourceIds contains entity UUIDs (misnamed); metadata.citations has actual file refs (file_id, locator, excerpt) |
606+
| Timeline citation UX | Modal with all citations vs Expandable list | Expandable list in card | Progressive disclosure; click count to expand, click individual citation to open SourceViewerModal |
607+
608+
---
609+
610+
## Known Issues
611+
612+
- **PDF Viewer**: Has rendering/display bugs (identified during Phase 10 testing)
613+
- **Audio Viewer**: Not yet tested with real data; may have issues
588614

589615
---
590616

@@ -597,9 +623,9 @@ None currently.
597623
## Session Continuity
598624

599625
Last session: 2026-02-09
600-
Stopped at: Phase 8.1 COMPLETE (5/5 plans, 5 commits, 38 min total). Geospatial agent + frontend integration + detail panel complete.
626+
Stopped at: Phase 10 COMPLETE (3/3 plans, 9 commits, 9/9 verified). Source panel & entity resolution across all views.
601627
Resume file: None
602-
Next action: Phase 9 (Chat Interface Backend)
628+
Next action: Phase 11 (Corrections & Refinement)
603629

604630
---
605631

0 commit comments

Comments
 (0)