@oakgreencc/cambium 0.0.35 → 0.0.36

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
@@ -434,7 +434,7 @@ flowchart TD
434
434
  - **Outcomes.** `actionable` → a comment with the reason, the task title and acceptance checks (when given), then `q:task` with a task-graph marker at `start-worker`, attempt 1, history kept; the checks also ride in the marker (`triage`) into the task worker's prompt. The issue body is never rewritten: cambium's write path has no issue edit, and the author's text stays as written. `needs-human` → `q:human` + `why:triage`, the reason as the state comment's last failure. `duplicate` → closed with reason `duplicate` and `Duplicate of #n (<link>). <reason>`. `obsolete` (the work no longer applies, verified: the code path is gone, already fixed, its check already passed) → closed as `not_planned` with `Obsolete: <reason>`. `defer` → stays in `q:intake` at `deferred` (see below). A missing or invalid verdict (no `result` event, no JSON, a schema error) or a worker killed at `wallClockMinutes` (the unlabelled `triaging → to-human` edge) → `q:human` + `why:triage` with the error.
435
435
  - **Read-only checkout.** Triage reads code to judge feasibility and duplicates, so it gets a checkout, but a disposable one: a detached worktree at `<root>/triage-<n>` on `origin/<base>` (the repo's worktree root), no install, hydrate or `prepare`, tools `Read,Glob,Grep,Bash` with Edit/Write and every graft/git write verb denied. It is removed outright after the verdict (no `graft status`: nothing in it is worth keeping).
436
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.
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.
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. A deferred issue whose GitHub "blocked by" issues are all closed, at least one after it was deferred, is triaged again at the next tick instead of waiting for `deferUntil`. After `phases.dispatch.maxDefers` (default 8) it goes to `q:human` + `why:triage` with the last reason.
438
438
  - **Leaving intake.** If the issue is closed or relabelled while triage runs, the verdict is dropped and the checkout removed.
439
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.
440
440
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oakgreencc/cambium",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
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",
@@ -129,14 +129,27 @@ export function intakeCandidates(deps, ctx) {
129
129
  }
130
130
 
131
131
  /**
132
- * Resting at `deferred` with its recheck time still ahead: triage waits for it.
132
+ * Resting at `deferred` with its recheck time still ahead: triage waits for it. Unless it was unblocked meanwhile:
133
+ * every GitHub "blocked by" issue is closed and one closed after the defer, so it is triaged again at once rather
134
+ * than at `deferUntil`. A blocker closed before the defer did not cause it, so it wakes nothing.
133
135
  * @param {import('./github.mjs').Issue} issue @param {number} now
134
136
  */
135
137
  const deferredPast = (issue, now) => {
136
138
  const m = issue.stateComment?.marker
137
- return m?.graph === dispatch.name && m.node === 'deferred' && !!m.deferUntil && Date.parse(m.deferUntil) > now
139
+ if (!(m?.graph === dispatch.name && m.node === 'deferred' && !!m.deferUntil && Date.parse(m.deferUntil) > now))
140
+ return false
141
+ return !unblockedSince(issue.blockedBy ?? [], m.enteredAt)
138
142
  }
139
143
 
144
+ /**
145
+ * All blockers closed, at least one after `since`.
146
+ * @param {import('./github.mjs').Blocker[]} blockers @param {string | null} since
147
+ */
148
+ const unblockedSince = (blockers, since) =>
149
+ blockers.length > 0 &&
150
+ blockers.every((b) => b.state === 'CLOSED') &&
151
+ blockers.some((b) => !since || (!!b.closedAt && Date.parse(b.closedAt) > Date.parse(since)))
152
+
140
153
  /** @param {Deps} deps @param {Ctx} ctx */
141
154
  async function schedule(deps, ctx) {
142
155
  await each(
package/src/github.mjs CHANGED
@@ -14,7 +14,10 @@ import { BASE_FIELDS, baseHealthOf } from './base-health.mjs'
14
14
  * @typedef {{
15
15
  * number: number, title: string, url: string, state: 'OPEN' | 'CLOSED', createdAt: string, body: string,
16
16
  * labels: string[], stateComment: { id: number, marker: import('./marker.mjs').Marker } | null,
17
+ * blockedBy: Blocker[],
17
18
  * }} Issue
19
+ * @typedef {{ number: number, state: 'OPEN' | 'CLOSED', closedAt: string | null }} Blocker
20
+ * An issue GitHub records as blocking this one (the "blocked by" relationship).
18
21
  * @typedef {{ name: string, url: string | null, summary: string }} FailingCheck
19
22
  * @typedef {{
20
23
  * number: number, url: string, branch: string, state: 'OPEN' | 'MERGED' | 'CLOSED', headSha: string | null,
@@ -101,6 +104,7 @@ export const SNAPSHOT_QUERY = `query($owner: String!, $name: String!, $labels: [
101
104
  fragment I on Issue {
102
105
  number title url state createdAt body
103
106
  labels(first: 30) { nodes { name } }
107
+ blockedBy(first: 20) { nodes { number state closedAt } }
104
108
  comments(first: 100) { nodes { databaseId body author { login } } }
105
109
  }
106
110
  fragment P on PullRequest {
@@ -214,6 +218,11 @@ function toIssue(n, botLogin) {
214
218
  body: n.body ?? '',
215
219
  labels: labelsOf(n),
216
220
  stateComment: stateCommentOf(n, botLogin),
221
+ blockedBy: (n.blockedBy?.nodes ?? []).filter(Boolean).map((/** @type {any} */ b) => ({
222
+ number: b.number,
223
+ state: b.state,
224
+ closedAt: b.closedAt ?? null,
225
+ })),
217
226
  }
218
227
  }
219
228