@sema-agent/core 7.56.0 → 7.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 (319) hide show
  1. package/CHANGELOG.md +926 -0
  2. package/LICENSE +1 -1
  3. package/dist/agents/org-delivery-gate.js +3 -4
  4. package/dist/agents/peer-held-queue.d.ts +69 -49
  5. package/dist/agents/peer-held-queue.js +255 -106
  6. package/dist/agents/peer-session-drain.js +63 -43
  7. package/dist/agents/send-message-tool.js +3 -2
  8. package/dist/agents/subagent-steps.js +2 -4
  9. package/dist/agents/subagent.js +8 -8
  10. package/dist/brain/anthropic.js +16 -8
  11. package/dist/brain/open-responses.js +10 -8
  12. package/dist/brain/openai.js +11 -9
  13. package/dist/brain/provider-dialect.d.ts +3 -2
  14. package/dist/brain/provider-dialect.js +2 -2
  15. package/dist/brain/request-params.d.ts +6 -0
  16. package/dist/brain/request-params.js +14 -1
  17. package/dist/brain/route-adjudicator.js +2 -1
  18. package/dist/brain/stream-engine.d.ts +9 -0
  19. package/dist/brain/stream-engine.js +24 -10
  20. package/dist/brain/stream-shared.d.ts +5 -4
  21. package/dist/brain/stream-shared.js +4 -4
  22. package/dist/core/a2a.d.ts +2 -1
  23. package/dist/core/a2a.js +23 -10
  24. package/dist/core/allow-entry.d.ts +5 -11
  25. package/dist/core/allow-entry.js +19 -26
  26. package/dist/core/approval-object.d.ts +21 -5
  27. package/dist/core/approval-object.js +44 -17
  28. package/dist/core/ask-origin.d.ts +23 -4
  29. package/dist/core/ask-origin.js +5 -1
  30. package/dist/core/auto-compaction.d.ts +75 -6
  31. package/dist/core/auto-compaction.js +43 -27
  32. package/dist/core/auto-mode-directive.d.ts +29 -5
  33. package/dist/core/auto-mode-directive.js +38 -8
  34. package/dist/core/background-agent-store.d.ts +6 -2
  35. package/dist/core/background-agent-store.js +1 -1
  36. package/dist/core/checkpoint-requirements.d.ts +13 -1
  37. package/dist/core/checkpoint-requirements.js +4 -0
  38. package/dist/core/checkpoint-store.d.ts +44 -40
  39. package/dist/core/checkpoint-store.js +32 -14
  40. package/dist/core/cross-boundary-taint.js +4 -2
  41. package/dist/core/engine-notice.d.ts +4 -3
  42. package/dist/core/engine-notice.js +6 -0
  43. package/dist/core/file-history-store.d.ts +14 -8
  44. package/dist/core/file-history-store.js +14 -4
  45. package/dist/core/fs-write-gate-policy.d.ts +4 -2
  46. package/dist/core/fs-write-gate-policy.js +7 -3
  47. package/dist/core/gate-fold.js +6 -3
  48. package/dist/core/gate-lanes.js +13 -5
  49. package/dist/core/git-worktree-env.d.ts +53 -11
  50. package/dist/core/git-worktree-env.js +96 -12
  51. package/dist/core/hooks.d.ts +6 -3
  52. package/dist/core/hooks.js +12 -5
  53. package/dist/core/human-input-projection.d.ts +1 -0
  54. package/dist/core/human-input-projection.js +3 -0
  55. package/dist/core/locked-config.d.ts +15 -1
  56. package/dist/core/locked-config.js +38 -2
  57. package/dist/core/mailbox-store.d.ts +62 -1
  58. package/dist/core/mailbox-store.js +59 -0
  59. package/dist/core/mcp-call-meta.d.ts +66 -0
  60. package/dist/core/mcp-call-meta.js +103 -0
  61. package/dist/core/mcp-connection-pool.d.ts +3 -1
  62. package/dist/core/mcp-connection-pool.js +3 -1
  63. package/dist/core/mcp-failure.d.ts +7 -1
  64. package/dist/core/mcp-failure.js +10 -0
  65. package/dist/core/mcp-name-judge.d.ts +46 -0
  66. package/dist/core/mcp-name-judge.js +61 -0
  67. package/dist/core/mcp-probe.d.ts +5 -1
  68. package/dist/core/mcp-probe.js +3 -6
  69. package/dist/core/mcp-server-link.d.ts +5 -2
  70. package/dist/core/mcp-server-spec.d.ts +46 -18
  71. package/dist/core/mcp-server-spec.js +1 -18
  72. package/dist/core/mcp.d.ts +6 -14
  73. package/dist/core/mcp.js +85 -65
  74. package/dist/core/memory-engine/consolidation-driver.js +4 -3
  75. package/dist/core/memory-engine/distiller.js +26 -17
  76. package/dist/core/memory-engine/layout.js +5 -2
  77. package/dist/core/memory-engine/scope-contract.d.ts +45 -4
  78. package/dist/core/memory-engine/scope-contract.js +80 -11
  79. package/dist/core/mode-policy.d.ts +8 -5
  80. package/dist/core/mode-policy.js +5 -4
  81. package/dist/core/mods/host.js +1 -1
  82. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  83. package/dist/core/mods/kernel/dispatch.js +10 -8
  84. package/dist/core/mods/kernel/events.d.ts +5 -1
  85. package/dist/core/mods/kernel/events.js +1 -1
  86. package/dist/core/mods/kernel/registration.d.ts +5 -1
  87. package/dist/core/mods/kernel/site-rules.d.ts +3 -0
  88. package/dist/core/mods/kernel/site-rules.js +10 -0
  89. package/dist/core/mods/package.d.ts +23 -0
  90. package/dist/core/mods/package.js +118 -0
  91. package/dist/core/mods/stations.d.ts +2 -2
  92. package/dist/core/mods/stations.js +1 -1
  93. package/dist/core/mods/tool-call.d.ts +5 -1
  94. package/dist/core/mods/tool-call.js +12 -3
  95. package/dist/core/park-selfcheck.js +2 -0
  96. package/dist/core/path-guard-rows.d.ts +20 -0
  97. package/dist/core/path-guard-rows.js +11 -0
  98. package/dist/core/peer-seat.d.ts +186 -0
  99. package/dist/core/peer-seat.js +307 -0
  100. package/dist/core/permission-rule-consent.d.ts +5 -3
  101. package/dist/core/permission-rule-consent.js +20 -15
  102. package/dist/core/permission-rule-model.d.ts +43 -2
  103. package/dist/core/permission-rule-model.js +52 -8
  104. package/dist/core/permission-rule-org.js +1 -1
  105. package/dist/core/present-plan-tool.d.ts +10 -1
  106. package/dist/core/present-plan-tool.js +46 -2
  107. package/dist/core/protocol-http-auth.d.ts +56 -31
  108. package/dist/core/protocol-http-auth.js +71 -42
  109. package/dist/core/protocol-naming.d.ts +20 -0
  110. package/dist/core/protocol-naming.js +20 -3
  111. package/dist/core/read-only-shell.d.ts +20 -5
  112. package/dist/core/read-only-shell.js +29 -14
  113. package/dist/core/redaction-marks.d.ts +16 -0
  114. package/dist/core/redaction-marks.js +16 -0
  115. package/dist/core/redaction-passes.js +8 -9
  116. package/dist/core/remote-env.d.ts +37 -1
  117. package/dist/core/remote-env.js +11 -0
  118. package/dist/core/resume-startup-cause.d.ts +24 -2
  119. package/dist/core/resume-startup-cause.js +20 -1
  120. package/dist/core/retention.d.ts +41 -15
  121. package/dist/core/retention.js +59 -12
  122. package/dist/core/rewrite-rejudge.d.ts +37 -0
  123. package/dist/core/rewrite-rejudge.js +40 -0
  124. package/dist/core/roles.js +50 -7
  125. package/dist/core/run-origin.d.ts +40 -0
  126. package/dist/core/run-origin.js +37 -0
  127. package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
  128. package/dist/core/runner/advertised-writable-dirs.js +126 -0
  129. package/dist/core/runner/compact-session.d.ts +10 -0
  130. package/dist/core/runner/compact-session.js +202 -0
  131. package/dist/core/runner/compaction-call-options.d.ts +2 -2
  132. package/dist/core/runner/compaction-restate.d.ts +15 -6
  133. package/dist/core/runner/compaction-restate.js +28 -2
  134. package/dist/core/runner/compaction-seams.d.ts +21 -1
  135. package/dist/core/runner/compaction-seams.js +11 -8
  136. package/dist/core/runner/contracts.d.ts +36 -21
  137. package/dist/core/runner/derived-route-fallback.d.ts +13 -0
  138. package/dist/core/runner/derived-route-fallback.js +6 -0
  139. package/dist/core/runner/env-capability-census.d.ts +3 -2
  140. package/dist/core/runner/env-capability-census.js +9 -3
  141. package/dist/core/runner/gate-exit.d.ts +18 -4
  142. package/dist/core/runner/gate-exit.js +5 -1
  143. package/dist/core/runner/permission-rule-lanes.d.ts +7 -7
  144. package/dist/core/runner/permission-rule-lanes.js +17 -11
  145. package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -0
  146. package/dist/core/runner/prepare-acquire-reconcile.js +2 -1
  147. package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
  148. package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
  149. package/dist/core/runner/prepare-config-doors.d.ts +14 -5
  150. package/dist/core/runner/prepare-config-doors.js +16 -13
  151. package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
  152. package/dist/core/runner/prepare-delegation-surface.js +15 -18
  153. package/dist/core/runner/prepare-gate-stations.js +1 -1
  154. package/dist/core/runner/prepare-hands-readface.d.ts +10 -4
  155. package/dist/core/runner/prepare-hands-readface.js +6 -1
  156. package/dist/core/runner/prepare-memory.d.ts +3 -0
  157. package/dist/core/runner/prepare-memory.js +19 -23
  158. package/dist/core/runner/prepare-park-ask.d.ts +2 -0
  159. package/dist/core/runner/prepare-park-ask.js +2 -2
  160. package/dist/core/runner/prepare-policy-chain.d.ts +4 -4
  161. package/dist/core/runner/prepare-policy-chain.js +4 -6
  162. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
  163. package/dist/core/runner/prepare-protocol-tools.js +3 -3
  164. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  165. package/dist/core/runner/prepare-suspend-saga.js +2 -1
  166. package/dist/core/runner/prepare-task.d.ts +4 -1
  167. package/dist/core/runner/prepare-task.js +46 -37
  168. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +13 -0
  169. package/dist/core/runner/prepare-tool-disclosure-mount.js +13 -7
  170. package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
  171. package/dist/core/runner/prepare-wiring-manifest.js +2 -2
  172. package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
  173. package/dist/core/runner/prepare-workspace-restore.js +4 -4
  174. package/dist/core/runner/resume-admission.js +1 -1
  175. package/dist/core/runner/resume-checkpoint-screen.js +2 -0
  176. package/dist/core/runner/rewind-files.d.ts +2 -5
  177. package/dist/core/runner/rewind-files.js +9 -51
  178. package/dist/core/runner/run-harness-handlers.d.ts +3 -4
  179. package/dist/core/runner/run-harness-handlers.js +1 -8
  180. package/dist/core/runner/run-identity-wiring.js +1 -0
  181. package/dist/core/runner/run-leg.js +15 -22
  182. package/dist/core/runner/run-notification-lane.d.ts +2 -0
  183. package/dist/core/runner/run-notification-lane.js +5 -2
  184. package/dist/core/runner/run-recovery-lanes.js +3 -4
  185. package/dist/core/runner/run-settle-and-teardown.js +5 -11
  186. package/dist/core/runner/run-terminal-adoption.js +3 -4
  187. package/dist/core/runner/run-turn-boundary.js +3 -5
  188. package/dist/core/runner/runtask.d.ts +8 -1
  189. package/dist/core/runner/runtask.js +28 -34
  190. package/dist/core/runner/send-message-continuation.js +1 -1
  191. package/dist/core/runner/session-verb-doors.d.ts +28 -0
  192. package/dist/core/runner/session-verb-doors.js +48 -0
  193. package/dist/core/runner/session-write-ledger.d.ts +30 -0
  194. package/dist/core/runner/session-write-ledger.js +101 -0
  195. package/dist/core/runner/stream-settle-backstop.js +11 -14
  196. package/dist/core/runner/sub-agent-deny-lists.d.ts +25 -3
  197. package/dist/core/runner/sub-agent-deny-lists.js +21 -10
  198. package/dist/core/runner/teardown-bounded.d.ts +1 -0
  199. package/dist/core/runner/teardown-bounded.js +1 -0
  200. package/dist/core/runner/terminal-account.js +3 -3
  201. package/dist/core/runner/tool-end-body.js +1 -0
  202. package/dist/core/runner/tool-occurrence.d.ts +4 -1
  203. package/dist/core/runner/tool-occurrence.js +2 -1
  204. package/dist/core/runner/write-protection-station.d.ts +8 -2
  205. package/dist/core/runner/write-protection-station.js +2 -0
  206. package/dist/core/runner-deps.d.ts +4 -4
  207. package/dist/core/secret-env.d.ts +4 -0
  208. package/dist/core/secret-env.js +3 -0
  209. package/dist/core/sensitive-path-policy.js +6 -7
  210. package/dist/core/session-log-transfer.d.ts +24 -0
  211. package/dist/core/session-log-transfer.js +166 -0
  212. package/dist/core/session-policy-store.d.ts +7 -2
  213. package/dist/core/session-policy-store.js +1 -1
  214. package/dist/core/session-store.d.ts +84 -19
  215. package/dist/core/session-store.js +162 -24
  216. package/dist/core/session.d.ts +92 -1
  217. package/dist/core/shell-read-silence.js +1 -0
  218. package/dist/core/shell-wrapper-projection.d.ts +1 -1
  219. package/dist/core/steer-replay.d.ts +4 -2
  220. package/dist/core/steer-replay.js +2 -1
  221. package/dist/core/store-contracts/background-agent-store-contract.js +1 -0
  222. package/dist/core/store-contracts/checkpoint-store-contract.js +19 -1
  223. package/dist/core/store-contracts/file-history-store-contract.js +9 -0
  224. package/dist/core/store-contracts/mailbox-store-contract.js +49 -1
  225. package/dist/core/store-contracts/session-repo-contract.js +112 -5
  226. package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
  227. package/dist/core/store-contracts/session-store-contract.js +236 -2
  228. package/dist/core/task-event.d.ts +68 -8
  229. package/dist/core/task-registry-agent.d.ts +8 -4
  230. package/dist/core/task-registry-agent.js +14 -8
  231. package/dist/core/task-registry-shared.d.ts +36 -6
  232. package/dist/core/task-registry-shared.js +11 -0
  233. package/dist/core/task-registry.d.ts +1 -1
  234. package/dist/core/task-registry.js +1 -1
  235. package/dist/core/task-spec.d.ts +37 -0
  236. package/dist/core/task-stream.d.ts +2 -1
  237. package/dist/core/terminal-cause.d.ts +1 -1
  238. package/dist/core/tool-catalog-entries.d.ts +6 -0
  239. package/dist/core/tool-catalog-entries.js +2 -0
  240. package/dist/core/tool-name-aliases.d.ts +32 -2
  241. package/dist/core/tool-name-aliases.js +23 -0
  242. package/dist/core/tool-name-readings.d.ts +4 -0
  243. package/dist/core/tool-name-readings.js +1 -0
  244. package/dist/core/tool-policy.d.ts +10 -6
  245. package/dist/core/tool-policy.js +4 -7
  246. package/dist/core/tool-result-store.d.ts +17 -10
  247. package/dist/core/tool-result-store.js +3 -1
  248. package/dist/core/trace.d.ts +4 -1
  249. package/dist/core/trace.js +2 -1
  250. package/dist/core/types.d.ts +1 -1
  251. package/dist/core/untrusted-egress.d.ts +18 -0
  252. package/dist/core/untrusted-egress.js +82 -12
  253. package/dist/core/wiring-manifest.d.ts +12 -3
  254. package/dist/core/wiring-manifest.js +4 -3
  255. package/dist/core/workspace-snapshot.d.ts +44 -0
  256. package/dist/core/workspace-snapshot.js +34 -0
  257. package/dist/core/write-protect.d.ts +43 -3
  258. package/dist/core/write-protect.js +43 -16
  259. package/dist/engine/execution-env/node-execution-env.js +15 -11
  260. package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
  261. package/dist/engine/harness/agent-harness.d.ts +12 -5
  262. package/dist/engine/harness/agent-harness.js +13 -2
  263. package/dist/engine/harness/types.d.ts +48 -7
  264. package/dist/engine/harness/types.js +5 -1
  265. package/dist/engine/llm/types.d.ts +12 -3
  266. package/dist/engine/llm/types.js +1 -1
  267. package/dist/engine/loop/agent-loop.d.ts +1 -4
  268. package/dist/engine/loop/agent-loop.js +26 -4
  269. package/dist/engine/session/import-validate.js +3 -0
  270. package/dist/engine/session/memory-repo.d.ts +17 -9
  271. package/dist/engine/session/memory-repo.js +44 -34
  272. package/dist/engine/session/repo-utils.d.ts +22 -4
  273. package/dist/engine/session/repo-utils.js +49 -1
  274. package/dist/engine/session/storage-base.d.ts +10 -1
  275. package/dist/engine/session/storage-base.js +7 -1
  276. package/dist/index.d.ts +23 -11
  277. package/dist/index.js +15 -6
  278. package/dist/internal/harness-types.d.ts +1 -1
  279. package/dist/internal/harness.d.ts +4 -3
  280. package/dist/internal/harness.js +3 -2
  281. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  282. package/dist/stores/file/checkpoint-store.js +0 -1
  283. package/dist/stores/file/file-history-store.js +12 -4
  284. package/dist/stores/file/index.d.ts +4 -1
  285. package/dist/stores/file/index.js +4 -1
  286. package/dist/stores/file/mailbox-store.d.ts +2 -1
  287. package/dist/stores/file/mailbox-store.js +26 -1
  288. package/dist/stores/file/session-store.d.ts +15 -8
  289. package/dist/stores/file/session-store.js +28 -13
  290. package/dist/tools/fs/bash-readonly-classifier.d.ts +15 -19
  291. package/dist/tools/fs/bash-readonly-classifier.js +5 -10
  292. package/dist/tools/fs/fs-bash.js +10 -3
  293. package/dist/tools/fs/fs-write.d.ts +6 -3
  294. package/dist/tools/fs/fs-write.js +8 -7
  295. package/dist/tools/fs/index.d.ts +3 -0
  296. package/dist/tools/fs/index.js +1 -1
  297. package/dist/tools/fs/pattern-kill-guard.d.ts +3 -2
  298. package/dist/tools/fs/pattern-kill-guard.js +68 -36
  299. package/dist/tools/fs/safety.js +40 -8
  300. package/dist/tools/fs/search.js +6 -24
  301. package/dist/tools/fs/shell-read-check.d.ts +18 -1
  302. package/dist/tools/fs/shell-read-check.js +66 -16
  303. package/dist/tools/fs/shell-read-establish.js +2 -1
  304. package/dist/tools/fs/shell-read-identity.d.ts +12 -9
  305. package/dist/tools/fs/shell-read-identity.js +10 -5
  306. package/dist/tools/fs/shell-read-judge.d.ts +10 -1
  307. package/dist/tools/web.js +9 -7
  308. package/dist/tools/worktree.d.ts +42 -15
  309. package/dist/tools/worktree.js +60 -32
  310. package/package.json +4 -2
  311. package/test/export-surface.snapshot.json +141 -3
  312. package/wire-changes/core-stores-sql@7.57.0.json +29 -0
  313. package/wire-changes/core-stores-sql@7.58.0.json +29 -0
  314. package/wire-changes/core@7.57.0.json +1487 -0
  315. package/wire-changes/core@7.58.0.json +2188 -0
  316. package/wire-changes/mods-kernel@7.57.0.json +29 -0
  317. package/wire-changes/mods-kernel@7.58.0.json +81 -0
  318. package/wire-changes/primitives@7.57.0.json +245 -0
  319. package/wire-changes/primitives@7.58.0.json +29 -0
