@oakgreencc/cambium 0.0.38 → 0.0.40

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/README.md CHANGED
@@ -30,6 +30,7 @@ cambium status
30
30
  | `cambium run <task\|pr\|dispatch> --issue <n> [--repo <owner/name>] [--follow]` | `engine: "graph"` only. `task`: advance one issue through the graph runtime in the foreground: a `q:task` issue without a lease starts with a foreground worker; anything else resumes where its marker rests. `pr`: the [PR graph](#the-pr-graph) for the issue's PR. `dispatch`: triage one `q:intake` issue with a foreground triage worker (the dispatch cap does not apply), read its verdict and end the [dispatch graph](#the-dispatch-graph); a tracked triage worker resumes at `triaging`. Stops at the first wait that is not ready; `--follow` re-reads and polls every `tickSeconds` until the graph ends. |
31
31
  | `cambium run release-prepare [--repo <owner/name>]` | `engine: "graph"` only. Run [release-prepare](#the-release-graphs) now, whatever `release.time`: close stale promotion PRs, open or refresh the promotion PR. Counts as the day's run. |
32
32
  | `cambium run release-promote [--repo <owner/name>] [--issue <pr>]` | `engine: "graph"` only. A [release-promote](#the-release-graphs) turn for each `q:promote` promotion PR (or only `<pr>`): merge an approved one, close out a merged or closed one; report the rest as not ready. |
33
+ | `cambium run rescue [--repo <owner/name>] [--issue <n>]` | `engine: "graph"` only. Without `--issue`: list the items the [rescue](#the-rescue-graph) sweep would find stuck now, with their symptoms (the cooldown aside); changes nothing. With it: rescue that item now with a foreground rescue worker, then carry out its verdict. |
33
34
  | `cambium gc [--dry-run] [--repo <owner/name>]` | Collect worktrees now; `--dry-run` only reports. See [Worktree GC](#worktree-gc). |
34
35
  | `cambium install [--dry-run]` | Write the launchd agent (`KeepAlive`, `RunAtLoad`) for `start --config <this config>`; `--dry-run` prints it. It does not call `launchctl`; it prints the command. |
35
36
  | `cambium update [--check] [--version <v>]` | Install the latest version (or `<v>`, even an older one) from npm into this global install, then SIGTERM the launchd agent so it finishes its tick and KeepAlive starts the new version. `--check` only reports. No config file needed. See [Self-update](#self-update). |
@@ -59,6 +60,8 @@ A requeue is `q:task` with attempt + 1, or, once `maxAttempts` are spent, `q:hum
59
60
  | `q:promote` on a closed issue | Merged into `release.from`, not yet in `release.to` ([Awaiting promotion](#awaiting-promotion)). |
60
61
  | `running` | A worker holds the lease (with `q:task`). |
61
62
  | `why:budget`, `why:triage` (also `why:reject`, …) | Why it is in `q:human` (`why:triage`: sent there by triage, see below). |
63
+ | `why:rescue` | In `q:human` because the [rescue graph](#the-rescue-graph) could not unstick it. |
64
+ | `rescue` | A root-cause ticket the rescue graph filed. |
62
65
  | _no `q:` label_, cambium comment, open `agent/*` PR | Submitted: in the Release Queue, which is the PR's merge-queue state. |
63
66
  | `priority:critical` … `priority:low` | Scheduling order (configurable). Unlabelled sorts after every listed priority. |
64
67
 
@@ -112,7 +115,8 @@ One JSON file. Everything but `repos` is optional; these are the defaults:
112
115
  "maxRounds": 3,
113
116
  "deferHours": 6,
114
117
  "maxDefers": 8
115
- }
118
+ },
119
+ "rescue": { "cap": 0, "wallClockMinutes": 20, "maxTurns": 80, "maxAttempts": 1 }
116
120
  },
117
121
  "mergeQueueMinutes": 120,
118
122
  "merge": "none",
@@ -120,6 +124,14 @@ One JSON file. Everything but `repos` is optional; these are the defaults:
120
124
  "release": { "enabled": false, "time": "06:00" },
121
125
  "reaper": { "everyMinutes": 60, "staleMinutes": 30, "orphanDays": 3 },
122
126
  "retriage": { "enabled": false, "time": "05:00" },
127
+ "rescue": {
128
+ "everyMinutes": 60,
129
+ "staleHours": 12,
130
+ "graceMinutes": 30,
131
+ "cooldownHours": 24,
132
+ "maxRescues": 2,
133
+ "causeRepo": null
134
+ },
123
135
  "paths": {
124
136
  "home": "~/.cambium",
125
137
  "db": "~/.cambium/cambium.db",
@@ -142,6 +154,7 @@ One JSON file. Everything but `repos` is optional; these are the defaults:
142
154
  - `merge` (top level, or per repo in `repos[]`): who merges a Task PR. See [The PR graph](#the-pr-graph).
143
155
  - `repos[].requiredCheck` (default `"ci"`): the check whose runs on `baseBranch` say whether the base is green; `null` turns the [red-base](#red-base) gate and repair off for that repo.
144
156
  - `engine` picks how the Task phase runs: `"legacy"` (the stage tick, the default) or `"graph"` (the [`task` graph](#the-task-graph)). Both make the same moves; see [The task graph](#the-task-graph). Only `"graph"` runs the [`dispatch` graph](#the-dispatch-graph) (gated by `phases.dispatch.cap`); legacy leaves `q:intake` alone.
157
+ - `phases.rescue.cap` (`engine: "graph"`; 0, the default, turns it off) and `rescue`: see [The rescue graph](#the-rescue-graph).
145
158
  - Setting `paths.home` moves every default path under it.
146
159
  - `release.time` is host-local `HH:MM`.
147
160
  - `repos[].release` (`engine: "graph"`): `{ "enabled", "time", "from", "to" }`. `enabled` and `time` default to the top-level `release`, `from` to the repo's `baseBranch`, `to` to `"main"`. A repo whose `from` equals `to` has no promotion PR. Example: `{ "slug": "o/app", "path": "~/app", "baseBranch": "develop", "release": { "enabled": true, "time": "06:00", "from": "develop", "to": "main" } }`.
@@ -175,7 +188,7 @@ The key decides which commands run on this host, so list `package.json` as prote
175
188
 
176
189
  ## Upkeep
177
190
 
178
- Two clocks in the graph engine's `upkeep` step, after Watch (`src/upkeep.mjs`).
191
+ Two clocks in the graph engine's `upkeep` step, after Watch (`src/upkeep.mjs`), then the [rescue graph](#the-rescue-graph)'s steps.
179
192
 
180
193
  **Reaper** (every `reaper.everyMinutes`, default 60; 0 turns it off). It looks at each open `agent/*` PR that nothing has updated for `reaper.staleMinutes` (default 30) and that cambium is not tracking. Such a PR comes from a worker killed at its wall-clock cap whose `graft publish` still landed, or from a PR body that never said `Closes #n`. Its issue is the one it closes, else the one its branch names (`agent/<n>-…`):
181
194
 
@@ -507,6 +520,69 @@ canopy's Promote lane lists these issues. A repo with `from` = `to` (e.g. releas
507
520
  - **Read.** With a repo's release on, the snapshot query also asks (in the same query) for the open PRs from `from` to `to`, the PRs labelled `q:promote`, and `to`'s comparison with `from` (`aheadBy`, and the merged PRs on the last 100 commits ahead).
508
521
  - **Legacy.** `engine: "legacy"` keeps the stub.
509
522
 
523
+ ## The rescue graph
524
+
525
+ With `"engine": "graph"` and `phases.rescue.cap > 0`, upkeep looks for stuck items every `rescue.everyMinutes` (default 60) and runs the `rescue` graph (`src/graphs/rescue.mjs`, steps in `src/rescue-engine.mjs`, detection, prompt and result in `src/phases/rescue.mjs`) for each: a one-shot, read-only `claude -p` worker works out how the item got stuck, what unsticks it and which root causes need a ticket; cambium checks that verdict, carries it out, files the tickets, and documents it all on the item.
526
+
527
+ ```mermaid
528
+ flowchart TD
529
+ start_(["start"])
530
+ n0["start-rescue"]
531
+ n1{{"diagnosing"}}
532
+ n2["unstick"]
533
+ n3["file-causes"]
534
+ n4["report"]
535
+ n5["to-human"]
536
+ end_(("end"))
537
+ start_ --> n0
538
+ n0 -->|"started"| n1
539
+ n0 -->|"budgetSpent"| n5
540
+ n0 --> end_
541
+ n1 -->|"resolved"| end_
542
+ n1 -->|"diagnosed"| n2
543
+ n1 --> n5
544
+ n2 --> n3
545
+ n3 --> n4
546
+ n4 --> end_
547
+ n5 --> end_
548
+ ```
549
+
550
+ **Stuck.** Detection is cambium's own (`findStuck`), over the snapshot plus the newest 50 closed-unmerged `agent/*` PRs and the issues they name. An item is always an issue; a stuck PR is reported on the issue it closes.
551
+
552
+ | Symptom | Found |
553
+ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
554
+ | `many-queues` | More than one `q:*` label. |
555
+ | `running-unqueued` | `running` outside `q:task` / `q:intake` (not another host's lease). |
556
+ | `why-outside-human` | A `why:*` label without `q:human`. |
557
+ | `wait-outside-intake` | A `wait:*` label without `q:intake`. |
558
+ | `closed-labelled` | A closed issue still carrying cambium labels (`q:promote` aside). |
559
+ | `merged-open` | Its agent PR merged, the issue open in no queue. |
560
+ | `stranded` | Open in no queue, no open agent PR: its PR closed unmerged (or its marker names one). |
561
+ | `stale-task` | In `q:task` without a lease for `rescue.staleHours` (default 12) while a task slot was free and the base not red: Schedule passed it over. |
562
+ | `stale-intake` | The same in `q:intake`, with a triage slot free, not parked (deferred or blocked). |
563
+ | `pr-stale` | An open agent PR nobody has updated for `rescue.staleHours`, its issue open in no queue (a queued one is the queue's; `q:human`'s is the human's). Untracked PRs are the [reaper](#upkeep)'s first. |
564
+
565
+ A label change counts after `rescue.graceMinutes` (default 30) since the issue's marker last moved (or since a merged or closed PR last changed), so a transition half-done this tick is not a symptom. An item a live worker holds, or that the tick already moved, is skipped.
566
+
567
+ **Pacing.** An item rescued in the last `rescue.cooldownHours` (default 24) is left alone. One rescued `rescue.maxRescues` (default 2) times in the last week goes straight to `q:human` + `why:rescue`, without another worker and whatever the cap. The rest start oldest issue first, up to `phases.rescue.cap` rescue workers. Rescue times live in the local store (`control`, `rescue:<repo>#<n>`): losing it costs an extra diagnosis at most.
568
+
569
+ **Diagnosis.** The worker runs in a read-only checkout (`cambium/rescue-<n>`, phase `rescue`) and is held to `phases.rescue.wallClockMinutes`. Its prompt has the symptoms, the issue, its marker, the PR involved, how cambium's queues work, where cambium's logs and source are, and how to read the issue's timeline (who changed which label when). The item is not claimed meanwhile: its labels are the evidence; the worker's row keeps Schedule and Sweep off it. Its final message ends with:
570
+
571
+ ```json
572
+ {
573
+ "stuck": true,
574
+ "how": "the sequence of events, with times and evidence",
575
+ "actions": [{ "do": "clear-labels", "labels": ["why:budget"] }, { "do": "requeue", "queue": "task", "reason": "…" }],
576
+ "rootCauses": [{ "title": "…", "body": "…", "fingerprint": "kebab-case-cause", "repo": "owner/name" }]
577
+ }
578
+ ```
579
+
580
+ **Actions**, in order: `clear-labels` (cambium labels only), `close-pr` (an open agent PR), then at most one move, last: `requeue` (to `q:task` or `q:intake` at its graph's entry, attempt 1, history kept, outcome `rescued`), `adopt-pr` (the task graph's `submit`, as the reaper adopts), `close-issue` (`completed` or `not_planned`), or `to-human` (`why:rescue`). `"stuck": false` takes no actions. Before anything is touched, the verdict is checked against the item (`checkPlan`); a missing, invalid or unworkable verdict, or a worker killed at its cap, sends the item to `q:human` + `why:rescue` with the error. When the worker exits the item is checked again: if none of the symptoms it started from still holds (someone fixed it meanwhile), the verdict is dropped.
581
+
582
+ **Root causes.** Each becomes a ticket in its `repo`: the item's own, or `rescue.causeRepo` (e.g. the repo that holds cambium itself). A ticket is labelled `q:intake` and `rescue`, so [triage](#the-dispatch-graph) takes it from there; its body is the worker's, then how the item got stuck, then a hidden `<!-- cambium:rescue-cause <fingerprint> -->`. When an open issue in that repo already carries the fingerprint, cambium comments there that the cause struck again instead of filing it twice (a repo cambium does not read is de-duplicated by what this host filed).
583
+
584
+ **Report.** Last, a comment on the item: what cambium saw, how it got stuck, what rescue did, and the root-cause tickets.
585
+
510
586
  ## Graph module (preview)
511
587
 
512
588
  `@oakgreencc/cambium/graph` is the start of typed workflows: nodes with schemas, edges as data, and a loop that advances a position through them. The Task phase runs on it with `engine: "graph"` ([The task graph](#the-task-graph)).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oakgreencc/cambium",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "The scheduler daemon: reads the q:* queues from GitHub every tick, runs headless claude workers in their own worktrees up to a cap, and makes every queue transition itself.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  "@opentelemetry/sdk-metrics": "^3.1.1",
52
52
  "@opentelemetry/sdk-trace": "^3.1.1",
53
53
  "zod": "^4.6.7",
54
- "@oakgreencc/mycelium": "0.0.11"
54
+ "@oakgreencc/mycelium": "0.0.12"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@langchain/core": "^1.4.1",
package/src/cli.mjs CHANGED
@@ -37,6 +37,9 @@ export const HELP = `cambium ${VERSION} — the scheduler daemon
37
37
  engine "graph": open or refresh the promotion PR now (the day's run)
38
38
  cambium run release-promote [--repo <owner/name>] [--issue <pr>]
39
39
  engine "graph": merge each approved q:promote promotion PR (or only <pr>)
40
+ cambium run rescue [--repo <owner/name>] [--issue <n>]
41
+ engine "graph": list the stuck issues and PRs (changes nothing); with
42
+ --issue, rescue that one now with a foreground rescue worker
40
43
  cambium gc [--dry-run] [--repo <owner/name>]
41
44
  remove worktrees GitHub holds all of; archive (to ~/.cambium/gc) then
42
45
  remove stale ones; skip live workers and live Claude Code sessions
@@ -242,7 +245,8 @@ async function runOne(config, argv, io, depsFor) {
242
245
  return fail(
243
246
  io,
244
247
  'usage: cambium run <graph> --issue <n> [--repo <owner/name>] [--follow]\n' +
245
- ' cambium run <release-prepare|release-promote> [--repo <owner/name>] [--issue <pr>]',
248
+ ' cambium run <release-prepare|release-promote> [--repo <owner/name>] [--issue <pr>]\n' +
249
+ ' cambium run rescue [--repo <owner/name>] [--issue <n>]',
246
250
  )
247
251
  const follow = has(argv, '--follow')
248
252
  if (config.engine === 'legacy' && (graph !== 'task' || follow))
package/src/config.mjs CHANGED
@@ -32,13 +32,17 @@ import { join, resolve } from 'node:path'
32
32
  * tickSeconds: number,
33
33
  * stepTimeoutSeconds: number,
34
34
  * repos: Repo[],
35
- * phases: { task: TaskCaps, dispatch: PhaseCaps & { maxRounds: number, deferHours: number, maxDefers: number } },
35
+ * phases: {
36
+ * task: TaskCaps, dispatch: PhaseCaps & { maxRounds: number, deferHours: number, maxDefers: number },
37
+ * rescue: PhaseCaps,
38
+ * },
36
39
  * mergeQueueMinutes: number,
37
40
  * merge: MergePolicy,
38
41
  * priorityLabels: string[],
39
42
  * release: { enabled: boolean, time: string },
40
43
  * reaper: { everyMinutes: number, staleMinutes: number, orphanDays: number },
41
44
  * retriage: { enabled: boolean, time: string },
45
+ * rescue: RescueConfig,
42
46
  * paths: { home: string, db: string, heartbeat: string, logs: string },
43
47
  * logs: { keepPerIssue: number, daemonMaxBytes: number },
44
48
  * graft: { command: string, app: string | null, botLogin: string | null },
@@ -46,6 +50,15 @@ import { join, resolve } from 'node:path'
46
50
  * update: { auto: boolean, checkMinutes: number },
47
51
  * gc: GcConfig,
48
52
  * }} Config
53
+ * @typedef {{
54
+ * everyMinutes: number, staleHours: number, graceMinutes: number, cooldownHours: number, maxRescues: number,
55
+ * causeRepo: string | null,
56
+ * }} RescueConfig
57
+ * The rescue graph (graphs/rescue.mjs, `engine: "graph"`, on while `phases.rescue.cap > 0`): every
58
+ * `everyMinutes` it looks for stuck items. A label that breaks the queue rules counts after `graceMinutes`; an
59
+ * item left waiting counts after `staleHours`. An item rescued in the last `cooldownHours` is left alone, and one
60
+ * rescued `maxRescues` times in a week goes to `q:human` without another diagnosis. `causeRepo`: a repo (owner/name)
61
+ * root-cause tickets may also be filed in, e.g. the one that holds cambium itself; the item's own repo always can.
49
62
  * @typedef {{ everyMinutes: number, graceMinutes: number, staleDays: number }} GcConfig
50
63
  * Worktree garbage collection (gc.mjs): the daemon sweeps every `everyMinutes` (0: only `cambium gc`). A
51
64
  * worktree touched within `graceMinutes` is left alone; one idle `staleDays` with work GitHub lacks is
@@ -76,6 +89,7 @@ export function defaults(home = DEFAULT_HOME) {
76
89
  deferHours: 6,
77
90
  maxDefers: 8,
78
91
  },
92
+ rescue: { cap: 0, wallClockMinutes: 20, maxTurns: 80, maxAttempts: 1 },
79
93
  },
80
94
  mergeQueueMinutes: 120,
81
95
  merge: 'none',
@@ -83,6 +97,7 @@ export function defaults(home = DEFAULT_HOME) {
83
97
  release: { enabled: false, time: '06:00' },
84
98
  reaper: { everyMinutes: 60, staleMinutes: 30, orphanDays: 3 },
85
99
  retriage: { enabled: false, time: '05:00' },
100
+ rescue: { everyMinutes: 60, staleHours: 12, graceMinutes: 30, cooldownHours: 24, maxRescues: 2, causeRepo: null },
86
101
  paths: {
87
102
  home,
88
103
  db: join(home, 'cambium.db'),
@@ -162,6 +177,12 @@ export function resolveConfig(raw = {}) {
162
177
  for (const k of /** @type {const} */ (['everyMinutes', 'graceMinutes', 'staleDays']))
163
178
  if (!(typeof config.gc[k] === 'number' && config.gc[k] >= 0))
164
179
  throw new Error(`config: gc.${k} must be a number, at least 0`)
180
+ for (const k of /** @type {const} */ (['everyMinutes', 'staleHours', 'graceMinutes', 'cooldownHours', 'maxRescues']))
181
+ if (!(typeof config.rescue[k] === 'number' && config.rescue[k] >= 0))
182
+ throw new Error(`config: rescue.${k} must be a number, at least 0`)
183
+ const causeRepo = config.rescue.causeRepo
184
+ if (causeRepo !== null && (typeof causeRepo !== 'string' || !/^[^/\s]+\/[^/\s]+$/.test(causeRepo)))
185
+ throw new Error(`config: rescue.causeRepo must be owner/name or null, got ${JSON.stringify(causeRepo)}`)
165
186
  if (config.engine !== 'legacy' && config.engine !== 'graph')
166
187
  throw new Error(`config: engine must be "legacy" or "graph", got ${JSON.stringify(config.engine)}`)
167
188
  const merging = config.repos.filter((r) => r.merge === 'green')
package/src/github.mjs CHANGED
@@ -69,11 +69,16 @@ import { BASE_FIELDS, baseHealthOf } from './base-health.mjs'
69
69
  * updatePull(slug: string, number: number): Promise<void>,
70
70
  * linkIssue(slug: string, pr: number, issue: number): Promise<void>,
71
71
  * addBlockedBy(slug: string, number: number, blocker: number): Promise<{ state: 'OPEN' | 'CLOSED' }>,
72
+ * closedPulls(slug: string): Promise<PullRequest[]>,
73
+ * readIssues(slug: string, numbers: number[]): Promise<Map<number, Issue>>,
72
74
  * }} GitHub
73
75
  * `behindBase`: how many commits of its base the PR's head lacks, read live (not from the tick's snapshot), so a
74
76
  * merge earlier in the same tick counts. `updatePull`: merge the base into the PR (`graft pr update`).
75
77
  * `linkIssue`: put `Closes #<issue>` at the top of the PR's body, so the PR names the issue it closes.
76
78
  * `addBlockedBy`: record GitHub's "blocked by" dependency of issue `number` on `blocker`; resolves the blocker's state.
79
+ * `closedPulls`: the newest {@link CLOSED_PULLS} `agent/*` PRs closed without merging (the rescue graph finds the
80
+ * issues they leave stranded). `readIssues`: these issues, whatever their labels or state; a number that is not
81
+ * an issue is left out.
77
82
  */
78
83
 
79
84
  const PR_FIELDS = `number url headRefName state headRefOid isInMergeQueue body mergeable reviewDecision createdAt updatedAt
@@ -148,6 +153,15 @@ export const ISSUES_PAGE_QUERY = `query($owner: String!, $name: String!, $labels
148
153
  } }
149
154
  ${SNAPSHOT_QUERY.slice(SNAPSHOT_QUERY.indexOf('fragment I on Issue'), SNAPSHOT_QUERY.indexOf('fragment P on'))}`
150
155
 
156
+ /** How many closed-unmerged PRs {@link CLOSED_PULLS_QUERY} reads, newest first. */
157
+ export const CLOSED_PULLS = 50
158
+
159
+ /** The newest closed (unmerged) PRs, for the rescue graph. */
160
+ export const CLOSED_PULLS_QUERY = `query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) {
161
+ closed: pullRequests(states: CLOSED, first: ${CLOSED_PULLS}, orderBy: { field: UPDATED_AT, direction: DESC }) { nodes { ${PR_FIELDS} } }
162
+ } }
163
+ ${SNAPSHOT_QUERY.slice(SNAPSHOT_QUERY.indexOf('fragment I on Issue'), SNAPSHOT_QUERY.indexOf('fragment P on'))}`
164
+
151
165
  /** Pages read past the first: 10 × 100 queued issues per repo is far past any real queue. */
152
166
  const MAX_ISSUE_PAGES = 10
153
167
 
@@ -494,6 +508,24 @@ export function graftGitHub({ config, exec: run = exec }) {
494
508
  const linked = `Closes #${issue}${body ? `\n\n${body}` : ''}`
