Skip to content

feat(exec/qa): explicit in-place checkout mode — run a phase on a branch in the current clone without creating or resolving a worktree #1136

Closed

Description

@admarble

Context

Sequant's skills know two checkout modes. Orchestrated (SEQUANT_ORCHESTRATOR set): the phase uses SEQUANT_WORKTREE, verified by the #899 existence guard. Standalone (SEQUANT_ORCHESTRATOR unset): the skill creates a worktree itself (exec/SKILL.md:301–318, :507; qa/SKILL.md:407 resolves one via npx sequant worktree resolve and halts otherwise). Neither mode can run a phase on a branch in the current clone.

That is exactly what a claude.ai cloud session is: a fresh clone of main, no sibling ../worktrees/, no sequant binary, no .claude/.local/ overrides. The 2026-09-24 matcha-maps credit plan (one cloud session per issue-phase, invoking /exec and /qa as the top-level agent) had to override the skills by prompt, and its reviewer needed four quoted anchors to do it:

  • exec/SKILL.md:507 and :315–320 — do not run ./scripts/dev/new-feature.sh, do not create a worktree
  • exec/SKILL.md:465–475 — skip the npm run dev & smoke test
  • never invoke /test — its .claude/.local/skills/test/overrides.md is gitignored and absent in the clone
  • qa/SKILL.md:407 — treat $PWD as the worktree; worktree resolve would bail

Prompt-level overrides of a 2,152-line skill are untested and drift with every skill edit. The mode should be first-class.

Design constraint

Explicit opt-in, never inferred. #899 closed the failure where skills silently executed in the main checkout because nothing verified the worktree. Auto-detecting "fresh clone on main" would reopen it. The mode is entered only by an env flag the launcher sets (proposed: SEQUANT_CHECKOUT=in-place); with the flag unset, behaviour is byte-identical to today.