@@ -13,6 +13,7 @@ import type { SessionPermissionRules } from "./session-policy-store.js";
13
13
  import type { NestedUsageAccum, PermissionMode, ShellGateDoctrine, TaskResult } from "./types.js";
14
14
  import type { ActiveWorktreeSession } from "../internal/harness-types.js";
15
15
  import type { ReopenReason } from "./resume-startup-cause.js";
16
+ import { type RetentionDeclaration } from "./retention.js";
16
17
  /**
17
18
  * design/45 — the **durable-checkpoint** primitive: cross-process / resumable `suspend`/`resume`.
18
19
  *
@@ -317,7 +318,7 @@ export declare const MAX_PENDING_STEER_ENTRIES: number;
317
318
  * loud rejection instead of having its new field silently dropped on the parked leg. Consumers (other
318
319
  * repos' backends) read it to assert they round-trip every field rather than hand-listing their own copy.
319
320
  */
320
- export declare const PENDING_STEER_FROZEN_FIELDS: readonly ["text", "trusted", "actor", "seq", "inputId", "priority"];
321
+ export declare const PENDING_STEER_FROZEN_FIELDS: readonly ["text", "trusted", "actor", "seq", "inputId", "priority", "runOrigin"];
321
322
  /**
322
323
  * design/171 §6.1 — WHO a piece of human input came from, as an attribution label. ONE definition:
323
324
  * the shape lives at its layering-legal home (`engine/llm/types.ts`, where `UserMessage.actor`
@@ -351,6 +352,9 @@ export interface PendingSteerEntry {
351
352
  inputId: string;
352
353
  /** Carried VERBATIM for the serving layer; it does NOT reorder the drain (drain is `seq` order). */
353
354
  priority?: SystemInjectionPriority;
355
+ /** What brought this input, when its host says so ({@link import("./run-origin.js").RunOrigin}): its `human_input` frame
356
+ * reports it, and the newest input a wake hands over states the woken leg's word with it. Attribution only; absent = the host said nothing. */
357
+ runOrigin?: import("./run-origin.js").RunOrigin;
354
358
  }
355
359
  /** design/171 §6.3 — the caller-supplied half of a {@link PendingSteerEntry}: everything except `seq`,
356
360
  * which only the store may mint. `inputId` is optional on the way in (minted when absent). */
@@ -360,6 +364,7 @@ export interface PendingSteerInput {
360
364
  actor?: ActorAssertion;
361
365
  inputId?: string;
362
366
  priority?: SystemInjectionPriority;
367
+ runOrigin?: import("./run-origin.js").RunOrigin;
363
368
  }
364
369
  /** True ONLY for a PLAIN data record (not null / array / class-instance / proxy-with-odd-prototype) — the only
365
370
  * shape we safely digest. Adversarial args (a proxy, a getter that throws) must never crash the mint, so this +
@@ -907,6 +912,8 @@ export type PendingAction = {
907
912
  /** The approval object's TARGETS (`approvalTargetsOf`): per reading of the path slot, where it resolved when the card
908
913
  * was asked; absent ⇒ not judged. A role resolving elsewhere at the execution vetoes the call (`resume.target_moved`). */
909
914
  targets?: import("./approval-object.js").ApprovalTargets;
915
+ /** The same member's shell reading (`approvalTargetsOf`): per read candidate the shell read station judged for the parked bytes, where it landed (digests); absent ⇒ not judged. A read landing elsewhere at the execution vetoes the call (`resume.target_moved`). Word `approval_target_reads`. */
916
+ targetReads?: import("./approval-object.js").ApprovalTargetReads;
910
917
  /**
911
918
  * #438 (additive; no checkpoint-version bump — the `reminderMark` precedent: an optional field an
912
919
  * older reader ignores. Unlike that precedent seat — which resume DOES read, through its
@@ -1365,6 +1372,12 @@ export interface CheckpointState {
1365
1372
  * that hands no live seat restores it, so the resume config cannot move the leg's next row. Not {@link Checkpoint.scope}
1366
1373
  * (where THIS row is filed — a resource slice's own declared scope). Absent ⇒ minted before the member: derived as before. */
1367
1374
  legScope?: string;
1375
+ /** The word of the LEG that parked this row ({@link import("./run-origin.js").RunOrigin}: the word of the input that opened
1376
+ * that leg, read once at its config doors), stamped at every mint and continued by a leg a decision resumes (a wake opens
1377
+ * its leg with the input it hands over instead): an approved, resumed leg is still that leg's work. Absent ⇒ the host said
1378
+ * nothing (or the row was minted before the member). Attribution only. A reader that lacks the word would resume the leg with
1379
+ * its origin silently lost. */
1380
+ runOrigin?: import("./run-origin.js").RunOrigin;
1368
1381
  /** The tool-selector layers this LEG was spawned under (`RunInternals.toolCeiling`), stamped at every mint: a resume that hands
1369
1382
  * no live ceiling restores it, so a resumed child can never use a tool its spawning run could not. Absent ⇒ the leg had no
1370
1383
  * ceiling (a root run) or the row was minted before the member. A reader that lacks the word would run the leg unbounded.
@@ -2096,6 +2109,11 @@ export interface CheckpointSummary {
2096
2109
  * value is a member of the closed set ({@link import("./ask-origin.js").isAskOrigin}) — a bad value
2097
2110
  * reads as absent, never as a word. OMITTED when the row carries none (a pre-existing row). */
2098
2111
  origin?: import("./ask-origin.js").AskOrigin;
2112
+ /** What opened the leg that parked this row — the row's `state.runOrigin` (`"scheduled"`: the deployment's scheduler, not a
2113
+ * person submitting just now), for every gate kind, so an inbox shows it in the one listing call. Echoed only as a member of
2114
+ * {@link import("./run-origin.js").RUN_ORIGINS} (the resume's screen refuses any other value loudly; this projection never
2115
+ * invents one). OMITTED when the row carries none. ECHO-ONLY: attribution, never a gate input. */
2116
+ runOrigin?: import("./run-origin.js").RunOrigin;
2099
2117
  /**
2100
2118
  * PRESENCE ONLY — this pending `tool_approval` row's payload carries at least one DIRECTIONAL
2101
2119
  * format control (the {@link import("./tool-policy.js").AskRequest.hasBidiControls} character class;
@@ -2214,7 +2232,7 @@ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "g
2214
2232
  * a skill's `baseDir` by its own reader, `config.skill_base_dir_invalid`). A door not entered here (the leg's model, its rebuilt
2215
2233
  * roster, its answer face, the approval seat's value) still refuses after the claim, each for a stated reason (INTEGRATION-CORE, "A resume's two doors").
2216
2234
  */
2217
- export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.permission_mode_invalid", "config.shell_gate_value_retired", "config.approval_reach_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"];
2235
+ export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["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"];
2218
2236
  export type CheckpointConfigRefusalCode = (typeof CHECKPOINT_CONFIG_REFUSAL_CODES)[number];
2219
2237
  export declare const isCheckpointConfigRefusalCode: (word: unknown) => word is CheckpointConfigRefusalCode;
2220
2238
  /** The words of a {@link CheckpointError}'s optional `detail.field` (what each means: the `detail` member's doc). A CLOSED SET with one home, registered in
@@ -2748,13 +2766,12 @@ export declare function encodeAtFidelity(fidelity: StoreFidelity, value: unknown
2748
2766
  };
2749
2767
  export interface CheckpointStore {
2750
2768
  /**
2751
- * Managed-retention declaration (ruled 2026-08-05, retention.ts): `"managed"` promises the
2752
- * `ManagedRetentionCapability` contract — including the reap/unpin gap this interface documents on
2753
- * {@link reap} (a managed store's scheduled expiry DOES release the session pins). `"none"` (or
2754
- * ABSENT — read fail-closed as `"none"`) states the store cannot delete on schedule; a deployment
2755
- * with a LOCKED retention policy refuses to start over it. Declaration, never duck-typing.
2769
+ * Managed-retention declaration (retention.ts), stated by the party that runs the sweep: `"managed"` says this store's
2770
+ * rows are deleted on schedule by the deployment — an executor runs over them, closing the reap/unpin gap documented on
2771
+ * {@link reap} (its scheduled expiry DOES release the session pins). `"none"` (or ABSENT — read fail-closed as `"none"`)
2772
+ * says nothing deletes them on schedule; a deployment with a LOCKED retention policy refuses to start over it.
2756
2773
  */
2757
- readonly retention?: import("./retention.js").RetentionDeclaration;
2774
+ readonly retention?: RetentionDeclaration;
2758
2775
  /**
2759
2776
  * design/173 §2.3 — durability declaration (see {@link StoreDurability}): whether checkpoints
2760
2777
  * this store accepts survive a process restart. Same "declaration, never duck-typing" posture as
@@ -2771,19 +2788,6 @@ export interface CheckpointStore {
2771
2788
  * that still matches.
2772
2789
  */
2773
2790
  readonly fidelity?: StoreFidelity;
2774
- /**
2775
- * F-012 L2/L3 — the RE-DECISION capability declaration: whether this store's `reopen` (and, when
2776
- * present, a durable validating-lease discipline) actually works — a promise, not a method-presence
2777
- * sniff (`reopen` is optional and a stub that returns `false` still satisfies the type). The
2778
- * sandbox-admission mode's pre-flight REQUIRES `redecision.reopen === true` (its boundary asks park
2779
- * to a human and must be re-decidable); absent reads fail-closed as "no declared re-decision face"
2780
- * and the mode refuses to arm, loudly. Same "declaration, never duck-typing" posture as
2781
- * {@link retention}/{@link durability}/{@link fidelity}.
2782
- */
2783
- readonly redecision?: {
2784
- reopen: boolean;
2785
- validatingLease?: boolean;
2786
- };
2787
2791
  /**
2788
2792
  * The EXECUTION-OUTCOME declaration — REQUIRED, and required to be exactly `{ outcome: true }`: the
2789
2793
  * store promises that {@link recordExecutionOutcome} is the real CAS this contract describes (the
@@ -2846,9 +2850,12 @@ export interface CheckpointStore {
2846
2850
  * `resolve` CAS *before* the workspace `resumeVM` runs; if that restore then fails (`resume.env_failed`)
2847
2851
  * the pending action never executed yet the checkpoint is consumed — without this the suspended work is
2848
2852
  * lost to a forced "re-initiate" (fine for a short approval, ruinous for a long unattended task).
2849
- * Reopening lets a retry re-resume the SAME work. Optional: a store that omits it keeps the prior (lossy)
2850
- * behavior, and the runner degrades gracefully. Safe by the `status='resolved'` guard — only the run that
2851
- * consumed the checkpoint (and then failed to restore) can reopen it, and only while it is still `resolved`.
2853
+ * Reopening lets a retry re-resume the SAME work. REQUIRED — the verb is the contract (no declaration stands
2854
+ * for it; the store seat, {@link resolveCheckpointStore}, refuses a store that does not carry it): a claimed
2855
+ * resume that ends before its decided action is disposed — a failed restore, a refusal at the leg's prepare, an
2856
+ * abort, a leg that returns failed — returns the row here, and the engine has no lane for a store that cannot. Safe by
2857
+ * the `status='resolved'` guard — only the run that consumed the checkpoint (and then failed to restore) can
2858
+ * reopen it, and only while it is still `resolved`.
2852
2859
  *
2853
2860
  * **design/80 D-1 (reopen-by-reason):** the `reason` distinguishes the two reopen triggers (both shipped at
2854
2861
  * runtask.ts) so re-resume can validate per reason (§3 inv #1): `env_failed` (the action is still valid,
@@ -2863,7 +2870,7 @@ export interface CheckpointStore {
2863
2870
  * already ran or re-decide one already refused. Answers `false` like every other predicate miss; the
2864
2871
  * reasons and the winner are untouched.
2865
2872
  */
2866
- reopen?(token: CheckpointToken, scope: string, reason: ReopenReason): Promise<boolean>;
2873
+ reopen(token: CheckpointToken, scope: string, reason: ReopenReason): Promise<boolean>;
2867
2874
  /**
2868
2875
  * Record how the DECIDED action was finally disposed on the resumed leg — the {@link GateOutcome} its
2869
2876
  * `tool_end` frame carried (see {@link CheckpointRow.executionOutcome} for what the record means and why
@@ -2987,9 +2994,8 @@ export interface CheckpointStore {
2987
2994
  * needed semantics; "who beat me / with what" is claimant-identity territory this contract
2988
2995
  * does not mint.
2989
2996
  * 7. **No declaration bit** — presence of the method IS the contract (an implementation
2990
- * obligation at the same level as `resolve`'s CAS promise); no `redecision`-style declaration,
2991
- * because that family guards against a stub satisfying a type, and a `claimTerminal` stub has
2992
- * no such shape — the return form itself carries the obligation.
2997
+ * obligation at the same level as `resolve`'s CAS promise), as it is for the required {@link reopen}:
2998
+ * the return form itself carries the obligation.
2993
2999
  *
2994
3000
  * Deployment correspondence (an ask-row store implementing the same law maps its own vocabulary):
2995
3001
  * token+scope ↔ the ask id (+ its run binding); pending/resolved/expired ↔ the ask row's
@@ -3079,12 +3085,13 @@ export declare function resolveCheckpointStore(spec: {
3079
3085
  }, deps: {
3080
3086
  checkpointStore?: CheckpointStore;
3081
3087
  }): CheckpointStore | undefined;
3082
- /** The ONE refusal of a store seat whose {@link CheckpointStore} does not declare `execution = { outcome: true }`
3083
- * (named by seat and by the store's constructor when it has one). Same door, same code, as the retired-`null`
3084
- * refusal above: a configuration the run cannot honour is refused at the first read, never carried. */
3085
- export declare function checkpointStoreExecutionUndeclared(seat: "TaskSpec.checkpointStore" | "RunnerDeps.checkpointStore", store: object): Error & {
3088
+ /** The ONE refusal of a store seat whose {@link CheckpointStore} lacks a required member (the {@link CheckpointStore.execution}
3089
+ * declaration, the {@link CheckpointStore.reopen} verb) — every missing one named, with the seat and the store's constructor when it
3090
+ * has one — or `undefined` when the store carries them all. Same door, same code, as the retired-`null` refusal below: a configuration
3091
+ * the run cannot honour is refused at the first read, never carried. */
3092
+ export declare function checkpointStoreIncomplete(seat: "TaskSpec.checkpointStore" | "RunnerDeps.checkpointStore", store: object): (Error & {
3086
3093
  code: "config.invalid_checkpoint_store";
3087
- };
3094
+ }) | undefined;
3088
3095
  /** The ONE refusal of the retired `checkpointStore: null` spelling (the resolver and the workflow baseline overlay both throw it). */
3089
3096
  export declare function retiredCheckpointStoreNull(): Error & {
3090
3097
  code: "config.invalid_checkpoint_store";
@@ -3174,18 +3181,14 @@ export type CheckpointFaultMode =
3174
3181
  * {@link testInjectFault} simulates the crash-recovery races a real backend must survive.
3175
3182
  */
3176
3183
  export declare class InMemoryCheckpointStore implements CheckpointStore {
3177
- /** In-memory rows die with the process, but there is no scheduled tenant-scoped deletion contract
3178
- * here — honestly `"none"` (a locked retention policy must refuse this store). */
3179
- readonly retention: "none";
3184
+ /** Managed-retention declaration (retention.ts) — the `retention` option (default `"none"`, a third word refused), stated by
3185
+ * the party that runs the sweep. In-memory rows die with the process, which is not a schedule. */
3186
+ readonly retention: RetentionDeclaration;
3180
3187
  /** design/173 §2.3 — honest declaration: in-memory rows die with the process. */
3181
3188
  readonly durability: "process-local";
3182
3189
  /** Honest declaration on the fidelity axis: `put`/`get` are `structuredClone`, so a row keeps the
3183
3190
  * whole structured-clone domain — a `Date` filed here is a `Date` when it comes back. */
3184
3191
  readonly fidelity: "structured-clone";
3185
- /** F-012 L2: this store's `reopen` is a real resolved→pending CAS (below) — declared, not sniffed. */
3186
- readonly redecision: {
3187
- readonly reopen: true;
3188
- };
3189
3192
  /** The execution-outcome record verb below is the contract's CAS, and `reopen` honours the record. */
3190
3193
  readonly execution: {
3191
3194
  readonly outcome: true;
@@ -3209,6 +3212,7 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
3209
3212
  readonly owner: string | null;
3210
3213
  } | undefined>;
3211
3214
  holderIsCurrent?: HolderJudge;
3215
+ retention?: RetentionDeclaration;
3212
3216
  });
3213
3217
  put(token: CheckpointToken, cp: Checkpoint): Promise<void>;
3214
3218
  get(token: CheckpointToken): Promise<Checkpoint | null>;
