Repository navigation
Description
The /exec parallel-group marker filename is a global constant, so a parallel group in one project silently redirects worktree enforcement for every concurrently-running Claude session on the machine — including sessions in unrelated repos.
Mechanism
/exec creates the marker with a hardcoded name (skills/exec/SKILL.md, and both mirrors):
touch /tmp/claude-parallel-group-1.markerpre-tool.sh then resolves the worktree it enforces as: SEQUANT_WORKTREE, else the first matching marker file, with no project scoping:
# pre-tool.sh:63
PARALLEL_MARKER_PREFIX="${_TMPDIR}/claude-parallel-"
...
# pre-tool.sh:571-579
for marker in "${PARALLEL_MARKER_PREFIX}"*.marker; do
if [[ -f "$marker" ]]; then
EXPECTED_WORKTREE=$(head -1 "$marker" 2>/dev/null || true)
break
fi
done${_TMPDIR} is the shared user temp dir, and the group id (group-1) carries no project or session identity. Every session on the box globs the same namespace and takes the first hit.
Observed
While editing files in sequant's own worktree during work on #856, an Edit was rejected with a worktree path belonging to a different project's test run:
HOOK_BLOCKED: File operation must be within worktree
Worktree: /tmp/matcha-maps-worktree-test-59691-1785383831275/worktrees/feature/540-test
File: /Users/tony/Projects/worktrees/feature/856-.../src/lib/locks/lock-manager.integration.test.ts
It cleared on retry once the other run finished, which is what makes it nasty — it presents as a transient, unreproducible glitch rather than a namespace collision. Note the two failure branches are distinguishable: a marker pointing at a deleted directory yields HOOK_BLOCKED: Worktree does not exist, so the message above proves the foreign worktree was live at the time.
Impact
- Blocks legitimate edits in the correct worktree, with a confusing path from an unrelated repo.
- Worse — the inverse. Worktree enforcement exists to stop agents editing the main repo instead of the worktree. Whichever session loses the race gets its guard pointed somewhere meaningless, so the protection silently stops protecting for the duration.
- Cross-project by construction. The dogfood testbed (
sequantnpm-linked intoad-motion/matcha-maps) makes concurrent runs routine rather than exotic.
Acceptance Criteria
- AC-1: The marker filename includes a per-project component (e.g. a hash of the project root) so two projects running parallel groups simultaneously cannot collide.
- AC-2:
pre-tool.shandpost-tool.shmatch only markers belonging to the current project root, rather than globbing the whole${_TMPDIR}namespace and taking the first hit. - AC-3: A marker whose worktree path does not contain the current project root is ignored rather than enforced, so a stale or foreign marker cannot block edits.
- AC-4: The marker name is defined in exactly one place shared by the skill and both hooks, so the writer and the readers cannot drift apart.
- AC-5: A regression test starts a foreign marker pointing at an unrelated live directory and asserts an edit inside the real worktree is still permitted.
Non-Goals
- Not redesigning the parallel-group protocol or the isolation feature (Evaluate built-in worktree isolation for /exec parallel agent groups #485).
- Not changing
SEQUANT_WORKTREEprecedence — it stays authoritative when set.
Notes
All three skill copies must change together (skills/, templates/skills/, .claude/skills/), plus both hook mirrors (hooks/, templates/hooks/) — check-skill-sync and the sync lint cover the drift.
Found while working #856; unrelated to that issue's cause.
Activity
admarble commentedon Jul 31, 2026
📋 Plan Review — #881 (parallel-group marker is global)
Complexity: Standard (5 ACs, 3 mirrored dir-sets)
AC Quality Check
ACs are measurable and testable. One design tension to flag⚠️ :
/Users/tony/Projects/worktrees/feature/856-…) does not contain the project root (…/sequant) either. Implementing AC-3 literally would reject the legitimate marker too. The requirement (a foreign marker must not be enforced) is sound; the prescribed check is not. Recommendation: satisfy AC-3 by storing the owning project root inside the marker and comparing that to the current project — not by substring-matching the worktree path. Flagging per prior guidance that an AC's suggested design can violate its own requirement.Scope Assessment
Non-Goals: present and clear (no protocol redesign;
SEQUANT_WORKTREEstays authoritative). ✅__tests__Verdict: ✅ SCOPE_OK
Root Cause (verified in code)
skills/exec/SKILL.md:1526touch /tmp/claude-parallel-group-1.marker(empty file today).hooks/pre-tool.sh:63,636-642(PARALLEL_MARKER_PREFIX="${_TMPDIR}/claude-parallel-").pre-tool.sh:636pre-tool.sh:250andpost-tool.sh:84(post-tool has no enforcement, only enumeration).Acceptance Criteria + Verification
AC-1 — marker filename includes a per-project component.
Integration Test — Given a project root → When the marker path is computed → Then the filename contains
md5(project_root). Writer must also write worktree path (line 1) + owning project root (line 2) into the marker (today'stouchwrites an empty file — the worktree-path contract is currently vacuous; fix must populate it).AC-2 — hooks match only current-project markers at all three glob sites.
Integration Test — Given a foreign-project marker in
${_TMPDIR}→ When pre/post-tool run → Then it is not selected atpre-tool.sh:250/636orpost-tool.sh:84.AC-3 — foreign marker ignored (see tension above).
Integration Test — Given a marker whose stored owning project root ≠ current → Then it is ignored. (Implement via stored project root, not worktree-path containment.)
AC-4 — marker name defined in exactly one shared place.
Integration Test / drift check — grep asserts no independent hardcoded
claude-parallel-groupliteral survives in >1 site; covered additionally bycheck-skill-sync+sync-hooks.sh.AC-5 — regression test: foreign live marker present, edit inside the real worktree still permitted.
Integration Test — extend
__tests__/pre-tool-hook.integration.test.ts(parametrized over all 3 hook copies). SetTMPDIRto a hermetic dir; drop a foreign marker pointing at a real live unrelated dir; assert an Edit inside the real worktree exits 0. Mutation-verify (per repo testing rule): revert the scoping fix → confirm exactly AC-5 fails → restore → record in PR body.Implementation Plan
Phase 1 — single source of truth (AC-1, AC-4)
hooks/parallel-marker.shexposing the naming scheme + aparallel_marker_path <group-id>function that emits${_TMPDIR}/claude-parallel-${PROJECT_HASH}-<group-id>.marker. Reuse the existingmd5 -q … || md5sumidiom (pre-tool.sh:703) for cross-platform hashing.sourcethe helper; skill calls it instead of hardcoding:MARKER=$(…); { echo "$WORKTREE"; echo "$PROJECT_ROOT"; } > "$MARKER".Phase 2 — scope the readers (AC-2, AC-3)
3. Replace the glob at
pre-tool.sh:636,pre-tool.sh:250,post-tool.sh:84with the project-hashed prefix.4. AC-3 defense-in-depth: skip any marker whose line-2 owning project root ≠ current project root.
Phase 3 — mirror + regression (AC-5)
5. Apply identically across all mirrors:
skills/,templates/skills/,.claude/skills/(exec SKILL.md ×3) andhooks/,templates/hooks/(pre + post ×2). Runcheck-skill-sync+sync-hooks.sh.6. Add the mutation-verified AC-5 test.
Design Review
pre-tool.sh:703; same 3-copy mirroring + drift lint already guarding hooks/skills.Open Questions
CLAUDE_PROJECT_DIRenv if Claude Code sets it in both; (b)git rev-parse --show-toplevel/--git-common-dirfrom the file/cwd. A mismatch silently re-introduces the collision. Recommendation: verifyCLAUDE_PROJECT_DIRis present in the hook env; fall back to git toplevel of the file's dir. Impact if wrong: markers never match → enforcement silently disabled (the exact failure mode we're fixing).claude-lock-*(pre-tool.sh:703) andTIMING_LOGalso live in shared${_TMPDIR}. Locks are keyed by file-path hash so they lack the first-hit collision; timing-log coupling is fix(hooks):^gh (issue|pr)prefix skip disarms all 5 pre-tool guards for compound commands, and re-breaks on anycdprefix #763. Not expanding scope — flagging only.Recommended Workflow
Phases: spec → exec → qa
Quality Loop: disabled (SCOPE_OK) — but this weakens a safety guard across 6 mirrored files, so treat the AC-5 mutation-verification as a hard gate.
Testgen: skip a separate phase — the one required regression test slots into the existing
pre-tool-hook.integration.test.tsharness.Reasoning: cohesive single-mechanism bug fix with an established test harness; no UI, no new schema, no security phase (local dev hook, not auth/payments).
Label Review
Current:
bug— Recommended: keepbug. No label change needed.admarble commentedon Jul 31, 2026
✅ Exec complete — PR #888
Implemented the project-scoped parallel-group marker per the spec plan.
AC Verification
parallel-marker.sh:parallel_marker_prefix→claude-parallel-<md5(project-root)>-<group-id>.markerpre-tool.shenforcement + agent-id;post-tool.shagent-id — all scoped to the project prefixparallel-marker.sh(mirrored ×3) is the sole constructor; hooks +/execskill source it.claude-parallel-groupliteral now survives in zero other sites#881block inpre-tool-hook.integration.test.ts, parametrized over all 3 hook copies, + a positive controlDesign notes (per spec)
CLAUDE_PROJECT_DIR(set by Claude Code in both skill- and hook-context) with agit rev-parse --show-toplevelfallback — identical in writer and readers so they can't re-collide.Mutation verification (AC-5 — hard gate)
Reverted the reader scoping in one hook copy (global glob + neutralized owner guard) → exactly
AC-5 [templates/hooks/pre-tool.sh]failed (1 failed / 5 passed), reproducing the original cross-project block. Restored viagit checkout; all 6#881assertions pass.Checks
npm run build✅ (tsc clean) ·npm run lint✅ (eslint clean)pre-tool-hook.integration.test.ts+hook-sync.test.ts+check-skill-sync.test.ts→ 198 passedcheck-skill-sync(3 skill dirs) +sync-hooks(templates →.claude) in sync;hooks/plugin mirror updated tooFiles changed
templates/hooks/parallel-marker.sh(new) +hooks/,.claude/hooks/mirrorspre-tool.sh/post-tool.sh×3 hook dirsexec/SKILL.md×3 skill dirs__tests__/pre-tool-hook.integration.test.ts,CHANGELOG.mdQuality Plan Alignment: N/A — no Feature Quality Planning section in the spec comment.
admarble commentedon Jul 31, 2026
QA Review for Issue #881
Reviewed at commit
6915217917df7b3acc894c99b93c1c56105dc939(PR #888). Standard QA (522 insertions across 14 files; shell hooks + skill md + integration test).AC Coverage
parallel-marker.sh:parallel_marker_prefix→${TMPDIR}/claude-parallel-<md5(project-root)>-<group-id>.marker; reuses the established md5/md5sum-fallback idiom$PARALLEL_MARKER_PREFIX: pre-tool agent-id find (pre-tool.sh:272), pre-tool enforcement glob (:656), post-tool agent-id find. No unscopedclaude-parallel-*glob survives except the intentional helper-missing fallbackcontinues past any marker whose root ≠ current. Correctly implemented via stored project root, not worktree-path containment — resolving the spec's flagged AC-3 tension (worktrees are siblings, so containment would reject the legit marker)grep claude-parallel-groupreturns zero hits across all hook + skill dirs;parallel-marker.shis the sole constructor, sourced by both hooks and the/execskill#881describe block parametrized over all 3 hook copies, + a positive control proving same-project enforcement still fires. Mutation-verified in exec (reverting the reader scoping fails exactly AC-5). Independently re-ran: 198/198 pass (integration + hook-sync + skill-sync)Coverage: 5/5 AC items MET on the merits.
CI Status
mergeable: CONFLICTING,mergeStateStatus: DIRTY, statusCheckRollup empty. CI has not dispatched because the branch conflicts withorigin/main. The conflict is CHANGELOG.md only — origin/main'sfix(#856)(97b08e9) added an entry to the top of the same### Fixedsection, overlapping the #881 entry. This is a trivial merge-hygiene conflict (keep both entries), not a code conflict, but it blocks CI and merge until resolved. Branch is also 1 commit behind main (under the stale threshold — warning only).Quality Metrics
any)Drift Guards
check-skill-sync: 44/44 match (3 skill dirs in sync)hook-sync: templates/hooks ↔ .claude/hooks byte-identical for pre-tool.sh, post-tool.sh, and the new parallel-marker.shhooks/plugin mirror updated (incl. its divergent post-tool.sh)Test Coverage Analysis
Shell hooks have no unit harness, but the integration test spawns the real hook binaries across all three copies — the AC-5 block exercises both directions (foreign marker ignored / own marker still enforces). Adequate for a shell-guard change.
Risk Assessment
CLAUDE_PROJECT_DIR(set by Claude Code in both contexts) with a git-toplevel fallback; the positive-control test exercises the fallback path.md5-absent (Linux) hash branch isn't unit-exercised, but writer and reader call the same function so they cannot diverge.claude-lock-*andTIMING_LOGshare${TMPDIR}but were correctly left out of scope (locks are keyed by file-path hash → no first-hit collision; timing-log coupling is fix(hooks):^gh (issue|pr)prefix skip disarms all 5 pre-tool guards for compound commands, and re-breaks on anycdprefix #763). No other cross-file sibling with this root cause.Trust-Boundary Check
Finding: Clean — the diff implements only the product requirement (project-scoped marker naming); no agent-directed instruction from the issue body was acted on.
Status: Clean
Behavior-Rule Survival Check
The old global-glob behavior was removed from every reader site (verified: no unscoped
claude-parallel-*glob survives except the deliberate helper-missing fallback). Status: Clean / N/A (no default/always/never behavior-rule AC).Code Review
Strengths:
Non-blocking suggestions:
rm -f "${MARKER:-$(source "$MARKER_HELPER"; parallel_marker_path group-1)}"willsource ""if both$MARKERand$MARKER_HELPERare out of scope in a fresh shell → empty path, marker lingers until temp purge. Cosmetic (marker is harmless once its group finishes); worth a guard if revisited.CHANGELOG Verification
Result: Requirements met — but the entry is the source of the merge conflict above.
Adversarial Re-Read
Findings: Walked the diff against: (1) the AC-5 fixtures — foreign marker uses a non-md5 hash segment so it can never match the real prefix, and the positive control writes line-2 = own root so the guard accepts it; both directions genuinely exercised. (2) No "evidence" claim is a pre-fix repro — the mutation-verify flips exactly AC-5. (3) Process state: branch is CONFLICTING/DIRTY (surfaced above). (4) Sibling sites cited (cross-file + intra-file). (5) Non-Goals honored —
SEQUANT_WORKTREEprecedence untouched (still checked first), no protocol redesign. One process-state gap surfaced (the conflict), which drives the verdict.Status: Gaps Found (merge conflict / CI undispatched — external, not a code defect)
Verdict: NEEDS_VERIFICATION
All 5 ACs are MET and code quality is high (this would be READY_FOR_MERGE on the code alone). The blocker is external: the branch is CONFLICTING with
origin/main(trivial CHANGELOG overlap with #856), so CI never dispatched and the PR cannot merge. This is a merge-hygiene issue, not a code regression — resolve it and re-verify:git merge origin/mainin the worktree, resolveCHANGELOG.mdby keeping both the bug(exec/hooks): parallel-group marker filename is global — one project's /exec run redirects worktree enforcement for every concurrent session #881 and Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856### Fixedentries, commit the merge (do not rebase/force-push a pushed branch).git pushand confirm CI dispatches and goes green (the full vitest + lint + build + plugin/hook/skill validation matrix)./qa 881— with a green, mergeable branch this flips to READY_FOR_MERGE.Documentation: Before merge, optionally run
/docs 881(dev-tooling fix; README/user docs unaffected — the marker scheme is internal).admarble commentedon Jul 31, 2026
QA Review for Issue #881 — Verification Resolved
Follow-up to the full QA review at
69152179(verdict: NEEDS_VERIFICATION, blocked solely on the external merge-conflict/CI gate). The blocker is now cleared:What changed since the prior review
origin/maininto the branch (2291f4e5), resolving the CHANGELOG.md conflict by keeping both the bug(exec/hooks): parallel-group marker filename is global — one project's /exec run redirects worktree enforcement for every concurrent session #881 and Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856### Fixedentries. No code changes — the branch's diff vsorigin/mainis byte-identical to the reviewed scope (14 files, +522/−48).CI Status
CI Summary: 8 passed, 0 pending, 0 failed.
mergeable: MERGEABLE,mergeStateStatus: CLEAN.AC Coverage
Unchanged from the prior review — all 5 ACs MET (per-project marker hash, scoped globs at all 3 reader sites, stored-root foreign-marker guard, single shared
parallel-marker.shconstructor, mutation-verified AC-5 regression test; 198/198 tests, all skill/hook mirrors in sync).Coverage: 5/5 AC items MET.
Verdict: READY_FOR_MERGE
The prior review found the code merge-ready on its merits; the only gate was the conflicting branch blocking CI. That is resolved and the full check matrix is green.
Documentation: internal dev-tooling fix — CHANGELOG entry present; README/user docs unaffected.
/docs 881optional.docs(#881): document project-scoped parallel-group markers
admarble commentedon Aug 3, 2026
Documentation Generated
File:
docs/features/parallel-marker-scoping.md(commitf3fa25d5on PR #888)Sections Included:
HOOK_BLOCKEDsymptom, explained)SEQUANT_WORKTREEprecedence unchanged; foreign/stale markers ignored)Next Steps:
Ready to merge!
fix(#881): scope parallel-group marker filename per project (#888)