fix: use high-water mark for incremental indexing (fixes #84)#85
Closed
anastasiiaanfimova wants to merge 1 commit into
Closed
fix: use high-water mark for incremental indexing (fixes #84)#85anastasiiaanfimova wants to merge 1 commit into
anastasiiaanfimova wants to merge 1 commit into
Conversation
obra
added a commit
that referenced
this pull request
May 2, 2026
The indexer skipped any file with COUNT(*) > 0 in exchanges, so once a transcript had been indexed it never gained new rows. Resumed sessions and concurrent SessionStart syncs that raced a still-running session left the tail permanently invisible to search. Schema already stored line_start/line_end per exchange, so the fix is a high-water-mark check: SELECT MAX(line_end), then filter parsed exchanges to those with lineStart past that mark. Transcript JSONLs are append-only, so monotonicity holds and IDs from prior runs are preserved. The archive copy is refreshed whenever maxIndexedLine > 0, since the source may have grown since the last copy. Test: indexUnprocessed against a temp source with 2 exchanges, append 3 more, re-index, verify all 5 are present in the DB. Credit: independent re-derivation of @anastasiiaanfimova's #85 via TDD. Closes #84
Owner
|
Hi @anastasiiaanfimova — thanks for diagnosing this and proposing the fix. The bug + your high-water-mark approach were correct. Re-derived in fa02569 via TDD: red test that indexes 2 exchanges, appends 3 more, re-indexes, asserts 5 in the DB. Closing in favor of the merged version, but the credit is yours. Original reporter @jamster — your detection script and the file-distribution stats were what made this actionable. Thank you. Closes #84. — Claude Opus 4.7, Claude Code 2.1.119 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The indexer skips a file entirely if
COUNT(*) > 0for itsarchive_path:This means any conversation that was indexed in a previous run will never receive new exchanges — even if the source
.jsonlfile has grown since then. Fixes #84.Fix
Replace the count check with a high-water mark using
MAX(line_end). After parsing, filter out exchanges already covered by the high-water mark. The archive copy is also updated whenever the file was partially indexed (it may have grown since the last copy).No schema migration needed —
line_startandline_endare already stored per exchange.Testing
Verified locally: after
rebuild, subsequent index runs correctly pick up new exchanges appended to previously-indexed files.