495
509
  await graft(slug, ['api', 'PATCH', path, '--body', JSON.stringify({ body: linked })])
496
510
  },
511
+ async closedPulls(slug) {
512
+ const [owner, name] = slug.split('/')
513
+ const data = await json(graft(slug, ['graphql', CLOSED_PULLS_QUERY, '--vars', JSON.stringify({ owner, name })]))
514
+ const closed = (data?.data ?? data)?.repository?.closed?.nodes ?? []
515
+ return normalize({ repository: { open: { nodes: closed } } }).prs
516
+ },
517
+ async readIssues(slug, numbers) {
518
+ if (!numbers.length) return new Map()
519
+ const [owner, name] = slug.split('/')
520
+ const ask = (/** @type {number[]} */ ns) =>
521
+ json(graft(slug, ['graphql', issuesQuery(ns), '--vars', JSON.stringify({ owner, name })]))
522
+ // A number that resolves to nothing fails the whole query: then one at a time, skipping those.
523
+ const data = await ask(numbers).catch(async () => {
524
+ const one = await Promise.all(numbers.map((n) => ask([n]).catch(() => null)))
525
+ return { repository: Object.assign({}, ...one.map((d) => d?.repository ?? {})) }
526
+ })
527
+ return addIssues({ issues: new Map(), prs: [] }, data, numbers, config.graft.botLogin).issues
528
+ },
497
529
  async addBlockedBy(slug, number, blocker) {
498
530
  // The dependencies API takes the blocker's database id, not its number.
499
531
  const b = await json(graft(slug, ['api', 'GET', `/repos/${slug}/issues/${blocker}`]))
@@ -30,6 +30,8 @@ import { dispatch } from './graphs/dispatch.mjs'
30
30
  import { releasePrepare, releasePromote, runRelease } from './graphs/release.mjs'
31
31
  import { trackPromotion } from './promotion.mjs'
32
32
  import { trackBaseHealth } from './base-health.mjs'
33
+ import { rescue } from './graphs/rescue.mjs'
34
+ import { runRescue } from './rescue-engine.mjs'
33
35
 
34
36
  /**
35
37
  * @typedef {import('./tick.mjs').Deps} Deps
@@ -273,10 +275,14 @@ export const GRAPHS = {
273
275
  [dispatch.name]: dispatch,
274
276
  [releasePrepare.name]: releasePrepare,
275
277
  [releasePromote.name]: releasePromote,
278
+ [rescue.name]: rescue,
276
279
  }
277
280
 
278
- /** The graphs whose subject is a repo (its promotion PR), not an issue: `--issue` is optional. */
279
- export const REPO_GRAPHS = new Set([releasePrepare.name, releasePromote.name])
281
+ /**
282
+ * The graphs for which `--issue` is optional: the release graphs (their subject is the repo's promotion PR), and
283
+ * rescue (without it, a list of what is stuck).
284
+ */
285
+ export const REPO_GRAPHS = new Set([releasePrepare.name, releasePromote.name, rescue.name])
280
286
 
281
287
  export { prGraph }
282
288
 
@@ -298,6 +304,7 @@ export { prGraph }
298
304
  export async function runIssue(deps, { graph, slug, number, follow = false, out, sleep = delay, signal }) {
299
305
  if (!Object.hasOwn(GRAPHS, graph))
300
306
  return { ok: false, error: `unknown graph "${graph}"; known: ${Object.keys(GRAPHS).join(', ')}` }
307
+ if (graph === rescue.name) return runRescue(deps, { slug, number, out, newCtx })
301
308
  if (REPO_GRAPHS.has(graph)) return runRelease(deps, newCtx(deps), { graph, slug, pr: number, out })
302
309
  if (!Number.isInteger(number) || number <= 0) return { ok: false, error: `the ${graph} graph needs --issue <n>` }
303
310
  if (graph === prGraph.name) return runPr(deps, { slug, number, follow, out, sleep, signal })