update(): fail fast when all_traces.jsonl is missing#5
Merged
Conversation
The first-update branch in update() carried a comment promising to reconstruct the original traces "from the original trace source… or infer count from existing embeddings," but did neither — it appended only the new records while X_combined still held old + new embeddings. fit() always writes all_traces.jsonl, so this branch was effectively unreachable; but if the file is deleted (which AGENTS.md warns against), the next update() produced a cryptic trace/embedding length mismatch far from the real cause. The original records can't be recovered from the index embeddings alone, so raise a clear, actionable FileNotFoundError instead. Adds a regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
adrida
approved these changes
Jun 8, 2026
adrida
left a comment
Owner
There was a problem hiding this comment.
Excellent code archaeology. You're right that the else branch was effectively unreachable (fit() always writes all_traces.jsonl, and AGENTS.md warns against deleting it) and that it was actively wrong when hit: X_combined held old+new embeddings while combined_records held only the new ones, producing the Trace/embedding mismatch downstream. Since the originals genuinely can't be recovered from index embeddings alone, failing fast with an actionable message is the correct call. Merging.
Tiny optional follow-up, no need to block: the check could move above EmbeddingIndex.load and vstack so it fails before the wasted work. Happy to take it in a later PR or just leave it.
Merged
adrida
added a commit
that referenced
this pull request
Jun 8, 2026
Ships everything since 0.1.1 (0.1.2 was bumped in-tree but never tagged): predict_batch() dim guard (#3), FitConfig/EmbeddingConfig fail-fast validation (#4), update() fail-fast on missing all_traces.jsonl (#5), plus the skip_candidates knob and fit() progress logging. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
update()now raises a clearFileNotFoundErrorwhen.tracer/all_traces.jsonlis missing, instead of silently dropping the original traces and failing later.
Why
The first-update branch in
update()had a comment promising to "reconstructoriginal traces … or infer count from existing embeddings," but did neither — it
appended only the new records while
X_combinedstill held old + new embeddings.Since
fit()always writesall_traces.jsonl, the branch was effectivelyunreachable; but if a user deletes that file (which AGENTS.md explicitly warns
against), the next
update()produced a crypticTrace/embedding mismatchfarfrom the cause.
The original records genuinely can't be recovered from the index embeddings alone,
so the honest fix is to fail fast with an actionable message ("re-run fit() to
rebuild it").
Changes
FileNotFoundError.test_update_missing_all_traces_raises_clear_error.Compatibility
Non-breaking — the normal
fit → updateflow is unchanged (full suite green, 22 passed).