Skip to content

fix: include source titles in graph exports - #379

Merged
hurttlocker merged 1 commit into
hurttlocker:mainfrom
w3lld1:fix/graph-source-title-fallback
Jul 11, 2026
Merged

fix: include source titles in graph exports#379
hurttlocker merged 1 commit into
hurttlocker:mainfrom
w3lld1:fix/graph-source-title-fallback

Conversation

@w3lld1

@w3lld1 w3lld1 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Adds source_title to graph JSON export nodes so graph consumers receive the same non-empty citation title fallback used by answer citations.
  • Derives the title from the backing memory's section/header first, then the base source filename when source_section is empty.
  • Adds regression coverage for subject graph JSON exports with an 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.go graph JSON export
  • cmd/cortex/graph_subject_test.go

Tests

  • 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

@hurttlocker hurttlocker left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Citation title fallback: handle memories with empty source_section gracefully everywhere

2 participants