Summary
The new link_entities_to_chunks write-path (eaf803f) fans every doc-level entity across every chunk of the document. For a typical Notion page (18 entities × 19 chunks = 342 link rows), every chunk appears to contain every entity. Historical koi_entity_chunk_links data (614K rows from before Feb 10) had genuine per-chunk attribution — we should return to that fidelity.
Proposed work
- Evaluate whether per-chunk precision is worth the cost vs. current doc-level fanout
- Implement either:
- A. Per-chunk LLM extraction (highest fidelity, N× LLM cost, N ≈ 20 for Notion)
- B. Offset-match: after doc-level extraction, substring-search each entity in each chunk's text and only link where it actually appears (~free, misses synonyms/pronouns)
- Populate
char_offset (currently NULL) for chunk-level context in UI
- Adjust ranking in
koi-query-api.ts to use per-chunk entity density where available
Option B is likely the right MVP. It compounds well with improved entity extraction (#19).
Dependencies
Blocked by #19 (entity extraction quality) — not strictly, but the combined improvement is much more valuable than either alone.
References
- Current write-path:
eaf803f — link_entities_to_chunks in src/core/koi_event_bridge_v2.py
- Backfill script:
scripts/backfill_entity_chunk_links.py
- Search consumer:
koi-query-api.ts line ~1163 (entity_memories CTE)
Task key: other-2026-04-14-per-chunk-entity-attribution
Vault task: Tasks/2026-04-14-per-chunk-entity-attribution.md
Summary
The new
link_entities_to_chunkswrite-path (eaf803f) fans every doc-level entity across every chunk of the document. For a typical Notion page (18 entities × 19 chunks = 342 link rows), every chunk appears to contain every entity. Historicalkoi_entity_chunk_linksdata (614K rows from before Feb 10) had genuine per-chunk attribution — we should return to that fidelity.Proposed work
char_offset(currently NULL) for chunk-level context in UIkoi-query-api.tsto use per-chunk entity density where availableOption B is likely the right MVP. It compounds well with improved entity extraction (#19).
Dependencies
Blocked by #19 (entity extraction quality) — not strictly, but the combined improvement is much more valuable than either alone.
References
eaf803f—link_entities_to_chunksinsrc/core/koi_event_bridge_v2.pyscripts/backfill_entity_chunk_links.pykoi-query-api.tsline ~1163 (entity_memoriesCTE)Task key:
other-2026-04-14-per-chunk-entity-attributionVault task:
Tasks/2026-04-14-per-chunk-entity-attribution.md