@tangle-network/agent-runtime 0.60.0 → 0.62.0

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 (58) hide show
  1. package/dist/agent.d.ts +3 -2
  2. package/dist/agent.js +2 -3
  3. package/dist/agent.js.map +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/chunk-DVQGYDN5.js +59 -0
  6. package/dist/chunk-DVQGYDN5.js.map +1 -0
  7. package/dist/{chunk-ZWGEA722.js → chunk-E4X4FNQZ.js} +2 -2
  8. package/dist/{chunk-45D64J7B.js → chunk-MT4XM3G6.js} +191 -100
  9. package/dist/chunk-MT4XM3G6.js.map +1 -0
  10. package/dist/{chunk-GLMFBUKT.js → chunk-O2UPHN7X.js} +1 -1
  11. package/dist/chunk-O2UPHN7X.js.map +1 -0
  12. package/dist/{chunk-MMDIORZY.js → chunk-RTNMMHWR.js} +4 -23
  13. package/dist/chunk-RTNMMHWR.js.map +1 -0
  14. package/dist/chunk-RYD7ND4A.js +475 -0
  15. package/dist/chunk-RYD7ND4A.js.map +1 -0
  16. package/dist/{chunk-IN7WHMGZ.js → chunk-YWO4H64E.js} +47 -7
  17. package/dist/chunk-YWO4H64E.js.map +1 -0
  18. package/dist/coder-2leJPOvC.d.ts +52 -0
  19. package/dist/coordination-Curpzeyc.d.ts +381 -0
  20. package/dist/{delegates-C94qchkz.d.ts → delegates-CLFNAKyi.d.ts} +650 -21
  21. package/dist/improvement.js +1 -1
  22. package/dist/index.d.ts +10 -6
  23. package/dist/index.js +10 -10
  24. package/dist/intelligence.d.ts +3 -2
  25. package/dist/intelligence.js.map +1 -1
  26. package/dist/{loop-runner-bin-Noz7P-mS.d.ts → loop-runner-bin-B6dzNZC8.d.ts} +46 -12
  27. package/dist/loop-runner-bin.d.ts +8 -4
  28. package/dist/loop-runner-bin.js +5 -5
  29. package/dist/loops.d.ts +8 -6
  30. package/dist/loops.js +18 -7
  31. package/dist/mcp/bin.js +11 -11
  32. package/dist/mcp/bin.js.map +1 -1
  33. package/dist/mcp/index.d.ts +13 -12
  34. package/dist/mcp/index.js +8 -8
  35. package/dist/{openai-tools-d4GKwgya.d.ts → openai-tools-CA2N3-Ak.d.ts} +1 -1
  36. package/dist/profiles.d.ts +9 -10
  37. package/dist/profiles.js +5 -7
  38. package/dist/profiles.js.map +1 -1
  39. package/dist/{run-loop-CcqfR_gy.d.ts → run-loop-D3PwlG7J.d.ts} +1 -1
  40. package/dist/runtime.d.ts +31 -1046
  41. package/dist/runtime.js +18 -7
  42. package/dist/{types-CUzjRFZ3.d.ts → types-Crxftafi.d.ts} +2 -2
  43. package/dist/workflow.d.ts +2 -2
  44. package/dist/workflow.js +2 -3
  45. package/dist/workflow.js.map +1 -1
  46. package/dist/worktree-fanout-DUiKPApb.d.ts +1099 -0
  47. package/package.json +6 -2
  48. package/dist/chunk-45D64J7B.js.map +0 -1
  49. package/dist/chunk-4FEUFYOY.js +0 -282
  50. package/dist/chunk-4FEUFYOY.js.map +0 -1
  51. package/dist/chunk-7QYOXFCD.js +0 -293
  52. package/dist/chunk-7QYOXFCD.js.map +0 -1
  53. package/dist/chunk-GLMFBUKT.js.map +0 -1
  54. package/dist/chunk-IN7WHMGZ.js.map +0 -1
  55. package/dist/chunk-MMDIORZY.js.map +0 -1
  56. package/dist/coder-CybltHEm.d.ts +0 -163
  57. package/dist/coordination-Biw19JzN.d.ts +0 -944
  58. /package/dist/{chunk-ZWGEA722.js.map → chunk-E4X4FNQZ.js.map} +0 -0
