You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/experimental/issue-worktree-support.md
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,21 +24,32 @@ We are intentionally not shipping the UI for this yet. The runtime code remains
24
24
25
25
## Large-repo Worktree Lifecycle Policy
26
26
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:
28
28
29
29
- owner: the Paperclip company/project plus the issue linked through `sourceIssueId` and `issues.executionWorkspaceId`
30
30
- linked work: the issue identifier, branch name, base ref, project workspace, and any PR link carried in the issue thread
31
31
- creation and use time: `openedAt`, `createdAt`, and `lastUsedAt`
32
32
- cleanup eligibility: `closedAt`, `cleanupEligibleAt`, `cleanupReason`, and workspace `status`
33
33
- provider ownership: `providerType: "git_worktree"` plus `metadata.createdByRuntime: true` means Paperclip may remove the derived worktree after close-readiness passes
34
34
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
+
35
45
Retention defaults for large local worktrees:
36
46
37
47
- active or linked to open issue: keep; report size and readiness only
38
48
- clean, idle, Paperclip-created issue worktree: eligible for cleanup after 24 hours
39
49
- in review: keep for 7 days unless a reviewer explicitly archives the workspace earlier
40
50
-`cleanup_failed`: keep until an operator resolves the reported reason
41
51
- 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
42
53
43
54
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:
44
55
@@ -50,7 +61,7 @@ Close and cleanup must use the execution workspace close-readiness report before
50
61
51
62
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.
52
63
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:
54
65
55
66
- provider is `git_worktree`
56
67
- 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
59
70
60
71
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.
61
72
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
+
62
75
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.
0 commit comments