Repository navigation
fix(agent-activity): cache a context id only after its line is written (#1303) - #1414
Merged
Juliusolsson05 merged 7 commits intoSep 27, 2026
Conversation
#1303) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tial write (#1414 review a+b) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e and retried, never overwritten (#1414 review a round 3) Recovery treated any failure as 'no open file' and overwrote open.json with an empty snapshot, losing the pending interval. Only ENOENT is empty now; anything else is moved to open.json.unrecovered-<time> (a rename needs no read permission) and later starts recover each copy they can read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…recovered; no reissue-by-size fallback (#1414 review c) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d is not cached as empty (#1414, B6 check) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The same store reads while aliases.jsonl is unreadable, then must group A and B once readable. Red with a catch-all; the append test could not pin it because the tail check refuses that append on its own (B6 check 2110). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Disposition at 4241aa2 (a, b and c rounds; review cap reached; B6 manual inspection, then manager-verify a/b/c MERGE-READY):
Gates: tsc -b clean; 78 tests at 4241aa2; CI green. 🤖 Generated with Claude Code |
Juliusolsson05
changed the base branch from
main
to
integration/batch-2026-09-27-r
September 27, 2026 21:32
Juliusolsson05
merged commit Sep 27, 2026
72a753a
into
integration/batch-2026-09-27-r
2 checks passed
Merged
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.
Fixes #1303.
Problem
AgentActivityStore.appendIntervalcached a new context id (ids.set(key, id)) BEFORE the append that writes that context line. If the append failed (ENOSPC, EIO; the store's queue onlyconsole.warns), every later interval for that agent in the same month referenced a context line that never reached disk, andreadIntervalssilently dropped each one. One failed write cost the agent's hours for the rest of the month.What merges
appendLinessucceeds (Agent Analytics silently loses an agent's hours after one failed context write #1303).ids.size + 1fallback is removed.open.jsonis set aside toopen.json.unrecovered-<time>, never overwritten. Later starts recover each readable copy. A recovery that fails partway sets aside only the unrecovered remainder, so nothing is counted twice;aliases.jsonlrefuses the append (its tail cannot be checked) and is not cached as empty (B6 check).Tests (real files,
AgentActivityStore.test.ts)open.jsonis set aside, not overwritten, and recovered once readable;loadAliases' ENOENT-only catch; red with a catch-all).Each is red on the code it fixes, and the named mutations are killed. The aliases case has two separate guards, each with its own test. The read path depends on
loadAliasesalone. The append path is also refused by the tail check.Residual: the ENOENT-only guard in
contextsForis pinned for EACCES only; EISDIR fails the append itself, and EIO is not reproducible on a real filesystem.Gate:
npx tsc -bis clean;src/main/agentActivity+src/renderer/src/features/agent-activitypass, 6 files / 78 tests at4241aa25.🤖 Generated with Claude Code