Skip to content

fix(cloister): reaper safety follow-ups: unheld commits, precious ignored files, .overdeck names, pan-sync paths, GitLab parity (PAN-5990) - #6005

Merged
eltmon merged 2 commits into
mainfrom
feature/pan-5990
Dec 4, 2026
Merged

eltmon merged 2 commits into
mainfrom
feature/pan-5990

Conversation

@eltmon

@eltmon eltmon commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Closes #5990. Follow-ups to #5989 (PAN-5979): the closed-issue reaper force-removes a merged workspace, and these changes close the remaining ways it could still delete work. Every new check fails closed: a git call that errors or times out keeps the workspace.

What changed

1. Commits the merged branch does not hold (src/lib/workspaces/unheld-commits.ts)

  • Keeps the workspace when the worktree's own git dir has rebase-merge/, rebase-apply/, MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or BISECT_LOG.
  • Keeps it when git rev-list HEAD --not <target> <verified branch> is non-empty. This covers a detached HEAD, another branch, and a .swarm/ worker branch.
  • A checkout below a member inherits the member's branches only when both share a repository (--git-common-dir). A separate clone nested in the folder is kept.
  • When a repository lives inside the folder, its local refs die with it. Then only origin/ refs count as holding, and every local branch and every stash entry is judged too.
  • Decision not in the brief: the polyrepo wrapper has no remote, target or feature branch. Its commits, on any branch or in its stash, may touch only .gitignore and pipeline records (isStatePlanePath); anything else, such as a .pan/drafts/ PRD, keeps the workspace. The literal rule would refuse every polyrepo reap forever, because every wrapper has at least one local commit.

2. Precious gitignored files: keep, don't archive (src/lib/workspaces/ignored-work.ts)

  • Keeps the workspace for .env and .env.* (not .env.example), for *.sql, *.dump, *.sqlite and *.db outside node_modules/, and for anything under .tmp/.
  • The listing is git ls-files --others --ignored --exclude-standard --directory --no-empty-directory. A collapsed folder that is not build, cache or Overdeck output is listed once more, without its node_modules/, with a cap of 50 such folders. Every call has a timeout and a buffer cap.
  • An .env that Overdeck rendered from workspace.env.template does not count.
  • Git does not list ignored files inside an untracked folder, but that folder's untracked files already keep the workspace through git status.

3. The .overdeck/ exemption (src/lib/workspaces/overdeck-runtime-files.ts)

  • Only the exact names Overdeck's writers produce count as runtime. The writers are listed in the module header, and context/workspace.md is among them.
  • Any other untracked file under .overdeck/ is work.
  • The pan done and spawn gates keep the blanket prefix, because there the file stays on disk.

4. pan-sync output by exact path (src/lib/workspaces/overdeck-written-paths.ts)

  • Recognised by exact path:
    • .claude/.overdeck-manifest.json entries whose hash still matches (an edited synced file is work);
    • the exact .claude/ files the sync writes;
    • the project agent template's copy_dirs files and rendered *.template targets such as .mcp.json;
    • the rendered .env;
    • a .hume-config holding exactly the two lines the writer produces;
    • the pan sync mirror of a checkout's own skills/, when byte-identical.
  • Gitignored files in the root's .claude/skills|commands|agents/ that the sync did not write keep the workspace. This matters because the generated wrapper .gitignore ignores .claude/ as a whole.
  • Wrapper .gitignore: since PAN-5199 the generated wrapper .gitignore already lists .claude/, .mcp.json, .hume-config and .env, which covers every pan-sync path. No generator change was needed. A real-git test pins that it ignores each path, but that test does not fail on revert because nothing was reverted.
  • Template copies, .mcp.json and the rendered .env are exempt by path, not content, because placeholders are substituted when they are written.

5. GitLab parity (src/lib/forge.ts, src/lib/lifecycle/verify-merged.ts)

  • findMergedGitLabArtifact now reports target_branch, merge_commit_sha (or squash_commit_sha) and whether source_project_id differs from target_project_id. A listed MR known to come from a fork is skipped, as gh pr list rows are. This also applies to the DoD and merge-completeness lookups that share the adapter.
  • In requireBranchCovered mode the merged-MR path runs mergedIntoTargetRefusal before the head match. A missing fact is a refusal, so a fast-forward MR without squash (no merge or squash commit reported) always refuses that path. Its branch is normally an ancestor of the target and passes on the earlier git check.

The reaper's skip line now reads work kept (<reason>) for every one of these reasons.

Tests

