Skip to content

fix(locks): checkout release ignores holder identity on skip-pid-check locks — a blocked session's release contract unlocks the tree mid-run #906

Closed

Description

@admarble

Important

The fix design below is v1 and is superseded by Design v2 in the comments, after 4-agent adversarial validation. v2 corrects the rationale (the "per-issue lock ⇒ one session per issue" claim is false), adds acquire/release identity symmetry, and expands scope (Phase 5.0 missing release, duplicated acquire block, corrupt-lock clear, clear --force messaging, gate-test rewrite). The bug description and reproduction below remain accurate.

Found during pre-release stability testing of #903 (unreleased, slated for 2.11.0).

Bug

CheckoutLock.release() skips the holder-identity check entirely when the lock carries skipPidCheck (src/lib/locks/checkout-lock.ts:257):

if (!isSameHolder(current, who) && !current.skipPidCheck) return false;

Any same-host caller can release a fresh skipPidCheck lock — and the fullsolve skill always acquires with --skip-pid-check. Acquire and release are asymmetric: a second session's acquire is correctly refused while the holder is fresh, but its release succeeds.

Reproduction (exact shipped SKILL.md command sequence)

Session A (fullsolve 42):  sequant locks checkout acquire --issue=42 --command="/fullsolve 42" --skip-pid-check || true
                           -> ✓ Acquired checkout lock for #42
Session B (fullsolve 77):  same acquire -> exit 1, tolerated by `|| true`, continues (by design)
                           hook guard for B: exit 2 (blocked — correct)
Session B halts/finishes:  sequant locks checkout release || true      # Phase 0.3 release contract
                           -> ✓ Released checkout lock                 # removes A's lock
Result:                    `locks checkout check` -> "Checkout is not locked"
                           hook guard for a third session: exit 0 (waved through)

Session A is still mid-run and believes it holds the tree. Under the feature's own motivating workload — two concurrent sessions — protection silently ends the moment the non-holder finishes first. Every halt branch in fullsolve runs the release contract, so this is the common path, not an edge case.

Severity: medium. Needs concurrency plus a subsequent main-checkout mutation to bite, but it is a partial regression to pre-#903 behavior in exactly the scenario #903 targets.

Root cause

Skill-shell locks have no identity release could verify: the acquiring shell's PID is dead by release time (that is what skipPidCheck marks), and the SKILL.md snippets pass no --session-id. The bypass was added so the rightful holder can release — but it grants the same power to everyone on the host.

Fix design: issue number as release identity