@@ -0,0 +1,1099 @@
1
+ import { AgentProfile } from '@tangle-network/agent-interface';
2
+ import { AnalystFinding, DefaultVerdict } from '@tangle-network/agent-eval';
3
+ import { h as AgentSpec, E as ExecutorRegistry, B as Budget, A as Agent, i as SpawnJournal, g as ResultBlobStore, j as RootHandle, k as SupervisedResult, N as NodeId, l as Settled, m as Spend, S as Scope, n as Executor, G as GitRunner } from './delegates-CLFNAKyi.js';
4
+ import { I as Iteration } from './types-Crxftafi.js';
5
+ import { BackendType } from '@tangle-network/sandbox';
6
+ import { R as RuntimeHooks } from './runtime-hooks-C7JwKb9E.js';
7
+ import { L as LocalHarness, r as runLocalHarness } from './local-harness-BE_h8szs.js';
8
+
9
+ /**
10
+ * @experimental
11
+ *
12
+ * The personify layer — the "act like X" knob on top of the recursive keystone.
13
+ *
14
+ * The keystone (`src/loops/supervise/`) is pure STRUCTURE: a recursive `Agent` atom inside
15
+ * a budget-conserving `Scope`, an `ExecutorRegistry` mapping an `AgentSpec` to a runtime,
16
+ * and a `Supervisor` that runs a root agent to a typed `SupervisedResult`. It carries no
17
+ * CONTENT — no model, no prompt, no goal framing, no notion of "who this loop is".
18
+ *
19
+ * This layer adds exactly that content seam without inventing a second engine:
20
+ * - A `Persona` is a thin record: the root `AgentSpec` (profile + harness + optional BYO
21
+ * executor), a root `directive` (the goal framing handed to the chosen shape), a
22
+ * `context` blob (who the loop is acting as), and the executor seams the registry needs.
23
+ * `definePersona` builds it; it is data, not behavior.
24
+ * - A `LoopShape` is a reusable act-body FACTORY: `(ctx: ShapeContext) => Agent`. The shape
25
+ * owns the STRUCTURE (how to decompose / fan out / verify / synthesize); the persona's
26
+ * content parameterizes it. A new shape is ONE file + one `registerShape` call.
27
+ * - `Outcome<D>` is the contract every shape synthesizes into: a finished deliverable OR a
28
+ * list of concrete blockers — "100% done or 100%-defined blockers", never a vague middle.
29
+ *
30
+ * Layering: this module imports ONLY keystone runtime types (`./supervise/types`) and the
31
+ * substrate `AgentProfile`/`BackendType`. It typechecks standalone — no impl, no engine.
32
+ * Extensibility is structural: `Persona` carries an open `extensions` bag so a later
33
+ * world-model / memory field is additive (a new optional key), never a breaking change.
34
+ */
35
+
36
+ /**
37
+ * The terminal contract Drew wants: a loop returns a FINISHED deliverable, or the concrete
38
+ * list of blockers that stopped it — never a half-done best-effort coercion. A `blocked`
39
+ * outcome with an empty `blockers` list is a contract violation (a shape that can't finish
40
+ * MUST name why); impls fail loud on it rather than emitting a vacuous block.
41
+ *
42
+ * `Outcome` is the `Out` type a personified `Agent`/`Supervisor` is parameterized by, so the
43
+ * keystone's typed `SupervisedResult<Outcome<D>>` carries it end to end with no coercion.
44
+ */
45
+ type Outcome<D> = {
46
+ kind: 'done';
47
+ deliverable: D;
48
+ } | {
49
+ kind: 'blocked';
50
+ blockers: string[];
51
+ };
52
+ /**
53
+ * The "act like X" record. A thin composition over the keystone's `AgentSpec`: it pairs the
54
+ * root spec (the executor mapping for the root agent the shape builds) with the CONTENT a
55
+ * shape consumes — the goal framing (`directive`) and who the loop is acting as (`context`).
56
+ *
57
+ * The framework never reads `directive`/`context` semantically; it threads them to the shape
58
+ * verbatim through `ShapeContext`. This is the rule the mandate names: the FRAMEWORK is
59
+ * structure, the PERSONA carries model/prompt/tools/directive. No model name, prompt, or
60
+ * persona string is ever hardcoded in a shape or the engine.
61
+ *
62
+ * `D` is the deliverable type this persona's loops produce; it flows into `Outcome<D>`.
63
+ */
64
+ interface Persona<D = unknown> {
65
+ /** Stable persona name — used as the trace/journal label root, never as content. */
66
+ readonly name: string;
67
+ /**
68
+ * The root agent's executor mapping (profile + harness + optional BYO executor). The
69
+ * shape's root `Agent` carries THIS as its `executorSpec`; child specs the shape spawns
70
+ * are derived from / resolved against the same persona registry (see `ShapeContext`).
71
+ */
72
+ readonly root: AgentSpec;
73
+ /** The goal framing handed to the shape — the "what to achieve", not "how". */
74
+ readonly directive: string;
75
+ /** Who the loop is acting as — the opaque persona context blob the shape may inject into
76
+ * child tasks. Opaque to the framework; only the persona's profiles/prompts interpret it. */
77
+ readonly context: PersonaContext;
78
+ /**
79
+ * The executor seams (router endpoint+key, sandbox client, cli bin) the built-in runtimes
80
+ * read off `ExecutorContext.seams`, OR a fully pre-configured registry. The supervisor
81
+ * threads an EMPTY seam bag to the root scope, so a persona that uses built-in metered
82
+ * runtimes MUST supply a registry whose factories close over their seams (or BYO executors
83
+ * on each `AgentSpec`). Carried here so `runPersonified` can build `SupervisorOpts.executors`.
84
+ */
85
+ readonly executors: PersonaExecutors;
86
+ /**
87
+ * Forward-compatible extension bag — a later world-model / memory / tool-budget field is an
88
+ * additive key here, never a breaking change to the `Persona` shape. Opaque to the engine.
89
+ */
90
+ readonly extensions?: Readonly<Record<string, unknown>>;
91
+ /** Phantom: binds the persona to its deliverable type so `runPersonified` infers `D` from
92
+ * the persona and the chosen shape must agree. Type-only — never present at runtime. */
93
+ readonly __deliverable?: D;
94
+ }
95
+ /** The persona context blob — who the loop is acting as. Open by intent: a persona names its
96
+ * own role/audience/constraints; the framework treats it as opaque content. */
97
+ interface PersonaContext {
98
+ /** The role the loop embodies ("senior staff engineer", "equity research analyst", …). */
99
+ readonly role: string;
100
+ /** Optional freeform framing the persona's prompts/profiles consume. */
101
+ readonly notes?: string;
102
+ /** Open content bag — persona-specific fields a shape's child tasks may carry. */
103
+ readonly [key: string]: unknown;
104
+ }
105
+ /**
106
+ * How a persona supplies executor resolution. Either a pre-built registry (factories already
107
+ * closed over their seams) OR the raw seam bag the engine uses to construct a registry +
108
+ * thread the seams onto each spawn. Exactly one is required — fail loud if neither is set.
109
+ */
110
+ interface PersonaExecutors {
111
+ /** A registry whose factories already capture their seams. Highest precedence. */
112
+ readonly registry?: ExecutorRegistry;
113
+ /** Raw seams to thread onto built-in runtimes (`router`/`sandbox`/`cli` keys). */
114
+ readonly seams?: Readonly<Record<string, unknown>>;
115
+ }
116
+ /** The minimal input to build a `Persona`. Mirrors `Persona` but lets the builder default
117
+ * the executors-supplied invariant check and freeze the record. */
118
+ interface DefinePersonaInput<D = unknown> {
119
+ readonly name: string;
120
+ readonly root: AgentSpec;
121
+ readonly directive: string;
122
+ readonly context: PersonaContext;
123
+ readonly executors: PersonaExecutors;
124
+ readonly extensions?: Readonly<Record<string, unknown>>;
125
+ /** Phantom: pins the input's deliverable type so `definePersona<D>` returns a `Persona<D>`
126
+ * the caller's shape must agree with. Type-only — never supplied at a call site. */
127
+ readonly __deliverable?: D;
128
+ }
129
+ /** Builds a frozen `Persona`, failing loud on the executors-supplied invariant (neither a
130
+ * registry nor seams = an unresolvable persona). Pure — no I/O, no engine. */
131
+ type DefinePersona = <D = unknown>(input: DefinePersonaInput<D>) => Persona<D>;
132
+ /**
133
+ * Budget knobs a shape reads to size its fanout/children WITHOUT owning the conserved pool.
134
+ * The root budget lives on `SupervisorOpts.budget`; the shape only needs the per-child
135
+ * sizing hints + the fanout width it is allowed to open. All ceilings — the pool reserves
136
+ * against them and fails closed, so an over-eager shape can never overspend.
137
+ */
138
+ interface ShapeBudget {
139
+ /** Per-child spawn budget the shape reserves for each leaf/sub-loop it opens. */
140
+ readonly perChild: Budget;
141
+ /** Max children a fanout step may open in one round (the shape's structural width). */
142
+ readonly fanout: number;
143
+ }
144
+ /**
145
+ * The construction context a `LoopShape` factory receives. Carries the persona's resolved
146
+ * executor seams + the budget knobs, plus the ONE helper a shape needs to spawn a child
147
+ * through the keystone: `spawnChild` resolves an `AgentSpec` (or a persona-derived child
148
+ * profile) into an `Agent` the shape hands to `scope.spawn`. The shape never touches the
149
+ * registry directly — it asks the context, keeping resolution single-sourced.
150
+ */
151
+ interface ShapeContext<D = unknown> {
152
+ readonly persona: Persona<D>;
153
+ readonly budget: ShapeBudget;
154
+ /**
155
+ * Wrap an `AgentSpec` into a leaf `Agent` carrying it as `executorSpec`, so the shape can
156
+ * `scope.spawn(spawnChild(spec), task, opts)`. `name` labels the child for traces. The
157
+ * returned agent's `act` is never invoked by the keystone (it is spawned, not run) — the
158
+ * spec drives the resolved `Executor`; `act` exists only to satisfy the `Agent` shape.
159
+ */
160
+ spawnChild(name: string, spec: AgentSpec): Agent<unknown, Outcome<D>>;
161
+ /** Derive a child `AgentSpec` from the persona's root spec with an overridden profile —
162
+ * the seam a shape uses to give a worker a narrower role/prompt than the root persona. */
163
+ childSpec(profile: AgentProfile, harness?: BackendType | null): AgentSpec;
164
+ /** The scope analyst (selector≠judge firewall) the combinator steers from. Absent ⇒ the
165
+ * dormant default (empty findings → gates read deliverables/state only). */
166
+ readonly analyst?: ScopeAnalyst<D>;
167
+ }
168
+ /**
169
+ * A reusable act-body factory. Given the persona's content + seams (`ShapeContext`), it
170
+ * returns the root `Agent<Task, Outcome<D>>` whose `act` decomposes the task, fans out
171
+ * children through `scope.spawn`, verifies/selects across their settlements (selector≠judge:
172
+ * via `settledToIteration` + `defaultSelectWinner`, never re-ranking behind the driver), and
173
+ * synthesizes the terminal `Outcome<D>`. The shape is STRUCTURE; the persona is CONTENT.
174
+ */
175
+ type LoopShape<Task, D> = (ctx: ShapeContext<D>) => Agent<Task, Outcome<D>>;
176
+ /**
177
+ * The open shape registry — the extension point that makes a new loop-shape ONE file + one
178
+ * `registerShape` call with zero edits elsewhere. `resolve` returns a typed outcome (inspect
179
+ * `succeeded` before `value`); `register` fails loud on a duplicate name.
180
+ */
181
+ interface ShapeRegistry {
182
+ register<Task, D>(name: string, factory: LoopShape<Task, D>): void;
183
+ resolve<Task, D>(name: string): {
184
+ succeeded: true;
185
+ value: LoopShape<Task, D>;
186
+ } | {
187
+ succeeded: false;
188
+ error: string;
189
+ };
190
+ /** The registered shape names — for diagnostics + a fail-loud "unknown shape" message. */
191
+ names(): string[];
192
+ }
193
+ /**
194
+ * The end-to-end entrypoint. Builds the persona's root `Agent` from the chosen shape, then
195
+ * runs it through a fresh `createSupervisor` over the persona's executors + the supplied
196
+ * budget/journal/blobs. Returns the keystone's typed `SupervisedResult<Outcome<D>>` — a
197
+ * `winner` carries the synthesized `Outcome<D>`; a `no-winner` is never coerced into one.
198
+ *
199
+ * `shape` is either a resolved `LoopShape` or a registered shape NAME (resolved through the
200
+ * default registry). The journal/blobs default to in-memory impls in the engine when omitted
201
+ * (durable FS impls are passed explicitly for a persisted run).
202
+ */
203
+ interface RunPersonifiedOptions<Task, D> {
204
+ readonly persona: Persona<D>;
205
+ /** A resolved shape factory OR a registered shape name. */
206
+ readonly shape: LoopShape<Task, D> | string;
207
+ readonly task: Task;
208
+ readonly budget: Budget;
209
+ /** Per-child sizing + fanout width handed to the shape. Defaults derive from `budget`. */
210
+ readonly shapeBudget?: Partial<ShapeBudget>;
211
+ /** Trace/journal root key. Defaults to the persona name + a run discriminator in the engine. */
212
+ readonly runId?: string;
213
+ readonly journal?: SpawnJournal;
214
+ readonly blobs?: ResultBlobStore;
215
+ /** Runtime recursion-depth ceiling, paired with the conserved pool. */
216
+ readonly maxDepth?: number;
217
+ /** OTP intensity breaker bounds, forwarded to the supervisor verbatim. */
218
+ readonly maxRestarts?: number;
219
+ readonly withinMs?: number;
220
+ /** A live root handle to attach (view/signal/abort) before the run starts. */
221
+ readonly handle?: RootHandle<Outcome<D>>;
222
+ readonly now?: () => number;
223
+ readonly signal?: AbortSignal;
224
+ /** Optional scope analyst threaded into the shape's ShapeContext so loopUntil/widen steer
225
+ * on trace-derived findings instead of the dormant empty default. */
226
+ readonly analyst?: ScopeAnalyst<D>;
227
+ /**
228
+ * Lifecycle stream sink, forwarded to `SupervisorOpts.hooks` so the root `Scope`'s
229
+ * `agent.spawn`/`agent.child` events flow to an observer (e.g. the Intelligence SDK's
230
+ * trace export). Absent ⇒ no stream (the run is silent, as today).
231
+ */
232
+ readonly hooks?: RuntimeHooks;
233
+ }
234
+ /** The composed run signature. */
235
+ type RunPersonified = <Task, D>(options: RunPersonifiedOptions<Task, D>) => Promise<SupervisedResult<Outcome<D>>>;
236
+
237
+ /**
238
+ * @experimental
239
+ *
240
+ * The RSI-wave type surface — the FROZEN contracts the wave's Core + Compose build to.
241
+ *
242
+ * The keystone (`../supervise/`) is pure execution structure: a recursive `Agent` atom in a
243
+ * budget-conserving `Scope`, run to a typed `SupervisedResult` by a `Supervisor`. The persona
244
+ * layer (`./types`, `./persona`) adds the "act like X" content seam (`Persona` = `AgentSpec` +
245
+ * `directive` + `context`, `LoopShape = (ctx) => Agent`, `Outcome<D>`). This module freezes the
246
+ * remaining four wave seams ON TOP of those — and nothing more:
247
+ *
248
+ * 1. GENERIC COMBINATORS — the content-free act-library. Five composable shapes
249
+ * (`pipeline`/`fanout`/`loopUntil`/`panel`/`verify`) plus the streaming widener (G5). Each
250
+ * is a `CombinatorShape` (a `LoopShape` whose `Agent.act` runs the combinator over `Scope`),
251
+ * so a combinator IS just a `LoopShape` — no new engine type. The SHAPE is here; the DOMAIN
252
+ * (model, prompt, role) stays on the `Persona`. There is no "research" or "code" combinator:
253
+ * a research sweep is `fanout` under a research persona; a build is `pipeline` under a coder.
254
+ * 2. ANALYST-ON-SCOPE (G1, a PORT) — `ScopeAnalyst` carries the round-synchronous driver's
255
+ * analyze→findings→steer wire (dynamic.ts) across to the reactive `Scope`, behind
256
+ * the same trace-derived firewall (`assertTraceDerivedFindings` semantics): a reactive
257
+ * combinator steers from trace FINDINGS, never a child's raw `verdict`.
258
+ * 3. CROSS-RUN CORPUS (G2) — `Corpus` is the DURABLE accreted-fact store, DISTINCT from the
259
+ * per-run `SpawnJournal`/`ResultBlobStore`. `renderCorpusToInstructions` is the read-back:
260
+ * it projects accreted facts into `AgentProfile.prompt.instructions` / `resources.instructions`
261
+ * for the next run's persona (the learning-flywheel READ side).
262
+ * 4. TRAJECTORY TRACE + COST LEDGER — `trajectoryReport(journal, blobs)` reconstructs the whole
263
+ * spawn tree with per-node + rolled-up `Spend`; `equalKOnCost` compares arms on conserved
264
+ * COST (tokens/usd), NOT raw iteration count — closing the leaf-fanout confound.
265
+ *
266
+ * Layering: imports ONLY keystone runtime types (`../supervise/types`), persona types
267
+ * (`./types`), the substrate `AnalystFinding`/`AgentProfile`, and the durable-store interfaces.
268
+ * Pure types/interfaces — this module typechecks standalone, owns no impl, invents no engine.
269
+ */
270
+
271
+ /**
272
+ * A combinator is just a `LoopShape`: a factory `(ShapeContext) => Agent` whose `Agent.act`
273
+ * runs the combinator's structure over the `Scope` (spawn children, drain `next()`, select via
274
+ * the single-sourced `settledToIteration`+`defaultSelectWinner`, synthesize an `Outcome<D>`).
275
+ * Aliased — NOT a new type — so a combinator stays a first-class shape the persona layer's
276
+ * `runPersonified`/`ShapeRegistry` resolve with zero new machinery. The SHAPE is content-free;
277
+ * the persona carries the domain.
278
+ */
279
+ type CombinatorShape<Task, D> = LoopShape<Task, D>;
280
+ /**
281
+ * `pipeline(stages)` — sequential composition: each stage's `Outcome.deliverable` feeds the next
282
+ * stage's task (via `feed`). The first `blocked` stage short-circuits the whole pipeline (its
283
+ * blockers ARE the pipeline's blockers — never coerced past a failed stage). The terminal
284
+ * stage's `done` deliverable is the pipeline's deliverable. Spawns one child per stage in order;
285
+ * a stage that the conserved pool cannot admit is a concrete blocker.
286
+ *
287
+ * No domain: "code build test" is `pipeline([plan, implement, integrate])` under a coder persona,
288
+ * not a named shape. A stage names only its label + how to derive its task from the prior output.
289
+ */
290
+ interface PipelineStage<Task, StepIn, StepOut> {
291
+ /** Trace/journal label for this stage's spawned child. */
292
+ readonly label: string;
293
+ /** Derive this stage's task from the prior stage's deliverable (or the root task for stage 0).
294
+ * Pure projection — the framework never interprets the result; the resolved leaf does. */
295
+ feed(prior: StepIn, ctx: ShapeContext<unknown>, rootTask: Task): unknown;
296
+ /** Read this stage's settled child output into the typed `StepOut` the next stage feeds on.
297
+ * Fail loud (return a `blocked`) when the child produced nothing usable for the next stage. */
298
+ collect(settled: Settled<Outcome<StepOut>>): Outcome<StepOut>;
299
+ }
300
+ /** `pipeline(stages)` — build the sequential combinator from an ordered stage list. The first
301
+ * stage's `StepIn` is the root `Task`; the last stage's `StepOut` is the deliverable `D`. */
302
+ type Pipeline = <Task, D>(stages: ReadonlyArray<PipelineStage<Task, unknown, unknown>>) => CombinatorShape<Task, D>;
303
+ /**
304
+ * `fanout(items, { synthesize? })` — N children spawned in one round (one per item, bounded by
305
+ * the conserved pool's fail-closed admission), drained via `scope.next()`, then optionally a
306
+ * single SYNTHESIS child over the gathered results. Without `synthesize`, the combinator returns
307
+ * the best-valid child via the single-sourced selector (selector≠judge). A round that admitted
308
+ * zero children, or whose synthesis child could not be admitted, is a concrete blocker.
309
+ *
310
+ * No domain: a "research sweep over angles" is `fanout(angles, { synthesize: cite })` under a
311
+ * research persona; a "fanout-vote" is `fanout(copies)` with the default selector. The item list
312
+ * + the synthesis posture are the SHAPE's args; the prompt that turns an item into work is the
313
+ * persona's.
314
+ */
315
+ interface FanoutOptions<Item, D> {
316
+ /** One child task per item: `item` + the index discriminator. The persona's directive/context
317
+ * is threaded in by the combinator; this only supplies the per-item discriminator. */
318
+ itemTask(item: Item, index: number, ctx: ShapeContext<D>): unknown;
319
+ /** Per-item child label (defaults to `item:<index>` in the impl). */
320
+ label?(item: Item, index: number): string;
321
+ /**
322
+ * Optional per-item `AgentSpec` override. When set, each item's child is spawned against the
323
+ * returned spec instead of `persona.root` — the seam a heterogeneous fanout uses to give each
324
+ * item a DISTINCT executor (e.g. N authored harness profiles, each on its own worktree-CLI
325
+ * leaf). Absent ⇒ every item runs against the persona's root spec (the homogeneous default).
326
+ */
327
+ itemSpec?(item: Item, index: number, ctx: ShapeContext<D>): AgentSpec;
328
+ /**
329
+ * Optional synthesis over the gathered child results: when present, the combinator spawns ONE
330
+ * synthesis child whose task is built from the drained settlements, and its `done` output is
331
+ * the deliverable. When absent, the deliverable is the best-valid child via `defaultSelectWinner`.
332
+ * The synthesis child is a SEPARATE keystone agent (not a re-rank behind the driver).
333
+ */
334
+ synthesize?: FanoutSynthesis<D>;
335
+ /**
336
+ * Winner-selection strategy among the gathered `done` children when there is no `synthesize`.
337
+ * Receives the SAME `Iteration[]` the default selector reads (each child's output is its
338
+ * `Outcome<D>`), so a strategy is a thin re-sort (smallest-diff, highest-readiness, first-valid
339
+ * …) over the candidates — NEVER a re-rank behind a judge. Default = `defaultSelectWinner`
340
+ * semantics (best-valid-score, ties→earliest). Mutually exclusive with `synthesize` (a
341
+ * synthesis child IS the selection); supplying both is a config error.
342
+ */
343
+ selectWinner?: FanoutWinnerSelector<D>;
344
+ }
345
+ /** A winner-selection strategy: argmax/sort over the gathered child iterations (each output is the
346
+ * child's `Outcome<D>`), returning the chosen iteration or `undefined` when none qualifies. */
347
+ type FanoutWinnerSelector<D> = (iterations: Iteration<unknown, Outcome<D>>[]) => {
348
+ readonly output?: Outcome<D> | undefined;
349
+ } | undefined;
350
+ /** Built-in valid-only winner strategies for `selectValidWinner` (selector≠judge): best gated-valid
351
+ * score, the smallest delivered artifact (via a `sizeOf` extractor), or the earliest valid. */
352
+ type WinnerStrategy = 'highest-score' | 'smallest-artifact' | 'first-valid';
353
+ /** How a fanout's synthesis child is built + read. `synthesisTask` projects the drained child
354
+ * settlements into the synthesis child's task; `collect` reads its settled output into the
355
+ * deliverable `Outcome<D>`. */
356
+ interface FanoutSynthesis<D> {
357
+ synthesisTask(gathered: ReadonlyArray<Settled<Outcome<D>>>, ctx: ShapeContext<D>): unknown;
358
+ collect(settled: Settled<Outcome<D>>): Outcome<D>;
359
+ }
360
+ /** `fanout(items, opts)` — build the fanout combinator over a static item list. */
361
+ type Fanout = <Task, Item, D>(items: ReadonlyArray<Item>, opts: FanoutOptions<Item, D>) => CombinatorShape<Task, D>;
362
+ /**
363
+ * `loopUntil({ until, step })` — iterative deepening inside the conserved pool: spawn one `step`
364
+ * child per round, ask `until` whether the accumulated state satisfies the goal, and stop when it
365
+ * does OR when the pool can no longer admit a step (budget IS the loop bound — no unbounded
366
+ * while). The deployable, non-oracle stop: `until` is the satisfiability gate, read from trace
367
+ * findings + accumulated deliverables, never a fresh raw verdict the loop minted to stop itself.
368
+ *
369
+ * No domain: "refine until tests pass" is `loopUntil` with a coder persona + a `step` that edits
370
+ * and an `until` that reads the test-finding; the combinator owns only the round/stop wiring.
371
+ */
372
+ interface LoopUntilSpec<Task, State, D> {
373
+ /** Build the next step child's task from the root task + the state accumulated so far. */
374
+ step(rootTask: Task, state: LoopUntilState<State>, ctx: ShapeContext<D>): unknown;
375
+ /** Fold one settled step into the accumulated state (the loop's running deliverable candidate). */
376
+ fold(prior: LoopUntilState<State>, settled: Settled<Outcome<D>>): LoopUntilState<State>;
377
+ /**
378
+ * The satisfiability gate: given the accumulated state + the round's trace findings, has the
379
+ * goal been reached? Returns the terminal deliverable when satisfied, or `null` to keep going.
380
+ * Reads `findings` (trace-derived), NOT a raw verdict score — the deployable-stop discipline.
381
+ */
382
+ until(state: LoopUntilState<State>, findings: ReadonlyArray<AnalystFinding>): Outcome<D> | null;
383
+ /** Per-round step label (defaults to `step:<round>` in the impl). */
384
+ label?(round: number): string;
385
+ }
386
+ /** The accumulated state `loopUntil` threads across rounds — the running candidate + the round
387
+ * index, so `step`/`fold`/`until` are pure functions of it (replay-safe, no wall-clock). */
388
+ interface LoopUntilState<State> {
389
+ readonly round: number;
390
+ readonly value: State;
391
+ }
392
+ /** `loopUntil(spec)` — build the iterative-deepening combinator. `seed` is the initial state. */
393
+ type LoopUntil = <Task, State, D>(seed: State, spec: LoopUntilSpec<Task, State, D>) => CombinatorShape<Task, D>;
394
+ /**
395
+ * `panel(judges)` — M judges over ONE artifact, merged WRITE-ONLY (selector≠judge taken to its
396
+ * limit). The combinator spawns the M judge children over the same input artifact, drains their
397
+ * settlements, and MERGES their findings into a panel verdict via `merge` — a pure WRITE-ONLY
398
+ * fold (a judge's output is never fed back to steer another judge, and the merge never re-ranks
399
+ * the children behind the driver). The merged verdict gates the deliverable.
400
+ *
401
+ * No domain: a "code review panel" and an "essay rubric panel" are the same `panel` shape under
402
+ * different personas; the rubric lives in each judge persona's profile, not the combinator.
403
+ */
404
+ interface PanelSpec<Artifact, D> {
405
+ /** The M judge child specs: each is a persona-derived child (a narrower judge profile). The
406
+ * combinator spawns one child per entry over the SAME `artifact` and never lets one judge's
407
+ * output reach another's task (write-only). */
408
+ readonly judges: ReadonlyArray<PanelJudge>;
409
+ /** Build one judge child's task from the shared artifact under review + the judge descriptor. */
410
+ judgeTask(artifact: Artifact, judge: PanelJudge, ctx: ShapeContext<D>): unknown;
411
+ /**
412
+ * Write-only merge: fold the M settled judge verdicts into the panel's terminal `Outcome<D>`.
413
+ * Pure over the drained settlements — it MUST NOT spawn, re-judge, or feed one verdict into
414
+ * another. A panel that reached no quorum is a concrete blocker (fail loud, never a vacuous done).
415
+ */
416
+ merge(verdicts: ReadonlyArray<PanelVerdict>, artifact: Artifact): Outcome<D>;
417
+ }
418
+ /** One judge in a panel — a labeled persona-derived judge child. Content (the rubric) lives in
419
+ * the judge's profile; this carries only the label + the optional weight the merge may read. */
420
+ interface PanelJudge {
421
+ readonly label: string;
422
+ /** Optional merge weight (a write-only hint the `merge` fold may use; default-equal in the impl). */
423
+ readonly weight?: number;
424
+ }
425
+ /** One judge child's settled verdict, surfaced to the write-only `merge`. `down` judges carry no
426
+ * verdict (excluded from the merge `n`, like an infra-errored cell). */
427
+ interface PanelVerdict {
428
+ readonly judge: PanelJudge;
429
+ readonly verdict?: DefaultVerdict;
430
+ /** The judge child's raw output — what it was asked to assess, for a merge that quotes it. */
431
+ readonly output?: unknown;
432
+ /** True when the judge child went `down` (no usable verdict — kept out of the merge denominator). */
433
+ readonly down: boolean;
434
+ }
435
+ /** `panel(spec)` — build the M-judge write-only-merge combinator. */
436
+ type Panel = <Task, Artifact, D>(spec: PanelSpec<Artifact, D>) => CombinatorShape<Task, D>;
437
+ /**
438
+ * `verify({ implement, verifier })` — the 2-node sequential gate: an IMPLEMENT child produces a
439
+ * candidate, then a SEPARATE VERIFIER child's verdict GATES shippability. A `valid` verifier
440
+ * verdict ships the implement deliverable; any other outcome (implement down, verifier down,
441
+ * invalid verdict) becomes a concrete blocker carrying the failure verbatim — never a coerced
442
+ * "done". The verifier is a distinct keystone agent (selector≠judge: the implement child does
443
+ * not grade itself).
444
+ *
445
+ * No domain: "write code then run the test gate" and "draft then fact-check" are the same `verify`
446
+ * shape under different personas; the gate rubric is the verifier persona's, not the combinator's.
447
+ */
448
+ interface VerifySpec<Task, Candidate, D> {
449
+ /** Build the implement child's task from the root task. */
450
+ implement(rootTask: Task, ctx: ShapeContext<D>): unknown;
451
+ /** Build the verifier child's task from the implement child's settled candidate. */
452
+ verifier(candidate: Settled<Outcome<Candidate>>, ctx: ShapeContext<D>): unknown;
453
+ /** Project the gated (verifier-`valid`) candidate into the terminal deliverable. */
454
+ collect(candidate: Settled<Outcome<Candidate>>, verdict: DefaultVerdict): Outcome<D>;
455
+ /** Implement / verifier child labels (default `implement` / `verify` in the impl). */
456
+ readonly implementLabel?: string;
457
+ readonly verifierLabel?: string;
458
+ }
459
+ /** `verify(spec)` — build the 2-node implement→verifier-gate combinator. */
460
+ type Verify = <Task, Candidate, D>(spec: VerifySpec<Task, Candidate, D>) => CombinatorShape<Task, D>;
461
+ /**
462
+ * `widen({ gate })` (G5) — the STREAMING spawn-on-completion driver. Unlike the static-fanout
463
+ * combinators above, the widener REACTS to each `scope.next()`: as each child settles it consults
464
+ * the `WidenGate` and, when a lineage is `promising`, widens by AT MOST ONE child toward it under
465
+ * the remaining conserved pool. Defaults to FLAT (the gate never widens) so a gate run stays
466
+ * non-widening and the R2 selector≠judge collision is dormant. `promising` is derived from the
467
+ * round's analyst FINDINGS (via `ScopeAnalyst`, §2), NOT a child's raw `verdict` — the firewall.
468
+ *
469
+ * This is the progressive-widening (MCTS-PW) combinator: the one shape whose breadth is decided
470
+ * at runtime from the diagnosis, not fixed at spawn. It is the mechanism the diverse-strategy-vs-
471
+ * blind GATE is run with — kept FLAT by default until that gate returns positive (don't build
472
+ * mechanism ahead of the gate).
473
+ */
474
+ interface WidenSpec<Seed, D> {
475
+ /** The initial children to spawn before any widening — the seed lineages the gate widens from.
476
+ * One child task per seed; bounded by the conserved pool's fail-closed admission. */
477
+ readonly seeds: ReadonlyArray<Seed>;
478
+ seedTask(seed: Seed, index: number, ctx: ShapeContext<D>): unknown;
479
+ /**
480
+ * The progressive-widening gate. Consulted on EVERY settled child with the round's
481
+ * trace-derived `findings`; returns a widen decision (spawn one more toward a lineage) or a
482
+ * stop. DEFAULTS to flat via `flatWidenGate` — never widens, so the firewall stays dormant.
483
+ */
484
+ readonly gate: ScopeWidenGate<D>;
485
+ /** Build the widened child's task from the lineage the gate chose to extend. */
486
+ widenTask(toward: WidenLineage<D>, ctx: ShapeContext<D>): unknown;
487
+ /** Synthesize the terminal deliverable from every settled lineage (selector≠judge: the
488
+ * single-sourced selector over the gathered children, never a re-judge). */
489
+ synthesize(gathered: ReadonlyArray<Settled<Outcome<D>>>, ctx: ShapeContext<D>): Outcome<D>;
490
+ }
491
+ /**
492
+ * The runtime widening gate (the reactive analogue of the keystone's `WidenGate`, lifted to read
493
+ * trace FINDINGS instead of a raw verdict). `decide` is consulted per settled child; it MUST
494
+ * derive `promising` from `findings`, never from `settled.verdict`, unless `judgeExempt` is
495
+ * explicitly argued (the documented off-by-default escape hatch). Flat default never widens.
496
+ */
497
+ interface ScopeWidenGate<D> {
498
+ decide(settled: Settled<Outcome<D>>, findings: ReadonlyArray<AnalystFinding>, budget: Scope<Outcome<D>>['budget']): WidenDecision<D>;
499
+ /** When true, `decide` may read `settled.verdict` directly — collides with the steer firewall,
500
+ * so it must be argued per cell, never defaulted on (mirrors the keystone `WidenGate`). */
501
+ readonly judgeExempt?: boolean;
502
+ }
503
+ /** A widening decision: extend one lineage by one child, or stop widening. `flatWidenGate`
504
+ * always returns `{ kind: 'stop' }`. */
505
+ type WidenDecision<D> = {
506
+ kind: 'widen';
507
+ toward: WidenLineage<D>;
508
+ } | {
509
+ kind: 'stop';
510
+ rationale?: string;
511
+ };
512
+ /** A lineage the gate may widen toward — the settled child that looked promising + the findings
513
+ * that justified it (the trace-derived provenance the firewall requires). */
514
+ interface WidenLineage<D> {
515
+ readonly settled: Extract<Settled<Outcome<D>>, {
516
+ kind: 'done';
517
+ }>;
518
+ readonly findings: ReadonlyArray<AnalystFinding>;
519
+ }
520
+ /** `widen(spec)` — build the streaming progressive-widening combinator. */
521
+ type Widen = <Task, Seed, D>(spec: WidenSpec<Seed, D>) => CombinatorShape<Task, D>;
522
+ /** The flat default `ScopeWidenGate` factory contract — never widens, keeping the R2 firewall
523
+ * conflict dormant. Exported so a gate run can pass it explicitly and a test can assert the
524
+ * default is flat. */
525
+ type FlatWidenGate = <D>() => ScopeWidenGate<D>;
526
+ /**
527
+ * The reactive analyst seam — the PORT of the round-synchronous driver's `analyze` hook
528
+ * (dynamic.ts) onto the reactive `Scope`. The old driver wired the analyst at round
529
+ * boundaries (`plan` ran the analyst over `history` BEFORE the planner); the reactive `Scope` has
530
+ * no rounds, so this carries the wire across: a combinator's `act` asks the `ScopeAnalyst` to turn
531
+ * the settled children SO FAR into `AnalystFinding[]`, and steers from THOSE findings.
532
+ *
533
+ * The firewall is preserved (selector≠judge): `analyze` runs the trace-derived analyst and the
534
+ * impl asserts `assertTraceDerivedFindings` semantics — a finding citing judge/verdict/score
535
+ * `metric` evidence aborts the round. The steer decision reads `findings`, NEVER the children's
536
+ * raw `verdict`. Fail loud — a throwing or non-array analyst aborts (no silent empty findings).
537
+ */
538
+ interface ScopeAnalyst<D> {
539
+ /**
540
+ * Turn the children settled so far into trace-derived findings. `settledSoFar` is the cursor-
541
+ * ordered settlement list a combinator has drained (the reactive analogue of the old driver's
542
+ * `history`). The impl runs the analyst, then enforces the trace-derived firewall before
543
+ * returning — a judge-derived finding is rejected, not filtered.
544
+ */
545
+ analyze(input: ScopeAnalyzeInput<D>): Promise<ReadonlyArray<AnalystFinding>>;
546
+ }
547
+ /** Input to a `ScopeAnalyst.analyze` — the root task framing + the children settled so far. */
548
+ interface ScopeAnalyzeInput<D> {
549
+ /** Opaque root-task framing (whatever the combinator was invoked with). */
550
+ readonly task: unknown;
551
+ /** The children this combinator has drained off `scope.next()`, in cursor order. */
552
+ readonly settledSoFar: ReadonlyArray<Settled<Outcome<D>>>;
553
+ /** This combinator's scope id (the trace-correlation root for the analyst). */
554
+ readonly nodeId: NodeId;
555
+ }
556
+ /**
557
+ * How a combinator's `act` consumes findings to steer — the SINGLE firewalled steer surface a
558
+ * reactive combinator reads. `loopUntil.until`, `widen` gate, and any future steer all funnel
559
+ * through a `SteerContext` so the firewall is enforced in one place: `findings` is trace-derived
560
+ * (the analyst already asserted it), and a combinator MUST NOT reach back to `settled.verdict`
561
+ * for the steer decision. `lastValidScore` is provided for OBSERVABILITY only (rendering/traces),
562
+ * explicitly NOT for steering — reading it to steer is the coupling the architecture forbids.
563
+ */
564
+ interface SteerContext<D> {
565
+ readonly findings: ReadonlyArray<AnalystFinding>;
566
+ readonly settledSoFar: ReadonlyArray<Settled<Outcome<D>>>;
567
+ /** Observability-only: the best valid score seen so far. Rendering/trace use ONLY — steering
568
+ * off this re-introduces selector=judge. Marked so a reviewer catches a misuse. */
569
+ readonly lastValidScore?: number;
570
+ }
571
+ /**
572
+ * The firewall assertion contract, re-stated for the reactive seam (PORT of
573
+ * `assertTraceDerivedFindings`). A PROVENANCE check, not a content check: span/event/artifact/
574
+ * finding refs and empty-evidence findings pass; only a `metric` ref whose uri is a
575
+ * judge/verdict/score scheme is rejected. Fail loud — a tainted finding aborts. The impl lives in
576
+ * `analyst.ts`; this type pins its signature so callers depend on the contract, not the impl.
577
+ */
578
+ type AssertTraceDerivedFindings = (findings: ReadonlyArray<AnalystFinding>) => void;
579
+ /**
580
+ * One accreted fact in the cross-run corpus — the learning-flywheel's durable unit. DISTINCT from
581
+ * a `SpawnEvent` (a per-run decision record): a `CorpusRecord` is a fact a run LEARNED that a
582
+ * FUTURE run should read back (the world-model for story 5). It is content the next persona reads,
583
+ * not a replay input. Tagged + scored so `query`/`renderCorpusToInstructions` can project the
584
+ * relevant, high-confidence subset.
585
+ */
586
+ interface CorpusRecord {
587
+ readonly schemaVersion: '1.0.0';
588
+ /** Stable id over identity-defining fields (claim + tags) so a re-learned fact dedups. */
589
+ readonly id: string;
590
+ /** The run that produced this fact (the journal `runId`/`root`) — provenance back to the trace. */
591
+ readonly runId: NodeId;
592
+ readonly producedAt: string;
593
+ /** Coarse classification the query/render filters on (free-form, mirrors `AnalystFinding.area`). */
594
+ readonly area: string;
595
+ /** The accreted fact — the instruction-shaped statement the next run reads back. */
596
+ readonly claim: string;
597
+ /** Optional supporting detail the renderer may include under the claim. */
598
+ readonly rationale?: string;
599
+ /** Free-form tags for `query` filtering (domain, persona, surface). */
600
+ readonly tags: ReadonlyArray<string>;
601
+ /** 0..1 — the producing run's confidence in this fact (the render threshold reads it). */
602
+ readonly confidence: number;
603
+ /** Optional provenance back into the run that learned it (a finding id / outRef / span). */
604
+ readonly evidence?: ReadonlyArray<{
605
+ readonly kind: string;
606
+ readonly uri: string;
607
+ }>;
608
+ }
609
+ /** A corpus query filter — every field is an AND-narrowing; an omitted field does not constrain. */
610
+ interface CorpusFilter {
611
+ readonly area?: string;
612
+ /** Match records carrying ALL of these tags. */
613
+ readonly tags?: ReadonlyArray<string>;
614
+ /** Minimum confidence a record must clear to be returned (the render gate). */
615
+ readonly minConfidence?: number;
616
+ /** Only records from this run (rare — usually a cross-run read). */
617
+ readonly runId?: NodeId;
618
+ /** Cap the result count (most-confident first in the impl). */
619
+ readonly limit?: number;
620
+ }
621
+ /**
622
+ * The durable cross-run corpus — the learning-flywheel store. DISTINCT from `SpawnJournal`
623
+ * (per-run decisions, replay) and `ResultBlobStore` (per-run payloads): `Corpus` holds accreted
624
+ * FACTS across runs that the next run reads back. `InMemoryCorpus` + `FileCorpus` (JSONL) impls
625
+ * live in `corpus.ts` and MAY share a storage spine with the JSONL journal, but the INTERFACE is
626
+ * separate so a consumer never confuses a replay record with a learned fact.
627
+ *
628
+ * Fail-loud, typed-outcome boundary: `append` is idempotent on an identical record (same `id` +
629
+ * `claim`); a conflicting re-append under the same `id` is a typed error, never a silent overwrite.
630
+ */
631
+ interface Corpus {
632
+ /** Append one accreted fact. Idempotent on an identical record; returns a typed outcome —
633
+ * inspect `succeeded` before treating it as durable (no silent write-through on conflict). */
634
+ append(record: CorpusRecord): Promise<{
635
+ succeeded: true;
636
+ } | {
637
+ succeeded: false;
638
+ error: string;
639
+ }>;
640
+ /** Query accreted facts by filter — most-confident first. Returns the matching records (an
641
+ * empty array when none match is a valid result, NOT an error). */
642
+ query(filter: CorpusFilter): Promise<ReadonlyArray<CorpusRecord>>;
643
+ }
644
+ /**
645
+ * Project accreted corpus facts into an `AgentProfile`'s instruction seams — the learning-flywheel
646
+ * READ side. Reads the corpus through `filter`, renders the matching facts into instruction lines,
647
+ * and returns a NEW profile with them merged into `prompt.instructions` (the append-line seam) so
648
+ * the next run's persona reads the accreted world-model. Pure projection over the queried records;
649
+ * never mutates the input profile (returns a fresh one). The impl lives in `corpus.ts`.
650
+ *
651
+ * `resources.instructions` is `string | AgentProfileResourceRef`; `prompt.instructions` is
652
+ * `string[]`. The render targets `prompt.instructions` (additive lines) by default; a caller that
653
+ * wants the single-blob `resources.instructions` form passes `target: 'resources'`.
654
+ */
655
+ interface RenderCorpusToInstructionsOptions {
656
+ readonly corpus: Corpus;
657
+ readonly filter: CorpusFilter;
658
+ /** The profile to project the facts into. The result is a fresh profile — the input is unchanged. */
659
+ readonly profile: AgentProfile;
660
+ /** Where the rendered facts land: appended to `prompt.instructions[]` (default) or folded into
661
+ * the single-blob `resources.instructions` string. */
662
+ readonly target?: 'prompt' | 'resources';
663
+ /** Optional cap on rendered lines (most-confident first), independent of the query `limit`. */
664
+ readonly maxLines?: number;
665
+ }
666
+ /** `renderCorpusToInstructions(opts)` — the flywheel read-back projection. Async (queries the
667
+ * durable corpus); returns a fresh `AgentProfile` with the accreted facts merged in. */
668
+ type RenderCorpusToInstructions = (opts: RenderCorpusToInstructionsOptions) => Promise<AgentProfile>;
669
+ /**
670
+ * One node in the reconstructed trajectory tree — a driver OR a leaf, with its OWN spend and the
671
+ * spend ROLLED UP over its subtree. Reconstructed from the `SpawnJournal` (structure + per-node
672
+ * `Spend`) + the `ResultBlobStore` (the `out` artifact, rehydrated by `outRef`). The realized tree
673
+ * shape: `parent`/`children` are the actual spawn edges the run took, not a planned topology.
674
+ */
675
+ interface TrajectoryNode {
676
+ readonly id: NodeId;
677
+ readonly parent?: NodeId;
678
+ readonly children: ReadonlyArray<NodeId>;
679
+ readonly label: string;
680
+ readonly runtime: string;
681
+ /** Terminal status the journal recorded for this node. */
682
+ readonly status: 'done' | 'failed' | 'cancelled' | 'pending';
683
+ /** This node's OWN conserved spend (from its `settled` event). */
684
+ readonly ownSpend: Spend;
685
+ /** This node's spend PLUS every descendant's — the rolled-up subtree cost. The cost a parent
686
+ * "really" consumed inclusive of its children's fanout (the equal-k-on-cost basis). */
687
+ readonly rolledUpSpend: Spend;
688
+ /** The node's verdict, when its settlement carried one (observability — NOT a steer input). */
689
+ readonly verdict?: DefaultVerdict;
690
+ /** The rehydrated output artifact, when `withOutputs` was requested + the blob resolved. */
691
+ readonly output?: unknown;
692
+ readonly outRef?: string;
693
+ }
694
+ /** The whole reconstructed trajectory — the realized tree + its root-rolled-up total. The
695
+ * per-node + rolled-up `Spend` is the evidence both the trace viewer and `equalKOnCost` read. */
696
+ interface TrajectoryReport {
697
+ readonly root: NodeId;
698
+ /** Every node, in cursor/spawn order — the realized tree (`parent`/`children` are the real edges). */
699
+ readonly nodes: ReadonlyArray<TrajectoryNode>;
700
+ /** The root's rolled-up spend — the whole run's conserved total (tokens + usd + iterations + ms). */
701
+ readonly total: Spend;
702
+ /** Count of nodes by terminal status — a quick "how did the tree end" readout. */
703
+ readonly statusCounts: Readonly<Record<TrajectoryNode['status'], number>>;
704
+ }
705
+ /**
706
+ * `trajectoryReport(journal, blobs, root, { withOutputs? })` — reconstruct the whole tree with
707
+ * per-node + rolled-up `Spend`. Reads the journal for structure + spend and (when `withOutputs`)
708
+ * the blob store for each `done` node's artifact. Fail loud on a tree that was never journaled or
709
+ * a `done` node whose blob the store cannot rehydrate (a silent gap would mis-cost the tree). The
710
+ * impl lives in `trajectory.ts`.
711
+ */
712
+ interface TrajectoryReportOptions {
713
+ /** Rehydrate each `done` node's `output` from the blob store. Off by default (cost-only report). */
714
+ readonly withOutputs?: boolean;
715
+ }
716
+ /** `trajectoryReport(...)` — the tree+cost reconstructor. Async (reads journal + optionally blobs). */
717
+ type TrajectoryReportFn = (journal: SpawnJournal, blobs: ResultBlobStore, root: NodeId, options?: TrajectoryReportOptions) => Promise<TrajectoryReport>;
718
+ /**
719
+ * One arm of an equal-k comparison — a labeled trajectory (a `TrajectoryReport` is one arm's whole
720
+ * run). The arm's conserved COST is `report.total` (tokens + usd), which the sandbox executor
721
+ * already reports INCLUSIVE of a leaf's internal sub-agent fanout — so comparing arms on this cost
722
+ * (not raw `iterations`) closes the leaf-fanout confound: a treatment arm whose leaf fanned out
723
+ * internally is charged for that fanout in `total.tokens`/`total.usd`, not hidden behind one
724
+ * iteration count.
725
+ */
726
+ interface EqualKArm {
727
+ readonly label: string;
728
+ readonly report: TrajectoryReport;
729
+ }
730
+ /**
731
+ * The equal-k-on-cost verdict: whether every arm spent within `tolerance` of the others on the
732
+ * CONSERVED cost channels (tokens + usd), so a downstream metric comparison is "at equal k". Per-
733
+ * arm cost is surfaced so a caller can see HOW close. `withinTolerance: false` means the arms are
734
+ * NOT comparable at equal compute — a confound to report, not a result to publish.
735
+ */
736
+ interface EqualKVerdict {
737
+ readonly withinTolerance: boolean;
738
+ /** Per-arm conserved cost (the basis: tokens total + usd). */
739
+ readonly arms: ReadonlyArray<{
740
+ readonly label: string;
741
+ readonly tokens: number;
742
+ readonly usd: number;
743
+ readonly iterations: number;
744
+ }>;
745
+ /** The realized spread on each channel (max − min across arms), for the report. */
746
+ readonly spread: {
747
+ readonly tokens: number;
748
+ readonly usd: number;
749
+ };
750
+ /** The fractional tolerance the check used (spread / median ≤ tolerance per channel). */
751
+ readonly tolerance: number;
752
+ }
753
+ /**
754
+ * `equalKOnCost(arms, { tolerance? })` — assert arms are comparable at EQUAL conserved COST
755
+ * (tokens + usd), NOT raw iteration count. The conserved-pool guarantees `Σk` equal by
756
+ * construction WITHIN one supervised run; this checks it ACROSS arms (separate runs) where the
757
+ * pool cannot, so a cross-arm gate comparison can prove equal compute before claiming a win. The
758
+ * impl lives in `trajectory.ts`. Pure over the reports — no I/O.
759
+ */
760
+ interface EqualKOnCostOptions {
761
+ /** Max fractional spread (spread/median) per channel for arms to count as equal-k. Default in
762
+ * the impl (e.g. 0.05). A tighter tolerance = a stricter equal-compute claim. */
763
+ readonly tolerance?: number;
764
+ }
765
+ /** `equalKOnCost(arms, opts)` — the cross-arm equal-compute check on conserved cost. */
766
+ type EqualKOnCost = (arms: ReadonlyArray<EqualKArm>, options?: EqualKOnCostOptions) => EqualKVerdict;
767
+
768
+ /**
769
+ * @experimental
770
+ *
771
+ * The completion-oracle: **settled ⟺ DELIVERED.**
772
+ *
773
+ * Foreman's one hard lesson (0/18 self-improvement deliverables) — "done" must mean a check
774
+ * PASSED, not the agent's say-so. `gateOnDeliverable` wraps an `Executor` so its settlement
775
+ * is `valid` ONLY when the deliverable check passes. The child still RUNS and settles (its
776
+ * spend is conserved into the pool either way), but a child that ran WITHOUT delivering
777
+ * settles `valid:false` — so a keep-best driver never counts it as done, and a gate never
778
+ * inflates with self-judged wins.
779
+ *
780
+ * Dual-purpose by construction:
781
+ * - product: the agent fleet only advances on real, checked deliverables.
782
+ * - proof: the gate's `valid` is the honest settle — equal-k comparisons can't be gamed by an
783
+ * arm that "ran" without producing the artifact.
784
+ *
785
+ * The check is a DEPLOYABLE oracle — a test command, a state verifier, the commit0 judge —
786
+ * read off the child's output, never the model judging itself. A throwing check is
787
+ * fail-closed (not delivered), never a crash.
788
+ */
789
+
790
+ interface DeliverableSpec<Out = unknown> {
791
+ /** The deployable check that decides DELIVERED. `settled.valid ⟺ this resolves true`. */
792
+ check: (out: Out) => boolean | Promise<boolean>;
793
+ /** What the spawn was supposed to produce — surfaced in traces/reports. */
794
+ describe?: string;
795
+ }
796
+ /**
797
+ * Wrap an `Executor` so its settlement `valid` reflects the deliverable check, not the
798
+ * inner verdict. Handles both `execute` shapes (one-shot `Promise<ExecutorResult>` and
799
+ * streaming `AsyncIterable<UsageEvent>` + `resultArtifact()`); the check runs once the inner
800
+ * executor has produced its output. The inner `score` is preserved; only `valid` is gated.
801
+ */
802
+ declare function gateOnDeliverable<Out>(inner: Executor<Out>, deliverable: DeliverableSpec<Out>): Executor<Out>;
803
+
804
+ /**
805
+ * @experimental
806
+ *
807
+ * The mechanical patch gate — the SINGLE source of the no-op / always-on secret-path floor /
808
+ * forbidden-path / diff-size / test / typecheck checks over a captured diff. No I/O: it scores a
809
+ * patch plus its already-derived test/typecheck PASS signals. The generic worktree-CLI deliverable
810
+ * (`patchDelivered`, which runs the commands itself) calls this, so the gate logic never forks.
811
+ *
812
+ * The always-on safety floors (no-op rejection + secret-path) are also exported standalone
813
+ * (`isNonEmptyPatch` / `touchesSecretPath`) for reuse outside the full scorer.
814
+ */
815
+
816
+ /** @experimental The patch + its derived PASS signals the mechanical gate decides on. */
817
+ interface CoderCheckInput {
818
+ /** The unified diff produced by the run. */
819
+ patch: string;
820
+ /** Did `testCmd` exit clean? */
821
+ testsPassed: boolean;
822
+ /** Did `typecheckCmd` exit clean? */
823
+ typecheckPassed: boolean;
824
+ }
825
+ /** @experimental The per-task constraints the mechanical gate enforces. */
826
+ interface CoderCheckConstraints {
827
+ /** Default 400. Hard cap; gate fails when exceeded. */
828
+ maxDiffLines?: number;
829
+ /** Literal path prefixes the patch must not touch. */
830
+ forbiddenPaths?: string[];
831
+ }
832
+ /** The unified-diff paths the patch touches — the `+++`/`---` headers, de-`a/`/`b/`-prefixed,
833
+ * with `/dev/null` (a delete's other side) dropped. */
834
+ declare function touchedPathsFromPatch(patch: string): string[];
835
+ /** Count the added/removed content lines in a unified diff (excludes the `+++`/`---` headers). */
836
+ declare function countDiffLines(patch: string): number;
837
+ /** True when the patch actually changes something — at least one touched path AND non-blank body.
838
+ * An empty patch can trivially "pass" tests/typecheck (nothing changed) yet does no work. */
839
+ declare function isNonEmptyPatch(patch: string): boolean;
840
+ /** The credential-shaped paths the patch touches (always-on floor, independent of `forbiddenPaths`). */
841
+ declare function touchesSecretPath(patch: string): string[];
842
+ /**
843
+ * @experimental
844
+ *
845
+ * The pure mechanical gate — the SINGLE source of the no-op / always-on secret-path floor /
846
+ * diff-size / forbidden-path / test / typecheck checks. No I/O: it scores a patch + its
847
+ * already-derived pass signals.
848
+ *
849
+ * Checks in order: (1) no-op rejection, (2) always-on secret-path floor (independent of
850
+ * `forbiddenPaths`), (3) forbidden-path, (4) diff-size cap, (5) tests, (6) typecheck.
851
+ * Aggregate score: `0.5*tests + 0.3*typecheck + 0.2*(1 - diffLines/maxDiff)`; `valid` is the
852
+ * conjunction of all six.
853
+ */
854
+ declare function runCoderChecks(input: CoderCheckInput, constraints?: CoderCheckConstraints): DefaultVerdict;
855
+
856
+ /**
857
+ * @experimental
858
+ *
859
+ * The ONE worktree-harness execution core. The physical act — run a supervisor-authored
860
+ * `AgentProfile` on a local coding-harness CLI (claude / codex / opencode) against a fresh git
861
+ * worktree off `repoRoot`, capture the diff, derive the test/typecheck PASS signals, then clean
862
+ * up — lives here ONCE. Two executors adapt it to two ports without re-implementing it:
863
+ * - `createWorktreeCliExecutor` — the `Scope`/`Supervisor` leaf `Executor`.
864
+ * - `createInProcessExecutor` — the `runLoop` `SandboxClient` / coder-delegate path.
865
+ *
866
+ * §1.5 by construction: the authored `profile.prompt.systemPrompt` + `profile.model.default`
867
+ * reach the harness through `harnessInvocation` HERE, so neither port can drop them — the exact
868
+ * bug that existed while the in-process path called `runLocalHarness` with only the task prompt.
869
+ *
870
+ * Lifecycle: `createWorktree` → `harnessInvocation` + `runLocalHarness` → `captureWorktreeDiff`
871
+ * (BEFORE checks, so the patch is the harness's output, not polluted by files a test run writes)
872
+ * → the configured test/typecheck commands in the live worktree → return the result + a `cleanup`
873
+ * the caller invokes at its own teardown point. A throw cleans up before propagating, so a failed
874
+ * run never leaks a worktree.
875
+ */
876
+
877
+ /** Outcome of one verification command run in the worktree (test or typecheck). */
878
+ interface WorktreeCommandResult {
879
+ /** The shell command line that was run. */
880
+ command: string;
881
+ /** Did the command exit 0? The PASS signal a deliverable gate / coder output reads. */
882
+ passed: boolean;
883
+ /** OS exit code, or `null` when killed before exit. */
884
+ exitCode: number | null;
885
+ /** Combined stdout+stderr (capped) — surfaced in traces for diagnosis. */
886
+ output: string;
887
+ }
888
+ /** The canonical result of one worktree-harness run, projected by each port to its own shape. */
889
+ interface WorktreeHarnessResult {
890
+ /** The branch the worktree was cut on (`delegate/<runId>`). */
891
+ branch: string;
892
+ /** `git diff` of the worktree against its base — the unified patch the harness produced. */
893
+ patch: string;
894
+ /** Shortstat-derived change counts. */
895
+ stats: {
896
+ filesChanged: number;
897
+ insertions: number;
898
+ deletions: number;
899
+ };
900
+ /** The harness subprocess outcome. */
901
+ harness: {
902
+ name: LocalHarness;
903
+ exitCode: number | null;
904
+ timedOut: boolean;
905
+ killedBySignal: NodeJS.Signals | null;
906
+ durationMs: number;
907
+ stdout: string;
908
+ stderr: string;
909
+ };
910
+ /** Verification signals derived in the live worktree (present only when commands were given). */
911
+ checks?: {
912
+ tests?: WorktreeCommandResult;
913
+ typecheck?: WorktreeCommandResult;
914
+ };
915
+ }
916
+ /** The single shell-command-in-worktree runner seam (replaces the per-executor copies). */
917
+ type WorktreeCheckRunner = (opts: {
918
+ command: string;
919
+ cwd: string;
920
+ timeoutMs: number;
921
+ signal?: AbortSignal;
922
+ }) => Promise<{
923
+ exitCode: number | null;
924
+ output: string;
925
+ }>;
926
+
927
+ /**
928
+ * @experimental
929
+ *
930
+ * The worktree-CLI leaf executor — a supervisor-authored `AgentProfile` driving a local
931
+ * coding-harness CLI (claude / codex / opencode) on its OWN git worktree, surfaced as the open
932
+ * `Executor<Out>` port (`./types`). It is a LEAF executor: it plugs straight into the
933
+ * `Scope`/`Supervisor` recursion and `gateOnDeliverable`, so it IS the canonical recursive path
934
+ * (no `runLoop`/virtual-SandboxInstance shim in between).
935
+ *
936
+ * This is a THIN adapter: the physical act (worktree → profile-aware harness invocation → diff →
937
+ * checks → cleanup) lives ONCE in `runWorktreeHarness` (`../../mcp/worktree-harness`), shared with
938
+ * the `runLoop`/coder-delegate `createInProcessExecutor`. This executor only projects that core's
939
+ * result onto the `Executor` port (artifact + spend) and owns the teardown point. The §1.5 payload
940
+ * (authored systemPrompt + model) reaches the harness inside the core, not here.
941
+ *
942
+ * Token accounting: a harness CLI does not surface usage, so this executor is `budgetExempt: true`
943
+ * — its spend is NOT metered against the conserved pool and its iterations are EXCLUDED from the
944
+ * equal-k arms by construction (mirrors `cliExecutor`).
945
+ */
946
+
947
+ /** Terminal artifact of one worktree-CLI run — the canonical worktree-harness result (the captured
948
+ * diff + the harness's run record + the derived checks). */
949
+ type WorktreePatchArtifact = WorktreeHarnessResult;
950
+ /** @experimental */
951
+ interface WorktreeCliExecutorOptions {
952
+ /** Absolute path to the git checkout the worktree is cut from. */
953
+ repoRoot: string;
954
+ /** The SUPERVISOR-AUTHORED profile (the §1.5 payload: systemPrompt + model). */
955
+ profile: AgentProfile;
956
+ /** Which local harness CLI drives this leaf (`claude` | `codex` | `opencode`). */
957
+ harness: LocalHarness;
958
+ /** The per-task instruction handed to the harness (composed under the system prompt). */
959
+ taskPrompt: string;
960
+ /** Unique id for the worktree path + branch. Defaults to a fresh UUID. */
961
+ runId?: string;
962
+ /** Override the base ref the worktree is cut from (default `HEAD`). */
963
+ baseRef?: string;
964
+ /** Wall-clock cap per harness subprocess (ms). Default 5 min (the `runLocalHarness` default). */
965
+ harnessTimeoutMs?: number;
966
+ /**
967
+ * Shell command run in the live worktree to derive the tests-PASS signal (e.g. `pnpm test`).
968
+ * Its exit code becomes `artifact.checks.tests.passed`. Omit to skip (no signal derived).
969
+ */
970
+ testCmd?: string;
971
+ /** Shell command run in the live worktree to derive the typecheck-PASS signal (e.g. `pnpm typecheck`). */
972
+ typecheckCmd?: string;
973
+ /** Wall-clock cap per verification command (ms). Default = `harnessTimeoutMs` or 5 min. */
974
+ checkTimeoutMs?: number;
975
+ /** Test seam — inject a git runner so unit tests drive the worktree helpers without git. */
976
+ runGit?: GitRunner;
977
+ /** Test seam — inject the harness runner so unit tests script a `LocalHarnessResult`. */
978
+ runHarness?: typeof runLocalHarness;
979
+ /** Test seam — inject the verification-command runner so unit tests script test/typecheck
980
+ * outcomes without spawning a real shell. Defaults to a `/bin/sh -c` spawn in the worktree. */
981
+ runCommand?: WorktreeCheckRunner;
982
+ }
983
+ /**
984
+ * Build a worktree-CLI leaf `Executor`. Per-spawn (a fresh worktree + abort + teardown each), so a
985
+ * fanout of N profiles = N parallel worktrees that never clobber each other.
986
+ *
987
+ * Fail-loud: an empty `repoRoot`/`harness`/`taskPrompt` throws at construction. `resultArtifact()`
988
+ * before `execute()` resolves throws.
989
+ *
990
+ * @experimental
991
+ */
992
+ declare function createWorktreeCliExecutor(options: WorktreeCliExecutorOptions): Executor<WorktreePatchArtifact>;
993
+
994
+ /**
995
+ * @experimental
996
+ *
997
+ * `patchDelivered` — the mechanical patch gate as a generic `DeliverableSpec` over the worktree-CLI
998
+ * artifact. It is one construction of a `DeliverableSpec` (a plain `check(artifact) => boolean`
999
+ * function); a domain customizes "is it done" by building its own spec, not by extending this one.
1000
+ * The canonical use: a `fanout(createWorktreeCliExecutor)` of authored harness profiles, each
1001
+ * `gateOnDeliverable(patchDelivered(...))`.
1002
+ *
1003
+ * The checks themselves are NOT re-implemented here — `runCoderChecks` (`./patch-checks`) is the
1004
+ * single source of the no-op / always-on secret-path floor / forbidden-path / diff-size / test /
1005
+ * typecheck logic. This factory only adapts the `WorktreePatchArtifact` shape (its `checks` carry
1006
+ * the test/typecheck PASS signals the executor derived in the live worktree) into the check inputs
1007
+ * and returns the boolean the gate consumes.
1008
+ *
1009
+ * Test/typecheck enforcement is OPT-IN per `require`: when a command was not run in the worktree
1010
+ * (the executor's `testCmd`/`typecheckCmd` were omitted) the corresponding signal is treated as
1011
+ * passed UNLESS `require` lists it — so a gate that demands a tests-pass on an artifact that never
1012
+ * ran tests fails closed (the honest outcome) rather than passing on a missing signal.
1013
+ */
1014
+
1015
+ /** @experimental */
1016
+ interface PatchDeliverableOptions extends CoderCheckConstraints {
1017
+ /**
1018
+ * Which verification signals the gate REQUIRES to be present-and-passing. A required signal
1019
+ * that the artifact never derived (the command was not configured on the executor) fails the
1020
+ * gate closed. Unlisted signals default to passed-when-absent (the executor simply didn't run
1021
+ * that command). Default `[]` — gate on no-op / secret / forbidden / diff-size only.
1022
+ */
1023
+ require?: ReadonlyArray<'tests' | 'typecheck'>;
1024
+ }
1025
+ /**
1026
+ * Build the `DeliverableSpec<WorktreePatchArtifact>`: `check(artifact)` runs the shared mechanical
1027
+ * gate (`runCoderChecks`) over the captured patch + the worktree-derived pass signals and returns
1028
+ * whether the patch is DELIVERED (the `valid` conjunction).
1029
+ *
1030
+ * @experimental
1031
+ */
1032
+ declare function patchDelivered(options?: PatchDeliverableOptions): DeliverableSpec<WorktreePatchArtifact>;
1033
+
1034
+ /**
1035
+ * @experimental
1036
+ *
1037
+ * `worktreeFanout` — the GENERIC coding combinator: a `fanout` of N supervisor-authored harness
1038
+ * profiles, each on its OWN worktree-CLI leaf, each `gateOnDeliverable(deliverable)`, winner via the
1039
+ * shared `selectValidWinner` (valid-only — an ungated patch never wins, the deliverable gate is the
1040
+ * point). The `deliverable` is passed as DATA: it defaults to `patchDelivered(opts)` but any
1041
+ * `DeliverableSpec<WorktreePatchArtifact>` a domain authors slots in unchanged.
1042
+ *
1043
+ * The shape is content-free at the `fanout` layer; this builder only assembles the pieces (the
1044
+ * worktree-CLI executor + the injected deliverable + the diff-size selector) into the generic
1045
+ * combinator's `itemSpec`/`selectWinner` seams. Nothing here re-implements selection, gating, or
1046
+ * fanout — it composes the existing primitives.
1047
+ */
1048
+
1049
+ /** @experimental One authored harness profile in a worktree fanout: the §1.5 profile + which local
1050
+ * harness CLI drives it. The supervisor authors `profile` per sub-task; `harness` chooses the leaf. */
1051
+ interface AuthoredHarness {
1052
+ /** A short label for the worktree branch + trace node. */
1053
+ name: string;
1054
+ /** The supervisor-authored `AgentProfile` (systemPrompt + model reach the harness via §1.5). */
1055
+ profile: AgentProfile;
1056
+ /** Which local harness CLI drives this leaf. */
1057
+ harness: 'claude' | 'codex' | 'opencode';
1058
+ /** Per-harness model/runId/baseRef overrides flow through the profile + these. */
1059
+ runId?: string;
1060
+ baseRef?: string;
1061
+ }
1062
+ /** @experimental */
1063
+ interface WorktreeFanoutOptions extends PatchDeliverableOptions {
1064
+ /** Absolute path to the git checkout each worktree is cut from. */
1065
+ repoRoot: string;
1066
+ /** The per-task instruction handed to every harness (composed under each profile's systemPrompt). */
1067
+ taskPrompt: string;
1068
+ /** The authored harness profiles — one fanout item (and one worktree-CLI leaf) each. */
1069
+ harnesses: ReadonlyArray<AuthoredHarness>;
1070
+ /**
1071
+ * The completion check each leaf is gated on. Defaults to `patchDelivered(opts)` (the mechanical
1072
+ * no-op/secret/forbidden/diff-size + required test/typecheck gate). Pass any
1073
+ * `DeliverableSpec<WorktreePatchArtifact>` to customize "is it delivered" as DATA.
1074
+ */
1075
+ deliverable?: DeliverableSpec<WorktreePatchArtifact>;
1076
+ /** Shell command run in each worktree to derive the tests-PASS signal. */
1077
+ testCmd?: string;
1078
+ /** Shell command run in each worktree to derive the typecheck-PASS signal. */
1079
+ typecheckCmd?: string;
1080
+ /** Wall-clock cap per harness subprocess (ms). */
1081
+ harnessTimeoutMs?: number;
1082
+ /** Winner-selection strategy. Default `highest-score`. */
1083
+ winnerStrategy?: WinnerStrategy;
1084
+ /** Test seams forwarded to every worktree-CLI leaf (inject git/harness/command runners so the
1085
+ * whole fanout runs offline). Production callers leave these unset. */
1086
+ runGit?: WorktreeCliExecutorOptions['runGit'];
1087
+ runHarness?: WorktreeCliExecutorOptions['runHarness'];
1088
+ runCommand?: WorktreeCliExecutorOptions['runCommand'];
1089
+ }
1090
+ /**
1091
+ * Build the worktree fanout combinator. Run it with `runPersonified({ persona, shape, task, budget })`
1092
+ * — equal-k holds by construction (the conserved budget pool bounds the N leaves), and selection is
1093
+ * the shared valid-only `selectValidWinner` (never a judge).
1094
+ *
1095
+ * @experimental
1096
+ */
1097
+ declare function worktreeFanout<Task>(options: WorktreeFanoutOptions): CombinatorShape<Task, WorktreePatchArtifact>;
1098
+
1099
+ export { type TrajectoryNode as $, type AuthoredHarness as A, type FlatWidenGate as B, type CorpusRecord as C, type DefinePersonaInput as D, type EqualKArm as E, type FanoutOptions as F, type LoopUntil as G, type LoopUntilState as H, type Panel as I, type PanelJudge as J, type PanelVerdict as K, type LoopUntilSpec as L, type PatchDeliverableOptions as M, type PersonaContext as N, type Outcome as O, type PanelSpec as P, type PersonaExecutors as Q, type RenderCorpusToInstructionsOptions as R, type ScopeAnalyzeInput as S, type TrajectoryReportOptions as T, type Pipeline as U, type VerifySpec as V, type WinnerStrategy as W, type RenderCorpusToInstructions as X, type RunPersonified as Y, type ShapeBudget as Z, type ShapeContext as _, type WorktreeFanoutOptions as a, type TrajectoryReportFn as a0, type Verify as a1, type Widen as a2, type WidenDecision as a3, type WidenLineage as a4, type WorktreeCliExecutorOptions as a5, type WorktreeCommandResult as a6, countDiffLines as a7, createWorktreeCliExecutor as a8, gateOnDeliverable as a9, isNonEmptyPatch as aa, patchDelivered as ab, runCoderChecks as ac, touchedPathsFromPatch as ad, touchesSecretPath as ae, worktreeFanout as af, type WorktreePatchArtifact as b, type Corpus as c, type AssertTraceDerivedFindings as d, type SteerContext as e, type ScopeAnalyst as f, type CombinatorShape as g, type ScopeWidenGate as h, type PipelineStage as i, type FanoutWinnerSelector as j, type WidenSpec as k, type CorpusFilter as l, type Persona as m, type RunPersonifiedOptions as n, type ShapeRegistry as o, type LoopShape as p, type EqualKOnCostOptions as q, type EqualKVerdict as r, type TrajectoryReport as s, type DeliverableSpec as t, type CoderCheckConstraints as u, type CoderCheckInput as v, type DefinePersona as w, type EqualKOnCost as x, type Fanout as y, type FanoutSynthesis as z };