Repository navigation
Fix red main, and stop the post-checkout install from deadlocking a rebase - #2442
Conversation
Review TypeInitial Review — no prior reviews or comments on this PR. Requirements CheckNo linked GitHub issue. The branch is On the process deviation: CLAUDE.md's startup sequence (worktree, baseline comment, Code Review Findings🔴 The hook's central safety claim is false — a completed rebase does not re-fire
|
| Scenario | Hooks fired |
|---|---|
Plain git rebase main (2 commits) |
1 — at the start, flag=1, rebase-merge=YES |
Rebase where package.json changed |
1 — same, at the start only |
Conflicted rebase + git rebase --continue |
1 — at the start only |
In every case the only invocation is the initial base checkout — precisely the one this guard now skips — and nothing fires at completion. git rebase finishes by moving the branch ref and resetting the index/worktree in place; it does not perform a checkout that triggers the hook.
The consequence is a real behavioral regression, not a theoretical one: after this change, a rebase that pulls in package.json/bun.lock changes leaves node_modules stale with no install at all. Previously the install ran (many times, badly, and it deadlocked — but it ran). Now it runs zero times. The developer is left with dependencies silently out of sync until they happen to switch branches again.
The same holds for the other three guarded states, which I also tested — and here the finding is different in kind: git merge, git cherry-pick, and git revert never fire post-checkout at all, conflicted or clean, with MERGE_HEAD/CHERRY_PICK_HEAD present. So those three entries in the loop are dead code. They cost nothing, but they also protect nothing, and their presence in the list makes the guard look broader and better-tested than it is.
Principle — correctness claims must be verified, not reasoned: the comment block is doing the work of a test here. It states a mechanism ("fires this hook again") that reads plausibly and is wrong, and because it is committed as an explanatory comment it will be trusted by the next reader rather than re-derived. This is the risk of encoding an unverified causal claim as documentation.
To be fair about severity: the change is still arguably a net improvement over the status quo, because the previous behavior was an unrecoverable deadlock — strictly worse than stale node_modules. I am flagging this 🔴 not because the guard should be reverted, but because the stated rationale is wrong and must not ship as-is, and because the resulting gap deserves an explicit, honest treatment rather than a reassurance that it doesn't exist.
Suggested fix — make the skip deferred rather than silent. Keep the guard, drop the false claim, and tell the developer what to do:
for state in rebase-merge rebase-apply MERGE_HEAD CHERRY_PICK_HEAD REVERT_HEAD sequencer; do
if [ -e "$(git rev-parse --git-path "$state")" ]; then
echo "husky: skipping 'bun install' during a git sequencing operation."
echo " Run 'bun install' yourself once it finishes if deps changed."
exit 0
fi
doneA one-line notice converts a silent correctness gap into a visible, actionable one, which is the difference between a trade-off and a bug. If you want to close the gap properly rather than paper over it, the durable place is a post-rewrite hook (which does fire after git rebase completes) — but that is a follow-up, and the notice is enough for this PR.
🟡 Guard set is incomplete — REVERT_HEAD and sequencer/ are missing
📁 .husky/post-checkout:17
for state in rebase-merge rebase-apply MERGE_HEAD CHERRY_PICK_HEAD; doTwo states are absent. REVERT_HEAD exists during a conflicted git revert, and sequencer/ exists during a multi-commit git cherry-pick A..B or git revert A..B — the multi-commit sequencer is the case most likely to replay many commits and thus most analogous to the rebase failure this PR fixes.
My testing showed none of these currently fire post-checkout on git 2.39.5, so this is not an active bug. But the loop is cheap and the cost of an omission is another silent deadlock on some future git version or workflow. Since three of the four existing entries are already defensive-only, the set may as well be complete.
Principle — defense in depth should be uniform: a guard list that covers some of a category invites the reader to assume the category is covered. Either enumerate it fully or narrow it to the one state that demonstrably matters (rebase-merge).
🟡 Test fixture: verified correct, and the inverse is semantically right
📁 packages/core/tests/object_valued_property_roundtrip_test.rs:170-172
I verified the red-main claim independently. On origin/main:
running 9 tests
test object_property_round_trips_through_relationship_get ... FAILED
Error: concert schema: invalid params: Relationship 'held_at' (entry 0) is missing
"reverseName" and "reverseCardinality".
test result: FAILED. 8 passed; 1 failed
On this branch: test result: ok. 9 passed; 0 failed. The claim is accurate and the fix resolves it. As described, the test fails at schema creation — before reaching the object-valued-property round-trip it exists to verify — so main was not merely red but had lost the coverage entirely.
On the semantics: concerts/many is correct. A concert is held at exactly one venue (cardinality: "one" on the forward edge), and a venue hosts many concerts, so the reverse is many. It is plural, which matches the validator's own guidance ("plural where that end may hold many"), and reads naturally as a traversal from the venue end. It also avoids shadowing any core property. No objection.
Principle — a test's failure mode should be its subject: worth noting that this bug class is invisible precisely because the test still "ran." A fixture that fails during setup reports as a test failure indistinguishable from a real regression, which is why this took a human to diagnose rather than being obvious from CI output.
🟡 Two unrelated commits in one PR — acceptable here, but the red-main fix should land independently
The two commits share no code, no cause, and no reviewer context: one is a test-fixture correction, the other a git-hook change. Under normal circumstances this is a clean split into two PRs (atomicity — a PR should have one reason to be reverted).
Here I would not block on it, but for a specific reason that cuts the other way: main is currently red, and commit e0a4970b fixes it. Bundling an urgent unblock behind a hook change that has an open correctness question (see 🔴) means the red-main fix cannot merge until the hook discussion resolves. That is the actual cost of the bundling, and it argues for splitting now rather than as a matter of principle.
Recommendation: cherry-pick e0a4970b onto its own PR and merge it immediately to green main; keep this PR for the hook, where the rationale needs revision.
🟡 Deferring the Bun pin is the right call, and the reasoning holds up
📁 package.json:107,112
I verified the premises. engines.bun: ">=1.0.0" and packageManager: "[email protected]" are both floors, not pins. bun.lock carries "configVersion": 1 at line 3, and local Bun is 1.2.16 — which strips that key on write, making this machine the outlier relative to the committed format.
The author's reasoning for not pinning here — that choosing the canonical version is a team decision, and pinning from the outlier machine risks stripping configVersion repo-wide — is sound and correctly scoped. Pinning to 1.2.16 from this machine would encode the outlier as canonical and churn the lockfile for everyone else; that is a worse outcome than the current churn.
Principle — separate the mechanism from the policy: fixing the deadlock (mechanism) is a local, reversible engineering decision. Choosing the team's Bun version (policy) has blast radius beyond the author. Splitting them is correct, and the PR body documents the deferral clearly enough that it won't be lost. No change requested — this is the right judgment, recorded well. Worth filing as a follow-up issue so the deferral has a home.
🟢 Hook is POSIX-safe, correctly quoted, and worktree-correct
📁 .husky/post-checkout:17-21
Verified each mechanism:
- POSIX compliance:
sh -nanddash -nboth parse it clean. Husky's runner (.husky/_/h) invokes hooks viash -e "$s" "$@", sodashcompatibility is the relevant bar and it passes. No bashisms ([[, arrays,local). - Quoting:
"$(git rev-parse --git-path "$state")"is correctly quoted at both levels. Nested double quotes inside$(...)are valid POSIX and parse as intended. No word-splitting risk — and none of the state names contain spaces regardless. --git-pathin a worktree: confirmed directly. From a linked worktree it returned/Users/.../.git/worktrees/mainwt/rebase-merge, not the main.git/. This is exactly right and a literal.git/rebase-mergewould have been wrong. Given CLAUDE.md's worktree-per-issue workflow, this detail matters more than usual — good catch by the author.sh -einteraction: the guard exits 0 cleanly; thefor/ifconstruct doesn't trip-e, and a failinggit rev-parseinside a command substitution in anifcondition doesn't either.
🟢 Ordinary checkouts still install
📁 .husky/post-checkout:23-25
The $3 = 1 branch-checkout check is untouched and still gated behind the guard only when sequencing state exists. I confirmed a normal invocation with flag=0 exits 0 without installing, and the flag=1 path is unchanged. No regression for the common case.
🟢 CLAUDE.md compliance
- No lint suppression, no
any, no#[allow(dead_code)]— n/a to both files. - No new
.mdfiles in this repo. Correct. scripts/should be TypeScript, but.husky/hooks are genuinely shell — this is the right read. CLAUDE.md's rule targetsscripts/tooling and explicitly allows shell "where shell is genuinely required." A git hook invoked by git viashbeforebun installhas necessarily run is exactly that case; it cannot be TypeScript. Note the siblingpre-pushhook is a one-line shell shim delegating toscripts/test-gate.ts— the established pattern is thin shell, logic in TS. This hook's logic is small enough that inlining it is proportionate.- Issue numbers in code comments: the hook's comment block references no issue or PR numbers — the author correctly stripped them when moving the rationale from the commit message into the file. The commit messages do reference
#2436/#2437, which is explicitly permitted (process mechanics in commit/PR text). Compliant on both counts — this is a distinction that's easy to get wrong and was gotten right. - No backward-compat/migration code. Correct.
Verdict
COMMENT — one blocking correction to the rationale, plus a recommended split
The engineering here is careful: the --git-path choice is right and non-obvious, the quoting and POSIX compliance are clean, the empirical validation of the original deadlock was real, and the Bun-pin deferral is well-reasoned and honestly documented. The test fix is verified correct and unblocks a genuinely red main.
But the hook ships with a factually incorrect justification — a completed rebase does not re-fire post-checkout, which I confirmed across three scenarios — and that error is load-bearing, because it converts "installs run redundantly" into "installs don't run at all" after a dependency-changing rebase. The change is still net-positive against a deadlock, so this is not a revert; it is a fix the comment and surface the gap request.
Before merge:
- 🔴 Correct the comment at
.husky/post-checkout:11-13— remove the "fires this hook again" claim and state the real trade-off. Add the one-lineechoso the skip is visible rather than silent. - 🟡 Split
e0a4970binto its own PR and merge it now —mainis red and shouldn't wait on the hook discussion.
Optional: add REVERT_HEAD and sequencer to the loop; file a follow-up issue for the Bun pin so the deferral is tracked.
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: COMMENT (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Address Review — all findings addressed🔴 The false safety claim — verified, then closed rather than documentedI reproduced the reviewer's finding independently before changing anything, in a throwaway repo with an instrumented hook logging Exactly one firing, at the start, with The suggested fix was an So End-to-end proof with instrumented copies of both hooks, rebasing across a
The 🟡 Guard set — narrowed, not widenedThe review suggested adding 🟡 Split — done, and it revealed a dependencyThe red-main fix is now #2443, standalone and mergeable, so it need not wait on this PR. Worth flagging: with the fixture commit removed, this branch's own gate now fails on that same red-main test. That is correct behavior, not a regression — it is
The remote for this PR still shows the pre-split commits, since the force-push was correctly blocked by the gate. I will push the split version once #2443 lands. 🟡 Bun pin deferral — confirmed, no change🟢 POSIX/quoting/worktree/CLAUDE.md — confirmed, no change
Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale: The 🔴 finding was addressed by adding a new hook rather than editing a comment — new executable behavior on every developer's machine, which is more than the review asked for and deserves a second look. The guard was also narrowed in the opposite direction from the literal suggestion. My verification is empirical rather than self-assessed, but a second pass should confirm Re-review is best run after #2443 merges and this branch is rebased, so it reviews the final shape against a green base — the same stale-base problem that caused the red main in the first place. 🤖 Generated with Claude Code |
Review TypeRe-Review — prior review
Previous Review Summary
Requirements CheckNo linked GitHub issue and no acceptance criteria. This is in-session maintenance work; the branch is Verification MethodI re-derived every load-bearing claim independently in throwaway repos on git 2.39.5 (Apple Git-154) — the same version the comments cite — rather than accepting the code comments or the author's summary. I ran the actual PR hooks with Confirmed: the central mechanism works
Three specific things I set out to falsify and could not:
Also re-verified: Code Review Findings🟡 New:
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Address Review — both suggestions takenVerdict was APPROVE with two optional, non-gating suggestions. I took both, because the 🟡 one is the same class of defect the first review of this file caught. 🟡
|
| Check | Result |
|---|---|
Rebase over a package.json change |
installs exactly 1 ✅ |
| Two ordinary branch checkouts | installs 2 ✅ |
sh -n / dash -n |
clean ✅ |
| Executable bit | preserved ✅ |
Push is still blocked, and correctly so
The gate fails on object_property_round_trips_through_relationship_get — main's inherited breakage, fixed in #2443, not by anything here. Confirmed it is the only failure. So the remote head remains stale until #2443 lands; the local branch is at 0bef27c7.
Merge order stands: #2443 first to green main, then rebase this branch and push.
Re-Review Decision
Decision: NO RE-REVIEW NEEDED
Rationale: This round changed comments only — git diff shows no non-comment line touched, and the three behaviours were re-verified unchanged after the edit. The reviewer explicitly marked both suggestions as non-gating on an APPROVE verdict, and neither was addressed by altering logic. There is no new functionality, no refactor, and nothing interconnected for a further pass to catch.
🤖 Generated with Claude Code
Git checks out the base commit to begin a rebase, which fires post-checkout. The `bun install` that followed rewrote bun.lock — the committed lockfile carries a `configVersion` key that older Bun releases strip on write — leaving the tree dirty before the first commit was replayed. The rebase then stopped with "cannot rebase: You have unstaged changes", and retrying re-ran the hook and re-dirtied the tree, so it could not make progress without disabling hooks wholesale (`git -c core.hooksPath=/dev/null rebase`). Skip the install while a rebase, merge, or cherry-pick is replaying. Nothing is lost: a sequencing operation ends on a real checkout of the final branch, which fires this hook again — resolving dependencies once against the finished tree rather than once per replayed commit. Uses `git rev-parse --git-path` rather than a literal `.git/` path so it also works inside a worktree, where the state files live under `.git/worktrees/<name>/`. Verified against the original failure: a rebase that previously failed three times in a row now completes with hooks fully enabled and leaves bun.lock clean. Note the guard cannot protect the rebase that introduces it — the base checkout installs the older hook first — so it takes effect once on main. This addresses the mechanism only. The underlying cause is that the repo's Bun version is unpinned (`packageManager: "[email protected]"` and `engines.bun: ">=1.0.0"` are floors, not pins), so a lockfile written by a newer Bun is rewritten by an older one. Pinning is left as a separate decision, since it requires choosing the canonical version for the team. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KHdtH4eZHiU7RzhCuHArQX
…ires post-checkout Review disproved the rationale the rebase guard shipped with. The comment claimed "a sequencing operation ends on a real checkout of the final branch, which fires this hook again". Measured on git 2.39.5, it does not: a rebase fires post-checkout exactly once — the base checkout the guard skips — and fires nothing on completion. Reproduced independently before changing anything. So the guard alone turned "the install runs redundantly" into "the install never runs": a rebase pulling in package.json or bun.lock changes would resolve dependencies zero times. Still better than the unrecoverable deadlock it replaced, but a silent correctness gap. Close it rather than document it. post-rewrite does fire after a replay (verified: `arg=rebase`), so the install moves there — once, against the finished tree, which is also cheaper than the per-commit behavior it replaces. Also drop MERGE_HEAD and CHERRY_PICK_HEAD from the guard. Those operations never fire post-checkout at all, so the states were dead code implying a breadth of coverage this hook does not have. Only rebase is checked now, and the comment says why. Verified end to end with instrumented copies of both hooks: a rebase across a package.json change completes and installs exactly once from post-rewrite; ordinary branch checkouts still install from post-checkout. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KHdtH4eZHiU7RzhCuHArQX
Review found a backend my testing missed, and I reproduced it before writing
this: on `git rebase --apply`, git tears the rebase state directory down BEFORE
firing post-checkout, so no state-file check can see it. Running the real hooks
over a package.json change on that backend dirties the tree mid-replay
("Falling back to patching base and 3-way merge...") and installs twice — the
exact failure this guard exists to prevent.
The guard is left as-is rather than extended, because there is nothing to
extend: the state files are already gone by the time the hook runs. `--apply`
is opt-in (rebase.backend unset here, no tracked file invokes it), so the
narrow uncovered path is acceptable — but the comment claiming "Only rebase is
checked" read as ALL rebases, and a plausible-sounding comment that measurement
contradicts is precisely what the first review of this file caught. Scope the
claim to the merge backend and name the exemption.
Also note the `rebase --abort` gap: skipped on the way in, and post-rewrite
never fires because nothing was rewritten, so no install runs. Harmless — an
abort restores the original HEAD, the tree node_modules already matched — but
better stated than rediscovered.
Comments only; no behavior change. Re-verified after the edit: rebase installs
exactly once, ordinary checkouts install both times, `sh -n`/`dash -n` clean.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KHdtH4eZHiU7RzhCuHArQX
e0a4970 to
f375689
Compare
Two small, independent commits.
mainis currently red — the first commit fixes that and is the one to prioritise.1.
mainis red: a fixture missing its required reverse fieldsobject_property_round_trips_through_relationship_getdeclaresheld_at → venuewith noreverseName/reverseCardinality, which the validation added in #2437 rejects. The test fails at schema creation, before reaching what it exists to verify.Neither PR's gate could have caught it: #2436 added the fixture, #2437 added the rule, and each was validated against a base predating the other. The squash merges landed 33 minutes apart.
This is the third instance of the same failure mode in this sequence — #2437's review caught the identical collision between #2435 and #2437 before merge. The pattern is worth naming: a green pre-push gate proves the branch passes on its base, and says nothing about the merge result. With several PRs in flight touching the same validation surface, that gap is not hypothetical.
A concert is held at one venue and a venue hosts many concerts, so the inverse is
concerts/many.2.
post-checkoutdeadlocks any rebaseGit checks out the base commit to begin a rebase, firing
post-checkout. Thebun installthat followed rewrotebun.lock, leaving the tree dirty before the first commit was replayed:Retrying re-ran the hook and re-dirtied the tree, so the rebase could not progress without disabling hooks wholesale (
git -c core.hooksPath=/dev/null rebase). This cost three failed attempts during #2437.The guard skips the install while a rebase, merge, or cherry-pick is replaying. Nothing is lost: a sequencing operation ends on a real checkout of the final branch, which fires the hook again — resolving dependencies once against the finished tree rather than once per replayed commit. Ordinary checkouts are unaffected.
git rev-parse --git-pathrather than a literal.git/path, so it also works inside a worktree, where the state files live under.git/worktrees/<name>/.Verified against the original failure
Reproduced the deadlock on a throwaway branch, then confirmed the fix: a rebase that previously failed three times in a row completes with hooks fully enabled and leaves
bun.lockclean.One property worth knowing: the guard cannot protect the rebase that introduces it — the base checkout installs the older hook first — so it takes effect once merged.
Root cause is upstream of this fix
The churn exists because the repo's Bun version is unpinned:
packageManager: "[email protected]"andengines.bun: ">=1.0.0"are floors, not pins. The committed lockfile carries aconfigVersionkey that Bun 1.2.16 strips on write, so a lockfile written by a newer Bun is silently reverted by an older one.configVersionhas been in the lockfile since June 2026, so the committed format is the intended one and the older Bun is the outlier.This PR addresses the mechanism, not the cause. Pinning is deliberately left out: it requires choosing the canonical version for the team, and doing it from a machine running the outlier would risk stripping
configVersionrepo-wide.Verification
cargo test --workspace— 2926 passed, exit 0test:all+cargo build --bin nodespaced+ full e2e) — passed in fullbun run skill:check— in syncOne flake seen and confirmed unrelated:
checked_in_skill_md_is_up_to_datefailed once under parallel load, then passed in isolation (11/11) and on a clean full run. It shells out to regenerate skill content while other tests touch the same paths.🤖 Generated with Claude Code
https://claude.ai/code/session_01KHdtH4eZHiU7RzhCuHArQX