@sema-agent/core 5.56.0 → 5.58.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 (208) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/dist/agents/cascade.d.ts +1 -1
  3. package/dist/agents/cumulative-stats.d.ts +1 -1
  4. package/dist/agents/observer.d.ts +2 -2
  5. package/dist/agents/peer-admission.d.ts +1 -1
  6. package/dist/agents/retain-ledger.d.ts +2 -2
  7. package/dist/agents/roster-store.d.ts +8 -8
  8. package/dist/agents/send-message-tool.d.ts +13 -2
  9. package/dist/agents/send-message-tool.js +34 -12
  10. package/dist/agents/subagent-steps.d.ts +1 -1
  11. package/dist/agents/subagent.d.ts +13 -13
  12. package/dist/agents/team.d.ts +15 -6
  13. package/dist/agents/team.js +1 -0
  14. package/dist/agents/tool-filter.d.ts +2 -2
  15. package/dist/agents/verify.d.ts +1 -1
  16. package/dist/bench/metrics.d.ts +35 -35
  17. package/dist/brain/anthropic.js +15 -5
  18. package/dist/brain/circuit-breaker.js +2 -1
  19. package/dist/brain/degrading.d.ts +1 -1
  20. package/dist/brain/degrading.js +4 -1
  21. package/dist/brain/errors.d.ts +3 -3
  22. package/dist/brain/failover.js +16 -1
  23. package/dist/brain/open-responses.js +15 -5
  24. package/dist/brain/openai.js +16 -5
  25. package/dist/brain/reasoning.d.ts +2 -2
  26. package/dist/brain/repetition.d.ts +1 -1
  27. package/dist/brain/request-params.d.ts +30 -27
  28. package/dist/brain/request-params.js +1 -7
  29. package/dist/brain/route-adjudicator.d.ts +190 -0
  30. package/dist/brain/route-adjudicator.js +189 -0
  31. package/dist/brain/route-conformance.d.ts +55 -0
  32. package/dist/brain/route-conformance.js +136 -0
  33. package/dist/brain/routing.js +8 -3
  34. package/dist/brain/status-sink.d.ts +2 -2
  35. package/dist/brain/stream-shared.d.ts +1 -1
  36. package/dist/config/catalog.d.ts +5 -5
  37. package/dist/core/arg-summary.d.ts +4 -4
  38. package/dist/core/ask-class.d.ts +2 -2
  39. package/dist/core/ask-question.d.ts +1 -1
  40. package/dist/core/auto-compaction.d.ts +15 -15
  41. package/dist/core/auto-mode.d.ts +5 -5
  42. package/dist/core/background-agent-store.d.ts +20 -20
  43. package/dist/core/background-shell.d.ts +4 -4
  44. package/dist/core/checkpoint-store.d.ts +35 -27
  45. package/dist/core/context-edit.d.ts +1 -1
  46. package/dist/core/context-guard.d.ts +1 -1
  47. package/dist/core/exec-output-tail.d.ts +6 -6
  48. package/dist/core/file-snapshot-store.d.ts +8 -8
  49. package/dist/core/git-worktree-env.d.ts +3 -3
  50. package/dist/core/governance-codes.js +2 -0
  51. package/dist/core/hooks.d.ts +73 -33
  52. package/dist/core/hooks.js +87 -25
  53. package/dist/core/image-downsample.d.ts +1 -1
  54. package/dist/core/locked-config.d.ts +1 -1
  55. package/dist/core/lsp.d.ts +1 -1
  56. package/dist/core/mailbox-store.d.ts +1 -1
  57. package/dist/core/mcp.d.ts +3 -3
  58. package/dist/core/mcp.js +4 -4
  59. package/dist/core/memory-engine/consolidation-driver.d.ts +207 -0
  60. package/dist/core/memory-engine/consolidation-driver.js +378 -0
  61. package/dist/core/memory-engine/consolidation.d.ts +46 -2
  62. package/dist/core/memory-engine/consolidation.js +1 -0
  63. package/dist/core/memory-engine/data-plane.d.ts +1 -1
  64. package/dist/core/memory-engine/distiller.d.ts +550 -0
  65. package/dist/core/memory-engine/distiller.js +598 -0
  66. package/dist/core/memory-engine/dual-root.d.ts +1 -1
  67. package/dist/core/memory-engine/engine.d.ts +62 -8
  68. package/dist/core/memory-engine/engine.js +40 -4
  69. package/dist/core/memory-engine/file-backend.d.ts +1 -1
  70. package/dist/core/memory-engine/index.d.ts +4 -2
  71. package/dist/core/memory-engine/index.js +4 -2
  72. package/dist/core/memory-engine/origin-clearance.d.ts +1 -1
  73. package/dist/core/memory-engine/scope-contract.d.ts +4 -4
  74. package/dist/core/memory-engine/sync-client.d.ts +16 -16
  75. package/dist/core/memory-engine/sync.d.ts +4 -4
  76. package/dist/core/memory-recall.d.ts +1 -1
  77. package/dist/core/memory.d.ts +2 -2
  78. package/dist/core/permission-rule-consent.d.ts +230 -36
  79. package/dist/core/permission-rule-consent.js +258 -54
  80. package/dist/core/permission-rule-model.d.ts +295 -97
  81. package/dist/core/permission-rule-model.js +132 -41
  82. package/dist/core/permission-rules.d.ts +9 -9
  83. package/dist/core/remote-env.d.ts +8 -8
  84. package/dist/core/roles.d.ts +3 -3
  85. package/dist/core/roles.js +1 -0
  86. package/dist/core/runner/assemble-result.d.ts +2 -2
  87. package/dist/core/runner/compaction-call-options.d.ts +3 -3
  88. package/dist/core/runner/memory-consolidation-driver.d.ts +49 -0
  89. package/dist/core/runner/memory-consolidation-driver.js +60 -0
  90. package/dist/core/runner/memory-consolidation.d.ts +1 -1
  91. package/dist/core/runner/prepare-config-doors.d.ts +3 -3
  92. package/dist/core/runner/prepare-task.d.ts +21 -21
  93. package/dist/core/runner/prepare-task.js +54 -18
  94. package/dist/core/runner/prepare-workspace-restore.d.ts +2 -2
  95. package/dist/core/runner/runtask.d.ts +15 -12
  96. package/dist/core/runner/runtask.js +48 -0
  97. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  98. package/dist/core/runner/teardown-bounded.d.ts +1 -1
  99. package/dist/core/runner/tool-disclosure.d.ts +2 -2
  100. package/dist/core/runner/turn-attachments.d.ts +11 -11
  101. package/dist/core/scheduler.d.ts +10 -5
  102. package/dist/core/secret-env.d.ts +1 -1
  103. package/dist/core/sensitive-path-policy.d.ts +1 -1
  104. package/dist/core/session-policy-store.d.ts +2 -2
  105. package/dist/core/session-reconcile.d.ts +2 -2
  106. package/dist/core/session-store.d.ts +3 -3
  107. package/dist/core/session.d.ts +1 -1
  108. package/dist/core/shutdown-debug.d.ts +2 -2
  109. package/dist/core/side-query.d.ts +14 -7
  110. package/dist/core/spec-contract.d.ts +1 -1
  111. package/dist/core/store-contracts/contract-harness.d.ts +2 -2
  112. package/dist/core/store-contracts/contract-kit-version.d.ts +2 -2
  113. package/dist/core/store-contracts/mailbox-store-contract.d.ts +1 -1
  114. package/dist/core/store-contracts/mailbox-store-contract.js +1 -1
  115. package/dist/core/task-notification.d.ts +5 -5
  116. package/dist/core/task-registry-agent.d.ts +12 -12
  117. package/dist/core/task-registry-monitor.d.ts +1 -1
  118. package/dist/core/task-registry-shared.d.ts +41 -41
  119. package/dist/core/task-registry.d.ts +12 -12
  120. package/dist/core/tool-detach.d.ts +2 -2
  121. package/dist/core/tool-errors.d.ts +3 -3
  122. package/dist/core/tool-policy.d.ts +55 -28
  123. package/dist/core/tool-result-budget.d.ts +1 -1
  124. package/dist/core/tool-result-store.d.ts +2 -2
  125. package/dist/core/tools.d.ts +1 -1
  126. package/dist/core/trace.d.ts +26 -23
  127. package/dist/core/types.d.ts +155 -70
  128. package/dist/core/untrusted-egress.d.ts +1 -1
  129. package/dist/core/untrusted-text.d.ts +7 -7
  130. package/dist/core/wiring-manifest.d.ts +5 -5
  131. package/dist/core/workflow-journal-store.d.ts +14 -14
  132. package/dist/core/workflow-run-store-contract.d.ts +1 -1
  133. package/dist/core/workflow-run-store-contract.js +1 -1
  134. package/dist/core/workflow-run-store.d.ts +4 -4
  135. package/dist/engine/compaction/compaction.d.ts +3 -3
  136. package/dist/engine/compaction/utils.d.ts +2 -2
  137. package/dist/engine/execution-env/kill-tree.d.ts +1 -1
  138. package/dist/engine/execution-env/node-execution-env.d.ts +8 -8
  139. package/dist/engine/harness/agent-harness.d.ts +6 -6
  140. package/dist/engine/harness/agent-harness.js +26 -1
  141. package/dist/engine/harness/messages.d.ts +1 -1
  142. package/dist/engine/harness/types.d.ts +15 -11
  143. package/dist/engine/llm/types.d.ts +79 -14
  144. package/dist/engine/loop/agent-loop.d.ts +3 -3
  145. package/dist/engine/loop/types.d.ts +4 -4
  146. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  147. package/dist/engine/session/import-validate.d.ts +1 -1
  148. package/dist/engine/session/log-digest.d.ts +1 -1
  149. package/dist/engine/session/memory-repo.d.ts +2 -2
  150. package/dist/engine/session/session.d.ts +4 -4
  151. package/dist/fixtures/index.d.ts +4 -4
  152. package/dist/index.d.ts +8 -4
  153. package/dist/index.js +5 -2
  154. package/dist/internal/llm.d.ts +1 -1
  155. package/dist/orchestration/goal.d.ts +1 -1
  156. package/dist/orchestration/run-spec.d.ts +1 -1
  157. package/dist/orchestration/run-workflow-tool.d.ts +12 -12
  158. package/dist/orchestration/workflow-governance.d.ts +4 -4
  159. package/dist/orchestration/workflow-observe.d.ts +1 -1
  160. package/dist/orchestration/workflow-script-runner.d.ts +1 -1
  161. package/dist/orchestration/workflow-script-store.d.ts +9 -9
  162. package/dist/orchestration/workflow-size-guideline.d.ts +1 -1
  163. package/dist/orchestration/workflow-types.d.ts +5 -5
  164. package/dist/orchestration/workflow.d.ts +10 -10
  165. package/dist/prompt-assembly/artifact-store.d.ts +1 -1
  166. package/dist/prompt-assembly/artifact.d.ts +1 -1
  167. package/dist/prompt-assembly/assemble.d.ts +1 -1
  168. package/dist/prompt-assembly/composer.d.ts +2 -2
  169. package/dist/prompt-assembly/epoch.d.ts +2 -2
  170. package/dist/prompt-assembly/event-registry.d.ts +1 -1
  171. package/dist/prompt-assembly/explain.d.ts +3 -3
  172. package/dist/prompt-assembly/tool-catalog.d.ts +1 -1
  173. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -4
  174. package/dist/prompt-assembly/types.d.ts +12 -12
  175. package/dist/prompts/coordinator.d.ts +1 -1
  176. package/dist/prompts/default.d.ts +10 -10
  177. package/dist/prompts/default.js +2 -0
  178. package/dist/prompts/simple-sections.d.ts +3 -3
  179. package/dist/prompts/supervisor.d.ts +2 -2
  180. package/dist/scenarios/full-body.d.ts +3 -3
  181. package/dist/scenarios/scenario-registry.d.ts +6 -2
  182. package/dist/scenarios/scenario-registry.js +4 -2
  183. package/dist/stores/cc/sidecar-transcript.d.ts +3 -3
  184. package/dist/stores/file/fs-atomic.d.ts +2 -2
  185. package/dist/stores/file/index.d.ts +1 -1
  186. package/dist/stores/file/session-store.d.ts +2 -2
  187. package/dist/stores/file/workflow-journal-store.d.ts +4 -4
  188. package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
  189. package/dist/tools/fs/encoding.d.ts +4 -4
  190. package/dist/tools/fs/fs-bash.d.ts +3 -3
  191. package/dist/tools/fs/fs-pdf.d.ts +1 -1
  192. package/dist/tools/fs/fs-shared.d.ts +6 -6
  193. package/dist/tools/fs/index.d.ts +2 -2
  194. package/dist/tools/fs/index.js +8 -1
  195. package/dist/tools/fs/notebook.d.ts +1 -1
  196. package/dist/tools/fs/pdf.d.ts +1 -1
  197. package/dist/tools/fs/read-deny.d.ts +1 -1
  198. package/dist/tools/fs/safety.d.ts +9 -9
  199. package/dist/tools/fs/search.d.ts +2 -2
  200. package/dist/tools/monitor.d.ts +3 -3
  201. package/dist/tools/scheduler-tools.js +28 -6
  202. package/dist/tools/task-list.d.ts +2 -2
  203. package/dist/tools/web.d.ts +19 -4
  204. package/dist/tools/web.js +8 -2
  205. package/dist/tools/worktree.d.ts +5 -5
  206. package/dist/tools/worktree.js +2 -2
  207. package/package.json +1 -1
  208. package/test/export-surface.snapshot.json +74 -3