The commit guard in pre-tool.sh already allows commits on a non-base branch in the main checkout (the #1079 cloud run committed and was stopped only by GitHub App push permissions), so no hook change is needed.

Fix shape

In-place mode, in exec and qa (and loop/testgen if they resolve a worktree):

  • On entry: if the current branch is the base branch, create and check out feature/<N>-<slug> from origin/<base>; if already on a non-base branch, keep it. Never call new-feature.sh, git worktree add, or worktree resolve.
  • Skip the dev-server smoke section unless SEQUANT_SMOKE=1.
  • Never invoke /test.
  • Everything else (AC loop, suite, PR creation, verdict comment) unchanged.
  • The mode table (orchestrated / standalone / in-place) goes in the skill's env-var section and a docs reference page.

Consumer: the claude-cloud driver (filed separately) sets this flag for every cloud phase.

Acceptance criteria

  • AC-1: exec with SEQUANT_CHECKOUT=in-place and cwd on the base branch creates and checks out feature/<N>-<slug> in the current clone and never invokes new-feature.sh, git worktree add, or worktree resolve — Verify: gate test on the delimited in-place section of templates/skills/exec/SKILL.md, mutation-verified per CLAUDE.md
  • AC-2: qa with the flag treats $PWD as the worktree, skips npx sequant worktree resolve, and halts if the current branch is the base branch — Verify: gate test on the delimited section of templates/skills/qa/SKILL.md, mutation-verified
  • AC-3: with the flag unset, the bug(fullsolve/exec): the worktree is never created and never verified — skill-driven runs execute in the main checkout, or in another repo's worktree #899 guards are untouched and the mode is never inferred from git state — Verify: existing bug(fullsolve/exec): the worktree is never created and never verified — skill-driven runs execute in the main checkout, or in another repo's worktree #899 gate tests green and grep -c "in-place" templates/skills/exec/SKILL.md matches only inside the delimited section
  • AC-4: all three skill directories carry the change — Verify: npm run lint:skill-sync green
  • AC-5: docs reference page lists the three modes with their entry condition and what each skips — Verify: grep -l "in-place" docs/reference/*.md non-empty
  • AC-6: dogfood — one real cloud session on a project issue with the flag set opens a PR, and its run log shows no worktree attempt; the session URL and PR link are posted on this issue — Verify: the comment
  • AC-7: npm run build && npm test green

Not in scope

Launching cloud sessions from sequant run (the driver issue), hook changes, /test portability.

Related

#899 (the guard this must not weaken) · #901 (checkout-scoped locks) · #1096 (driver conformance item 6, skill load) · #1079 (the cloud run that proved commits pass the hook)

Activity

  1. added
    enhancement
    on Sep 24, 2026
  2. admarble commented on Sep 24, 2026

    @admarble
    ContributorAuthor

    AC-6 (dogfood cloud session) is blocked, and I have not ticked it. Every other AC is implemented and verified on branch feature/1136-feat-exec-qa-explicit-in-place-checkout-mode-. The PR follows.

    A real cloud session with SEQUANT_CHECKOUT=in-place has to push a branch and open a PR. The #1079 cloud run showed the claude.ai GitHub App has no write access to sequant-io/sequant: the commit passed the hook and the push was rejected. One of these unblocks AC-6:

    1. Grant the App write access (contents plus pull requests) on sequant-io/sequant, or on the project repo the dogfood will use. Then the dogfood session runs and its URL and PR link get posted here.
    2. Move AC-6 to a follow-up issue. This needs the AC-6 line in the issue body edited, for example to Deferred to #NNNN. A comment alone does not change the gate that /qa reads.

    Until one of those happens, the PR's Closes #1136 would close this issue with AC-6 unmet.

  3. admarble commented on Sep 24, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #1136

    PR #1139, reviewed at 283560c1. Standalone QA, standard pipeline: the diff is 1,250 lines, all additive.

    AC Coverage

    AC Description Status Notes
    AC-1 exec in-place creates feature/<N>-<slug>, never reaches worktree tooling MET Gate test asserts on the region and also executes its bash in a scratch clone. The run ends on the expected branch from origin/main, resolveIssueWorktree resolves it, listWorktrees = 1, and the npx shim was called 0 times.
    AC-2 qa treats $PWD as the worktree, skips resolve, halts on base MET Executed for qa, loop and testgen: exit 1 on main and on a detached HEAD. On the feature branch the adopted path passes verifyWorktreePath, with 0 npx calls. qa's Phase 0 resolve is behind a skip marker.
    AC-3 flag unset: #899 untouched, never inferred MET grep -c "in-place" returns 20, all 20 inside regions. The skill diff deletes 0 lines. The #899 regions hash-identical to origin/main (3 roots × 4 skills). The #899 gate tests pass 51/51. The unset-flag no-op is executed in the test.
    AC-4 three mirrors MET npm run lint:skill-sync: 44 synced, 0 diverged. The changed files hash-identical across roots.
    AC-5 docs reference page, three modes MET grep -l "in-place" docs/reference/*.md returns checkout-modes.md, plus a table-shape gate.
    AC-6 dogfood cloud session opens a PR NOT_MET Blocked. The GitHub App lacks write access to sequant-io (#1079). See the comment above for the two ways to unblock.
    AC-7 build and test green MET npm run build exit 0. timeout 900 npm test: 337 files, 8,376 passed, 0 failed.

    Coverage: 6/7 met.

    CI Status

    test is pending. The other 9 checks pass, including canary, typecheck, validate-skills and tautology-advisory.

    Quality Checks

    Check Status Notes
    Type safety / deleted tests ✅ Pass 0 any, 0 deleted or skipped tests. One row! is guarded by toBeDefined.
    Scope / size ✅ Pass 16 files, all in scope. 232 unique skill lines, mirrored ×3.
    Security ✅ Pass The issue title is sanitized to [a-z0-9-] before reaching git. Every expansion is quoted. rmSync touches only the mkdtemp scratch dir.
    Tautology detector ⚠️ WARN 5/11 blocks (45.5%), non-blocking. The five are pure text gates.

    Detection Pattern Verification (§6c)

    The sed slug pipeline was run against 10 recent real feature/ branches recomputed from their issue titles. 10 of 10 differ. Those branches came from sequant run, whose slugify in worktree-manager.ts:108 cuts the slug at 50 characters. The in-place block copies new-feature.sh, which cuts the whole branch at 58. The two rules agree only when the slug is at most 45 characters. ensureWorktree looks up an existing branch by exact name, so a later local sequant run phase would miss a long-titled in-place branch and branch again. That is the #1137 hand-off path. Resolver lookups key on the issue number and are unaffected.

    Status: Failed for the "same name" claim. The AC-1 text does not specify which slug rule to use.

    Mutation Verification

    AC Marker Status
    AC-1 in-place-checkout-skill.integration.test.ts > … > creates feature/<N>-<slug> … Verified
    AC-2 … > qa > treats $PWD as the worktree … Verified
    AC-3 … > never inferred > every mention … Verified
    AC-5 … > checkout modes reference page (AC-5) > … Verified

    Status: Verified. There are six recorded mutations, each failing exactly one test, and all four markers parse valid.

    Trust-Boundary Check

    Finding: Clean. The diff implements only the issue's product requirements. The issue body carries no agent-directed instructions.

    Status: Clean

    Adversarial Re-Read

    Findings:

    1. The slug divergence above.
    2. sequant run spreads process.env, so an exported SEQUANT_CHECKOUT collides with SEQUANT_WORKTREE. It halts loudly and the docs cover it.
    3. /fullsolve and /test also create or resolve worktrees and have no in-place entry. The issue scopes them out.
    4. The exec code comment names ./scripts/dev/new-feature.sh, which is not tracked in the repo. It is harmless inside a prohibition.

    Status: Gaps Found

    Risk Assessment

    • Likely failure mode: A long issue title yields an in-place branch that a local sequant run phase does not reuse.
    • Not tested: A live cloud session (AC-6), and the gh title fetch against the real API inside the entry block. The test shims gh.
    • Sibling sites considered: fullsolve and test skills, out of scope. The worktree-manager slugify is covered by the finding.
    • Sibling-line audit: Every worktree-creating site in exec has its own skip marker: context-gathering, the smoke test, the worktree workflow and parallel isolation.

    CHANGELOG Verification

    Result: The entry is present under [Unreleased] / Added and carries the issue number.

    Verdict: AC_NOT_MET

    AC-6 is not met and cannot be met from code. It needs the App permission or an edit to the AC text. All other ACs are met with executed evidence. The slug finding is a small fix that will land in the same PR.

    Next Steps

    1. Align the in-place slug with worktree-manager.ts slugify, which cuts the slug at 50. Extend the corpus check.
    2. Tony: grant the App write access, or edit AC-6 to defer it. Closes #1136 would otherwise close the issue with AC-6 unmet.
  4. added
    needs-work
    on Sep 24, 2026
  5. added a commit that references this issue on Sep 24, 2026
  6. admarble commented on Sep 24, 2026

    @admarble
    ContributorAuthor

    Field evidence from the matcha-maps credit run (2026-09-24), relevant to the design and to AC-6.

    Two cloud sessions ran /spec and /exec on a fresh clone of main with the in-place behaviour carried by prompt overrides (the four anchors in the issue body). Observed in the run logs (docs/internal/graph-2026-09-credits/HANDOFF.md in admarble/matcha-maps):

    • Run 1 (admarble/matcha-maps#1046): the worker never called the Skill tool at all — it read "invoke /exec" and implemented directly, following the inline discipline in the prompt. Skills load only when the prompt names the Skill tool explicitly.
    • Run 2 (admarble/matcha-maps#1047): Skill{skill:"spec"} and Skill{skill:"exec"} both loaded the vendored 2.17.0 skills. With the overrides, the worker branched in place from origin/main, created no worktree, ran no new-feature.sh, skipped the dev-server smoke test, and opened a PR. So the override path works; this issue makes it a flag instead of ~400 words of prompt.
    • gh is not installed in the cloud environment. The spec skill's preflight printed GITHUB_AVAILABLE=false and the worker fell back to the GitHub MCP connector for the issue read, the plan comment and the PR. In-place mode must not assume gh; either the skill's platform preflight tolerates MCP-only, or the docs say the environment needs a setup script that installs it.
    • The vendored pre-tool.sh env-dump guard and the repo's Bash(env) deny both fired on the worker's env | grep -i sequant probe (unanchored). The node -e key-name probe works. Not a defect; noting so the mode's docs recommend the node probe.
    • .sequant/settings.json is untracked in that repo, so it is absent in the clone (SETTINGS_AVAILABLE=false). In-place mode must not require it.

    AC-6 status: the GitHub App now has write access on admarble/matcha-maps (both runs pushed and opened PRs). It still lacks sequant-io, so the dogfood run for this AC can happen on matcha-maps once the flag exists there, or on this repo after the App is granted.

  7. added a commit that references this issue on Sep 24, 2026
  8. admarble commented on Sep 24, 2026

    @admarble
    ContributorAuthor

    AC-6 evidence and updated QA verdict

    Session: session link removed (cse_01W6MSXo6CpVP1WmyNMwxWVz, Sonnet 5, cloud environment "Sequant in-place" carrying SEQUANT_CHECKOUT=in-place, fresh clone of sequant-io/sequant on main).
    PR it opened: #1142 (fix for #1123, on feature/1123-fix-init-yes-init-replaces-a-user-modified-agents-).

    What the run log shows (read through the routines API, all pages):

    • echo SEQUANT_CHECKOUT=$SEQUANT_CHECKOUT → in-place, set by the environment, not by the agent.
    • git worktree list → one entry, /home/user/sequant, before and after.
    • The in-place entry block, run from main: Switched to a new branch 'feature/1123-fix-init-yes-init-replaces-a-user-modified-agents-' … set up to track 'origin/main'. The name equals sequant run's slugify of the issue title, so a later local phase reuses it.
    • git push -u origin feature/1123-… → [new branch]. Cloud push protection did not block a skill-created branch.
    • PR opened with the GitHub MCP pull-request tool. Body has the AC table, a mutation check, a ### Settled against base block, and Closes #1123.
    • No occurrence of new-feature.sh, git worktree add, or worktree resolve anywhere in the session.

    What the dogfood found, fixed on PR #1139 (7f6d0ba1): the first attempt halted inside the entry block with gh: command not found. Cloud sandboxes have no gh; the title is now an <issue-title> placeholder the agent fills from gh or the GitHub MCP issue_read tool, and the block never names gh. Mutation-verified: restoring the gh fetch fails the AC-1 gate.

    Side findings for #1137's Phase-0 list: the environment setup script does not run in the repo checkout (npm ci there fails); cloud clones are shallow, so __tests__/evals-fixture-commit.test.ts false-fails 5 cases (the session filed #1140 after settling it against base); the repo's Stop hook errors in the cloud; a stopped run leaves a readable log with runner lines. One caveat on the evidence: the session prefixed the block with its own export SEQUANT_CHECKOUT=in-place, redundant with the environment value it had already printed.

    AC Coverage

    AC Status
    AC-1 … AC-5, AC-7 MET, unchanged from the review above; CI on 7f6d0ba1 is 10/10 green
    AC-6 MET, per the evidence above

    Adversarial Re-Read

    Findings: /fullsolve and /test still have no in-place entry (scoped out by the issue). An exported SEQUANT_CHECKOUT in a sequant run shell halts every phase on the mutual-exclusion check (fails safe, documented). The dogfood agent added an export line to the block, showing agents may embellish the block; the flag check still gates entry.

    Status: Gaps Found

    Verdict: AC_MET_BUT_NOT_A_PLUS

    All seven ACs are met with executed evidence. The remaining gaps are follow-ups, not blockers.

  9. added
    needs-improvement
    and removed
    needs-work
    on Sep 24, 2026
  10. added a commit that references this issue on Sep 24, 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

    enhancementneeds-improvement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions