Skip to content

test(cli): stop the read-only object store fixture from proving nothing - #39

Merged
rmyndharis merged 2 commits into
mainfrom
fix/write-tree-fixture-premise
Aug 12, 2026
Merged

test(cli): stop the read-only object store fixture from proving nothing#39
rmyndharis merged 2 commits into
mainfrom
fix/write-tree-fixture-premise

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

The premise nothing guaranteed

The warn-and-continue test breaks git write-tree by chmodding .git/objects
to 0500, then asserts the break happened before exercising the branch it exists
to cover.

Git returns an object it already has without writing it. So if the staged tree
had reached the object store before the chmod, write-tree exits 0 under a
read-only store and the fixture assertion fails — the test reports a failure
that has nothing to do with the behaviour under test.

Reproduced directly: write the tree once with the store writable, chmod to 0500,
run write-tree again, exit 0.

The change

The staged file opens with a unique line, so the tree it produces cannot already
be in the store.

The failure is also checked for its reason, not only its exit status. Any other
breakage — a missing binary, a corrupt index, a different permission problem —
satisfied the old assertion while testing something else entirely. Writing that
check is what surfaced git's actual wording here: insufficient permission for adding an object to repository database, which is neither of the phrasings I
would have guessed.

What this does not claim

This test failed once in a full local run, passed in isolation 25/25, and passed
on re-run. I ran the full suite repeatedly to capture the assertion message and
did not reproduce it in the runs that completed.

So the pre-existing-object path is the fragility I could prove, not a proven
cause of that particular failure. The two other assertions in the test look
robust by inspection: write-tree failures are caught at both call sites
(bin/aimhooman.mjs:337, src/guard.mjs:91), and hashBlob uses
hash-object --stdin without -w, so nothing else in the precommit path needs
to write an object.

Full suite green, npm run check green.

The warn-and-continue test breaks `git write-tree` by chmodding .git/objects to
0500, then asserts the break happened before exercising the branch it cares
about. That premise is not guaranteed by anything in the test.

Git returns an object it already has without writing it, so if the staged tree
had reached the store before the chmod, `write-tree` exits 0 under a read-only
store and the fixture assertion fails. Reproduced directly: write the tree once
with the store writable, chmod to 0500, run `write-tree` again, exit 0.

The staged file now opens with a unique line, so the tree it produces cannot
already exist. And the failure is checked for its reason rather than only its
exit status: any other breakage would satisfy the old assertion while testing
something else. Writing that check is what surfaced git's actual wording here —
"insufficient permission for adding an object to repository database".

This test failed once in a full local run and passed in isolation and on re-run.
The pre-existing-object path is the fragility I could prove; whether it is what
fired that time is not established.
…took

CI caught the fixture assertion failing on macOS with the unique-tree change
already in place, which rules out the pre-existing-object path as the cause
there: `git write-tree` succeeded with .git/objects at mode 0500.

Mode bits are not the whole permission story. macOS keeps inherited ACLs across
chmod, so a directory can read 0500 and still accept a new file. The fixture
then builds nothing and the test reports a failure of the code under test when
the harness is what did not hold.

The test now writes a probe file into the directory it just made read-only. If
that succeeds, the environment does not enforce the mode this fixture needs and
the test skips with that reason instead of failing. The fixture assertion also
carries write-tree's own status and output now, so the next surprise explains
itself rather than needing a CI archaeology run.
@rmyndharis
rmyndharis merged commit 1ed62bd into main Aug 12, 2026
8 checks passed
@rmyndharis
rmyndharis deleted the fix/write-tree-fixture-premise branch August 12, 2026 11:40
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