Skip to content

fix: exempt canonical corpus chunks from length normalization and decay - #986

Merged
rwmjhb merged 1 commit into
CortexReach:masterfrom
benjaml4:fix/corpus-lifecycle-exemption
Aug 4, 2026
Merged

fix: exempt canonical corpus chunks from length normalization and decay#986
rwmjhb merged 1 commit into
CortexReach:masterfrom
benjaml4:fix/corpus-lifecycle-exemption

Conversation

@benjaml4

@benjaml4 benjaml4 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #985.

Corpus chunks are line-span document chunks whose length is set by the indexer, and whose timestamps are source-file mtimes — so conversation-memory length normalisation and decay compound to ~0.15 on a chunk that fused at 0.917, dropping the store's #1 match below minScore. Details and measurements in the issue.

The guard is id.startsWith("corpus:") (always true for buildCorpusId output), applied in applyLengthNormalization, applyDecayBoost, and applyTimeDecay. Conversation-memory scoring is untouched. tsc --noEmit clean; verified before/after on a live 2,505-chunk store.

Complements #982/#983 — with all three, a canonical-corpus-only store (no import-markdown copies) has working recall.

Canonical corpus recall was near-impossible: after fusion, results pass
through applyLengthNormalization and applyDecayBoost/applyTimeDecay,
both calibrated for conversation memories.

- Corpus chunks are line-span document chunks (~3,900 chars against the
  500-char anchor -> factor ~0.40). Length is a property of the chunker,
  not entry quality, and chunk size is already bounded by the indexer.
- Corpus rows carry the source file's mtime as their timestamp
  (toMemoryEntry: timestamp: doc.mtimeMs), so weeks-old reference docs
  take the decay multiplier down to ~boostMin. Reference truth does not
  age like chat memory.

Measured: a corpus chunk that fused at 0.917 (top FTS hit, exact-keyword
floor) finished ~0.15 after both stages — below hardMinScore/minScore —
so memory_search and memory_recall returned 0 results for content that
is the store's CortexReach#1 match on both retrieval sides. With the exemption the
same query returns it correctly.

Corpus ids are always 'corpus:'-prefixed (buildCorpusId), so the guard
is a cheap string check with no metadata parsing.

@rwmjhb rwmjhb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed head 8ce9371. Exempting canonical corpus chunks from conversation-oriented length normalization and decay directly addresses the reported retrieval failure. The targeted checks and full local suite pass.

Please follow up with direct retrieval regressions covering all three exemptions and a shared corpus-entry predicate; these are non-blocking for this focused change. GitHub currently reports no check runs for this head.

Approved.

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.

Canonical corpus chunks are crushed by length normalization + decay — top-match content returns 0 results

2 participants