@eir-labs/coltrane 0.6.2 → 0.7.2

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.
Files changed (85) hide show
  1. package/README.md +23 -0
  2. package/agents/bill.json +59 -0
  3. package/agents/deploy-agent.json +68 -0
  4. package/agents/deploy-scout.json +40 -0
  5. package/agents/john.json +42 -0
  6. package/agents/miles.json +44 -0
  7. package/charts/software-delivery-v1.json +9 -0
  8. package/charts/software-delivery-v2.json +39 -0
  9. package/dist/src/canonical_form.d.ts +23 -0
  10. package/dist/src/canonical_form.js +53 -0
  11. package/dist/src/canonical_form.js.map +1 -1
  12. package/dist/src/chart.d.ts +254 -0
  13. package/dist/src/chart.js +897 -0
  14. package/dist/src/chart.js.map +1 -0
  15. package/dist/src/cli.d.ts +19 -4
  16. package/dist/src/cli.js +132 -9
  17. package/dist/src/cli.js.map +1 -1
  18. package/dist/src/composition.d.ts +24 -0
  19. package/dist/src/composition.js +50 -5
  20. package/dist/src/composition.js.map +1 -1
  21. package/dist/src/genome_schema.d.ts +1130 -166
  22. package/dist/src/genome_schema.js +311 -34
  23. package/dist/src/genome_schema.js.map +1 -1
  24. package/dist/src/genome_store.d.ts +53 -3
  25. package/dist/src/genome_store.js +316 -139
  26. package/dist/src/genome_store.js.map +1 -1
  27. package/dist/src/gig_tracker.d.ts +11 -1
  28. package/dist/src/gig_tracker.js +5 -0
  29. package/dist/src/gig_tracker.js.map +1 -1
  30. package/dist/src/index.d.ts +1 -0
  31. package/dist/src/index.js +1 -0
  32. package/dist/src/index.js.map +1 -1
  33. package/dist/src/ledger.d.ts +22 -0
  34. package/dist/src/ledger.js +4 -0
  35. package/dist/src/ledger.js.map +1 -1
  36. package/dist/src/loader.d.ts +9 -1
  37. package/dist/src/loader.js +105 -5
  38. package/dist/src/loader.js.map +1 -1
  39. package/dist/src/mcp.js +42 -4
  40. package/dist/src/mcp.js.map +1 -1
  41. package/dist/src/output_mirror.d.ts +1 -1
  42. package/dist/src/outputs.d.ts +75 -1
  43. package/dist/src/outputs.js +142 -28
  44. package/dist/src/outputs.js.map +1 -1
  45. package/dist/src/reuse.d.ts +56 -0
  46. package/dist/src/reuse.js +0 -0
  47. package/dist/src/reuse.js.map +1 -1
  48. package/dist/src/runtime.d.ts +91 -2
  49. package/dist/src/runtime.js +217 -17
  50. package/dist/src/runtime.js.map +1 -1
  51. package/dist/src/server.d.ts +11 -0
  52. package/dist/src/server.js +529 -64
  53. package/dist/src/server.js.map +1 -1
  54. package/dist/src/version.d.ts +1 -1
  55. package/dist/src/version.js +1 -1
  56. package/dist/src/worker.d.ts +182 -0
  57. package/dist/src/worker.js +609 -0
  58. package/dist/src/worker.js.map +1 -0
  59. package/domain_types/branch-state.json +21 -0
  60. package/domain_types/change-context.json +39 -0
  61. package/domain_types/change-decision.json +36 -0
  62. package/domain_types/change-plan.json +47 -0
  63. package/domain_types/change-request.json +24 -0
  64. package/domain_types/change-set.json +46 -0
  65. package/domain_types/change-verdict.json +26 -0
  66. package/domain_types/deploy-verdict.json +23 -0
  67. package/domain_types/design-brief.json +37 -0
  68. package/domain_types/design-concept.json +36 -0
  69. package/domain_types/design-definition.json +37 -0
  70. package/domain_types/design-question.json +23 -0
  71. package/domain_types/design-verdict.json +27 -0
  72. package/domain_types/preview-deployment.json +32 -0
  73. package/institutions/quartet.json +344 -0
  74. package/package.json +4 -1
  75. package/skills/vercel-api/fixtures/error.json +10 -0
  76. package/skills/vercel-api/fixtures/ready.json +10 -0
  77. package/skills/vercel-api/fixtures/unsettled.json +10 -0
  78. package/skills/vercel-api/meta.json +10 -0
  79. package/skills/vercel-api/skill.mjs +63 -0
  80. package/standards/preview-deploy-v1.json +89 -0
  81. package/standards/product-design-v1.json +122 -0
  82. package/standards/promote-v1.json +41 -0
  83. package/standards/software-change-v1.json +147 -0
  84. package/venues/ci-deploy-room-v1.json +28 -0
  85. package/venues/empty-room-v1.json +19 -0
