owenloop 0.5.0 → 0.5.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 (229) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +144 -35
  3. package/bin/owenloop.mjs +49 -1
  4. package/dist/packages/work/src/agent/brief.d.ts +29 -4
  5. package/dist/packages/work/src/agent/brief.js +49 -4
  6. package/dist/packages/work/src/agent/capability-model.d.ts +123 -0
  7. package/dist/packages/work/src/agent/capability-model.js +148 -0
  8. package/dist/packages/work/src/agent/loop.d.ts +56 -7
  9. package/dist/packages/work/src/agent/loop.js +166 -9
  10. package/dist/packages/work/src/bundle/cache.d.ts +7 -5
  11. package/dist/packages/work/src/bundle/cache.js +20 -6
  12. package/dist/packages/work/src/bundle/fetch.d.ts +7 -5
  13. package/dist/packages/work/src/bundle/fetch.js +27 -7
  14. package/dist/packages/work/src/bundle/types.d.ts +8 -4
  15. package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
  16. package/dist/packages/work/src/consumed-verifier.js +205 -0
  17. package/dist/packages/work/src/exec/instructions.d.ts +99 -0
  18. package/dist/packages/work/src/exec/instructions.js +323 -0
  19. package/dist/packages/work/src/exec/loop.d.ts +29 -1
  20. package/dist/packages/work/src/exec/loop.js +313 -35
  21. package/dist/packages/work/src/exec/payload.d.ts +29 -0
  22. package/dist/packages/work/src/exec/payload.js +54 -0
  23. package/dist/packages/work/src/exec/receipt.d.ts +9 -6
  24. package/dist/packages/work/src/exec/receipt.js +12 -1
  25. package/dist/packages/work/src/exec/runner.d.ts +7 -1
  26. package/dist/packages/work/src/exec/runner.js +84 -3
  27. package/dist/packages/work/src/harness/child-env.js +7 -0
  28. package/dist/packages/work/src/harness/claude.d.ts +20 -8
  29. package/dist/packages/work/src/harness/claude.js +260 -58
  30. package/dist/packages/work/src/harness/codex.d.ts +5 -4
  31. package/dist/packages/work/src/harness/codex.js +169 -41
  32. package/dist/packages/work/src/harness/contract.d.ts +36 -11
  33. package/dist/packages/work/src/harness/fake.js +1 -0
  34. package/dist/packages/work/src/harness/jsonrpc-stdio.js +7 -0
  35. package/dist/packages/work/src/harness/permissions.d.ts +16 -3
  36. package/dist/packages/work/src/harness/permissions.js +102 -13
  37. package/dist/packages/work/src/harness/session-store.d.ts +30 -10
  38. package/dist/packages/work/src/harness/session-store.js +317 -89
  39. package/dist/packages/work/src/hold/mcp.d.ts +25 -5
  40. package/dist/packages/work/src/hold/mcp.js +134 -12
  41. package/dist/packages/work/src/hub/client.d.ts +8 -1
  42. package/dist/packages/work/src/hub/client.js +15 -1
  43. package/dist/packages/work/src/hub/types.d.ts +137 -33
  44. package/dist/packages/work/src/hub/types.js +8 -10
  45. package/dist/packages/work/src/mcp/server.js +1 -1
  46. package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
  47. package/dist/packages/work/src/owenloop-bin.js +18 -0
  48. package/dist/packages/work/src/roles/agent-run.d.ts +12 -6
  49. package/dist/packages/work/src/roles/agent-run.js +115 -34
  50. package/dist/packages/work/src/roles/exec.d.ts +8 -0
  51. package/dist/packages/work/src/roles/exec.js +27 -2
  52. package/dist/packages/work/src/roles/hold.d.ts +6 -0
  53. package/dist/packages/work/src/roles/hold.js +83 -13
  54. package/dist/packages/work/src/roles/lint.d.ts +3 -4
  55. package/dist/packages/work/src/roles/lint.js +41 -7
  56. package/dist/packages/work/src/roles/settings.js +19 -2
  57. package/dist/packages/work/src/roles/shift.d.ts +1 -0
  58. package/dist/packages/work/src/roles/shift.js +36 -2
  59. package/dist/packages/work/src/settings/settings.d.ts +70 -1
  60. package/dist/packages/work/src/settings/settings.js +90 -4
  61. package/dist/packages/work/src/shift/logretention.d.ts +253 -0
  62. package/dist/packages/work/src/shift/logretention.js +407 -0
  63. package/dist/packages/work/src/shift/logsink.d.ts +14 -0
  64. package/dist/packages/work/src/shift/logsink.js +98 -0
  65. package/dist/packages/work/src/shift/loop.d.ts +32 -4
  66. package/dist/packages/work/src/shift/loop.js +687 -166
  67. package/dist/packages/work/src/shift/protocol.d.ts +128 -1
  68. package/dist/packages/work/src/shift/protocol.js +14 -0
  69. package/dist/packages/work/src/shift/runtime.d.ts +16 -0
  70. package/dist/packages/work/src/shift/runtime.js +291 -5
  71. package/dist/packages/work/src/shift/server.d.ts +13 -0
  72. package/dist/packages/work/src/shift/server.js +61 -36
  73. package/dist/packages/work/src/shift/spawn.d.ts +115 -19
  74. package/dist/packages/work/src/shift/spawn.js +234 -30
  75. package/dist/packages/work/src/shift/state.d.ts +76 -49
  76. package/dist/packages/work/src/shift/state.js +350 -103
  77. package/dist/packages/work/src/shift/truncate.d.ts +35 -0
  78. package/dist/packages/work/src/shift/truncate.js +73 -0
  79. package/dist/packages/work/src/submit-proof.d.ts +61 -0
  80. package/dist/packages/work/src/submit-proof.js +119 -0
  81. package/dist/packages/work/src/submit-value.d.ts +48 -0
  82. package/dist/packages/work/src/submit-value.js +118 -0
  83. package/dist/packages/work/src/usage.d.ts +1 -1
  84. package/dist/packages/work/src/usage.js +11 -0
  85. package/dist/src/add.d.ts +64 -259
  86. package/dist/src/add.js +81 -615
  87. package/dist/src/archive.d.ts +97 -0
  88. package/dist/src/archive.js +591 -0
  89. package/dist/src/bundle/index.d.ts +64 -0
  90. package/dist/src/bundle/index.js +508 -0
  91. package/dist/src/bundle/manifest.d.ts +50 -0
  92. package/dist/src/bundle/manifest.js +435 -0
  93. package/dist/src/bundle/runtime.d.ts +26 -0
  94. package/dist/src/bundle/runtime.js +64 -0
  95. package/dist/src/bundle/tar.d.ts +62 -0
  96. package/dist/src/bundle/tar.js +238 -0
  97. package/dist/src/bundle/types.d.ts +105 -0
  98. package/dist/src/bundle/types.js +21 -0
  99. package/dist/src/capabilities.d.ts +93 -0
  100. package/dist/src/capabilities.js +101 -0
  101. package/dist/src/cli.d.ts +90 -20
  102. package/dist/src/cli.js +2421 -374
  103. package/dist/src/credentials.d.ts +4 -3
  104. package/dist/src/credentials.js +21 -19
  105. package/dist/src/crypto/allowed-signers.d.ts +68 -0
  106. package/dist/src/crypto/allowed-signers.js +307 -0
  107. package/dist/src/crypto/canonical.d.ts +8 -0
  108. package/dist/src/crypto/canonical.js +92 -0
  109. package/dist/src/crypto/chain.d.ts +65 -0
  110. package/dist/src/crypto/chain.js +377 -0
  111. package/dist/src/crypto/dsse.d.ts +209 -0
  112. package/dist/src/crypto/dsse.js +282 -0
  113. package/dist/src/crypto/enrollment.d.ts +78 -0
  114. package/dist/src/crypto/enrollment.js +186 -0
  115. package/dist/src/crypto/index.d.ts +48 -0
  116. package/dist/src/crypto/index.js +44 -0
  117. package/dist/src/crypto/keys.d.ts +258 -0
  118. package/dist/src/crypto/keys.js +908 -0
  119. package/dist/src/crypto/org-root.d.ts +33 -0
  120. package/dist/src/crypto/org-root.js +78 -0
  121. package/dist/src/crypto/origin-rules.d.ts +56 -0
  122. package/dist/src/crypto/origin-rules.js +143 -0
  123. package/dist/src/crypto/policy-floor.d.ts +98 -0
  124. package/dist/src/crypto/policy-floor.js +353 -0
  125. package/dist/src/crypto/records.d.ts +319 -0
  126. package/dist/src/crypto/records.js +168 -0
  127. package/dist/src/crypto/scope.d.ts +49 -0
  128. package/dist/src/crypto/scope.js +83 -0
  129. package/dist/src/crypto/ssh.d.ts +171 -0
  130. package/dist/src/crypto/ssh.js +396 -0
  131. package/dist/src/crypto/submission.d.ts +33 -0
  132. package/dist/src/crypto/submission.js +47 -0
  133. package/dist/src/crypto/trust-roots.d.ts +29 -0
  134. package/dist/src/crypto/trust-roots.js +39 -0
  135. package/dist/src/crypto/verify-consumed.d.ts +67 -0
  136. package/dist/src/crypto/verify-consumed.js +259 -0
  137. package/dist/src/crypto/verify-origin.d.ts +50 -0
  138. package/dist/src/crypto/verify-origin.js +151 -0
  139. package/dist/src/crypto/verify-publication.d.ts +60 -0
  140. package/dist/src/crypto/verify-publication.js +150 -0
  141. package/dist/src/defs.d.ts +24 -1
  142. package/dist/src/defs.js +335 -27
  143. package/dist/src/engine.d.ts +211 -6
  144. package/dist/src/engine.js +459 -59
  145. package/dist/src/factory.d.ts +16 -0
  146. package/dist/src/factory.js +16 -4
  147. package/dist/src/global-config.d.ts +59 -0
  148. package/dist/src/global-config.js +84 -0
  149. package/dist/src/hub.d.ts +102 -32
  150. package/dist/src/hub.js +147 -58
  151. package/dist/src/index.d.ts +19 -2
  152. package/dist/src/index.js +23 -2
  153. package/dist/src/install.d.ts +538 -0
  154. package/dist/src/install.js +1981 -0
  155. package/dist/src/lock.d.ts +15 -57
  156. package/dist/src/lock.js +251 -143
  157. package/dist/src/mcp/serve.d.ts +46 -22
  158. package/dist/src/mcp/serve.js +174 -44
  159. package/dist/src/mcp/server.js +12 -1
  160. package/dist/src/model.d.ts +51 -0
  161. package/dist/src/model.js +157 -1
  162. package/dist/src/order-resolver.d.ts +184 -0
  163. package/dist/src/order-resolver.js +252 -0
  164. package/dist/src/package-version.d.ts +10 -0
  165. package/dist/src/package-version.js +42 -0
  166. package/dist/src/paths.d.ts +14 -1
  167. package/dist/src/paths.js +18 -0
  168. package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
  169. package/dist/src/schemas/index.d.ts +1433 -0
  170. package/dist/src/schemas/index.js +31 -0
  171. package/dist/src/schemas/order.v1.schema.json +120 -0
  172. package/dist/src/schemas/origin.v1.schema.json +68 -0
  173. package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
  174. package/dist/src/schemas/publication.v1.schema.json +31 -0
  175. package/dist/src/schemas/revocation.v1.schema.json +39 -0
  176. package/dist/src/schemas/submission.v1.schema.json +61 -0
  177. package/dist/src/store/def-source.d.ts +52 -0
  178. package/dist/src/store/def-source.js +335 -0
  179. package/dist/src/store/index-file.d.ts +69 -0
  180. package/dist/src/store/index-file.js +151 -0
  181. package/dist/src/store/index.d.ts +27 -0
  182. package/dist/src/store/index.js +22 -0
  183. package/dist/src/store/ingestor.d.ts +43 -0
  184. package/dist/src/store/ingestor.js +211 -0
  185. package/dist/src/store/install.d.ts +228 -0
  186. package/dist/src/store/install.js +555 -0
  187. package/dist/src/store/instruction-source.d.ts +49 -0
  188. package/dist/src/store/instruction-source.js +298 -0
  189. package/dist/src/store/origin-evidence.d.ts +21 -0
  190. package/dist/src/store/origin-evidence.js +66 -0
  191. package/dist/src/store/pre-commit-verifier.d.ts +68 -0
  192. package/dist/src/store/pre-commit-verifier.js +418 -0
  193. package/dist/src/store/resolve.d.ts +138 -0
  194. package/dist/src/store/resolve.js +363 -0
  195. package/dist/src/store/types.d.ts +288 -0
  196. package/dist/src/store/types.js +356 -0
  197. package/dist/src/store.d.ts +33 -1
  198. package/dist/src/store.js +57 -4
  199. package/dist/src/types.d.ts +146 -12
  200. package/dist/src/untar.d.ts +8 -23
  201. package/dist/src/untar.js +10 -136
  202. package/docs/agent-runner.md +86 -0
  203. package/docs/authoring.md +64 -6
  204. package/docs/bundles.md +350 -0
  205. package/docs/cli.md +1298 -106
  206. package/docs/crypto.md +832 -0
  207. package/docs/design.md +342 -20
  208. package/docs/embedding.md +132 -25
  209. package/docs/shift-logs.md +642 -0
  210. package/docs/wire-contracts.md +395 -0
  211. package/package.json +6 -1
  212. package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
  213. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
  214. package/plugins/claude-code/plugin/.mcp.json +14 -0
  215. package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
  216. package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
  217. package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
  218. package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
  219. package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
  220. package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
  221. package/plugins/codex/.agents/plugins/marketplace.json +21 -0
  222. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
  223. package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
  224. package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
  225. package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
  226. package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
  227. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
  228. package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
  229. package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
