@oakgreencc/cambium 0.0.39 → 0.0.41
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 +95 -2
- package/package.json +1 -1
- package/src/cli.mjs +5 -1
- package/src/config.mjs +22 -1
- package/src/github.mjs +32 -0
- package/src/graph/define.mjs +11 -3
- package/src/graph/describe.mjs +50 -0
- package/src/graph/index.mjs +2 -1
- package/src/graph-engine.mjs +9 -2
- package/src/graphs/dispatch.mjs +33 -10
- package/src/graphs/pr.mjs +23 -6
- package/src/graphs/release.mjs +14 -5
- package/src/graphs/rescue.mjs +504 -0
- package/src/graphs/task.mjs +20 -5
- package/src/labels.mjs +4 -0
- package/src/marker.mjs +1 -1
- package/src/phases/dispatch.mjs +23 -14
- package/src/phases/rescue.mjs +444 -0
- package/src/rescue-engine.mjs +280 -0
- package/src/tick.mjs +17 -4
- package/src/upkeep.mjs +8 -1
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
|
|
|
@@ -273,10 +286,26 @@ Written at the end of every tick to `paths.heartbeat` (default `~/.cambium/state
|
|
|
273
286
|
"repo": "oakgreencc/monorepo",
|
|
274
287
|
"issue": 12
|
|
275
288
|
} // level: "info" | "warn" | "error"; repo/issue optional
|
|
289
|
+
],
|
|
290
|
+
"engine": "graph", // config.engine: "legacy" | "graph"
|
|
291
|
+
"graphs": [
|
|
292
|
+
// every graph this cambium defines, as describeGraph() writes it (see The graph module); the same every tick
|
|
293
|
+
{
|
|
294
|
+
"name": "task",
|
|
295
|
+
"version": 2,
|
|
296
|
+
"about": "Turns a q:task issue into a published PR; …",
|
|
297
|
+
"entry": { "queue": "q:task", "node": "start-worker" },
|
|
298
|
+
"nodes": [
|
|
299
|
+
{ "name": "worker-running", "kind": "wait", "queue": "q:task", "running": true, "about": "Holds while …" }
|
|
300
|
+
],
|
|
301
|
+
"edges": [{ "from": "start-worker", "to": "worker-running", "when": "started" }] // to: null ends the graph
|
|
302
|
+
}
|
|
276
303
|
]
|
|
277
304
|
}
|
|
278
305
|
```
|
|
279
306
|
|
|
307
|
+
`engine` and `graphs` were added within `version: 1`; a reader of an older heartbeat finds neither.
|
|
308
|
+
|
|
280
309
|
The mode lives in the SQLite file (`paths.db`, table `control`), so `cambium status --json` returns `{ "mode", "heartbeat" }` even when the daemon is down. The daemon's own log is `<paths.logs>/cambium.log` (one `.1` kept); launchd's stderr goes to `<paths.logs>/cambium.launchd.err.log`.
|
|
281
310
|
|
|
282
311
|
## The task graph
|
|
@@ -507,6 +536,69 @@ canopy's Promote lane lists these issues. A repo with `from` = `to` (e.g. releas
|
|
|
507
536
|
- **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
537
|
- **Legacy.** `engine: "legacy"` keeps the stub.
|
|
509
538
|
|
|
539
|
+
## The rescue graph
|
|
540
|
+
|
|
541
|
+
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.
|
|
542
|
+
|
|
543
|
+
```mermaid
|
|
544
|
+
flowchart TD
|
|
545
|
+
start_(["start"])
|
|
546
|
+
n0["start-rescue"]
|
|
547
|
+
n1{{"diagnosing"}}
|
|
548
|
+
n2["unstick"]
|
|
549
|
+
n3["file-causes"]
|
|
550
|
+
n4["report"]
|
|
551
|
+
n5["to-human"]
|
|
552
|
+
end_(("end"))
|
|
553
|
+
start_ --> n0
|
|
554
|
+
n0 -->|"started"| n1
|
|
555
|
+
n0 -->|"budgetSpent"| n5
|
|
556
|
+
n0 --> end_
|
|
557
|
+
n1 -->|"resolved"| end_
|
|
558
|
+
n1 -->|"diagnosed"| n2
|
|
559
|
+
n1 --> n5
|
|
560
|
+
n2 --> n3
|
|
561
|
+
n3 --> n4
|
|
562
|
+
n4 --> end_
|
|
563
|
+
n5 --> end_
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
**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.
|
|
567
|
+
|
|
568
|
+
| Symptom | Found |
|
|
569
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
570
|
+
| `many-queues` | More than one `q:*` label. |
|
|
571
|
+
| `running-unqueued` | `running` outside `q:task` / `q:intake` (not another host's lease). |
|
|
572
|
+
| `why-outside-human` | A `why:*` label without `q:human`. |
|
|
573
|
+
| `wait-outside-intake` | A `wait:*` label without `q:intake`. |
|
|
574
|
+
| `closed-labelled` | A closed issue still carrying cambium labels (`q:promote` aside). |
|
|
575
|
+
| `merged-open` | Its agent PR merged, the issue open in no queue. |
|
|
576
|
+
| `stranded` | Open in no queue, no open agent PR: its PR closed unmerged (or its marker names one). |
|
|
577
|
+
| `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. |
|
|
578
|
+
| `stale-intake` | The same in `q:intake`, with a triage slot free, not parked (deferred or blocked). |
|
|
579
|
+
| `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. |
|
|
580
|
+
|
|
581
|
+
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.
|
|
582
|
+
|
|
583
|
+
**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.
|
|
584
|
+
|
|
585
|
+
**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:
|
|
586
|
+
|
|
587
|
+
```json
|
|
588
|
+
{
|
|
589
|
+
"stuck": true,
|
|
590
|
+
"how": "the sequence of events, with times and evidence",
|
|
591
|
+
"actions": [{ "do": "clear-labels", "labels": ["why:budget"] }, { "do": "requeue", "queue": "task", "reason": "…" }],
|
|
592
|
+
"rootCauses": [{ "title": "…", "body": "…", "fingerprint": "kebab-case-cause", "repo": "owner/name" }]
|
|
593
|
+
}
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
**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.
|
|
597
|
+
|
|
598
|
+
**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).
|
|
599
|
+
|
|
600
|
+
**Report.** Last, a comment on the item: what cambium saw, how it got stuck, what rescue did, and the root-cause tickets.
|
|
601
|
+
|
|
510
602
|
## Graph module (preview)
|
|
511
603
|
|
|
512
604
|
`@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)).
|
|
@@ -547,6 +639,7 @@ const { transitions, reason, node, input } = await advance(g, { node: 'open-pr',
|
|
|
547
639
|
- **`validateGraph(graph)`** returns every problem as a string (`defineGraph` throws on any): unknown edge endpoints, nodes unreachable from `entry.node`, a node with outgoing edges whose last edge is conditional (no fallback), duplicate names, a non-integer `version`.
|
|
548
640
|
- **`advance(graph, { node, input }, ctx, { maxTransitions = 8, signal })`** runs step nodes and ready waits and returns `{ transitions, reason, node, input, error? }`: `reason` is `waiting` (a wait that is not ready), `end`, `limit`, `aborted` (`signal`, or `ctx.signal`, checked before each node) or `error`; `node`/`input` is where it stopped. Each transition is `{ from, to, edge, input, output, next }`. `ctx` is passed to `run`/`poll` untouched apart from `ctx.signal`; edges see `ctx.subject`.
|
|
549
641
|
- **`toMermaid(graph)`** renders a flowchart: boxes for steps, hexagons for waits, conditional edges labelled with `when`'s function name.
|
|
642
|
+
- **`describeGraph(graph)`** returns the graph as plain JSON: `{ name, version, about, entry: { queue, node }, nodes: [{ name, kind: 'step' | 'wait', queue, running, about }], edges: [{ from, to, when }] }`. `to: null` ends the graph; `when` is the condition's function name, `null` for the fallback. `about` is the optional one-line description given to `defineGraph` (and, in cambium's graphs, to each node's declaration); `queue`/`running` are the labels a node declares, else `null`/`false`. The heartbeat carries every cambium graph this way.
|
|
550
643
|
- **`opts.instrument(visit, step)`** (optional) wraps each node visit: `visit` is `{ node, kind: 'node' | 'wait', input }`; `step(extraCtx?)` runs the node (or poll) and picks the edge, returning the transition, or `null` for a wait that is not ready, and throws on a node error. `extraCtx` is merged into that node's `ctx`. Return what `step` returned. Without it, `advance` behaves exactly as before. [`advanceHooks`](#tracing) is the tracing implementation.
|
|
551
644
|
|
|
552
645
|
### LangGraph interop
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oakgreencc/cambium",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
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",
|
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: {
|
|
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}`]))
|
package/src/graph/define.mjs
CHANGED
|
@@ -20,7 +20,8 @@ export { END }
|
|
|
20
20
|
* @typedef {(out: any, subject: unknown) => unknown} EdgeFn
|
|
21
21
|
* @typedef {[from: string, to: string, when?: EdgeFn | null, map?: EdgeFn]} Edge
|
|
22
22
|
* @typedef {{ queue?: string, node: string, input?: (...args: any[]) => unknown }} Entry
|
|
23
|
-
* @typedef {{ name: string, version: number, entry: Entry, nodes: GraphNode[], edges: Edge[] }} Graph
|
|
23
|
+
* @typedef {{ name: string, version: number, about?: string, entry: Entry, nodes: GraphNode[], edges: Edge[] }} Graph
|
|
24
|
+
* `about`: one line on what the graph is for, carried into the heartbeat (graph/describe.mjs).
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
27
|
/** A failure inside a node: bad input or output, or a throw from run, poll, when or map. */
|
|
@@ -98,6 +99,13 @@ export function defineWait(def) {
|
|
|
98
99
|
export function defineGraph(def) {
|
|
99
100
|
const problems = validateGraph(def)
|
|
100
101
|
if (problems.length) throw new Error(`graph "${def?.name}" is invalid:\n- ${problems.join('\n- ')}`)
|
|
101
|
-
const { name, version, entry, nodes, edges } = def
|
|
102
|
-
return Object.freeze({
|
|
102
|
+
const { name, version, about, entry, nodes, edges } = def
|
|
103
|
+
return Object.freeze({
|
|
104
|
+
name,
|
|
105
|
+
version,
|
|
106
|
+
...(typeof about === 'string' ? { about } : {}),
|
|
107
|
+
entry: { ...entry },
|
|
108
|
+
nodes: [...nodes],
|
|
109
|
+
edges: edges.map((e) => e),
|
|
110
|
+
})
|
|
103
111
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* A graph as plain JSON, for the heartbeat: what a reader (canopy's Graphs tab) needs to draw it without importing
|
|
4
|
+
* cambium. Schemas and functions are dropped; a conditional edge keeps its `when`'s name.
|
|
5
|
+
*/
|
|
6
|
+
import { END } from './validate.mjs'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {{
|
|
10
|
+
* name: string, kind: 'step' | 'wait', queue: string | null, running: boolean, about: string | null,
|
|
11
|
+
* }} NodeDescription
|
|
12
|
+
* `queue`/`running`: the labels an issue resting at the node carries, when the graph declares them.
|
|
13
|
+
* @typedef {{ from: string, to: string | null, when: string | null }} EdgeDescription
|
|
14
|
+
* `to: null` ends the graph. `when: null` is the unconditional fallback, taken when no condition before it holds.
|
|
15
|
+
* @typedef {{
|
|
16
|
+
* name: string, version: number, about: string | null, entry: { queue: string | null, node: string },
|
|
17
|
+
* nodes: NodeDescription[], edges: EdgeDescription[],
|
|
18
|
+
* }} GraphDescription
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** @param {unknown} v */
|
|
22
|
+
const str = (v) => (typeof v === 'string' && v ? v : null)
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {import('./define.mjs').Graph} graph
|
|
26
|
+
* @returns {GraphDescription}
|
|
27
|
+
*/
|
|
28
|
+
export function describeGraph(graph) {
|
|
29
|
+
return {
|
|
30
|
+
name: graph.name,
|
|
31
|
+
version: graph.version,
|
|
32
|
+
about: str(graph.about),
|
|
33
|
+
entry: { queue: str(graph.entry.queue), node: graph.entry.node },
|
|
34
|
+
nodes: graph.nodes.map((n) => {
|
|
35
|
+
const d = /** @type {{ queue?: unknown, running?: unknown, about?: unknown }} */ (n)
|
|
36
|
+
return {
|
|
37
|
+
name: n.name,
|
|
38
|
+
kind: n.kind === 'wait' ? 'wait' : 'step',
|
|
39
|
+
queue: str(d.queue),
|
|
40
|
+
running: d.running === true,
|
|
41
|
+
about: str(d.about),
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
edges: graph.edges.map(([from, to, when]) => ({
|
|
45
|
+
from,
|
|
46
|
+
to: to === END ? null : to,
|
|
47
|
+
when: when ? when.name || 'when' : null,
|
|
48
|
+
})),
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/graph/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
/** `@oakgreencc/cambium/graph`: typed nodes, data edges, load-time validation, Mermaid and the advance loop. */
|
|
2
|
+
/** `@oakgreencc/cambium/graph`: typed nodes, data edges, load-time validation, Mermaid, JSON and the advance loop. */
|
|
3
3
|
export { defineGraph, defineNode, defineWait, END, GraphNodeError } from './define.mjs'
|
|
4
4
|
export { validateGraph } from './validate.mjs'
|
|
5
5
|
export { toMermaid } from './mermaid.mjs'
|
|
6
|
+
export { describeGraph } from './describe.mjs'
|
|
6
7
|
export { advance } from './advance.mjs'
|
package/src/graph-engine.mjs
CHANGED
|
@@ -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
|
-
/**
|
|
279
|
-
|
|
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 })
|
package/src/graphs/dispatch.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import { task } from './task.mjs'
|
|
|
24
24
|
* @typedef {import('../marker.mjs').Marker} Marker
|
|
25
25
|
* @typedef {import('./task.mjs').Subject} Subject
|
|
26
26
|
* @typedef {import('./task.mjs').TaskCtx} DispatchCtx
|
|
27
|
-
* @typedef {{ queue: string | null, running: boolean }} Declared
|
|
27
|
+
* @typedef {{ queue: string | null, running: boolean, about?: string }} Declared
|
|
28
28
|
* A stale `running` lease (at `triaging`) goes to `retry-triage` (dispatch-engine.mjs sweep).
|
|
29
29
|
* @typedef {import('../graph/define.mjs').GraphNode & Declared} DispatchNode
|
|
30
30
|
*/
|
|
@@ -235,7 +235,11 @@ const startTriage = declare(
|
|
|
235
235
|
return { to: 'running', pid: s.pid, worktree: s.worktree, attempt: marker.attempt }
|
|
236
236
|
},
|
|
237
237
|
}),
|
|
238
|
-
{
|
|
238
|
+
{
|
|
239
|
+
queue: Q.intake,
|
|
240
|
+
running: false,
|
|
241
|
+
about: 'Claims the issue and starts a triage worker in a read-only checkout; out of attempts, it goes to a human.',
|
|
242
|
+
},
|
|
239
243
|
)
|
|
240
244
|
|
|
241
245
|
const triaging = declare(
|
|
@@ -289,7 +293,12 @@ const triaging = declare(
|
|
|
289
293
|
}
|
|
290
294
|
},
|
|
291
295
|
}),
|
|
292
|
-
{
|
|
296
|
+
{
|
|
297
|
+
queue: Q.intake,
|
|
298
|
+
running: true,
|
|
299
|
+
about:
|
|
300
|
+
'Holds while the triage worker runs under its wall-clock cap; on exit, reads the typed verdict from its log.',
|
|
301
|
+
},
|
|
293
302
|
)
|
|
294
303
|
|
|
295
304
|
const retryTriage = declare(
|
|
@@ -322,7 +331,11 @@ const retryTriage = declare(
|
|
|
322
331
|
return { to: 'start', attempt: m.attempt + 1 }
|
|
323
332
|
},
|
|
324
333
|
}),
|
|
325
|
-
{
|
|
334
|
+
{
|
|
335
|
+
queue: Q.intake,
|
|
336
|
+
running: false,
|
|
337
|
+
about: 'Back to q:intake with attempt + 1, or to a human once the attempts are spent.',
|
|
338
|
+
},
|
|
326
339
|
)
|
|
327
340
|
|
|
328
341
|
const ToTaskIn = z.object({
|
|
@@ -367,7 +380,12 @@ const toTask = declare(
|
|
|
367
380
|
return {}
|
|
368
381
|
},
|
|
369
382
|
}),
|
|
370
|
-
{
|
|
383
|
+
{
|
|
384
|
+
queue: Q.task,
|
|
385
|
+
running: false,
|
|
386
|
+
about:
|
|
387
|
+
'Actionable: posts the triage comment (title, acceptance checks), then hands the issue to the task graph in q:task.',
|
|
388
|
+
},
|
|
371
389
|
)
|
|
372
390
|
|
|
373
391
|
const toHuman = declare(
|
|
@@ -398,7 +416,7 @@ const toHuman = declare(
|
|
|
398
416
|
return {}
|
|
399
417
|
},
|
|
400
418
|
}),
|
|
401
|
-
{ queue: Q.human, running: false },
|
|
419
|
+
{ queue: Q.human, running: false, about: 'Into q:human with why:triage and the reason in the state comment.' },
|
|
402
420
|
)
|
|
403
421
|
|
|
404
422
|
const DupIn = z.object({ duplicateOf: z.number().int(), reason: z.string(), log: z.string() })
|
|
@@ -443,7 +461,7 @@ const closeDuplicate = declare(
|
|
|
443
461
|
return {}
|
|
444
462
|
},
|
|
445
463
|
}),
|
|
446
|
-
{ queue: null, running: false },
|
|
464
|
+
{ queue: null, running: false, about: 'Out of every queue, closed as a duplicate with a link to the original.' },
|
|
447
465
|
)
|
|
448
466
|
|
|
449
467
|
const DeferIn = z.object({ reason: z.string(), recheckHours: z.number().optional(), log: z.string() })
|
|
@@ -502,7 +520,11 @@ const deferred = declare(
|
|
|
502
520
|
return { to: 'wait', until }
|
|
503
521
|
},
|
|
504
522
|
}),
|
|
505
|
-
{
|
|
523
|
+
{
|
|
524
|
+
queue: Q.intake,
|
|
525
|
+
running: false,
|
|
526
|
+
about: 'Rests in q:intake until a condition a machine can check is due, then triages again. Bounded by maxDefers.',
|
|
527
|
+
},
|
|
506
528
|
)
|
|
507
529
|
|
|
508
530
|
const BlockedIn = z.object({
|
|
@@ -573,7 +595,7 @@ const blockedNode = declare(
|
|
|
573
595
|
return { to: 'wait', blockedBy: open }
|
|
574
596
|
},
|
|
575
597
|
}),
|
|
576
|
-
{ queue: Q.intake, running: false },
|
|
598
|
+
{ queue: Q.intake, running: false, about: 'Rests in q:intake with wait:blocked until every blockedBy issue closes.' },
|
|
577
599
|
)
|
|
578
600
|
|
|
579
601
|
const ObsIn = z.object({ reason: z.string(), log: z.string() })
|
|
@@ -612,7 +634,7 @@ const closeObsolete = declare(
|
|
|
612
634
|
return {}
|
|
613
635
|
},
|
|
614
636
|
}),
|
|
615
|
-
{ queue: null, running: false },
|
|
637
|
+
{ queue: null, running: false, about: 'Out of every queue, closed as not planned with the evidence triage found.' },
|
|
616
638
|
)
|
|
617
639
|
|
|
618
640
|
/** @param {unknown} err */
|
|
@@ -621,6 +643,7 @@ const errText = (err) => /** @type {Error} */ (err)?.message ?? String(err)
|
|
|
621
643
|
/** The Dispatch phase. Bump `version` when a node is removed or renamed. */
|
|
622
644
|
export const dispatch = defineGraph({
|
|
623
645
|
name: 'dispatch',
|
|
646
|
+
about: 'Triages a q:intake issue with a one-shot read-only worker, then routes it on its verdict.',
|
|
624
647
|
version: 1,
|
|
625
648
|
entry: { queue: Q.intake, node: 'start-triage', input: () => ({}) },
|
|
626
649
|
nodes: [startTriage, triaging, retryTriage, toTask, toHuman, closeDuplicate, deferred, blockedNode, closeObsolete],
|
package/src/graphs/pr.mjs
CHANGED
|
@@ -155,7 +155,11 @@ const assess = declare(
|
|
|
155
155
|
return hold
|
|
156
156
|
},
|
|
157
157
|
}),
|
|
158
|
-
{
|
|
158
|
+
{
|
|
159
|
+
queue: null,
|
|
160
|
+
running: false,
|
|
161
|
+
about: 'Reads the PR and decides, in order: merged, close, rework, merge, stall or hold. Writes nothing.',
|
|
162
|
+
},
|
|
159
163
|
)
|
|
160
164
|
|
|
161
165
|
const merge = declare(
|
|
@@ -219,7 +223,11 @@ const merge = declare(
|
|
|
219
223
|
return { to: 'done' }
|
|
220
224
|
},
|
|
221
225
|
}),
|
|
222
|
-
{
|
|
226
|
+
{
|
|
227
|
+
queue: null,
|
|
228
|
+
running: false,
|
|
229
|
+
about: 'Updates a branch that is behind its base; otherwise merges through graft pr merge --auto.',
|
|
230
|
+
},
|
|
223
231
|
)
|
|
224
232
|
|
|
225
233
|
const ReworkIn = z.object({ ...failure, pr: z.number().int(), failedSha: z.string().nullable() })
|
|
@@ -281,7 +289,11 @@ const rework = declare(
|
|
|
281
289
|
return { to: 'task' }
|
|
282
290
|
},
|
|
283
291
|
}),
|
|
284
|
-
{
|
|
292
|
+
{
|
|
293
|
+
queue: Q.task,
|
|
294
|
+
running: false,
|
|
295
|
+
about: 'Back to the task graph in q:task with the PR kept and the reason as lastFailure. Reworks spent: q:human.',
|
|
296
|
+
},
|
|
285
297
|
)
|
|
286
298
|
|
|
287
299
|
const CloseIn = z.object({ pr: z.number().int(), reason: z.string() })
|
|
@@ -317,7 +329,7 @@ const closePr = declare(
|
|
|
317
329
|
return {}
|
|
318
330
|
},
|
|
319
331
|
}),
|
|
320
|
-
{ queue: null, running: false },
|
|
332
|
+
{ queue: null, running: false, about: 'Closes the PR with the reason. The issue stays where it is.' },
|
|
321
333
|
)
|
|
322
334
|
|
|
323
335
|
/** Delete a merged PR's branch once per tick. @param {TaskCtx} ctx @param {PullRequest} pr */
|
|
@@ -362,7 +374,11 @@ const closeOut = declare(
|
|
|
362
374
|
return {}
|
|
363
375
|
},
|
|
364
376
|
}),
|
|
365
|
-
{
|
|
377
|
+
{
|
|
378
|
+
queue: null,
|
|
379
|
+
running: false,
|
|
380
|
+
about: 'Merged: the issue is closed and leaves every queue, and the branch is deleted.',
|
|
381
|
+
},
|
|
366
382
|
)
|
|
367
383
|
|
|
368
384
|
const toHuman = declare(
|
|
@@ -393,12 +409,13 @@ const toHuman = declare(
|
|
|
393
409
|
return {}
|
|
394
410
|
},
|
|
395
411
|
}),
|
|
396
|
-
{ queue: Q.human, running: false },
|
|
412
|
+
{ queue: Q.human, running: false, about: 'Into q:human with a why:* reason label.' },
|
|
397
413
|
)
|
|
398
414
|
|
|
399
415
|
/** The PR graph. Bump `version` when a node is removed or renamed. */
|
|
400
416
|
export const prGraph = defineGraph({
|
|
401
417
|
name: 'pr',
|
|
418
|
+
about: 'Takes an agent PR whose CI has settled to merged, reworked, closed or a human.',
|
|
402
419
|
version: 1,
|
|
403
420
|
entry: { node: 'assess', input: () => ({}) },
|
|
404
421
|
nodes: [assess, merge, rework, closePr, closeOut, toHuman],
|