jonah-fleet 1.15.0 โ†’ 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,30 @@ All notable changes to `jonah-fleet` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.16.0](https://github.com/juliendurandeu/jonah-fleet/compare/v1.15.1...v1.16.0) (2026-09-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * **orchestration:** routine run failure ingestion, dynamic target binding, and auto-closure ([#232](https://github.com/juliendurandeu/jonah-fleet/issues/232)) ([b76b3fc](https://github.com/juliendurandeu/jonah-fleet/commit/b76b3fccd767e5cc9517d977fd08c8979baf64b6))
14
+
15
+ ## [Unreleased] - 2026-09-19
16
+
17
+ ### Features
18
+
19
+ * **orchestration:** add Routine Run Failure Ingestion & Auto-Closure Protocol to `ORCHESTRATION.md`, unifying prior failure memory and resolution lifecycle across `autowork` and `peer-review`.
20
+ * **prompts:** add Dynamic Target Binding in Scan mode to `autowork.md` and `peer-review.md`, dynamically updating `$ROUTINE_ISSUE_NUMBER` titles with `(Issue #N)` or `(PR #M)` upon claiming so crashed runs are never anonymous.
21
+ * **prompts:** add Prior Failure Ingestion Protocol to `autowork.md` and `peer-review.md`, inspecting past open failed routine issues to extract error logs and crash milestones before implementation or review.
22
+ * **prompts:** add resolution-triggered auto-closure to `autowork.md` and `peer-review.md`, automatically commenting on and closing past failed routine issues for a target once work is marked ready or merged.
23
+ * **housekeeping:** expand `issues-housekeeping.md` to sweep and close stale untargeted `status:failure` routine issues older than 48 hours or whose targets are resolved, eliminating backlog clutter.
24
+
25
+ ## [1.15.1](https://github.com/juliendurandeu/jonah-fleet/compare/v1.15.0...v1.15.1) (2026-09-19)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **radar:** robust options resolution in evaluateActivity when orbital data is empty object ([#248](https://github.com/juliendurandeu/jonah-fleet/issues/248)) ([02e9999](https://github.com/juliendurandeu/jonah-fleet/commit/02e9999609ac4d2ea052e3a52c4c146c393e2957)), closes [#215](https://github.com/juliendurandeu/jonah-fleet/issues/215)
31
+
8
32
  ## [1.15.0](https://github.com/juliendurandeu/jonah-fleet/compare/v1.14.0...v1.15.0) (2026-09-19)
9
33
 
10
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jonah-fleet",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Standalone autonomous agent fleet with Symphony orchestration, claim protocols, and continuous improvement loops",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -153,6 +153,23 @@ How live execution progress is reported during autonomous routine runs:
153
153
  6. **Harness Interruption Card**: If a routine run fails, times out, or crashes abruptly before Milestone 4, the workflow harness or local runner post-step automatically appends an Interruption Card (`### โŒ Milestone: Run Interrupted / Failed`) before marking `status:failure`.
154
154
  7. **Final State Reconciliation**: The final comment is Milestone 4 (Compact completion card). The workflow harness replaces the top-level issue body with the comprehensive telemetry & audit report (`.jonah-fleet/run-report.md`) and closes the issue on success.
155
155
 
156
+ ### Routine Run Failure Ingestion & Auto-Closure Protocol
157
+
158
+ Single source of truth for handling routine run failures, context extraction, and issue tracker clutter across the fleet:
159
+
160
+ 1. **Dynamic Target Binding (Scan Mode)**: When `autowork` or `peer-review` starts in Scan mode, the routine tracking issue is initialized with a generic timestamp title (`[routine-name] run {timestamp}`). As soon as the runner claims an Issue or PR, it immediately updates the routine tracking issue title:
161
+ ```bash
162
+ gh issue edit "$ROUTINE_ISSUE_NUMBER" --title "[autowork] run ${TIMESTAMP} (Issue #<TARGET_ISSUE>)"
163
+ ```
164
+ (or `(PR #<PR_NUMBER>)` for PR convergence and peer review). This guarantees that even if a run is abruptly terminated, times out, or crashes midway, the resulting failure issue is explicitly tied to its target in GitHub issue lists.
165
+ 2. **Prior Failure Ingestion (Active Memory)**: Before writing code or conducting review, routines query open routine run issues for the target:
166
+ ```bash
167
+ gh issue list --label routine-log --search "Issue #<TARGET_ISSUE>" --state open --json number,title,body
168
+ ```
169
+ (or `PR #<PR_NUMBER>`). If prior failed runs exist, the runner extracts error messages, failing test names, or crash milestones from the Interruption Card and incorporates this context into Milestone 1 and its reproduction strategy, preventing repeated identical failures.
170
+ 3. **Resolution-Triggered Auto-Closure**: When a target issue or PR reaches terminal completion (a ready PR opened, review decision executed, or PR merged), the routine iterates through any open past failed routine issues for that target, posts a resolution comment referencing the successful run (including the Antigravity run footer), and closes them via `gh issue close <ISSUE> --reason completed`.
171
+ 4. **Housekeeping Garbage Collection for Untargeted Crashes**: Routine runs that fail before claiming a target (e.g. runner VM startup errors, GitHub CLI auth failures) or whose target has already been resolved are audited by `issues-housekeeping.md` and closed once older than 48 hours, keeping consumer issue lists clean and noise-free.
172
+
156
173
  ---
157
174
 
158
175
  ## Token Anomaly Triage & Remediation
@@ -87,7 +87,17 @@ a. **Read the target issue and check eligibility.** Eligible = open, unassigned
87
87
  - **Claim atomically**: assign yourself to the PR (`gh pr edit <PR> --add-assignee <login>`) AND post a claim comment on the PR:
88
88
  - In **Cloud Actions**: `๐Ÿ”’ Addressing review findings by autowork run {run_url} {timestamp}`
89
89
  - In **Local Agent**: `๐Ÿ”’ Addressing review findings by local autowork session (host: {hostname}) {timestamp}`
90
- - **Confirm sole ownership**: fetch comments on the PR. Earliest `created_at` among competing claim comments in this round wins. If you lost the race, unassign yourself (`gh pr edit <PR> --remove-assignee <login>`), annotate your comment, and evaluate the next PR (or proceed to Phase 2 if none left).
90
+ - **Confirm sole ownership**: fetch comments on the PR. Earliest `created_at` among competing claim comments in this round wins. If you lost the race, unassign yourself (`gh pr edit <PR> --remove-assignee <login>`), annotate your comment, and evaluate the next PR (or proceed to Phase 2 if none left).
91
+ - **Dynamic Target Binding (Scan Mode)**: If `$ROUTINE_ISSUE_NUMBER` is set and its title does not mention `PR #<PR_NUMBER>`, update the routine issue title to bind the target PR:
92
+ ```bash
93
+ TIMESTAMP=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
94
+ gh issue edit "$ROUTINE_ISSUE_NUMBER" --title "[autowork] run ${TIMESTAMP} (PR #<PR_NUMBER>)" || true
95
+ ```
96
+ - **Prior Failure Ingestion**: Query open routine run issues for `PR #<PR_NUMBER>`:
97
+ ```bash
98
+ gh issue list --label routine-log --search "PR #<PR_NUMBER>" --state open --json number,title,body
99
+ ```
100
+ If prior failed routine runs exist (carrying label `status:failure` or an Interruption Card), read the Interruption Card or comments to understand why the previous autowork pass on this PR failed, crashed, or timed out, and take that into account before making fixes.
91
101
  2. For the claimed PR, fetch ALL review threads and PR-level comments. Filter for actionable findings matching trust & noise rules (author login matching `get_me`, non-noise). Address every single one in this run โ€” push fixes for actionable findings, reply to clarifying questions, and comment on deferred items.
92
102
  3. For PRs where you have addressed all findings:
93
103
  3a. **Pre-ready self-audit** (run before marking ready):
@@ -97,18 +107,29 @@ a. **Read the target issue and check eligibility.** Eligible = open, unassigned
97
107
  - **Documentation accuracy**: update relevant docs (`ARCHITECTURE.md`, `CODEMAP.md`, `API.md`, `CHANGELOG.md` if maintained by repo).
98
108
  - **Build & type-check verification**: run the repository's test, type-check, and lint commands from `AGENTS.md` (e.g. `npm test`, `npm run type-check`, `npm run lint`, `pytest`, `cargo test`). Confirm zero errors and zero test failures.
99
109
  - **Active Origin Sync & Clean-Merge Gate**: Run `git fetch origin main && git merge origin/main --no-edit` to absorb any newly merged pull requests and resolve any conflicts locally. Verify `git merge-tree origin/main HEAD` reports no conflicts before marking ready.
100
- - **Release claim on ready**: mark the PR ready (`gh pr ready <PR>`) and unassign yourself (`gh pr edit <PR> --remove-assignee <login>`) so Peer Review can evaluate without holding stale agent reservation locks.
101
- Only mark the PR ready after passing every check above.
102
- 3b. **Ping-pong cap**: If this same PR has bounced between draft and ready 3 or more times over the same substantive finding, stop re-marking it ready. Post the mandatory 4-part escalation card summarizing the disagreement for human resolution and leave the PR in draft:
103
- ```markdown
104
- ## ๐Ÿ›‘ Escalation: Human Decision Required
105
- - **Decision Needed**: [1 focused question or choice]
106
- - **Evidence ("Why I believe this")**: [Specific files, lines, test outputs, or conflicting docs]
107
- - **Evaluated Options & Trade-offs**:
108
- - *Option A*: [Pros / Cons]
109
- - *Option B*: [Pros / Cons]
110
- - **Recommended Path**: [Agent recommendation]
111
- ```
110
+ - **Release claim on ready & resolve past failures**: mark the PR ready (`gh pr ready <PR>`), unassign yourself (`gh pr edit <PR> --remove-assignee <login>`) so Peer Review can evaluate without holding stale agent reservation locks, and resolve any open past failed routine issues for `PR #<PR_NUMBER>`:
111
+ ```bash
112
+ PAST_FAILURES=$(gh issue list --label routine-log --search "PR #<PR_NUMBER>" --state open --json number --jq '.[].number' || true)
113
+ for past_num in $PAST_FAILURES; do
114
+ if [ -n "$past_num" ] && [ "$past_num" != "$ROUTINE_ISSUE_NUMBER" ]; then
115
+ gh issue comment "$past_num" --body "Resolved by autowork run ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-} (PR #<PR_NUMBER> findings addressed and marked ready).
116
+
117
+ _Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_" || true
118
+ gh issue close "$past_num" --reason completed || true
119
+ fi
120
+ done
121
+ ```
122
+ Only mark the PR ready after passing every check above.
123
+ 3b. **Ping-pong cap**: If this same PR has bounced between draft and ready 3 or more times over the same substantive finding, stop re-marking it ready. Post the mandatory 4-part escalation card summarizing the disagreement for human resolution and leave the PR in draft:
124
+ ```markdown
125
+ ## ๐Ÿ›‘ Escalation: Human Decision Required
126
+ - **Decision Needed**: [1 focused question or choice]
127
+ - **Evidence ("Why I believe this")**: [Specific files, lines, test outputs, or conflicting docs]
128
+ - **Evaluated Options & Trade-offs**:
129
+ - *Option A*: [Pros / Cons]
130
+ - *Option B*: [Pros / Cons]
131
+ - **Recommended Path**: [Agent recommendation]
132
+ ```
112
133
  3c. **Orphaned Ready PR Recovery**: If an open PR authored by this routine is `ready_for_review`, has passing CI, no unaddressed review comments, and has received no review activity for over 2 hours (e.g. because peer review crashed or encountered quota limits), kickstart the review routine by posting `/review` comment or toggling draft and ready (`gh pr ready <PR> --undo && gh pr ready <PR>`).
113
134
  - **Passing CI Verification Gate**: Verify via `gh pr view <PR> --json statusCheckRollup,mergeStateStatus` that all required and existing checks have completed with `conclusion: "SUCCESS"` and `mergeStateStatus` is `CLEAN` (neither `UNSTABLE`, `BLOCKED`, nor `DIRTY`).
114
135
  - **Unapproved/Pending Workflow Invariant**: NEVER post `/review` or toggle draft state if checks are in-progress, failing, or awaiting approval (`conclusion: "ACTION_REQUIRED"`). Doing so creates an infinite comment storm while workflows remain paused awaiting human permissions.
@@ -116,7 +137,19 @@ a. **Read the target issue and check eligibility.** Eligible = open, unassigned
116
137
  - For open issues, check if recent git history or merged PRs reference the issue (e.g. `git log -n 50 --grep="#<ISSUE_NUMBER>"` or `gh pr list --state merged --search "<ISSUE_NUMBER>" --limit 5`).
117
138
  - If a merged PR or commit on `main` resolved the issue, close it immediately:
118
139
  ```bash
119
- gh issue close <ISSUE_NUMBER> --comment "Closed via merged PR #<PR_NUMBER> (found in git history)."
140
+ gh issue close <ISSUE_NUMBER> --comment "Closed via merged PR #<PR_NUMBER> (found in git history).
141
+
142
+ _Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_"
143
+ # Reconcile lingering past failed routine run issues for this resolved issue
144
+ PAST_FAILURES=$(gh issue list --label routine-log --search "Issue #<ISSUE_NUMBER>" --state open --json number --jq '.[].number' || true)
145
+ for past_num in $PAST_FAILURES; do
146
+ if [ -n "$past_num" ] && [ "$past_num" != "$ROUTINE_ISSUE_NUMBER" ]; then
147
+ gh issue comment "$past_num" --body "Resolved via merged PR #<PR_NUMBER>.
148
+
149
+ _Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_" || true
150
+ gh issue close "$past_num" --reason completed || true
151
+ fi
152
+ done
120
153
  ```
121
154
 
122
155
  5. If any PR was updated in this phase, STOP โ€” run is SUCCESS.
@@ -134,17 +167,30 @@ a. **Read the target issue and check eligibility.** Eligible = open, unassigned
134
167
  - If running in **Local Agent** (`$LOCAL_AGENT`): Scan mode selects across all priorities (P0 โ†’ P1 โ†’ P2 โ†’ P3) without time gating, prioritizing active local backlog consumption.
135
168
  - Skip assigned issues (unless stale claim per `ORCHESTRATION.md`), issues with open PRs, issues with unclosed blocking dependencies (`Blocked by #N` / `Depends on #N`), issues labeled `needs-human`, `needs-design`, or `needs-info`, and issues under cross-run cooldown.
136
169
  9. If no eligible candidate exists, STOP โ€” run is SUCCESS with "No unclaimed work available".
137
- 10. If the candidate should be closed already (work done, merged PR found in git history or via `gh pr list --state merged --search "<ISSUE_NUMBER>"`), close it immediately (`gh issue close <ISSUE_NUMBER> --comment "Closed: work already merged in PR #<PR_NUMBER>."`) and return to step 8.
170
+ 10. If the candidate should be closed already (work done, merged PR found in git history or via `gh pr list --state merged --search "<ISSUE_NUMBER>"`), close it immediately (`gh issue close <ISSUE_NUMBER> --comment "Closed: work already merged in PR #<PR_NUMBER>.\n\n_Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_"`), close any lingering past failed routine run issues (`PAST_FAILURES=$(gh issue list --label routine-log --search "Issue #<ISSUE_NUMBER>" --state open --json number --jq '.[].number' || true); for p in $PAST_FAILURES; do if [ -n "$p" ] && [ "$p" != "$ROUTINE_ISSUE_NUMBER" ]; then gh issue comment "$p" --body "Resolved: work already merged in PR #<PR_NUMBER>.\n\n_Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_" || true; gh issue close "$p" --reason completed || true; fi; done`), and return to step 8.
138
171
  10a. **Stale-claim reclamation:** If candidate is a stale claim per `ORCHESTRATION.md`, re-read immediately before writing, unassign the dead owner, post reclamation comment, and proceed to claim.
139
172
  11. **Claim protocol:**
140
173
  a. Re-read candidate issue immediately before claiming (`issue_read`). If assigned, abort and pick next candidate.
141
174
  b. Claim atomically: assign yourself (`login` from step 7) AND post claim comment:
142
175
  - In **Cloud Actions**: `๐Ÿ”’ Claimed by autowork run {run_url} {timestamp}`
143
176
  - In **Local Agent**: `๐Ÿ”’ Claimed by local autowork session (host: {hostname}) {timestamp}`
144
- c. Confirm sole ownership by counting `๐Ÿ”’ Claimed by autowork run` / `๐Ÿ”’ Claimed by local autowork session` comments. Earliest `created_at` wins. If you lost the race, leave assignee as is, annotate your comment, and pick next candidate.
177
+ c. Confirm sole ownership by counting `๐Ÿ”’ Claimed by autowork run` / `๐Ÿ”’ Claimed by local autowork session` comments. Earliest `created_at` wins. If you lost the race, leave assignee as is, annotate your comment, and pick next candidate.
178
+ d. **Dynamic Target Binding (Scan Mode)**: If `$ROUTINE_ISSUE_NUMBER` is set and its title does not mention `Issue #<TARGET_ISSUE>`, update the routine issue title to bind the target issue:
179
+ ```bash
180
+ TIMESTAMP=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
181
+ gh issue edit "$ROUTINE_ISSUE_NUMBER" --title "[autowork] run ${TIMESTAMP} (Issue #<TARGET_ISSUE>)" || true
182
+ ```
145
183
  12. Evaluate whether the claimed issue can be completed autonomously:
146
184
  - Confirm your `๐Ÿ”’` claim comment is present on the issue.
147
185
  - Read the issue description, linked code, and comment thread.
186
+ - **Prior Failure Ingestion Protocol**: Query open routine run issues for `<TARGET_ISSUE>`:
187
+ ```bash
188
+ gh issue list --label routine-log --search "Issue #<TARGET_ISSUE>" --state open --json number,title,body
189
+ ```
190
+ If prior failed routine issues are found (carrying label `status:failure` or an Interruption Card):
191
+ - Read the Interruption Card or latest milestone card to identify previous failure causes (e.g. failing test suite, build failure, timeout, or infeasible dependency).
192
+ - Incorporate findings into the reproduction plan and note in Milestone 1:
193
+ `- **Prior Failure Context**: <summary of past error/crash and strategy to avoid repeating it>`
148
194
  - If bug: use `/diagnosing-bugs` to establish reproduction test before fixing.
149
195
  - If large/complex: use `/domain-modeling` and `/codebase-design`.
150
196
  - **Pre-Flight Memory Scan**: If `LESSONS.md` exists, grep matching subsystem tags (`grep -E "^### \[(subsystem)\]" LESSONS.md -A 4`) to incorporate known landmines into implementation plans before writing code.
@@ -174,6 +220,7 @@ a. **Read the target issue and check eligibility.** Eligible = open, unassigned
174
220
  - **Phase**: \`Phase 1 ยท Target Selection & Planning\`
175
221
  - **Status**: โณ In Progress
176
222
  - **Target / Context**: \`#<TARGET_ISSUE> (<Title>)\`
223
+ - **Prior Failure Context**: <summary of past error/crash and strategy to avoid repeating it>
177
224
  - **Key Decision / Finding**: <Summary of plan, root cause, or reproduction strategy>
178
225
  - **Next**: Implementation & Test Verification" || true
179
226
  ```
@@ -199,6 +246,18 @@ a. **Read the target issue and check eligibility.** Eligible = open, unassigned
199
246
  - **Issue Cross-Reference Comment Guardrail**: Post an explicit comment on the tracking issue referencing the newly created PR (`gh issue comment <ISSUE_NUMBER> --body "Work in progress in PR #<PR_NUMBER>."`). This guarantees an unambiguous, permanent link on the issue timeline even when GitHub's native UI link is suppressed for bot draft PRs.
200
247
  - **Warm Context Assignment**: Assign yourself to the newly opened PR (`gh pr edit <PR> --add-assignee <login>`) to hold the reservation across Step 15's in-session review wait so parallel Scan routines recognise the PR as actively held by a live session.
201
248
  - Mark PR ready (`gh pr ready <PR>`).
249
+ - **Auto-Closure on Success**: Once the PR is marked ready (`gh pr ready <PR>`), resolve and close any open past failed routine issues for `#<TARGET_ISSUE>`:
250
+ ```bash
251
+ PAST_FAILURES=$(gh issue list --label routine-log --search "Issue #<TARGET_ISSUE>" --state open --json number --jq '.[].number' || true)
252
+ for past_num in $PAST_FAILURES; do
253
+ if [ -n "$past_num" ] && [ "$past_num" != "$ROUTINE_ISSUE_NUMBER" ]; then
254
+ gh issue comment "$past_num" --body "Resolved by autowork run ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-} (PR #<PR_NUMBER> created and ready).
255
+
256
+ _Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_" || true
257
+ gh issue close "$past_num" --reason completed || true
258
+ fi
259
+ done
260
+ ```
202
261
  - **Milestone 3 (Autonomous Handoff)**: Once PR is marked ready, emit milestone card if `$ROUTINE_ISSUE_NUMBER` is set:
203
262
  ```bash
204
263
  gh issue comment "$ROUTINE_ISSUE_NUMBER" --body "### ๐Ÿš€ Milestone: Autonomous Handoff
@@ -211,7 +270,18 @@ a. **Read the target issue and check eligibility.** Eligible = open, unassigned
211
270
  14. If run aborts before opening PR, release claim (unassign).
212
271
  15. **In-Session Peer Review Wait & Immediate Convergence (Warm Context):**
213
272
  - Poll PR status for up to 10โ€“12 minutes.
214
- - If merged: unassign yourself, record terminal SUCCESS and exit cleanly.
273
+ - If merged: unassign yourself, resolve and close any open past failed routine run issues for `#<TARGET_ISSUE>`, record terminal SUCCESS and exit cleanly:
274
+ ```bash
275
+ PAST_FAILURES=$(gh issue list --label routine-log --search "Issue #<TARGET_ISSUE>" --state open --json number --jq '.[].number' || true)
276
+ for past_num in $PAST_FAILURES; do
277
+ if [ -n "$past_num" ] && [ "$past_num" != "$ROUTINE_ISSUE_NUMBER" ]; then
278
+ gh issue comment "$past_num" --body "Resolved by autowork run ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-} (PR #<PR_NUMBER> merged).
279
+
280
+ _Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_" || true
281
+ gh issue close "$past_num" --reason completed || true
282
+ fi
283
+ done
284
+ ```
215
285
  - If bounced to draft with findings: fetch review comments, apply fixes in active worktree, run tests, push fix commit, re-mark ready (`gh pr ready <PR>`), and complete run.
216
286
  - If timeout (>12m): unassign yourself from the PR (`gh pr edit <PR> --remove-assignee <login>`) and exit cleanly; scheduled cron will handle subsequent rounds.
217
287
 
@@ -23,7 +23,7 @@ The run is SUCCESS only if ALL of these are true:
23
23
  - [ ] Label audit completed: every open issue has consistent type, size, and priority labels
24
24
  - [ ] Dependency check completed: issues with `## Dependencies` verified against blocker status
25
25
  - [ ] Orphaned-claim sweep completed: stale autowork claims (per `ORCHESTRATION.md`) released back to the unclaimed pool
26
- - [ ] Stalled routine run audit completed: routine log issues in `status:running` older than 6 hours marked as `status:failure` (timed_out)
26
+ - [ ] Stalled routine run audit and stale failure sweep completed: routine log issues in `status:running` older than 6 hours marked as `status:failure`; untargeted or already-resolved `status:failure` routine log issues older than 48 hours closed with resolution summary
27
27
  - [ ] Summary posted listing all changes made
28
28
 
29
29
  If any criterion cannot be met, stop immediately and log FAILURE with the reason.
@@ -39,7 +39,9 @@ If any criterion cannot be met, stop immediately and log FAILURE with the reason
39
39
 
40
40
  ### Phase 1: Quick Recovery & Clearing
41
41
 
42
- 1. **Stalled routine run sweep**: Check open issues with labels `routine-log` and `status:running`. If an issue has been in `status:running` for > 6 hours without updates, add label `status:failure`, remove `status:running`, add label `needs-attention`, and comment noting the runner timeout or crash.
42
+ 1. **Stalled routine run and stale failure sweep**:
43
+ - **Stalled runs**: Check open issues with labels `routine-log` and `status:running`. If an issue has been in `status:running` for > 6 hours without updates, add label `status:failure`, remove `status:running`, add label `needs-attention`, and comment noting the runner timeout or crash.
44
+ - **Stale / untargeted failures**: Check open issues with labels `routine-log` and `status:failure`. If an issue is older than 48 hours and either: (i) has no target issue or PR in its title or body (an untargeted infrastructure crash), or (ii) references a target issue or PR that has already been closed or merged, close the routine-log issue with comment "Closed: routine failure superseded or resolved.\n\n_Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_" and reason completed.
43
45
  2. **Orphaned-claim sweep**: Sweep assigned issues. If an issue meets the 3 stale-claim conditions in `ORCHESTRATION.md` (autowork claim comment, no open PR, comment > 6 hours old), re-read immediately before writing, unassign the dead owner, and post a release comment.
44
46
 
45
47
  ### Phase 2: Backlog Hygiene
@@ -68,7 +70,7 @@ If any criterion cannot be met, stop immediately and log FAILURE with the reason
68
70
 
69
71
  After completing (SUCCESS or FAILURE), record run execution details to `.jonah-fleet/run-report.md`. Include:
70
72
  - Prompt SHA
71
- - Tally of issues audited, claims released, stalled runs reconciled
73
+ - Tally of issues audited, claims released, stalled runs reconciled, and stale failure runs closed
72
74
  - List of closed or modified issues
73
75
 
74
76
  **Issue Logging Protocol**:
@@ -90,8 +90,18 @@ Check if `$PR_NUMBER` is set:
90
90
  - **Category A (re-review)**: PRs with prior review comments where author has pushed new fix commits.
91
91
  - **Category B (first review / unreviewed)**: Brand new PRs ready for review, or ready PRs whose previous review session failed or timed out.
92
92
 
93
- ### Step 3: Round tracking & Starting Review marker
93
+ ### Step 3: Round tracking, Target Binding, Failure Ingestion & Starting Review marker
94
94
 
95
+ - **Dynamic Target Binding (Scan Mode)**: If `$ROUTINE_ISSUE_NUMBER` is set and its title does not mention `(PR #<PR_NUMBER>)`:
96
+ ```bash
97
+ TIMESTAMP=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
98
+ gh issue edit "$ROUTINE_ISSUE_NUMBER" --title "[peer-review] run ${TIMESTAMP} (PR #<PR_NUMBER>)" || true
99
+ ```
100
+ - **Prior Review Failure Ingestion**: Query open routine run issues for `PR #<PR_NUMBER>`:
101
+ ```bash
102
+ gh issue list --label routine-log --search "PR #<PR_NUMBER>" --state open --json number,title,body
103
+ ```
104
+ If prior failed routine issues exist (carrying `status:failure` or an Interruption Card), read the Interruption Card or comments to understand what caused the previous review session to fail, crash, or timeout.
95
105
  - Post a "Starting review (round N)" comment on the target PR to claim the review window:
96
106
  - If `$ROUTINE_ISSUE_NUMBER` is set in the environment or routine prompt, include a link to the tracking log issue:
97
107
  `Starting review (round N) ยท [Run Log #$ROUTINE_ISSUE_NUMBER](${GITHUB_SERVER_URL:-https://github.com}/${GITHUB_REPOSITORY}/issues/${ROUTINE_ISSUE_NUMBER})`
@@ -104,6 +114,7 @@ Check if `$PR_NUMBER` is set:
104
114
  - **Phase**: \`Phase 1 ยท Review Target & Scope\`
105
115
  - **Status**: โณ In Progress
106
116
  - **Target / Context**: \`PR #<PR_NUMBER> (Round N)\`
117
+ - **Prior Failure Context**: <summary of past review failure/crash and verification focus, or None>
107
118
  - **Key Decision / Finding**: Claimed review window; starting multi-angle evaluation passes.
108
119
  - **Next**: Multi-Angle Code Review Pass" || true
109
120
  ```
@@ -144,7 +155,7 @@ If the PR is clean and approved for merge, but lacks a `Closes #N` tracking link
144
155
  gh pr edit <PR_NUMBER> --body "<PR Description>\n\nCloses #$ISSUE_NUMBER"
145
156
  ```
146
157
 
147
- ### Step 6: Execute Final Action
158
+ ### Step 6: Execute Final Action & Reconcile Past Failures
148
159
 
149
160
  - **If Blocking findings exist**:
150
161
  - If `N < 5`: Post inline comments, submit review as `COMMENT`, and convert PR to draft (`gh pr ready <N> --undo`).
@@ -156,12 +167,26 @@ If the PR is clean and approved for merge, but lacks a `Closes #N` tracking link
156
167
  - Squash-merge the PR: `gh pr merge <N> --squash --delete-branch`.
157
168
  - **Explicit Tracking Issue Closure Guardrail**: If a tracking issue was referenced (`$ISSUE_NUMBER`), explicitly close it immediately after merge rather than relying solely on GitHub's native keyword parser (which often fails to trigger on bot-merged squash commits or draft PRs):
158
169
  ```bash
159
- gh issue close "$ISSUE_NUMBER" --comment "Closed via PR #<N> (merged into main)."
170
+ gh issue close "$ISSUE_NUMBER" --comment "Closed via PR #<N> (merged into main).
171
+
172
+ _Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_"
160
173
  ```
161
174
  - Submit held review comments.
162
175
  - In any review summary, decision comment, or escalation comment posted to the PR, include the run log reference if `$ROUTINE_ISSUE_NUMBER` is set (e.g. `- **Run Log**: [#$ROUTINE_ISSUE_NUMBER](${GITHUB_SERVER_URL:-https://github.com}/${GITHUB_REPOSITORY}/issues/${ROUTINE_ISSUE_NUMBER})`).
163
176
  - File follow-up issues for material non-blocking findings.
164
177
  - If mechanical doc fixes are needed, commit directly to `main`.
178
+ - **Resolve Past Failed Review Runs**: After the terminal action (merge or bounce to draft) completes successfully, resolve and close any open past failed routine issues for `PR #<PR_NUMBER>`:
179
+ ```bash
180
+ PAST_FAILURES=$(gh issue list --label routine-log --search "PR #<PR_NUMBER>" --state open --json number --jq '.[].number' || true)
181
+ for past_num in $PAST_FAILURES; do
182
+ if [ -n "$past_num" ] && [ "$past_num" != "$ROUTINE_ISSUE_NUMBER" ]; then
183
+ gh issue comment "$past_num" --body "Resolved by peer-review run ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-} (PR #<PR_NUMBER> review cycle completed).
184
+
185
+ _Generated by [Antigravity](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID:-})_" || true
186
+ gh issue close "$past_num" --reason completed || true
187
+ fi
188
+ done
189
+ ```
165
190
 
166
191
  ## Logging
167
192