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
Actively garden pull requests referenced by Paperclip issues active in a recent window. Candidate discovery and readiness checking are scripts, not LLM analysis. GitHub access is read-only throughout this workflow.
14
+
Actively garden the pull requests **this Paperclip instance opened** that are referenced by Paperclip issues active in a recent window (default 14 days). Candidate discovery and readiness checking are scripts, not LLM analysis. GitHub access is read-only throughout this workflow.
15
+
16
+
## Scope — Our PRs Only
17
+
18
+
By default the workflow gardens only pull requests authored by this instance's GitHub identity (the `gh` authenticated login, e.g. `cryppadotta`). Community contributions and dependabot PRs are excluded mechanically by author login in Stage A and land in `droppedCommunityPullRequests`; never re-add them by hand, widen the scope only when the caller explicitly passes `--authors` or `--include-community`.
14
19
15
20
## Hard Guardrails
16
21
17
22
-**Never merge, approve, or close a pull request.**
18
23
-**Never instruct another person or agent to merge, approve, or close a pull request.**
24
+
-**Never garden, comment on, or run `/prepare-paperclip-pr` against a community PR.** Only PRs from the Stage A author allowlist are actionable.
19
25
- Never use mutating `gh` commands or mutating GitHub API requests. The scripts only use `gh pr view` and read-only `gh api` GET requests.
20
26
- Draft pull requests are report-only. Do not post gardening comments for drafts.
21
27
- Comment only on existing originating issues. Never create a gardening issue per pull request.
22
-
-`--dry-run` suppresses all Paperclip mutations, including gardening comments and inbox archives. Discovery and GitHub inspection remain read-only in every mode.
28
+
-`--dry-run` suppresses all Paperclip mutations, including gardening comments, prepare tasks, and inbox archives. Discovery and GitHub inspection remain read-only in every mode.
-`--days <N>`: activity window, default `14`. Applies to both mentioning-issue activity and the PR's own `updatedAt`; open PRs with no activity inside the window are dropped as stale.
33
+
-`--authors <logins>`: comma-separated GitHub logins whose PRs are in scope; default is the `gh` authenticated user.
34
+
-`--include-community`: disable the author filter entirely. Only on explicit caller request.
27
35
-`--repo <owner/repo>`: GitHub repository, default detected by `gh repo view`.
28
-
-`--dry-run`: discover, verify, and report without posting comments or archiving inbox entries.
36
+
-`--dry-run`: discover, verify, and report without posting comments, creating prepare tasks, or archiving inbox entries.
29
37
-`--archive-inbox`: after GitHub confirms a candidate PR is merged at its current head, archive the originating issue from the responsible user's inbox in Stage D.
-`--max-rounds <N>`: maximum gardening rounds per PR, default `3`.
32
40
33
41
Use a run-owned directory such as `$PAPERCLIP_RUN_SCRATCH_DIR/pr-gardening` for generated files.
34
42
35
43
## Stage A — Discover Candidates
36
44
37
-
Run the extract-search path. It scans every result page, rejects truncated match sets, normalizes PR URLs, deduplicates PR numbers, records every mentioning issue, checks issue work products to identify the origin, and drops PRs that GitHub says are merged or closed.
45
+
Run the extract-search path. It scans every result page, normalizes PR URLs, deduplicates PR numbers, records every mentioning issue, checks issue work products to identify the origin, drops PRs that GitHub says are merged or closed, drops PRs whose author is outside the allowlist (community contributions) into `droppedCommunityPullRequests`, and drops open PRs whose own `updatedAt` is older than the window into `droppedStalePullRequests`. Issues that exceed the per-issue extract match cap (typically digest or QA issues that enumerate hundreds of PR URLs) are recorded in `source.truncatedIssues` and noted in the report instead of aborting the run.
The script calls `GET /api/companies/:companyId/search/extract` with `kind=url`, `scope=all`, and `updatedWithin=<N>d`. Do not replace it with full issue-list fetching or LLM scanning.
54
+
The script calls `GET /api/companies/:companyId/search/extract` with `kind=url`, `scope=all`, and `updatedWithin=<N>d`, then resolves the author allowlist from `gh api user` unless `--authors` or `--include-community` overrides it. Do not replace it with full issue-list fetching or LLM scanning.
47
55
48
56
## Stage B — Verify Current-Head Readiness
49
57
@@ -75,33 +83,33 @@ For each branch, process one branch at a time and do this serially:
75
83
3. If an equivalent open task exists, reuse it: add a concise comment with the current PR/head/reason context and link it from the gardening issue or blocker list. Do not create another task.
76
84
4. Only if no equivalent open task exists, create exactly one follow-up task for that branch.
77
85
78
-
Never fan out follow-up task creation in parallel. Do not issue concurrent `POST /api/companies/:companyId/issues` calls for create-PR tasks. After P1's issue-create idempotency support is available, every create-PR follow-up task creation must include `idempotencyKey: "pr-gardening:create-pr:{branch}"`, where `{branch}` is the exact branch name.
86
+
Never fan out follow-up task creation in parallel. Do not issue concurrent `POST /api/companies/:companyId/issues` calls for create-PR or prepare-PR tasks. After P1's issue-create idempotency support is available, every create-PR follow-up task creation must include `idempotencyKey: "pr-gardening:create-pr:{branch}"` and every prepare-PR task `idempotencyKey: "pr-gardening:prepare-pr:{owner/repo}#{number}"`.
79
87
80
-
## Stage C — Comment on Originating Issues
88
+
## Stage C — Drive Our PRs to Ready with /prepare-paperclip-pr
81
89
82
90
Skip this stage in `--dry-run` mode and for `ready` or `report_only` entries.
83
91
84
-
For each `needs_gardening` PR, use `originatingIssue` from `candidates.json`. Selection priority is:
92
+
Every `needs_gardening` PR here was opened by this instance (Stage A guarantees it), so do not just report — actively get it merge-ready by running the `/prepare-paperclip-pr` skill against it. Process PRs one at a time:
85
93
86
-
1. issue carrying the exact PR URL as a `pull_request` work product;
87
-
2. issue whose comment mentions the PR;
88
-
3. most recently active mentioning issue.
94
+
1.**Cooldown and rounds.** Locate the `originatingIssue` from `candidates.json` (selection priority: issue carrying the exact PR URL as a `pull_request` work product; then issue whose comment mentions the PR; then most recently active mentioning issue). Fetch its comments and search for the marker:
89
95
90
-
Before commenting, fetch the issue comments and search for this marker:
96
+
```text
97
+
<!-- pr-gardening:<owner/repo>#<number> -->
98
+
```
91
99
92
-
```text
93
-
<!-- pr-gardening:<owner/repo>#<number> -->
94
-
```
100
+
Skip the PR if the latest matching marker is newer than the cooldown. Track rounds from matching markers; after three rounds, stop and report `not converging; recommend close or human decision`. That is a recommendation for human disposition, not an instruction to close the PR.
95
101
96
-
Do not comment if the latest matching marker is newer than the cooldown. Track rounds from matching markers; after three rounds, stop nagging and report `not converging; recommend close or human decision`. This is a recommendation for human disposition, not an instruction to close the PR.
102
+
2.**Deduplicate.** Search open Paperclip issues for the PR number/branch. If an equivalent open prepare-PR task already exists, reuse it with a concise status comment instead of creating another (see the deduplication section above).
97
103
98
-
When a comment is allowed, mention the originating issue assignee, instruct them to run `/prepare-pr`, include the current head SHA, and copy the exact machine-detected `reasons[]`. Use `POST /api/issues/:issueId/comments` with `X-Paperclip-Run-Id`. Include `resume: true` when the issue is terminal so the comment creates a live continuation.
104
+
3.**Run the prepare skill.** Create one focused child task per PR assigned to a coder agent (prefer CodexCoder) instructing it to run `/prepare-paperclip-pr` for that PR — include the PR URL, branch, current head SHA, and the exact machine-detected `reasons[]` from `readiness.json`. If you are the gardener and already have the PR's branch checked out in a worktree, you may run `/prepare-paperclip-pr` directly instead of delegating. Either way, the prepare work must never merge, approve, or close the PR.
105
+
106
+
4.**Leave the marker comment.** Comment on the originating issue with the marker above, the current head SHA, the copied `reasons[]`, the round counter, and a link to the prepare task. Use `POST /api/issues/:issueId/comments` with `X-Paperclip-Run-Id`. Include `resume: true` when the issue is terminal so the comment creates a live continuation.
99
107
100
108
Suggested body:
101
109
102
110
```markdown
103
111
<!-- pr-gardening:paperclipai/paperclip#1234 -->
104
-
@Assignee please run `/prepare-pr` for https://github.com/paperclipai/paperclip/pull/1234.
112
+
Gardening: dispatched `/prepare-paperclip-pr` for https://github.com/paperclipai/paperclip/pull/1234 via PAP-XXXX.
105
113
106
114
Current-head verification at `abc123` found:
107
115
- failing check: test
@@ -133,7 +141,7 @@ Use `POST /api/issues/:issueId/comments` and include `X-Paperclip-Run-Id` on bot
133
141
134
142
## Stage E — Monitor to Termination
135
143
136
-
Set the gardening run issue's `blockedByIssueIds` to the non-terminal issues commented in Stage C so blocker resolution wakes the gardener. A scheduled or manual rerun is the fallback.
144
+
Set the gardening run issue's `blockedByIssueIds` to the non-terminal prepare tasks and originating issues engaged in Stage C so blocker resolution wakes the gardener. A scheduled or manual rerun is the fallback.
137
145
138
146
On every wake, rerun Stage B first. A PR terminates from active gardening only when one of these is mechanically observed:
The report states the scope (authors + window), and for every open PR gives its author, a one-line purpose summary taken from the PR description, and a readiness confidence bucket:
155
163
156
164
-**High:** current-head checks green, no conflicts, Greptile clean, base fresh, originating issue terminal.
157
165
-**Medium:** otherwise green but base stale, review not complete, or originating issue active.
158
166
-**Low:** failing/pending checks, missing Greptile, draft/just-fixed-unverified state, or no identifiable origin.
159
167
168
+
If a PR's generated purpose line is empty or unhelpful, write a one-sentence description from the PR title and diff summary when publishing the report.
169
+
160
170
Upload `candidates.json`, `readiness.json`, and `gardening-report.md` to the gardening issue, create/update the `gardening-report` issue document with the Markdown body, and leave a summary comment linking the artifacts. The report is the deliverable; it is never authorization to merge.
For a live dry run, execute Stages A, B, and F with `--dry-run`, then sanity-check named PRs only if they are still open. Merged or closed examples should appear under `droppedClosedPullRequests`, not in readiness results. If also exercising `--archive-inbox`, confirm the report describes the suppressed Stage D action and that no Paperclip archive or marker-comment mutation occurred.
180
+
For a live dry run, execute Stages A, B, and F with `--dry-run`, then sanity-check named PRs only if they are still open. Merged or closed examples should appear under `droppedClosedPullRequests`, not in readiness results, and community-authored PRs must appear only under `droppedCommunityPullRequests` — a candidate or report entry with an author outside the allowlist is a scope failure. If also exercising `--archive-inbox`, confirm the report describes the suppressed Stage D action and that no Paperclip archive or marker-comment mutation occurred.
0 commit comments