@sema-agent/core 7.72.0 → 7.73.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 (256) hide show
  1. package/CHANGELOG.md +319 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/parked-resume-drive.d.ts +10 -0
  5. package/dist/agents/parked-resume-drive.js +9 -0
  6. package/dist/agents/retain-ledger.d.ts +3 -0
  7. package/dist/agents/send-message-tool.js +1 -0
  8. package/dist/agents/send-user-message-tool.d.ts +12 -0
  9. package/dist/agents/send-user-message-tool.js +67 -0
  10. package/dist/agents/subagent-steps.d.ts +9 -0
  11. package/dist/agents/subagent-steps.js +38 -0
  12. package/dist/agents/subagent.d.ts +2 -0
  13. package/dist/agents/subagent.js +43 -12
  14. package/dist/agents/verify.js +23 -8
  15. package/dist/agents/yield-adoption.js +3 -1
  16. package/dist/brain/anthropic.js +14 -9
  17. package/dist/brain/open-responses.js +4 -5
  18. package/dist/brain/openai.js +30 -23
  19. package/dist/brain/stream-engine.js +159 -151
  20. package/dist/core/actions-digest.d.ts +43 -0
  21. package/dist/core/actions-digest.js +22 -0
  22. package/dist/core/allow-entry.js +3 -3
  23. package/dist/core/auto-mode.d.ts +7 -9
  24. package/dist/core/auto-mode.js +114 -8
  25. package/dist/core/checkpoint-features.d.ts +3 -2
  26. package/dist/core/checkpoint-features.js +1 -1
  27. package/dist/core/checkpoint-rekey.d.ts +1 -1
  28. package/dist/core/checkpoint-rekey.js +6 -1
  29. package/dist/core/checkpoint-requirements.d.ts +23 -3
  30. package/dist/core/checkpoint-requirements.js +5 -1
  31. package/dist/core/checkpoint-row-verdict.js +7 -1
  32. package/dist/core/checkpoint-store.d.ts +24 -2
  33. package/dist/core/checkpoint-store.js +1 -0
  34. package/dist/core/child-clamp-seats.d.ts +15 -0
  35. package/dist/core/child-clamp-seats.js +15 -0
  36. package/dist/core/delegation-frames.d.ts +1 -0
  37. package/dist/core/delegation-frames.js +1 -1
  38. package/dist/core/engine-capabilities.d.ts +5 -1
  39. package/dist/core/engine-capabilities.js +1 -1
  40. package/dist/core/engine-notice.d.ts +30 -22
  41. package/dist/core/engine-version.js +1 -1
  42. package/dist/core/entries-not-applied.d.ts +19 -7
  43. package/dist/core/entries-not-applied.js +33 -1
  44. package/dist/core/governance-codes.d.ts +7 -1
  45. package/dist/core/governance-codes.js +13 -5
  46. package/dist/core/hooks.d.ts +3 -0
  47. package/dist/core/hooks.js +1 -0
  48. package/dist/core/host-instance.d.ts +23 -0
  49. package/dist/core/host-instance.js +69 -0
  50. package/dist/core/instruction-preview.d.ts +63 -0
  51. package/dist/core/instruction-preview.js +406 -0
  52. package/dist/core/leg-budget.d.ts +26 -0
  53. package/dist/core/leg-budget.js +9 -0
  54. package/dist/core/leg-identity.d.ts +51 -1
  55. package/dist/core/leg-identity.js +45 -2
  56. package/dist/core/manager-launch-check.d.ts +48 -0
  57. package/dist/core/manager-launch-check.js +64 -0
  58. package/dist/core/mcp-call-meta.d.ts +2 -2
  59. package/dist/core/mcp-injection-drop.d.ts +20 -10
  60. package/dist/core/mcp-injection-drop.js +9 -3
  61. package/dist/core/mcp-server-spec.d.ts +2 -1
  62. package/dist/core/member-outcome.d.ts +3 -2
  63. package/dist/core/member-outcome.js +1 -1
  64. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  65. package/dist/core/memory-engine/deletion-record.js +96 -0
  66. package/dist/core/memory-engine/engine.js +24 -16
  67. package/dist/core/memory-engine/file-backend.js +7 -5
  68. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  69. package/dist/core/memory-engine/projection-ledger.js +1 -1
  70. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  71. package/dist/core/memory-engine/scope-contract.js +18 -18
  72. package/dist/core/memory-engine/sync-client.js +26 -6
  73. package/dist/core/memory-engine/sync.d.ts +20 -2
  74. package/dist/core/memory-engine/sync.js +18 -17
  75. package/dist/core/mode-policy.d.ts +21 -6
  76. package/dist/core/mode-policy.js +15 -6
  77. package/dist/core/own-property-receipt.js +11 -4
  78. package/dist/core/parent-spec-seat.d.ts +13 -11
  79. package/dist/core/parent-spec-seat.js +13 -9
  80. package/dist/core/peer-seat.js +3 -3
  81. package/dist/core/peer-task-store.d.ts +365 -0
  82. package/dist/core/peer-task-store.js +682 -0
  83. package/dist/core/permission-rule-consent.js +6 -11
  84. package/dist/core/permission-rule-model.d.ts +27 -0
  85. package/dist/core/permission-rule-model.js +33 -5
  86. package/dist/core/permission-rule-provider.d.ts +35 -33
  87. package/dist/core/permission-rule-provider.js +38 -295
  88. package/dist/core/permission-rule-store.d.ts +181 -8
  89. package/dist/core/permission-rule-store.js +420 -17
  90. package/dist/core/permission-rule-sync.js +15 -1
  91. package/dist/core/project-seat.d.ts +55 -0
  92. package/dist/core/project-seat.js +96 -0
  93. package/dist/core/protocol-http-auth.d.ts +3 -2
  94. package/dist/core/protocol-http-auth.js +26 -18
  95. package/dist/core/remote-env.d.ts +4 -4
  96. package/dist/core/retired-keys.js +1 -0
  97. package/dist/core/rule-offer-read.d.ts +1 -1
  98. package/dist/core/rule-offer-read.js +32 -4
  99. package/dist/core/run-ledger-seat.d.ts +66 -0
  100. package/dist/core/run-ledger-seat.js +70 -0
  101. package/dist/core/run-ledger.d.ts +332 -0
  102. package/dist/core/run-ledger.js +550 -0
  103. package/dist/core/runner/checkpoint-scope.d.ts +13 -3
  104. package/dist/core/runner/checkpoint-scope.js +12 -4
  105. package/dist/core/runner/construction-doors.js +6 -0
  106. package/dist/core/runner/contracts.d.ts +21 -5
  107. package/dist/core/runner/delegation-owner.d.ts +30 -0
  108. package/dist/core/runner/delegation-owner.js +20 -4
  109. package/dist/core/runner/finish-reason-seat.js +4 -2
  110. package/dist/core/runner/leg-frame.js +3 -0
  111. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  112. package/dist/core/runner/nested-memory-lane.js +91 -30
  113. package/dist/core/runner/person-path-rows.d.ts +21 -16
  114. package/dist/core/runner/person-path-rows.js +80 -15
  115. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  116. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  117. package/dist/core/runner/prepare-config-doors.js +5 -3
  118. package/dist/core/runner/prepare-context-lane.js +1 -0
  119. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  120. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  121. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  122. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  123. package/dist/core/runner/prepare-hands-readface.js +12 -1
  124. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  125. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  126. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  127. package/dist/core/runner/prepare-run-refs.js +3 -2
  128. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  129. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  130. package/dist/core/runner/prepare-task.js +36 -27
  131. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  132. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  133. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  134. package/dist/core/runner/prepare-wiring-manifest.js +5 -2
  135. package/dist/core/runner/resume-apply.js +11 -5
  136. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  137. package/dist/core/runner/resume-review-outcome.js +24 -1
  138. package/dist/core/runner/run-harness-handlers.js +3 -0
  139. package/dist/core/runner/run-identity-wiring.js +3 -2
  140. package/dist/core/runner/run-leg.js +3 -0
  141. package/dist/core/runner/run-notification-lane.js +20 -1
  142. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  143. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  144. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  145. package/dist/core/runner/runtask.d.ts +6 -2
  146. package/dist/core/runner/runtask.js +21 -9
  147. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  148. package/dist/core/runner/shell-env-withheld.js +1 -2
  149. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  150. package/dist/core/runner/stop-tail-notice.js +9 -2
  151. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  152. package/dist/core/runner/stream-settle-backstop.js +1 -0
  153. package/dist/core/runner/task-start-doors.js +6 -3
  154. package/dist/core/runner/terminal-account.d.ts +6 -1
  155. package/dist/core/runner/terminal-account.js +16 -1
  156. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  157. package/dist/core/runner-deps.d.ts +13 -10
  158. package/dist/core/secret-env.d.ts +53 -37
  159. package/dist/core/secret-env.js +44 -47
  160. package/dist/core/session-checkout.d.ts +3 -0
  161. package/dist/core/session-checkout.js +1 -0
  162. package/dist/core/session-store.d.ts +12 -6
  163. package/dist/core/session-store.js +26 -6
  164. package/dist/core/session.d.ts +31 -8
  165. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  166. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  167. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  168. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  169. package/dist/core/store-contracts/session-store-contract.js +87 -3
  170. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  171. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  172. package/dist/core/task-event.d.ts +10 -3
  173. package/dist/core/task-notification.d.ts +96 -10
  174. package/dist/core/task-notification.js +129 -5
  175. package/dist/core/task-registry-shared.d.ts +12 -1
  176. package/dist/core/task-registry-shared.js +3 -1
  177. package/dist/core/task-registry-workflow.d.ts +1 -1
  178. package/dist/core/task-registry-workflow.js +9 -1
  179. package/dist/core/task-registry.d.ts +39 -2
  180. package/dist/core/task-registry.js +76 -12
  181. package/dist/core/task-result.d.ts +13 -0
  182. package/dist/core/task-spec-members.d.ts +3 -1
  183. package/dist/core/task-spec-members.js +11 -3
  184. package/dist/core/task-spec.d.ts +48 -22
  185. package/dist/core/tool-catalog-entries.js +2 -0
  186. package/dist/core/tool-mount-facts.d.ts +1 -1
  187. package/dist/core/tool-mount-facts.js +1 -0
  188. package/dist/core/tool-mount-plan.d.ts +3 -1
  189. package/dist/core/tool-mount-plan.js +6 -0
  190. package/dist/core/tool-mount-static.d.ts +1 -1
  191. package/dist/core/tool-mount-static.js +4 -2
  192. package/dist/core/tool-result-store.d.ts +19 -2
  193. package/dist/core/tool-result-store.js +51 -2
  194. package/dist/core/tool-spec.d.ts +9 -2
  195. package/dist/core/user-attachment.d.ts +5 -1
  196. package/dist/core/user-attachment.js +14 -7
  197. package/dist/core/wiring-manifest.d.ts +26 -20
  198. package/dist/core/wiring-manifest.js +7 -3
  199. package/dist/core/workflow-journal-store.d.ts +53 -10
  200. package/dist/core/workflow-journal-store.js +27 -4
  201. package/dist/core/workflow-run-store-contract.js +16 -0
  202. package/dist/core/workflow-run-store.d.ts +9 -7
  203. package/dist/core/workflow-run-store.js +4 -1
  204. package/dist/engine/execution-env/node-execution-env.js +3 -1
  205. package/dist/engine/harness/types.d.ts +24 -1
  206. package/dist/engine/harness/types.js +10 -0
  207. package/dist/engine/llm/types.d.ts +5 -7
  208. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  209. package/dist/engine/session/import-validate.js +6 -1
  210. package/dist/engine/session/session.d.ts +15 -2
  211. package/dist/engine/session/session.js +34 -4
  212. package/dist/index.d.ts +18 -7
  213. package/dist/index.js +13 -4
  214. package/dist/orchestration/run-workflow-tool.js +40 -32
  215. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  216. package/dist/orchestration/workflow-park-adoption.js +47 -12
  217. package/dist/orchestration/workflow-stop.d.ts +128 -0
  218. package/dist/orchestration/workflow-stop.js +156 -0
  219. package/dist/orchestration/workflow.d.ts +30 -6
  220. package/dist/orchestration/workflow.js +117 -55
  221. package/dist/prompts/manager-recipe.d.ts +18 -0
  222. package/dist/prompts/manager-recipe.js +24 -0
  223. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  224. package/dist/stores/file/permission-rule-store.js +0 -1
  225. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  226. package/dist/stores/file/workflow-journal-store.js +93 -5
  227. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  228. package/dist/tools/fs/file-write-check.js +9 -3
  229. package/dist/tools/fs/index.d.ts +8 -7
  230. package/dist/tools/fs/index.js +4 -4
  231. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  232. package/dist/tools/fs/read-deny-home.js +5 -5
  233. package/dist/tools/fs/read-deny.d.ts +33 -8
  234. package/dist/tools/fs/read-deny.js +114 -25
  235. package/dist/tools/fs/safety.d.ts +4 -1
  236. package/dist/tools/fs/safety.js +4 -2
  237. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  238. package/dist/tools/fs/shell-read-check.js +96 -14
  239. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  240. package/dist/tools/fs/shell-read-establish.js +21 -11
  241. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  242. package/dist/tools/fs/shell-read-judge.js +26 -7
  243. package/dist/tools/fs/shell-read-plan.d.ts +5 -0
  244. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  245. package/package.json +2 -2
  246. package/test/export-surface.snapshot.json +131 -1
  247. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  248. package/wire-changes/answers/core@7.73.0.json +216 -0
  249. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  250. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  251. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  252. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  253. package/wire-changes/core@7.73.0.json +6480 -0
  254. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  255. package/wire-changes/primitives@7.73.0.json +227 -0
  256. package/wire-changes/wiki-gate@7.73.0.json +145 -0
