Skip to content

Commit 5f18885

Browse files
committed
docs: cover non-execution worktree lifecycle (WAT-1777)
1 parent 9ace763 commit 5f18885

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

doc/experimental/issue-worktree-support.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,32 @@ We are intentionally not shipping the UI for this yet. The runtime code remains
2424

2525
## Large-repo Worktree Lifecycle Policy
2626

27-
Paperclip-owned issue and review worktrees are execution workspaces, not agent-owned scratch directories. The execution workspace record is the source of truth for:
27+
Paperclip-owned issue and review worktrees should be execution workspaces, not agent-owned scratch directories. For worktrees created through the execution workspace runtime, the execution workspace record is the source of truth for:
2828

2929
- owner: the Paperclip company/project plus the issue linked through `sourceIssueId` and `issues.executionWorkspaceId`
3030
- linked work: the issue identifier, branch name, base ref, project workspace, and any PR link carried in the issue thread
3131
- creation and use time: `openedAt`, `createdAt`, and `lastUsedAt`
3232
- cleanup eligibility: `closedAt`, `cleanupEligibleAt`, `cleanupReason`, and workspace `status`
3333
- provider ownership: `providerType: "git_worktree"` plus `metadata.createdByRuntime: true` means Paperclip may remove the derived worktree after close-readiness passes
3434

35+
Some existing large-repo worktrees were created by local agent workflows before execution workspace records covered every path. Examples include superpowers or agent-created worktrees under `/tmp` with names derived from issue branches. Those worktrees are still in scope for stale-worktree prevention, but they are not automatically safe to delete. Until they are adopted into execution workspace records or carry explicit Paperclip ownership metadata, they use a report-only lifecycle:
36+
37+
- owner discovery: infer the repository from `git rev-parse --show-toplevel`, the branch or detached commit from `git status --branch --porcelain=v2`, and the creating workflow from path markers such as `/tmp`, `.paperclip/worktrees`, `paperclip/`, `wat-`, or adapter-specific worktree roots
38+
- linked work discovery: parse `WAT-\d+` or project issue keys from the branch name, worktree basename, PR branch, or recent commit subjects, then query matching Paperclip issues and PR links
39+
- active-work guardrail: if any inferred linked issue is non-terminal, the row remains active and report-only regardless of age
40+
- missing-link guardrail: if no issue or PR can be inferred, the row is reported as orphaned but not deleted
41+
- retention: clean, linked, terminal non-execution worktrees are stale after 24 hours; review-shaped worktrees are stale after 7 days; unknown-owner rows stay report-only until an operator records ownership or removes them manually
42+
- dirty-work guardrails: dirty tracked files, untracked files, unpushed commits, detached heads, unresolved merges, inaccessible git status, missing upstream/base refs, or running processes with `cwd` inside the worktree all block deletion
43+
- deletion policy: non-execution worktrees are never deleted by the automatic release/completion cleanup path. A later cleanup implementation may delete them only after adopting them into an execution workspace record or recording equivalent owner, issue, creation time, and Paperclip-created metadata.
44+
3545
Retention defaults for large local worktrees:
3646

3747
- active or linked to open issue: keep; report size and readiness only
3848
- clean, idle, Paperclip-created issue worktree: eligible for cleanup after 24 hours
3949
- in review: keep for 7 days unless a reviewer explicitly archives the workspace earlier
4050
- `cleanup_failed`: keep until an operator resolves the reported reason
4151
- shared/project-primary workspace: never delete the underlying project checkout; archive only the execution workspace record
52+
- non-execution Paperclip/agent worktree: report when stale by the windows above, but do not delete until ownership metadata is explicit
4253

4354
Close and cleanup must use the execution workspace close-readiness report before deleting anything. The report includes linked open issues, runtime services, git dirty state, untracked files, ahead/behind counts, merge status, and planned cleanup actions. Destructive archive is blocked for isolated git worktrees when:
4455

@@ -50,7 +61,7 @@ Close and cleanup must use the execution workspace close-readiness report before
5061

5162
The lower-level cleanup helper also refuses to remove a git worktree when `git status --porcelain --untracked-files=all` is non-empty, so direct callers report dirty worktrees instead of deleting them. If a worktree is clean and Paperclip owns it, cleanup removes the git worktree and then attempts to delete the runtime-created branch with `git branch -d`; unmerged branches are reported and kept.
5263

53-
Safe stale-worktree reporting should list, but not delete, candidate `/tmp` worktrees matching all of:
64+
Safe stale-worktree reporting should list, but not delete, execution-workspace candidate `/tmp` worktrees matching all of:
5465

5566
- provider is `git_worktree`
5667
- workspace path resolves under `/tmp` or the platform temp directory
@@ -59,6 +70,8 @@ Safe stale-worktree reporting should list, but not delete, candidate `/tmp` work
5970

6071
Each row should include workspace id, issue identifier, owner agent if known, path, branch, base ref, opened/last-used time, approximate path size, readiness state, blocking reasons, and planned actions. Deletion is only allowed by the archive/close path after readiness returns `ready` or `ready_with_warnings`; blocked rows remain report-only.
6172

73+
The same stale report should also scan registered large-repo roots and platform temp worktree roots for non-execution git worktrees. These rows should include source `non_execution_git_worktree`, inferred repository, inferred issue or PR, owner agent if known, path, branch or detached commit, upstream/base ref, last filesystem activity, approximate path size, git cleanliness, ahead/unpushed status, active process hints, and why the row is report-only. They are stale signals for operators and future adoption work, not deletion candidates.
74+
6275
Successful release/completion behavior: when a Paperclip-owned isolated worktree is closed, the server archives the execution workspace record, stops attached runtime services, runs configured cleanup/teardown commands, removes the clean git worktree, and records any cleanup warning in `cleanupReason`. If release/completion does not explicitly archive the workspace, the stale-worktree report is the follow-up mechanism that makes the retention breach visible before manual or scheduled archive.
6376

6477
## Hidden UI entrypoints

0 commit comments

Comments
 (0)