@@ -29,8 +29,18 @@ export interface StaleToolResultOffloadOptions {
29
29
  * - `advisor` — the strong "teacher" a cheap student escalates to (`runWithTeacher`).
30
30
  * - `classifier` — the auto-mode permission classifier (a roster-cheap tier; falls back
31
31
  * `summarize → default`, tier default `flash` on tier-expanded catalogs).
32
+ * - `consolidate` — the memory-consolidation distillation driver (design/376). Falls back to
33
+ * `summarize` and then REFUSES LOUDLY — deliberately never to `default`: one consolidation run
34
+ * is a whole-library read (~10⁵ prompt tokens), so silently escalating to the most expensive
35
+ * main-task model is the bad-value-silence family, not a convenience. The divergence from the
36
+ * classifier family's `→ default` tail is calibrated on call volume: a classifier resolves one
37
+ * short classification, this role resolves a full-library batch. An explicit
38
+ * `roles.consolidate = <main model>` is a legal deployment choice; the summarize hop is kept
39
+ * because a deployment that declared a cheap summarize tier has already made the cost choice
40
+ * this role wants (note the summarize DEFAULT rationale — prompt-cache forking — does not
41
+ * apply here: consolidation is an offline independent request with no shared prefix).
32
42
  */
33
- export type ModelRole = "default" | "summarize" | "subagent" | "team" | "synthesize" | "advisor" | "verifier" | "classifier";
43
+ export type ModelRole = "default" | "summarize" | "subagent" | "team" | "synthesize" | "advisor" | "verifier" | "classifier" | "consolidate";
34
44
  /**
35
45
  * A role's model: a `ModelRef`, or a config object that pins a `model`, **selects** one by
36
46
  * capability/price (`select`, design/11 Layer 2), and/or sets a default `thinking` level.
@@ -72,6 +82,24 @@ export interface Brain {
72
82
  * - honor `options.maxTokens` — that is the escalating budget the recovery re-issues the call with.
73
83
  */
74
84
  complete?: CompleteSimpleFn;
85
+ /**
86
+ * Optional key↔URL pairing judge (see `src/brain/route-adjudicator.ts` for the law). Answers, for a
87
+ * model this brain would serve, whether the credential the request would carry belongs to the URL
88
+ * it would target — WITHOUT sending anything. `perModelAuth` is the caller's already-resolved
89
+ * per-model auth (the `getApiKeyAndHeaders` result), so a resolution seat can pre-flight the exact
90
+ * request it is about to make. First-party brains implement it against their own config; the
91
+ * decorators (routing/failover/degrading/circuit-breaker) re-dispatch it the way their `stream`
92
+ * would. `undefined` = this brain cannot judge (a custom brain without the face) — callers must
93
+ * treat that as "no judgment", never as OK or as broken.
94
+ *
95
+ * The same law runs again inside the first-party brains' request build (single source, called
96
+ * twice): a broken pairing that skips the pre-flight still refuses loudly at the request instead
97
+ * of sending a credential to a host it is not paired with.
98
+ */
99
+ adjudicateRoute?: (model: Model, perModelAuth?: {
100
+ apiKey?: string;
101
+ headers?: Record<string, string>;
102
+ }) => import("../internal/llm.js").RouteAdjudication | undefined;
75
103
  }
76
104
  /**
77
105
  * Side-effect class of a tool. Used by wake/resume reconciliation: when a call was interrupted
@@ -128,7 +156,7 @@ export interface ToolSpec<TParams extends TSchema = TSchema> {
128
156
  aliases?: string[];
129
157
  description: string;
130
158
  /**
131
- * R2 双形轴(clay 2026-07-18 裁):the CLASSIC-profile variant of {@link description}. CC 2.1.212
159
+ * R2 双形轴(2026-07-18 裁):the CLASSIC-profile variant of {@link description}. CC 2.1.212
132
160
  * keys its tool descriptions on `LT(model_id)` (simple short form vs classic long form); sema's
133
161
  * counterpart is {@link TaskSpec.promptProfile} — default "simple" (what CC serves every BYOM
134
162
  * model id). When the run resolves to "classic" and this field is present, it REPLACES
@@ -189,7 +217,7 @@ export interface ToolSpec<TParams extends TSchema = TSchema> {
189
217
  aliases?: readonly string[];
190
218
  contentOrigin?: ToolContentOrigin;
191
219
  }>;
192
- /** [1245] — approval display projection (see AgentTool.approvalPreview): pure args→display value
220
+ /** approval display projection (see AgentTool.approvalPreview): pure args→display value
193
221
  * for human approval surfaces; clamped + throw-swallowed by the gate; never adjudication input. */