Every item has real-git tests in a temp repo: src/lib/workspaces/__tests__/reap-work-checks.test.ts, tests/unit/lib/lifecycle/verify-merged-gitlab-mr.test.ts, plus cases in reap-issue-residue-forge-merged.test.ts, uncommitted-work.test.ts and forge-merged-artifact.test.ts. Reverting each fix by hand made its tests fail: item 1 (5 tests), the shared-repository check (1), the local-refs rule (3), the stash reflog walk (1), item 2 (7), item 3 (4), item 4 status filter (3), item 4 ignored-folder check (1), item 5 (5).

A read-only run of the new check over this machine's live workspaces found that the old MYN polyrepo workspaces that were kept only for pan-sync files now reap. Workspaces stay kept for wrapper package.json/package-lock.json files that no Overdeck writer produces, and for PRD drafts committed into the wrapper repo.

Gates

  • npm run typecheck: pass
  • npm run lint: pass
  • npx vitest run on the touched and affected files (35 files, 521 tests): pass

🤖 Generated with Claude Code

overdeck-agent[bot] and others added 2 commits December 3, 2026 22:00
… merge proof (PAN-5990)

The closed-issue reaper force-removes a merged workspace. It now also
keeps the folder, branches and volumes when:

- a checkout holds commits on neither the target nor the verified
  branch (detached HEAD, another branch, a .swarm worker branch), or a
  rebase/merge/cherry-pick/revert/bisect is in progress; the remote-less
  polyrepo wrapper may hold only .gitignore and pipeline-record commits
- a known-precious gitignored file exists (.env*, *.sql/.dump/.sqlite/.db
  outside node_modules, anything under .tmp/); bounded listing with
  --directory, build/cache folders never inspected
- an untracked .overdeck/ file is not one of the exact runtime names
  Overdeck's writers produce
- a file in the synced .claude/skills|commands|agents folders was not
  written by the sync (manifest entries with matching hash, the agent
  template's copy_dirs and rendered templates, generated .env and
  .hume-config are recognised by exact path), even when .claude/ is
  gitignored

The GitLab merged-MR path now refuses a fork MR, a different target or a
merge/squash commit not on the target, as the GitHub path does.

Closes #5990

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Overdeck-Conversation: conv-20261204-38bc
…AN-5990)

A checkout inherits a member's branches only when it shares that
member's repository; local refs, other branches and stash entries count
only when the repository lives outside the workspace folder. The wrapper
check covers every branch and stash entry. context/workspace.md and the
pan sync mirror of a checkout's own skills/ are recognised as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Overdeck-Conversation: conv-20261204-38bc
@eltmon

eltmon commented Dec 4, 2026

Copy link
Copy Markdown
Owner Author

Overdeck has not verified or reviewed this PR. It could not adopt feature/pan-5990 into a pipeline workspace (checked-out-elsewhere).

PR #6005 (feature/pan-5990) is checked out in /home/eltmon/Projects/hoff-pan-5990, so Overdeck cannot create the pipeline workspace and nothing has verified or reviewed it. Push any unpushed commits on feature/pan-5990, run git -C /home/eltmon/Projects/hoff-pan-5990 switch --detach (the branch and the worktree stay), then pan review request PAN-5990.

@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2fffed6 and d69c5af.

Files selected for processing: 16

  • changelog.d/pan-5990.md
  • configuration/polyrepo.mdx
  • src/lib/cloister/__tests__/reap-issue-residue-forge-merged.test.ts
  • src/lib/cloister/__tests__/reap-issue-residue.test.ts
  • src/lib/cloister/reap-issue-residue.ts
  • src/lib/forge.ts
  • src/lib/lifecycle/verify-merged.ts
  • src/lib/workspaces/__tests__/reap-work-checks.test.ts
  • src/lib/workspaces/__tests__/uncommitted-work.test.ts
  • src/lib/workspaces/ignored-work.ts
  • src/lib/workspaces/overdeck-runtime-files.ts
  • src/lib/workspaces/overdeck-written-paths.ts
  • src/lib/workspaces/uncommitted-work.ts
  • src/lib/workspaces/unheld-commits.ts
  • tests/unit/lib/forge-merged-artifact.test.ts
  • tests/unit/lib/lifecycle/verify-merged-gitlab-mr.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@eltmon

eltmon commented Dec 4, 2026

Copy link
Copy Markdown
Owner Author

Flywheel review: APPROVE

Head: d69c5afd8785. GitHub reports MERGEABLE, and git merge-tree against current origin/main is clean. I reviewed git diff e59879b5ade d69c5afd8785 (16 files).

CI when I posted:

  • Passed: lint-group (state), prompt-trailer gate, integrations, clean-install smoke test, bare-host-changes, CodeRabbit.
  • Still running: build, lint-group (core, effect, skills), test shards 1 to 4, test-e2e, mobile-android and the flake lane.
  • This approval assumes those finish green.

Tests: on an exported copy of the head I ran the 6 touched test files plus the polyrepo reaper, member-forge, workflows and merge-completeness suites: 207 passed, 1 skipped.

