@oakgreencc/cambium 0.0.32 → 0.0.34

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
@@ -19,18 +19,20 @@ cambium status
19
19
 
20
20
  ## Commands
21
21
 
22
- | Command | What |
23
- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
24
- | `cambium start [--once]` | Foreground daemon, one tick every `tickSeconds`. SIGTERM/SIGINT stop it after the current tick; workers keep running and are re-adopted on restart. One daemon per database. |
25
- | `cambium status [--json]` | Mode, last tick, queue counts, workers, failed steps. Exit 1 when there is no heartbeat or it is older than 3 ticks. |
26
- | `cambium pause` | Read and heartbeat only: no transitions, no starts. Running workers are left alone. |
27
- | `cambium drain` | Reconcile, watch and sweep as usual; start nothing new. |
28
- | `cambium resume` | Back to `running`. |
29
- | `cambium run task --issue <n> [--repo <owner/name>]` | Claim one open `q:task` issue, run its worker in the foreground, then make the same transition the daemon would. |
30
- | `cambium run <task | pr> --issue <n> [--repo <owner/name>] [--follow]` | `engine: "graph"` only. `pr`: the [PR graph](#the-pr-graph) for the issue's PR. `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. Stops at the first wait that is not ready; `--follow` re-reads and polls every `tickSeconds` until the graph ends. |
31
- | `cambium gc [--dry-run] [--repo <owner/name>]` | Collect worktrees now; `--dry-run` only reports. See [Worktree GC](#worktree-gc). |
32
- | `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. |
33
- | `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). |
22
+ | Command | What |
23
+ | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24
+ | `cambium start [--once]` | Foreground daemon, one tick every `tickSeconds`. SIGTERM/SIGINT stop it after the current tick; workers keep running and are re-adopted on restart. One daemon per database. |
25
+ | `cambium status [--json]` | Mode, last tick, queue counts, workers, failed steps. Exit 1 when there is no heartbeat or it is older than 3 ticks. |
26
+ | `cambium pause` | Read and heartbeat only: no transitions, no starts. Running workers are left alone. |
27
+ | `cambium drain` | Reconcile, watch and sweep as usual; start nothing new. |
28
+ | `cambium resume` | Back to `running`. |
29
+ | `cambium run task --issue <n> [--repo <owner/name>]` | Claim one open `q:task` issue, run its worker in the foreground, then make the same transition the daemon would. |
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
+ | `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
+ | `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 gc [--dry-run] [--repo <owner/name>]` | Collect worktrees now; `--dry-run` only reports. See [Worktree GC](#worktree-gc). |
34
+ | `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
+ | `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). |
34
36
 
35
37
  Every command takes `--config <file>`; the default is `$CAMBIUM_CONFIG`, then `~/.cambium/config.json`.
36
38
 
@@ -434,7 +436,7 @@ flowchart TD
434
436
  - **Retries.** A worker that cannot start, or a lost `running` lease on a `q:intake` issue (Sweep), goes back to `q:intake` with attempt + 1, then to `q:human` once `phases.dispatch.maxAttempts` are spent. A marker from another graph or a finished triage starts over at attempt 1.
435
437
  - **Defer, not a human.** A verdict that hangs on something a machine can check later (a CD run that has not happened, a release, a merge, a deploy) is `defer`, never `needs-human`: asking a human to verify what a machine can is what the factory exists to avoid. The issue rests at `deferred` with `deferUntil` (now + `recheckHours`, else `phases.dispatch.deferHours`, default 6) and `deferReason` in its marker; Schedule skips it until then, and the next triage gets the reason in its prompt ("check it now"). A defer is not a failed attempt. After `phases.dispatch.maxDefers` (default 8) it goes to `q:human` + `why:triage` with the last reason.
436
438
  - **Leaving intake.** If the issue is closed or relabelled while triage runs, the verdict is dropped and the checkout removed.
437
- - **Tracing.** Call sites are marked (`TRACING (follow-up)`) as in the task graph: the worker's `TRACEPARENT`, its stream-json spans, and `advanceHooks` in the driver, whose `cambium.issue` root continues mycelium's intake span from the issue body.
439
+ - **Tracing.** Wired as in the task graph (see [Tracing](#tracing)): the driver's node and wait spans under a `cambium.issue` root that continues mycelium's intake span from the issue body, the triage worker's `TRACEPARENT` (its `start-triage` span), and its stream-json spans when `triaging` ends.
438
440
 
439
441
  ## The release graphs
440
442
 
@@ -716,7 +718,7 @@ Without Jaeger running the collector still writes the files; the Jaeger exporter
716
718
 
717
719
  Seams that exist, typed, and do nothing yet:
718
720
 
719
- - **Dispatch on the legacy engine** (`src/phases/dispatch.mjs`): `Dispatch(input: { repo, intake, capacity, now }) → { started }`. Reached only when `phases.dispatch.cap > 0`; the stub starts nothing and logs that `q:intake` waits. The graph engine runs [the dispatch graph](#the-dispatch-graph) instead; `cambium run dispatch` is not wired yet.
721
+ - **Dispatch on the legacy engine** (`src/phases/dispatch.mjs`): `Dispatch(input: { repo, intake, capacity, now }) → { started }`. Reached only when `phases.dispatch.cap > 0`; the stub starts nothing and logs that `q:intake` waits. The graph engine runs [the dispatch graph](#the-dispatch-graph) instead (`cambium run dispatch --issue <n>` in the foreground). Switching `engine` back to `legacy` while a triage worker runs is safe: legacy holds it to its wall-clock cap but never finishes it as a Task, and leaves a lost triage lease on a `q:intake` issue alone; the graph engine picks both up once switched back.
720
722
  - **Release**, legacy engine only (`src/phases/release.mjs`): `Release(input: { repo, now }) → { done, note }`. The once-a-day schedule (`releaseDue`) is real and recorded in the store; the run returns `{ done: false }`. The graph engine runs the [release graphs](#the-release-graphs).
721
723
  - Conditional (ETag) reads, so an unchanged poll is free against the rate limit; GraphQL has no ETag, so this needs a REST probe in front of the query.
722
724
  - More than 100 queued issues or open PRs per repo, and state comments beyond an issue's first 100 comments: the read is one page.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oakgreencc/cambium",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
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.9"
54
+ "@oakgreencc/mycelium": "0.0.10"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@langchain/core": "^1.4.1",
package/src/cli.mjs CHANGED
@@ -14,7 +14,7 @@ import { acquireLock, readHeartbeat, realDeps, runDaemon } from './daemon.mjs'
14
14
  import { plist, plistPath } from './launchd.mjs'
15
15
  import { openStore } from './store.mjs'
16
16
  import { finish, newCtx, startTask } from './tick.mjs'
17
- import { runIssue } from './graph-engine.mjs'
17
+ import { REPO_GRAPHS, runIssue } from './graph-engine.mjs'
18
18
  import { createTelemetry } from './tracing.mjs'
19
19
  import { defaultExec, realUpdater, runUpdate, VERSION } from './update.mjs'
20
20
 
@@ -29,9 +29,14 @@ export const HELP = `cambium ${VERSION} — the scheduler daemon
29
29
  cambium drain reconcile and watch, start no new workers
30
30
  cambium run task --issue <n> [--repo <owner/name>]
31
31
  claim one q:task issue, run its worker in the foreground, transition
32
- cambium run <task|pr> --issue <n> [--repo <owner/name>] [--follow]
32
+ cambium run <task|pr|dispatch> --issue <n> [--repo <owner/name>] [--follow]
33
33
  engine "graph": advance the issue in the foreground to the first wait
34
- that is not ready; --follow keeps polling until the graph ends
34
+ that is not ready; --follow keeps polling until the graph ends.
35
+ dispatch: triage a q:intake issue with a foreground triage worker
36
+ cambium run release-prepare [--repo <owner/name>]
37
+ engine "graph": open or refresh the promotion PR now (the day's run)
38
+ cambium run release-promote [--repo <owner/name>] [--issue <pr>]
39
+ engine "graph": merge each approved q:promote promotion PR (or only <pr>)
35
40
  cambium gc [--dry-run] [--repo <owner/name>]
36
41
  remove worktrees GitHub holds all of; archive (to ~/.cambium/gc) then
37
42
  remove stale ones; skip live workers and live Claude Code sessions
@@ -229,10 +234,16 @@ function status(config, io, json) {
229
234
  * @param {(config: import('./config.mjs').Config) => import('./tick.mjs').Deps} depsFor
230
235
  */
231
236
  async function runOne(config, argv, io, depsFor) {
232
- const n = Number(flag(argv, '--issue'))
237
+ const issueFlag = flag(argv, '--issue')
238
+ const n = Number(issueFlag)
233
239
  const graph = argv[0]
234
- if (!graph || graph.startsWith('-') || !Number.isInteger(n) || n <= 0)
235
- return fail(io, 'usage: cambium run <graph> --issue <n> [--repo <owner/name>] [--follow]')
240
+ const optional = REPO_GRAPHS.has(graph) && issueFlag === undefined
241
+ if (!graph || graph.startsWith('-') || (!optional && (!Number.isInteger(n) || n <= 0)))
242
+ return fail(
243
+ io,
244
+ 'usage: cambium run <graph> --issue <n> [--repo <owner/name>] [--follow]\n' +
245
+ ' cambium run <release-prepare|release-promote> [--repo <owner/name>] [--issue <pr>]',
246
+ )
236
247
  const follow = has(argv, '--follow')
237
248
  if (config.engine === 'legacy' && (graph !== 'task' || follow))
238
249
  return fail(io, `engine "legacy" runs only \`run task --issue <n>\`; set "engine": "graph" for graphs and --follow`)
@@ -245,7 +256,15 @@ async function runOne(config, argv, io, depsFor) {
245
256
  const deps = depsFor(config)
246
257
  if (config.engine === 'graph') {
247
258
  const r = await withTelemetry(deps, io, () =>
248
- runIssue(deps, { graph, slug, number: n, follow, out: io.out, sleep: io.sleep, signal: io.signal }),
259
+ runIssue(deps, {
260
+ graph,
261
+ slug,
262
+ number: optional ? undefined : n,
263
+ follow,
264
+ out: io.out,
265
+ sleep: io.sleep,
266
+ signal: io.signal,
267
+ }),
249
268
  )
250
269
  return r.ok ? 0 : fail(io, /** @type {string} */ (r.error))
251
270
  }
@@ -25,7 +25,9 @@ import { effectivePosition, graphVersionDecision, withHistory } from './marker.m
25
25
  import { each, newCtx, staleLeases, taskCandidates, watchPairs } from './tick.mjs'
26
26
  import { move, Q, RUNNING } from './labels.mjs'
27
27
  import { markerTrace, turnTracer } from './tracing.mjs'
28
- import { DISPATCH_STEPS } from './dispatch-engine.mjs'
28
+ import { DISPATCH_STEPS, driveDispatch } from './dispatch-engine.mjs'
29
+ import { dispatch } from './graphs/dispatch.mjs'
30
+ import { releasePrepare, releasePromote, runRelease } from './graphs/release.mjs'
29
31
  import { trackPromotion } from './promotion.mjs'
30
32
  import { trackBaseHealth } from './base-health.mjs'
31
33
 
@@ -262,10 +264,19 @@ export const GRAPH_ENGINE = {
262
264
  upkeep,
263
265
  }
264
266
 
265
- // ---- `cambium run <graph> --issue <n> [--follow]`
267
+ // ---- `cambium run <graph> --issue <n> [--follow]`, `cambium run release-* --repo <slug> [--issue <pr>]`
266
268
 
267
269
  /** Graphs `cambium run` knows, by name. */
268
- export const GRAPHS = { [task.name]: task, [prGraph.name]: prGraph }
270
+ export const GRAPHS = {
271
+ [task.name]: task,
272
+ [prGraph.name]: prGraph,
273
+ [dispatch.name]: dispatch,
274
+ [releasePrepare.name]: releasePrepare,
275
+ [releasePromote.name]: releasePromote,
276
+ }
277
+
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])
269
280
 
270
281
  export { prGraph }
271
282
 
@@ -274,9 +285,12 @@ export { prGraph }
274
285
  * foreground worker, whose exit is awaited; anything else resumes where its marker rests. Stops at the first wait
275
286
  * that is not ready, unless `follow`, which re-reads and polls again every `tickSeconds` until the graph ends.
276
287
  *
288
+ * The dispatch graph runs the same way from `q:intake` ({@link runDispatch}); the release graphs take the repo,
289
+ * with `number` (optional) naming the promotion PR (graphs/release.mjs `runRelease`).
290
+ *
277
291
  * @param {Deps} deps
278
292
  * @param {{
279
- * graph: string, slug: string, number: number, follow?: boolean,
293
+ * graph: string, slug: string, number?: number, follow?: boolean,
280
294
  * out: (line: string) => void, sleep?: (ms: number) => Promise<void>, signal?: AbortSignal,
281
295
  * }} opts
282
296
  * @returns {Promise<{ ok: boolean, error?: string }>}
@@ -284,7 +298,10 @@ export { prGraph }
284
298
  export async function runIssue(deps, { graph, slug, number, follow = false, out, sleep = delay, signal }) {
285
299
  if (!Object.hasOwn(GRAPHS, graph))
286
300
  return { ok: false, error: `unknown graph "${graph}"; known: ${Object.keys(GRAPHS).join(', ')}` }
301
+ if (REPO_GRAPHS.has(graph)) return runRelease(deps, newCtx(deps), { graph, slug, pr: number, out })
302
+ if (!Number.isInteger(number) || number <= 0) return { ok: false, error: `the ${graph} graph needs --issue <n>` }
287
303
  if (graph === prGraph.name) return runPr(deps, { slug, number, follow, out, sleep, signal })
304
+ if (graph === dispatch.name) return runDispatch(deps, { slug, number, follow, out, sleep, signal })
288
305
  /** @type {Set<number>} */
289
306
  const reaped = new Set()
290
307
  let first = true
@@ -367,6 +384,62 @@ async function runPr(deps, { slug, number, follow, out, sleep, signal }) {
367
384
  }
368
385
  }
369
386
 
387
+ /**
388
+ * `cambium run dispatch --issue N [--follow]`: triage in the foreground. A `q:intake` issue without a lease starts
389
+ * at `start-triage` with a foreground triage worker, whose exit is awaited; then `triaging` reads its verdict and
390
+ * the graph ends (to-task, to-human, closed, or deferred). A tracked triage worker resumes at `triaging`.
391
+ * `--follow` polls every `tickSeconds` until the graph ends (e.g. after a retried triage).
392
+ * @param {Deps} deps
393
+ * @param {{ slug: string, number: number, follow: boolean, out: (line: string) => void, sleep: (ms: number) => Promise<void>, signal?: AbortSignal }} o
394
+ * @returns {Promise<{ ok: boolean, error?: string }>}
395
+ */
396
+ async function runDispatch(deps, { slug, number, follow, out, sleep, signal }) {
397
+ /** @type {Set<number>} */
398
+ const reaped = new Set()
399
+ for (let first = true; ; first = false) {
400
+ const ctx = newCtx(deps)
401
+ const snap = await deps.github.read(slug)
402
+ ctx.snaps.set(slug, snap)
403
+ const issue = snap.issues.get(number)
404
+ if (issue?.state !== 'OPEN') {
405
+ if (first) return { ok: false, error: `${slug}#${number} is not an open issue` }
406
+ return report(out, slug, number, issue)
407
+ }
408
+ const worker = deps.store.worker(slug, number)
409
+ const fresh = issue.labels.includes(Q.intake) && !issue.labels.includes(RUNNING) && !worker
410
+ const at = fresh
411
+ ? { node: dispatch.entry.node, input: {} }
412
+ : worker?.phase === 'dispatch'
413
+ ? { node: 'triaging', input: { attempt: worker.attempt } }
414
+ : null
415
+ if (!at) {
416
+ if (first)
417
+ return {
418
+ ok: false,
419
+ error: `${slug}#${number} has nothing to run in the dispatch graph (not in ${Q.intake}, or its triage holds a lease with no worker here)`,
420
+ }
421
+ return report(out, slug, number, issue)
422
+ }
423
+ /** @type {Subject} */
424
+ const subject = { slug, number, snap, issue, foreground: true, reaped }
425
+ const turn = await driveDispatch(deps, ctx, subject, at)
426
+ if (subject.started) {
427
+ const s = subject.started
428
+ out(`triage worker pid ${s.pid} in ${s.worktree}\n stdout ${s.stdout}\n stderr ${s.stderr}`)
429
+ const code = await s.exited
430
+ out(`triage worker exited ${code}`)
431
+ reaped.add(s.pid)
432
+ continue
433
+ }
434
+ if (first && fresh && !follow)
435
+ return { ok: false, error: `${slug}#${number} was not started; see its state comment` }
436
+ const ended = turn.transitions.some((t) => t.to === END)
437
+ if (ended || !follow || signal?.aborted) return report(out, slug, number, issue)
438
+ await sleep(deps.config.tickSeconds * 1000)
439
+ if (signal?.aborted) return report(out, slug, number, issue)
440
+ }
441
+ }
442
+
370
443
  /** @param {number} ms */
371
444
  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
372
445
 
@@ -172,6 +172,7 @@ const startTriage = declare(
172
172
  phase: 'dispatch',
173
173
  maxTurns: caps.maxTurns,
174
174
  readOnly: true,
175
+ foreground: ctx.subject.foreground ?? false,
175
176
  // This node's cambium.node span, so Claude Code's own spans (when worker.env turns them on) join the trace.
176
177
  env: ctx.traceparent ? { TRACEPARENT: ctx.traceparent } : undefined,
177
178
  buildPrompt: (agentsMd) =>
@@ -365,6 +365,7 @@ export const RELEASE_QUEUES = {
365
365
  *
366
366
  * @param {import('../graph/define.mjs').Graph} graph @param {ReleaseCtx} ctx
367
367
  * @param {{ node: string, input: unknown }} at
368
+ * @returns {Promise<import('../graph/advance.mjs').Transition[]>}
368
369
  */
369
370
  async function drive(graph, ctx, at) {
370
371
  const { pr } = ctx.subject
@@ -377,17 +378,20 @@ async function drive(graph, ctx, at) {
377
378
  issue: pr?.number,
378
379
  ...markerTrace(pr?.stateComment?.marker),
379
380
  })
381
+ /** @type {import('../graph/advance.mjs').Transition[]} */
382
+ const transitions = []
380
383
  let pos = at
381
384
  for (;;) {
382
385
  const r = await advance(graph, pos, ctx, { maxTransitions: 1, instrument: traced.instrument })
383
386
  if (r.error) throw r.error.cause instanceof Error ? r.error.cause : r.error
384
387
  traced.sync()
388
+ transitions.push(...r.transitions)
385
389
  const t = r.transitions[0]
386
390
  const next = /** @type {(import('../graph/define.mjs').GraphNode & Declared) | undefined} */ (
387
391
  graph.nodes.find((n) => n.name === r.node)
388
392
  )
389
393
  if (t && t.to !== END) await next?.enter?.(t.next, ctx)
390
- if (r.reason !== 'limit' || next?.kind === 'wait') return
394
+ if (r.reason !== 'limit' || next?.kind === 'wait') return transitions
391
395
  pos = { node: r.node, input: r.input }
392
396
  }
393
397
  }
@@ -449,3 +453,54 @@ export async function releaseGraphs(deps, tick) {
449
453
  }
450
454
  }
451
455
  }
456
+
457
+ // ---- `cambium run release-prepare|release-promote --repo <slug> [--issue <pr>]`
458
+
459
+ /** @param {import('../graph/advance.mjs').Transition[]} ts */
460
+ const path = (ts) => ts.map((t) => (t.to === END ? 'end' : String(t.to))).join(' → ')
461
+
462
+ /**
463
+ * One release graph in the foreground for one repo, whatever the clock: `release-prepare` runs once (and counts
464
+ * as the day's run); `release-promote` takes a turn for each `q:promote` PR (or only PR `pr`) that is ready, and
465
+ * reports the rest.
466
+ *
467
+ * @param {import('../tick.mjs').Deps} deps @param {import('../tick.mjs').Ctx} tick a fresh tick context
468
+ * @param {{ graph: string, slug: string, pr?: number, out: (line: string) => void }} opts
469
+ * @returns {Promise<{ ok: boolean, error?: string }>}
470
+ */
471
+ export async function runRelease(deps, tick, { graph, slug, pr: only, out }) {
472
+ const repo = deps.config.repos.find((r) => r.slug === slug)
473
+ if (!repo) return { ok: false, error: `${slug} is not in the config` }
474
+ const { from, to } = repo.release
475
+ if (from === to) return { ok: false, error: `${slug}: release.from = release.to (\`${from}\`); nothing to promote` }
476
+ const snap = await deps.github.read(slug)
477
+ tick.snaps.set(slug, snap)
478
+ const release = snap.release
479
+ if (!release) return { ok: false, error: `${slug}: no release state in the snapshot` }
480
+ /** @param {PromotionPr} [pr] @returns {ReleaseCtx} */
481
+ const ctxFor = (pr) => ({ ...deps, tick, subject: { slug, repo, release, pr } })
482
+ if (graph === releasePrepare.name) {
483
+ deps.store.set(lastRunKey(slug), String(tick.now))
484
+ const ts = await drive(releasePrepare, ctxFor(), { node: releasePrepare.entry.node, input: {} })
485
+ out(`${slug} release-prepare: ${path(ts)}`)
486
+ return { ok: true }
487
+ }
488
+ const prs = release.prs.filter((p) => only === undefined || p.number === only)
489
+ if (only !== undefined && !prs.length) return { ok: false, error: `${slug}: #${only} is not a promotion PR` }
490
+ if (!prs.length) out(`${slug} release-promote: no promotion PR`)
491
+ for (const pr of prs) {
492
+ const at = promoteStart(pr)
493
+ if (!at) {
494
+ const why = !pr.labels.includes(Q.promote)
495
+ ? `no ${Q.promote}`
496
+ : !pr.approved
497
+ ? 'not approved'
498
+ : 'merge refused on this head'
499
+ out(`PR #${pr.number}: not ready (${why}, ${pr.state.toLowerCase()})`)
500
+ continue
501
+ }
502
+ const ts = await drive(releasePromote, ctxFor(pr), at)
503
+ out(`PR #${pr.number}: ${path(ts) || at.node}`)
504
+ }
505
+ return { ok: true }
506
+ }
package/src/tick.mjs CHANGED
@@ -229,7 +229,12 @@ export async function requeue(deps, ctx, slug, issue, what) {
229
229
 
230
230
  // ---- Reconcile
231
231
 
232
- /** @param {Deps} deps @param {Ctx} ctx */
232
+ /**
233
+ * A triage worker (phase `dispatch`, started by the graph engine before a switch to `legacy`) is only held to its
234
+ * wall-clock cap: its row stays, so its `running` lease is not swept, and the graph engine reads its verdict once
235
+ * switched back. Legacy never finishes it as a Task.
236
+ * @param {Deps} deps @param {Ctx} ctx
237
+ */
233
238
  async function reconcile(deps, ctx) {
234
239
  const { config, store, procs } = deps
235
240
  await each(
@@ -238,6 +243,7 @@ async function reconcile(deps, ctx) {
238
243
  async (w) => {
239
244
  const caps = config.phases[/** @type {'task'} */ (w.phase)] ?? config.phases.task
240
245
  if (stopOverdue({ procs, store, log: deps.log }, w, caps.wallClockMinutes, ctx.now) !== 'gone') return
246
+ if (w.phase === 'dispatch') return
241
247
  const snap = ctx.snaps.get(w.repo)
242
248
  if (snap) await finish(deps, ctx, w, snap)
243
249
  },
@@ -387,12 +393,16 @@ export const watched = (deps, slug, issue) =>
387
393
 
388
394
  // ---- Sweep: stale leases (a `running` label on this host with no tracked worker)
389
395
 
390
- /** @param {Deps} deps @param {Ctx} ctx */
396
+ /**
397
+ * A stale lease on a `q:intake` issue is a lost triage (the graph engine's): legacy leaves it to the dispatch
398
+ * graph's sweep rather than requeue it as a Task.
399
+ * @param {Deps} deps @param {Ctx} ctx
400
+ */
391
401
  async function sweep(deps, ctx) {
392
402
  for (const [slug, snap] of ctx.snaps)
393
403
  await each(
394
404
  deps,
395
- staleLeases(deps, ctx, slug, snap),
405
+ staleLeases(deps, ctx, slug, snap).filter((issue) => !issue.labels.includes(Q.intake)),
396
406
  (issue) => requeue(deps, ctx, slug, issue, lostLease(deps)),
397
407
  (issue) => ({ repo: slug, issue: issue.number }),
398
408
  )
package/src/workers.mjs CHANGED
@@ -348,6 +348,8 @@ export function processSpawner({
348
348
  ...config.worker.env,
349
349
  ...extraEnv,
350
350
  }
351
+ // A triage worker has no branch, even when cambium itself runs inside a worker's environment.
352
+ if (readOnly) delete env.CAMBIUM_BRANCH
351
353
  /** @type {import('node:child_process').ChildProcess} */
352
354
  let child
353
355
  try {