Skip to content

analysis: root cause analysis for #59 (worktree teardown deletes branch-committed skills)#60

Closed
stempeck wants to merge 1 commit into
mainfrom
af/rootcause-all-2a7c06
Closed

analysis: root cause analysis for #59 (worktree teardown deletes branch-committed skills)#60
stempeck wants to merge 1 commit into
mainfrom
af/rootcause-all-2a7c06

Conversation

@stempeck

Copy link
Copy Markdown
Owner

Summary

Root cause analysis for #59, produced by the rootcause-all formula. This PR carries the analysis artifacts only (under .analysis/af-6bc9e66f/) — it is not the code fix, so it does not close the issue.

  • 10/10 concerns investigated and VALIDATED by parallel sub-agents, each with code references and (mostly) empirical repro.
  • Primary root cause: cleanupMergedSkills (internal/worktree/worktree.go:507-522) decides what to delete by inferring provenance from a name collision with the live factory .claude/skills/, instead of recording what the lifecycle actually merged in — so branch-committed skills whose directory name collides with a factory skill get os.RemoveAll'd on teardown. Identified as the 4th recurrence of the anti-pattern ADR-017 forbids.
  • Selected solution (git provenance): gate deletion on git-tracked status — a skill dir tracked in the worktree's index is branch content (preserve); an untracked name-colliding dir is a merge copy (remove). Robust to the byte-identical case, needs no schema/migration, localized to cleanupMergedSkills so all teardown paths inherit the fix. Also resolves the ordering hazard (concern feat: Eliminate Manual File Moves After agent-gen #7) with no separate change.
  • Includes Files-to-Modify, implementation code for cleanupMergedSkills + trackedSkillDirs, a regression test, enforcement-level classification (the fix is an Interlock), and verification steps.

See .analysis/af-6bc9e66f/rootcause_analysis.md for the synthesized findings and solution; per-concern investigations are in the sibling rootcause_concern_*.md files.

Next step

Implementation of the selected solution (intended for the ultra-implement pass).

Relates to #59.

🤖 Generated with Claude Code

Root cause analysis for the worktree-teardown skill-deletion bug
(GitHub issue #59, bead af-6bc9e66f), produced by the rootcause-all
formula. Artifacts under .analysis/af-6bc9e66f/.

Synthesized root cause: cleanupMergedSkills infers what to delete from
name-collision with the live factory .claude/skills/ instead of recording
merge provenance, so branch-committed skills whose names collide with a
factory skill are destroyed on teardown. Selected fix: gate deletion on
git-tracked status (git ls-files) in the worktree; preserve tracked dirs.

Co-Authored-By: Claude <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


agentfactory seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@stempeck

Copy link
Copy Markdown
Owner Author

Resolved.

@stempeck stempeck closed this Jun 13, 2026
@stempeck stempeck deleted the af/rootcause-all-2a7c06 branch June 13, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants