Skip to content

Drop a heading's path chunk when it has real content - #19

Merged
johnsabath merged 1 commit into
mainfrom
john/drop-redundant-path-chunks
Sep 15, 2026
Merged

johnsabath merged 1 commit into
mainfrom
john/drop-redundant-path-chunks

Conversation

@johnsabath

Copy link
Copy Markdown
Collaborator

Every markdown heading gets a breadcrumb-only path chunk regardless of
whether it also has narrow/full content chunks — even a heading with a full
paragraph under it carries an extra, content-free copy in the index.

Two independent retrieval benchmarks (a synthetic corpus and a real 137-file
vault, 145 hand-verified queries) measured this chunk as retrieval-inert: it
never ranked in a query's top 30 across either set.

path chunks share of index
real 137-file vault 1846 of 3989 46%

Emit path only when a heading has neither direct content nor a non-empty
subtree (a placeholder ## Future work with nothing under it) — the one case
where Store.FileHeadings has no other chunk to derive that heading's
#anchor from. search.go's existing path→sibling promotion is unchanged;
it now only ever fires for that case, correctly finding nothing to promote.

Side effect: [reindex] — chunkVersion bumps to 5, so every vault
re-chunks and re-embeds once on the next semantic index.

Proof: unit tests pin both the emitted-for and dropped-for cases,
including the empty-subtree-still-gets-an-anchor case FileHeadings/lint
depend on. Full suite green, including the real-embedding-model e2e script.

Every markdown heading got a breadcrumb-only `path` chunk regardless
of whether it also had narrow/full content chunks. Two independent
retrieval benchmarks (a synthetic corpus and a real 137-file vault,
145 hand-verified queries) measured it as retrieval-inert — it never
ranked in a query's top 30 across either — while accounting for ~46%
of a vault's chunk count, so of embedding time and index size on every
`semantic index`.

Keep it only where it is load-bearing: a heading with neither direct
content nor a non-empty subtree (a placeholder `## Future work` with
nothing under it) still needs a row for Store.FileHeadings to derive a
valid `#anchor` from, since that's the only place such a heading would
otherwise appear in the chunks table. search.go's collapseByFile /
bestContentSibling, which promote a path hit to its content sibling,
are unchanged — they now only ever fire for that one case, which is
exactly correct (nothing to promote to).

[reindex] — chunkVersion 5; every vault re-chunks and re-embeds once
on the first index after upgrading.

Signed-off-by: John Sabath <john@reactor.inc>
@johnsabath
johnsabath marked this pull request as ready for review September 15, 2026 18:37
@johnsabath
johnsabath merged commit 3b1d1a2 into main Sep 15, 2026
9 checks passed
@johnsabath
johnsabath deleted the john/drop-redundant-path-chunks branch September 15, 2026 18:38
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.

1 participant