Skip to content

fix(coord): a branch that predates docs/BACKLOG.md is not a ledger violation#10

Merged
wshallwshall merged 1 commit into
mainfrom
ledger-head-absent
Jul 27, 2026
Merged

fix(coord): a branch that predates docs/BACKLOG.md is not a ledger violation#10
wshallwshall merged 1 commit into
mainfrom
ledger-head-absent

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Publishing docs/BACKLOG.md (#6) broke the ledger gate on every branch cut before that merge — including PR #7, whose diff touched release.yml and leak-gate docs and nothing near a ledger:

OSError: git show HEAD:docs/BACKLOG.md failed (128):
fatal: path 'docs/BACKLOG.md' does not exist in 'HEAD'

Why

CI's change set is diff base HEAD. Once origin/main gained the file, a branch that predates it lists docs/BACKLOG.md as changed — as a deletion relative to base — despite never touching it. check_backlog then read HEAD for a copy that was never there.

base_has (added when the file was imported) covers the opposite end: absent on base, being added. This is the mirror case — present on base, absent on HEAD — and it's the one that fires repeatedly, because it hits every open branch at once rather than the single commit that publishes the file.

The fix

Both probes now share _obj_exists, which asks git cat-file -e directly rather than inferring absence from an exception. git() must keep raising on real failures — an error swallowed as "empty ledger" reads as "no numbers taken", the false-clean this gate exists to prevent. "The path is not on that ref" is the one genuine non-failure, so it gets its own probe instead of a broad except.

head_has mirrors head_text's ref exactly (HEAD in CI, the index locally), so the guard can't disagree with the read it guards.

Mutation-verified: neutralise the guard and the new test fails with the same exit-128 shape seen in CI.

A note on how this was found

It surfaced as an unrelated-looking failure on someone else's PR, and the first re-run "fixed" nothing — the attempt before it had failed for a genuinely different, genuinely random reason (a 3-char needle colliding with base64 ciphertext, fixed in #8). Two different faults on consecutive attempts of the same leg is exactly the shape that gets misread as one flaky test and re-run until it goes green.

🤖 Generated with Claude Code

…olation

Publishing docs/BACKLOG.md (#6) broke the ledger gate on every branch cut before that merge, including
PR #7 -- whose diff touched release.yml and leak-gate docs and nothing near a ledger:

    OSError: git show HEAD:docs/BACKLOG.md failed (128): fatal: path 'docs/BACKLOG.md' does not exist
    in 'HEAD'

CI's change set is `diff base HEAD`. Once origin/main gained the file, a branch that predates it lists
docs/BACKLOG.md as CHANGED -- as a deletion relative to base -- despite never touching it. check_backlog
then read HEAD for a copy that was never there.

`base_has` (added when the file was imported) covers the opposite end: absent on BASE, being added.
This is the mirror case -- present on base, absent on HEAD -- and it is the one that fires repeatedly,
because it hits every open branch at once rather than the single commit that publishes the file. Both
probes now share `_obj_exists`, which asks `git cat-file -e` directly rather than inferring absence
from an exception: `git()` must keep raising on real failures, since an error swallowed as "empty
ledger" reads as "no numbers taken" -- the false-clean this gate exists to prevent. "The path is not on
that ref" is the one non-failure, so it gets its own probe instead of a broad `except`.

`head_has` mirrors `head_text`'s ref exactly (HEAD in CI, the INDEX locally), so the guard cannot
disagree with the read it guards.

Mutation-verified: neutralise the guard and the new test fails with the same exit-128 shape seen in CI.

Worth noting for whoever meets this next: the failure looked like an unrelated flake on somebody else's
PR, and the first re-run "fixed" nothing -- the run before it had failed for a genuinely different,
genuinely random reason (a 3-char needle colliding with base64 ciphertext, fixed separately). Two
different faults on consecutive attempts of the same leg is exactly the shape that gets misread as one
flaky test.
@wshallwshall
wshallwshall merged commit bee2ea6 into main Jul 27, 2026
31 checks passed
@wshallwshall
wshallwshall deleted the ledger-head-absent branch July 27, 2026 15:07
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.

1 participant