Skip to content

bug(qa/loop): SEQUANT_WORKTREE is still trusted unchecked — the sibling sites #899 left behind #904

Closed as not planned

Description

@admarble

Summary

#899 gave /exec a verification gate before it trusts SEQUANT_WORKTREE. /qa and /loop receive the same variable from the same orchestrator and still cd into it unchecked — the identical line #899 removed from /exec:

  • .claude/skills/qa/SKILL.md:365 — - Use the provided worktree path directly: \cd $SEQUANT_WORKTREE``
  • .claude/skills/loop/SKILL.md:220 — same line, verbatim

(Both mirrored into templates/skills/ and skills/.)

Surfaced by #899's cross-file sibling-site scan (§5). Deliberately left out of PR #902 rather than widening its scope mid-review.

Why this is lower-severity than #899 was

#899's /fullsolve Phase 1.5 now creates the worktree and resolves an absolute path before any child skill runs, so under the orchestrator the value /qa and /loop receive is already known-good. The residual exposure is the standalone path: /qa 123 or /loop 123 invoked in a shell that still carries a SEQUANT_WORKTREE export from an earlier, unrelated run. That value can point at a deleted worktree, or — because ../worktrees/ is one flat namespace shared by every sibling repository — at another project's.

Failure shape is the same as #899's: the cd fails, the skill keeps going in whatever directory it is in, and QA reviews or /loop edits the wrong tree while reporting success.

Acceptance Criteria

  • AC-1: /qa halts with the named error from sequant worktree verify when SEQUANT_WORKTREE is set but is not an existing directory of this repository, instead of continuing in the current directory.
  • AC-2: /loop carries the same guard, with the same halt semantics.
  • AC-3: Both guards reuse npx sequant worktree verify (added in 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) rather than reimplementing the check inline, so there is one source of truth for the three named errors.
  • AC-4: All three skill mirrors (.claude/skills/, templates/skills/, skills/) carry identical changes.
  • AC-5: A regression test asserts the guard is present in both skills, scoped to a delimited region rather than the whole file, with a recorded mutation result per CLAUDE.md — matching the pattern established by __tests__/integration/worktree-contract-skill.integration.test.ts.

Non-Goals

Follow-up to #899 / PR #902.

Activity

  1. added
    bug
    on Aug 6, 2026
  2. added a commit that references this issue on Aug 6, 2026
  3. admarble commented on Aug 6, 2026

    @admarble
    ContributorAuthor

    Absorbed into PR #902 rather than shipped separately — same defect class, same files, same mirrors.

    Scope grew once I actually swept for it. This issue named two sites (/qa, /loop); the sweep found six, in five skills:

    Unguarded cd $SEQUANT_WORKTREE — /qa (reviewed the main checkout while reporting on the feature branch) and /loop (worse: it writes, so it applied fixes and committed them there). Both now run the sequant worktree verify gate from #899 and halt on a named error.

    Globbing the shared ../worktrees/ namespace — /qa, /loop, and /testgen. /testgen was not in this issue's AC list and matters as much as the others: it writes test stubs, so a cross-repo match scatters them into an unrelated project.

    Prefix matching on the issue number instead of the branch — the sharpest one, also not in the original AC list. /merger had git worktree list | grep "feature/$ISSUE" with git worktree remove --force on the very next line, so ISSUE=89 matched feature/899-… and force-removed an unrelated issue's worktree. Also /qa's Phase 0 implementation probe (a bare-number grep -i gating the "no implementation found" verdict), and /assess's read-only probe.

    AC-5 was implemented differently than written, deliberately. The AC asked for a regression test asserting the guard is present in both skills. Pinning known sites is what would have let this spread in the first place — the pattern reached six skills by being copied. Instead the gate test carries two completeness invariants over every skill in every mirror:

    1. Every cd $SEQUANT_WORKTREE sits inside a verify-bearing guard region.
    2. No skill globs ../worktrees/ or greps git worktree list for an issue number.

    A newly-added skill that reintroduces either pattern now fails the build. The per-skill assertions AC-5 asked for are still there; the invariants sit on top.

    Both invariants are scoped to spare legitimate uses — /assess's grep "^worktree" enumerates every worktree for diff-overlap and keys on nothing, so it is not flagged. Narrowing that exemption is what surfaced a --porcelain variant in /merger that the first regex had missed.

    Mutation-verified per CLAUDE.md: removing /qa's guard failed exactly 2 tests (the per-skill one and the invariant); appending a glob to /docs — a skill in no pinned list — failed exactly 1 and named docs: as the offender, which is the case pinning could never have caught; restoring /merger's grep failed exactly 1 and named merger:. All restored, 62/62 green.

    Full suite green (237 files, 5011 passed, 0 failed) and CI 8/8 on #902.

    AC-1 through AC-4 met as written; AC-5 met via the stronger invariant form described above.

  4. admarble commented on Aug 6, 2026

    @admarble
    ContributorAuthor

    Closing as consolidated into #902 (see above). Tracked by #899.

  5. added 2 commits that reference this issue on Aug 6, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions