fix: include source titles in graph exports - #379
Conversation
hurttlocker
left a comment
There was a problem hiding this comment.
Verified locally: clean build, and both graph subject tests pass (TestRunGraph_SubjectJSONIncludesSeedFactIDs, TestRunGraph_SubjectAndFactIDMutuallyExclusive). Reusing search.CitationTitleForResult instead of reimplementing the fallback is exactly the right call — one title path everywhere.
One non-blocking observation: graphSourceTitle does a GetMemory per node, and facts frequently share a backing memory, so large subgraph exports pay an N+1. Not worth holding this PR for — I'm filing it as a follow-up good-first-issue (memoize by MemoryID inside the export loop). If you want to grab that one too, it's yours.
This also closes the graph-export half of #374. Thanks for the clean regression test — merging.
What changed
source_titleto graph JSON export nodes so graph consumers receive the same non-empty citation title fallback used by answer citations.source_sectionis empty.source_section.Why this change exists
Graph export consumers could not rely on a human-readable source title when a memory had no
source_section, even though citation titles already had a shared fallback path.Touched surfaces
cmd/cortex/main.gograph JSON exportcmd/cortex/graph_subject_test.goTests
go test ./cmd/cortex -run 'TestRunGraph_SubjectJSONIncludesSeedFactIDs|TestResolveGraphSeedFactIDsBySubject|TestRunGraph_SubjectAndFactIDMutuallyExclusive'go test ./...go vet ./...Risk
Low. This adds an optional JSON field and leaves existing graph node fields unchanged.
AI-assisted implementation, reviewed locally with the test suite above.
Fixes #374