Skip to content

fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock #911

Closed

Description

@admarble

Found during adversarial validation of #906 (Design v2, "Adjacent defects"). Verified against main at e2e57a7c.

Bug

/merger and /release both run branch-mutating git in the main checkout and neither participates in the checkout lock (#901):

Skill locks references Guarded git verbs in the main checkout
/merger 0 7
/release 0 2

They never acquire, so they get no protection; and because the guard blocks a non-holder, they are the ones refused when someone else holds the tree. They are victims with no release site: the block message points at sequant locks checkout clear, which refuses a fresh holder — the --force wording fix landing in #906 is their only documented recovery today.

/merger is the sharper of the two: it merges and deletes branches in the shared tree, so an interleaved branch switch from another session can land its merge on the wrong HEAD.

Fix sketch

Give both skills the same Phase 0.3 treatment /fullsolve has:

/release may be able to take the cheaper route: if its two verbs can be expressed as git -C, it needs no lock at all.

Note both skills exist in all three mirrored dirs (skills/, .claude/skills/, templates/skills/) and lint:skill-sync enforces byte-identity.

Test plan

  • Hold the checkout lock as session A; run each skill's first guarded command as session B; assert refusal.
  • Assert each skill acquires before its first mutation and releases on each exit path, gated the way fullsolve-checkout-lock-skill.test.ts does it (per-site, mutation-verified — a whole-file count tolerates a deleted release site).

Activity

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

    @admarble
    ContributorAuthor

    #911 — fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock
    Open · bug
    ────────────────────────────────────────────────────────────────

    → PROCEED — Confirmed on main at 5a68930 — /merger has 9 guarded git verbs in the main checkout and /release 5; neither references the checkout lock

    Commands:
    sequant run 911 -Q

    spec → exec → qa

    Flags:
    -Q release-site placement across two skills in three mirrored dirs, with a per-site mutation-verified gate

    Considered:
    --testgen bug-only label; testgen skips bug/fix issues even though the body carries a Test plan
    --security-review no security/auth label — shared-resource coordination, not authz
    ────────────────────────────────────────────────────────────────
    ⚠ Body has zero - [ ] checkboxes — spec must derive ACs from the Fix sketch / Test plan; --strict-preflight would hard-stop this issue
    ⚠ Both skills exist in all three mirrored dirs (skills/, .claude/skills/, templates/skills/) and lint:skill-sync enforces byte identity — edit all three in sync
    ⚠ The gate test must assert per release site the way fullsolve-checkout-lock-skill.test.ts does, and be mutation-verified: a whole-file occurrence count stays green after a release site is deleted
    ⚠ /release may need no lock at all if its guarded verbs can be expressed as git -C — settle that in spec rather than acquiring reflexively
    ────────────────────────────────────────────────────────────────

  3. admarble commented on Aug 7, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (8 derived ACs, ~4 directories)

    No AC checkboxes in the issue body — ACs derived from the Fix sketch + Test plan below.

    AC Quality Check

    The issue is a well-scoped bug with a concrete fix sketch and test plan, but ships no checkbox ACs. Derived below. One substantive concern surfaced during planning (see Open Questions #1): the fix sketch's "/release may be able to take the cheaper route: if its two verbs can be expressed as git -C, it needs no lock at all" does not hold — /release mutates the main checkout itself, so there is no worktree to route git -C through. Building the literal suggestion would leave /release unprotected. Flagging per "an AC's suggested design can violate its own requirement — build the requirement, flag loudly."


    Scope Assessment

    Non-Goals: Not stated in the issue. Implied: no change to the lock mechanism itself (checkout-lock.ts), the pre-tool.sh guard, or /fullsolve — this only makes /merger and /release participate in the existing lock. ⚠️ Consider stating that boundary explicitly.

    Metric Value Status
    Feature count 2 (merger, release) ✅
    AC items 8 (derived) ✅
    Directory spread skills/ ×3 mirrors + src/lib/tests (+ maybe src/commands, bin) ⚠️

    Verdict: ⚠️ SCOPE_WARNING — the directory spread is a mirroring artifact (3 byte-identical skill dirs), not genuine breadth. Stays one cohesive change unless Open Question #1 forces a CLI extension for /release's holder identity, which would pull in src/commands/locks.ts + bin/cli.ts and warrant a split. Decide OQ #1 before implementing.


    Acceptance Criteria

    AC-1: /merger acquires the checkout lock before its first guarded git verb

    Verification: Integration Test
    Scenario: Given a session runs /merger, When it reaches its first main-checkout branch-mutating verb (git checkout main for baseline at skills/merger/SKILL.md:122, or git checkout -b integrate/…/git merge at :249/:252), Then a locks checkout acquire --issue=<id> --command="/merger …" --skip-pid-check has already run.
    Assumptions: Acquire is placed before the baseline-capture step (the earliest guarded verb), mirroring /fullsolve Phase 0.3.

    AC-2: /merger releases the checkout lock on every exit path, and only on exits

    Verification: Integration Test (gate test, per-site + mutation-verified)
    Scenario: Given /merger acquired the lock, When it finishes (happy path) OR halts (regression gate at :404/:415, conflict abort, error), Then it runs npx sequant locks checkout release --issue=<id> || true before the halt/exit message; When it hits a branch that continues to a later mutation, Then it does NOT release (the #906 distinction).
    Assumptions: Every early-exit ❌/halt in merger gets a paired release, same contract as fullsolve.

    AC-3: /merger's release proves ownership with --issue

    Verification: Integration Test
    Scenario: Given merger operates on multiple issues, When it acquires/releases, Then it passes a single deterministic --issue=<first-issue-number> on both (acquire and every release), so ownership is provable (#906) and never refused against itself.
    Assumptions: Identity need only be self-consistent within the run; first issue number is the natural choice (see OQ #2).

    AC-4: /release holds the checkout lock across its critical section

    Verification: Integration Test
    Scenario: Given /release runs, When it enters the mutate span (version bump → git commit → git tag → git push, plus its rollback verbs git reset --soft/git checkout main at :571-574/:606), Then it holds the checkout lock so (a) a foreign git checkout cannot interleave and land the release commit on the wrong HEAD, and (b) release's own guarded rollback verbs are not refused by the guard.
    Assumptions: Resolves Open Question #1 (holder identity for an issue-less skill).

    AC-5: /release releases the checkout lock on every exit path with --issue

    Verification: Integration Test (gate test, per-site + mutation-verified)
    Scenario: Given /release acquired the lock, When it completes, aborts pre-flight (Not on main/Uncommitted/Behind origin at :59-66), or errors mid-release, Then it releases with --issue=<id> || true before exiting.

    AC-6: Both skills are orchestrator-safe

    Verification: Unit Test (assert prose/flow) + reuse of existing CLI no-op behavior
    Scenario: Given SEQUANT_ORCHESTRATOR is set, When either skill calls acquire/release, Then they are no-ops (exit 0, no file touched) — so the calls are safe to run unconditionally, exactly as documented for /fullsolve Phase 0.3.
    Assumptions: No new orchestrator logic needed; the CLI already no-ops. Skills just call unconditionally + document it.

    AC-7: All edits mirrored byte-identical across the three skill dirs

    Verification: Integration Test (npm run lint:skill-sync)
    Scenario: Given edits to merger/SKILL.md and release/SKILL.md, When lint runs, Then skills/, .claude/skills/, and templates/skills/ copies are byte-identical.

    AC-8: Lock participation is gated by per-site, mutation-verified tests

    Verification: Integration Test
    Scenario: Given the new gate tests (modeled on src/lib/__tests__/fullsolve-checkout-lock-skill.test.ts), When a release site or the acquire is deleted, Then exactly that test fails (per-site, not a whole-file count — a whole-file count tolerates a deleted release site, the exact trap #906's test was rewritten to close). PLUS a real contention assertion: session A holds the checkout lock; session B runs each skill's first guarded command; assert refusal (from the issue's Test plan).
    Assumptions: Reuse the phase03-style scoped-region extraction + EXPECTED_RELEASE_SITES exact-count pattern from the fullsolve test.


    Implementation Plan

    Phase 1: Resolve the design fork (blocking)

    1. Decide Open Question feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 (/release holder identity) — this gates the whole /release half. Recommendation in OQ feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1.

    Phase 2: /merger lock participation

    1. Add an acquire block near the top of skills/merger/SKILL.md (before baseline capture at :122), mirroring /fullsolve Phase 0.3: locks checkout acquire --issue=<first-issue> --command="/merger …" --skip-pid-check || true, with the orchestrator no-op note. Export the identity for the guard binding (fix(locks): checkout release ignores holder identity on skip-pid-check locks — a blocked session's release contract unlocks the tree mid-run #906) as fullsolve does.
    2. Add paired locks checkout release --issue=<first-issue> || true at every merger exit: happy-path completion, the regression halt (:404/:415), conflict/abort paths, and error exits. Do not release on continue-paths.

    Phase 3: /release lock participation

    1. Per OQ feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 decision, add acquire before the mutate span and release on the pre-flight failures (:59-66), happy-path end, and rollback/error paths in skills/release/SKILL.md.

    Phase 4: Mirror + test

    1. Apply Phases 2–3 identically to all three skill dirs (read each mirror independently before editing; lint:skill-sync enforces byte-identity).
    2. Add src/lib/__tests__/merger-checkout-lock-skill.test.ts and …/release-checkout-lock-skill.test.ts — scoped-region gate tests + a contention integration assertion (session A holds, session B refused). Mutation-verify each new gate: delete the acquire / one release site, confirm exactly that test fails, restore, record in the PR body (CLAUDE.md gate-test rule).

    Rule Touchpoints

    The core AC is a behavior rule ("acquire before the first guarded verb; release on every exit"). Its touchpoints are the skill prompts themselves, each triplicated:

    AC Touchpoint Snippet
    AC-1..3 {skills,.claude/skills,templates/skills}/merger/SKILL.md acquire before git checkout main (:122); release at halts (:404)
    AC-4..5 {skills,.claude/skills,templates/skills}/release/SKILL.md acquire before commit/tag/push (:425-434); release at pre-flight exits (:59-66)

    There is no runtime TypeScript twin of this rule (unlike #533) — the lock CLI (src/commands/locks.ts, src/lib/locks/checkout-lock.ts) is the shared mechanism and is unchanged; only the two skill prompts gain participation. That keeps the change prompt-only unless OQ #1 forces a CLI extension.


    Design Review

    1. Where does this logic belong? In the two SKILL.md prompts (LLM-executed), reusing the existing sequant locks checkout CLI. No new mechanism — this is the "make the mutator participate" pattern already established for /fullsolve in feat(locks): per-issue locks give no mutual exclusion on the shared working tree — checkout-scoped protection #901/fix(locks): checkout release ignores holder identity on skip-pid-check locks — a blocked session's release contract unlocks the tree mid-run #906.
    2. What's the simplest correct approach? Copy /fullsolve Phase 0.3's acquire/release contract verbatim (with --issue, --skip-pid-check, || true, orchestrator no-op). Reject: (a) a bespoke lock for merger/release — needless divergence; (b) the issue's git -C route for release — doesn't apply (release mutates main).
    3. What existing pattern does this follow? The /fullsolve Phase 0.3 checkout-lock contract and its per-site mutation-verified gate test (fullsolve-checkout-lock-skill.test.ts).
    4. What would a senior reviewer challenge? "Does /release even trip the guard?" — Yes, but only on its rollback path (git reset --soft, git checkout main); its happy path (add/commit/tag/push) isn't a guarded verb. The value for release is twofold: preventing a foreign git checkout from landing the release commit on the wrong HEAD, and not being refused mid-rollback when it most needs to recover. Worth stating explicitly in the release edit so a future reader doesn't "simplify" the lock away.

    Feature Quality Planning


    Open Questions

    1. How does issue-less /release prove holder identity to the checkout lock? — --issue must be a positive integer (parseCheckoutIssue), and the fix sketch's git -C "cheaper route" is inapplicable (release mutates main). Recommendation: smallest correct option — extend sequant locks checkout to accept a symbolic holder (e.g. --label=release) OR reserve a sentinel issue id for release; pick the label route (self-documenting, avoids colliding with a real issue #). Impact if wrong: a numeric-sentinel collision could make release and a real issue's session appear to be the same holder. This decision pulls src/commands/locks.ts + bin/cli.ts into scope — if the team prefers prompt-only, the fallback is to acquire under a fixed high sentinel id and document it. Needs a decision before Phase 3.
    2. What --issue identity should /merger use across multiple issues? — Recommendation: the first issue number in the argument list (deterministic, always a real issue in the batch). Impact if wrong: none functional — identity only needs to be self-consistent acquire→release; first-issue is just the clearest choice.
    3. Does /merger's clean-merge path (gh pr merge + git -C <worktree>) need the lock at all, or only the integration-branch path? — Recommendation: acquire unconditionally up front regardless of path (matches fullsolve, avoids a path-dependent acquire that's easy to get wrong). Impact if wrong: a per-path acquire could miss the baseline git checkout main at :122.

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: enabled (SCOPE_WARNING auto-enables; the continue-vs-exit release placement is the #906-class subtlety that benefits from a QA pass)
    Reasoning: Prompt + test change, no browser/UI (skip test). ACs are Integration-Test-verified against real lock contention, so testgen would help stub the two new gate tests — add testgen if the team wants stubs before implementation; otherwise the exec agent writes them directly from the fullsolve test as a template. No security-review phase (reuses an existing, already-reviewed lock mechanism).


    Label Review

    Current: bug
    Recommended: bug, planned (added below). Consider skills if that label exists in this repo.
    Reason: Straightforward bug scope; no complex/breaking. If OQ #1 forces the CLI extension, revisit for a possible split.
    Quality Loop: Will auto-enable (SCOPE_WARNING).


    --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---

    Plan for #911 — /merger & /release participate in the checkout lock

    Derived ACs (no checkboxes in the body):

    • AC-1: /merger acquires the checkout lock before its first main-checkout guarded verb (baseline git checkout main).
    • AC-2: /merger releases on every exit path (happy + regression halt + conflict/error), never on continue-paths.
    • AC-3: /merger acquire/release use --issue=<first-issue> for provable ownership (fix(locks): checkout release ignores holder identity on skip-pid-check locks — a blocked session's release contract unlocks the tree mid-run #906).
    • AC-4: /release holds the checkout lock across bump→commit→tag→push and its rollback verbs.
    • AC-5: /release releases on every exit (pre-flight fail, happy path, rollback/error) with --issue.
    • AC-6: Both skills call acquire/release unconditionally; they no-op under SEQUANT_ORCHESTRATOR.
    • AC-7: Edits mirrored byte-identical across the 3 skill dirs (lint:skill-sync).
    • AC-8: Per-site, mutation-verified gate tests per skill + a real contention assertion (holder blocks a second session), modeled on fullsolve-checkout-lock-skill.test.ts.

    Key decisions / open questions:

    1. ⚠️ The fix sketch's "git -C cheaper route" for /release does not apply — /release mutates the main checkout itself. /release needs the lock, and --issue requires a positive integer it doesn't have. Proposed: extend locks checkout to accept a symbolic --label=release holder (pulls in src/commands/locks.ts + bin/cli.ts), or use a reserved sentinel id if you'd rather keep it prompt-only. Decision needed before implementing the release half.
    2. /merger identity across multiple issues → use the first issue number.
    3. /merger acquires unconditionally up front (not per-path).

    Approach: copy /fullsolve Phase 0.3's acquire/release contract (incl. the #906 continue-vs-exit distinction) into both skills; reuse its gate-test pattern.

    Workflow: spec → exec → qa, quality loop enabled.

  4. added
    planned
    on Aug 7, 2026
  5. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #911
    Status: READY_FOR_MERGE
    PR: #917

    AC Coverage (8/8 MET)

    • AC-1 — /merger acquires before its first guarded verb: acquire section precedes Step 0 Baseline Capture; ordering pinned by test.
    • AC-2 — /merger releases on every exit path (regression-gate halt, Step 8 happy path, Error Handling), never on continue-paths (integration merge, mid-workflow checkouts explicitly stay held). Exact release-site count (3) pinned; mutation-verified.
    • AC-3 — Acquire and every release name --issue=<first-issue>; the prose warns to substitute the literal number since pre-tool.sh reads pre-expansion command text.
    • AC-4 — /release holds the lock across bump→commit→tag→push and rollback; acquire placed after read-only pre-flight, before the first mutation (pinned by ordering test).
    • AC-5 — /release releases on happy path, before-publish rollback, and Error Handling, always with --issue=999999999. The spec's "release on pre-flight abort" clause is deliberately inapplicable: acquire happens after pre-flight, so an abort there holds no lock (documented in the skill text — requirement satisfied, prescription refined).
    • AC-6 — Orchestrator no-op documented in both skills; CLI already no-ops under SEQUANT_ORCHESTRATOR.
    • AC-7 — Byte-identical across the three skill dirs: lint:skill-sync 44/44 synced.
    • AC-8 — Per-site, mutation-verified gate tests + contention proof driving the real pre-tool.sh (foreign holder refused exit 2, holder unrefused, no-lock baseline passes).

    Open Question #1 resolution: reserved sentinel id 999999999 (works with CLI + hook unchanged); the --label=release route is documented as a rejected-for-now alternative. Verified live: sentinel acquire → check → release round-trips against the built CLI.

    Quality Summary

    • Tests: 54/54 passing (2 gate files + 1 integration contention proof); build passes; lint:skill-calls clean.
    • Mutation verification: 2 mutations run (regression-gate release site deleted → exactly 2 tests failed; release acquire fence deleted → exactly 3 tests failed); details recorded in the PR body.
    • Quality checks: type safety 0 issues, deleted tests 0, scope exact match (10 files, +993/−0), security scan 0 critical / 0 warnings.
    • Trust-boundary: Clean — diff implements only product requirements from the issue's fix sketch.
    • CHANGELOG: [Unreleased] Fixed entry present with issue number.

    Risk Assessment

    • Likely failure mode: an executing agent skips a prompt instruction at runtime (prompt-only enforcement); mitigated by the pre-tool.sh guard itself, which refuses non-holders regardless of whether the skill acquired.
    • Not tested: the sentinel's rendering in sequant locks list alongside real issues (cosmetic); --label follow-up would address readability.

    Iterations

    Phase Iterations Status
    Spec 1/1 Complete (prior session)
    Exec 1/3 Complete (prior session; verified this session)
    Test — Skipped (no UI labels)
    QA 1/2 Complete — READY_FOR_MERGE

    Ready for human review and merge.

  6. added 2 commits that reference this issue on Aug 8, 2026
  7. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    QA Gap Fixes Applied (741ba8e5, PR #917)

    Both actionable gaps from the QA pass are closed:

    1. After-push rollback release site — the /release skill's "After git push, before npm publish" rollback now carries its own inline locks checkout release call (previously covered only by the Error Handling blanket). EXPECTED_RELEASE_SITES bumped 3 → 4; new per-site gate test added and mutation-verified (deleting the site fails exactly the 2 tests asserting it).
    2. Sentinel rendering — locks list and the CLI release-refusal now render the /release holder as /release (sentinel) instead of issue=#999999999 (describeCheckoutHolderIssue() in src/lib/locks). Hook shell-side message left untouched to avoid TS↔shell mirror drift; recovery hints keep the typeable numeric form. Verified live against the rebuilt CLI.

    Not changed (deliberate): the acquire-after-pre-flight placement (refines spec AC-5's letter in favor of its requirement, documented in the skill text) and prompt-only enforcement (the pre-tool.sh guard is the backstop). Full --label=release support remains the follow-up.

    Post-fix: 90/90 tests, build passes, lint:skill-sync 44/44.

  8. added a commit that references this issue on Aug 8, 2026
  9. added 2 commits that reference this issue on Aug 8, 2026
  10. added 2 commits that reference this issue on Sep 9, 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

    bugplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions