@sema-agent/core 7.61.0 → 7.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/CHANGELOG.md +312 -0
  2. package/dist/agents/cascade.d.ts +11 -3
  3. package/dist/agents/cascade.js +1 -1
  4. package/dist/agents/peer-held-queue.d.ts +27 -4
  5. package/dist/agents/peer-held-queue.js +81 -36
  6. package/dist/agents/peer-session-drain.js +13 -3
  7. package/dist/agents/subagent.d.ts +6 -1
  8. package/dist/agents/subagent.js +66 -12
  9. package/dist/agents/suspend-guard.d.ts +38 -16
  10. package/dist/agents/suspend-guard.js +9 -4
  11. package/dist/agents/verify.js +4 -3
  12. package/dist/core/checkpoint-features.d.ts +722 -0
  13. package/dist/core/checkpoint-features.js +98 -0
  14. package/dist/core/checkpoint-requirements.d.ts +9 -2
  15. package/dist/core/checkpoint-requirements.js +9 -4
  16. package/dist/core/checkpoint-row-verdict.d.ts +99 -0
  17. package/dist/core/checkpoint-row-verdict.js +225 -0
  18. package/dist/core/checkpoint-store.d.ts +55 -745
  19. package/dist/core/checkpoint-store.js +39 -141
  20. package/dist/core/engine-notice.d.ts +19 -3
  21. package/dist/core/engine-notice.js +9 -2
  22. package/dist/core/gate-fold.js +2 -2
  23. package/dist/core/governance-codes.d.ts +3 -1
  24. package/dist/core/governance-codes.js +3 -0
  25. package/dist/core/hooks.d.ts +13 -0
  26. package/dist/core/human-input-projection.d.ts +1 -0
  27. package/dist/core/human-input-projection.js +3 -0
  28. package/dist/core/image-admission.d.ts +1 -1
  29. package/dist/core/locked-config.d.ts +2 -2
  30. package/dist/core/mcp-host-seat.js +6 -1
  31. package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
  32. package/dist/core/memory-vector.d.ts +1 -1
  33. package/dist/core/memory.d.ts +10 -10
  34. package/dist/core/mode-policy.js +1 -1
  35. package/dist/core/mods/classic-events.d.ts +9 -1
  36. package/dist/core/mods/dollar.d.ts +32 -1
  37. package/dist/core/mods/dollar.js +13 -1
  38. package/dist/core/mods/kernel/events.d.ts +11 -3
  39. package/dist/core/mods/kernel/events.js +13 -10
  40. package/dist/core/mods/lifecycle-stations.d.ts +36 -4
  41. package/dist/core/mods/lifecycle-stations.js +44 -9
  42. package/dist/core/mods/session-append.d.ts +4 -1
  43. package/dist/core/mods/session-append.js +7 -0
  44. package/dist/core/mods/session-receive.js +12 -15
  45. package/dist/core/mods/stations.d.ts +51 -6
  46. package/dist/core/mods/stations.js +124 -0
  47. package/dist/core/own-property-receipt.d.ts +7 -0
  48. package/dist/core/own-property-receipt.js +3 -0
  49. package/dist/core/read-root-candidate.js +1 -1
  50. package/dist/core/resume-startup-cause.d.ts +5 -4
  51. package/dist/core/runner/compact-session.js +5 -2
  52. package/dist/core/runner/contracts.d.ts +18 -8
  53. package/dist/core/runner/delegation-owner.d.ts +43 -0
  54. package/dist/core/runner/delegation-owner.js +59 -0
  55. package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
  56. package/dist/core/runner/lineage-reroot-view.js +108 -0
  57. package/dist/core/runner/permission-rule-lanes.d.ts +2 -1
  58. package/dist/core/runner/permission-rule-lanes.js +2 -2
  59. package/dist/core/runner/person-path-rows.d.ts +15 -0
  60. package/dist/core/runner/person-path-rows.js +26 -3
  61. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
  62. package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
  63. package/dist/core/runner/prepare-caps-and-workflow.d.ts +1 -0
  64. package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
  65. package/dist/core/runner/prepare-config-doors.d.ts +6 -6
  66. package/dist/core/runner/prepare-config-doors.js +3 -4
  67. package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
  68. package/dist/core/runner/prepare-hands-readface.js +28 -7
  69. package/dist/core/runner/prepare-inherited-gate.d.ts +2 -0
  70. package/dist/core/runner/prepare-inherited-gate.js +7 -3
  71. package/dist/core/runner/prepare-task.js +10 -7
  72. package/dist/core/runner/resume-admission.d.ts +3 -3
  73. package/dist/core/runner/resume-admission.js +6 -3
  74. package/dist/core/runner/resume-apply.d.ts +4 -0
  75. package/dist/core/runner/resume-apply.js +11 -4
  76. package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
  77. package/dist/core/runner/resume-checkpoint-screen.js +4 -84
  78. package/dist/core/runner/run-git-lane.d.ts +2 -0
  79. package/dist/core/runner/run-git-lane.js +4 -1
  80. package/dist/core/runner/run-harness-handlers.d.ts +2 -0
  81. package/dist/core/runner/run-harness-handlers.js +3 -2
  82. package/dist/core/runner/run-leg.js +24 -7
  83. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  84. package/dist/core/runner/run-stop-and-final-verify.js +2 -1
  85. package/dist/core/runner/run-turn-boundary.js +7 -4
  86. package/dist/core/runner/runtask.js +6 -6
  87. package/dist/core/runner/steering-preview.d.ts +9 -0
  88. package/dist/core/runner/steering-preview.js +5 -0
  89. package/dist/core/runner/stream-steer-verb.js +8 -0
  90. package/dist/core/runner/tool-face-overlay.js +2 -0
  91. package/dist/core/runner/turn-attachments.d.ts +5 -0
  92. package/dist/core/runner/turn-attachments.js +1 -1
  93. package/dist/core/runner-deps.d.ts +2 -2
  94. package/dist/core/secret-env.d.ts +8 -5
  95. package/dist/core/secret-env.js +37 -18
  96. package/dist/core/session-store.d.ts +1 -1
  97. package/dist/core/session-store.js +5 -1
  98. package/dist/core/session.d.ts +14 -4
  99. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -0
  100. package/dist/core/store-contracts/checkpoint-store-contract.js +68 -0
  101. package/dist/core/store-contracts/session-store-contract.js +22 -8
  102. package/dist/core/task-event.d.ts +7 -1
  103. package/dist/core/task-notification.js +2 -1
  104. package/dist/core/task-registry-agent.d.ts +27 -7
  105. package/dist/core/task-registry-agent.js +12 -5
  106. package/dist/core/task-registry-shared.d.ts +7 -0
  107. package/dist/core/task-registry-workflow.js +4 -3
  108. package/dist/core/task-registry.d.ts +13 -2
  109. package/dist/core/task-registry.js +11 -4
  110. package/dist/core/task-result.d.ts +5 -5
  111. package/dist/core/task-spec.d.ts +1 -1
  112. package/dist/core/terminal-cause.d.ts +6 -6
  113. package/dist/core/tool-face.d.ts +6 -2
  114. package/dist/core/tool-face.js +1 -1
  115. package/dist/core/tool-policy.d.ts +2 -1
  116. package/dist/core/tool-roster.d.ts +4 -4
  117. package/dist/core/tool-spec.d.ts +4 -0
  118. package/dist/core/types.d.ts +1 -1
  119. package/dist/core/types.js +1 -1
  120. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  121. package/dist/engine/execution-env/node-execution-env.js +12 -5
  122. package/dist/engine/harness/types.d.ts +11 -0
  123. package/dist/engine/session/parent-chain-guard.d.ts +3 -3
  124. package/dist/engine/session/parent-chain-guard.js +1 -1
  125. package/dist/engine/session/path-to-root.d.ts +18 -3
  126. package/dist/engine/session/path-to-root.js +15 -1
  127. package/dist/engine/session/repo-utils.d.ts +12 -1
  128. package/dist/engine/session/repo-utils.js +41 -0
  129. package/dist/engine/session/session.js +1 -1
  130. package/dist/engine/session/storage-base.d.ts +20 -0
  131. package/dist/engine/session/storage-base.js +28 -9
  132. package/dist/index.d.ts +9 -8
  133. package/dist/index.js +4 -4
  134. package/dist/internal/harness.d.ts +4 -3
  135. package/dist/internal/harness.js +3 -2
  136. package/dist/orchestration/run-workflow-tool.d.ts +3 -0
  137. package/dist/orchestration/run-workflow-tool.js +27 -11
  138. package/dist/orchestration/workflow-governance.d.ts +1 -1
  139. package/dist/orchestration/workflow.d.ts +3 -0
  140. package/dist/orchestration/workflow.js +2 -7
  141. package/dist/stores/file/checkpoint-store.d.ts +2 -0
  142. package/dist/stores/file/checkpoint-store.js +7 -6
  143. package/dist/stores/file/fs-atomic.d.ts +0 -22
  144. package/dist/stores/file/fs-atomic.js +0 -17
  145. package/dist/stores/file/index.d.ts +2 -9
  146. package/dist/stores/file/index.js +2 -4
  147. package/dist/stores/file/session-store.d.ts +13 -7
  148. package/dist/stores/file/session-store.js +40 -17
  149. package/dist/tools/fs/bash-program-position.d.ts +3 -2
  150. package/dist/tools/fs/bash-program-position.js +7 -7
  151. package/dist/tools/fs/removal-targets.js +2 -2
  152. package/dist/tools/fs/shell-read-argv.d.ts +4 -2
  153. package/dist/tools/fs/shell-read-argv.js +14 -3
  154. package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
  155. package/dist/tools/fs/shell-read-bindings.js +148 -68
  156. package/dist/tools/fs/shell-read-check.js +20 -4
  157. package/dist/tools/fs/shell-read-establish.js +22 -8
  158. package/dist/tools/fs/shell-read-functions.js +2 -2
  159. package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
  160. package/dist/tools/fs/shell-read-object-path.js +119 -0
  161. package/dist/tools/fs/shell-read-plan.d.ts +8 -0
  162. package/dist/tools/fs/shell-read-plan.js +47 -30
  163. package/dist/tools/fs/shell-read-start.d.ts +66 -13
  164. package/dist/tools/fs/shell-read-start.js +89 -17
  165. package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
  166. package/dist/tools/fs/shell-read-workdir.js +31 -8
  167. package/package.json +2 -2
  168. package/test/export-surface.snapshot.json +21 -33
  169. package/wire-changes/core-stores-sql@7.62.0.json +30 -0
  170. package/wire-changes/core@7.62.0.json +2181 -0
  171. package/wire-changes/mods-kernel@7.62.0.json +42 -0
  172. package/wire-changes/primitives@7.62.0.json +30 -0
  173. package/dist/core/consolidate-scope.d.ts +0 -93
  174. package/dist/core/consolidate-scope.js +0 -98
  175. package/dist/core/runner/memory-consolidation.d.ts +0 -109
  176. package/dist/core/runner/memory-consolidation.js +0 -251
@@ -1,10 +1,12 @@
1
1
  import { randomBytes, randomUUID } from "node:crypto";
2
2
  import { uuidv7 } from "../internal/harness.js";
3
- import { PROBE_CAUSE_PATH_MAX, PROBE_REASON_MAX, inlineUntrusted, sanitizeUntrustedText } from "./untrusted-text.js";
3
+ import { PROBE_REASON_MAX, inlineUntrusted, sanitizeUntrustedText } from "./untrusted-text.js";
4
+ import { CheckpointError, checkpointVersionOf, isPlainRecord, normalizeProbeCause, safeDataValue } from "./checkpoint-features.js";
5
+ import { judgeCheckpointRow, retiredSteerSeatRefusal } from "./checkpoint-row-verdict.js";
4
6
  import { carriesBidiControls } from "./tool-policy.js";
5
7
  import { agentIdOf, legTaskIdOf } from "./leg-identity.js";
6
8
  import { isAutoModeFallbackCause, readDenialLimitFallback } from "./auto-mode.js";
7
- import { isAskOrigin, isPermissionMode, isPersistedRuleMandate } from "./ask-origin.js";
9
+ import { isAskOrigin, isPersistedRuleMandate } from "./ask-origin.js";
8
10
  import { isRunOrigin, RUN_ORIGINS } from "./run-origin.js";
9
11
  import { describeRejectedValue } from "./tool-search-setting.js";
10
12
  import { readBoundBinding } from "./skill-grant-binding.js";
@@ -16,7 +18,8 @@ import { renderUntrustedCommandText, stripFormatCharacters } from "./permission-
16
18
  import { egressText } from "./untrusted-egress.js";
17
19
  import { steerReplayRefusal } from "./steer-replay.js";
18
20
  import { readRetentionDeclaration } from "./retention.js";
19
- import { optionKeys, receiveOptions } from "./own-property-receipt.js";
21
+ import { memberPresent, optionKeys, receiveOptions } from "./own-property-receipt.js";
22
+ export { BINDING_CHECKPOINT_VERSION, CHECKPOINT_CONFIG_REFUSAL_CODES, CHECKPOINT_FEATURES, CheckpointError, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, encodeAtFidelity, F012_CHECKPOINT_VERSION, FACE_CHECKPOINT_VERSION, isCheckpointConfigRefusalCode, isPlainRecord, MAX_SUPPORTED_CHECKPOINT_VERSION, normalizeProbeCause, ORG_ADMISSION_CHECKPOINT_VERSION, REAL_APPROVAL_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, safeDataValue, TOKEN_CHECKPOINT_VERSION, } from "./checkpoint-features.js";
20
23
  export function mintCheckpointToken() {
21
24
  return randomBytes(16).toString("hex");
22
25
  }
@@ -24,37 +27,6 @@ export function mintCheckpointId() {
24
27
  return `cp_${randomUUID()}`;
25
28
  }
26
29
  export { PROBE_REASON_MAX } from "./untrusted-text.js";
27
- const PROBE_CAUSE_MAX_SHOWN = 8;
28
- export function normalizeProbeCause(value) {
29
- if (!isPlainRecord(value))
30
- return undefined;
31
- const code = safeDataValue(value, "code");
32
- if (typeof code !== "string" || code.trim().length === 0)
33
- return undefined;
34
- const family = (raw) => {
35
- if (!isPlainRecord(raw))
36
- return undefined;
37
- const shownRaw = safeDataValue(raw, "shown");
38
- if (!Array.isArray(shownRaw))
39
- return undefined;
40
- const shown = shownRaw
41
- .filter((p) => typeof p === "string")
42
- .slice(0, PROBE_CAUSE_MAX_SHOWN)
43
- .map((p) => inlineUntrusted(p, PROBE_CAUSE_PATH_MAX));
44
- const totalRaw = safeDataValue(raw, "total");
45
- const total = typeof totalRaw === "number" && Number.isFinite(totalRaw) ? Math.max(0, Math.floor(totalRaw)) : shown.length;
46
- return { shown, total: Math.max(total, shown.length) };
47
- };
48
- const roots = family(safeDataValue(value, "roots"));
49
- if (roots === undefined)
50
- return undefined;
51
- const further = family(safeDataValue(value, "further"));
52
- return {
53
- code: inlineUntrusted(code, PROBE_REASON_MAX),
54
- roots,
55
- ...(further !== undefined && further.total > 0 ? { further } : {}),
56
- };
57
- }
58
30
  export function riskSeverity(axes) {
59
31
  return readRiskAxes(axes).tier;
60
32
  }
@@ -84,26 +56,6 @@ export const MAX_PENDING_STEER_CHARS = 16_000;
84
56
  export const PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES = 48_000;
85
57
  export const MAX_PENDING_STEER_ENTRIES = Math.floor(PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES / MAX_PENDING_STEER_CHARS);
86
58
  export const PENDING_STEER_FROZEN_FIELDS = Object.freeze(["text", "trusted", "actor", "seq", "inputId", "priority", "runOrigin"]);
87
- export function isPlainRecord(x) {
88
- try {
89
- if (x === null || typeof x !== "object" || Array.isArray(x))
90
- return false;
91
- const p = Object.getPrototypeOf(x);
92
- return p === Object.prototype || p === null;
93
- }
94
- catch {
95
- return false;
96
- }
97
- }
98
- export function safeDataValue(obj, key) {
99
- try {
100
- const d = Object.getOwnPropertyDescriptor(obj, key);
101
- return d && "value" in d ? d.value : undefined;
102
- }
103
- catch {
104
- return undefined;
105
- }
106
- }
107
59
  function safeKeys(obj) {
108
60
  try {
109
61
  return Object.keys(obj);
@@ -197,29 +149,6 @@ export function realApprovalOrgFact(bit) {
197
149
  return bit.org;
198
150
  return bit.origin === "org_rule" ? "rule" : bit.origin === "org_unavailable" ? "unavailable" : undefined;
199
151
  }
200
- export const CHECKPOINT_FEATURES = {
201
- baseline: { version: 1, introduced: "design/49", writes: "the row itself" },
202
- resource: { version: 2, introduced: "design/74", writes: "resourceLedger; gate/pendingAction kind resource_limit" },
203
- binding: { version: 3, introduced: "design/80", writes: "pendingAction.boundCallId + boundInputHash on a tool_approval; a plan_review carries the stamp only" },
204
- token: { version: 5, introduced: "design/164", writes: "resourceLedger.totalTokens" },
205
- orgAdmission: { version: 6, introduced: "org-admission", writes: "inheritedGate.admittedOrgScopes / ownAdmittedOrgScopes / ownAdmittedOrgWriteScope / orgAdmissionGoverned" },
206
- f012: { version: 7, introduced: "F-012", writes: "inheritedGate.constraintChain + constraintDigest together; delegationProvenance" },
207
- realApproval: { version: 8, introduced: "#130/#120", writes: "gate.realApproval (a well-formed bit) + pendingAction.requiresRealApproval; from v9: readFace.realApproval = true beside it" },
208
- face: { version: 9, introduced: "design/199", writes: "state.readFace { face, denyEntries? } for a non-default posture; realApproval: true only at the mint whose gate carries the bit (a hands-less re-park never carries the seed's marker forward)" },
209
- requirements: { version: 10, introduced: "#1320", writes: "requires (the row's words) + requirementsDigest (the row digest), both derived from its content (checkpoint-requirements.ts)" },
210
- };
211
- export const CURRENT_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.baseline.version;
212
- export const RESOURCE_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.resource.version;
213
- export const BINDING_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.binding.version;
214
- export const TOKEN_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.token.version;
215
- export const ORG_ADMISSION_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.orgAdmission.version;
216
- export const F012_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.f012.version;
217
- export const REAL_APPROVAL_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.realApproval.version;
218
- export const FACE_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.face.version;
219
- export const MAX_SUPPORTED_CHECKPOINT_VERSION = CHECKPOINT_FEATURES.requirements.version;
220
- export function checkpointVersionOf(cp) {
221
- return cp.version ?? 0;
222
- }
223
152
  function finiteBound(v) {
224
153
  return v !== undefined && Number.isFinite(v) ? v : undefined;
225
154
  }
@@ -282,13 +211,15 @@ export function planReviewRequesterOf(pendingAction) {
282
211
  const id = pendingAction.requestedByCallId;
283
212
  return typeof id === "string" && id !== "" ? id : undefined;
284
213
  }
285
- export function summarizeCheckpoint(cp, disclose) {
214
+ export function summarizeCheckpoint(cp, disclose, verdict) {
215
+ const rowVerdict = verdict ?? judgeCheckpointRow(cp);
286
216
  const facts = checkpointIndexFacts(cp);
217
+ const rowName = `checkpoint ${JSON.stringify(cp.checkpointId ?? null)} of session ${JSON.stringify(cp.sessionId)}`;
287
218
  const descriptor = facts.riskDescriptor;
288
219
  const axes = descriptor === null ? undefined : readRiskAxes(descriptor?.axes);
289
220
  const severity = axes?.tier;
290
221
  if (axes?.problem !== undefined) {
291
- disclose?.(`checkpoint ${JSON.stringify(cp.checkpointId ?? null)} of session ${JSON.stringify(cp.sessionId)}: the risk descriptor's axes are ${axes.problem} — ${severity === undefined ? "the summary carries no severity" : `the summary's severity ${severity} is read from the valid marks`}`);
222
+ disclose?.(`${rowName}: the risk descriptor's axes are ${axes.problem} — ${severity === undefined ? "the summary carries no severity" : `the summary's severity ${severity} is read from the valid marks`}`);
292
223
  }
293
224
  const cardReading = parkedApprovalCardOf(cp.gate);
294
225
  const tool = cp.pendingAction.kind === "tool_approval" ? cp.pendingAction : undefined;
@@ -305,12 +236,25 @@ export function summarizeCheckpoint(cp, disclose) {
305
236
  toolInput = undefined;
306
237
  }
307
238
  }
239
+ const shownPreview = tool?.preview;
308
240
  const hasBidi = tool !== undefined &&
309
241
  (facts.hasBidiControls === true ||
310
- carriesBidiControls([toolInput, tool.preview], { maxNodes: BIDI_BACKFILL_MAX_NODES, maxChars: BIDI_BACKFILL_MAX_CHARS }));
242
+ carriesBidiControls([toolInput, shownPreview], { maxNodes: BIDI_BACKFILL_MAX_NODES, maxChars: BIDI_BACKFILL_MAX_CHARS }));
311
243
  const agentId = agentIdOf({ taskId: legTaskIdOf({}, cp.state, cp.sessionId), isDelegatedChild: cp.state.isDelegatedChild === true });
244
+ const preview = (() => {
245
+ if (shownPreview === undefined)
246
+ return {};
247
+ try {
248
+ return { copy: structuredClone(shownPreview) };
249
+ }
250
+ catch {
251
+ disclose?.(`${rowName}: its approval preview is not a value a summary can copy — the summary carries no preview`);
252
+ return {};
253
+ }
254
+ })();
312
255
  return {
313
256
  token: facts.token,
257
+ rowVerdict,
314
258
  ...(cp.checkpointId !== undefined ? { checkpointId: cp.checkpointId } : {}),
315
259
  sessionId: facts.sessionId,
316
260
  scope: facts.scope,
@@ -331,7 +275,7 @@ export function summarizeCheckpoint(cp, disclose) {
331
275
  ? { restoreMode: cp.state.workspaceHandle.restoreMode === "park_only" ? "park_only" : "snapshot" }
332
276
  : {}),
333
277
  ...((runOrigin) => (isRunOrigin(runOrigin) ? { runOrigin } : {}))(cp.state.runOrigin),
334
- ...(tool?.preview !== undefined ? { preview: tool.preview } : {}),
278
+ ...("copy" in preview ? { preview: preview.copy } : {}),
335
279
  ...(tool?.previewWithheld === "oversize" || tool?.previewWithheld === "unavailable" ? { previewWithheld: tool.previewWithheld } : {}),
336
280
  ...(tool?.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
337
281
  ...(tool?.mandated === true ? { mandated: true } : {}),
@@ -350,17 +294,13 @@ export function summarizeCheckpoint(cp, disclose) {
350
294
  ...(hasBidi ? { hasBidiControls: true } : {}),
351
295
  };
352
296
  }
353
- export const CHECKPOINT_CONFIG_REFUSAL_CODES = Object.freeze(["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_invalid", "config.run_origin_invalid", "config.user_invoked_skill_unknown", "config.skill_deny_unreadable", "config.user_attachment_invalid", "config.tool_face_control", "config.deps_retired_key", "config.peer_presence_invalid", "config.tool_model_gate_invalid", "config.microcompact_invalid", "config.prompt_selector_invalid", "resume_at.conflicts_resume", "resume_at.mode_without_target", "config.read_face_invalid", "config.write_face_invalid", "config.invalid_argument", "config.tool_face_invalid", "config.memory_delegation_evidence", "config.memory_provenance", "config.memory_capture_policy", "config.cross_boundary_posture", "config.advisor_tool_invalid", "config.advisor_model_invalid", "config.auto_consolidation", "config.unknown_role", "config.tool_materialize_invalid", "config.memory_persistence_invalid", "config.tool_materialize_unreachable", "config.locked_registry", "config.locked_key", "config.mcp_content_class", "config.skill_listing_budget_invalid", "config.limit_unknown_key", "config.limit_invalid", "config.attachment_invalid", "config.usage_window_invalid", "config.brain_call_guardrail_invalid", "config.retention_policy", "config.retention_capability", "config.invalid_checkpoint_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing", "config.spec_member_unreadable", "config.spec_unknown_key"]);
354
- export const isCheckpointConfigRefusalCode = (word) => CHECKPOINT_CONFIG_REFUSAL_CODES.some((w) => w === word);
355
- export class CheckpointError extends Error {
356
- code;
357
- detail;
358
- constructor(code, message, detail) {
359
- super(message);
360
- this.code = code;
361
- this.detail = detail;
362
- this.name = "CheckpointError";
297
+ export function summarizeStoredCheckpoint(cp, memo, disclose) {
298
+ let verdict = memo.get(cp);
299
+ if (verdict === undefined) {
300
+ verdict = judgeCheckpointRow(cp);
301
+ memo.set(cp, verdict);
363
302
  }
303
+ return summarizeCheckpoint(cp, disclose, verdict);
364
304
  }
365
305
  export function resolveDeclaredFidelity(store, storeName) {
366
306
  const declared = store?.fidelity;
@@ -373,17 +313,6 @@ export function resolveDeclaredFidelity(store, storeName) {
373
313
  e.code = "config.store_fidelity_invalid";
374
314
  throw e;
375
315
  }
376
- export function encodeAtFidelity(fidelity, value) {
377
- if (fidelity === "structured-clone")
378
- return { ok: true, value };
379
- try {
380
- const encoded = JSON.stringify(value);
381
- return { ok: true, value: encoded === undefined ? undefined : JSON.parse(encoded) };
382
- }
383
- catch (err) {
384
- return { ok: false, cause: err };
385
- }
386
- }
387
316
  export function resolveCheckpointStore(spec, deps) {
388
317
  if (Object.is(spec.checkpointStore, null))
389
318
  throw retiredCheckpointStoreNull();
@@ -542,9 +471,9 @@ function captureActorAssertion(actor) {
542
471
  return { id, hostAsserted, ...(issuer !== undefined ? { issuer } : {}) };
543
472
  }
544
473
  export function readPendingSteerQueue(state) {
545
- if (state.pendingSteer !== undefined) {
546
- throw new CheckpointError("checkpoint.unsupported_version", "this checkpoint carries a parked steer in the retired pre-queue single seat (`state.pendingSteer`), which this engine does not read — decide the parked instruction on the host's surface and, if it still applies, park it again with setPendingSteer", { reason: "seat_retired" });
547
- }
474
+ const retired = retiredSteerSeatRefusal(state);
475
+ if (retired !== undefined)
476
+ throw retired;
548
477
  return [...(state.pendingSteerQueue ?? [])].sort((a, b) => a.seq - b.seq);
549
478
  }
550
479
  export function judgeParkedSteerRepeat(queue, entry) {
@@ -584,6 +513,7 @@ export class InMemoryCheckpointStore {
584
513
  fidelity = "structured-clone";
585
514
  execution = { outcome: true };
586
515
  cps = new Map();
516
+ rowVerdicts = new WeakMap();
587
517
  fault = null;
588
518
  disclose;
589
519
  holderIsCurrent;
@@ -617,7 +547,7 @@ export class InMemoryCheckpointStore {
617
547
  current: {
618
548
  status: cp.status,
619
549
  rev: checkpointRevOf(cp),
620
- ...(cp.resolvedOutcome !== undefined ? { resolvedOutcome: structuredClone(cp.resolvedOutcome) } : {}),
550
+ ...(memberPresent(cp, "resolvedOutcome") ? { resolvedOutcome: structuredClone(cp.resolvedOutcome) } : {}),
621
551
  },
622
552
  };
623
553
  }
@@ -638,7 +568,7 @@ export class InMemoryCheckpointStore {
638
568
  cp.rev = checkpointRevOf(cp) + 1;
639
569
  if (winnerClone)
640
570
  cp.resolvedOutcome = winnerClone;
641
- cp.reopenReason = undefined;
571
+ delete cp.reopenReason;
642
572
  return { claimed: true };
643
573
  }
644
574
  claimExpireCore(token, scope) {
@@ -729,7 +659,7 @@ export class InMemoryCheckpointStore {
729
659
  const out = [];
730
660
  for (const cp of this.cps.values()) {
731
661
  if (cp.scope === scope && cp.status === "pending")
732
- out.push(summarizeCheckpoint(cp, this.disclose));
662
+ out.push(summarizeStoredCheckpoint(cp, this.rowVerdicts, this.disclose));
733
663
  }
734
664
  return out;
735
665
  }
@@ -741,7 +671,7 @@ export class InMemoryCheckpointStore {
741
671
  return [...out];
742
672
  }
743
673
  async listOverdue(query) {
744
- return selectOverduePage(this.cps.entries(), readCheckpointOverdueQuery(query), (cp) => summarizeCheckpoint(cp, this.disclose), this.disclose);
674
+ return selectOverduePage(this.cps.entries(), readCheckpointOverdueQuery(query), (cp) => summarizeStoredCheckpoint(cp, this.rowVerdicts, this.disclose), this.disclose);
745
675
  }
746
676
  async listBySession(query) {
747
677
  return selectSessionPage(this.cps.entries(), readCheckpointSessionQuery(query), (cp) => structuredClone(cp), this.disclose);
@@ -753,35 +683,3 @@ export class InMemoryCheckpointStore {
753
683
  return this.cps.size;
754
684
  }
755
685
  }
756
- const RETIRED_MODE_SEED_MEMBERS = Object.freeze([
757
- ["autoModeRequested", () => true],
758
- ["approverPosture", () => true],
759
- ["shellGate", (v) => v !== "always"],
760
- ]);
761
- export function refuseRetiredModeSeed(state) {
762
- const gate = state.inheritedGate;
763
- if (gate === undefined)
764
- return;
765
- for (const [key, retired] of RETIRED_MODE_SEED_MEMBERS) {
766
- const value = gate[key];
767
- if (value === undefined || !retired(value))
768
- continue;
769
- const shown = typeof value === "string" ? JSON.stringify(value.slice(0, 40)) : typeof value === "boolean" ? String(value) : typeof value;
770
- throw new CheckpointError("checkpoint.unsupported_version", `this checkpoint's inheritedGate carries the retired mode-seed member \`${key}\` (${shown}), written before 7.34.0 and read by no engine since 7.39.0 — resume it once on an engine at 7.38.x or earlier (which reads it into \`permissionMode\`), or expire the row (\`CheckpointStore.expire\`); nothing was consumed`, { reason: "seat_retired" });
771
- }
772
- }
773
- export function recordedModeSeed(gate) {
774
- if (gate === undefined)
775
- return {};
776
- const refusal = (message) => {
777
- const e = new Error(message);
778
- e.code = "config.permission_mode_invalid";
779
- return e;
780
- };
781
- const { permissionMode, prePlanMode, shellGate } = gate;
782
- if (permissionMode !== undefined && !isPermissionMode(permissionMode))
783
- throw refusal(`the checkpoint row's inheritedGate.permissionMode is ${JSON.stringify(permissionMode)}, not a permission mode — the row cannot be resumed under a mode this engine does not know`);
784
- if (prePlanMode !== undefined && (!isPermissionMode(prePlanMode) || prePlanMode === "plan"))
785
- throw refusal(`the checkpoint row's inheritedGate.prePlanMode is ${JSON.stringify(prePlanMode)}, not a permission mode a plan can return to`);
786
- return { ...(permissionMode !== undefined ? { permissionMode } : {}), ...(prePlanMode !== undefined ? { prePlanMode } : {}), ...(shellGate !== undefined ? { shellGate } : {}) };
787
- }
@@ -117,6 +117,18 @@ export interface EngineNotice {
117
117
  * replace itself would mint for this target, under a pid that is gone, plain files with one name. A running writer's staged
118
118
  * file is never touched. Audience `operator`. `detail: { count }` — how many, no names. Seat-only (an environment with no
119
119
  * `onNotice` seat says nothing). ONCE PER WRITE THAT REMOVED ANY.
120
+ * - `"session.lineage_rerooted"` — the session this run continues has a log whose replay dropped records it could not read, and this
121
+ * says what the run lost. Two forms, told apart by `detail.break`: `true` — the branch the run reads broke at a parent the log does
122
+ * not hold, and the run continues from the entry that names that parent (the branch ends there, as a bounded window ends at its floor)
123
+ * instead of failing; `false` — the branch is whole (the log's last records were unreadable and its head fell back to the last one
124
+ * still readable, or the damage sat off the branch) and the run continues from `leaf`. A break the replay cannot account for (it
125
+ * dropped nothing) is refused `corrupt_session`, never re-rooted. Audience `user`. `detail: { break, recordsDropped, recordsTotal, leaf,
126
+ * entriesOnPath, sessionId, runId }` and, when `break` is `true`, `{ missingParentId, rootedAt, entriesCut }` — the replay's count
127
+ * (records, not entries), the entry the run continues from (`null` = nothing of the log is readable), the branch's length, the parent
128
+ * not in the log, the entry the branch starts at, and how many entries the log holds that do not descend from `rootedAt` (the history
129
+ * above the break and its side branches). Counts and entry ids only, never a record's words. ONCE PER PREPARED LEG for a whole branch,
130
+ * once per break for a broken one (and then the whole-branch form is not said), at the first read that met it — said when the acquire
131
+ * has settled on the attempt that holds, so an attempt that lost a write race and was run again is not described.
120
132
  * - `"workflow.governance_key_stripped"` (#235) — the fields of an LLM-authored workflow `agent(spec)`
121
133
  * that did NOT cross the governed default-deny whitelist: an unrecognized/control-plane field, or a
122
134
  * `readFace` value that is not the containment-tightening one. The spawn PROCEEDS on the deployment
@@ -531,8 +543,8 @@ export interface EngineNotice {
531
543
  * such as `EMPTY`, fewer than eight characters, one character repeated): it is used as given, but a variable holding
532
544
  * the same string is not withheld from a spawned child. Once per PROCESS per value
533
545
  * ({@link import("./secret-env.js").holdOwnCredentialValues}); `detail: { reason }` — the kind, never the value. Delivered
534
- * to `RunnerDeps.onNotice` from the `new Runner` receipt; the intakes with no structured seat (a brain's construction,
535
- * a request's route reading, a peer's dial, a directly built distiller seat) print its line on `console.warn`.
546
+ * to `RunnerDeps.onNotice` from the `new Runner` receipt; the intakes with no seat in hand (a brain's construction,
547
+ * a request's route reading, a peer's dial, a directly built distiller seat) go to the default seat ({@link setDefaultEngineNoticeSeat}), else `console.warn`.
536
548
  * - `"config.cross_boundary_posture_undeclared"` — a run whose tree executes on a target device (armed) on a deployment that
537
549
  * configured no `RunnerDeps.crossBoundaryPosture`: the permissive `"single_user"` reading is in force. Once per run;
538
550
  * `detail: { sessionId, runId, taint }` — `taint` lists the tree's taint bits
@@ -1120,6 +1132,9 @@ export interface EngineNotice {
1120
1132
  * Optional and absent for process/config-scoped codes. */
1121
1133
  sessionId?: string;
1122
1134
  }
1135
+ /** Install the process's default notice seat, for what the engine says where no seat is in hand (a brain's construction, a route reading, a peer's dial): a second call replaces it,
1136
+ * `undefined` removes it (such notices then print on `console.warn`), a seat a station holds always wins, anything but a function or `undefined` is refused (`config.invalid_argument`). */
1137
+ export declare function setDefaultEngineNoticeSeat(seat: ((notice: EngineNotice) => void) | undefined): void;
1123
1138
  /** Test seam (mirrors `__resetBashTimeoutAnnouncements`): never called by production code. */
1124
1139
  export declare function __resetMalformedNoticeSeatAnnouncement(): void;
1125
1140
  /**
@@ -1139,7 +1154,8 @@ export declare function __resetMalformedNoticeSeatAnnouncement(): void;
1139
1154
  * · a PRESENT NON-function seat is a bad deployment value, and #123 (loud-bad-value law) forbids
1140
1155
  * folding it to silence: the notice itself falls back to `console.warn` (no line is lost), and the
1141
1156
  * seat defect — the one fact every fallback would otherwise repeat — is announced once per process.
1142
- * · an ABSENT seat prints the historic `console.warn` line verbatim (byte-compat loudness).
1157
+ * · an ABSENT seat goes to the default seat a host installed ({@link setDefaultEngineNoticeSeat}; a function seat as above, and
1158
+ * a present seat — non-function included — never falls through to it), else prints the historic `console.warn` line verbatim.
1143
1159
  */
1144
1160
  export declare function deliverEngineNotice(onNotice: ((notice: EngineNotice) => void) | undefined, notice: EngineNotice): void;
1145
1161
  /**
@@ -1,4 +1,10 @@
1
1
  import { egressAccount, egressText } from "./untrusted-egress.js";
2
+ let defaultNoticeSeat;
3
+ export function setDefaultEngineNoticeSeat(seat) {
4
+ if (seat !== undefined && typeof seat !== "function")
5
+ throw Object.assign(new Error(`setDefaultEngineNoticeSeat: the seat must be a function, or undefined to remove it (got ${seat === null ? "null" : typeof seat})`), { code: "config.invalid_argument" });
6
+ defaultNoticeSeat = seat;
7
+ }
2
8
  let malformedNoticeSeatAnnounced = false;
3
9
  export function __resetMalformedNoticeSeatAnnouncement() {
4
10
  malformedNoticeSeatAnnounced = false;
@@ -12,9 +18,10 @@ export function deliverEngineNotice(onNotice, notice) {
12
18
  if (notice.sessionId === undefined && typeof notice.detail?.["sessionId"] === "string") {
13
19
  notice = { ...notice, sessionId: notice.detail["sessionId"] };
14
20
  }
15
- if (typeof onNotice === "function") {
21
+ const seat = onNotice === undefined ? defaultNoticeSeat : onNotice;
22
+ if (typeof seat === "function") {
16
23
  try {
17
- const r = onNotice(notice);
24
+ const r = seat(notice);
18
25
  if (typeof r?.then === "function") {
19
26
  r.then(undefined, () => {
20
27
  });
@@ -1,6 +1,6 @@
1
- import { inlineUntrusted } from "./untrusted-text.js";
1
+ import { inlineUntrusted, PROBE_REASON_MAX } from "./untrusted-text.js";
2
2
  import { markTightenMessage } from "./safety-axis-vocab.js";
3
- import { PROBE_REASON_MAX, normalizeProbeCause } from "./checkpoint-store.js";
3
+ import { normalizeProbeCause } from "./checkpoint-features.js";
4
4
  import { normalizeReadRootCandidate } from "./read-root-candidate.js";
5
5
  import { engineFailClosedExit, hookDenyExit, settledScreenExit, takeInheritedScreen } from "./runner/gate-exit.js";
6
6
  import { noteRewrite, POLICY_AUTHOR, readRejudge, screenRewrite } from "./rewrite-rejudge.js";
@@ -145,7 +145,7 @@ export type NoticeAudience = "user" | "operator";
145
145
  * the union's catalog ({@link EngineNotice.code}). The groups below say only which family a row joins,
146
146
  * so the catalog is not written a second time here and the two cannot drift.
147
147
  */
148
- export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "instructions.source_changed", "session.records_skipped", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
148
+ export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "session.lineage_rerooted", "instructions.source_changed", "session.records_skipped", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
149
149
  /** A catalogued code (see {@link ENGINE_NOTICE_CODES}); {@link NOTICE_MINTER} says who mints it. NOT the type of
150
150
  * `EngineNotice.code`, which stays `string` — a host forwarding its own notices through the same
151
151
  * sink is a supported shape, and narrowing that field would break it. */
@@ -272,6 +272,7 @@ declare const NOTICE_AUDIENCE_TABLE: {
272
272
  readonly "config.image_processor_unavailable": "operator";
273
273
  readonly "fs.staging_file_left": "operator";
274
274
  readonly "fs.staging_file_swept": "operator";
275
+ readonly "session.lineage_rerooted": "user";
275
276
  readonly "config.forward_sink_failed": "operator";
276
277
  readonly "instructions.source_changed": "user";
277
278
  readonly "session.records_skipped": "user";
@@ -412,6 +413,7 @@ declare const NOTICE_MINTER_TABLE: {
412
413
  readonly "config.image_processor_unavailable": "engine";
413
414
  readonly "fs.staging_file_left": "engine";
414
415
  readonly "fs.staging_file_swept": "engine";
416
+ readonly "session.lineage_rerooted": "engine";
415
417
  readonly "instructions.source_changed": "server";
416
418
  readonly "session.records_skipped": "server";
417
419
  readonly "memory.layer_locked_legacy": "server";
@@ -233,6 +233,7 @@ export const ENGINE_NOTICE_CODES = Object.freeze([
233
233
  "config.image_processor_unavailable",
234
234
  "fs.staging_file_left",
235
235
  "fs.staging_file_swept",
236
+ "session.lineage_rerooted",
236
237
  "instructions.source_changed",
237
238
  "session.records_skipped",
238
239
  "memory.layer_locked_legacy",
@@ -348,6 +349,7 @@ const NOTICE_AUDIENCE_TABLE = {
348
349
  "config.image_processor_unavailable": "operator",
349
350
  "fs.staging_file_left": "operator",
350
351
  "fs.staging_file_swept": "operator",
352
+ "session.lineage_rerooted": "user",
351
353
  "config.forward_sink_failed": "operator",
352
354
  "instructions.source_changed": "user",
353
355
  "session.records_skipped": "user",
@@ -469,6 +471,7 @@ const NOTICE_MINTER_TABLE = {
469
471
  "config.image_processor_unavailable": "engine",
470
472
  "fs.staging_file_left": "engine",
471
473
  "fs.staging_file_swept": "engine",
474
+ "session.lineage_rerooted": "engine",
472
475
  "instructions.source_changed": "server",
473
476
  "session.records_skipped": "server",
474
477
  "memory.layer_locked_legacy": "server",
@@ -205,6 +205,19 @@ export interface StopFailureEvent extends ClassicEventBase {
205
205
  /** Turns completed when the failure ended the run. */
206
206
  readonly turns: number;
207
207
  }
208
+ /** `classic.SessionStart`'s `e` — raised once per leg, in the bottom of `session.start` (the leg is prepared, its first model
209
+ * request not yet made). Observe-only. */
210
+ export interface SessionStartEvent extends ClassicEventBase {
211
+ /** The leg's tracked working directory. */
212
+ readonly cwd: string;
213
+ readonly sessionId: string;
214
+ }
215
+ /** `classic.SessionEnd`'s `e` — raised once per leg, in the bottom of `session.end` (its terminal settled). Observe-only. */
216
+ export interface SessionEndEvent extends ClassicEventBase {
217
+ /** The terminal status word. */
218
+ readonly reason: string;
219
+ readonly sessionId: string;
220
+ }
208
221
  /** `classic.PreCompact`'s `e` — before each compaction, after the trigger gate and a valid cut point. Answer:
209
222
  * {@link PreCompactResult} (`block` honored on "auto" / "manual" only). */
210
223
  export interface PreCompactEvent extends ClassicEventBase {
@@ -77,4 +77,5 @@ export declare function buildAppliedHumanInputEvent(input: {
77
77
  actor?: ActorAssertion | undefined;
78
78
  principal?: string | undefined;
79
79
  runOrigin?: HumanInputEvent["runOrigin"];
80
+ rewrittenBy?: readonly string[] | undefined;
80
81
  }): HumanInputEvent;
@@ -33,6 +33,7 @@ const HANDLED_HUMAN_INPUT_KEYS = {
33
33
  entryId: "forwarded",
34
34
  attachments: "forwarded",
35
35
  runOrigin: "forwarded",
36
+ rewrittenBy: "forwarded",
36
37
  };
37
38
  export function buildHumanInputEvent(input) {
38
39
  void HANDLED_HUMAN_INPUT_KEYS;
@@ -49,6 +50,7 @@ export function buildHumanInputEvent(input) {
49
50
  ...(input.entryId !== undefined ? { entryId: input.entryId } : {}),
50
51
  ...(input.attachments !== undefined && input.attachments.length > 0 ? { attachments: input.attachments.map((a) => ({ ...a })) } : {}),
51
52
  ...(input.runOrigin !== undefined ? { runOrigin: input.runOrigin } : {}),
53
+ ...(input.rewrittenBy !== undefined ? { rewrittenBy: Object.freeze([...input.rewrittenBy]) } : {}),
52
54
  };
53
55
  }
54
56
  export function buildAppliedHumanInputEvent(input) {
@@ -62,5 +64,6 @@ export function buildAppliedHumanInputEvent(input) {
62
64
  ...(input.actor?.issuer !== undefined ? { issuer: input.actor.issuer } : {}),
63
65
  ...(input.principal !== undefined ? { principal: input.principal } : {}),
64
66
  ...(input.runOrigin !== undefined ? { runOrigin: input.runOrigin } : {}),
67
+ ...(input.rewrittenBy !== undefined ? { rewrittenBy: input.rewrittenBy } : {}),
65
68
  });
66
69
  }
@@ -26,7 +26,7 @@ export declare const PDF_TARGET_RAW_SIZE: number;
26
26
  */
27
27
  export declare const IMAGE_ADMISSION: Readonly<{
28
28
  readonly hard: Readonly<{
29
- formats: Readonly<Record<"image/png" | "image/jpeg" | "image/gif" | "image/webp", (b: Uint8Array) => boolean>>;
29
+ formats: Readonly<Record<"image/jpeg" | "image/png" | "image/gif" | "image/webp", (b: Uint8Array) => boolean>>;
30
30
  readBytes: Readonly<{
31
31
  withoutProcessor: number;
32
32
  withProcessor: number;
@@ -268,8 +268,8 @@ export declare function snapshotAndValidateMcpEntries(declared: unknown, where?:
268
268
  * a locked slot (`config.locked_key`, two-state — the whole prepare is rejected, nothing is
269
269
  * silently dropped or merged), and produce the resolved snapshot downstream assembly consumes.
270
270
  * Runs BEFORE any side effect of task preparation — and, on a resume, before the claim: the resume's
271
- * screen calls this same function (`enter` naming each refusal's seat) and hands the leg the frozen
272
- * entries it judged, so the leg's prepare judges engine-owned plain data and dials what was judged.
271
+ * screen calls this same function (`enter` naming each refusal's seat) and hands the leg its judged copies
272
+ * of the lists THIS resume handed (the row records none), so the leg's prepare judges engine-owned plain data and dials what was judged.
273
273
  */
274
274
  export declare function preflightLockedConfig(spec: Pick<TaskSpec, "mcp" | "a2a" | "toolPolicy" | "basePolicyForResumeEdit">, deps: RunnerDeps, enter?: ConfigDoorEntry, receipt?: ReceivedPeerDeclarations): LockedPreflight;
275
275
  /**
@@ -65,6 +65,7 @@ export async function settledBefore(work, stop) {
65
65
  }
66
66
  const TAKEN = new WeakMap();
67
67
  const refusal = (condition) => new McpHostSeatFailure({ delivered: "no", condition });
68
+ const connectionClosed = () => refusal("the host seat's connection to this leg is closed");
68
69
  export async function openHostPipe(seat, server, stop) {
69
70
  stop?.throwIfAborted();
70
71
  let open;
@@ -143,6 +144,8 @@ class TakenPipe {
143
144
  const [heard, ended, failed] = [p.onmessage, p.onclose, p.onerror];
144
145
  p.onmessage = (message, extra) => {
145
146
  heard?.(message, extra);
147
+ if (this.#ended)
148
+ return;
146
149
  if ((isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) && this.#inFlight.has(message.id))
147
150
  this.#inFlight.set(message.id, true);
148
151
  this.onmessage?.(message, extra);
@@ -162,6 +165,8 @@ class TakenPipe {
162
165
  await Reflect.apply(this.#parts.start, this.#pipe, []);
163
166
  }
164
167
  async send(message, options) {
168
+ if (this.#ended)
169
+ throw connectionClosed();
165
170
  if (!isJSONRPCRequest(message))
166
171
  return void (await Reflect.apply(this.#parts.send, this.#pipe, [message, options]));
167
172
  const id = message.id;
@@ -270,7 +275,7 @@ class RequestSeatPipe {
270
275
  return this.deliver({ jsonrpc: "2.0", id, result: { protocolVersion, capabilities: { tools: {} }, serverInfo: { name: this.serverName, version: "" } } });
271
276
  }
272
277
  if (this.closed)
273
- throw new McpHostSeatFailure({ delivered: "no", condition: "the host seat's connection to this leg is closed" });
278
+ throw connectionClosed();
274
279
  if (method !== "tools/list" && method !== "tools/call")
275
280
  throw new McpHostSeatFailure({ delivered: "no", condition: `the host seat carries tools/list and tools/call only, and ${inlineUntrusted(method, 80)} was not handed on` });
276
281
  const stop = new AbortController();
@@ -9,7 +9,7 @@
9
9
  * plan and clears the session count), so without a durable run account a process exit between two
10
10
  * cycles would strand the work: no open plan to reconcile, no session edge to re-arm, and a naive
11
11
  * re-entry would re-mint the whole plan at full model cost. The run row under the control plane is
12
- * the resume seat: `runMemoryConsolidation` first looks for a PENDING run of the scope and
12
+ * the resume seat: `runMemoryConsolidationDriver` first looks for a PENDING run of the scope and
13
13
  * CONTINUES it (same plan cache, same force requestId, zero new mint) — the idempotent re-entry
14
14
  * GD-15 pins.
15
15
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * design/81 Slice 5 — the shared distance primitives for the consolidation `searchScored` retrieval, extracted
3
3
  * BYTE-IDENTICAL from the original PgMemoryStore implementation so the File (portable/TOC) and Pg (native/TOB)
4
- * backends rank on ONE source of truth and can't drift. The `{@link import("./runner/memory-consolidation.js")}`
4
+ * backends rank on ONE source of truth and can't drift. The consolidation
5
5
  * band `{0.05, 0.3}` is defined on this cosine-distance scale; the lexical `1 - Jaccard ∈ [0,1] ⊂ [0,2]` is the
6
6
  * same-zero-point stand-in used when no embedding vector is present (fail-open per row).
7
7
  *