Revert check: I swapped uncommitted-work.ts, forge.ts and verify-merged.ts back to the merge-base and re-ran the 4 new or changed test files: 35 tests fail. That covers every case in reap-work-checks.test.ts sections 1 to 4, the new uncommitted-work exhaust case, the 5 GitLab refusal cases and the 4 GitLab lookup cases. (c) is the exception: as the author says, the wrapper .gitignore pin cannot fail on a revert, because PAN-5199 already ships it.

Earlier reaper protections still hold

  • The forge "merged" early return is still limited to the mode without requireBranchCovered (verify-merged.ts:159).
  • mergedIntoTargetRefusal runs for the GitHub member and issue-level sources (:667-668). It now also runs for GitLab, before the head match (:486-487).
  • judgePostMergeDelta is unchanged.
  • The reaper still passes requireBranchCovered (reap-issue-residue.ts:76) and runs checkWorkspaceUncommittedWork (:96) before the teardown (:109).

The new checks narrow deletion and never widen it

Main deletes everything the dirty check cannot see. Every new check is an extra reason to keep the workspace, and every exemption only takes something out of a new keep reason. Nothing that main keeps is deleted now. Every new git call has a 30 s timeout and a 32 MB buffer. An error, a timeout or exceeding a bound keeps the workspace. The written-paths walk is capped at 5,000 files and depth 8.

The author's own calls

(a) Wrapper commits may touch only .gitignore and state-plane paths. Safe in practice, with one blind spot to close.

The allowed paths are pipeline records: continues, continue.json, specs, test, review, feedback and .tasks/. Drafts, notes and every review-required .pan/ path still keep the workspace, which is how MIN-1198 and MIN-1203 stay kept.

The blind spot is merge commits. git log --name-only lists no paths for a merge commit, and every stash W commit is a merge. I checked this in a throwaway repo: after git stash of an edit to a tracked file, the command at unheld-commits.ts:132 lists the stash commit with no paths. With --diff-merges=first-parent it lists notes.md.

This cannot be exploited today. Every non-merge commit is checked, so the wrapper's tracked files are all allowed paths, and a stash of unstaged edits can only touch those. A stash -u root commit and a staged index commit do show their paths. An evil merge on a wrapper branch would still slip through, but that is very unlikely. Please add --diff-merges=first-parent, or -m, so the rule does not rest on that invariant.

(b) Nested clones: not inverted. It is correct.

  • For a member worktree whose common git dir is outside the folder (localRefsSurvive), local branches and the stash survive the reap. Only HEAD is judged, and local main/feature refs count as holding commits.
  • For a repository whose git dir is inside the folder, everything local dies with it. So HEAD, --branches and every stash reflog entry are judged against origin/ refs only.
  • A checkout under a member that is not a worktree of that member's repository (a separate clone) is kept outright, because its branches are unknown.
  • Counting refs/heads/feature/<id> and origin/feature/<id> as holding, even though the reaper then deletes both, is sound. Those tips are exactly what the merge proof covered.

(c) Agreed. It needs no code; it is a pin only.

The .env question: yes, an operator-edited rendered .env would be exempted

overdeck-written-paths.ts:105 adds .env to written whenever workspace.env.template is set, whatever the file's content. findPreciousIgnoredFiles then skips it.

  • No project in the current projects.yaml sets workspace.env.template, so this is latent.
  • Template targets and copy_dirs files (MYN and Auricle use infra/.agent-template) are also exempt by path, regardless of later edits. Hashing is already done right for the .claude/ manifest and .hume-config.
  • Follow-up: record a content hash when .env and the template targets are rendered, as .claude/.overdeck-manifest.json does, and exempt them only while the hash matches.

Other non-blocking findings

  1. .devcontainer/ is never inspected. NOT_LISTED_FOLDERS (ignored-work.ts:35) includes .devcontainer, so a wholly ignored .devcontainer/ is never listed. MYN's wrapper ignores it. A .devcontainer/.env, or a *.sql/*.dump seed or backup placed there, is deleted without a check. .devcontainer is rendered output, but people do drop DB dumps beside the compose file. Consider listing it one level down like backups/, with only the rendered compose files exempt.
  2. The GitLab fast-forward-without-squash refusal and fork filtering in the DoD and completeness lookups both fail closed, which is correct. A fork MR that is the only merged MR now reads as not merged.
  3. Ignored nested clones are still missed. A clone that is gitignored and not under .tmp/ (for example vendor/x/) is neither scanned nor precious. An unignored one shows as ?? vendor/x/ and is kept. This is unchanged from main.

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.

Reaper safety follow-ups: unreferenced commits, gitignored files, the .overdeck exemption, pan-sync noise, GitLab parity

1 participant