194
222
  approvalPreview?: (args: unknown) => unknown;
195
223
  /**
@@ -201,7 +229,7 @@ export interface ToolSpec<TParams extends TSchema = TSchema> {
201
229
  */
202
230
  agentModels?: readonly string[];
203
231
  /**
204
- * [876] core half — PER-TASK agent-roster rebuild seam, filled ONLY by `createSubagentTool`
232
+ * core half — PER-TASK agent-roster rebuild seam, filled ONLY by `createSubagentTool`
205
233
  * (deployment-authored tools leave it unset). The delegation tool's roster is a mount-time SNAPSHOT
206
234
  * baked into its parameter enum/description (see the `SubagentToolOptions` snapshot note), so per-task
207
235
  * additions ({@link TaskSpec.agents}) cannot mutate the mounted instance — `prepareTask` instead calls
@@ -405,7 +433,7 @@ export interface ToolSpec<TParams extends TSchema = TSchema> {
405
433
  */
406
434
  modelGate?: string;
407
435
  /**
408
- * Tool contract identity (campaign S2, prompt-assembly protocol §7): declares the EXECUTION
436
+ * Tool contract identity (stage S2, prompt-assembly protocol §7): declares the EXECUTION
409
437
  * CONTRACT this tool implements, independent of its presentation text. `defineTool` attaches it
410
438
  * to the materialized tool via the catalog side-table (identity follows the OBJECT, never the
411
439
  * wire name — a caller tool shadowing a built-in name never inherits the core contract). Omitted
@@ -435,7 +463,7 @@ export type ToolReturn = string | {
435
463
  /** Hint the agent to stop after this tool batch. */
436
464
  terminate?: boolean;
437
465
  /**
438
- * RB-211(黑板 [1870] C3,已修 — root-cause widening): a `ToolSpec.execute` can RETURN a failure
466
+ * RB-211 (root-cause widening): a `ToolSpec.execute` can RETURN a failure
439
467
  * receipt instead of throwing (teaching errors that carry structured `details`, e.g. an
440
468
  * unrecoverable-but-informative rejection). Before this field existed, `ToolReturn` had NO
441
469
  * isError channel at all — `defineTool`'s wrapper builds a fresh `{content,details,terminate}`
@@ -445,7 +473,7 @@ export type ToolReturn = string | {
445
473
  * produced `isError:false` on the model-facing `toolResult`, in BOTH the live per-turn path and
446
474
  * the durable-resume path — a returned rejection was structurally unable to look like anything
447
475
  * other than success. Omitted/false = success (matches `AgentToolResult.isError`'s own
448
- * `[1331]③` convention exactly — this is that SAME field, finally reachable from a `ToolSpec`).
476
+ * convention exactly — this is that SAME field, finally reachable from a `ToolSpec`).
449
477
  */
450
478
  isError?: boolean;
451
479
  };