@@ -4,6 +4,8 @@ import { PROBE_CAUSE_PATH_MAX, PROBE_REASON_MAX, inlineUntrusted, sanitizeUntrus
4
4
  import { carriesBidiControls } from "./tool-policy.js";
5
5
  import { isAutoModeFallbackCause, readDenialLimitFallback } from "./auto-mode.js";
6
6
  import { isAskOrigin, isPersistedRuleMandate } from "./ask-origin.js";
7
+ import { isRunOrigin, RUN_ORIGINS } from "./run-origin.js";
8
+ import { describeRejectedValue } from "./tool-search-setting.js";
7
9
  import { readBoundBinding } from "./skill-grant-binding.js";
8
10
  import { checkpointExecutionRecorded, executionRecordDisposition, ExecutionOutcomeConflictError, } from "./checkpoint-execution-record.js";
9
11
  import { checkpointHolderMatches, checkpointOccMatches, checkpointRevOf } from "./checkpoint-generation.js";
@@ -13,6 +15,7 @@ import { renderUntrustedCommandText, stripFormatCharacters } from "./permission-
13
15
  import { egressText } from "./untrusted-egress.js";
14
16
  import { steerReplayRefusal } from "./steer-replay.js";
15
17
  import { isPermissionMode } from "./ask-origin.js";
18
+ import { readRetentionDeclaration } from "./retention.js";
16
19
  export function mintCheckpointToken() {
17
20
  return randomBytes(16).toString("hex");
18
21
  }
@@ -79,7 +82,7 @@ const BIDI_BACKFILL_MAX_NODES = 512;
79
82
  export const MAX_PENDING_STEER_CHARS = 16_000;
80
83
  export const PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES = 48_000;
81
84
  export const MAX_PENDING_STEER_ENTRIES = Math.floor(PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES / MAX_PENDING_STEER_CHARS);
82
- export const PENDING_STEER_FROZEN_FIELDS = Object.freeze(["text", "trusted", "actor", "seq", "inputId", "priority"]);
85
+ export const PENDING_STEER_FROZEN_FIELDS = Object.freeze(["text", "trusted", "actor", "seq", "inputId", "priority", "runOrigin"]);
83
86
  export function isPlainRecord(x) {
84
87
  try {
85
88
  if (x === null || typeof x !== "object" || Array.isArray(x))
@@ -316,6 +319,7 @@ export function summarizeCheckpoint(cp, disclose) {
316
319
  ...(cp.state.workspaceHandle !== undefined
317
320
  ? { restoreMode: cp.state.workspaceHandle.restoreMode === "park_only" ? "park_only" : "snapshot" }
318
321
  : {}),
322
+ ...((runOrigin) => (isRunOrigin(runOrigin) ? { runOrigin } : {}))(cp.state.runOrigin),
319
323
  ...(tool?.preview !== undefined ? { preview: tool.preview } : {}),
320
324
  ...(tool?.previewWithheld === "oversize" || tool?.previewWithheld === "unavailable" ? { previewWithheld: tool.previewWithheld } : {}),
321
325
  ...(tool?.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
@@ -335,7 +339,7 @@ export function summarizeCheckpoint(cp, disclose) {
335
339
  ...(hasBidi ? { hasBidiControls: true } : {}),
336
340
  };
337
341
  }
338
- 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.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"]);
342
+ 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"]);
339
343
  export const isCheckpointConfigRefusalCode = (word) => CHECKPOINT_CONFIG_REFUSAL_CODES.some((w) => w === word);
340
344
  export class CheckpointError extends Error {
341
345
  code;
@@ -375,22 +379,31 @@ export function resolveCheckpointStore(spec, deps) {
375
379
  if (spec.checkpointStore === "disabled")
376
380
  return undefined;
377
381
  if (spec.checkpointStore !== undefined) {
378
- if (spec.checkpointStore.execution?.outcome !== true)
379
- throw checkpointStoreExecutionUndeclared("TaskSpec.checkpointStore", spec.checkpointStore);
382
+ const refused = checkpointStoreIncomplete("TaskSpec.checkpointStore", spec.checkpointStore);
383
+ if (refused !== undefined)
384
+ throw refused;
380
385
  return spec.checkpointStore;
381
386
  }
382
- if (deps.checkpointStore !== undefined && deps.checkpointStore?.execution?.outcome !== true) {
383
- throw checkpointStoreExecutionUndeclared("RunnerDeps.checkpointStore", deps.checkpointStore);
387
+ if (deps.checkpointStore !== undefined) {
388
+ const refused = checkpointStoreIncomplete("RunnerDeps.checkpointStore", deps.checkpointStore);
389
+ if (refused !== undefined)
390
+ throw refused;
384
391
  }
385
392
  return deps.checkpointStore;
386
393
  }
387
- export function checkpointStoreExecutionUndeclared(seat, store) {
388
- const ctor = store?.constructor?.name;
394
+ const REQUIRED_STORE_MEMBERS = [
395
+ { carried: (store) => store?.execution?.outcome === true, lacks: "does not declare `execution = { outcome: true }`", cost: "the execution-outcome record (recordExecutionOutcome, and reopen refusing a recorded row) — without it no reader can settle how a resumed approval was disposed" },
396
+ { carried: (store) => typeof store?.reopen === "function", lacks: "does not carry the `reopen` verb", cost: "the claim's reversal (reopen) — without it a resume the engine claimed and then refused before its decided action was disposed would consume the approval" },
397
+ ];
398
+ export function checkpointStoreIncomplete(seat, store) {
399
+ const read = store;
400
+ const missing = REQUIRED_STORE_MEMBERS.filter((m) => !m.carried(read));
401
+ if (missing.length === 0)
402
+ return undefined;
403
+ const ctor = read?.constructor?.name;
389
404
  const name = typeof ctor === "string" && ctor.length > 0 && ctor !== "Object" ? ` (${ctor})` : "";
390
- const e = new Error(`${seat}: the wired CheckpointStore${name} does not declare \`execution = { outcome: true }\` — the execution-outcome ` +
391
- "record (recordExecutionOutcome, and reopen refusing a recorded row) is a required member of the store contract; " +
392
- "a store without it cannot record how a resumed approval was disposed, so the run is refused here rather than " +
393
- "resolving rows no reader can settle. Implement the verb and add the declaration (the in-tree stores and the " +
405
+ const e = new Error(`${seat}: the wired CheckpointStore${name} ${missing.map((m) => m.lacks).join(" and ")} — ${missing.map((m) => m.cost).join("; ")}. ` +
406
+ "Each is a required member of the store contract, so the run is refused here. Implement it (the in-tree stores and the " +
394
407
  "store-contract kit are the reference).");
395
408
  e.code = "config.invalid_checkpoint_store";
396
409
  return e;
@@ -441,6 +454,7 @@ export function validatePendingSteer(steer) {
441
454
  const actor = steer.actor;
442
455
  const inputId = steer.inputId;
443
456
  const priority = steer.priority;
457
+ const runOrigin = steer.runOrigin;
444
458
  if (typeof text !== "string") {
445
459
  throw new CheckpointError("steering.invalid_content", "steering text must be a string");
446
460
  }
@@ -453,6 +467,9 @@ export function validatePendingSteer(steer) {
453
467
  if (priority !== undefined && priority !== "now" && priority !== "next" && priority !== "later") {
454
468
  throw new CheckpointError("steering.invalid_content", `steering priority "${typeof priority === "string" ? priority : priority === null ? "null" : typeof priority}" is outside the injection-priority domain ("now", "next", "later")`);
455
469
  }
470
+ if (runOrigin !== undefined && !isRunOrigin(runOrigin)) {
471
+ throw new CheckpointError("steering.invalid_content", `steering runOrigin ${describeRejectedValue(runOrigin)} is not a run origin (${RUN_ORIGINS.map((w) => JSON.stringify(w)).join(" | ")}) — omit it when the deployment's scheduler did not hand this input`);
472
+ }
456
473
  const actorTwin = actor === undefined ? undefined : captureActorAssertion(actor);
457
474
  if (inputId !== undefined && (inputId === "" || inputId.length > MAX_STEER_INPUT_ID_CHARS)) {
458
475
  throw new CheckpointError("steering.invalid_content", `steering inputId must be a non-empty string of at most ${MAX_STEER_INPUT_ID_CHARS} characters`);
@@ -472,6 +489,7 @@ export function validatePendingSteer(steer) {
472
489
  ...(actorTwin !== undefined ? { actor: actorTwin } : {}),
473
490
  inputId: inputId ?? uuidv7(),
474
491
  ...(priority !== undefined ? { priority: priority } : {}),
492
+ ...(runOrigin !== undefined ? { runOrigin } : {}),
475
493
  };
476
494
  }
477
495
  export const MAX_ACTOR_FIELD_CHARS = 256;
@@ -545,16 +563,16 @@ export function checkpointRowMatches(cp, scope, status) {
545
563
  return cp !== undefined && cp.scope === scope && cp.status === status;
546
564
  }
547
565
  export class InMemoryCheckpointStore {
548
- retention = "none";
566
+ retention;
549
567
  durability = "process-local";
550
568
  fidelity = "structured-clone";
551
- redecision = { reopen: true };
552
569
  execution = { outcome: true };
553
570
  cps = new Map();
554
571
  fault = null;
555
572
  disclose;
556
573
  holderIsCurrent;
557
574
  constructor(opts = {}) {
575
+ this.retention = readRetentionDeclaration("InMemoryCheckpointStore.retention", opts.retention);
558
576
  this.disclose = opts.disclose;
559
577
  this.holderIsCurrent = opts.holderIsCurrent;
560
578
  if (opts.holderIsCurrent !== undefined)
@@ -1,4 +1,5 @@
1
1
  import { hasConversationContent } from "./session.js";
2
+ import { egressText } from "./untrusted-egress.js";
2
3
  export const CROSS_BOUNDARY_TAINT_BITS = Object.freeze(["targetExecutionArmed", "offTargetReadObserved"]);
3
4
  export const CROSS_BOUNDARY_POSTURES = Object.freeze(["single_user", "multi_tenant"]);
4
5
  const postureSeatIsTheSet = true;
@@ -152,13 +153,14 @@ export function crossBoundaryPostureUndeclaredNotice(at) {
152
153
  };
153
154
  }
154
155
  export function crossBoundaryRecordUnwrittenNotice(at) {
156
+ const cause = egressText("same-principal", at.cause).slice(0, 300);
155
157
  return {
156
158
  code: "config.cross_boundary_record_unwritten",
157
- message: `The session's cross-boundary record could not be written at ${at.phase} (${at.cause.slice(0, 300)}) — ` +
159
+ message: `The session's cross-boundary record could not be written at ${at.phase} (${cause}) — ` +
158
160
  (!at.governed
159
161
  ? "the tree is not governed: no judgment reads the record, so its failure refused nothing; the tree's growth, or the leg's end, writes next, and a failure of this same state is not reported again."
160
162
  : `the tree is governed: ${at.phase === "prepare" ? "the leg's next write (an exit before its call runs, a suspend before its row, its end) owes the record again; if none lands, " : ""}the next leg on this session reads the content after its newest record as off-target, so its device calls are put to a person.`),
161
- detail: { sessionId: at.sessionId, runId: at.runId, phase: at.phase, governed: at.governed, cause: at.cause.slice(0, 300) },
163
+ detail: { sessionId: at.sessionId, runId: at.runId, phase: at.phase, governed: at.governed, cause },
162
164
  };
163
165
  }
164
166
  const NO_LEGS = Object.freeze([]);
@@ -72,7 +72,7 @@ export interface EngineNotice {
72
72
  * - `"mods.registration_refused"` — an extension registration was not mounted: a registration admitted before it
73
73
  * answered `{ refuse }` on `plugin.register`, or failed while judging it (fail-closed). The run goes on without it.
74
74
  * Audience `user` (the seat is in `detail`). Once per refused registration per run. `detail: { name, seat, tier,
75
- * refusedBy, reason, sessionId }` (`seat` ∈ `deployment` / `task`).
75
+ * provenance?, refusedBy, reason, sessionId }` (`seat` ∈ `deployment` / `task`; `provenance` as the host gave it, absent when none).
76
76
  * - `"skills.listing_truncated"` — the `<skills>` disclosure block did not fit its byte budget, so
77
77
  * at least one skill is listed without its description (`nameOnly`) or, in the pathological case,
78
78
  * not listed at all (`dropped`); the `Skill` tool still serves every one of them. Audience
@@ -400,8 +400,9 @@ export interface EngineNotice {
400
400
  * is silent; a broken one must not look the same). Once per prepared leg;
401
401
  * `detail: { problem, sessionId, runId }`.
402
402
  * - `"config.execution_env_capability_invalid"` — a remote env DECLARES a boolean capability key
403
- * (`isolation`, `suspendable`, `canonicalPathAuthoritative`) with a non-boolean value; ABSENCE is a
404
- * supported reading of each and stays silent. Once per key per run; `detail: { key, valueType }`. Also minted for
403
+ * (`isolation`, `suspendable`, `canonicalPathAuthoritative`, `sharesProcessTable`) with a non-boolean value; ABSENCE is a
404
+ * supported reading of the first three and stays silent, and is announced for `sharesProcessTable`, which has no
405
+ * absent reading (`valueType: "undefined"`). Once per key per run; `detail: { key, valueType }`. Also minted for
405
406
  * `withheldEnv` (key `"withheldEnv"`) when it is neither a list of findings nor `"unknown"`, read at a shell call of
406
407
  * a root leg (once per run).
407
408
  * - `"config.secret_env_scrubbed"` (#1081) — the D1 fail-closed `scrub` policy, or the deployment's
@@ -1,8 +1,14 @@
1
+ import { egressAccount, egressText } from "./untrusted-egress.js";
1
2
  let malformedNoticeSeatAnnounced = false;
2
3
  export function __resetMalformedNoticeSeatAnnouncement() {
3
4
  malformedNoticeSeatAnnounced = false;
4
5
  }
5
6
  export function deliverEngineNotice(onNotice, notice) {
7
+ notice = {
8
+ ...notice,
9
+ message: typeof notice.message === "string" ? egressText("same-principal", notice.message) : notice.message,
10
+ ...(notice.detail !== undefined ? { detail: egressAccount("same-principal", notice.detail) } : {}),
11
+ };
6
12
  if (notice.sessionId === undefined && typeof notice.detail?.["sessionId"] === "string") {
7
13
  notice = { ...notice, sessionId: notice.detail["sessionId"] };
8
14
  }
@@ -114,11 +114,13 @@ export interface FileHistoryError {
114
114
  * whose history cannot be judged) must NOT wear this
115
115
  * code or the failure disappears into that silence — those are `adopt_failed`, which the
116
116
  * ADOPTION FAMILY shares: `importHistory` publishes under the same target law and answers the
117
- * same code for the same non-conflict failures, and `exportHistory` answers it for a history it cannot
118
- * read whole (its `unsupported_format` names a bad ENVELOPE or
119
- * work its shape drove; a fault in the PUBLISH step itself — the disk refusing a good graph —
120
- * answers `adopt_failed`); `unsupported_format`
121
- * = a foreign-epoch or wrong-version envelope; the rest name the verb that failed. */
117
+ * same code for the same non-conflict failures — a source that cannot supply a referenced blob (it is
118
+ * absent, its read throws, or its bytes do not hash to their address), a target whose history cannot
119
+ * be judged, a fault in staging or publishing a good graph (the disk refusing it) — and `exportHistory`
120
+ * answers it for a history it cannot read whole. `unsupported_format` is the import DOOR's refusal and
121
+ * nothing else: a foreign-epoch or wrong-version envelope, or an envelope whose content the closed sets
122
+ * (or the backend's own record-naming rules) cannot hold, refused before any blob is fetched; the rest
123
+ * name the verb that failed. */
122
124
  code: (typeof FILE_HISTORY_ERROR_CODES)[number];
123
125
  message: string;
124
126
  /** The backend's judgment of a FAULT — it could not do what it was asked — as a {@link GovernanceRetryClass}
@@ -330,8 +332,9 @@ export declare function fileHistoryExportDigest(data: FileHistoryExport): string
330
332
  * The import DOOR's structural judgment, shared by every backend (a second implementation is a second
331
333
  * opinion about what is safe to accept): the envelope must carry THIS format version and every row
332
334
  * must be shaped and self-described from the closed sets — `unsupported_format` otherwise, never a
333
- * coercion. Backends call this BEFORE fetching a single blob, so a foreign-epoch payload costs
334
- * nothing and changes nothing.
335
+ * coercion and never a throw (a payload that cannot be read is refused in the same word). Backends call
336
+ * this BEFORE fetching a single blob, so a foreign-epoch payload costs nothing and changes nothing, and
337
+ * `unsupported_format` is a word only this door (and a backend's own record-naming rule) says.
335
338
  */
336
339
  export declare function validateFileHistoryExport(data: FileHistoryExport): FileHistoryResult;
337
340
  /**
@@ -568,7 +571,10 @@ export interface FileHistoryStore {
568
571
  * re-publish). A non-empty target with any other content ⇒ typed `conflict` refusal — atomic
569
572
  * visibility prevents half-graphs, this law prevents publishing the WRONG complete graph over
570
573
  * locally-grown history. A target whose history cannot be judged ⇒ `adopt_failed`, before any blob is
571
- * fetched; a source that cannot supply a referenced blob ⇒ `adopt_failed`. `exportHistory` answers a
574
+ * fetched; a source that cannot supply a referenced blob — absent, its read throws, or bytes that fail
575
+ * their content address — ⇒ `adopt_failed`, and so is a fault in staging or publishing the graph.
576
+ * `unsupported_format` is the door's refusal alone ({@link validateFileHistoryExport}, before any blob
577
+ * is fetched). `exportHistory` answers a
572
578
  * {@link FileHistoryExportResult}: the whole graph, `null` for nothing to export, or `adopt_failed` with the
573
579
  * fault for a history it cannot read whole (an unreadable tracked set, boundaries that cannot be judged) —
574
580
  * never a partial graph, and never a `null` that hides a fault.
@@ -158,6 +158,14 @@ export function fileHistoryExportDigest(data) {
158
158
  return createHash("sha256").update(JSON.stringify(canonical)).digest("hex");
159
159
  }
160
160
  export function validateFileHistoryExport(data) {
161
+ try {
162
+ return judgeFileHistoryEnvelope(data);
163
+ }
164
+ catch (err) {
165
+ return { ok: false, error: { code: "unsupported_format", message: `file-history import payload cannot be read: ${thrownText(err)}` } };
166
+ }
167
+ }
168
+ function judgeFileHistoryEnvelope(data) {
161
169
  const bad = (message) => ({ ok: false, error: { code: "unsupported_format", message } });
162
170
  if (data === null || typeof data !== "object")
163
171
  return bad("file-history import payload is not an envelope");
@@ -182,6 +190,8 @@ export function validateFileHistoryExport(data) {
182
190
  if (typeof t.baseAvailable !== "boolean" || !Array.isArray(t.versions))
183
191
  return bad(`tracked row ${t.relOrAbsPath} is missing its base-availability state or version chain`);
184
192
  for (const v of t.versions) {
193
+ void v?.backupTime;
194
+ void v?.parentIdent;
185
195
  if (typeof v?.version !== "number" || !Number.isInteger(v.version) || v.version < 1)
186
196
  return bad(`tracked row ${t.relOrAbsPath} carries a non-integer version number`);
187
197
  if (v.blobHash !== null && (typeof v.blobHash !== "string" || !/^[0-9a-f]{64}$/.test(v.blobHash)))
@@ -874,7 +884,7 @@ export class InMemoryFileHistoryStore {
874
884
  }
875
885
  }
876
886
  catch (err) {
877
- return { ok: false, error: { code: "unsupported_format", message: `importHistory failed: ${thrownText(err)}`, ...caughtFault(err) } };
887
+ return { ok: false, error: { code: "adopt_failed", message: `importHistory failed: ${thrownText(err)}`, ...caughtFault(err) } };
878
888
  }
879
889
  }
880
890
  async importStaged(scope, data, srcGetBlob, needed) {
@@ -888,12 +898,12 @@ export class InMemoryFileHistoryStore {
888
898
  bytes = await srcGetBlob(hash);
889
899
  }
890
900
  catch (err) {
891
- return { ok: false, error: { code: "unsupported_format", message: `source blob ${hash} fetch failed: ${thrownText(err)}`, ...caughtFault(err) } };
901
+ return { ok: false, error: { code: "adopt_failed", message: `source blob ${hash} fetch failed: ${thrownText(err)}`, ...caughtFault(err) } };
892
902
  }
893
903
  if (bytes === undefined)
894
904
  return { ok: false, error: { code: "adopt_failed", message: `source blob ${hash} is missing — the envelope's graph cannot be completed, so nothing is published` } };
895
905
  if (createHash("sha256").update(bytes).digest("hex") !== hash) {
896
- return { ok: false, error: { code: "unsupported_format", message: `source blob ${hash} fails content-address integrity — refused, nothing published` } };
906
+ return { ok: false, error: { code: "adopt_failed", message: `source blob ${hash} fails content-address integrity — refused, nothing published` } };
897
907
  }
898
908
  staged.set(hash, bytes);
899
909
  }
@@ -920,7 +930,7 @@ export class InMemoryFileHistoryStore {
920
930
  return { ok: true };
921
931
  }
922
932
  catch (err) {
923
- return { ok: false, error: { code: "unsupported_format", message: `importHistory failed: ${thrownText(err)}`, ...caughtFault(err) } };
933
+ return { ok: false, error: { code: "adopt_failed", message: `importHistory failed: ${thrownText(err)}`, ...caughtFault(err) } };
924
934
  }
925
935
  }
926
936
  }
@@ -20,8 +20,10 @@ export interface FsWriteGatePolicyOptions {
20
20
  * the `acceptDirs`/`exemptDirs` entries below always resolve against THIS value. */
21
21
  rootPath?: string;
22
22
  /** Writes whose canonical target lands inside one of these dirs are ALLOWED (the accept-session
23
- * domain, e.g. the cwd subtree after "allow all edits during this session"). */
24
- acceptDirs?: readonly string[];
23
+ * domain, e.g. the cwd subtree after "allow all edits during this session"). A getter is read once per
24
+ * call — a leg's live write roots, which move with its write location — and its entries are CANONICAL
25
+ * identities, compared as keys (a fixed list is resolved per call, as before). */
26
+ acceptDirs?: readonly string[] | (() => readonly string[]);
25
27
  /** Writes whose canonical target lands inside one of these dirs are ALLOWED and never asked
26
28
  * (auto-approved working areas: the scratchpad dir, plan files). Checked before `acceptDirs`
27
29
  * (same verdict — the split is intent/observability, exemptions are structural not session-won).
@@ -42,7 +42,11 @@ function assertExemptDirsDoNotCoverRoot(exemptDirs, rootLexical) {
42
42
  }
43
43
  export function createFsWriteGatePolicy(opts) {
44
44
  const { env, rootPath, defaultWrite } = opts;
45
- const acceptDirs = opts.acceptDirs && opts.acceptDirs.length > 0 ? opts.acceptDirs : undefined;
45
+ const acceptDirsSeat = opts.acceptDirs;
46
+ const acceptDirsNow = () => {
47
+ const dirs = typeof acceptDirsSeat === "function" ? acceptDirsSeat() : acceptDirsSeat;
48
+ return dirs !== undefined && dirs.length > 0 ? dirs : undefined;
49
+ };
46
50
  const exemptDirs = opts.exemptDirs && opts.exemptDirs.length > 0 ? opts.exemptDirs : undefined;
47
51
  const rootLexical = absoluteRootOf(rootPath, env.cwd);
48
52
  assertExemptDirsDoNotCoverRoot(exemptDirs, rootLexical);
@@ -80,12 +84,12 @@ export function createFsWriteGatePolicy(opts) {
80
84
  let refusedDomain;
81
85
  for (const [dirs, structural] of [
82
86
  [exemptDirs, true],
83
- [acceptDirs, false],
87
+ [acceptDirsNow(), false],
84
88
  ]) {
85
89
  if (!dirs)
86
90
  continue;
87
91
  for (const raw of dirs) {
88
- const dir = await canonicalizeTarget(env, raw, signal, pathFamilyOf({ root: rootPath ?? env.cwd }), rootPath);
92
+ const dir = !structural && typeof acceptDirsSeat === "function" ? { ok: true, key: raw } : await canonicalizeTarget(env, raw, signal, pathFamilyOf({ root: rootPath ?? env.cwd }), rootPath);
89
93
  if (!dir.ok)
90
94
  continue;
91
95
  if (structural) {
@@ -3,9 +3,9 @@ import { markTightenMessage } from "./safety-axis-vocab.js";
3
3
  import { PROBE_REASON_MAX, normalizeProbeCause } from "./checkpoint-store.js";
4
4
  import { normalizeReadRootCandidate } from "./read-root-candidate.js";
5
5
  import { engineFailClosedExit, hookDenyExit } from "./runner/gate-exit.js";
6
- import { readRejudge, screenRewrite } from "./rewrite-rejudge.js";
6
+ import { noteRewrite, POLICY_AUTHOR, readRejudge, screenRewrite } from "./rewrite-rejudge.js";
7
7
  import { traceHookCrash } from "./gate-crash-trace.js";
8
- import { writeProtectionMandated, writeProtectionTightenDecision } from "./write-protect.js";
8
+ import { writeProtectionMandated, writeProtectionReachOf, writeProtectionTightenDecision } from "./write-protect.js";
9
9
  import { createGateDeadline, awaitWriteProtectionJudgment, gateWaitFailureOf, withGateTimeout } from "./gate-bounded-await.js";
10
10
  import { shellReadFaceWords } from "../tools/fs/shell-read-face.js";
11
11
  import { failedJudgmentDeny } from "./runner/policy-throw.js";
@@ -54,6 +54,7 @@ export async function runGateFold(pass) {
54
54
  }
55
55
  if ((pass.decision.action === "allow" || pass.decision.action === "ask") && pass.decision.updatedInput !== undefined) {
56
56
  pass.policyRewrite = argsAsTheToolReads(pass.req, pass.decision.updatedInput);
57
+ noteRewrite(pass.rewrites, pass.req, pass.currentInput, pass.policyRewrite, POLICY_AUTHOR);
57
58
  }
58
59
  else if (pass.hookAsk?.updatedInput !== undefined) {
59
60
  pass.policyRewrite = argsAsTheToolReads(pass.req, pass.hookAsk.updatedInput);
@@ -170,7 +171,7 @@ export async function runGateFold(pass) {
170
171
  traceHookCrash(input, new Error(`write-protection judge ${kind === "timeout" ? "timed out" : "threw"} for tool "${toolName}" (toolCallId ${toolCallId}) — this call's write target could not be judged: ${thrownText(err)}`), notifier);
171
172
  });
172
173
  if (verdict !== undefined && writeProtectionMandated(verdict))
173
- pass.writeProtected = true;
174
+ pass[writeProtectionReachOf(verdict) === "spelling" ? "writeProtected" : "writeProtectedOnDisk"] = true;
174
175
  const decision = verdict === undefined ? undefined : writeProtectionTightenDecision(toolName, verdict);
175
176
  if (decision !== undefined && (writeProtectionStanding === "allow" || decision.action === "deny")) {
176
177
  pass.decision = decision;
@@ -208,6 +209,8 @@ function applyShellReadVerdict(pass, answer, toolName, shellGated) {
208
209
  pass.shellWritesPlaced = true;
209
210
  if (verdict.writeProtected === true)
210
211
  pass.writeProtected = true;
212
+ if (verdict.writeProtectedOnDisk === true)
213
+ pass.writeProtectedOnDisk = true;
211
214
  if (verdict.targetUnresolved === true)
212
215
  pass.targetUnresolved = true;
213
216
  if (verdict.unplacedOptions !== undefined)