@@ -11,8 +11,11 @@
11
11
  */
12
12
  import type { WorkflowStatus } from './model.ts';
13
13
  import type { SchemaIssue } from './schema.ts';
14
+ import type { MatchMode } from './capabilities.ts';
14
15
  import type { Store } from './store.ts';
15
16
  import type { Author, Fingerprint, Order, WorkflowDef } from './types.ts';
17
+ import { OrderResolver } from './order-resolver.ts';
18
+ import type { OrderInstructionSource, ResolvedInstructions } from './order-resolver.ts';
16
19
  export type { Order } from './types.ts';
17
20
  /**
18
21
  * F2: a typed refusal for a produced-value/input-value schema mismatch, thrown
@@ -38,6 +41,24 @@ export declare class SchemaRefusalError extends Error {
38
41
  gateFingerprint?: Fingerprint;
39
42
  constructor(inputName: string, issues: SchemaIssue[]);
40
43
  }
44
+ /**
45
+ * WS-6: a `calls:` step resolved to a child definition that is NOT the one the
46
+ * parent's own bundle pinned. Thrown from inside `provisionCallsChild`'s
47
+ * transaction, so the whole provisioning tx rolls back — no child row, no
48
+ * partial input sync — and `maintainCalls` converts it into a visible debt on
49
+ * the parent's `calls:` artifact (see `recordCallsDigestReject`). The failure
50
+ * mode this prevents is silent: without it, a newer install of the same package
51
+ * would let a running parent spawn a DIFFERENT workflow body than the one it was
52
+ * pinned against, and nothing would say so.
53
+ */
54
+ export declare class CallsPinError extends Error {
55
+ readonly name = "CallsPinError";
56
+ /** The `calls:` target text exactly as the parent def wrote it. */
57
+ readonly target: string;
58
+ /** Human-readable statement of which pin was violated and how. */
59
+ readonly detail: string;
60
+ constructor(target: string, detail: string);
61
+ }
41
62
  /**
42
63
  * §tick-deferred: an eligible firing the tick did NOT promote to an order, tagged
43
64
  * with why. `'in-flight'` — the step's task is already claimed by an open run;
@@ -47,9 +68,11 @@ export declare class SchemaRefusalError extends Error {
47
68
  * `applySchedule` or `tick`; never alters which firings are selected or claimed.
48
69
  * `'capability-mismatch'` (A2) — the tick caller passed a capability filter that does not
49
70
  * intersect the step's declared capabilities, so a peer orchestrator serving other
50
- * capabilities leaves it for the matching caller.
71
+ * capabilities leaves it for the matching caller; `'workdir-unresolved'` — a
72
+ * workdirFrom path in a consumed artifact was missing, non-object, or not a
73
+ * non-empty string, so no order or run was emitted.
51
74
  */