@@ -0,0 +1,609 @@
1
+ // worker.ts — the drain worker's verb set. The gig table IS the queue; this module is the
2
+ // consumer that turns a queued row into a completed one.
3
+ //
4
+ // The credential model is two keys with two jobs (governor rulings, 2026-08-10):
5
+ // * a ctk_ AGENT token — per-agent, authenticates WHO is working. Claim, genome read, and
6
+ // failure reporting all speak through it; authorization derives from the CHAIR CONTRACT
7
+ // the agent is seated on (the store enforces it — "standards should be authorized on
8
+ // chair contract"). A token narrows the office, never widens it.
9
+ // * a cdk_ DRAIN key — per-ORGANIZATION, because the org is the resource boundary. It is
10
+ // the write path for results (outputs + gig header), consumed by the engine's drain
11
+ // layer via COLTRANE_DRAIN_URL / COLTRANE_DRAIN_KEY, not by this module directly.
12
+ //
13
+ // workOnce runs the claimed gig UNDER THE CLAIMED GIG'S ID (deps.gig_id), so the drained
14
+ // header completes the queue row itself — one record per gig, no parallel bookkeeping. A
15
+ // run that throws is recorded as failed through coltrane_mcp_gig_fail; a worker crash
16
+ // leaves only an expiring lease, which the claim RPC hands to the next worker.
17
+ //
18
+ // The third outcome is the HUMAN SEAT. A run that reaches a chair a person holds parks:
19
+ // coltrane_mcp_gig_park sets the row to awaiting_approval and clears the lease, so the store's
20
+ // approve RPC can re-queue it at once. The approval comes back on the next claim payload, and
21
+ // the durable checkpoint (workerStateRoot) means the approved re-claim RESTORES the chairs that
22
+ // already sealed instead of paying for them twice.
23
+ //
24
+ // THAT LOCAL CHECKPOINT IS ONLY THE FAST PATH. A human-in-the-loop delay is measured in hours
25
+ // or days, and the worker that re-claims is a different process — often on a different machine
26
+ // — from the one that parked. `workerStateRoot()` cannot travel, so on its own it makes the
27
+ // saving conditional on the accident of which box picked the row up.
28
+ //
29
+ // The SINK already is the checkpoint. Every sealed output drained to the org store carries its
30
+ // content_sha, its input_shas, its phase, its agent_slug and its whole `data`; the drained gig
31
+ // header carries the run's genome_hash. So a worker with no local record reconstructs one from
32
+ // the sink (`resumeStateFromDrain` below) and resumes from that. Resume state's home is the
33
+ // store; the local checkpoint demotes to a fast path.
34
+ import { homedir, tmpdir } from "node:os";
35
+ import { join } from "node:path";
36
+ import { runGig, ResumeRefused, genomeHash, CORE_TO_PRIMITIVE } from "./runtime.js";
37
+ import { loadRegistry } from "./registry.js";
38
+ import { createOutputStore } from "./outputs.js";
39
+ import { MemoryLedger } from "./ledger.js";
40
+ import { rpcGenomeStore } from "./genome_store.js";
41
+ import { createOutputMirror } from "./output_mirror.js";
42
+ import { PRIMITIVE_OUTPUT_TYPE } from "./core_types.js";
43
+ import { sha256Hex, canonJson, outputContentHash, CANONICAL_FORM_VERSION } from "./canonical_form.js";
44
+ import { createCheckpointStore, producersSha, CHECKPOINT_SCHEMA_VERSION, } from "./reuse.js";
45
+ /**
46
+ * The worker's durable state root: `checkpoints/` for the resume records, `outputs/` + `refs/`
47
+ * for the sealed rows those records name — the sibling layout `createCheckpointStore` documents.
48
+ *
49
+ * BOTH halves have to outlive the process. A worker is a short-lived consumer: it claims one
50
+ * row and exits, and the approved re-claim is a DIFFERENT process. A checkpoint whose outputs
51
+ * the next process cannot read refuses the resume it exists to permit, so the run would be
52
+ * paid for twice — which is the whole cost this store exists to avoid.
53
+ */
54
+ export function workerStateRoot() {
55
+ const override = process.env["COLTRANE_WORKER_CHECKPOINTS"];
56
+ if (override && override.length > 0)
57
+ return override;
58
+ return join(homedir(), ".coltrane", "worker-checkpoints");
59
+ }
60
+ async function workerRpc(ctx, fn, body) {
61
+ const res = await fetch(`${ctx.baseUrl}/rest/v1/rpc/${fn}`, {
62
+ method: "POST",
63
+ headers: {
64
+ apikey: ctx.anonKey,
65
+ // A ctk_ bearer is not a JWT — it authenticates inside the definer RPC via the body;
66
+ // the transport rides the anon key.
67
+ Authorization: `Bearer ${ctx.anonKey}`,
68
+ "Content-Type": "application/json",
69
+ },
70
+ body: JSON.stringify(body),
71
+ });
72
+ const text = await res.text();
73
+ if (!res.ok) {
74
+ let message = text || `store error ${res.status}`;
75
+ try {
76
+ const parsed = JSON.parse(text);
77
+ if (parsed.message)
78
+ message = parsed.message;
79
+ }
80
+ catch { /* keep the raw text */ }
81
+ throw new Error(`${fn}: ${message}`);
82
+ }
83
+ return text ? JSON.parse(text) : null;
84
+ }
85
+ /** Atomically claim the oldest runnable gig (queued, or running with an expired lease) the
86
+ * seated agent's chair contract authorizes. Null means the queue holds nothing for us. */
87
+ export async function claimNextGig(ctx) {
88
+ const out = await workerRpc(ctx, "coltrane_mcp_claim", {
89
+ p_bearer: ctx.agentToken,
90
+ p_worker: ctx.worker ?? null,
91
+ });
92
+ return out ?? null;
93
+ }
94
+ /**
95
+ * Release the lease on a PARKED gig: the row goes `awaiting_approval` and its lease clears, so
96
+ * an approval can re-queue it immediately instead of waiting the lease out. Deliberately NOT
97
+ * `gig_fail` — a run waiting on a person is not a failed run, and recording it as one both lies
98
+ * to the operator and takes the row out of the approve→requeue path.
99
+ *
100
+ * False means the store did not record the release — including a store that has not deployed
101
+ * the RPC yet. The run's own drained header already carries `awaiting_approval`, so an absent
102
+ * release is a missing convenience, not a lost fact, and must not fail the claim.
103
+ */
104
+ export async function parkGig(ctx, gig_id) {
105
+ try {
106
+ const out = await workerRpc(ctx, "coltrane_mcp_gig_park", {
107
+ p_bearer: ctx.agentToken,
108
+ p_gig: gig_id,
109
+ });
110
+ return out === true;
111
+ }
112
+ catch (e) {
113
+ const message = e instanceof Error ? e.message : String(e);
114
+ // PostgREST answers an undeployed function with PGRST202 / "Could not find the function".
115
+ if (/PGRST202|could not find the function|does not exist/i.test(message))
116
+ return false;
117
+ throw e;
118
+ }
119
+ }
120
+ /** Record a failed run on the claimed row. True iff the store recorded it (row was running). */
121
+ export async function failGig(ctx, gig_id, error) {
122
+ const out = await workerRpc(ctx, "coltrane_mcp_gig_fail", {
123
+ p_bearer: ctx.agentToken,
124
+ p_gig: gig_id,
125
+ p_error: error,
126
+ });
127
+ return out === true;
128
+ }
129
+ /** The sink's sealed rows for one gig. `[]` covers "no drain to read" as well as "nothing drained". */
130
+ export async function fetchDrainedOutputs(ctx, gig_id) {
131
+ let out;
132
+ try {
133
+ out = await workerRpc(ctx, "coltrane_mcp_gig_outputs", { p_bearer: ctx.agentToken, p_gig: gig_id });
134
+ }
135
+ catch (e) {
136
+ // Every failure here is the same kind of event: resume state could not be read. The queue
137
+ // row is still runnable work, so this never fails the claim — it costs a cold run, which is
138
+ // exactly what the worker did before this path existed.
139
+ return { rows: [], error: e instanceof Error ? e.message : String(e) };
140
+ }
141
+ if (!Array.isArray(out))
142
+ return { rows: [] };
143
+ return { rows: out.filter((r) => !!r && typeof r === "object") };
144
+ }
145
+ /**
146
+ * The `genome_hash` the sink recorded on this gig's drained HEADER.
147
+ *
148
+ * This is the only identity a drained gig carries, and reading it is what keeps the
149
+ * reconstruction from being a splice. `genomeHash` folds the standard's whole phase graph and
150
+ * every bound agent's type surface — chair `depends_on`, `input_contract`, an added or removed
151
+ * phase — none of which reaches an individual row's `content_sha`. Without this check a
152
+ * pipeline could be re-wired between the park and the approval and the restored outputs would
153
+ * be consumed by chairs that never produced them, with nothing in the manifest recording it.
154
+ *
155
+ * STATED GAP: the header carries no `producers_sha`, so a rewritten agent `method` (or a
156
+ * rewritten skill under a stable version) is invisible to this path — the very hole
157
+ * `RunIdentity.producers_sha` exists to close for a LOCAL checkpoint. A drain-reconstructed
158
+ * resume is therefore a weaker gate than a local one by exactly that much, and the strongest
159
+ * available check is the one applied: the sink's structural hash plus a per-row re-seal.
160
+ */
161
+ export async function fetchDrainedGenomeHash(ctx, gig_id) {
162
+ let out;
163
+ try {
164
+ out = await workerRpc(ctx, "coltrane_mcp_gig_status", { p_bearer: ctx.agentToken, p_gig: gig_id });
165
+ }
166
+ catch (e) {
167
+ return { error: e instanceof Error ? e.message : String(e) };
168
+ }
169
+ // The RPC may answer with the header row or a single-row array; both are the same fact.
170
+ const row = Array.isArray(out) ? out[0] : out;
171
+ if (!row || typeof row !== "object")
172
+ return {};
173
+ const gh = row["genome_hash"];
174
+ // 64 hex or nothing: the header stores `null` for a run with no hash, and the ledger writes
175
+ // "n/a" in places. Neither is a genome identity, and treating one as if it were is the bug.
176
+ return typeof gh === "string" && /^[0-9a-f]{64}$/.test(gh) ? { genome_hash: gh } : {};
177
+ }
178
+ /**
179
+ * Re-derive every chair's seal specs from the loaded standard.
180
+ *
181
+ * This mirrors the runtime's own derivation chair-kind for chair-kind (`outputSpecsFor`, the
182
+ * skill-backed branch of `prepareChair`, and the human-seat branch of the phase loop), because
183
+ * `content_sha` folds exactly what it produces. Divergence here would not be a cosmetic
184
+ * mismatch — it would compute a different sha for an unchanged row and refuse every resume.
185
+ */
186
+ function chairSeats(standard, outputs) {
187
+ const seats = [];
188
+ for (const phase of standard.phases) {
189
+ for (const chair of phase.chairs) {
190
+ const specs = new Map();
191
+ if (chair.human === true && (chair.agent_slug ?? "") === "") {
192
+ const dt = chair.output_contract[0] ?? "Judgment";
193
+ const core = outputs.coreTypeOf(dt) ?? dt;
194
+ specs.set(dt, { core_type: core, primitive: CORE_TO_PRIMITIVE[core] ?? "JUDGE", domain: standard.domain });
195
+ seats.push({ chair, phase: phase.name, producer: { kind: "human" }, specs });
196
+ continue;
197
+ }
198
+ if (chair.skill_slug && (chair.agent_slug ?? "") === "") {
199
+ const dt = chair.output_contract[0] ?? "Signal";
200
+ const core = outputs.coreTypeOf(dt) ?? "Signal";
201
+ specs.set(dt, { core_type: core, primitive: CORE_TO_PRIMITIVE[core] ?? "SENSE", domain: standard.domain });
202
+ seats.push({ chair, phase: phase.name, producer: { kind: "skill", slug: chair.skill_slug }, specs });
203
+ continue;
204
+ }
205
+ const agent = standard.agents.find((a) => a.slug === chair.agent_slug);
206
+ const fallback = agent?.primitives[0];
207
+ // A chair whose agent the genome no longer holds could not have sealed anything under
208
+ // THIS genome. Skipping it means its rows find no seat and the reconstruction refuses,
209
+ // which is the honest outcome.
210
+ if (!agent || !fallback)
211
+ continue;
212
+ const wanted = chair.output_contract.length
213
+ ? agent.output_types.filter((t) => chair.output_contract.includes(t))
214
+ : agent.output_types;
215
+ const domain = agent.domain ?? standard.domain;
216
+ for (const dt of wanted) {
217
+ const core = outputs.coreTypeOf(dt) ?? PRIMITIVE_OUTPUT_TYPE[fallback];
218
+ specs.set(dt, { core_type: core, primitive: CORE_TO_PRIMITIVE[core] ?? fallback, domain });
219
+ }
220
+ seats.push({ chair, phase: phase.name, producer: { kind: "agent", slug: agent.slug }, specs });
221
+ }
222
+ }
223
+ return seats;
224
+ }
225
+ /**
226
+ * The run identity a COLD run of this claim would compute, field for field.
227
+ *
228
+ * Kept adjacent to the `runGig` call in `workOnce` on purpose: `model_version` and `depth` are
229
+ * that call's defaults (it passes neither), and `skills: []` is what `resolvedSkillHashes()`
230
+ * folds for a worker that registers no `skill_dirs` — a store-loaded skill has no code half by
231
+ * construction. Change what `workOnce` passes and this has to move with it, or every
232
+ * reconstruction is refused for identity drift against its own run.
233
+ */
234
+ function coldRunIdentity(standard, gigInput) {
235
+ return {
236
+ standard_slug: standard.slug,
237
+ genome_hash: genomeHash(standard),
238
+ producers_sha: producersSha({ agents: standard.agents, skills: [] }),
239
+ gig_input_sha: sha256Hex(canonJson(gigInput)),
240
+ model_version: "unknown",
241
+ depth: "",
242
+ canonical_form_version: CANONICAL_FORM_VERSION,
243
+ };
244
+ }
245
+ /** Accumulate one restored record onto its chair's checkpoint role, whether written or adopted. */
246
+ function noteRole(byRole, p, output_id, content_sha) {
247
+ const role = p.seat.chair.role;
248
+ const cur = byRole.get(role) ?? {
249
+ role, phase: p.seat.phase,
250
+ output_ids: [], content_shas: [], domain_types: [], type_fingerprints: [],
251
+ sealed_at: p.row.created_at,
252
+ };
253
+ cur.output_ids.push(output_id);
254
+ cur.content_shas.push(content_sha);
255
+ cur.domain_types.push(p.row.domain_type);
256
+ cur.type_fingerprints.push(p.fingerprint);
257
+ if (p.row.created_at > cur.sealed_at)
258
+ cur.sealed_at = p.row.created_at;
259
+ byRole.set(role, cur);
260
+ }
261
+ /**
262
+ * Turn the sink's sealed rows into a resume checkpoint — or refuse, with a reason.
263
+ *
264
+ * ALL-OR-NOTHING, in two passes. Pass one derives and verifies every row while nothing is
265
+ * durable; pass two writes. A gig whose second row fails must not leave its first one in the
266
+ * local store seeding a half-resume, which is the same invariant #243 gave a single chair, one
267
+ * scope up.
268
+ *
269
+ * ROLE MAPPING. The sink does not record `from_role`, so each row is mapped to a chair by
270
+ * `phase` + the chair's SEAT: `agent_slug` for an agent chair, the skill slug for a skill-backed
271
+ * one, and name-agnostically for a human chair (its record seals under the approving principal,
272
+ * whom the genome cannot know). The row's `domain_type` narrows further — a chair that does not
273
+ * seal that type is not a candidate. Zero candidates or MORE THAN ONE both refuse: a guess about
274
+ * which chair produced a sealed output is a guess about the provenance chain.
275
+ *
276
+ * SHA VERIFICATION. Every row is re-sealed under the derived core/primitive/domain and the sha
277
+ * compared to the one the sink recorded. A mismatch refuses the WHOLE reconstruction — a sink
278
+ * row that no longer hashes to its claimed sha must never silently seed a resume, and one such
279
+ * row is evidence about the sink, not about that row alone.
280
+ */
281
+ export function resumeStateFromDrain(args) {
282
+ const { gig_id, standard, identity, rows, outputs } = args;
283
+ if (rows.length === 0)
284
+ return { ok: false, reason: "the sink holds no sealed outputs for this gig" };
285
+ const seats = chairSeats(standard, outputs);
286
+ // created_at order, so a row's in-gig predecessors are already re-written when it is written.
287
+ const ordered = [...rows].sort((a, b) => (a.created_at < b.created_at ? -1 : a.created_at > b.created_at ? 1 : 0));
288
+ const planned = [];
289
+ for (const row of ordered) {
290
+ const phase = typeof row.phase === "string" && row.phase !== "" ? row.phase : undefined;
291
+ if (phase === undefined) {
292
+ return { ok: false, reason: `sink row "${row.id}" records no phase, so it cannot be mapped to a chair` };
293
+ }
294
+ if (typeof row.content_sha !== "string" || !row.data || typeof row.data !== "object") {
295
+ return { ok: false, reason: `sink row "${row.id}" is not a sealed output shape (content_sha + data)` };
296
+ }
297
+ const candidates = seats.filter((s) => s.phase === phase && s.specs.has(row.domain_type) &&
298
+ (s.producer.kind === "human" || s.producer.slug === row.agent_slug));
299
+ if (candidates.length === 0) {
300
+ return {
301
+ ok: false,
302
+ reason: `no chair in phase "${phase}" seals "${row.domain_type}" for producer "${row.agent_slug}" — the standard has moved since that output sealed`,
303
+ };
304
+ }
305
+ if (candidates.length > 1) {
306
+ return {
307
+ ok: false,
308
+ reason: `chairs [${candidates.map((c) => c.chair.role).join(", ")}] in phase "${phase}" could each have sealed "${row.domain_type}" — the sink records no from_role, so the mapping is ambiguous`,
309
+ };
310
+ }
311
+ const seat = candidates[0];
312
+ const spec = seat.specs.get(row.domain_type);
313
+ // The registry moves independently of the standard, so genome_hash does not see a type that
314
+ // changed shape. Same fingerprint tool the local resume gate and the reuse cache use.
315
+ const fingerprint = outputs.typeFingerprint(row.domain_type);
316
+ if (fingerprint === "") {
317
+ return { ok: false, reason: `the registry can no longer describe type "${row.domain_type}", so the sink's row cannot be checked` };
318
+ }
319
+ const gate = outputs.validateWrite({ core_type: spec.core_type, domain_type: row.domain_type, data: row.data });
320
+ if (!gate.valid) {
321
+ return { ok: false, reason: `sink row "${row.id}" would not pass the seal boundary today — ${gate.reason}` };
322
+ }
323
+ const sha = outputContentHash({
324
+ core_type: spec.core_type,
325
+ domain_type: row.domain_type,
326
+ domain_type_version: 1,
327
+ domain: spec.domain,
328
+ primitive: spec.primitive,
329
+ phase,
330
+ agent_slug: row.agent_slug,
331
+ data: row.data,
332
+ });
333
+ if (sha !== row.content_sha) {
334
+ return {
335
+ ok: false,
336
+ reason: `sink row "${row.id}" ("${row.domain_type}", phase "${phase}") re-seals to a different content_sha than the sink recorded — the row no longer hashes to its claimed content_sha`,
337
+ };
338
+ }
339
+ planned.push({ row, seat, spec, fingerprint });
340
+ }
341
+ // Pass two — durable. The resume gate resolves a checkpoint's `output_ids` against the LOCAL
342
+ // output store, so the sink's rows have to become local records before they can be restored.
343
+ //
344
+ // IDEMPOTENT. The local store may already hold these rows: the checkpoint file can go missing
345
+ // while `outputs/<gig_id>.jsonl` survives (a swallowed checkpoint write, a cleared checkpoints
346
+ // dir), and appending second copies would leave `output_query` and `output_trace` reporting a
347
+ // gig that sealed each record twice. An existing IN-GIG record with the same content_sha IS
348
+ // that record — content_sha folds core, type, version, domain, primitive, phase, agent_slug and
349
+ // data, so an identical sha is an identical derivation — and it is adopted by id.
350
+ const alreadyHeld = new Map();
351
+ for (const rec of outputs.all()) {
352
+ if (rec.gig_id === gig_id && !alreadyHeld.has(rec.content_sha))
353
+ alreadyHeld.set(rec.content_sha, rec.id);
354
+ }
355
+ const byRole = new Map();
356
+ const shaToId = new Map();
357
+ for (const p of planned) {
358
+ const adopted = alreadyHeld.get(p.row.content_sha);
359
+ if (adopted !== undefined) {
360
+ shaToId.set(p.row.content_sha, adopted);
361
+ noteRole(byRole, p, adopted, p.row.content_sha);
362
+ continue;
363
+ }
364
+ const inputShas = (p.row.input_shas ?? []).map((s) => (typeof s === "string" ? s : ""));
365
+ const mapped = inputShas.map((s) => shaToId.get(s));
366
+ // Object identity is machine-local: the sink's own output ids name nothing here, and the ids
367
+ // of the rows we are writing are fresh. The HASH chain does travel — each `input_sha` names
368
+ // the content a row consumed — so remap ids only when every entry resolves, and otherwise
369
+ // keep the engine-stamped hashes and leave `input_refs` empty rather than emit a
370
+ // half-aligned pair.
371
+ const remapped = mapped.every((id) => typeof id === "string") ? mapped : undefined;
372
+ let rec;
373
+ try {
374
+ rec = outputs.write({
375
+ core_type: p.spec.core_type,
376
+ domain_type: p.row.domain_type,
377
+ domain_type_version: 1,
378
+ domain: p.spec.domain,
379
+ gig_id,
380
+ agent_slug: p.row.agent_slug,
381
+ from_role: p.seat.chair.role,
382
+ phase: p.seat.phase,
383
+ primitive: p.spec.primitive,
384
+ data: p.row.data,
385
+ input_refs: remapped ?? [],
386
+ input_shas: inputShas,
387
+ });
388
+ }
389
+ catch (e) {
390
+ // Unreachable: `validateWrite` above is the same gate `write` runs, from one implementation.
391
+ return { ok: false, reason: `sink row "${p.row.id}" could not be written locally — ${e instanceof Error ? e.message : String(e)}` };
392
+ }
393
+ if (rec.content_sha !== p.row.content_sha) {
394
+ return { ok: false, reason: `sink row "${p.row.id}" sealed locally to a different content_sha than the sink recorded` };
395
+ }
396
+ shaToId.set(rec.content_sha, rec.id);
397
+ noteRole(byRole, p, rec.id, rec.content_sha);
398
+ }
399
+ return {
400
+ ok: true,
401
+ checkpoint: {
402
+ schema_version: CHECKPOINT_SCHEMA_VERSION,
403
+ gig_id,
404
+ identity,
405
+ // The sink's own timestamps. `prior_usage` is deliberately absent: the outputs RPC carries
406
+ // no cost fields, so what the earlier attempt spent is genuinely unknown here, and an
407
+ // invented zero would be the "not captured reported as $0.00" defect #235/#236 removed.
408
+ started_at: ordered[0].created_at,
409
+ updated_at: ordered[ordered.length - 1].created_at,
410
+ roles: [...byRole.values()],
411
+ },
412
+ };
413
+ }
414
+ /** Read the sink and rebuild this claim's resume state, or say why it cannot be rebuilt. */
415
+ async function rebuildFromDrain(ctx, claim, standard, outputs) {
416
+ const drained = await fetchDrainedOutputs(ctx, claim.gig_id);
417
+ if (drained.error !== undefined)
418
+ return { ok: false, reason: `the sink's outputs could not be read — ${drained.error}` };
419
+ if (drained.rows.length === 0)
420
+ return { ok: false, reason: "the sink holds no sealed outputs for this gig" };
421
+ const header = await fetchDrainedGenomeHash(ctx, claim.gig_id);
422
+ const current = genomeHash(standard);
423
+ if (header.genome_hash === undefined) {
424
+ // A miss is free; a wrong hit is not. An identity that cannot be checked resolves to doing
425
+ // the work — the same asymmetry every other substitution gate in this engine resolves on.
426
+ return {
427
+ ok: false,
428
+ reason: `the sink reports no genome_hash for this gig${header.error !== undefined ? ` (${header.error})` : ""}, so the pipeline those outputs sealed under cannot be checked`,
429
+ };
430
+ }
431
+ if (header.genome_hash !== current) {
432
+ return {
433
+ ok: false,
434
+ reason: `the genome moved since those outputs sealed (sink genome_hash="${header.genome_hash}" current="${current}")`,
435
+ };
436
+ }
437
+ return resumeStateFromDrain({
438
+ gig_id: claim.gig_id,
439
+ standard,
440
+ identity: coldRunIdentity(standard, claim.input),
441
+ rows: drained.rows,
442
+ outputs,
443
+ });
444
+ }
445
+ /**
446
+ * Map the claim's per-role approval entries onto runGig's two arguments.
447
+ *
448
+ * The store keys each verdict by ROLE (a standard may hold more than one human chair) while
449
+ * runGig takes a single `approved_by` for the run. So the name is read from the entry for the
450
+ * chair this claim will actually reach — the first human chair the checkpoint does not already
451
+ * hold — and falls back to the first entry when that is not discernible. Attribution on a seal
452
+ * is not decoration: the approval output carries it as its `agent_slug`.
453
+ */
454
+ export function approvalWiring(approvals, standard, completedRoles = []) {
455
+ const entries = Object.entries(approvals ?? {}).filter(([, e]) => e && typeof e.verdict === "object" && e.verdict !== null);
456
+ if (entries.length === 0)
457
+ return {};
458
+ const held = new Set(completedRoles);
459
+ const awaitingRole = standard.phases
460
+ .flatMap((p) => p.chairs)
461
+ .find((c) => c.human === true && !held.has(c.role))?.role;
462
+ const named = (awaitingRole === undefined ? undefined : entries.find(([role]) => role === awaitingRole)) ?? entries[0];
463
+ const approved_by = named[1].approved_by;
464
+ return {
465
+ approvals: Object.fromEntries(entries.map(([role, e]) => [role, e.verdict])),
466
+ ...(typeof approved_by === "string" && approved_by !== "" ? { approved_by } : {}),
467
+ };
468
+ }
469
+ /** One unit of work: claim → load the org genome (as the agent) → run under the claimed
470
+ * gig's id → results drain via the org drain key (engine drain layer, env-configured), or
471
+ * the failure is recorded. Never throws for a run failure — a thrown claim/store error
472
+ * means the worker itself could not speak to the store.
473
+ *
474
+ * A run that reaches an unapproved human chair PARKS: the row is released (parkGig) and the
475
+ * outcome is `awaiting_approval` — its own status, because it is neither finished nor broken. */
476
+ export async function workOnce(ctx, deps) {
477
+ const log = deps.log ?? (() => { });
478
+ const claim = await claimNextGig(ctx);
479
+ if (!claim)
480
+ return { claimed: false };
481
+ log(`claimed ${claim.gig_id} (${claim.standard_slug}, ${claim.mode}) as ${claim.acting_for}`);
482
+ try {
483
+ const genome = await rpcGenomeStore(ctx).load();
484
+ const standard = genome.standards.get(claim.standard_slug);
485
+ if (!standard) {
486
+ throw new Error(`claimed standard "${claim.standard_slug}" is not in the org genome this token can read` +
487
+ (genome.load_errors.length ? ` (${genome.load_errors.length} load error(s) — system_health has them)` : ""));
488
+ }
489
+ const registry = loadRegistry(genome);
490
+ const stateRoot = workerStateRoot();
491
+ // The mirror tier is where OUTPUT drain lives (the header drains from the runtime
492
+ // directly) — without it a worker's sealed outputs never reach the sink. Found live:
493
+ // the first worker run drained its failure header and none of its sealed phases.
494
+ //
495
+ // `persistDir` is the RESUME half of the same concern: the checkpoint names sealed rows by
496
+ // id, and the process that resumes is not the process that sealed them. Without a durable
497
+ // row store every re-claim is refused ("the output store no longer holds") and pays again.
498
+ const outputs = createOutputStore(registry, {
499
+ persistDir: stateRoot,
500
+ mirror: createOutputMirror(join(tmpdir(), "coltrane-worker-mirror")),
501
+ });
502
+ const ledger = new MemoryLedger();
503
+ const invoke = deps.makeInvoke(registry, genome);
504
+ const checkpoints = createCheckpointStore(stateRoot);
505
+ // ORDER OF PREFERENCE: the local checkpoint (fast path — same box, nothing to fetch), then
506
+ // the DRAIN reconstruction (a different box, or a state root that was cleared), then cold.
507
+ // Exactly one line is logged for whichever path is taken, including the reason for cold.
508
+ let checkpoint;
509
+ let resumeSource = "local";
510
+ let coldReason = "no local checkpoint and no drain to rebuild one from";
511
+ try {
512
+ checkpoint = checkpoints.read(claim.gig_id);
513
+ }
514
+ catch (e) {
515
+ // A damaged checkpoint is not a reason to fail a runnable row — it is a reason to pay for
516
+ // a cold run, and to say so.
517
+ log(`checkpoint for ${claim.gig_id} unreadable, running cold: ${e instanceof Error ? e.message : String(e)}`);
518
+ }
519
+ if (!checkpoint) {
520
+ const rebuilt = await rebuildFromDrain(ctx, claim, standard, outputs);
521
+ if (rebuilt.ok) {
522
+ // Written to the LOCAL store because that is where the runtime's resume gate reads a
523
+ // checkpoint from. The reconstruction seeds that gate; the gate remains the authority —
524
+ // it re-resolves every output id, re-checks every content_sha and type fingerprint, and
525
+ // compares the identity itself, so a bad reconstruction is refused by the same code a
526
+ // bad local checkpoint is.
527
+ checkpoints.write(rebuilt.checkpoint);
528
+ checkpoint = rebuilt.checkpoint;
529
+ resumeSource = "drain";
530
+ }
531
+ else {
532
+ coldReason = rebuilt.reason;
533
+ }
534
+ }
535
+ const human = approvalWiring(claim.approvals, standard, checkpoint?.roles.map((r) => r.role) ?? []);
536
+ const run = (resume) => runGig(standard, claim.input, {
537
+ outputs,
538
+ ledger,
539
+ invoke,
540
+ gig_id: claim.gig_id, // ← the run IS the queue row; the drained header completes it
541
+ skills: genome.skills,
542
+ // Store-loaded skills carry no local package dir (no code half) by construction, so
543
+ // no skill_dirs: a skill-BACKED chair in a store standard fails precisely at prep
544
+ // with the runtime's own "no skill_dir is registered" error, not a confabulated run.
545
+ checkpoints,
546
+ ...(resume ? { resume_from: claim.gig_id } : {}),
547
+ ...human,
548
+ });
549
+ let res;
550
+ if (checkpoint) {
551
+ // An approved re-claim is the common case for this branch: the chairs before the human
552
+ // seat already sealed and were already paid for, so replaying them is money spent twice.
553
+ log(`resuming ${claim.gig_id} from its ${resumeSource === "drain" ? "DRAIN-reconstructed" : "local"} ` +
554
+ `checkpoint (${checkpoint.roles.length} chair(s) recorded)`);
555
+ try {
556
+ res = await run(true);
557
+ }
558
+ catch (e) {
559
+ if (!(e instanceof ResumeRefused))
560
+ throw e;
561
+ // A refusal is the engine declining to splice two runs together (the genome, the
562
+ // payload or a type moved). The queue row is still work that must happen, so it is run
563
+ // COLD and the second payment is stated rather than hidden.
564
+ log(`resume refused for ${claim.gig_id} — running it COLD: ${e.message}`);
565
+ res = await run(false);
566
+ }
567
+ }
568
+ else {
569
+ log(`running ${claim.gig_id} COLD — ${coldReason}`);
570
+ res = await run(false);
571
+ }
572
+ if (res.status === "awaiting_approval") {
573
+ const awaiting = res.awaiting;
574
+ log(`gig ${claim.gig_id} awaiting approval` +
575
+ (awaiting ? ` at human chair "${awaiting.role}" (phase "${awaiting.phase}")` : "") +
576
+ ` — ${res.outputs.length} sealed output(s)`);
577
+ try {
578
+ const released = await parkGig(ctx, claim.gig_id);
579
+ if (!released) {
580
+ log(`park not recorded for ${claim.gig_id} (coltrane_mcp_gig_park absent or the row moved) — the drained header carries awaiting_approval`);
581
+ }
582
+ }
583
+ catch (pe) {
584
+ // Same posture as an unrecordable failure: say it, and let the lease expire.
585
+ log(`could not park ${claim.gig_id} (lease will expire): ${pe instanceof Error ? pe.message : String(pe)}`);
586
+ }
587
+ return {
588
+ claimed: true, gig_id: claim.gig_id, status: "awaiting_approval",
589
+ outputs_count: res.outputs.length,
590
+ ...(awaiting ? { awaiting } : {}),
591
+ };
592
+ }
593
+ log(`gig ${claim.gig_id} ${res.status} — ${res.outputs.length} sealed output(s)`);
594
+ return { claimed: true, gig_id: claim.gig_id, status: "complete", outputs_count: res.outputs.length };
595
+ }
596
+ catch (e) {
597
+ const message = e instanceof Error ? e.message : String(e);
598
+ log(`gig ${claim.gig_id} failed: ${message}`);
599
+ try {
600
+ await failGig(ctx, claim.gig_id, message);
601
+ }
602
+ catch (fe) {
603
+ // The failure could not even be recorded — surface both; the lease will expire.
604
+ log(`could not record failure (lease will expire): ${fe instanceof Error ? fe.message : String(fe)}`);
605
+ }
606
+ return { claimed: true, gig_id: claim.gig_id, status: "failed", error: message };
607
+ }
608
+ }
609
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/worker.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,yDAAyD;AACzD,EAAE;AACF,iFAAiF;AACjF,4FAA4F;AAC5F,4FAA4F;AAC5F,yFAAyF;AACzF,qEAAqE;AACrE,2FAA2F;AAC3F,wFAAwF;AACxF,sFAAsF;AACtF,EAAE;AACF,yFAAyF;AACzF,yFAAyF;AACzF,sFAAsF;AACtF,+EAA+E;AAC/E,EAAE;AACF,wFAAwF;AACxF,+FAA+F;AAC/F,8FAA8F;AAC9F,gGAAgG;AAChG,mDAAmD;AACnD,EAAE;AACF,8FAA8F;AAC9F,+FAA+F;AAC/F,4FAA4F;AAC5F,qE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