@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,182 @@
1
+ import { type AgentInvoker } from "./runtime.js";
2
+ import { type Registry } from "./registry.js";
3
+ import { type OutputStore } from "./outputs.js";
4
+ import { type GigCheckpoint, type RunIdentity } from "./reuse.js";
5
+ import type { Standard } from "./composition.js";
6
+ import type { LoadedGenome } from "./loader.js";
7
+ /** Where the org store is, and who is working. */
8
+ export interface WorkerContext {
9
+ baseUrl: string;
10
+ anonKey: string;
11
+ /** The seated agent's ctk_ capability token — claim/genome/fail all speak through it. */
12
+ agentToken: string;
13
+ /** Lease label recorded on the claimed row (defaults to worker:<acting_for> store-side). */
14
+ worker?: string;
15
+ }
16
+ /** The claim RPC's payload: everything the worker needs to run the row it now leases. */
17
+ export interface ClaimedGig {
18
+ gig_id: string;
19
+ standard_slug: string;
20
+ standard_version: number | null;
21
+ mode: string;
22
+ input: Record<string, unknown>;
23
+ acting_for: string;
24
+ /**
25
+ * The human seat's verdicts, keyed by chair role — present on a RE-claim of a gig that
26
+ * parked. The approve RPC writes them onto the row's manifest and re-queues it; the claim
27
+ * hands them back here, and each entry carries the verdict AND who gave it, because the
28
+ * approval seals under the approving principal's name rather than the worker's.
29
+ */
30
+ approvals?: Record<string, {
31
+ verdict: Record<string, unknown>;
32
+ approved_by?: string;
33
+ }> | null;
34
+ }
35
+ /**
36
+ * The worker's durable state root: `checkpoints/` for the resume records, `outputs/` + `refs/`
37
+ * for the sealed rows those records name — the sibling layout `createCheckpointStore` documents.
38
+ *
39
+ * BOTH halves have to outlive the process. A worker is a short-lived consumer: it claims one
40
+ * row and exits, and the approved re-claim is a DIFFERENT process. A checkpoint whose outputs
41
+ * the next process cannot read refuses the resume it exists to permit, so the run would be
42
+ * paid for twice — which is the whole cost this store exists to avoid.
43
+ */
44
+ export declare function workerStateRoot(): string;
45
+ export type WorkOnceResult = {
46
+ claimed: false;
47
+ } | {
48
+ claimed: true;
49
+ gig_id: string;
50
+ /** `awaiting_approval` is its own outcome: a run that reached a human chair is neither
51
+ * finished nor broken, and calling it either would be a lie the operator acts on. */
52
+ status: "complete" | "failed" | "awaiting_approval";
53
+ outputs_count?: number;
54
+ error?: string;
55
+ /** Present iff awaiting_approval: the human chair the run parked at. */
56
+ awaiting?: {
57
+ phase: string;
58
+ role: string;
59
+ };
60
+ };
61
+ export interface WorkOnceDeps {
62
+ /** Build the chair invoker against the STORE registry (types the org's outputs seal to). */
63
+ makeInvoke(registry: Registry, genome: LoadedGenome): AgentInvoker;
64
+ /** Progress line sink (CLI wires stderr); silent by default. */
65
+ log?(line: string): void;
66
+ }
67
+ /** Atomically claim the oldest runnable gig (queued, or running with an expired lease) the
68
+ * seated agent's chair contract authorizes. Null means the queue holds nothing for us. */
69
+ export declare function claimNextGig(ctx: WorkerContext): Promise<ClaimedGig | null>;
70
+ /**
71
+ * Release the lease on a PARKED gig: the row goes `awaiting_approval` and its lease clears, so
72
+ * an approval can re-queue it immediately instead of waiting the lease out. Deliberately NOT
73
+ * `gig_fail` — a run waiting on a person is not a failed run, and recording it as one both lies
74
+ * to the operator and takes the row out of the approve→requeue path.
75
+ *
76
+ * False means the store did not record the release — including a store that has not deployed
77
+ * the RPC yet. The run's own drained header already carries `awaiting_approval`, so an absent
78
+ * release is a missing convenience, not a lost fact, and must not fail the claim.
79
+ */
80
+ export declare function parkGig(ctx: WorkerContext, gig_id: string): Promise<boolean>;
81
+ /** Record a failed run on the claimed row. True iff the store recorded it (row was running). */
82
+ export declare function failGig(ctx: WorkerContext, gig_id: string, error: string): Promise<boolean>;
83
+ /**
84
+ * One sealed row as `coltrane_mcp_gig_outputs` hands it back — the sink's view of an output.
85
+ *
86
+ * NARROWER than an `OutputRecord`, and the gap is the whole difficulty: the sink returns no
87
+ * `core_type`, no `domain`, no `primitive`, no `domain_type_version` and no `from_role`. Every
88
+ * one of the first four is folded into `content_sha`, so they are RE-DERIVED from the loaded
89
+ * genome the way the seal boundary derives them, and the re-derivation is then proved against
90
+ * the sha the sink recorded. A row that no longer hashes to its claimed sha is refused.
91
+ */
92
+ export interface DrainedOutput {
93
+ id: string;
94
+ domain_type: string;
95
+ agent_slug: string;
96
+ phase?: string | null;
97
+ content_sha: string;
98
+ input_shas?: readonly (string | null)[] | null;
99
+ created_at: string;
100
+ data: Record<string, unknown>;
101
+ }
102
+ /** A reconstruction either produced a checkpoint or refused, and a refusal always says why. */
103
+ export type DrainResumeState = {
104
+ ok: true;
105
+ checkpoint: GigCheckpoint;
106
+ } | {
107
+ ok: false;
108
+ reason: string;
109
+ };
110
+ /** The sink's sealed rows for one gig. `[]` covers "no drain to read" as well as "nothing drained". */
111
+ export declare function fetchDrainedOutputs(ctx: WorkerContext, gig_id: string): Promise<{
112
+ rows: DrainedOutput[];
113
+ error?: string;
114
+ }>;
115
+ /**
116
+ * The `genome_hash` the sink recorded on this gig's drained HEADER.
117
+ *
118
+ * This is the only identity a drained gig carries, and reading it is what keeps the
119
+ * reconstruction from being a splice. `genomeHash` folds the standard's whole phase graph and
120
+ * every bound agent's type surface — chair `depends_on`, `input_contract`, an added or removed
121
+ * phase — none of which reaches an individual row's `content_sha`. Without this check a
122
+ * pipeline could be re-wired between the park and the approval and the restored outputs would
123
+ * be consumed by chairs that never produced them, with nothing in the manifest recording it.
124
+ *
125
+ * STATED GAP: the header carries no `producers_sha`, so a rewritten agent `method` (or a
126
+ * rewritten skill under a stable version) is invisible to this path — the very hole
127
+ * `RunIdentity.producers_sha` exists to close for a LOCAL checkpoint. A drain-reconstructed
128
+ * resume is therefore a weaker gate than a local one by exactly that much, and the strongest
129
+ * available check is the one applied: the sink's structural hash plus a per-row re-seal.
130
+ */
131
+ export declare function fetchDrainedGenomeHash(ctx: WorkerContext, gig_id: string): Promise<{
132
+ genome_hash?: string;
133
+ error?: string;
134
+ }>;
135
+ /**
136
+ * Turn the sink's sealed rows into a resume checkpoint — or refuse, with a reason.
137
+ *
138
+ * ALL-OR-NOTHING, in two passes. Pass one derives and verifies every row while nothing is
139
+ * durable; pass two writes. A gig whose second row fails must not leave its first one in the
140
+ * local store seeding a half-resume, which is the same invariant #243 gave a single chair, one
141
+ * scope up.
142
+ *
143
+ * ROLE MAPPING. The sink does not record `from_role`, so each row is mapped to a chair by
144
+ * `phase` + the chair's SEAT: `agent_slug` for an agent chair, the skill slug for a skill-backed
145
+ * one, and name-agnostically for a human chair (its record seals under the approving principal,
146
+ * whom the genome cannot know). The row's `domain_type` narrows further — a chair that does not
147
+ * seal that type is not a candidate. Zero candidates or MORE THAN ONE both refuse: a guess about
148
+ * which chair produced a sealed output is a guess about the provenance chain.
149
+ *
150
+ * SHA VERIFICATION. Every row is re-sealed under the derived core/primitive/domain and the sha
151
+ * compared to the one the sink recorded. A mismatch refuses the WHOLE reconstruction — a sink
152
+ * row that no longer hashes to its claimed sha must never silently seed a resume, and one such
153
+ * row is evidence about the sink, not about that row alone.
154
+ */
155
+ export declare function resumeStateFromDrain(args: {
156
+ gig_id: string;
157
+ standard: Standard;
158
+ identity: RunIdentity;
159
+ rows: readonly DrainedOutput[];
160
+ outputs: OutputStore;
161
+ }): DrainResumeState;
162
+ /**
163
+ * Map the claim's per-role approval entries onto runGig's two arguments.
164
+ *
165
+ * The store keys each verdict by ROLE (a standard may hold more than one human chair) while
166
+ * runGig takes a single `approved_by` for the run. So the name is read from the entry for the
167
+ * chair this claim will actually reach — the first human chair the checkpoint does not already
168
+ * hold — and falls back to the first entry when that is not discernible. Attribution on a seal
169
+ * is not decoration: the approval output carries it as its `agent_slug`.
170
+ */
171
+ export declare function approvalWiring(approvals: ClaimedGig["approvals"], standard: Standard, completedRoles?: readonly string[]): {
172
+ approvals?: Record<string, Record<string, unknown>>;
173
+ approved_by?: string;
174
+ };
175
+ /** One unit of work: claim → load the org genome (as the agent) → run under the claimed
176
+ * gig's id → results drain via the org drain key (engine drain layer, env-configured), or
177
+ * the failure is recorded. Never throws for a run failure — a thrown claim/store error
178
+ * means the worker itself could not speak to the store.
179
+ *
180
+ * A run that reaches an unapproved human chair PARKS: the row is released (parkGig) and the
181
+ * outcome is `awaiting_approval` — its own status, because it is neither finished nor broken. */
182
+ export declare function workOnce(ctx: WorkerContext, deps: WorkOnceDeps): Promise<WorkOnceResult>;