52
- export type DeferredReason = 'in-flight' | 'cadence' | 'daily-budget' | 'parallel-cap' | 'capability-mismatch';
75
+ export type DeferredReason = 'in-flight' | 'cadence' | 'daily-budget' | 'parallel-cap' | 'capability-mismatch' | 'workdir-unresolved';
53
76
  export interface DeferredFiring {
54
77
  step: string;
55
78
  key: string;
@@ -57,6 +80,8 @@ export interface DeferredFiring {
57
80
  inputs: string[];
58
81
  outputs: string[];
59
82
  reason: DeferredReason;
83
+ /** Readable detail for deferrals whose reason alone is not actionable. */
84
+ detail?: string;
60
85
  /**
61
86
  * §23.6.8 deep tick: which instance this deferred firing belongs to.
62
87
  * Convention — **absent = the ticked ROOT instance; present = the named
@@ -133,8 +158,44 @@ export interface CreateOpts {
133
158
  parentWf: string;
134
159
  parentPath: string;
135
160
  };
161
+ /**
162
+ * The ONE routing modifier this instance carries for its whole life. Must be
163
+ * a member of the def's declared `modifiers` set — `createInstance` throws
164
+ * {@link ModifierRefusalError} otherwise, rather than starting a run that
165
+ * would compose capabilities no crew was ever bound to.
166
+ *
167
+ * Absent = an unmodified run: every step is offered on bare capabilities.
168
+ * Never mutated after creation; an escalated re-offer carries its own target
169
+ * modifier per-offer without rewriting this.
170
+ */
171
+ modifier?: string;
136
172
  }
137
- export type DefResolver = (defName: string) => WorkflowDef;
173
+ /**
174
+ * Thrown by `createInstance` when the requested modifier is not in the def's
175
+ * declared `modifiers` set (including the case of a def that declares none).
176
+ * Its own class so the hub can map it to a 400 instead of an opaque 500 —
177
+ * this is a caller mistake, not an engine fault.
178
+ */
179
+ export declare class ModifierRefusalError extends Error {
180
+ readonly defName: string;
181
+ readonly modifier: string;
182
+ /** The def's declared modifier set — empty when the def declares none. */
183
+ readonly declared: string[];
184
+ constructor(defName: string, modifier: string, declared: string[]);
185
+ }
186
+ /**
187
+ * Map a definition name to its `WorkflowDef`, or throw if there is none.
188
+ *
189
+ * WS-6 widened this with an OPTIONAL second parameter. `from` is the def that
190
+ * NAMED `defName` — supplied only by the `calls:` spawn path, where the naming
191
+ * def's own CAS bundle scope decides which `defName` a bare reference means (a
192
+ * bare `calls: build` inside bundle A must reach bundle A's `build`, never an
193
+ * unrelated `build` from bundle B). Because the parameter is optional, every
194
+ * existing single-argument resolver — including a host's hand-written one —
195
+ * keeps today's exact behavior with no change: a resolver that ignores `from`
196
+ * simply performs the flat lookup it always did.
197
+ */
198
+ export type DefResolver = (defName: string, from?: WorkflowDef) => WorkflowDef;
138
199
  /**
139
200
  * A push notification of a committed engine change, delivered to observers
140
201
  * registered via {@link Engine.subscribe}. Lets an in-process host react the
@@ -198,6 +259,15 @@ export interface ReapDetail {
198
259
  export declare class Engine {
199
260
  readonly store: Store;
200
261
  private readonly resolveDef;
262
+ /**
263
+ * The reference-mode instruction boundary (WP-B1): where an order's
264
+ * `defDigest` turns back into exact authored instructions. Injected when a
265
+ * host supplies a WP-A3-compatible source; otherwise a loaded-definition
266
+ * adapter that still emits and resolves reference orders (not a
267
+ * compatibility mode). Public read-only facade: {@link Engine.resolver}.
268
+ */
269
+ private readonly instructionSource;
270
+ readonly resolver: OrderResolver;
201
271
  private readonly reapTtlMs;
202
272
  private readonly maxLeaseMs;
203
273
  private readonly maxCallDepth;
@@ -221,6 +291,14 @@ export declare class Engine {
221
291
  onEvent?: EngineListener;
222
292
  /** Where a throwing listener's error goes (default: swallowed). */
223
293
  onListenerError?: (err: unknown, event: EngineEvent) => void;
294
+ /**
295
+ * WP-A3-compatible digest/instruction source (WP-B1 seam). When
296
+ * supplied, `buildOrder` takes definition digests from it and
297
+ * resolution reads its verified records; when absent, the engine
298
+ * builds a loaded-definition adapter (same reference-mode behavior,
299
+ * no legacy fallback).
300
+ */
301
+ instructionSource?: OrderInstructionSource;
224
302
  });