@@ -483,7 +511,7 @@ export interface NestedUsageAccum {
483
511
  turns: number;
484
512
  tasks: number;
485
513
  costMicroUsd: number;
486
- /** codex batch-4 F3 (RB-368 reaches the nested face): true once ANY delegated leg reported no cost —
514
+ /** batch-4 F3 (RB-368 reaches the nested face): true once ANY delegated leg reported no cost —
487
515
  * the summed `costMicroUsd` is then a priced-subtotal, not a total, and the publish site must go
488
516
  * ABSENT instead of impersonating one. REQUIRED so every seeding/snapshot site is tsc-forced to
489
517
  * carry knownness alongside the number it qualifies. */
@@ -507,13 +535,13 @@ export interface ToolExecuteContext {
507
535
  /** Publish provenance companion of {@link centerArtifactDigest}. */
508
536
  centerSourceRevision?: string;
509
537
  /**
510
- * design/147 S2a (codex R2) — the SPAWNING run's sessionId (trusted internals chain, same seat as
538
+ * design/147 S2a — the SPAWNING run's sessionId (trusted internals chain, same seat as
511
539
  * {@link parentTaskId}). Sibling resolution/delivery needs the parent's SESSION axis too: a
512
540
  * session-scoped sibling registers with owner = the parent's sessionId, which the parent's taskId
513
541
  * alone cannot satisfy when the two differ.
514
542
  */
515
543
  parentSessionId?: string;
516
- /** δ 批 [1498]⑦/A-3 — the ROOT host session of the delegation tree (see RunInternals.rootSessionId:
544
+ /** A-3 — the ROOT host session of the delegation tree (see RunInternals.rootSessionId:
517
545
  * fixed point `ctx.rootSessionId ?? ctx.sessionId` at every spawn). Absent for a top-level run
518
546
  * (its OWN sessionId is the root). */
519
547
  rootSessionId?: string;
@@ -543,7 +571,7 @@ export interface ToolExecuteContext {
543
571
  ticket: import("./task-registry.js").ParkedClaimTicket;
544
572
  outcome: import("./checkpoint-store.js").ResumeOutcome;
545
573
  /**
546
- * [1596] the CROSS-PROCESS re-supply seat for the checkpoint's opaque parent constraints.
574
+ * the CROSS-PROCESS re-supply seat for the checkpoint's opaque parent constraints.
547
575
  * A checkpoint minted under inherited parent-policy constraints records only
548
576
  * `requiresParentConstraint` (live ToolPolicy/onAsk closures cannot persist); the same-process
549
577
  * drive is re-supplied automatically from the Runner's in-memory `parentConstraintRegistry`,
@@ -554,7 +582,7 @@ export interface ToolExecuteContext {
554
582
  * config-driven) passes it here; the drive threads it into `resumeStream(..., internals)`,
555
583
  * where the recorded-count shape check still applies verbatim (a partial/mismatched re-supply
556
584
  * is rejected — this seat never widens, it only reopens the documented re-supply channel to
557
- * the parked-decide lane). Absent ⇒ exactly the pre-[1596] behavior.
585
+ * the parked-decide lane). Absent ⇒ exactly the previous behavior.
558
586
  *
559
587
  * One entry kind is NOT a policy the deployment authored: a hook-wired parent contributes a
560
588
  * PreToolUse SCREENING entry (issue #33), whose policy the engine mints. Rebuild it with the
@@ -604,21 +632,21 @@ export interface ToolExecuteContext {
604
632
  */
605
633
  roster?: import("../agents/roster-store.js").RosterStore;
606
634
  /**
607
- * [1345] fork source-store fix — the HOST Runner's session-fork face, Runner-filled read-only.
635
+ * fork source-store fix — the HOST Runner's session-fork face, Runner-filled read-only.
608
636
  * The fork arm's source session lives in the store of the Runner RUNNING this task; `opts.runner`
609
637
  * is the CHILD-EXECUTION runner, which a deployment may deliberately split (server's subRunner) —
610
638
  * forking through it queried an empty store and every fork missed ("source session not found").
611
639
  * The fork arm prefers this face and falls back to `opts.runner.sessions.fork` (single-runner
612
640
  * deployments unchanged).
613
641
  *
614
- * ZERO-ARG by design (codex 1350 F2): the source session id AND principal are bound in the Runner's
642
+ * ZERO-ARG by design: the source session id AND principal are bound in the Runner's
615
643
  * closure at injection — a mounted third-party tool holding this context can only branch THIS task's
616
644
  * own session under THIS task's principal, never copy a foreign session by supplying its id. The
617
645
  * returned handle's `release` is scoped to the just-created branch through the same closure, so
618
646
  * failure cleanup releases through the store that OWNS the branch (`opts.runner.sessions.release`
619
647
  * may be a different store entirely).
620
648
  *
621
- * Store contract (codex 1350 F1): the branch is created in the HOST store, but the fork child still
649
+ * Store contract: the branch is created in the HOST store, but the fork child still
622
650
  * executes on `opts.runner` with `requireExistingSession: true` — if the two runners do not share
623
651
  * session backing, the child run fails LOUD ("refusing a silent fresh run") instead of silently
624
652
  * running an empty session under the forked id. Split-runner deployments must share session backing
@@ -796,7 +824,7 @@ export interface ToolExecuteContext {
796
824
  * user. Runner-filled (NOT a tool argument). Undefined when the task carries no clientContext.
797
825
  */
798
826
  clientContext?: TaskSpec["clientContext"];
799
- /** [1043]③/[1044]② (codex F3) — the parent's tool-face controls ({@link TaskSpec.excludeTools} /
827
+ /** — the parent's tool-face controls ({@link TaskSpec.excludeTools} /
800
828
  * {@link TaskSpec.deferTools}), inherited down the delegation tree like `principal` (Runner-filled,
801
829
  * read-only): a scenario-wide roster must not be escapable by delegating to a child that remounts
802
830
  * the excluded tool. Children merge these with their own spec values (union — tighten-only). */
@@ -820,7 +848,7 @@ export interface ToolExecuteContext {
820
848
  * tool-face controls (Runner-filled): a classic-profile parent's children speak classic too
821
849
  * unless the child spec says otherwise (child spec wins — profile is presentation, not policy). */
822
850
  promptProfile?: "simple" | "classic";
823
- /** [1347]② — the parent's declared extra file-tool roots ({@link TaskSpec.additionalDirectories}),
851
+ /** the parent's declared extra file-tool roots ({@link TaskSpec.additionalDirectories}),
824
852
  * inherited down the delegation tree (Runner-filled, copy-at-spawn): a deployment that widened the
825
853
  * fs fence (e.g. the scratchpad host lane) widened it for the TASK, and a delegated child doing the
826
854
  * same work hit `path_not_in_root` on the very directory the parent could write. Same trust tier as
@@ -830,7 +858,7 @@ export interface ToolExecuteContext {
830
858
  * the same rule (Runner-filled, copy-at-spawn): a child doing the parent's work needs the same
831
859
  * read whitelist, and MUST NOT have it silently widened into a write grant in transit. */
832
860
  additionalReadDirectories?: readonly string[];
833
- /** [1347]② — the parent's environment facts ({@link TaskSpec.envFacts}), inherited down the
861
+ /** the parent's environment facts ({@link TaskSpec.envFacts}), inherited down the
834
862
  * delegation tree (Runner-filled, copy-at-spawn): the sandbox binding (profile/egress/scratchpad)
835
863
  * is a DEPLOYMENT property, not a per-task one — a child in the same sandbox needs the same facts
836
864
  * (its env block renders the scratchpad section; its root fence admits the scratchpad dir). */
@@ -847,7 +875,7 @@ export interface ToolExecuteContext {
847
875
  */
848
876
  memoryPersistenceCapable?: boolean;
849
877
  /**
850
- * [893]④a — the parent task's per-model auth hook ({@link TaskSpec.getApiKeyAndHeaders}), inherited
878
+ * the parent task's per-model auth hook ({@link TaskSpec.getApiKeyAndHeaders}), inherited
851
879
  * verbatim down the delegation tree like `principal`/`clientContext` (Runner-filled, read-only, NEVER
852
880
  * a model/tool argument). Without this seat a per-task agent pinned to a cross-provider model (its own
853
881
  * apiKeyEnv) spawned a child whose run had NO auth hook — the brain silently fell back to the global
@@ -1668,15 +1696,15 @@ export interface TaskSpec {
1668
1696
  */
1669
1697
  requireExistingSession?: boolean;
1670
1698
  /**
1671
- * 黑板 [1909]⑧/[1910]/[1911](cli/server 商定,per-request 语义,无异议)— this SUBMISSION is one-shot:
1699
+ * Per-request semantics — this SUBMISSION is one-shot:
1672
1700
  * no later turn exists in which an async background notification could land (the archetypal case is a
1673
1701
  * headless `sema -p` invocation, whose process exits once this turn ends). Per-request rather than
1674
1702
  * per-connection/per-process on purpose: "does this particular submission expect to be steered/continued"
1675
1703
  * is a property of the submission, not of the channel it arrived on — a persistent connection can still
1676
1704
  * mix interactive and one-shot submissions, which a connection-level flag could not express.
1677
1705
  *
1678
- * Currently consumed by the `RunWorkflow` tool's guidance text only (RB-215 candidate ①, blackboard
1679
- * [1870] C6): a workflow started from a one-shot submission is told to actively block-wait via
1706
+ * Currently consumed by the `RunWorkflow` tool's guidance text only (RB-215 candidate ①):
1707
+ * a workflow started from a one-shot submission is told to actively block-wait via
1680
1708
  * `TaskOutput({ block: true })` before ending its turn, instead of the default "end your turn, you will
1681
1709
  * be notified" guidance — the latter is actively wrong here (BGB drilldown case 2, `../sema-test/bench-bg/
1682
1710
  * intel/drilldown-C101-B401-20260727.md`: a model that followed that exact guidance lost background
@@ -1882,10 +1910,10 @@ export interface TaskSpec {
1882
1910
  */
1883
1911
  tools?: ToolSpec[];
1884
1912
  /**
1885
- * [1043]③ per-scenario tool ROSTER (true unmount, NOT a permission gate): wire names listed here
1913
+ * per-scenario tool ROSTER (true unmount, NOT a permission gate): wire names listed here
1886
1914
  * are removed from the mounted tool set AFTER assembly — their schemas never reach `tools[]`
1887
1915
  * (unlike a policy deny, which gates calls but still ships the schema bytes every request —
1888
- * measured at zero token savings, [1040]②a). Exact wire-name match (aliases resolve to their
1916
+ * measured at zero token savings). Exact wire-name match (aliases resolve to their
1889
1917
  * canonical wire name at mount, so list the canonical name). Unknown names are ignored (a
1890
1918
  * center-distributed roster may cover tools this deployment doesn't mount). The injected
1891
1919
  * ToolSearch cannot be excluded (it mounts after this filter, only when deferred tools exist).
@@ -1894,7 +1922,7 @@ export interface TaskSpec {
1894
1922
  */
1895
1923
  excludeTools?: string[];
1896
1924
  /**
1897
- * [1044]② (clay ruling B) per-request DEFERRED disclosure for ALREADY-MOUNTED tools (built-ins
1925
+ * Per-request DEFERRED disclosure for ALREADY-MOUNTED tools (built-ins
1898
1926
  * included — `ToolSpec.defer` only covers caller specs): wire names listed here ship as
1899
1927
  * lightweight placeholders (name + one-line hint, schema bytes OFF the cache prefix) and are
1900
1928
  * activated on demand via the injected ToolSearch (design/36 materialization — prefix untouched).
@@ -1978,7 +2006,7 @@ export interface TaskSpec {
1978
2006
  */
1979
2007
  deferSelfResolve?: boolean;
1980
2008
  /**
1981
- * R2 双形轴(clay 2026-07-18 裁): which prompt-profile face this task speaks — "simple" (default;
2009
+ * R2 双形轴(2026-07-18 裁): which prompt-profile face this task speaks — "simple" (default;
1982
2010
  * CC 2.1.212's short-form tool descriptions + lean system sections, what CC serves every non-claude
1983
2011
  * model id) or "classic" (the long-form face, ≈ CC 4.x-era wording — switchable per task/model,
1984
2012
  * e.g. serving classic to a model that scores better on it; center distribution rides this field).
@@ -1987,13 +2015,13 @@ export interface TaskSpec {
1987
2015
  */
1988
2016
  promptProfile?: "simple" | "classic";
1989
2017
  /**
1990
- * [876] core half — PER-TASK custom sub-agents. Same shape as the boot injection point
2018
+ * core half — PER-TASK custom sub-agents. Same shape as the boot injection point
1991
2019
  * ({@link RunnerDeps.agents} / `SubagentToolOptions.agents`): full {@link AgentDefinition} objects
1992
2020
  * (the shell resolves agent files / frontmatter into this shape; `model` is the already-resolved
1993
2021
  * real model ref passed through — core carries no model-word vocabulary). When set (non-empty),
1994
2022
  * `prepareTask` REBUILDS the mounted delegation tool (via {@link ToolSpec.withAgents}) so its roster
1995
2023
  * is the UNION of the boot roster and these definitions — a same-name per-task definition WINS over
1996
- * the boot one. Validation contract ([901] revision of the [876] posture, dual-leg verified against
2024
+ * the boot one. Validation contract (revision of the posture, dual-leg verified against
1997
2025
  * upstream): an `allowTools` entry naming a tool that does not exist is ITEM-FILTERED at spawn (the
1998
2026
  * agent stays listed and delegable; the only host disclosure is a prepare-time HEURISTIC advisory
1999
2027
  * via `RunnerDeps.onError` phase `"config"` for entries unknown to the parent's assembled roster —
@@ -2023,7 +2051,7 @@ export interface TaskSpec {
2023
2051
  /** How `ask` decisions resolve for this task (headless auto-deny by default). Overrides `RunnerDeps.onAsk`. */
2024
2052
  onAsk?: import("./tool-policy.js").OnAsk;
2025
2053
  /** Content-ask seam (design/64 §5): routes an AskUserQuestion tool call to a real human/UI. When set, the
2026
- * AskUserQuestion tool is mounted (one of the delivery faces in the [884] criterion — see
2054
+ * AskUserQuestion tool is mounted (one of the delivery faces in the criterion — see
2027
2055
  * {@link interactiveTools}). Overrides `RunnerDeps.onQuestion`. Distinct from `onAsk` (permission). */
2028
2056
  onQuestion?: import("./ask-question.js").OnQuestion;
2029
2057
  /** LSP code-intelligence seam (design/64 §13.1): when set, the `lsp` tool is mounted and routed to this
@@ -2302,7 +2330,7 @@ export interface TaskSpec {
2302
2330
  */
2303
2331
  enablePlanMode?: boolean;
2304
2332
  /**
2305
- * [884] Interactive-tool mounting override (CC 2.1.207/209 parity: AskUserQuestion / ExitPlanMode /
2333
+ * Interactive-tool mounting override (CC 2.1.207/209 parity: AskUserQuestion / ExitPlanMode /
2306
2334
  * EnterPlanMode share one `isEnabled` gate — in non-interactive mode without an SDK permission-prompt
2307
2335
  * tool the tool is NOT offered at all, so the model never asks into the void). sema's automatic
2308
2336
  * criterion (this knob unset): a human-facing tool mounts only when the deployment has SOME face that
@@ -2409,7 +2437,7 @@ export interface TaskSpec {
2409
2437
  * tasks trampling each other's temp files and project-dir pollution. Unset ⇒ no section rendered. */
2410
2438
  scratchpadDir?: string;
2411
2439
  /**
2412
- * [1451]/[1452]③ B-half — PER-LANE resume-continuity facts, rendered ONLY on a durable-resume leg so
2440
+ * B-half — PER-LANE resume-continuity facts, rendered ONLY on a durable-resume leg so
2413
2441
  * the model reasons honestly about what survived the suspension. DEPLOYMENT-supplied per its own lane
2414
2442
  * capability (a VM snapshot lane preserves processes; an ssh park-only workspace usually keeps /tmp;
2415
2443
  * a rebuilt container loses both) — core hardcodes NO lane table and renders NOTHING when a field is
@@ -2439,7 +2467,7 @@ export interface TaskSpec {
2439
2467
  */
2440
2468
  limits?: TaskLimits;
2441
2469
  /**
2442
- * Config-catalog override declarations (clay ruling 2026-07-19, anti-chaos contract): a HOST that
2470
+ * Config-catalog override declarations (ruled 2026-07-19, anti-chaos contract): a HOST that
2443
2471
  * overrides a recommended knob at its own layer (env cap, adapter flag, harness default) declares
2444
2472
  * it here — key + value + REASON — so the override rides the `config.assembled` trace with
2445
2473
  * provenance `host-declared` instead of being invisible to forensics. Advisory observability
@@ -2473,7 +2501,7 @@ export interface TaskSpec {
2473
2501
  * released (throwaway semantics restored — a retained session never dangles to the store's 7-day TTL).
2474
2502
  * `run_in_background` children are OUT OF SCOPE (no handle, no retain — r1-M3; the bg lane's resume needs
2475
2503
  * durable support and is a separate item). Resume is reachable only while the parent run lives (the
2476
- * ledger is run-scoped, not a durable registry — codex-B3).
2504
+ * ledger is run-scoped, not a durable registry).
2477
2505
  */
2478
2506
  retainSubagentSessions?: boolean | {
2479
2507
  ttlMs?: number;
@@ -3265,7 +3293,7 @@ export interface TaskResult {
3265
3293
  * accumulator rather than an alias. Optional BY DESIGN, like every usage field on this stats
3266
3294
  * face: undefined means the gateway reported no usage (and pre-3.0.0 persisted rows never had
3267
3295
  * it) — the event-face `turn_end.usage.totalInputTokens` is required because there the whole
3268
- * `usage` object is already conditional ([2285] item 3: intentional asymmetry, not a gap). */
3296
+ * `usage` object is already conditional (intentional asymmetry, not a gap). */
3269
3297
  totalInputTokens?: number;
3270
3298
  /** Completion (output) tokens summed over the task's turns. */
3271
3299
  outputTokens?: number;
@@ -3274,7 +3302,7 @@ export interface TaskResult {
3274
3302
  /** Authoritative (and only) cost figure: **integer micro-USD** (1e-6 USD), computed in core from
3275
3303
  * injected pricing — integer to avoid float-accumulation error in billing. (design/157 B19: the
3276
3304
  * float-USD twin was removed; divide by 1e6 at the display edge if you need USD.)
3277
- * **ABSENT when any spend was unpriced** (RB-368 [2076]): the serving model had neither a
3305
+ * **ABSENT when any spend was unpriced** (RB-368): the serving model had neither a
3278
3306
  * `RunnerDeps.pricing` entry nor a `Model.cost` declaration — an unpriced run reports NO cost
3279
3307
  * rather than a fabricated 0, so "no price table" stays distinguishable from "declared free"
3280
3308
  * (an explicit all-zero `Model.cost` still reports 0). `costBreakdown` is omitted with it. */
@@ -3413,7 +3441,7 @@ export interface TaskResult {
3413
3441
  * LLM total: `llmRootMicroUsd + compactionMicroUsd === costMicroUsd` and the fully-reconciled
3414
3442
  * spend is `costMicroUsd + nested.costMicroUsd` — `costMicroUsd` deliberately EXCLUDES nested
3415
3443
  * subagent cost (it lands in `nested`, see assemble-result.ts), so `nestedSubagentMicroUsd` sits
3416
- * OUTSIDE the costMicroUsd identity, not inside it ([2026] 细账批实测纠偏: the previous wording
3444
+ * OUTSIDE the costMicroUsd identity, not inside it (measured correction: the previous wording
3417
3445
  * `llmRoot + nested + compaction === costMicroUsd` only held when nested was 0).
3418
3446
  * (`memoryConsolidationMicroUsd` is a separate, budget-excluded line, permanently 0 since the
3419
3447
  * runner-integrated consolidation pass was retired — design/157 B19 — and NOT part of any identity).
@@ -3423,7 +3451,7 @@ export interface TaskResult {
3423
3451
  costBreakdown?: {
3424
3452
  /** Root-agent LLM cost (micro-USD) = `costMicroUsd − compactionMicroUsd` (the sub-category folded into
3425
3453
  * it). NOT minus nested — nested cost is never folded into `costMicroUsd` (it lands in `nested`).
3426
- * ⚠️ APPROXIMATE on a multi-slice `resource_limit` RESUME (design/80 D-E-core, codex review #3): the
3454
+ * ⚠️ APPROXIMATE on a multi-slice `resource_limit` RESUME (design/80 D-E-core): the
3427
3455
  * durable resource ledger persists only the AGGREGATE prior spend, not its compaction subtotal, so
3428
3456
  * prior slices' compaction folds in HERE rather than into `compactionMicroUsd`. The TOTAL (`costMicroUsd`)
3429
3457
  * stays exact; only this llmRoot-vs-compaction split is per-leg-approximate across resource slices. */
@@ -3462,7 +3490,7 @@ export interface TaskEventIdentity {
3462
3490
  eventId?: string;
3463
3491
  parentToolCallId?: string;
3464
3492
  /**
3465
- * design/122 S2 (codex-M4 name: the `WorkflowRun.sourceTaskId` family, NOT a second `taskId` — that
3493
+ * design/122 S2 (the `WorkflowRun.sourceTaskId` family, NOT a second `taskId` — that
3466
3494
  * field already exists on `task_progress` and a duplicate would bite consumers) — the ORIGINATING task's
3467
3495
  * canonical id (`spec.taskId ?? sessionId`), stamped ONLY on the content events of a task running AS A
3468
3496
  * SUB-AGENT (same condition as {@link parentToolCallId}). A consumer of the C1 forward channel
@@ -3472,7 +3500,7 @@ export interface TaskEventIdentity {
3472
3500
  */
3473
3501
  sourceTaskId?: string;
3474
3502
  /**
3475
- * design/151 S2 (MED-10 live-tail, [1498]⑦ server half) — the BACKGROUND agent's `a*` registry
3503
+ * design/151 S2 (MED-10 live-tail) — the BACKGROUND agent's `a*` registry
3476
3504
  * handle, stamped on every event a background child's lane forwards up the host `onForwardEvent`
3477
3505
  * channel (content deltas, tool events, progress). THE live-tail routing key: a serving layer
3478
3506
  * pipes "what is agent aXX doing right now" straight off the host forward stream — no uuid→a*
@@ -3554,7 +3582,7 @@ export interface ToolActivity {
3554
3582
  phase: "start" | "end";
3555
3583
  toolCallId: string;
3556
3584
  toolName: string;
3557
- /** [843]④a — wall-clock stamp (epoch ms, `Date.now()` read at the emitting Runner where the frame is
3585
+ /** wall-clock stamp (epoch ms, `Date.now` read at the emitting Runner where the frame is
3558
3586
  * minted). Carried on BOTH beats: the `start` beat stamps the moment the tool call began, the `end`
3559
3587
  * beat the moment it settled — so a consumer derives per-call duration (`end.at − start.at`) and
3560
3588
  * inter-call idle (an `end.at` → the NEXT `start.at`). Additive/optional: frames recorded by older
@@ -3564,7 +3592,7 @@ export interface ToolActivity {
3564
3592
  * single most salient input ABBREVIATED (command→name, path→basename, url→origin+path) + SECRET-SCRUBBED +
3565
3593
  * truncated (~80 code points). Set on `phase: "start"`. NOT the full args object, and NOT `redactHostLeaks`
3566
3594
  * (that over-redacts the path the monitor needs); the abbreviation + scrub is the leak boundary since the value
3567
- * is persisted + SSE-forwarded (codex-reviewed). See `primaryActivityArg`. */
3595
+ * is persisted + SSE-forwarded. See `primaryActivityArg`. */
3568
3596
  arg?: string;
3569
3597
  /** Set on `phase: "end"` — whether the tool call errored. */
3570
3598
  isError?: boolean;
@@ -3781,7 +3809,7 @@ export type TaskEvent = ({
3781
3809
  */
3782
3810
  truncated?: boolean;
3783
3811
  /**
3784
- * RB-210(黑板 [1870] C2,已修) — present iff {@link truncated}: the TRUE original size (characters) of
3812
+ * RB-210 — present iff {@link truncated}: the TRUE original size (characters) of
3785
3813
  * the content this event's {@link output} was degraded from — for a string result, the string's own
3786
3814
  * length; for a non-string result (a blocks array), the SUM of each block's own true size (a text
3787
3815
  * block's `.text.length`; an image/document block's `.data.length`, i.e. its base64 payload) — never
@@ -3801,7 +3829,7 @@ export type TaskEvent = ({
3801
3829
  totalChars?: number;
3802
3830
  } & TaskEventIdentity) | ({
3803
3831
  /**
3804
- * RB-126 / blackboard [1669]⑥ — context occupancy at a compaction boundary, emitted on EVERY
3832
+ * RB-126 — context occupancy at a compaction boundary, emitted on EVERY
3805
3833
  * boundary (not only when a compaction fires). The three numbers are the engine's own trigger
3806
3834
  * inputs, verbatim: `usedTokens > compactAtTokens` IS the predicate `shouldCompact` evaluates, so a
3807
3835
  * consumer's "context is N% full" indicator and the moment compaction actually fires can never
@@ -3862,7 +3890,7 @@ export type TaskEvent = ({
3862
3890
  } & TaskEventIdentity) | ({
3863
3891
  /** design/99 MF-18: a compaction boundary (or, since design/119 #1, mid-turn when the prompt-too-long recovery force-compacts between a failed request and its retry). `trigger` = what caused it: `"auto"` (the context-threshold
3864
3892
  * auto-compaction), `"manual"` (the `TaskStream.compact` / `/compact` path), or `"forced"` (RB-398-b
3865
- * [2105]: the prompt-too-long recovery and trim-pressure lanes — compaction was not optional; the
3893
+ * the prompt-too-long recovery and trim-pressure lanes — compaction was not optional; the
3866
3894
  * hook layer's `PreCompactContext.trigger` always had this third state and the wire now carries the
3867
3895
  * SAME value the hooks saw instead of flattening it to `"auto"`. Additive value space — a consumer
3868
3896
  * switching on auto/manual keeps its exact old behavior). `tokensBefore` = the
@@ -3922,7 +3950,7 @@ export type TaskEvent = ({
3922
3950
  phaseDurations?: import("./auto-compaction.js").CompactionPhaseDurations;
3923
3951
  } & TaskEventIdentity) | ({
3924
3952
  /**
3925
- * RB-398-b ([2105]): a compaction pass concluded WITHOUT landing — the non-landing outcomes
3953
+ * RB-398-b④: a compaction pass concluded WITHOUT landing — the non-landing outcomes
3926
3954
  * used to exist only as `compaction.*` trace frames, so a stream-only consumer watched a
3927
3955
  * context quietly stop being managed (breaker opens, rapid-refill disable, hook blocks —
3928
3956
  * all invisible). One lightweight additive event, emitted at the same sites as the trace
@@ -4124,12 +4152,12 @@ export type TaskEvent = ({
4124
4152
  * top-level run) has no generation concept, and absence must never be read as "cycle 1".
4125
4153
  */
4126
4154
  seq?: number;
4127
- /** [1611] workflow-lane self-identification (server field-proof: the SSE-forwarded tick of a
4155
+ /** Workflow-lane self-identification (field-proven: the SSE-forwarded tick of a
4128
4156
  * WORKFLOW child previously carried a bare uuid with no workflow identity — indistinguishable
4129
4157
  * from an unknown nested subagent; the fleet lane had `wa*`+workflowRunId but this lane had
4130
4158
  * nothing). Present iff the tick bubbled out of a workflow-spawned agent. Additive. */
4131
4159
  workflowRunId?: string;
4132
- /** [1611] the workflow agent's display label (opts.label / auto `agent-N`), riding with
4160
+ /** the workflow agent's display label (opts.label / auto `agent-N`), riding with
4133
4161
  * {@link workflowRunId} for the same self-identification. Additive. */
4134
4162
  workflowAgentLabel?: string;
4135
4163
  /** design/99 (nested-subagent live tree): the spawning run's taskId — present on a DEEPER-than-1 subagent tick
@@ -4154,7 +4182,7 @@ export type TaskEvent = ({
4154
4182
  toolUses: number;
4155
4183
  durationMs: number;
4156
4184
  };
4157
- /** Per-turn ticks are `"running"`. [1414]#3: ONE final tick fires at the sub-run's settle with the
4185
+ /** Per-turn ticks are `"running"`. ONE final tick fires at the sub-run's settle with the
4158
4186
  * terminal face (`"completed"` | `"failed"` — timeout/blocked fold to failed; a suspended durable
4159
4187
  * pause emits no terminal tick), so a uuid-lane consumer sees the row finish instead of a bare
4160
4188
  * removal after the last running beat. Additive value space — a consumer switching on "running"
@@ -4404,11 +4432,11 @@ export interface TaskStream extends AsyncIterable<TaskEvent> {
4404
4432
  * design/98 §E.2 / §2.5 (S8b) — the deployment-trusted governance that EVERY sub-agent an LLM-authored
4405
4433
  * workflow script spawns INHERITS (tighten-only). The child spec is BUILT from this baseline + a strict
4406
4434
  * WHITELIST of safe work-fields the script may set — `{ ...base, ...pick(scriptSpec, WHITELIST_KEYS) }` then
4407
- * `tightenTaskSpec(base, child)` (codex BLOCKER2: default-deny / complete-by-construction, NOT a blacklist
4435
+ * `tightenTaskSpec(base, child)` (default-deny / complete-by-construction, NOT a blacklist
4408
4436
  * strip — a missed control-plane field would otherwise leak). It is captured from `RunnerDeps` (trusted,
4409
4437
  * never LLM-influenced), NEVER from the LLM-influenced initiating task spec.
4410
4438
  *
4411
- * Why an EXPLICIT field (codex Q1/Q2 arbitration): `RunnerDeps` has no `tools`/`mcp`/`skills`/`principal`
4439
+ * Why an EXPLICIT field (arbitration): `RunnerDeps` has no `tools`/`mcp`/`skills`/`principal`
4412
4440
  * (those are TaskSpec-only), so the capability a workflow child gets cannot be auto-derived from deps —
4413
4441
  * the deployment must DECLARE it here. Unset ⇒ self-orchestration is FAIL-CLOSED (the `run_workflow` tool is
4414
4442
  * not mounted, same hard deploy gate as a missing sandbox): a script-spawned agent must never run without a
@@ -4449,7 +4477,7 @@ export interface WorkflowGovernanceBaseline {
4449
4477
  */
4450
4478
  worktreeBase?: Partial<TaskSpec>;
4451
4479
  /**
4452
- * The allowed model NAMES an LLM-authored script may pick (design/98 §2.5, codex 新洞2). A script gives a
4480
+ * The allowed model NAMES an LLM-authored script may pick (design/98 §2.5 新洞2). A script gives a
4453
4481
  * `modelName` string (never a `Model` object — that carries `baseUrl`/`headers` = exfil); the engine
4454
4482
  * resolves it against this list to a deploy-configured `Model` (the script never sees the object).
4455
4483
  * **FAIL-CLOSED**: `undefined`/empty ⇒ the script CANNOT pick a model (its `modelName` is rejected → the
@@ -4516,10 +4544,10 @@ export interface RuntimeCaps {
4516
4544
  export interface BackgroundChildEvent {
4517
4545
  kind: "spawn" | "tick" | "terminal";
4518
4546
  /** Row key, stable across all three kinds. The prefix is the DOMAIN DISCRIMINATOR (load-bearing,
4519
- * not opaque — design/149 + [1432]①): `a*` = registry handle (background subagent —
4547
+ * not opaque — design/149): `a*` = registry handle (background subagent —
4520
4548
  * TaskOutput/TaskStop addressable, fleet-footer display lane); `wa*` = synthetic workflow-agent
4521
4549
  * row (NOT a registry row — per-agent read face is the workflow's `TaskOutput(w*)` agent_runs
4522
- * projection + journal API). Display contract ([1433] CC anchor): CC's footer renders ONLY the
4550
+ * projection + journal API). Display contract (CC anchor): CC's footer renders ONLY the
4523
4551
  * workflow AGGREGATE row — `wa*` rows are read-face/observability rows and SHOULD NOT be
4524
4552
  * rendered in the footer fleet tree; shells filter on the prefix. */
4525
4553
  taskId: string;
@@ -4531,33 +4559,33 @@ export interface BackgroundChildEvent {
4531
4559
  scope?: string;
4532
4560
  /** spawn: the child's short description (bounded, display-safe). */
4533
4561
  description?: string;
4534
- /** spawn + tick ([1336]A, [1346]②): the RESOLVED subagent type ("general-purpose" / "Explore" /
4562
+ /** spawn + tick: the RESOLVED subagent type ("general-purpose" / "Explore" /
4535
4563
  * a roster name / "fork") — the fleet row's TYPE column. Never the description. On ticks it is
4536
4564
  * the ROW's type (this spawn), not the nested frame's origin — `progressTaskId` keys that. Rides
4537
4565
  * every tick so a consumer that only forwards ticks (server K-7) still gets the type without
4538
4566
  * waiting for spawn-frame forwarding; `name` stays the design/99 DISPLAY label (description-backed)
4539
4567
  * and was never a type field. */
4540
4568
  agentType?: string;
4541
- /** spawn ([1344]②): the HOST task's DECLARED task id (parent attribution). Omitted when the host
4569
+ /** spawn: the HOST task's DECLARED task id (parent attribution). Omitted when the host
4542
4570
  * run declared no task id (the `spec.taskId ?? sessionId` fallback would launder a session id into
4543
4571
  * a task-id field — the orphan-pointer shape); {@link parentSessionId} is the always-on linkage. */
4544
4572
  parentTaskId?: string;
4545
- /** spawn (codex 1350 r2 F2): the HOST run's session id (uuid domain) — the always-on parent
4573
+ /** spawn: the HOST run's session id (uuid domain) — the always-on parent
4546
4574
  * linkage, present whether or not a task id was declared. */
4547
4575
  parentSessionId?: string;
4548
- /** spawn (δ 批 [1498]⑦): the ROOT host session of the delegation tree (uuid domain). For a depth-1
4576
+ /** spawn: the ROOT host session of the delegation tree (uuid domain). For a depth-1
4549
4577
  * child it equals {@link parentSessionId}; for a nested grandchild it is the TOP session while
4550
4578
  * parentSessionId is the intermediate spawner — a recovery/enumeration consumer groups the whole
4551
4579
  * tree under the root without walking intermediate (possibly dead) sessions. */
4552
4580
  rootSessionId?: string;
4553
- /** spawn (δ 批 [1491]③c): epoch ms the child run was launched — the fleet row's time anchor
4581
+ /** spawn: epoch ms the child run was launched — the fleet row's time anchor
4554
4582
  * (elapsed rendering without waiting for the first tick). */
4555
4583
  startedAt?: number;
4556
- /** All kinds, `wa*` rows only (design/149 2, [1432]② ruling b): the owning workflow run's
4584
+ /** All kinds, `wa*` rows only (design/149 face 2): the owning workflow run's
4557
4585
  * `w*` id. `parentTaskId` stays task-domain (the HOST task) so parent resolvers that only
4558
4586
  * forward resolved task rows keep working; workflow grouping/nesting is THIS annotation's job. */
4559
4587
  workflowRunId?: string;
4560
- /** All kinds ([1832]/[1839] cross-repo P1-2): the delegating Agent tool call's OWN `toolCallId` —
4588
+ /** All kinds: the delegating Agent tool call's OWN `toolCallId` —
4561
4589
  * the same identity {@link TaskEvent}'s `parentToolCallId` already carries on every forwarded child
4562
4590
  * content event (via `RunInternals.parentToolCallId`), extended to this SEPARATE observer/fleet
4563
4591
  * event family so a consumer does not have to reassemble parent attribution from spawn-frame
@@ -4578,7 +4606,7 @@ export interface BackgroundChildEvent {
4578
4606
  */
4579
4607
  currentAction?: string;
4580
4608
  /**
4581
- * tick [1828] (server cross-repo, structured Progress-section source): the SAME `{tool, target}` pair
4609
+ * tick (structured Progress-section source): the SAME `{tool, target}` pair
4582
4610
  * {@link currentAction} concatenates into prose, exposed separately so a consumer can look `toolName`
4583
4611
  * up in its own tool registry (CC `renderToolActivity` parity) instead of parsing the human line.
4584
4612
  * `target` is UNTRUSTED free text (a file path / command / pattern the child chose) — same trust
@@ -4637,7 +4665,7 @@ export interface BackgroundChildEvent {
4637
4665
  * knowable (the registry handle / retain ledger's `cycleSeq`, the durable row's `seq` on a tier-3
4638
4666
  * revival / parked resume), absent when no carrier exists (forging a period would lie). */
4639
4667
  seq?: number;
4640
- /** terminal, P1-3(黑板 [1920]/[1921]/[1924]/[1925]): the cross-channel completion correlation id —
4668
+ /** terminal: the cross-channel completion correlation id —
4641
4669
  * MIRROR of the sibling task_notification's `TaskNotificationPayload.completionId` (same settle,
4642
4670
  * same minted value; the fleet lane was explicitly one of the four channels the original ask named
4643
4671
  * — "同一完成今天从四条通道扇出" — so it gets the same mirror treatment `seq`/`stoppedBy` already
@@ -4691,7 +4719,7 @@ export interface BackgroundChildEvent {
4691
4719
  * would stamp delegation frames onto host-resumed root tasks. Rows minted WITH the axis resume
4692
4720
  * with their spawn/terminal pair even deps-only; a resume that re-supplies trusted internals
4693
4721
  * (every in-engine lane does) was never affected.
4694
- * PAIRING (codex r2-D2 closed the one hole): a spawn frame is always closed by a terminal frame —
4722
+ * PAIRING (closed the one hole): a spawn frame is always closed by a terminal frame —
4695
4723
  * the ordinary path emits it where the `TaskResult` assembles, and a POST-SPAWN throw that the
4696
4724
  * stream layer converts into a synthesized failed result (e.g. `resume.tool_unavailable` re-thrown
4697
4725
  * past the run tail) emits the failed terminal from that backstop, gated on a carrier that is set
@@ -4787,7 +4815,7 @@ export interface ProjectMemoryLoad {
4787
4815
  */
4788
4816
  instructionSources?: ReadonlyArray<{
4789
4817
  path: string;
4790
- /** [1001]②a (server request, additive widening): `null` = the source is DECLARED but currently
4818
+ /** (additive widening): `null` = the source is DECLARED but currently
4791
4819
  * ABSENT from disk — the change probe then watches for its APPEARANCE (renders "absent → hash").
4792
4820
  * Runtime already handled null (collectInstructionsChange's from===null arm); this widening
4793
4821
  * only aligns the declared type with the shipped behavior. */
@@ -4829,6 +4857,20 @@ export interface EngineNotice {
4829
4857
  * catalog itself. In-flight tasks finish on the models they resolved at prepare (natural
4830
4858
  * snapshot); every later prepare resolves against the new generation. A failed swap (illegal
4831
4859
  * tier binding) throws atomically and mints nothing.
4860
+ * - `"route.fallback_to_primary"` (key↔URL pairing, `src/brain/route-adjudicator.ts`) — a
4861
+ * DERIVED-leg model (role/tier/system-default resolution, never a caller-explicit one) failed
4862
+ * the pairing pre-flight and the seat fell back to the primary model instead of sinking the
4863
+ * task; the notice is the loud half of that swap. `detail: { seat, from, to, cause, fixHint }`
4864
+ * — `cause` is the refusal code (`route.credential_mismatch` / `route.credential_missing`).
4865
+ * Explicitly-named models never mint this: they refuse at the brain's request gate instead.
4866
+ * - `"route.base_url_changed_key_unchanged"` (key↔URL pairing) — `Runner.swapModels` moved a
4867
+ * same-name entry's `baseUrl` while its Model-visible credential half (auth-bearing headers)
4868
+ * did not change: legal (a provider changing domains), but worth one loud line — if the
4869
+ * PROVIDER changed, the credential reference needs the same update. Advisory only, never a
4870
+ * refusal; per-model-hook credentials are invisible to the catalog swap, so the notice is
4871
+ * deliberately conservative (it may fire when a hook-side credential DID change in lockstep).
4872
+ * One aggregated notice per swap; `detail: { entries: [{ modelId, from, to }], total }`
4873
+ * (rendered list bounded, total always exact).
4832
4874
  * - `"config.read_face_deployment_clamped"` (#237) — a deployment-wide `readFace: "open"` is not
4833
4875
  * in force beside a read-only (verifier) mount: it clamps to "roots" without throwing
4834
4876
  * (stricter-wins; the clamp verdict stands, only its occurrence was undisclosed). Announced
@@ -4947,6 +4989,16 @@ export interface EngineNotice {
4947
4989
  * mark would have carried, neutralized/length-bounded (tool and agent-type names are
4948
4990
  * host/model-controlled inputs).
4949
4991
  *
4992
+ * - `"memory.consolidation_incomplete"` (design/376, LLM consolidation driver) — a driver run
4993
+ * settled without reaching the fixpoint: `detail` names the stop reason (the closed
4994
+ * `ConsolidationRunStopReason` set), cycles done, and the residue (write-failure or
4995
+ * fuse-refused groups by name). Advisory: committed cycles stand (add-only, never rolled
4996
+ * back); the recovery verb is re-running the host driver, which resumes the same pending run.
4997
+ * - `"memory.consolidation_driver_superseded"` (same family) — a concurrent driver invocation
4998
+ * took over this scope's run row (attempt fencing): the losing worker stops with this code
4999
+ * and MUST NOT retry into the winner's account. Coordination fact between two host calls,
5000
+ * not a principal ruling — listed in the non-governance disposition table.
5001
+ *
4950
5002
  * - `"delegation.transcript_integrity"` (subagent transcript persistence) — a durable agent row
4951
5003
  * with a BOUND transcript sessionId met a session store that attests `not_found` for it: the
4952
5004
  * deployment's declared transcript durability is being contradicted by reality. Announced at
@@ -5049,7 +5101,7 @@ export interface RunnerDeps {
5049
5101
  isRevoked(serverName: string): boolean;
5050
5102
  };
5051
5103
  /**
5052
- * design/147 S1c (clay ruling 2026-07-18) — the DURABLE name→agent roster behind explicit-name
5104
+ * design/147 S1c (ruled 2026-07-18) — the DURABLE name→agent roster behind explicit-name
5053
5105
  * addressing, a storage-tier seam like the checkpoint store: core bundles `MemoryRosterStore`
5054
5106
  * (default when omitted... none — omitted means NO durable roster; the in-memory task registry
5055
5107
  * still resolves live/recent names exactly as before) and `FileRosterStore`; a server deployment
@@ -5215,6 +5267,39 @@ export interface RunnerDeps {
5215
5267
  * {@link memoryProvenance}.
5216
5268
  */
5217
5269
  memoryConsolidation?: import("../core/memory-engine/consolidation.js").MemoryConsolidationOptions;
5270
+ /**
5271
+ * design/376 片② — the memory-consolidation DRIVER seat (the LLM half), ORTHOGONAL to
5272
+ * {@link memoryConsolidation} on purpose: that key is the write PROTOCOL's parameters (fuse,
5273
+ * caps, cadence — engine-side), this key is who thinks (model seat + mint knobs — driver-side).
5274
+ * The ENGINE itself keeps zero model seats (design/339 §1.1: engine adjudicates, driver
5275
+ * proposes; an engine-held model would put distillation authority on the wrong side of the
5276
+ * trust boundary), so the seat lives here and is consumed by the host driver verb
5277
+ * (`runMemoryConsolidationDriver` + `resolveMemoryConsolidationDriver(deps)`).
5278
+ *
5279
+ * `chat` — the explicit model seat: an endpoint triple (screened loudly: explicit model id, no
5280
+ * alias spellings, key present) or any JSON-only completion function. ABSENT ⇒ the driver
5281
+ * resolves the `consolidate` role (`consolidate → summarize → coded refusal`; deliberately
5282
+ * never `default` — see the {@link ModelRole} doc). Every other knob mirrors the driver verb's
5283
+ * options and is screened there (#123: bad values refuse coded, never fold to defaults).
5284
+ * DEPLOYMENT seat ONLY, same law as {@link memoryConsolidation}: no TaskSpec twin — a task
5285
+ * author gets no channel to point the library's consolidation at a model of its choosing.
5286
+ * Absent alongside absent {@link memoryConsolidation} ⇒ nothing runs and nothing changes
5287
+ * (the v3 default posture).
5288
+ */
5289
+ memoryConsolidationDriver?: {
5290
+ chat?: {
5291
+ baseUrl: string;
5292
+ apiKey: string;
5293
+ model: string;
5294
+ } | import("../core/memory-engine/distiller.js").DistillerChatFn;
5295
+ /** The audit model id — REQUIRED when `chat` is a bare function (a function carries no id and
5296
+ * the run/archive must not record a guess); derived from the endpoint triple or the resolved
5297
+ * role otherwise. */
5298
+ model?: string;
5299
+ contract?: import("../core/memory-engine/distiller.js").LlmDistillerContract;
5300
+ maxCycles?: number;
5301
+ mintRepairBudget?: number;
5302
+ };
5218
5303
  /**
5219
5304
  * design/199 件A — the DEPLOYMENT's read-face declaration
5220
5305
  * ({@link import("../tools/fs/read-face.js").ReadFace}; see {@link TaskSpec.readFace} for the
@@ -5503,7 +5588,7 @@ export interface RunnerDeps {
5503
5588
  * `SubagentToolOptions.background.agentStore` (spawn-side writer half) — the engine cannot
5504
5589
  * verify the pairing (the Agent tool is deployment-composed), and a half-wired deployment is a
5505
5590
  * SILENT degrade: reader-only ⇒ no rows ever exist; writer-only ⇒ the auto-mounted fallbacks
5506
- * here never see them (全景复审 F-6; RB-37). Third consumer ([1511] server 复审): delegated
5591
+ * here never see them (RB-37). Third consumer: delegated
5507
5592
  * CHILDREN's auto-mounted TaskOutput/TaskStop/AgentTranscript read THIS deps too (prepare-task
5508
5593
  * wires them from the child's runner) — a sub-runner with different deps splits the read face. */
5509
5594
  backgroundAgentStore?: import("./background-agent-store.js").BackgroundAgentStore;
@@ -5594,12 +5679,12 @@ export interface RunnerDeps {
5594
5679
  * the handle — no host-context leak into the runner); the deployment registers it by `runId`+`label` to route a
5595
5680
  * human/cross-replica steer to `handle.steer(...)`. Unset ⇒ agents run non-steerable (no overhead). Opt-in.
5596
5681
  *
5597
- * **Interaction with {@link workflowJournalStore} ([1422]② updated)**: a steerable agent runs via
5682
+ * **Interaction with {@link workflowJournalStore}**: a steerable agent runs via
5598
5683
  * `agentStream`, whose results ARE RECORDED in the journal since 1.355 (complete read-face: the journal
5599
5684
  * API / diagnostics coordinate show every agent) but are NEVER REPLAYED — `resumeFromRunId` on a
5600
5685
  * steerable workflow still re-runs agents LIVE (steer input is not deterministic; a cache would replay
5601
5686
  * a result the operator steered). Pre-1.355 the stream lane recorded NOTHING — with both deps set the
5602
- * journal read empty on every workflow (the [1419]② zero-write case), silently.
5687
+ * journal read empty on every workflow (the zero-write case), silently.
5603
5688
  */
5604
5689
  onWorkflowAgentSpawn?: (handle: import("../orchestration/workflow.js").WorkflowAgentHandle) => void;
5605
5690
  /** design/72 §2.2 (B): deployment default for the suspend-loop cap (see `TaskSpec.maxSuspends`).
@@ -5626,7 +5711,7 @@ export interface RunnerDeps {
5626
5711
  * When set AND `spec.memory.enabled`, the task runs the INJECTION-FIRST file-based memory lifecycle
5627
5712
  * (materialize → session file ops → harvest with the full gate set), the CC-verbatim `# Memory`
5628
5713
  * instruction + fenced derived index replace the legacy `<user_memory>` block, and NO remember/recall
5629
- * tools are mounted (memory = the model's ordinary file skills). **S4 (codex 1.258 F6 doc fix): unset ⇒
5714
+ * tools are mounted (memory = the model's ordinary file skills). **S4: unset ⇒
5630
5715
  * the task runs MEMORY-LESS** — the legacy `memoryStore` runtime path was retired (one deprecation
5631
5716
  * warning via `onError` phase `"config"`); this field is the ONLY live memory seam.
5632
5717
  */
@@ -5799,7 +5884,7 @@ export interface RunnerDeps {
5799
5884
  onAsk?: import("./tool-policy.js").OnAsk;
5800
5885
  /** Content-ask seam (design/64 §5): when set, every task mounts an AskUserQuestion tool that routes a
5801
5886
  * model-issued question to this callback (a real human/UI). Distinct from `onAsk` (permission). A task's
5802
- * own `onQuestion` overrides this. Unset ⇒ the tool mounts only if another [884] delivery face exists
5887
+ * own `onQuestion` overrides this. Unset ⇒ the tool mounts only if another delivery face exists
5803
5888
  * (durable park consumer / explicit `TaskSpec.interactiveTools` — see that knob's criterion table). */
5804
5889
  onQuestion?: import("./ask-question.js").OnQuestion;
5805
5890
  /**