@@ -17,7 +17,7 @@ import { inlineUntrusted, isMintableProbeReason } from "./untrusted-text.js";
17
17
  import { callerKey } from "./caller-text.js";
18
18
  import { valueTypeLabel } from "./tool-name-list.js";
19
19
  import { deliverEngineNotice } from "./engine-notice.js";
20
- import { entriesNotAppliedDetail } from "./entries-not-applied.js";
20
+ import { entriesNotAppliedDetail, orderEntriesBySeverity } from "./entries-not-applied.js";
21
21
  export const ALLOW_ENTRY_INERT_REASONS = Object.freeze(["wildcard_all", "namespace_wildcard", "content_unsupported", "grammar", "tool_name", "near_miss", "earlier_grammar"]);
22
22
  const INERT_REASON_WORDS = {
23
23
  wildcard_all: "a bare wildcard",
@@ -634,8 +634,8 @@ function inertEntriesListed(of) {
634
634
  export function allowedToolsNotGrantedNotices(inert, sessionId) {
635
635
  const entryOf = (e) => ({ ...e, entry: noticeRuleText(e.entry) });
636
636
  const route = sessionId !== undefined ? { sessionId } : {};
637
- const refusing = inert.filter((e) => "list" in e && e.list === "disallowed-tools");
638
- const granting = inert.filter((e) => !("list" in e && e.list === "disallowed-tools"));
637
+ const refusing = orderEntriesBySeverity(inert.filter((e) => "list" in e && e.list === "disallowed-tools"));
638
+ const granting = orderEntriesBySeverity(inert.filter((e) => !("list" in e && e.list === "disallowed-tools")));
639
639
  const notices = [];
640
640
  if (granting.length > 0) {
641
641
  notices.push({
@@ -1,3 +1,4 @@
1
+ import type { RunnerDeps } from "./runner-deps.js";
1
2
  import { type ClassifierCategory } from "./classifier-category.js";
2
3
  import type { PermissionResult, ToolCallRequest } from "./tool-policy.js";
3
4
  /**
@@ -537,15 +538,12 @@ export interface AutoModeDenialTracker {
537
538
  };
538
539
  }
539
540
  export declare function autoModeDenialLimitOf(v: unknown): Required<AutoModeDenialLimitOptions>;
540
- /** The deployment face's four value knobs, read by their one readers — every leg's prepare runs it while
541
- * `RunnerDeps.autoMode` is present, whatever mode the leg starts in, so a bad knob refuses the run before a steer or a
542
- * parent's live ceiling can reach an arming that would have refused it. */
543
- export declare function screenAutoModeKnobs(face: {
544
- readonly timeoutMs?: unknown;
545
- readonly classifierFallback?: unknown;
546
- readonly denialLimit?: unknown;
547
- readonly rateLimitBreakAfter?: unknown;
548
- }): void;
541
+ /** The ONE door for `RunnerDeps.autoMode` at both `new Runner` and prepare: receives a plain object of the ten known
542
+ * members, refuses stray or malformed members by field name (`config.invalid_argument`, or each existing knob's own
543
+ * code), and returns an isolated frozen copy. */
544
+ export declare function receiveAutoModeFace(given: unknown, subject?: string): RunnerDeps["autoMode"];
545
+ /** Screens `RunnerDeps.autoMode` through {@link receiveAutoModeFace} (the one door at construction and prepare). */
546
+ export declare function screenAutoModeKnobs(face: unknown): void;
549
547
  /** Build the per-run tracker over {@link autoModeDenialLimitOf}'s bounds (a bad knob refuses there). */
550
548
  export declare function createAutoModeDenialTracker(opts?: AutoModeDenialLimitOptions): AutoModeDenialTracker;
551
549
  /** The fallback ask's text — CC's sentence family, single-sourced for every mint site (the main gate
@@ -3,7 +3,7 @@ import { withStatusSeat } from "../brain/status-sink.js";
3
3
  import { thrownIs } from "./thrown-value.js";
4
4
  import { describeRejectedValue } from "./tool-search-setting.js";
5
5
  import { isPlainRecord } from "./mods/kernel/receive.js";
6
- import { optionKeys, receiveMembers } from "./own-property-receipt.js";
6
+ import { optionKeys, receiptRefusal, receiveMembers, refuseProxy } from "./own-property-receipt.js";
7
7
  import { callerKey } from "./caller-text.js";
8
8
  import { foreignLine } from "./protocol-http-auth.js";
9
9
  import { classifierCategoryOf, isClassifierCategory } from "./classifier-category.js";
@@ -440,14 +440,14 @@ function countsOf(fallback) {
440
440
  return { consecutive: fallback.consecutive, total: fallback.total, limit: fallback.limit };
441
441
  }
442
442
  const DENIAL_LIMIT_KEYS = optionKeys()({ maxConsecutive: 0, maxTotal: 0, autoDenyAfterMs: 0 });
443
- export function autoModeDenialLimitOf(v) {
443
+ function readDenialLimit(v) {
444
444
  const refuse = (what) => {
445
445
  const e = new Error(`RunnerDeps.autoMode.denialLimit${what}`);
446
446
  e.code = "config.auto_mode_denial_limit_invalid";
447
447
  throw e;
448
448
  };
449
449
  if (v === undefined)
450
- return { ...AUTO_MODE_DENIAL_LIMIT_DEFAULTS, autoDenyAfterMs: AUTO_MODE_DENIAL_AUTO_DENY_DEFAULT_MS };
450
+ return { resolved: { ...AUTO_MODE_DENIAL_LIMIT_DEFAULTS, autoDenyAfterMs: AUTO_MODE_DENIAL_AUTO_DENY_DEFAULT_MS }, given: undefined };
451
451
  if (typeof v !== "object" || v === null || Array.isArray(v))
452
452
  return refuse(` must be a record of bounds (got ${describeRejectedValue(v)}) — omit it for the defaults`);
453
453
  const opts = receiveMembers(v, { subject: "RunnerDeps.autoMode.denialLimit", unit: "member", moment: "when the knob is read" }, DENIAL_LIMIT_KEYS, (_, [stray]) => refuse(` has no member ${callerKey(stray)} — its members are maxConsecutive, maxTotal and autoDenyAfterMs`));
@@ -463,13 +463,119 @@ export function autoModeDenialLimitOf(v) {
463
463
  : typeof w === "number" && Number.isInteger(w) && w >= 0 && w <= MAX_TIMER_DELAY_MS
464
464
  ? w
465
465
  : refuse(`.autoDenyAfterMs must be an integer between 0 and ${MAX_TIMER_DELAY_MS} (got ${describeRejectedValue(w)}) — 0 disarms the window; omit it for the default ${AUTO_MODE_DENIAL_AUTO_DENY_DEFAULT_MS}`);
466
- return { maxConsecutive: bound("maxConsecutive", AUTO_MODE_DENIAL_LIMIT_DEFAULTS.maxConsecutive), maxTotal: bound("maxTotal", AUTO_MODE_DENIAL_LIMIT_DEFAULTS.maxTotal), autoDenyAfterMs };
466
+ const maxConsecutive = bound("maxConsecutive", AUTO_MODE_DENIAL_LIMIT_DEFAULTS.maxConsecutive);
467
+ const maxTotal = bound("maxTotal", AUTO_MODE_DENIAL_LIMIT_DEFAULTS.maxTotal);
468
+ return {
469
+ resolved: { maxConsecutive, maxTotal, autoDenyAfterMs },
470
+ given: Object.freeze({
471
+ ...(opts["maxConsecutive"] !== undefined ? { maxConsecutive } : {}),
472
+ ...(opts["maxTotal"] !== undefined ? { maxTotal } : {}),
473
+ ...(w !== undefined ? { autoDenyAfterMs } : {}),
474
+ }),
475
+ };
476
+ }
477
+ export function autoModeDenialLimitOf(v) {
478
+ return readDenialLimit(v).resolved;
479
+ }
480
+ const AUTO_MODE_FACE_KEYS = optionKeys()({
481
+ rules: 0,
482
+ settingsDenyRules: 0,
483
+ sessionContext: 0,
484
+ window: 0,
485
+ timeoutMs: 0,
486
+ classifierFallback: 0,
487
+ rateLimitBreakAfter: 0,
488
+ denialLimit: 0,
489
+ persistArming: 0,
490
+ settingsEpoch: 0,
491
+ });
492
+ const AUTO_MODE_RULES_KEYS = optionKeys()({ allow: 0, softDeny: 0, hardDeny: 0, environment: 0 });
493
+ const AUTO_MODE_WINDOW_KEYS = optionKeys()({ maxEntries: 0, maxCharsPerEntry: 0 });
494
+ function receiveStringList(v, path) {
495
+ if (v === undefined)
496
+ return undefined;
497
+ if (typeof v === "object" && v !== null)
498
+ refuseProxy(v, { subject: path, unit: "entry", moment: "when the auto-mode face is received" });
499
+ if (!Array.isArray(v))
500
+ throw receiptRefusal(`${path} must be a list of strings (got ${describeRejectedValue(v)})`);
501
+ const out = [];
502
+ for (let i = 0; i < v.length; i++) {
503
+ const held = i in v;
504
+ const item = held ? v[i] : undefined;
505
+ if (!held || typeof item !== "string") {
506
+ throw receiptRefusal(`${path}[${i}] must be a string (got ${!held ? "an empty slot" : describeRejectedValue(item)})`);
507
+ }
508
+ out.push(item);
509
+ }
510
+ return Object.freeze(out);
511
+ }
512
+ function receiveAutoModeRules(v, path) {
513
+ if (v === undefined)
514
+ return undefined;
515
+ if (typeof v !== "object" || v === null || Array.isArray(v))
516
+ throw receiptRefusal(`${path} must be a plain object of rule lists (got ${describeRejectedValue(v)})`);
517
+ const copy = receiveMembers(v, { subject: path, unit: "section", moment: "when the auto-mode face is received" }, AUTO_MODE_RULES_KEYS);
518
+ const out = {};
519
+ for (const k of AUTO_MODE_RULES_KEYS) {
520
+ const list = receiveStringList(copy[k], `${path}.${k}`);
521
+ if (list !== undefined)
522
+ out[k] = list;
523
+ }
524
+ return Object.freeze(out);
525
+ }
526
+ function receiveAutoModeWindow(v, path) {
527
+ if (v === undefined)
528
+ return undefined;
529
+ if (typeof v !== "object" || v === null || Array.isArray(v))
530
+ throw receiptRefusal(`${path} must be a plain object of window bounds (got ${describeRejectedValue(v)})`);
531
+ const copy = receiveMembers(v, { subject: path, unit: "bound", moment: "when the auto-mode face is received" }, AUTO_MODE_WINDOW_KEYS);
532
+ const out = {};
533
+ for (const k of AUTO_MODE_WINDOW_KEYS) {
534
+ const b = copy[k];
535
+ if (b === undefined)
536
+ continue;
537
+ if (typeof b !== "number" || !Number.isInteger(b) || b < 0)
538
+ throw receiptRefusal(`${path}.${k} must be a whole number >= 0 (got ${describeRejectedValue(b)})`);
539
+ out[k] = b;
540
+ }
541
+ return Object.freeze(out);
542
+ }
543
+ export function receiveAutoModeFace(given, subject = "RunnerDeps.autoMode") {
544
+ if (given === undefined)
545
+ return undefined;
546
+ if (typeof given !== "object" || given === null || Array.isArray(given)) {
547
+ throw receiptRefusal(`${subject} must be a plain object (got ${describeRejectedValue(given)}) — omit it to leave auto mode unarmed`);
548
+ }
549
+ const copy = receiveMembers(given, { subject, unit: "member", moment: "when the auto-mode face is received" }, AUTO_MODE_FACE_KEYS);
550
+ const timeoutMs = copy.timeoutMs !== undefined ? autoModeTimeoutMsOf(copy.timeoutMs) : undefined;
551
+ const classifierFallback = copy.classifierFallback !== undefined ? autoModeClassifierFallbackOf(copy.classifierFallback) : undefined;
552
+ const rateLimitBreakAfter = copy.rateLimitBreakAfter !== undefined ? autoModeRateLimitBreakAfterOf(copy.rateLimitBreakAfter) : undefined;
553
+ const denialLimit = readDenialLimit(copy.denialLimit).given;
554
+ const rules = receiveAutoModeRules(copy.rules, `${subject}.rules`);
555
+ const settingsDenyRules = receiveStringList(copy.settingsDenyRules, `${subject}.settingsDenyRules`);
556
+ const sessionContext = receiveStringList(copy.sessionContext, `${subject}.sessionContext`);
557
+ const window = receiveAutoModeWindow(copy.window, `${subject}.window`);
558
+ if (copy.persistArming !== undefined && typeof copy.persistArming !== "boolean") {
559
+ throw receiptRefusal(`${subject}.persistArming must be a boolean (got ${describeRejectedValue(copy.persistArming)}) — omit it for false`);
560
+ }
561
+ if (copy.settingsEpoch !== undefined && typeof copy.settingsEpoch !== "string") {
562
+ throw receiptRefusal(`${subject}.settingsEpoch must be a string (got ${describeRejectedValue(copy.settingsEpoch)}) — omit it when undeclared`);
563
+ }
564
+ return Object.freeze({
565
+ ...(rules !== undefined ? { rules } : {}),
566
+ ...(settingsDenyRules !== undefined ? { settingsDenyRules } : {}),
567
+ ...(sessionContext !== undefined ? { sessionContext } : {}),
568
+ ...(window !== undefined ? { window } : {}),
569
+ ...(timeoutMs !== undefined ? { timeoutMs } : {}),
570
+ ...(classifierFallback !== undefined ? { classifierFallback } : {}),
571
+ ...(rateLimitBreakAfter !== undefined ? { rateLimitBreakAfter } : {}),
572
+ ...(denialLimit !== undefined ? { denialLimit } : {}),
573
+ ...(copy.persistArming !== undefined ? { persistArming: copy.persistArming } : {}),
574
+ ...(copy.settingsEpoch !== undefined ? { settingsEpoch: copy.settingsEpoch } : {}),
575
+ });
467
576
  }
468
577
  export function screenAutoModeKnobs(face) {
469
- autoModeTimeoutMsOf(face.timeoutMs);
470
- autoModeClassifierFallbackOf(face.classifierFallback);
471
- autoModeDenialLimitOf(face.denialLimit);
472
- autoModeRateLimitBreakAfterOf(face.rateLimitBreakAfter);
578
+ void receiveAutoModeFace(face);
473
579
  }
474
580
  export function createAutoModeDenialTracker(opts) {
475
581
  const { maxConsecutive, maxTotal, autoDenyAfterMs } = autoModeDenialLimitOf(opts);
@@ -236,11 +236,12 @@ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "g
236
236
  * roster, its answer face, the approval seat's value, whether the posture's human is reachable) still refuses after the claim, each for a stated reason (INTEGRATION-CORE, "A resume's two doors").
237
237
  * The re-supplied config's one read (`readCallerSpec`, the read a run takes of its spec) refuses with its own two words, last in the set:
238
238
  * a member whose read throws (`config.spec_member_unreadable`) and a key the engine does not read (`config.spec_unknown_key`); its third,
239
- * a retired key, is `config.spec_retired_key` (first).
239
+ * a retired key, is `config.spec_retired_key` (first); the project seat it screens refuses as `config.invalid_argument` or, for an `id` that
240
+ * is no UUID, `config.project_id_invalid` (last).
240
241
  *
241
242
  * A SUBSET of {@link CONFIG_REFUSAL_CODES}, the family's whole refusal vocabulary: the words a resume's screen can produce, held to that set at compile time.
242
243
  */
243
- export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.language_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.invalid_session_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing", "config.interaction_posture", "config.agents.no_delegation_tool", "config.spec_member_unreadable", "config.spec_unknown_key", "config.agent_config_dir_invalid", "config.agent_home_dir_invalid"];
244
+ export declare const CHECKPOINT_CONFIG_REFUSAL_CODES: readonly ["config.spec_retired_key", "config.output_style_invalid", "config.language_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.invalid_session_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing", "config.interaction_posture", "config.agents.no_delegation_tool", "config.spec_member_unreadable", "config.spec_unknown_key", "config.agent_config_dir_invalid", "config.agent_home_dir_invalid", "config.project_id_invalid"];
244
245
  export type CheckpointConfigRefusalCode = (typeof CHECKPOINT_CONFIG_REFUSAL_CODES)[number];
245
246
  export declare const isCheckpointConfigRefusalCode: (word: unknown) => word is CheckpointConfigRefusalCode;
246
247
  /** 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
@@ -75,7 +75,7 @@ export const MAX_SUPPORTED_CHECKPOINT_VERSION = 10;
75
75
  export function checkpointVersionOf(cp) {
76
76
  return cp.version ?? 0;
77
77
  }
78
- export const CHECKPOINT_CONFIG_REFUSAL_CODES = Object.freeze(["config.spec_retired_key", "config.output_style_invalid", "config.language_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.invalid_session_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing", "config.interaction_posture", "config.agents.no_delegation_tool", "config.spec_member_unreadable", "config.spec_unknown_key", "config.agent_config_dir_invalid", "config.agent_home_dir_invalid"]);
78
+ export const CHECKPOINT_CONFIG_REFUSAL_CODES = Object.freeze(["config.spec_retired_key", "config.output_style_invalid", "config.language_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.invalid_session_store", "config.skill_base_dir_invalid", "config.host_floor_invalid", "config.credential_in_declaration", "config.credential_ref_invalid", "config.peer_seat_missing", "config.interaction_posture", "config.agents.no_delegation_tool", "config.spec_member_unreadable", "config.spec_unknown_key", "config.agent_config_dir_invalid", "config.agent_home_dir_invalid", "config.project_id_invalid"]);
79
79
  export const isCheckpointConfigRefusalCode = (word) => CHECKPOINT_CONFIG_REFUSAL_CODES.some((w) => w === word);
80
80
  export const CHECKPOINT_ERROR_CODES = Object.freeze([
81
81
  "checkpoint.already_exists",
@@ -20,7 +20,7 @@ import { type IdentityRekeyMap } from "./identity-rekey.js";
20
20
  */
21
21
  export declare const CHECKPOINT_IDENTITY_MEMBERS: Readonly<{
22
22
  readonly principal: readonly ["principal", "state.inheritedGate.ancestorRules[].principal"];
23
- readonly scope: readonly ["scope", "state.legScope", "durableApproval.scope"];
23
+ readonly scope: readonly ["scope", "state.legScope", "durableApproval.scope", "state.legIdentity.rootSessionScope"];
24
24
  readonly partition: readonly ["isolationScope"];
25
25
  }>;
26
26
  /**
@@ -7,7 +7,7 @@ import { isPlainRecord } from "./mods/kernel/receive.js";
7
7
  import { rekeyOwnerIdentity } from "./identity-rekey.js";
8
8
  export const CHECKPOINT_IDENTITY_MEMBERS = Object.freeze({
9
9
  principal: Object.freeze(["principal", "state.inheritedGate.ancestorRules[].principal"]),
10
- scope: Object.freeze(["scope", "state.legScope", "durableApproval.scope"]),
10
+ scope: Object.freeze(["scope", "state.legScope", "durableApproval.scope", "state.legIdentity.rootSessionScope"]),
11
11
  partition: Object.freeze(["isolationScope"]),
12
12
  });
13
13
  export const CHECKPOINT_NON_IDENTITY_MEMBERS = Object.freeze({
@@ -26,6 +26,11 @@ export const CHECKPOINT_NON_IDENTITY_MEMBERS = Object.freeze({
26
26
  "state.compositionLeg": "a composition leg's own names and host session id: ids, not an identity",
27
27
  "state.placementRootSessionId": "the placement root's session id: an id, not an identity",
28
28
  "state.rowTaskId": "the task a resumed leg runs as: an id, not an identity",
29
+ "state.legIdentity.declaredTaskId": "the task id the leg's host declared: an id, not an identity",
30
+ "state.legIdentity.parentTaskId": "the task that spawned the leg: an id, not an identity",
31
+ "state.legIdentity.rootSessionId": "a session id (the delegation tree's root): an id, not an identity",
32
+ "state.legIdentity.rootSessionIncarnation": "the occupant the tree's root session held: an id, not an identity",
33
+ "state.legIdentity.spawnName": "the leg's explicit spawn name: a name the spawning model or host chose, not an identity",
29
34
  "state.workspaceHandle": "the parked workspace's sandbox, snapshot and device ids: ids, not an identity",
30
35
  "state.handsHome": "an operating-system path: renaming a person moves no path",
31
36
  "state.inheritedGate.pathRuleAnchors": "operating-system paths the path rules anchor at: renaming a person moves no path",
@@ -7,7 +7,7 @@ import type { StoreFidelity, Checkpoint, CheckpointGate, PendingAction } from ".
7
7
  * had carried beside the one its word now names, and the members added after the table, each a capability a reader
8
8
  * must have. Downstream reads them for display only (`CheckpointError.detail.requires`).
9
9
  */
10
- export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes", "run_origin", "tool_declaration", "composition_leg", "row_task_id", "held_rows", "source_session", "tool_binding", "raw_name_identity", "isolation_scope", "from_subagent", "command_sandbox", "agent_config_dirs", "agent_home_dirs", "read_block", "persisted_rule_buckets", "constraint_layer_kinds"];
10
+ export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes", "run_origin", "tool_declaration", "composition_leg", "row_task_id", "held_rows", "source_session", "tool_binding", "raw_name_identity", "isolation_scope", "from_subagent", "command_sandbox", "agent_config_dirs", "agent_home_dirs", "read_block", "persisted_rule_buckets", "constraint_layer_kinds", "run_ledger", "leg_identity"];
11
11
  export type RequirementWord = (typeof REQUIREMENT_WORDS)[number];
12
12
  /** Runtime twin of {@link RequirementWord}. */
13
13
  export declare function isRequirementWord(word: unknown): word is RequirementWord;
@@ -327,6 +327,12 @@ export declare const CHECKPOINT_STATE_REQUIREMENTS: {
327
327
  readonly agentHomeDirs: {
328
328
  readonly word: "agent_home_dirs";
329
329
  };
330
+ readonly runLedger: {
331
+ readonly word: "run_ledger";
332
+ };
333
+ readonly legIdentity: {
334
+ readonly word: "leg_identity";
335
+ };
330
336
  };
331
337
  export declare const PENDING_ACTION_REQUIREMENTS: {
332
338
  readonly tool_approval: {
@@ -567,7 +573,11 @@ export declare const CHECKPOINT_GATE_REQUIREMENTS: {
567
573
  };
568
574
  readonly plan_review: {
569
575
  readonly kind: {
570
- readonly digest: "decision-read";
576
+ readonly word: "leg_identity";
577
+ readonly earlier: {
578
+ readonly was: "decision-read";
579
+ readonly agrees: () => true;
580
+ };
571
581
  };
572
582
  readonly reason: {
573
583
  readonly digest: "decision-read";
@@ -797,6 +807,12 @@ export declare const CHECKPOINT_REQUIREMENTS: {
797
807
  readonly agentHomeDirs: {
798
808
  readonly word: "agent_home_dirs";
799
809
  };
810
+ readonly runLedger: {
811
+ readonly word: "run_ledger";
812
+ };
813
+ readonly legIdentity: {
814
+ readonly word: "leg_identity";
815
+ };
800
816
  };
801
817
  };
802
818
  readonly resourceLedger: {
@@ -939,7 +955,11 @@ export declare const CHECKPOINT_REQUIREMENTS: {
939
955
  };
940
956
  readonly plan_review: {
941
957
  readonly kind: {
942
- readonly digest: "decision-read";
958
+ readonly word: "leg_identity";
959
+ readonly earlier: {
960
+ readonly was: "decision-read";
961
+ readonly agrees: () => true;
962
+ };
943
963
  };
944
964
  readonly reason: {
945
965
  readonly digest: "decision-read";
@@ -54,6 +54,8 @@ export const REQUIREMENT_WORDS = Object.freeze([
54
54
  "read_block",
55
55
  "persisted_rule_buckets",
56
56
  "constraint_layer_kinds",
57
+ "run_ledger",
58
+ "leg_identity",
57
59
  ]);
58
60
  export function isRequirementWord(word) {
59
61
  return typeof word === "string" && REQUIREMENT_WORDS.includes(word);
@@ -129,6 +131,8 @@ export const CHECKPOINT_STATE_REQUIREMENTS = {
129
131
  commandSandbox: { word: "command_sandbox" },
130
132
  agentConfigDirs: { word: "agent_config_dirs" },
131
133
  agentHomeDirs: { word: "agent_home_dirs" },
134
+ runLedger: { word: "run_ledger" },
135
+ legIdentity: { word: "leg_identity" },
132
136
  };
133
137
  export const PENDING_ACTION_REQUIREMENTS = {
134
138
  tool_approval: {
@@ -188,7 +192,7 @@ export const CHECKPOINT_GATE_REQUIREMENTS = {
188
192
  irreversible_ask: { kind: DECISION_READ, reason: DECISION_READ, toolName: DECISION_READ, approvalCard: DECISION_READ, safetyAxis: SHOWN, realApproval: { word: "realApproval" }, riskDescriptor: SHOWN },
189
193
  resource_limit: { kind: { word: "resource" }, reason: DECISION_READ, resumeAfterMs: DECISION_READ },
190
194
  needs_review: { kind: DECISION_READ, reason: DECISION_READ },
191
- plan_review: { kind: DECISION_READ, reason: DECISION_READ },
195
+ plan_review: { kind: { word: "leg_identity", earlier: { was: "decision-read", agrees: () => true } }, reason: DECISION_READ },
192
196
  task_done: { kind: DECISION_READ },
193
197
  };
194
198
  export const CHECKPOINT_REQUIREMENTS = {
@@ -5,6 +5,7 @@ import { validatePath } from "./effective-path-target.js";
5
5
  import { persistedReadDenyEntryProblem } from "../tools/fs/read-deny.js";
6
6
  import { readFrozenSkillGrants } from "./skill-grant.js";
7
7
  import { readFrozenSkillScopes } from "./mods/spec-seats.js";
8
+ import { readRunLedgerParked } from "./run-ledger.js";
8
9
  import { constraintChainDigestReading } from "./tool-policy.js";
9
10
  import { asResumeConfigRefusal } from "./mode-policy.js";
10
11
  import { screenRecordedRunOrigin } from "./run-origin.js";
@@ -12,7 +13,7 @@ import { refusePersistedToolNames } from "./runner/sub-agent-deny-lists.js";
12
13
  import { boundedThrownName } from "./thrown-value.js";
13
14
  import { memberPresent } from "./own-property-receipt.js";
14
15
  import { CHECKPOINT_ROW_DAMAGED_SENTENCE, checkpointRowUnreadable, rowMemberProblem } from "./checkpoint-queries.js";
15
- import { SYNC_CHILD_BLOCK_MEMBERS } from "./leg-identity.js";
16
+ import { readLegIdentityRecord, SYNC_CHILD_BLOCK_MEMBERS } from "./leg-identity.js";
16
17
  import { checkpointExecutionRecorded } from "./checkpoint-execution-record.js";
17
18
  import { readStoredPrincipal, recordedPrincipalNameOf } from "./principal-name.js";
18
19
  import { GLOBAL_USAGE_KEY } from "./usage-window-store.js";
@@ -227,6 +228,11 @@ function rowRefusalOf(cp) {
227
228
  return new CheckpointError("checkpoint.invalid_outcome", "this checkpoint carries a skill-grant section (state.skillGrants) that does not read as grant rows under this engine — a damaged section, or a row an earlier release wrote whose entry this release reads as nothing (an entry with a surrounding space, say) — refusing to resume without the grant rows and refusals it carries; the checkpoint stays pending: expire it and run the work again", { reason: "skill_grants_damaged" });
228
229
  if (readFrozenSkillScopes(cp.state.skillScopes) === undefined)
229
230
  return new CheckpointError("checkpoint.invalid_outcome", "this checkpoint carries a skill-scope section (state.skillScopes) that does not read as a list of SkillSpec names — a damaged section — refusing to resume without the active skills' hooks it records; the checkpoint stays pending: expire it and run the work again", { reason: "skill_scopes_damaged" });
231
+ const runLedgerRaw = cp.state.runLedger;
232
+ if (runLedgerRaw !== undefined && readRunLedgerParked(runLedgerRaw) === undefined)
233
+ return new CheckpointError("checkpoint.invalid_outcome", "this checkpoint's member ledger section (state.runLedger) does not read as the book an engine froze — a damaged row; the checkpoint stays pending", { reason: "requirements_damaged" });
234
+ if (readLegIdentityRecord(cp.state.legIdentity) === "damaged")
235
+ return new CheckpointError("checkpoint.invalid_outcome", "this checkpoint's leg identity section (state.legIdentity) does not read as the record an engine mints — a damaged row; the checkpoint stays pending", { reason: "requirements_damaged" });
230
236
  for (const field of ["handsRoot", "handsHome", "handsCwd"]) {
231
237
  const coordinate = cp.state[field];
232
238
  if (coordinate !== undefined && validatePath(coordinate, { intent: "validate-coordinate" }) === undefined)
@@ -670,6 +670,12 @@ export type ResumeOutcome = {
670
670
  decision: "approve" | "edit" | "reject";
671
671
  editedPlan?: string;
672
672
  reason?: string;
673
+ /** The mode the approved plan runs under — the approver's choice, on `approve` / `edit` only: any mode but `plan` (an approved
674
+ * plan is not kept open). Absent ⇒ the resume config's mode (a config of `plan` reads as none), else the mode the leg had before
675
+ * the plan. Recorded on the decided row (`ResolvedOutcome.permissionMode`), so an `env_failed` retry replays it. Refused before the
676
+ * claim (`checkpoint.invalid_outcome`, the row pending): a word outside the set, `plan`, a mode on a `reject`, or a mode the
677
+ * resume config contradicts (a config naming another mode but `plan`). */
678
+ permissionMode?: PermissionMode;
673
679
  /** Who ended this wait — the tool-approval arm's member, same shape, closed set, validation and refusals; REQUIRED.
674
680
  * `reject` is the refusal direction; `"sla_timeout"` is refused here (a plan pause expires, a sweep never resolves it). */
675
681
  hostDecision: HostDecisionFacts;
@@ -1373,8 +1379,8 @@ export interface CheckpointState {
1373
1379
  * frame — a deployment watching only that seat saw a human-approved delegation frozen at its
1374
1380
  * park-leg `"suspended"` terminal forever. Live internals still win when re-supplied (the in-engine
1375
1381
  * resume lanes all do); the checkpoint key is the fallback for the deps-only leg. Of the delegation
1376
- * axes this one, {@link fromSubagent} and the asks' display name ({@link sourceAgentName}) persist — `insideFork`, the hook identity's
1377
- * `agentName` / `spawnName` and `parentToolCallId` stay internals-only, honestly absent on a deps-only resume rather than guessed. `insideFork` needs no axis: no lane holds a fork leg's
1382
+ * axes this one, {@link fromSubagent}, the asks' display name ({@link sourceAgentName}) and the {@link legIdentity} section (the spawn name
1383
+ * among it) persist — `insideFork`, the hook identity's `agentName` and `parentToolCallId` stay internals-only, honestly absent on a deps-only resume rather than guessed. `insideFork` needs no axis: no lane holds a fork leg's
1378
1384
  * parks (`RunInternals.parkLaneHeld` is set only by a background lane that can park and an armed
1379
1385
  * workflow), so a fork leg mints no row and no resume of one exists to read the facet back. Schema ADDITION (additive, old readers ignore it —
1380
1386
  * the Q5 posture; no version movement): an older worker resuming a newer row keeps the pre-key
@@ -1500,6 +1506,18 @@ export interface CheckpointState {
1500
1506
  agentConfigDirs?: string[];
1501
1507
  /** The caller homes a task layer of the parked leg declared: a resume places the home-anchored rows there again. */
1502
1508
  agentHomeDirs?: string[];
1509
+ /** The parked leg's member ledger book (`TaskSpec.runLedger`; {@link import("./run-ledger.js").RunLedgerParked}): the members it
1510
+ * dispatched, the calls a check may cite, the accepted claims and the snapshot numbering — the leg that resumes the row continues
1511
+ * the same book. Written on every park of a leg that keeps a book; absent ⇒ the leg kept none, and a resumed leg that declares a
1512
+ * ledger starts a new one. A reader that lacks the word would resume the leg with the members dispatched before the park gone
1513
+ * from its ledger (an older engine refuses the row as newer); a section that does not read is a damaged row. */
1514
+ runLedger?: import("./run-ledger.js").RunLedgerParked;
1515
+ /** The parked leg's identity facts ({@link import("./leg-identity.js").LegIdentityRecord}: the task id its host declared, the task that
1516
+ * spawned it, its tree's root and that root's occupant, its explicit spawn name), stamped at every mint; a resume reads each one
1517
+ * the resuming call does not hand (live wins), so the resumed leg runs as the leg that parked. Absent ⇒ the leg had none of them, or
1518
+ * an earlier release minted the row (each then reads as the resume hands it). A reader that lacks the word would resume the leg
1519
+ * under the resuming call's identities (an older engine refuses the row as newer); a section that does not read is a damaged row. */
1520
+ legIdentity?: import("./leg-identity.js").LegIdentityRecord;
1503
1521
  }
1504
1522
  /**
1505
1523
  * {@link CheckpointState} with **every** field made required-PRESENT, while each value keeps its original
@@ -1622,6 +1640,10 @@ export interface ResolvedOutcome {
1622
1640
  * and bound by the replay equality on the same ADDITIVE rule as {@link reason}: absence means "never recorded". No
1623
1641
  * reader requirement word guards it: `resolvedOutcome` is a store-written state-machine member, never minted with the row. */
1624
1642
  feedback?: string;
1643
+ /** The mode an approved or edited `plan_review` exits the plan to, as the approval named it (`outcome.permissionMode`): the
1644
+ * substance of the approval, bound by the replay equality on the same ADDITIVE rule as {@link reason} (absence = never recorded:
1645
+ * a winner of a decision that named none, or one written before the member, leaves the mode unbound on a retry). */
1646
+ permissionMode?: PermissionMode;
1625
1647
  /** The settlement record core minted for this decide ({@link import("./gate-outcome.js").GateOutcome}):
1626
1648
  * the row's own copy of what the resolved call's `tool_end` frame carries, written with the winner so
1627
1649
  * an audit reading the row reads the same record the stream carried. NOT part of the replay equality
@@ -478,6 +478,7 @@ export function winnerFromOutcome(outcome) {
478
478
  decision: outcome.decision,
479
479
  ...(editedPlan !== undefined ? { updatedInput: editedPlan } : {}),
480
480
  ...(outcome.reason !== undefined ? { reason: outcome.reason } : {}),
481
+ ...(outcome.gate === "plan_review" && outcome.permissionMode !== undefined ? { permissionMode: outcome.permissionMode } : {}),
481
482
  ...(outcome.gate === "plan_review" && outcome.gateOutcome !== undefined ? { gateOutcome: outcome.gateOutcome } : {}),
482
483
  };
483
484
  }
@@ -343,6 +343,21 @@ export declare const CHILD_CLAMP_SEATS_NOT_CARRIED: Readonly<Record<string, stri
343
343
  * shape it misses leaves the real constructor invisible while a namesake answers for it.
344
344
  */
345
345
  export declare const ENGINE_CHILD_SPEC_CONSTRUCTORS: readonly ["src/agents/subagent.ts#buildChildSpec", "src/agents/subagent.ts#observerSpec", "src/agents/subagent.ts#resumeSpec", "src/agents/verify.ts#verifierSpec", "src/agents/verify.ts#fixLegSpec", "src/orchestration/workflow-primitives.ts#workflowChildClamps"];
346
+ /**
347
+ * THE leg-local narrowing of a leg's hands ({@link TaskSpec.ownHandsReadOnly}) — the one place it meets the table's
348
+ * `handsReadOnly` row. A leg that declares it reads its own hands exactly as a `handsReadOnly` leg does (every reader of
349
+ * the leg reads the one `handsReadOnly` cell, rebound here), while the clamp its children inherit stays the one it was
350
+ * handed: {@link handsReadOnlyCarried} is what the run's clamp source reads for that row. The narrowing therefore subtracts
351
+ * from this leg alone and never reaches a child — a child's hands are exactly what they would be without it.
352
+ *
353
+ * Rebound shape: `ownHandsReadOnly` is kept on the spec only while it is the SOLE reason the leg is read-only (a spec that
354
+ * was also handed the clamp drops it: the clamp already travels), so "the read-only cell here is this leg's own" is one
355
+ * reading of the rebound spec. A value other than `true` or absent is refused (a `false` would read as a loosening).
356
+ */
357
+ export declare function withOwnLegHands<S extends Pick<TaskSpec, "handsReadOnly" | "ownHandsReadOnly">>(spec: S): S;
358
+ /** The `handsReadOnly` cell a rebound spec hands its children: the spec's own cell, unless that cell is the leg-local
359
+ * narrowing ({@link withOwnLegHands}), which never travels. */
360
+ export declare function handsReadOnlyCarried(spec: Pick<TaskSpec, "handsReadOnly" | "ownHandsReadOnly">): TaskSpec["handsReadOnly"];
346
361
  /** Do these clamps leave nobody on the leg to ask — the hard-headless clamp (`interactiveTools: false`) or the declaration
347
362
  * that nobody can be asked (`approvalReach: "none"`)? The one reading {@link postureUnderClamps} and a revival's posture read. */
348
363
  export declare function clampsReachNoPerson(clamps: {
@@ -342,6 +342,21 @@ export const ENGINE_CHILD_SPEC_CONSTRUCTORS = Object.freeze([
342
342
  "src/agents/verify.ts#fixLegSpec",
343
343
  "src/orchestration/workflow-primitives.ts#workflowChildClamps",
344
344
  ]);
345
+ export function withOwnLegHands(spec) {
346
+ const own = spec.ownHandsReadOnly;
347
+ if (own === undefined)
348
+ return spec;
349
+ if (own !== true)
350
+ throw clampRecordError(`TaskSpec.ownHandsReadOnly must be true or absent (got ${describeStated(own)}) — it only narrows this leg's own hands; to keep them whole, leave it out.`);
351
+ if (spec.handsReadOnly === CLAMP_SET.handsReadOnly.value) {
352
+ const { ownHandsReadOnly: _dropped, ...rest } = spec;
353
+ return rest;
354
+ }
355
+ return { ...spec, handsReadOnly: CLAMP_SET.handsReadOnly.value };
356
+ }
357
+ export function handsReadOnlyCarried(spec) {
358
+ return spec.ownHandsReadOnly === true ? undefined : spec.handsReadOnly;
359
+ }
345
360
  export function clampsReachNoPerson(clamps) {
346
361
  return clamps.interactiveTools === false || clamps.approvalReach === "none";
347
362
  }
@@ -423,6 +423,7 @@ export declare function taskStartedFrame(run: {
423
423
  sessionId: string;
424
424
  model: string;
425
425
  identity: import("./hooks.js").HookInvocationIdentity;
426
+ startedAt: number;
426
427
  }, spawner: {
427
428
  delegationTaskType?: import("./task-event.js").DelegationTaskType;
428
429
  cycleSeq?: number;
@@ -75,7 +75,7 @@ export function taskStartedFrame(run, spawner, stamp) {
75
75
  ...(spawner?.explicitAgentName !== undefined ? { spawnName: spawner.explicitAgentName } : {}),
76
76
  ...(spawner?.spawnAgentType !== undefined ? { agentType: spawner.spawnAgentType } : {}),
77
77
  model: run.model,
78
- startedAt: Date.now(),
78
+ startedAt: run.startedAt,
79
79
  ...stamp,
80
80
  };
81
81
  }
@@ -208,7 +208,11 @@
208
208
  * nothing from elsewhere and puts everything inline. One bad entry refuses the whole Artifact mount (`config.artifact_host_invalid`,
209
209
  * the sentence naming the entry and repeating none of its url). An engine without the word ignores the member and says nothing
210
210
  * of libraries; a host that declares them gates on the word.
211
+ * - `instruction_family.preview` — `WiringManifest.instructions` carries first-load `included` (`@`-included files) and `withheld`
212
+ * (lane-discovered and host-text withholds, with `blockedAfterApproval` on `outside_its_root` when Read admission still refuses after
213
+ * approval), and `Runner.previewInstructions(spec)` returns that identical object before any turn with no model call, session/read-state
214
+ * write, checkpoint, or notice (coded refusal on invalid specs). A host that prompts for external includes before Turn 1 gates on the word.
211
215
  */
212
- export declare const ENGINE_CAPABILITIES: readonly ["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under"];
216
+ export declare const ENGINE_CAPABILITIES: readonly ["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "instruction_family.preview", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under"];
213
217
  /** One word of {@link ENGINE_CAPABILITIES}. */
214
218
  export type EngineCapability = (typeof ENGINE_CAPABILITIES)[number];
@@ -1 +1 @@
1
- export const ENGINE_CAPABILITIES = Object.freeze(["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under"]);
1
+ export const ENGINE_CAPABILITIES = Object.freeze(["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "instruction_family.preview", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under"]);