225
303
  /**
226
304
  * Register a synchronous observer of engine changes; returns an idempotent
@@ -367,6 +445,28 @@ export declare class Engine {
367
445
  * depth refusal anyway (identical outcome, no lost valid update to strand).
368
446
  */
369
447
  private recordCallsDepthReject;
448
+ /**
449
+ * WS-6: record a `calls:` PIN violation as a debt on the PARENT calls
450
+ * artifact. Same clean-stop mechanism as `recordCallsDepthReject` — mark the
451
+ * artifact `rejected` and stamp the current gate fingerprint so the STEP-2 F2
452
+ * guard skips re-attempts instead of crash-looping the same refusal every
453
+ * tick — with a different, actionable message.
454
+ *
455
+ * Kept as its OWN recorder rather than folded into `recordCallsDepthReject`:
456
+ * the two refusals differ in what they mean (a depth trip says the definition
457
+ * set has a cycle that bypassed load-time validation; a pin violation says the
458
+ * installed store no longer holds the version this parent was pinned against)
459
+ * and therefore in what an operator should do next. Merging them into one
460
+ * parameterized recorder would blur exactly the distinction the message exists
461
+ * to carry.
462
+ *
463
+ * Like the depth recorder, this one needs NO carry-and-compare gate guard: a
464
+ * pin violation is decided from immutable provenance (the parent's §28 pinned
465
+ * snapshot and the resolved child's bundle digest), not from the gate
466
+ * snapshot, so a refusal decided at time T stays valid at recording time no
467
+ * matter what moved concurrently.
468
+ */
469
+ private recordCallsDigestReject;
370
470
  /**
371
471
  * M2B: Maintain all `calls:` steps for a parent workflow.
372
472
  * Called at the top of tick (outside any tx) and as cascade-up prompt.
@@ -428,7 +528,23 @@ export declare class Engine {
428
528
  tick(workflow: string, opts?: {
429
529
  now?: number;
430
530
  deep?: boolean;
531
+ /**
532
+ * The claiming crew's capabilities. OMITTING this is not the same as
533
+ * passing `[]`: omitted means "no filter presented" (a local operator or
534
+ * test driver — everything matches, as before capabilities existed),
535
+ * while `[]` means a crew that serves nothing and therefore matches only
536
+ * capability-silent steps. See `claimMatches`.
537
+ */
431
538
  capabilities?: string[];
