Skip to content

fix(source-control): reap script enters --worktree-path and refuses a main working tree - #8181

Merged
kyle-sexton merged 5 commits into
mainfrom
work-resolve-issue/issue-7132-39106137801-1
Oct 19, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
work-resolve-issue/issue-7132-39106137801-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #7132

Summary

Opened by the work-resolve-issue lane. The run's own summary:

reap-project-plugin-records.sh now resolves --worktree-path, refuses a main working tree (its .git is a directory) before any directory change, then cds into the path itself. The cwd-equality refusal is gone, so the reap runs from a worktree-isolated session. Docs and tests follow the new contract.

Not verified

  • Main checkouts whose .git is a file (git init --separate-git-dir, submodules) are not caught by the .git-is-a-directory test; the recorded decision's alternative git-dir == git-common-dir test was not added. The caller's husk and empty-orphan guards still apply.
  • check-skill babysit-prs failed on sandbox read-only filesystem errors in its own tests, not on files this change touches
  • Code review ran as a fresh-context subagent; the repository's own CI review lane was not consulted

Fix

  • plugins/source-control/scripts/reap-project-plugin-records.sh: main-working-tree refusal, internal cd, header and comments updated
  • plugins/source-control/scripts/reap-project-plugin-records.test.sh: replaced cwd-equality case with must-refuse (main tree) and stay-quiet (unrelated cwd, linked worktree) cases; settings-restore fixtures now use linked worktrees
  • plugins/source-control/skills/worktree/context/cleanup.md: dropped cd <path> && and the cwd prose
  • plugins/source-control/skills/worktree/SKILL.md: reap no longer needs to run from inside the candidate
  • plugins/source-control/skills/worktree/fixtures/README.md: updated what the helper enforces
  • .changes/source-control/fix-reap-enters-worktree-path-7132a4c1.md: patch fragment

Verification

The run reports:

  • run-test-file plugins/source-control/scripts/reap-project-plugin-records.test.sh: all 85 cases passed
  • check-changelog-fragments: all 3 fragments valid
  • check-skill on plugins/source-control/skills: worktree passes with 0 errors; babysit-prs fails only on tests that write to a read-only /home/runner/.claude in this sandbox, unrelated to this change
  • fresh-context subagent review of the diff: no confirmed blocking defects; one garbled comment fixed
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/39106137801

Left out: the items under Not verified.

Related

#7132

melodic-automation-lanes Bot and others added 2 commits October 18, 2026 09:56
… main working tree

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

claude-review needs no new review of 4ff44f4cb6de067e36190d44a1c69a7df611f3a7: no file of this pull request changed since the review of 4c2a605.

No blocking findings.

Scope: I read the whole diff (6 files) against the PR context and closing issue #7132. I did not run the test file myself. The "85 cases passed" figure in the PR body is author-claimed and unverified by me.

Closing issue #7132 acceptance criteria

  • Run from outside a linked worktree. Met. The new "the caller's cwd does not matter" case runs from $OTHER. It asserts exit 0, that a@m is reaped, that b@m is left, and that the uninstall step ran.
  • Main working tree is refused. Met. Two fixtures are added: .git as a directory, and git init --separate-git-dir. Each asserts exit 2, nothing removed, and no CLI call.
  • Test file and changelog fragment passing. I did not run either. The fragment is present and has bump: patch.

Checks that held up

  • The refusal runs before the cd, as the recorded decision requires. The -s project, --keep-data and never--s user rules are unchanged.
  • A husk (a .git file whose admin dir is gone) fails git rev-parse, so the git-dir test is skipped and the husk stays reapable. A submodule or separate-git-dir main has git dir equal to common dir, so it is refused.
  • have is defined at line 71, before its new use.
  • The --dry-run assertion is relaxed to filter out only the one rev-parse call. It still catches any other git call.

Minor notes, not blocking

  • The PR body's "Not verified" section says the git-dir == common-dir test was not added. The diff adds it, with a test. The body is stale; the code and fragment are correct.
  • The git-dir test fails open when git rev-parse --path-format=absolute errors, for example on a git older than 2.31 or an unresolvable path. A separate-git-dir main would then pass the guard. This is intended for husks and is a narrow edge, so I am not flagging it.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review needs no new review of 4ff44f4cb6de067e36190d44a1c69a7df611f3a7: no file of this pull request changed since the review of 4c2a605.

Security review: PR 8181 (head 4c2a605)

No security issues found. This was a seat-run, so nothing was posted to GitHub.

The PR changes reap-project-plugin-records.sh. It used to require that the caller's cwd equal --worktree-path. It now refuses a main working tree, then enters the path itself.

  • The new guard:
    • It refuses a path whose .git is a directory.
    • It also refuses a path whose git dir equals its common dir, which covers --separate-git-dir checkouts and submodules.
    • The git call is git rev-parse, which doesn't run repo-configured hooks or commands.
    • If git can't resolve the path (a husk), the check is skipped and the script proceeds to enter the directory. That is intended and the test pins it.
  • The weaker check: The old guard let the script act only on its own cwd. The new one lets any non-main directory be named. I rate this low-risk, with no concrete exploit path in the diff. The caller is the trusted /source-control:worktree cleanup skill, not external input. The reap only runs claude plugin uninstall <id> -s project --keep-data, and the CLI matches only records whose projectPath equals the cwd. It never calls -s user or --prune. The unmounted-share rule (never reap on bare path non-resolution) is kept verbatim in SKILL.md.
  • Instruction-surface edits: The SKILL.md and cleanup.md edits drop the "run from inside the candidate" instruction. The script enforces the replacement guard, a main-tree refusal in code, and the test file pins it. The instruction exception register file was not consulted. I judged each removed rule by its consequence instead.
  • Path handling: $arg_native is always quoted and passed to cd and git -C as a single argument, so there is no injection surface.

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 18, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped on this pull request and needs a person: the merge stages a change under .github/workflows/, which the lane does not push.

  • Reason: workflow-staged
  • Resume key: f3f0f0d966368ce80c6c9ef64481a8d517d5d2d0 (the head the lane stopped on)

To resume, deal with the reason above, remove the needs-human label (and do-not-merge, if set), then dispatch the pr-unblock workflow with pr-number=8181 and activity=resolve-conflicts:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=8181 -f activity=resolve-conflicts

…sue-7132-39106137801-1

# Conflicts:
#	plugins/source-control/skills/worktree/SKILL.md
#	plugins/source-control/skills/worktree/context/cleanup.md
@kyle-sexton kyle-sexton added needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. and removed needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. labels Oct 18, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: risk MED at head 258df281a9d19770f00c490db8e82e7c56d7d98a. Only LOW merges without a human; this pull request waits for one.

MED findings:claude-review: 2 open

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 19, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped on this pull request and needs a person: the merge stages a change under .github/workflows/, which the lane does not push.

  • Reason: workflow-staged
  • Resume key: 258df281a9d19770f00c490db8e82e7c56d7d98a (the head the lane stopped on)

To resume, deal with the reason above, remove the needs-human label (and do-not-merge, if set), then dispatch the pr-unblock workflow with pr-number=8181 and activity=resolve-conflicts:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=8181 -f activity=resolve-conflicts

Compose the header with main's local-scope note. The reap now also refuses a
.git-file main checkout (git init --separate-git-dir, a submodule), with a
must-refuse test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit b784991 Oct 19, 2026
25 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-7132-39106137801-1 branch October 19, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(source-control): worktree reap requires the caller to cd into the target, which an isolated session cannot

1 participant