Cross-repo worktree isolation for parallel agents #188
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-platform#188
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
Standalone — discovered during parallel agent incident on 2026-03-26 where three Dev agents clobbered each other's branches on
westside-playground.Repo
forgejo_admin/pal-e-platform(this issue — where the gap was discovered)ldraney/claude-custom(hooks + agent profiles)pal-e-docsvia MCP tools (worktree-workflow, agent-spawn-conventions)User Story
As a platform operator spawning parallel Dev agents
I want cross-repo isolation so that agents working on repos OTHER than the spawning repo get their own isolated checkout
So that parallel agents cannot clobber each other's branches and working trees
Context
The
worktree-workflowSOP (pal-e-docs slug:worktree-workflow) documents isolation for the spawning repo. When Betty Sue spawns a Dev agent withisolation: "worktree", Claude Code creates a worktree at.claude/worktrees/agent-{id}/inside the spawning repo. This works perfectly for single-repo work.The gap: agents frequently work on repos OTHER than the spawning repo. For example, an agent spawned from
pal-e-platformmay need to work onwestside-playground,pal-e-docs-sdk, orbasketball-api. In this case, the target repo has no isolation — all agents share the same~/westside-playground/checkout. The spawning repo's worktree isolation is irrelevant because the actual code changes happen in a completely different directory.Incident (2026-03-26): Three parallel Dev agents were spawned to work on
westside-playground. All three rancd ~/westside-playground && git checkout ...against the same shared checkout. They clobbered each other's branches, staged files, and working tree state. Work was lost and had to be redone.Root cause: The
worktree-workflowSOP andagent-spawn-conventionsassume agents work on the spawning repo. There is no convention, SOP, or enforcement mechanism for cross-repo isolation.File Targets
This is a multi-repo concern. The work spans documentation (pal-e-docs SOPs) and enforcement (claude-custom hooks/agent configs):
Enforcement (claude-custom repo — primary PR target
ldraney/claude-custom):hooks/cross-repo-isolation.sh(new) — PreToolUse hook that detects when an agent runscd ~/other-repo && git checkouton a shared checkout and warns/blocksagents/dev.md— add cross-repo isolation instructions to the agent profileSOP updates (pal-e-docs, via Dottie — separate child issue):
worktree-workflow— add "Cross-Repo Isolation" section documenting the/tmp/clone orgit worktree addconvention for target reposagent-spawn-conventions— add cross-repo isolation to the Pre-Spawn ChecklistPlatform (this repo):
claude-customandpal-e-docs.Files the agent should NOT touch:
terraform/— no infrastructure changes neededsalt/— no Salt changes neededAcceptance Criteria
/tmp/{repo}-{branch}or usesgit worktree addon the target repo — nevercd ~/shared-checkout && git checkoutworktree-workflowSOP documents the cross-repo isolation convention with clear examplesagent-spawn-conventionspre-spawn checklist includes a cross-repo isolation stepclaude-customwarns when an agent attemptscd ~/repo && git checkouton a shared checkout (the hook should detect the pattern and suggest the isolated alternative)agents/dev.md) includes instructions for cross-repo isolation/tmp/clones cleaned up after agent completes (cleanup script or convention incleanup-worktrees.sh)Test Expectations
cd ~/repo && git checkoutpatternisolation: worktree)bash hooks/cross-repo-isolation.shwith mock inputs to validate pattern detectionConstraints
worktree-workflowSOP structure — add a new section, don't restructure/tmp/clone pattern is already precedented in the SOP ("Some pal-e-docs worktrees were manually placed in /tmp. Not standard." — make it standard for cross-repo)CLAUDE.mdinpal-e-platformalready has## Worktree Isolationreferencing/tmp/clones forclaude-custom— align with that conventionisolation: worktree(which only handles the spawning repo)Decomposition
This umbrella issue tracks the full scope. Execution is split into 2 child issues per the 5-minute rule:
Child 1:
ldraney/claude-custom— Hook + Agent Profilehooks/cross-repo-isolation.shPreToolUse hookagents/dev.mdwith cross-repo isolation instructions/tmp/clone cleanup tocleanup-worktrees.shChild 2:
pal-e-docsSOP Updates (Dottie)worktree-workflowSOP with "Cross-Repo Isolation" sectionagent-spawn-conventionspre-spawn checklistNote:
claude-custom#184covers adjacent gaps (freshness, cleanup) but NOT the cross-repo isolation hook or/tmp/clone convention — no overlap.Board Labels
arch:worktree(notarch:ci-pipeline— this is worktree/hooks domain, not Woodpecker CI)story:dev-executeChecklist
ldraney/claude-customfor hook + agent profileworktree-workflowSOP updatedagent-spawn-conventionsupdated/tmp/cleanup mechanism in placeRelated
worktree-workflow(pal-e-docs SOP) — the existing isolation SOP that needs the cross-repo sectionagent-spawn-conventions(pal-e-docs convention) — pre-spawn checklist needs cross-repo stepclaude-customrepo — hooks and agent configs live hereclaude-custom#184— adjacent worktree gaps (freshness, cleanup) — no overlap with this issuetodo-worktree-staleness-prevention(pal-e-docs) — prior incident that motivated the freshness check (same class of problem: isolation gap)Body updated 2026-03-27 from review comments #7887, #7900, #8755, #9553. Refinements merged: PR target clarification, /tmp/ cleanup AC, QA exclusion constraint, decomposition plan, arch label correction.
Scope Review: NEEDS_REFINEMENT
Review note:
review-418-2026-03-25Well-scoped issue with thorough context and verified file targets, but three items need resolution before moving to next_up:
type:bug, issue says### Type: Feature-- must agreestory:label on board item #418 -- suggeststory:dev-executepal-e-platformbut code changes land inclaude-custom-- clarify PR target or create child issue onclaude-customNon-blocking recommendations: add
/tmp/cleanup acceptance criterion, consider QA agent cross-repo isolation scope.Refinements from review-418-2026-03-25:
Type: Bug (not Feature). This is broken behavior — agents should be isolated but aren't. Updating issue type.
Repo placement: Primary PR lands on
ldraney/claude-custom(hooks + agent profiles). SOP updates land in pal-e-docs via MCP tools. Issue stays on pal-e-platform (where the gap was discovered) as the tracking repo.Cleanup criterion added:
/tmp/clones need cleanup too — add to acceptance criteria.QA agents: QA agents are read-only (no Write/Edit tools) so they can't clobber branches. Cross-repo isolation is Dev-agent-only.
Scope Review (re-review): NEEDS_REFINEMENT
Review note:
review-418-2026-03-25-r2Refinements addressed findings in comments but issue body was never updated. One of three original findings resolved, two persist.
Resolved:
Still open:
type:bug, issue body still says### Type: Feature. Refinement comment declared "updating" but body unchanged. Recommend aligning totype:featureon the board item -- the issue body is structured as a Feature (User Story, Context, File Targets, Constraints) and would need full restructuring to match the Bug template.ldraney/claude-custom, (b) Acceptance Criteria: add/tmp/cleanup criterion, (c) Constraints: note QA agents excluded.Once the board label is aligned and the issue body is updated with the refinement content, this ticket is READY.
CONSOLIDATED SPEC (supersedes issue body where conflicts exist):
Type
Feature (not Bug — the body is structured as a feature)
PR Targets
ldraney/claude-custom— hook + agent profile changespal-e-docsvia MCP tools (worktree-workflow, agent-spawn-conventions)Additional Acceptance Criterion
/tmp/clones cleaned up after agent completes (cleanup script or convention)Additional Constraint
Scope (unchanged from body)
agents/dev.mdwith cross-repo isolation instructionsworktree-workflowSOP in pal-e-docsagent-spawn-conventionsSOP in pal-e-docshooks/cross-repo-isolation.shPreToolUse hook (or equivalent enforcement)Scope Review: NEEDS_REFINEMENT
Review note:
review-418-2026-03-27Third review. Prior findings (type mismatch, missing story label) are resolved. Two issues remain:
claude-customfor hook + agent profile (AC 1,2,5,6,7), (2) Dottie ticket for SOP updates (AC 3,4). Keep #188 as umbrella tracker.Blast radius notes:
cleanup-worktrees.shdoes not handle/tmp/clones -- the cleanup mechanism needs to be part of the decomposed Dev ticket scope.Scope Review: NEEDS_REFINEMENT
Review note:
review-418-2026-03-27-r2Fourth review (R4). R3's two required actions were NOT completed — issue body still has comment-only refinements and no proper decomposition.
Three actions required before READY:
[BODY]Merge comment #7900 refinements into the issue body (PR target clarification, /tmp/ cleanup AC, QA exclusion constraint). Dev agents read the body, not comments. Same finding as R3.[DECOMPOSE]Create child issues for the unique scope of #188.claude-custom#184covers adjacent gaps (freshness, cleanup) but NOT the cross-repo isolation hook or /tmp/ clone convention. Need: (1) claude-custom issue forcross-repo-isolation.sh+dev.mdupdate, (2) pal-e-docs issue for SOP updates.[LABEL]Changearch:ci-pipelinetoarch:worktreeon board item #418. Perconvention-architecture-ids,ci-pipeline= Woodpecker CI; this work is worktree/hooks domain.Issue body refined (Dottie, responding to review-418-2026-03-27-r2 findings):
All three R4 required actions addressed in the body update:
[BODY] Merged refinements from comment #7900:
/tmp/clone cleanup after agent completes[DECOMPOSE] Decomposition plan added:
ldraney/claude-custom— hook + agent profile + cleanup (AC 1,2,5,6,7)pal-e-docsSOP updates via Dottie (AC 3,4)claude-custom#184covers adjacent gaps, no overlap documented[LABEL] Board label correction documented:
arch:worktree(notarch:ci-pipeline)Remaining before READY: Apply
arch:worktreelabel on board item #418, create the 2 child issues.Decomposition Complete
2 child work items created per the decomposition plan:
claude-custom#205worktree-workflowSOP +agent-spawn-conventionschecklistChild 2 is a Dottie (doc librarian) task — SOP content updates via MCP tools. No Forgejo issue needed; Dottie executes directly against pal-e-docs notes when this parent is picked up.
Child 1 references this parent in Lineage.
Scope Review: NEEDS_REFINEMENT
Review note:
review-418-2026-03-28Well-scoped umbrella issue after 4 prior review rounds. All template sections present, all file targets verified, decomposition into 2 children is clean. One finding:
[LABEL]Board item #418 hasarch:ci-pipelinebut issue body explicitly corrects toarch:worktree. The label was never updated to match. Fix the label and this is READY.