You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
investigation(worktrees): can native WorktreeCreate/WorktreeRemove hooks replace src/lib/worktree-isolation.ts? #1192
Follow-up from #1135 (upstream gap review, 2026-09-24). Claude Code v2.1.50 added the WorktreeCreate and WorktreeRemove hook events for native isolation: worktree. Sequant manages its own worktrees for parallel exec groups in src/lib/worktree-isolation.ts. #632 deferred moving onto native isolation, citing upstream #47548, and #485 (closed) evaluated built-in isolation before these hook events existed.
Question to answer first
Can the WorktreeCreate hook do what worktree-isolation.ts does today (dependency bootstrap, branch naming, cleanup), so that native isolation: worktree subagents become viable for exec parallel groups? Or does upstream #47548 or #43869 (subagent model routing) still block it?
Acceptance criteria
AC-1: an investigation note in docs/investigations/ maps each responsibility of src/lib/worktree-isolation.ts to a native hook capability or to "not covered", citing a real run of a WorktreeCreate hook — Evidence: ls docs/investigations/native-worktree-hooks-*.md
AC-2: the note ends with a decision of adopt, partial, or keep, plus rejected alternatives, and records whether upstream #47548 is still open on that date — Evidence: grep -n "^## Decision" docs/investigations/native-worktree-hooks-*.md
May touch
docs/investigations/ (one new note).
Non-Goals
Any edit under plugin/, .claude/skills/ or templates/skills/ (plugin freeze, I-1 of the graph doc).
Any change to worktree-isolation.ts in this issue. Adoption, if chosen, is filed separately.
Runner context for the phase agents (graph-2026-10-freeze, wave 2). This applies to spec, exec and qa by name.
This is a docs-only investigation. The deliverable is one note in docs/investigations/, and no src/ change.
AC-1 needs a real run of a WorktreeCreate hook. Keep it short and in the foreground: a throwaway temp git repo with a minimal .claude/settings.json registering a WorktreeCreate hook that logs its stdin payload, and one claude -p call (with timeout) that spawns an isolation: worktree subagent. Paste the logged payload and the Claude Code version. Never background a claude or sequant run process (Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856). If a nested run isn't possible inside the phase, say so in the note and the runner will run the probe outside the session.
Check upstream #47548's state on the day (AC-2) with gh issue view 47548 --repo anthropics/claude-code --json state,updatedAt.
The repo is public, and docs/ is published. No local paths, private repo names or session ids in the note.
Plugin freeze (graph doc I-1): the diff must not touch plugin/, .claude/skills/ or templates/skills/.
lintAcceptanceCriteria: 2/2 pass. Both ACs are one line and have an Evidence: clause. Both Evidence commands fail on main today (no docs/investigations/native-worktree-hooks-*.md yet), so neither check passes already.
⚠️The Evidence commands only check that the file and a heading exist. They don't check the substance: that every responsibility is mapped, that a real hook payload is pasted, that the #47548 line is there, or that rejected alternatives are listed. /qa has to read the note against the AC text. A file or heading check alone isn't enough.
⚠️The title says "note" but AC-1 needs a real run. The runner comment covers this: one foreground probe, with a fallback where the runner runs it outside the session.
Scope Assessment
Non-Goals: no edits under plugin/, .claude/skills/ or templates/skills/ (plugin freeze I-1). No change to worktree-isolation.ts.
Metric
Value
Status
Feature count
1
✅
AC items
2
✅
Directory spread
1 (docs/investigations/)
✅
Verdict: ✅ SCOPE_OK. There is no in-flight overlap. #1067 touches different files in docs/investigations/.
Upstream #43869 (subagent model routing) is still OPEN. The note should say whether it blocks isolation specifically, or affects every sequant-implementer spawn whether isolated or not. It is probably the second.
Local CLI is 2.1.296. That is far past v2.1.50, where the hooks were added.
Acceptance Criteria
AC-1: Note maps each worktree-isolation.ts responsibility to a native capability or "not covered", citing a real WorktreeCreate run
Verification: Manual review of the note's content. The Evidence ls only shows the file exists. Scenario: Given the note → When QA compares the mapping table with src/lib/worktree-isolation.ts → Then each row below has a native counterpart or "not covered", and the note includes the logged stdin payload and the claude --version string.
Responsibilities that must each have a row:
#
Responsibility
Source
R1
Location: .exec-agents/agent-N/ inside the issue worktree
createSubWorktree, SUB_WORKTREE_DIR
R2
Branch name exec-agent-<issue>-<N>
agentBranchName
R3
Base ref is the issue branch HEAD, not the default branch
createSubWorktree (worktree add -b from the issue worktree)
R4
node_modules is symlinked from the issue worktree
createSubWorktree
R5
Env and settings files copied via .worktreeinclude, or the defaults
getIncludeFiles
R6
Merge-back with --no-ff, conflict detection, merge --abort
mergeBackSubWorktree, mergeAllSubWorktrees
R7
Remove the worktree and delete its branch
cleanupSubWorktree
R8
Clean up orphans left by interrupted sessions (prune, exec-agent-* sweep)
cleanupOrphanedSubWorktrees
R9
Merge result reporting
formatMergeResult
Consumers to name in the note, without editing them: scripts/worktree-isolation.ts (CLI wrapper), exec SKILL steps 1b and 5b, and docs/reference/worktree-isolation.md.
AC-2: Note ends with ## Decision (adopt / partial / keep), rejected alternatives, and the #47548 state on the day
Verification: Manual review. The Evidence grep only finds the heading. Scenario: Given the note → When QA reads its last ## section → Then it is ## Decision and contains exactly one of adopt/partial/keep, at least one rejected alternative with a reason, and the output of gh issue view 47548 --repo anthropics/claude-code --json state,closedAt,updatedAt with the date.
Implementation Plan
Phase 1: Probe (foreground only, one temp repo)
Create a throwaway repo in mktemp -d with one commit and a feature branch checked out, so the base ref is something other than the default branch. Add .claude/settings.json with WorktreeCreate and WorktreeRemove hooks that append their stdin to a log file. Add a .worktreeinclude and an untracked .env.
P2: does the hook replace worktree creation (Claude uses the path the hook prints) or run alongside it?
P3: the parent's branch before and after (the #47548 regression check), and which ref the new worktree is based on
P4: the location and branch name Claude picks when no hook overrides it
P5: when WorktreeRemove fires (change made vs. no change) and its payload
P6: what the subagent result returns for merge-back (path and branch)
P7: whether .worktreeinclude is copied natively
Phase 2: Note
Write docs/investigations/native-worktree-hooks-2026-10.md in the shape of codex-driver-probe-2026-09.md: header (issue, date, CLI version), a summary table, the probe method, the redacted payload, the R1–R9 mapping table, the #43869 assessment, and ## Decisionas the last section.
Redact before committing. Replace temp paths, the username, and any session_id or transcript_path values with placeholders (<tmp>, <session>). The repo is public. Check with grep -nE '/Users/|/var/folders|session_id": "[0-9a-f-]{8}' on the note.
If the decision is adopt or partial, include the text for the follow-up issue in the note. Don't file it (Non-Goals: adoption is filed separately).
Design Review
Where does this logic belong? In one new note in docs/investigations/. No src/ changes and no skill changes, because of the plugin freeze.
Simplest correct approach? One probe run, plus a second run without the hook only if P4 can't be answered from the first. Rejected: reasoning from upstream docs without running anything, because AC-1 requires a real run and Evaluate built-in worktree isolation for /exec parallel agent groups #485 already evaluated native isolation on paper.
What a reviewer would challenge: "R6/R8 merge-back and orphan sweep aren't hook concerns, so the answer is obviously partial." Possibly. But R3 (base ref) and P2 (replace vs. run alongside) decide whether any adoption works, and only the probe can answer them.
Producers and consumers: The only producer of the sub-worktree artifact is src/lib/worktree-isolation.ts. Its consumers are scripts/worktree-isolation.ts, exec SKILL 1b/5b, src/lib/worktree-isolation.test.ts, and both worktree-isolation docs. The note lists them and doesn't edit any.
Feature Quality Planning
Public-docs hygiene (step 5) is the main risk.
Derived: pasting the raw payload makes AC-1 checkable. QA can run grep -n 'WorktreeCreate' <note> and expect a match inside a fenced payload block.
Open Questions
What if the phase can't run a nested claude -p? Recommendation: exec writes the note with a clearly marked Probe: pending (runner) section and reports AC-1 as blocked, not met. It doesn't fill in a mapping from guesses. Impact if handled wrong: a guessed mapping lands as "evidence".
Filename. Recommendation: native-worktree-hooks-2026-10.md. It matches both Evidence globs.
Probe model and cost. Recommendation: the default parent model with a short prompt and one subagent. #43869 means the subagent's model can't be pinned anyway.
Recommended Workflow
Phases: exec → qa Quality Loop: disabled Reasoning: This is a docs-only investigation. The parser infers integration_test from both Evidence commands, but they are file and heading checks with nothing to stub, so testgen is skipped. QA must review the content (see the AC Quality Check above).
Activity
docs(#1390): graph-2026-10-freeze founding doc, issue graph and as-fi…
admarble commentedon Oct 10, 2026
Runner context for the phase agents (graph-2026-10-freeze, wave 2). This applies to spec, exec and qa by name.
docs/investigations/, and nosrc/change.WorktreeCreatehook. Keep it short and in the foreground: a throwaway temp git repo with a minimal.claude/settings.jsonregistering aWorktreeCreatehook that logs its stdin payload, and oneclaude -pcall (withtimeout) that spawns anisolation: worktreesubagent. Paste the logged payload and the Claude Code version. Never background aclaudeorsequant runprocess (Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856). If a nested run isn't possible inside the phase, say so in the note and the runner will run the probe outside the session.gh issue view 47548 --repo anthropics/claude-code --json state,updatedAt.docs/is published. No local paths, private repo names or session ids in the note.plugin/,.claude/skills/ortemplates/skills/.admarble commentedon Oct 10, 2026
Complexity: Simple (2 ACs, 1 directory). Docs-only investigation.
AC Quality Check
lintAcceptanceCriteria: 2/2 pass. Both ACs are one line and have anEvidence:clause. Both Evidence commands fail onmaintoday (nodocs/investigations/native-worktree-hooks-*.mdyet), so neither check passes already./qahas to read the note against the AC text. A file or heading check alone isn't enough.Scope Assessment
Non-Goals: no edits under
plugin/,.claude/skills/ortemplates/skills/(plugin freeze I-1). No change toworktree-isolation.ts.docs/investigations/)Verdict: ✅ SCOPE_OK. There is no in-flight overlap. #1067 touches different files in
docs/investigations/.Premise check (as of 2026-10-10)
sequant-implementerspawn whether isolated or not. It is probably the second.Acceptance Criteria
AC-1: Note maps each
worktree-isolation.tsresponsibility to a native capability or "not covered", citing a realWorktreeCreaterunVerification: Manual review of the note's content. The Evidence
lsonly shows the file exists.Scenario: Given the note → When QA compares the mapping table with
src/lib/worktree-isolation.ts→ Then each row below has a native counterpart or "not covered", and the note includes the logged stdin payload and theclaude --versionstring.Responsibilities that must each have a row:
.exec-agents/agent-N/inside the issue worktreecreateSubWorktree,SUB_WORKTREE_DIRexec-agent-<issue>-<N>agentBranchNamecreateSubWorktree(worktree add -bfrom the issue worktree)node_modulesis symlinked from the issue worktreecreateSubWorktree.worktreeinclude, or the defaultsgetIncludeFiles--no-ff, conflict detection,merge --abortmergeBackSubWorktree,mergeAllSubWorktreescleanupSubWorktreeexec-agent-*sweep)cleanupOrphanedSubWorktreesformatMergeResultConsumers to name in the note, without editing them:
scripts/worktree-isolation.ts(CLI wrapper), exec SKILL steps 1b and 5b, anddocs/reference/worktree-isolation.md.AC-2: Note ends with
## Decision(adopt / partial / keep), rejected alternatives, and the #47548 state on the dayVerification: Manual review. The Evidence
greponly finds the heading.Scenario: Given the note → When QA reads its last
##section → Then it is## Decisionand contains exactly one of adopt/partial/keep, at least one rejected alternative with a reason, and the output ofgh issue view 47548 --repo anthropics/claude-code --json state,closedAt,updatedAtwith the date.Implementation Plan
Phase 1: Probe (foreground only, one temp repo)
mktemp -dwith one commit and a feature branch checked out, so the base ref is something other than the default branch. Add.claude/settings.jsonwithWorktreeCreateandWorktreeRemovehooks that append their stdin to a log file. Add a.worktreeincludeand an untracked.env.timeout 300 claude -p "…"call that spawns anisolation: worktreesubagent, and have the subagent make and commit one file change. Recordclaude --version. Never background it (Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856). If a nestedclaudecan't run inside the phase, stop and say so in the note (see OQ1).gitstate:WorktreeRemovefires (change made vs. no change) and its payload.worktreeincludeis copied nativelyPhase 2: Note
docs/investigations/native-worktree-hooks-2026-10.mdin the shape ofcodex-driver-probe-2026-09.md: header (issue, date, CLI version), a summary table, the probe method, the redacted payload, the R1–R9 mapping table, the #43869 assessment, and## Decisionas the last section.session_idortranscript_pathvalues with placeholders (<tmp>,<session>). The repo is public. Check withgrep -nE '/Users/|/var/folders|session_id": "[0-9a-f-]{8}'on the note.Design Review
docs/investigations/. Nosrc/changes and no skill changes, because of the plugin freeze.codex-driver-probe-2026-09.md,advisor-tool-phase0-2026-09.md). It is the third evaluation of native isolation, after Evaluate built-in worktree isolation for /exec parallel agent groups #485 (closed) and fix(agents): realign declared model tiers; document upstream routing bug #632 (deferred). Those were deferred decisions, not fixes, so the recurrence stop doesn't apply. The note should say what changed since fix(agents): realign declared model tiers; document upstream routing bug #632: the hooks exist and #47548 is closed.src/lib/worktree-isolation.ts. Its consumers arescripts/worktree-isolation.ts, exec SKILL 1b/5b,src/lib/worktree-isolation.test.ts, and both worktree-isolation docs. The note lists them and doesn't edit any.Feature Quality Planning
grep -n 'WorktreeCreate' <note>and expect a match inside a fenced payload block.Open Questions
claude -p? Recommendation: exec writes the note with a clearly markedProbe: pending (runner)section and reports AC-1 as blocked, not met. It doesn't fill in a mapping from guesses. Impact if handled wrong: a guessed mapping lands as "evidence".native-worktree-hooks-2026-10.md. It matches both Evidence globs.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: This is a docs-only investigation. The parser infers
integration_testfrom both Evidence commands, but they are file and heading checks with nothing to stub, so testgen is skipped. QA must review the content (see the AC Quality Check above).Label Review
Current:
graph-2026-10-freeze· Recommended: addplanned· Quality Loop: won't auto-enable (SCOPE_OK).admarble commentedon Oct 10, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 2/2 met
Gaps:
docs(#1192): record the P5 WorktreeRemove re-probe; adoption follow-u…
docs(#1192): native WorktreeCreate/WorktreeRemove hooks vs worktree-i…