fix(ledger): close-out count derives from ledger's own lines, never below them#33
Merged
Merged
Conversation
…elow them A real integration test surfaced a visible contradiction: the Stop close-out printed "lanes recorded this session: 0" directly above 2 lane LINES. Cause — the count read ONLY .agents/runs/lane_spawns.jsonl (the separate record_lane_spawn.py sidecar), while the lines came from ledger.py's own PostToolUse handler; when the sibling hasn't fired the count reads 0 despite ledger.py having just written N lines. Fix: lane_count() now returns max(own lane lines in ledger.md, sibling lane_spawns.jsonl), so the count is never lower than the lines shown and a sibling-only observation isn't lost. A shared _LANE_MARK couples the writer (lane_line) and reader (_own_lane_lines) so they can't drift. New test group G runs ONLY ledger.py through N spawns + a Stop (no lane_spawns.jsonl seeded) and asserts the count matches the N lines — the coupling can't hide. Robustness/consistency fix; in a fully-wired session both hooks co-fire and the count was already right. Independent cold-read review: pass, no blockers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
andrewwint
added a commit
that referenced
this pull request
Jul 10, 2026
… own lines (#34) Bumps 1.3.0 -> 1.3.1 (plugin.json, runtime/package.json, lockfile) + CHANGELOG 1.3.1 entry. Patch: the ledger close-out count now derives from ledger.py's own recorded lane lines (reconciled with the sibling lane_spawns.jsonl), so it can never read lower than the lines it displays. Trail-only; no enforcement/verdict change. Fix landed in #33. Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
A real integration test (feeding genuine PostToolUse/Stop JSON to the shipped hook) surfaced a visible contradiction: the Stop close-out printed "lanes recorded this session: 0" directly above 2 lane lines.
Cause: the count read only
.agents/runs/lane_spawns.jsonl(written by the separaterecord_lane_spawn.pysidecar), while the lane lines are written byledger.py's own PostToolUse handler. When the sibling hasn't fired, the count reads 0 despite ledger.py having just written N lines — two sources for one fact that can visibly disagree.Fix:
lane_count()now returnsmax(own lane lines in ledger.md, sibling lane_spawns.jsonl)— never lower than the visible lines, and a sibling-only observation isn't lost. A shared_LANE_MARKcouples the writer (lane_line) and reader (_own_lane_lines) so they can't drift.Test: new group G runs only
ledger.pythrough N spawns + a Stop (nolane_spawns.jsonlseeded) and asserts the count matches the N lines — the coupling can't hide the bug. Reproduced the exact reported scenario: 2 lanes → "lanes recorded this session: 2", Read event ignored.Robustness/consistency fix — in a fully-wired session both hooks co-fire and the count was already right. Independent cold-read review: pass, no blockers.
🤖 Generated with Claude Code