Skip to content

update(): fail fast when all_traces.jsonl is missing#5

Merged
adrida merged 1 commit into
adrida:mainfrom
anwesh2410:fix/update-missing-all-traces
Jun 8, 2026
Merged

update(): fail fast when all_traces.jsonl is missing#5
adrida merged 1 commit into
adrida:mainfrom
anwesh2410:fix/update-missing-all-traces

Conversation

@anwesh2410

Copy link
Copy Markdown
Contributor

What

update() now raises a clear FileNotFoundError when .tracer/all_traces.jsonl
is missing, instead of silently dropping the original traces and failing later.

Why

The first-update branch in update() had a comment promising to "reconstruct
original traces … or infer count from existing embeddings," but did neither — it
appended only the new records while X_combined still held old + new embeddings.
Since fit() always writes all_traces.jsonl, the branch was effectively
unreachable; but if a user deletes that file (which AGENTS.md explicitly warns
against), the next update() produced a cryptic Trace/embedding mismatch far
from 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

  • Replace the dead/misleading branch with an early FileNotFoundError.
  • Add test_update_missing_all_traces_raises_clear_error.

Compatibility

Non-breaking — the normal fit → update flow is unchanged (full suite green, 22 passed).

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 adrida left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

@adrida adrida merged commit d24a764 into adrida:main Jun 8, 2026
5 checks passed
@adrida adrida mentioned this pull request Jun 8, 2026
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>
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.

2 participants