539
+ /**
540
+ * Per-offered-capability claim mode, keyed by the COMPOSED capability
541
+ * (`wise:deep`), supplied by the caller that can see crew bindings — the
542
+ * hub. Any capability absent from the map is matched by name part
543
+ * (`DEFAULT_MATCH_MODE`), which is what a caller with no binding
544
+ * knowledge should get: the permissive tier. The pure engine never
545
+ * decides a mode, it only enforces the one it is handed.
546
+ */
547
+ matchModes?: Record<string, MatchMode>;
432
548
  }): TickResult;
433
549
  /**
434
550
  * The recursive tick worker. Runs this instance's own maintain → reap →
@@ -501,11 +617,23 @@ export declare class Engine {
501
617
  private callsDescendTargets;
502
618
  /**
503
619
  * Per-step cadence + daily budget + parallel cap over the eligible firings.
504
- * A2: `capabilities` is the tick caller's optional claim filter — when non-empty, a
505
- * step whose own `capabilities` are also non-empty is only schedulable when the two
506
- * intersect; a disjoint step's firings are deferred as `'capability-mismatch'`.
620
+ *
621
+ * A2: `capabilities` is the tick caller's claim filter, matched against the
622
+ * step's OFFERED capabilities — the authored list composed with the modifier
623
+ * this firing will actually be offered under (`wise` + `deep` → `wise:deep`),
624
+ * which is the same list the order will carry. `claimMatches` owns the rule;
625
+ * see it for the four cases (no filter presented, capability-silent step,
626
+ * empty caller list, both non-empty) and for what `matchModes` changes.
627
+ * A firing this caller may not claim is deferred as `'capability-mismatch'`.
507
628
  * Filtering here (before cadence/budget) means a mismatched firing never
508
629
  * consumes the caller's slots and never perturbs cadence math.
630
+ *
631
+ * The filter is per FIRING, not per step, because §7 escalation is per firing:
632
+ * on a map step one element may have escalated to `build:deep` while its
633
+ * siblings are still offered at `build:standard`, and a crew bound to only one
634
+ * of those must be judged against the compound its own firing carries. With no
635
+ * escalation authored every firing of a step composes identically, so this
636
+ * behaves exactly as a per-step filter would.
509
637
  */
510
638
  private applySchedule;
511
639
  /** Return the effective reap TTL for a step — per-step override or engine default. */
@@ -544,7 +672,28 @@ export declare class Engine {
544
672
  private isClaimFresh;
545
673
  /** Claim a firing's lease via CAS, snapshot the fingerprint, open a run. */
546
674
  private claim;
675
+ /**
676
+ * Build the reference-mode order for a firing (WP-B1). Carries the pinned
677
+ * snapshot's `defDigest` plus routing/reference fields, dynamic `consumes`
678
+ * values, and dynamic `owes` feedback — but NEVER authored prompt or
679
+ * command text, and no `owes[].acceptance` (the lifecycle state is dynamic
680
+ * engine state, not instructions). The digest comes from the instruction
681
+ * source's identity for the exact `def` passed in — the pinned snapshot
682
+ * from `defFor(workflow)`, never a fresh name lookup — and that same
683
+ * snapshot is registered under the digest (a side effect of `digestOf`),
684
+ * so the order stays resolvable after the live definition map changes.
685
+ */
547
686
  private buildOrder;
687
+ /**
688
+ * Resolve an order's static instructions through the SAME `(defDigest,
689
+ * step, key)` boundary {@link Engine.resolver} uses: exact authored prompt
690
+ * and command bytes (plus source-owned acceptance when the source carries
691
+ * it), with the runtime placeholders materialized in the prompt. Purely a
692
+ * read — never mutates the stored/emitted order, and never re-embeds text
693
+ * on it. Throws `UnknownDefDigestError` when no verified record exists for
694
+ * the order's digest — before any caller can execute a prompt or command.
695
+ */
696
+ resolveOrder(order: Order): ResolvedInstructions;
548
697
  /**
549
698
  * Commit a singleton/map output green — or born-reject it if an input moved.
550
699
  *
@@ -765,7 +914,63 @@ export declare class Engine {
765
914
  * make `status(parent)` throw (same stance as the §28 drift flag).
766
915
  */
767
916
  private childStatusSummary;
917
+ /**
918
+ * The two per-instance facts a tick needs, from ONE run-record read: the def
919
+ * this instance is pinned to, and the routing modifier it carries.
920
+ *
921
+ * Offer-time composition needs the modifier inside the claim path, where the
922
+ * run record was not previously in scope. Reading it here — in the same
923
+ * `getWorkflow` the def resolution already performs, once per tick frame —
924
+ * keeps that cost at zero extra reads rather than one per claim.
925
+ */
926
+ private instanceFor;
768
927
  private defFor;
928
+ /**
929
+ * §7: the modifier ONE offer of ONE firing composes with — the run's, or the
930
+ * step's escalation target when the escalation rule has tripped.
931
+ *
932
+ * Derived, never stored. Every offer re-evaluates it from the artifact
933
+ * counters, which is what makes the transition atomic (there is no separate
934
+ * write that could half-apply), idempotent (recomputing it changes nothing),
935
+ * and self-reversing (a human `retry` zeroes `judgmentRejects`, and the very
936
+ * next offer composes with the run's modifier again).
937
+ *
938
+ * The trigger is per OUTPUT PATH: the firing escalates when any path it owes
939
+ * has taken `escalation.after` judgment rejections. For a plain step that is
940
+ * its single produce; for a map step each element firing escalates on its own
941
+ * element's count, so one bad element does not promote the whole step.
942
+ *
943
+ * Three cases return the run's modifier untouched:
944
+ * - the step authors no `escalation:` block — rejections run the normal
945
+ * retry path at the same compound until the stall brake;
946
+ * - no owed path has reached the threshold yet;
947
+ * - the run's modifier ALREADY equals the escalation target — there is
948
+ * nothing to promote, so no `escalated` flag and no history record. A
949
+ * `deep` run whose builder escalates to `deep` is a no-op, not an event.
950
+ *
951
+ * `escalation` on the result is set ONLY in the case that actually changed
952
+ * the routing; `claim` writes the history record from it.
953
+ */
954
+ private routingFor;
955
+ /**
956
+ * Write the ONE artifact-history record for an escalation promotion.
957
+ *
958
+ * `version: 0` on purpose. The promotion belongs to the artifact across a
959
+ * whole rejection episode, not to any single produced version — the episode
960
+ * spans every attempt from the crossing rejection to the human `retry` that
961
+ * ends it, and those attempts each produce their own version. Anchoring the
962
+ * record to a version would either mislabel it or (since the row id mixes in
963
+ * the version) write one row per version, breaking the once-per-episode
964
+ * guarantee. `getArtifactHistory` collects version-0 events in its
965
+ * artifact-level `events` bucket, which is exactly where this belongs; the
966
+ * version the promotion took effect at is in `metadata.atVersion`.
967
+ *
968
+ * The dedupe key is `(step, firing key, episode)`. Step and key are in it
969
+ * because two different steps can owe the same path in different firings; the
970
+ * episode ordinal is what makes a SECOND promotion, after a human `retry` and
971
+ * three fresh rejections, a distinct row rather than a swallowed duplicate.
972
+ */
973
+ private recordEscalation;
769
974
  private step;
770
975
  /**
771
976
  * The JSON Schema (if any) declared for the artifact `art` greened by `green()`