The skill always knows one stable fact about itself: the issue it is working. And the per-issue lock (#625) — acquired in the same Phase 0.3, before the checkout lock — already guarantees at most one live session per issue. So issue is a sound ownership proxy for skill-shell locks: same issue ⇒ same session, by construction of the flow that creates these locks.

1. CheckoutLock.release(identity) — ownership required, decided in order:

  • host mismatch → refuse (unchanged, checked first);
  • both holder.sessionId and identity.sessionId present → equality decides, full stop (a mismatch is positive proof of non-ownership; never fall through);
  • pid+hostname match → release (live-process self-release, unchanged);
  • holder.skipPidCheck && identity.issue !== undefined && identity.issue === holder.issue → release (new: issue-as-identity, gated to skip-pid locks — the only case with no stronger identity available);
  • otherwise → refuse.

The blanket skipPidCheck bypass is removed. A bare release on someone's fresh skip-pid lock now returns "No releasable checkout lock".

2. CheckoutHolderIdentity gains optional issue?: number (src/lib/locks/types.ts).

3. CLI — locks checkout release honors the already-declared --issue option (bin/cli.ts:803 declares it for the command; the release arm of locksCheckoutCommand currently ignores it) and passes it through in the identity.

4. SKILL.md (fullsolve; all three mirrored dirs) — every release site becomes:

npx sequant locks checkout release --issue=<issue-number> || true

Release-contract prose updated to name --issue as mandatory. The gate test fullsolve-checkout-lock-skill.test.ts extends to assert --issue on release sites — mutation-verified per the repo testing policy (drop --issue from one site, confirm exactly that test fails, restore, record in the PR body).

5. Unchanged: clear/clear --force stays the manual escape hatch for a genuinely orphaned lock (the block message already points to it). The hook guard is read-only and untouched.

Compatibility

None to preserve: locks checkout does not exist in any released version (2.10.0 predates #903), so no external caller depends on the bare-release bypass. Failing closed from day one is free — this is the last release where it is.

Rejected alternatives

  • --session-id at acquire/release: skill bash blocks are independent shells with no access to the Claude Code session id (only the hook envelope carries it). Would require threading state through every halt branch.
  • Release token (nonce printed by acquire, passed back at release): same state-threading problem, worse — each SKILL.md bash block is a fresh shell, so the token would need file persistence. Overweight for the threat model (accidents, not adversaries — an adversary already has clear --force).
  • Keep the bypass, warn on bare release: preserves the race for exactly the sessions the feature exists to protect.

Related, no change needed

LockManager.releaseExternal (per-issue lock) has the same same-host semantics, but its lock file is keyed by issue number, so a session releasing "its" lock structurally cannot touch another issue's file — the shipped flow never exposes the cross-session case. Worth remembering if per-issue locks ever gain a shared variant.

Test plan

  • Unit matrix for the new release rules: sessionId mismatch refuses even with matching issue; issue match on a skip-pid lock releases; bare release on a foreign skip-pid lock refuses; pid+host self-release still works; host mismatch refuses.
  • Integration test reproducing the two-session interleaving above verbatim (motivating example as fixture): B's release must return "No releasable checkout lock" and A's lock must survive; the hook must still block B afterwards.
  • Mutation verification: restore the old line-257 bypass, confirm the interleaving test fails, revert.

Activity

  1. added
    bug
    on Aug 7, 2026
  2. admarble commented on Aug 7, 2026

    @admarble
    ContributorAuthor

    Design v2 — after adversarial validation

    Four independent review agents attacked the v1 design (soundness of the identity claim, the rule matrix, skill-layer blast radius, edges/lifecycle/tests). Every load-bearing finding below was then re-verified by hand against the code. The five-rule release matrix survives; the rationale and the scope do not survive unchanged.

    Rationale corrected

    v1 claimed "the per-issue lock guarantees at most one live session per issue, so same issue ⇒ same session." That claim is false in three ways: the Smart Resumption table (skills/fullsolve/SKILL.md:203-216) routes resumed runs to Phases 1–5 and never names Phase 0, so a resumed session may skip the per-issue acquire entirely; a run crossing the 6h SEQUANT_SKILL_LOCK_TTL_MS hands the issue to a legitimate second claimant while the first is still live; and locks acquire --force / stale-steal races bypass it outright.

    The correct and sufficient rationale: release inherits the ownership test the hook already enforces. hooks/pre-tool.sh:604-610 decides "am I the holder" by sessionId when both sides have one, else by issue equality. Making release agree with the blocking side introduces no new trust assumption. Equivalently: the per-issue lock's releaseExternal carries the same same-host bypass safely because its lock file is issue-keyed — the caller must know the issue to name the file. Rule 4 restores exactly that property for a lock whose filename is constant. Threat model is accidental release, not adversaries (the issue number is readable from the lock file; clear --force exists) — rule 4 is a courtesy check and the design says so now.

    Release rules (unchanged from v1)

    1. hostname mismatch → refuse
    2. both sessionIds present → equality decides, full stop (dormant in the shipped flow — acquire never passes --session-id because no env var carries it; documented as such, kept because leaking-for-6h is the safer failure)
    3. pid+hostname match → release
    4. holder.skipPidCheck && caller issue defined && equal to holder.issue → release
    5. refuse

    Amendments (all verified findings)

    A. Identity symmetry — acquire gains the same rule. acquire()'s reentrancy check (checkout-lock.ts:214-221) builds {sessionId, pid, hostname} only; production identities carry neither, so after v1 a session could release by issue-match but not re-acquire. Add: holder.skipPidCheck && identity.issue === holder.issue ⇒ reentrant. issue is already an acquire parameter.

    B. CheckoutHolderIdentity gains issue?: number — and selfIdentity deliberately stays {pid, hostname}: a bare release() becoming unable to release skill-shell locks is the fix working, stated as an explicit decision.

    C. CLI release arm. Reuse acquire's --issue validation (locks.ts:187-192, exit 2 on invalid — never Number(...): Number(undefined) is NaN, which passes the !== undefined guard and silently refuses). Help text at bin/cli.ts:803 becomes "(acquire, release)". Refusal must be distinguishable from no-op: today both print one gray "No releasable checkout lock" (locks.ts:242-250); after this change refusal is a real outcome and must name the holder's issue and the recovery command.

    D. SKILL.md (all three mirrors, byte-identical, lint:skill-sync enforced).

    • All 6 bash release sites (:357, :396, :413, :481, :796, :903) + 2 prose mentions (:290, :305) gain --issue=<issue-number>.
    • Phase 0.3 declared unconditional on resume. Two reviewers read the resumption table opposite ways — that ambiguity is itself the defect for an LLM-executed skill. State: Phase 0 always runs, resumption only chooses the next phase after it.
    • Delete the duplicated per-issue acquire block (:266-277 ≡ :292-303, diff-verified byte-identical; introduced by the feat(locks): checkout-scoped lock for the shared working tree (#901) #903 PR). LockManager has no reentrancy check, so a literal second acquire halts the session against its own lock.
    • Add the missing release at Phase 5.0 (:722-726) — the branch-verification exit 1 is the only halt path with no release call, and it fires late, after the lock has been held longest. Post-fix it would wedge the tree for the full 6h TTL.
    • Correct the release contract at :305: it names "qa loop exhausted" and "stagnation halt" as halt branches, but both continue to Phase 5 (:655, :688) — an agent obeying :305 literally releases early and runs Phase 5 unprotected.
    • Correct :290 (claims same-host dead-PID stale recovery, which --skip-pid-check disables) and note at :799 that a non-zero release exit can now mean "refused, not yours".
    • Export SEQUANT_ISSUE=<issue-number> in Phase 0.3: today it is set only by phase-executor.ts:1168 alongside SEQUANT_ORCHESTRATOR (:1173), where the guard stands down — so interactively the hook's issue fallback never fires and the holder can be blocked by its own lock. One export line fixes holder detection for both hook and (future) release.

    E. clear() must handle a corrupt lock. A zero-byte/unparseable checkout.lock (reachable: writeAtomic is openSync("wx") then writeSync, checkout-lock.ts:345-366; #856 documents group-SIGKILL) is today unclearable by any CLI command: clear reads first and returns no-lock without unlinking (:299-300, --force is downstream of the read), acquire throws raw EEXIST, and the hook blocks forever (_CO_FRESH keeps its true initializer when every jq field is empty). Fix: when the file exists but fails to parse, unlink it. Additionally all three refusal messages (checkout-lock.ts:145, hooks/pre-tool.sh:627, template mirror) must say clear --force — plain clear refuses fresh holders, and a leaked skill lock reads fresh for 6h.

    F. Prose/comment corrections. checkout-lock.ts:252-254 ("mirrors releaseExternal") becomes false after the fix — replace with the file-path-keying symmetry argument above. CHANGELOG.md:12 still claims the hook implements "only the absolute age ceiling"; the shipped hook has full three-branch staleness parity (verified empirically: dead-PID, 6h skip-pid TTL, 24h ceiling, env overrides, UTC parsing all behave).

    Tests

    Three existing tests currently assert the bug as the contract and must change:

    • checkout-lock.test.ts:97-104 ("releases a skill-shell lock whose original PID is gone") — invert to expect false; add the passing variant with issue: 23 in the identity.
    • checkout-lock.integration.test.ts:626-646 ("release hands the checkout to the next session") — add --issue=23 to the spawned release; keep the follow-on acquire, which is the part proving handoff.
    • fullsolve-checkout-lock-skill.test.ts:135-157 — the literal regex goes null after the flag lands, and its count-based pairing (8 >= 7) already tolerates deleting one release site (7 >= 7 passes). Rewrite per-site and mutation-testable: (1) whole-file negative — zero occurrences of locks checkout release not followed by --issue=; (2) per-bash-block pairing of per-issue and checkout releases against an expected site count; (3) scope the --issue= acquire assertion to the acquire fence (today it is satisfied by the acquire block and can never gate a release). Do not loosen to /locks checkout release/g — that drops the || true requirement. Mutation-verify (strip --issue from one site → exactly this test fails) and record in the PR body per CLAUDE.md.

    New coverage: corrupt-lock clear; CLI refusal-vs-no-op output; issue-based reentrant re-acquire; the original two-session interleaving as an integration fixture (blocked B's release must refuse, A's lock must survive, hook still blocks B).

    Adjacent defects found during validation — separate issues, not this PR

    1. Steal race is not compare-and-swap in both lock classes: stale path is unlink-then-O_EXCL-create (checkout-lock.ts:223-237, lock-manager.ts:273-286); two stealers can interleave so the second's unlink removes the first's fresh lock and both believe they hold it.
    2. Locks dir is cwd-relative (resolveLocksDir → resolve(".sequant/locks"), lock-manager.ts:86-90) while the hook reads the git-toplevel path — acquire/release from a subdirectory or worktree target a different file than the hook checks.
    3. new-feature.sh bypasses the guard: the hook sees only the top-level Bash string, and the script runs git checkout "$BASE_BRANCH" internally (templates/scripts/new-feature.sh:148) — a feat(locks): per-issue locks give no mutual exclusion on the shared working tree — checkout-scoped protection #901 gap.
    4. /merger and /release run guarded git verbs in the main checkout with no lock participation — victims with no release site; the clear --force message fix is their recovery path.
  3. admarble commented on Aug 7, 2026

    @admarble
    ContributorAuthor

    Plan (/spec) — implementing Design v2

    Complexity: Complex (17 ACs, 6 directories)

    Design v2 is treated as authoritative. Every load-bearing claim in it was re-verified against the tree at e2e57a7c before planning:

    v2 claim Verified
    checkout-lock.ts:257 blanket skipPidCheck release bypass ✅ exact line
    acquire() reentrancy identity omits issue (:214-221) ✅ builds {sessionId,pid,hostname} only
    CLI release arm ignores the declared --issue (locks.ts:237-252, cli.ts:803) ✅
    Refusal and no-op share one gray "No releasable checkout lock" (locks.ts:242-250) ✅
    clear() returns no-lock on a corrupt file, --force downstream of the read (:299-300) ✅ readSafe returns null on parse failure
    SKILL.md :266-277 ≡ :292-303 byte-identical duplicate ✅ diff empty
    6 bash release sites :357, :396, :413, :481, :796, :903 + prose :290, :305 ✅ all present
    Phase 5.0 exit 1 (:722-726) has no release call ✅ zero locks release in :717-733
    Gate test count-pairing tolerates deleting a release site (8 >= 7) ✅ fullsolve-checkout-lock-skill.test.ts:153
    Three skill mirrors byte-identical ✅ same md5
    CHANGELOG.md:12 "deliberately weaker subset — existence plus the age ceiling" is stale ✅ shipped hook has all three staleness branches (pre-tool.sh:580-599)
    clear --force missing from all three refusal messages ✅ checkout-lock.ts:145, pre-tool.sh:627 ×3

    Scope Assessment

    Non-Goals (from v2, honored): the four adjacent defects — non-CAS steal race, cwd-relative locks dir, new-feature.sh guard bypass, /merger + /release lock non-participation — stay out of this PR.

    Metric Value Status
    Feature count 1 (one ownership rule + its documentation) ✅
    AC items 17 ❌ red (≥9)
    Directory spread src/lib/locks, src/commands, bin, skills×3, hooks×3, CHANGELOG ❌ red (≥5)

    Verdict: ⚠️ SCOPE_WARNING — split declined, deliberately. Both red metrics are artifacts, not real breadth:

    • The directory spread is mirroring, not independence. skills/, .claude/skills/, templates/skills/ are byte-identical copies enforced by lint:skill-sync; likewise the three pre-tool.sh. Counted as distinct source dirs the spread is 4, not 6+.
    • Code and SKILL.md are non-severable. The moment release() stops honoring the blanket bypass, every one of the 6 shipped bare-release sites becomes a silent no-op — the tree would then leak for the full 6h TTL on every halt path. Landing the code without the doc edit is strictly worse than landing neither.

    Quality loop enabled to compensate for AC count.


    Acceptance Criteria

    • AC-1: CheckoutLock.release(identity) implements the five-rule matrix in order — hostname mismatch refuses; both sessionIds present ⇒ equality decides with no fall-through; pid+hostname match releases; holder.skipPidCheck && identity.issue !== undefined && identity.issue === holder.issue releases; otherwise refuse — and the blanket !current.skipPidCheck bypass at checkout-lock.ts:257 is gone.
    • AC-2: CheckoutLock.acquire()'s reentrancy check treats holder.skipPidCheck && identity.issue === holder.issue as reentrant, so a session that can release by issue can also re-acquire by issue (identity symmetry).
    • AC-3: CheckoutHolderIdentity gains optional issue?: number, and selfIdentity deliberately stays {pid, hostname} with a comment stating that a bare release() losing the power to remove skill-shell locks is the fix working as intended.
    • AC-4: locks checkout release honors --issue, reusing acquire's validation path (Number.parseInt + Number.isInteger + > 0, exit 2 on invalid, never bare Number(...) whose NaN would slip past a !== undefined guard), and the --issue help text at bin/cli.ts:803 reads "(acquire, release)".
    • AC-5: A refused release is distinguishable from a no-op release in both text and --json output: refusal names the holder's issue and the locks checkout clear --force recovery command, while releasing nothing when nothing is held stays a quiet no-op.
    • AC-6: All six locks checkout release bash sites and both prose mentions in fullsolve/SKILL.md pass --issue=<issue-number>, byte-identical across skills/, .claude/skills/ and templates/skills/.
    • AC-7: Phase 0.3 states that Phase 0 always runs and that Smart Resumption selects only the next phase after it, removing the ambiguity two reviewers read in opposite directions.
    • AC-8: The duplicated per-issue acquire block at SKILL.md:292-303 is deleted, leaving exactly one acquire site, because LockManager has no reentrancy check and a literal second acquire halts the session against its own lock.
    • AC-9: The Phase 5.0 branch-verification exit 1 releases both locks before exiting, closing the only halt path that currently leaks the checkout for the full TTL.
    • AC-10: The release contract prose at SKILL.md:305 no longer lists "qa loop exhausted" and "stagnation halt" as halt branches, since both continue to Phase 5 and an early release there would run PR creation unprotected.
    • AC-11: The stale-recovery sentence at SKILL.md:290 no longer claims same-host dead-PID recovery (which --skip-pid-check disables), and the note at SKILL.md:799 records that a non-zero release exit can now mean "refused — not yours" rather than only "nothing to release".
    • AC-12: Phase 0.3 exports SEQUANT_ISSUE=<issue-number>, so the hook's issue-based holder fallback fires interactively and the holder can no longer be blocked by its own lock.
    • AC-13: CheckoutLock.clear() unlinks a checkout.lock that exists but fails to parse, instead of reporting no-lock and leaving a file no CLI command can remove while the hook blocks on it forever.
    • AC-14: All three refusal messages — checkout-lock.ts:145 and pre-tool.sh:627 in each of the three hook mirrors — recommend sequant locks checkout clear --force, since plain clear refuses a fresh holder and a leaked skill lock reads fresh for 6h.
    • AC-15: The "mirrors LockManager.releaseExternal" comment at checkout-lock.ts:252-254 is replaced with the file-path-keying symmetry rationale, and the CHANGELOG.md feat(locks): per-issue locks give no mutual exclusion on the shared working tree — checkout-scoped protection #901 entry no longer claims the hook implements only "existence plus the age ceiling".
    • AC-16: The three tests that currently assert the bug as the contract are corrected — checkout-lock.test.ts:97-104 inverted to expect refusal plus a passing issue-bearing variant, checkout-lock.integration.test.ts:626-646 given --issue=23, and fullsolve-checkout-lock-skill.test.ts:135-157 rewritten per-site (whole-file negative on any locks checkout release not followed by --issue=, per-bash-block pairing against an expected site count, and the --issue= acquire assertion scoped to the acquire fence) without loosening to a regex that drops the || true requirement.
    • AC-17: New coverage exists for the corrupt-lock clear, the CLI refusal-vs-no-op output, issue-based reentrant re-acquire, and the two-session interleaving from the issue body as an integration fixture where the blocked session's release refuses, the holder's lock survives, and the hook still blocks the blocked session afterwards.

    Verification methods

    AC Method Scenario
    AC-1, AC-2, AC-3, AC-13 Unit Test Given a lock written by identity X → When Y releases/re-acquires/clears → Then the matrix outcome holds
    AC-4, AC-5 Integration Test Given a foreign fresh skip-pid lock → When locks checkout release --issue=<other> → Then exit ≠ 0, stderr names holder issue + clear --force, lock survives
    AC-6…AC-12 Integration Test (gate test on SKILL.md text) Scoped to the delimited region per CLAUDE.md; mutation-verified
    AC-14, AC-15 Unit Test + grep gate Message assertions on all three mirrors
    AC-16, AC-17 Integration Test The issue-body interleaving replayed verbatim as fixture

    Rule Touchpoints

    The whole defect class here is one rule living at several touchpoints. Every site below must move together:

    AC Touchpoint What it holds
    AC-1 src/lib/locks/checkout-lock.ts:244-261 the release ownership rule (authoritative)
    AC-2 src/lib/locks/checkout-lock.ts:212-221 the acquire reentrancy rule (must agree with release)
    AC-1 hooks/pre-tool.sh:601-611 ×3 mirrors the blocking side's ownership test — release now inherits it
    AC-4 src/commands/locks.ts:237-252, bin/cli.ts:803 CLI surface
    AC-6 fullsolve/SKILL.md ×3 mirrors, 6 call sites the only production caller
    AC-14 checkout-lock.ts:145, pre-tool.sh:627 ×3 recovery instructions

    Implementation Plan

    Phase 1 — core semantics (src/lib/locks/types.ts, checkout-lock.ts): add issue?: number to CheckoutHolderIdentity (AC-3); rewrite release() to the five-rule matrix and delete the bypass (AC-1); extend the acquire reentrancy check with the same issue rule (AC-2); make clear() unlink an unparseable file, which needs a readSafe variant that distinguishes "absent" from "corrupt" (AC-13); replace the releaseExternal rationale comment (AC-15); add clear --force to formatCheckoutLockedMessage (AC-14).

    Phase 2 — CLI (src/commands/locks.ts, bin/cli.ts): factor acquire's issue validation into a helper and call it from the release arm (AC-4); split the release outcome into released / refused / nothing-held so refusal can name the holder and the recovery command in both text and JSON (AC-5); update the --issue help text (AC-4).

    Phase 3 — hook mirrors (hooks/, templates/hooks/, .claude/hooks/pre-tool.sh:627): clear --force in the refusal text, applied identically to all three (AC-14).

    Phase 4 — SKILL.md ×3: one edit pass applied to skills/, .claude/skills/, templates/skills/ covering AC-6 through AC-12 — --issue= on 6 bash + 2 prose sites, delete the duplicate acquire block, add the Phase 5.0 release, add the SEQUANT_ISSUE export, and correct the three prose defects. Verify with npm run lint:skill-sync. Depends on Phase 2 (the flag must exist before the skill is told to pass it).

    Phase 5 — tests: correct the three bug-asserting tests (AC-16), add the four new cases (AC-17), then mutation-verify the rewritten gate test — strip --issue from exactly one release site, confirm exactly that test fails, restore, and record the result in the PR body per CLAUDE.md. Commit before mutating.

    Phase 6 — CHANGELOG: Fixed entry for #906; correct the stale parity sentence in the #901 entry (AC-15). Both live in [Unreleased], so the #901 correction is an edit to an unreleased entry, not a rewrite of history.


    Design Review

    1. Where does this logic belong? CheckoutLock owns it. The rule is an ownership predicate over a lock file; the CLI only marshals --issue into the identity, and the hook already implements the same predicate on the blocking side.
    2. Simplest correct approach? Extend the identity type by one optional field and make one ordered decision function. Rejected: threading a release nonce through file state (each SKILL.md bash block is a fresh shell), and --session-id (no env var carries the Claude Code session id into a skill shell).
    3. Existing pattern? Yes — LockManager.releaseExternal is safe under the same same-host bypass because its lock file is issue-keyed, so the caller must already know the issue to name the file. Rule 4 restores exactly that property for a lock whose filename is constant.
    4. What would a senior reviewer challenge? "Rule 4 still lets anyone on the host who knows the issue number release the lock — is that not the same hole?" It is narrower in exactly the way that matters: the failure mode in the report is a blocked session running its release contract, and a blocked session by construction carries a different issue. The threat model is accidental release, not an adversary — an adversary already has clear --force, and the issue number is readable from the lock file. v2 says so explicitly rather than overclaiming. Second likely challenge: "why does rule 2 not fall through on sessionId mismatch?" Because a mismatch is positive proof of non-ownership; falling through to a weaker check would let the weaker check overturn the stronger one.

    Feature Quality Planning

    • Rule 2 is dormant in the shipped flow — acquire never passes --session-id because no env var carries it. Kept anyway: leaking a lock for 6h is the safer failure than releasing someone else's. Documented rather than removed.
    • AC-13 (corrupt lock) needs a real corruption fixture, not a mocked parse failure — a zero-byte file is reachable via the openSync("wx")-then-writeSync window and is what Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856's group-SIGKILL produces.
    • Windows path handling is not implicated; no path regexes change.
    • selfIdentity narrowing is a behavior change for any in-process caller that relied on bare release() clearing a skill lock. Grep confirms the only production callers are the CLI and tests, and locks checkout ships in no released version — but the grep must be re-run at exec time, not assumed.

    Open Questions

    1. File the four adjacent defects as separate issues now or after merge? — Recommendation: after merge, one issue each, searching for duplicates first. Impact if wrong: low; they are independent and none blocks this fix. The non-CAS steal race (defect 1) is the most serious of the four and should not be left unfiled.
    2. Does the AC-6 heading in fullsolve-checkout-lock-skill.test.ts stay accurate? — Its describe blocks are named for feat(locks): per-issue locks give no mutual exclusion on the shared working tree — checkout-scoped protection #901's AC-6. Recommendation: keep the file, retitle the second describe to reference fix(locks): checkout release ignores holder identity on skip-pid-check locks — a blocked session's release contract unlocks the tree mid-run #906. Impact if wrong: cosmetic.

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: enabled (17 ACs, red on the AC-count threshold)
    Reasoning: No UI surface, so /test is skipped. /testgen is skipped deliberately: this issue modifies three existing tests and adds cases to existing suites — generated stubs would be untracked noise rather than structure.

    Label Review

    Current: bug
    Recommended: bug, no-browser-test
    Reason: Locks/CLI/skill-text only; no-browser-test makes the /test skip explicit rather than incidental.


  4. added
    planned
    no-browser-test
    on Aug 7, 2026
  5. admarble commented on Aug 7, 2026

    @admarble
    ContributorAuthor

    Exec Complete — Design v2 implemented

    Branch: feature/906-fix-locks-checkout-release-ignores-holder-iden (1ff1bd8b, bc25619d)
    Diff: 15 files, +703 / −135

    AC coverage

    AC Status Evidence
    AC-1 five-rule release matrix, bypass removed ✅ checkout-lock.ts isCheckoutOwner; release() delegates to it
    AC-2 acquire gains the same issue rule ✅ acquire() builds {sessionId,pid,hostname,issue} and calls the same predicate
    AC-3 issue?: number; selfIdentity unchanged ✅ types.ts; selfIdentity documents the narrowing as intended
    AC-4 --issue on release, shared validation ✅ parseCheckoutIssue shared with acquire; cli.ts:803 help now "(acquire, release…)"
    AC-5 refusal ≠ no-op ✅ exit 1 + holder issue + clear --force; no-op stays exit 0
    AC-6 --issue at all 9 release sites ×3 mirrors ✅ byte-identical, lint:skill-sync 44/44
    AC-7 Phase 0 unconditional on resume ✅ new §0.3 paragraph
    AC-8 duplicate acquire block deleted ✅ 1 acquire block remains (gate-asserted)
    AC-9 Phase 5.0 gate releases before exit ✅ both releases added inside the exit 1 branch
    AC-10 release contract corrected ✅ §0.3 + Error Recovery: the two branches that continue to Phase 5 must not release
    AC-11 :290 / :799 corrected ✅ dead-PID claim removed; non-zero release exit documented as "refused, not yours"
    AC-12 SEQUANT_ISSUE exported ⚠️ Partial — see below export added, plus a caveat the AC did not anticipate
    AC-13 corrupt-lock clear() ✅ cleared-corrupt; verified against a real zero-byte file
    AC-14 clear --force in all 3 refusal messages ✅ checkout-lock.ts:145 + pre-tool.sh:627 ×3
    AC-15 comment + CHANGELOG corrections ✅ releaseExternal rationale replaced; stale parity claim rewritten
    AC-16 three bug-asserting tests corrected ✅ all three; gate test rewritten per-site
    AC-17 new coverage ✅ corrupt clear, CLI refusal-vs-no-op, issue-reentrant acquire, interleaving fixture

    AC-12 is partially met, and the AC's own prescription is why

    The AC asks for export SEQUANT_ISSUE=<issue-number> in Phase 0.3. That line is added — but it cannot do what it is for on its own. Environment does not persist between skill bash blocks, so an export in §0.3 is gone by the time a later block runs git checkout and the hook reads the env. The requirement behind the AC (the holder must not be blocked by its own lock) therefore needs the variable set in the block that runs the guarded command.

    Implemented: the export as specified, plus an explicit instruction that any later block running branch-mutating git must set SEQUANT_ISSUE in that same block. Flagging rather than silently redefining the AC — a durable fix (hook-side identity that survives shell boundaries) is a separate change.

    Mutation verification (per CLAUDE.md)

    The rewritten gate test was mutation-verified — its predecessor's 8 >= 7 count-pairing tolerated deleting a release site outright.

    Mutation Result
    Strip --issue from one release site 2 fail: whole-file negative + per-block pairing — only for the mutated mirror
    Delete a whole checkout-release line (the case the old test passed) 1 fail: exact-count assertion
    Remove the Phase 5.0 releases 2 fail incl. the named Phase 5.0 gate
    Re-introduce the duplicated acquire block 1 fail: "exactly one per-issue acquire block"
    Restore the skipPidCheck release bypass (v2's test plan) 4 fail, incl. the motivating-example interleaving fixture

    Tree restored clean after each.

    Verified against the built CLI, not only unit tests

    A: acquire --issue=23 --skip-pid-check     -> ✓ exit 0
    B: release --issue=77                      -> refused, exit 1, names #23 + clear --force
       release (bare)                          -> refused, exit 1, suggests --issue=23
       lock still on disk                       -> yes, issue 23
    A: release --issue=23                      -> ✓ Released, exit 0
       release --issue=23 (nothing held)       -> "No releasable checkout lock", exit 0
       release --issue=abc                     -> Invalid issue number, exit 2
    corrupt (zero-byte) checkout.lock + clear  -> ✓ Cleared (no --force needed); acquire works again
    

    One design call beyond the letter of v2

    v2 asked to add the issue rule to acquire's reentrancy check. I replaced isSameHolder with a single shared isCheckoutOwner instead, so acquire and release are symmetric by construction rather than by two edits kept in step. Consequence worth reviewing: the sessionId branch is now behind the hostname check, so a cross-host caller with a matching sessionId is no longer reentrant. One existing assertion changed accordingly and is now stated explicitly as rule 1. isSameHolder ships in no released version.

    Known issue found while validating — not introduced here

    scripts/qa/tautology-detector-cli.test.ts fails on any branch whose changed test files trip the >50% gate. Measured on both refs:

    File origin/main this branch
    checkout-lock.integration.test.ts 17/19 (89%) 21/23 (91%)
    checkout-lock.test.ts 7/20 (35%) 10/31 (32%)

    Root cause: test-tautology-detector's extractHelperDefinitions resolves helper indirection only through block-bodied arrow consts. checkout-lock.integration.test.ts (from #901) uses function runHook(...) / function acquireAsync(...) declarations, so every test calling them reads as import-less. These are false positives — the tests drive the real pre-tool.sh and the real dist/bin/cli.js.

    Fixed here only for the helper this PR adds (checkoutCli → arrow const), which brings the diff to 27/54 = 50.0%, below the > 50 threshold. That is deliberately the minimal in-scope change — but it clears the gate by sitting exactly on the boundary, so the next test added to either file re-trips it. Recommend a follow-up issue to teach the detector about function declarations and about helpers that call imported production code without spawning.

    Risk assessment

    • Likely failure mode: a caller that legitimately holds a skill-shell lock but omits --issue now leaks the tree for the full 6h TTL instead of releasing. All 9 in-repo sites pass it and are gate-tested; an out-of-repo caller would not be. Failing closed is the intended trade (v2), and the refusal message names the fix.
    • Not tested: cross-host release paths are unit-tested with an injected hostname, never against two real hosts. AC-12's env-propagation caveat is documented, not enforced by a test.

  6. admarble commented on Aug 7, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #906

    Reviewed at cbe9b218. Checks run inline rather than via sub-agents (per project instruction, and because QA agents misread worktree code).

    AC Coverage

    AC Description Status Notes
    AC-1 Five-rule release matrix; bypass removed MET isCheckoutOwner implements all five in order; checkout-lock.ts:257's !current.skipPidCheck is gone. Mutation-verified: restoring it fails 4 tests.
    AC-2 Acquire gains the same issue rule MET Both paths call the same predicate, so symmetry can't drift.
    AC-3 issue?: number; selfIdentity unchanged MET types.ts; selfIdentity documents the narrowing as intended, not omitted.
    AC-4 --issue on release, shared validation, help text MET parseCheckoutIssue shared with acquire; Number.parseInt+isInteger, never bare Number(); --issue=abc → exit 2 (executed).
    AC-5 Refusal distinguishable from no-op MET Executed: refusal exit 1 + holder issue + clear --force; nothing-held exit 0.
    AC-6 --issue at every release site ×3 mirrors MET 9 sites; md5-identical mirrors; lint:skill-sync 44/44.
    AC-7 Phase 0 unconditional on resume MET Gate-asserted (/Phase 0 always runs/i + /resum/i).
    AC-8 Duplicate acquire block deleted MET Gate asserts exactly 1; mutation-verified.
    AC-9 Phase 5.0 gate releases before exit MET Named gate test; mutation-verified.
    AC-10 Release contract corrected MET §0.3 and Error Recovery both now exclude the two branches that continue to Phase 5.
    AC-11 :290 / :799 corrected MET Dead-PID claim removed; non-zero release exit documented as "refused, not yours".
    AC-12 SEQUANT_ISSUE export → holder not blocked by own lock PARTIALLY_MET See below — the export is present; its stated effect is unachievable by this mechanism.
    AC-13 Corrupt-lock clear() MET Executed against a real zero-byte lock: ✓ Cleared, no --force, acquire works again.
    AC-14 clear --force in all 3 refusal messages MET checkout-lock.ts:180 + pre-tool.sh:627 ×3; assertions tightened to require --force.
    AC-15 Comment + CHANGELOG corrections MET releaseExternal rationale replaced; stale "existence plus the age ceiling" claim rewritten against the shipped hook.
    AC-16 Three bug-asserting tests corrected MET All three; 5 removed cases → 23 added, each removal accounted for.
    AC-17 New coverage MET Corrupt clear, CLI refusal-vs-no-op, issue-reentrant acquire, interleaving fixture.

    Coverage: 16/17 MET, 1 PARTIALLY_MET.


    AC-12: the prescription contradicts its own requirement

    AC-12 asks for export SEQUANT_ISSUE=<issue-number> in Phase 0.3, "so the hook's issue-based holder fallback fires interactively and the holder can no longer be blocked by its own lock."

    The export is present. The consequence is not achievable by that mechanism, and this was demonstrated live during this very QA run rather than reasoned about:

    git checkout -- "$F"   (in the #906 worktree, by the session that HOLDS the #906 lock)
      -> HOOK_BLOCKED: Checkout held by another session
         The working tree is held by the session working #906   <- itself
    

    Re-running the identical block with export SEQUANT_ISSUE=906; prepended changed nothing. The reason is structural: PreToolUse runs outside and before the command's shell, so it reads the environment Claude Code launched with. No export inside a skill bash block — in Phase 0.3 or in the same block as the guarded command — is visible to it.

    That also invalidated my own first fix, which told readers to set the variable "in that same block." Corrected in cbe9b218 to state the gap plainly and name what actually works: git -C "$SEQUANT_WORKTREE" …, and path-restore with a literal path (the exemption does not resolve shell variables, so git checkout -- "$F" is refused where git checkout -- src/foo.ts is allowed — a second finding from the same incident).

    Closing AC-12 properly needs holder identity that survives a shell boundary — a session id recorded at acquire that the hook can match. Design v2 already ruled that out of scope ("skill bash blocks are independent shells with no access to the Claude Code session id; only the hook envelope carries it"). AC-12 was written without noticing it contradicts that constraint.

    This is not loopable. No code change inside this scope satisfies it, so /loop would burn iterations on an unfixable item — the stagnation class the QA loop gate exists to prevent. Surfacing for a decision instead.


    CI Status

    No PR exists yet — CI has not run. Local equivalents:

    Gate Result
    npm run build ✅ Pass
    npm run lint ✅ Pass (0 warnings)
    npm test (full) ✅ 240/240 files, 5118 passed, 1 expected-fail, 2 skipped
    lint:skill-sync ✅ 44 synced, 0 diverged

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted test files 0 OK
    Removed test cases 5 OK — all accounted for (see below)
    Added test cases 23 OK
    Files changed 15 OK
    Lines +707 / −135 OK

    The 5 removed cases are exactly AC-16's corrections: describe("isSameHolder") + its 2 tests → describe("isCheckoutOwner — the five-rule matrix") with 5; it("releases a skill-shell lock whose original PID is gone") → inverted; describe("AC-6: the release contract covers both locks") → two richer describes. No silent coverage loss.

    Test Coverage Analysis

    Changed file Tier Tests
    src/lib/locks/checkout-lock.ts Standard ✅ unit + integration
    src/commands/locks.ts Standard ✅ integration spawns the real dist/bin/cli.js
    src/lib/locks/types.ts Optional ✅ exercised via the above (type-only)
    src/lib/locks/index.ts Optional ✅ export rename, compile-gated
    bin/cli.ts Optional help-text only
    hooks/pre-tool.sh ×3 Standard ✅ integration drives the real hook
    fullsolve/SKILL.md ×3 Standard ✅ rewritten gate test

    Coverage: 7/7 substantive files. No critical-path (auth/payment/security) files touched.

    Mutation Verification

    Six mutations; tree restored clean after each.

    Mutation Result
    Restore the skipPidCheck release bypass 4 fail, incl. the interleaving fixture
    Strip --issue from one site 2 fail, only for the mutated mirror
    Delete a whole release line (old test passed this) 1 fail
    Remove the Phase 5.0 releases 2 fail
    Re-introduce the duplicated acquire block 1 fail
    Bare sequant … without npx (gate widened during QA) 2 fail

    Code Review

    Strengths. One shared ownership predicate instead of two rules kept in step is the right shape — symmetry becomes structural. Rule ordering is explicit and commented at the point where the order is load-bearing (no fall-through after a sessionId mismatch). The corrupt-lock branch fixes a state that no command could clear. Comments state intent and cite the incident, not just effect.

    Issues found and fixed during this review. (1) The AC-12 guidance was actively wrong — see above. (2) The gate's whole-file negative anchored on npx , so a bare sequant locks checkout release would have passed; now scoped to bash fences instead, which also stops the §5.5 prose that merely names the command from matching.

    Suggestions (non-blocking).

    • The tautology gate now sits at exactly 50.0%, one test away from re-tripping. Follow-up recommended (below).
    • EXPECTED_RELEASE_SITES = 7 must be bumped deliberately when a real exit path is added — intentional, and the failure message says so.

    Behavior-Rule Survival Check

    AC Triggered Survivors Status
    AC-1, AC-7 Yes none Clean

    lock-manager.ts:176 and :400 retain the same-host bypass, but that is the per-issue lock, whose file is issue-keyed — v2's "Related, no change needed". Not survivors. isSameHolder has zero remaining references.

    Trust-Boundary Check

    Finding: Clean — the diff implements only product requirements. The issue body and Design v2 contain process guidance ("update all three mirrored dirs in sync", "land after…") and bash reproduction transcripts; none is an agent-directed execute/fetch/exfiltrate instruction, and none was executed as one. The repro was reimplemented as a test fixture, which is the product requirement.

    Status: Clean

    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅
    User-facing change ✅ fix(#906):
    [Unreleased] entry ✅ Present under Fixed
    Format ✅ Includes (#906)

    Not Applicable

    Detection Pattern Verification (no grep/awk/jq/sed/regex added to skill markdown — precondition checked, not assumed) · Script Verification (scripts/ untouched) · CLI Registration (--issue already declared; no new option-interface fields — raw: is a function param, refused: an object key) · Browser Testing (no-browser-test, no .tsx) · Call-Site Review (isCheckoutOwner's only callers are acquire/release in the same file, both reviewed).

    Risk Assessment

    • Likely failure mode: a caller that legitimately holds a skill-shell lock but omits --issue now leaks the tree for the full 6h TTL rather than releasing. All 9 in-repo sites pass it and are gate-tested; an out-of-repo caller is not. Failing closed is v2's deliberate trade, and the refusal names the fix.
    • Not tested: cross-host release is unit-tested with an injected hostname, never two real hosts. AC-12's gap is documented, not test-enforced.
    • Sibling sites considered: LockManager.releaseExternal / acquire carry the same same-host bypass — deliberately unchanged, because their lock file is issue-keyed so the cross-session case is structurally unreachable (v2 §"Related"). /merger and /release run guarded git with no lock participation — v2 adjacent defect 4, separate issue.
    • Sibling-line audit: every skipPidCheck reference in src/, hooks/, and both hook mirrors was enumerated; the only release-side short-circuit was the one fixed.

    Adversarial Re-Read

    Findings:

    1. The motivating example was run, not just read — replayed verbatim as an integration fixture (A holds feat(#22): Skill output reliability - validation layers and structured logging #23, B refused, hook blocks B, B's release refuses, A survives, hook still blocks B).
    2. An evidence claim was audited and corrected. The tautology-detector failure was initially a plausible "pre-existing" hand-wave. Measuring it on both refs proved it (origin/main 17/19 = 89%) — and that measurement, not the assumption, is what's reported.
    3. Process state inspected. The live HOOK_BLOCK during this run is what exposed AC-12, and a second finding (the path-restore exemption not resolving $VARS) came with it. Both are in the diff or reported.
    4. Non-Goals held. v2's four adjacent defects stayed out; the tautology-detector blind spot was fixed only for the helper this PR adds, not patched in the detector.
    5. One deliberate divergence from v2, stated rather than buried: isSameHolder was replaced rather than supplemented, which moves the sessionId branch behind the hostname check. Cross-host + matching session id is no longer reentrant. locks checkout ships in no released version.

    Status: Gaps Found (both surfaced gaps were fixed in cbe9b218; AC-12 remains open by design, not by omission)


    Verdict: AC_NOT_MET

    Mechanically: AC-12 is PARTIALLY_MET, and §7 treats partial as not-met. Substantively the code is in good shape — 16/17 ACs met, full suite green, six mutations confirming the gates bite.

    The single open item is not a code defect and not loopable: AC-12 asks for an outcome its own prescribed mechanism cannot produce, for a reason Design v2 documented elsewhere in the same comment. Running /loop on it would iterate against an impossibility.

    Decision needed — two reasonable paths:

    1. Accept and merge, treating AC-12 as met-in-deliverable with the gap documented in the skill, plus a follow-up issue for hook-side holder identity. (Recommended — the checkout-release bug this issue is about is fully fixed and verified.)
    2. Expand scope to thread a session id through acquire so the hook can match it — a real design change v2 deliberately deferred.

    Recommended follow-ups (not filed — confirm first)

    1. Hook-side holder identity surviving a shell boundary — closes AC-12 properly.
    2. test-tautology-detector blind spots — resolves helpers only through block-bodied arrow consts, and has no rule for helpers calling imported production code. Causes ~89% false positives on checkout-lock.integration.test.ts; the gate currently passes at exactly 50.0%.
    3. Path-restore exemption doesn't resolve shell variables — git checkout -- "$F" is refused where a literal path is allowed.
    4. v2's four adjacent defects — non-CAS steal race (most serious), cwd-relative locks dir, new-feature.sh guard bypass, /merger+/release non-participation.

    Documentation

    • CHANGELOG [Unreleased] entry added
    • Skill prose corrected (fullsolve/SKILL.md ×3)
    • N/A — no README/docs reference locks checkout (verified)

  7. admarble commented on Aug 7, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #906 · PR: #907 · Status: AC_NOT_MET on one item — merge decision needed

    Progress

    Phase Iterations Status
    Spec 1/1 Complete — 17 ACs derived from Design v2
    Worktree 1/1 Created and verified (sequant worktree verify)
    Exec 1/1 Complete — 3 commits, +707/−135 across 15 files
    Test — Skipped: no UI surface, no-browser-test label added
    QA 1/2 Complete — verdict below; loop deliberately not run
    PR 1/1 #907

    Quality

    Gate Result
    CI (PR #907) ✅ 8/8 pass — build (22.x), typecheck, validate-skills, validate-plugin, node-floor-guard, Hooks Validation, Plugin Structure Validation, Setup Directory Creation
    npm test (local, full) ✅ 240/240 files, 5118 passed, 1 expected-fail, 2 skipped
    npm run build / npm run lint ✅ Pass / ✅ 0 warnings
    lint:skill-sync ✅ 44 synced, 0 diverged
    Type issues (any) added 0
    Test cases 5 removed (all AC-16 corrections, each accounted for) → 23 added

    AC Coverage — 16/17 MET

    All met except AC-12 (PARTIALLY_MET). Full per-AC table in the QA review.

    Verdict: AC_NOT_MET — and why no quality loop was run

    Mechanically, one PARTIALLY_MET forces AC_NOT_MET under §7. Substantively the bug this issue is about is fully fixed, verified end-to-end against the built CLI, and mutation-verified six ways.

    The open item is AC-12, whose prescription contradicts its own requirement. It asks for export SEQUANT_ISSUE=<issue-number> "so the hook's issue-based holder fallback fires interactively." The export is present; the effect is unreachable by that mechanism — PreToolUse runs outside and before the command's shell, so it reads the environment Claude Code launched with, and no export in a skill bash block is visible to it.

    This was demonstrated, not deduced: this run was HOOK_BLOCKED by its own #906 lock, and re-running the identical block with the export prepended changed nothing. That also falsified my first fix ("set it in the same block"), corrected in cbe9b218.

    Closing AC-12 needs holder identity surviving a shell boundary — which Design v2 itself ruled out of scope. No in-scope code change satisfies it, so /loop would iterate against an impossibility. Halted for a human decision instead of burning iterations.

    Two reasonable paths:

    1. Accept and merge — treat AC-12 as met-in-deliverable with the gap documented in the skill, and file follow-up 1 below. (Recommended.)
    2. Expand scope to thread a session id through acquire so the hook can match it.

    Risk Assessment

    • Likely failure mode: a caller that legitimately holds a skill-shell lock but omits --issue now leaks the tree for the full 6h TTL rather than releasing. All 9 in-repo sites pass it and are gate-tested; an out-of-repo caller is not. Failing closed is v2's deliberate trade, and the refusal message names the fix.
    • Not tested: cross-host release is unit-tested with an injected hostname, never against two real hosts. AC-12's gap is documented, not test-enforced.

    Follow-ups (not filed — confirm first)

    1. Hook-side holder identity surviving a shell boundary (closes AC-12).
    2. test-tautology-detector blind spots — resolves helpers only through block-bodied arrow consts, and has no rule for helpers calling imported production code. Measured: checkout-lock.integration.test.ts already reads 17/19 (89%) false-positive on origin/main; the gate now passes at exactly 50.0%.
    3. The guard's path-restore exemption does not resolve shell variables — git checkout -- "$F" is refused where a literal path is allowed.
    4. Design v2's four adjacent defects — non-CAS steal race (most serious), cwd-relative locks dir, new-feature.sh guard bypass, /merger + /release non-participation.

    Ready for human review. Merge is not automatic — AC-12 needs your call first.

  8. added 4 commits that reference this issue on Aug 7, 2026
  9. admarble commented on Aug 7, 2026

    @admarble
    ContributorAuthor

    Gaps filled — AC-12 closed, plus a correction

    All 17 ACs now MET. PR #907 updated; full suite 240/240 files, 5140 passed.

    Correction to my earlier comments

    I reported the path-restore defect as "the guard's exemption does not resolve shell variables — git checkout -- "$F" is refused where git checkout -- src/foo.ts is allowed." That diagnosis was wrong, and I published it before testing it. Probing quoted-vs-unquoted and literal-vs-variable separately:

    git checkout -- src/foo.ts        -> allowed
    git checkout -- $F                -> allowed      <- unquoted variable was always fine
    git checkout -- "src/foo.ts"      -> BLOCKED      <- quoted literal was not
    git checkout -- "$F"              -> BLOCKED
    

    The cause is quoting, not variables. emit_segments drops double-quoted regions wholesale, so the segment for a quoted path is git checkout -- — trailing whitespace trimmed — while the exemption required -- . Fixed as --( |$). --detach still doesn't match it, and git checkout "main" is still correctly blocked.

    AC-12 — now genuinely met

    The earlier verdict marked this PARTIALLY_MET on the grounds that the requirement was unreachable. That was true of the prescribed mechanism and I stopped one step too early: SEQUANT_ISSUE can never work (PreToolUse runs outside and before the command's shell, so no export in a skill block reaches it — and the only path that does export it also sets SEQUANT_ORCHESTRATOR, where the guard stands down), but the hook does not need the skill's help.

    The hook sees both the acquire and every later command of the same session, and session_id survives the shell boundary that kills the acquiring PID. It now records the session→issue binding when it observes locks checkout acquire --issue=<N> and consults it as the last rule in the holder check. Ordering preserved — sessionId when both sides have one, then SEQUANT_ISSUE for a genuine parent-process export, then the binding. Clearing happens only on a release naming the session's own issue, so a refused release cannot strip the real holder's identity and lock it out of its own tree.

    Driven against the real hook, six cases: blocked before its acquire is observed → allowed after → a different session still blocked → a session that acquired a different issue still blocked → holder status dropped on its own release → kept through a refused release.

    Tautology detector — 57.4% → 0%

    Measured on both refs rather than assumed:

    File origin/main now
    checkout-lock.integration.test.ts 17/19 (89%) 0/29
    checkout-lock.test.ts 7/20 (35%) 0/31
    this PR's diff 31/54 (57.4%) 0/60

    Three blind spots: only arrow-const helpers were extracted; handles were seeded only on build-output spawns (so a makeLock() factory didn't count); and "production" meant dist/ alone, excluding the hook scripts these tests exist to drive. All 60 pre-existing detector tests unchanged and passing, 8 added — two of them negatives proving the widening didn't switch the detector off.

    Two process notes

    A git checkout -- during mutation testing wiped uncommitted work. Reverting a mutation reverted my not-yet-committed detector fixes with it. Caught only because the next "baseline" run failed 5 tests instead of passing — which also meant the preceding mutation batch had been measuring a corrupted baseline and had to be redone.

    One fix looked right for the wrong reason. The first function-declaration pattern reported a clean 0/60 while matching greedily past the helper body onto the next declaration's brace, attributing unrelated code as the helper body. A synthetic object-return-type test caught what the real file had masked. Replaced with a deterministic body-brace walk.

    Mutation verification

    Eleven mutations, tree restored clean after each — full table in the PR. Isolated re-runs also exposed that PROJECT_SCRIPT_PATTERN was gated by nothing (the existing test reached production by another route); added the inline-path case that actually pins it, and that mutation now fails exactly one test.

    Adjacent defects — filed

    Design v2 scoped these out of this PR. Verified against the code, each with a fix sketch and test plan:


    Verdict: READY_FOR_MERGE. 17/17 ACs met, full suite green, eleven mutations confirming the gates bite.

  10. added
    ready-for-review
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugno-browser-testplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions