@sema-agent/core 7.58.0 → 7.59.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 (284) hide show
  1. package/CHANGELOG.md +776 -0
  2. package/README.md +6 -4
  3. package/dist/agents/cc-peer-directory.js +8 -8
  4. package/dist/agents/child-model-seat.d.ts +4 -2
  5. package/dist/agents/child-model-seat.js +5 -3
  6. package/dist/agents/peer-directory.d.ts +9 -0
  7. package/dist/agents/peer-directory.js +6 -2
  8. package/dist/agents/send-message-tool.js +21 -12
  9. package/dist/agents/subagent.js +33 -34
  10. package/dist/brain/anthropic.js +161 -45
  11. package/dist/brain/errors.d.ts +9 -3
  12. package/dist/brain/errors.js +7 -1
  13. package/dist/brain/failover.js +2 -1
  14. package/dist/brain/open-responses.js +3 -3
  15. package/dist/brain/openai.js +103 -53
  16. package/dist/brain/provider-dialect.d.ts +11 -0
  17. package/dist/brain/provider-dialect.js +5 -2
  18. package/dist/brain/reasoning-request.js +5 -4
  19. package/dist/brain/reasoning.d.ts +19 -0
  20. package/dist/brain/reasoning.js +17 -2
  21. package/dist/brain/request-route.d.ts +4 -1
  22. package/dist/brain/request-route.js +4 -1
  23. package/dist/brain/route-adjudicator.d.ts +84 -18
  24. package/dist/brain/route-adjudicator.js +87 -21
  25. package/dist/brain/route-conformance.js +1 -1
  26. package/dist/brain/stream-engine.js +84 -49
  27. package/dist/brain/stream-shared.d.ts +30 -0
  28. package/dist/brain/stream-shared.js +34 -1
  29. package/dist/brain/timeout.d.ts +62 -5
  30. package/dist/brain/timeout.js +93 -6
  31. package/dist/core/account-row.d.ts +61 -0
  32. package/dist/core/account-row.js +51 -0
  33. package/dist/core/advisor-verdict.d.ts +2 -1
  34. package/dist/core/advisor-verdict.js +1 -1
  35. package/dist/core/allow-entry.d.ts +18 -6
  36. package/dist/core/allow-entry.js +16 -8
  37. package/dist/core/approval-object.d.ts +29 -15
  38. package/dist/core/approval-object.js +47 -19
  39. package/dist/core/auto-compaction.js +1 -1
  40. package/dist/core/background-agent-store.d.ts +16 -3
  41. package/dist/core/checkpoint-requirements.d.ts +13 -1
  42. package/dist/core/checkpoint-requirements.js +3 -1
  43. package/dist/core/checkpoint-store.d.ts +58 -12
  44. package/dist/core/checkpoint-store.js +18 -6
  45. package/dist/core/child-clamp-seats.d.ts +29 -0
  46. package/dist/core/child-clamp-seats.js +56 -1
  47. package/dist/core/compliance.d.ts +2 -2
  48. package/dist/core/compliance.js +1 -1
  49. package/dist/core/effective-path-target.d.ts +8 -2
  50. package/dist/core/effective-path-target.js +8 -3
  51. package/dist/core/engine-notice.d.ts +98 -8
  52. package/dist/core/engine-notice.js +19 -5
  53. package/dist/core/gate-fold.js +1 -1
  54. package/dist/core/gate-lanes.js +8 -4
  55. package/dist/core/gate-outcome.d.ts +32 -3
  56. package/dist/core/gate-outcome.js +19 -1
  57. package/dist/core/governance-codes.d.ts +9 -1
  58. package/dist/core/governance-codes.js +13 -0
  59. package/dist/core/hooks.d.ts +31 -3
  60. package/dist/core/hooks.js +5 -6
  61. package/dist/core/image-admission.d.ts +6 -5
  62. package/dist/core/image-admission.js +18 -14
  63. package/dist/core/locked-config.d.ts +5 -2
  64. package/dist/core/locked-config.js +2 -1
  65. package/dist/core/mailbox-store.d.ts +45 -1
  66. package/dist/core/mailbox-store.js +53 -9
  67. package/dist/core/mcp-failure.d.ts +114 -18
  68. package/dist/core/mcp-failure.js +63 -5
  69. package/dist/core/mcp-server-link.d.ts +22 -1
  70. package/dist/core/mcp-server-link.js +25 -1
  71. package/dist/core/mcp.d.ts +12 -8
  72. package/dist/core/mcp.js +42 -25
  73. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  74. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  75. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  76. package/dist/core/memory-engine/consolidation.js +1 -0
  77. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  78. package/dist/core/memory-engine/distiller.js +2 -2
  79. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  80. package/dist/core/memory-engine/dual-root.js +44 -1
  81. package/dist/core/memory-engine/engine.d.ts +67 -14
  82. package/dist/core/memory-engine/engine.js +384 -212
  83. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  84. package/dist/core/memory-engine/export-bundle.js +23 -4
  85. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  86. package/dist/core/memory-engine/file-backend.js +290 -117
  87. package/dist/core/memory-engine/index.d.ts +1 -1
  88. package/dist/core/memory-engine/layout.d.ts +59 -11
  89. package/dist/core/memory-engine/layout.js +190 -40
  90. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  91. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  92. package/dist/core/memory-engine/sync-client.d.ts +9 -1
  93. package/dist/core/memory-engine/sync-client.js +31 -8
  94. package/dist/core/memory-engine/sync.d.ts +5 -0
  95. package/dist/core/memory-engine/types.d.ts +6 -0
  96. package/dist/core/mods/classic-events.d.ts +5 -1
  97. package/dist/core/mods/kernel/dispatch.js +2 -1
  98. package/dist/core/mods/kernel/events.d.ts +2 -1
  99. package/dist/core/mods/kernel/events.js +2 -2
  100. package/dist/core/mods/kernel/registration.d.ts +4 -0
  101. package/dist/core/mods/kernel/registration.js +3 -0
  102. package/dist/core/mods/stations.d.ts +31 -10
  103. package/dist/core/mods/stations.js +44 -10
  104. package/dist/core/mods/tool-call.js +1 -1
  105. package/dist/core/parent-spec-seat.d.ts +8 -3
  106. package/dist/core/parent-spec-seat.js +2 -0
  107. package/dist/core/park-selfcheck.js +6 -0
  108. package/dist/core/peer-seat.d.ts +70 -8
  109. package/dist/core/peer-seat.js +143 -11
  110. package/dist/core/permission-rule-consent.js +10 -4
  111. package/dist/core/permission-rule-model.d.ts +16 -0
  112. package/dist/core/permission-rule-model.js +1 -1
  113. package/dist/core/present-plan-tool.d.ts +11 -3
  114. package/dist/core/present-plan-tool.js +2 -2
  115. package/dist/core/resume-startup-cause.js +1 -0
  116. package/dist/core/rewrite-rejudge.d.ts +1 -0
  117. package/dist/core/rewrite-rejudge.js +2 -2
  118. package/dist/core/roles.d.ts +34 -2
  119. package/dist/core/roles.js +43 -4
  120. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  121. package/dist/core/runner/announce-once-ledger.js +4 -2
  122. package/dist/core/runner/call-hook-stations.js +2 -2
  123. package/dist/core/runner/contracts.d.ts +20 -16
  124. package/dist/core/runner/credential-origin-seat.js +4 -3
  125. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  126. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  127. package/dist/core/runner/decide-continuation.d.ts +2 -2
  128. package/dist/core/runner/gate-exit.d.ts +12 -4
  129. package/dist/core/runner/gate-exit.js +10 -7
  130. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  131. package/dist/core/runner/image-removed-seat.js +19 -0
  132. package/dist/core/runner/inline-image.js +1 -1
  133. package/dist/core/runner/memory-consolidation-driver.js +3 -3
  134. package/dist/core/runner/park-commit.d.ts +1 -1
  135. package/dist/core/runner/park-commit.js +3 -0
  136. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  137. package/dist/core/runner/prepare-ask-lane.js +2 -1
  138. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  139. package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
  140. package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
  141. package/dist/core/runner/prepare-config-doors.js +2 -0
  142. package/dist/core/runner/prepare-context-lane.js +2 -0
  143. package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
  144. package/dist/core/runner/prepare-delegation-surface.js +1 -0
  145. package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
  146. package/dist/core/runner/prepare-hands-readface.js +5 -0
  147. package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
  148. package/dist/core/runner/prepare-inherited-gate.js +14 -27
  149. package/dist/core/runner/prepare-memory.js +10 -17
  150. package/dist/core/runner/prepare-park-ask.d.ts +1 -1
  151. package/dist/core/runner/prepare-park-ask.js +2 -1
  152. package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
  153. package/dist/core/runner/prepare-policy-chain.js +16 -13
  154. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  155. package/dist/core/runner/prepare-project-context.js +2 -2
  156. package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
  157. package/dist/core/runner/prepare-prompt-inputs.js +8 -19
  158. package/dist/core/runner/prepare-protocol-tools.js +9 -1
  159. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  160. package/dist/core/runner/prepare-run-refs.js +4 -1
  161. package/dist/core/runner/prepare-task.js +4 -2
  162. package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
  163. package/dist/core/runner/prepare-wiring-manifest.js +2 -1
  164. package/dist/core/runner/reply-pricing.d.ts +30 -0
  165. package/dist/core/runner/reply-pricing.js +19 -0
  166. package/dist/core/runner/resume-admission.js +4 -2
  167. package/dist/core/runner/resume-apply.js +6 -1
  168. package/dist/core/runner/resume-policy-outcome.js +5 -5
  169. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  170. package/dist/core/runner/role-seat-defaulted.js +40 -0
  171. package/dist/core/runner/run-brain-sinks.js +2 -0
  172. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  173. package/dist/core/runner/run-identity-wiring.js +5 -4
  174. package/dist/core/runner/run-leg.d.ts +2 -0
  175. package/dist/core/runner/run-leg.js +37 -28
  176. package/dist/core/runner/run-stop-and-final-verify.js +2 -2
  177. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  178. package/dist/core/runner/run-terminal-adoption.js +9 -3
  179. package/dist/core/runner/run-turn-boundary.js +77 -70
  180. package/dist/core/runner/runtask.d.ts +1 -1
  181. package/dist/core/runner/runtask.js +2 -2
  182. package/dist/core/runner/side-call-account.d.ts +1 -1
  183. package/dist/core/runner/side-call-account.js +3 -18
  184. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  185. package/dist/core/runner/sub-agent-deny-lists.js +10 -0
  186. package/dist/core/runner/tool-end-body.js +2 -2
  187. package/dist/core/runner/tool-occurrence.d.ts +1 -1
  188. package/dist/core/runner/tool-occurrence.js +2 -2
  189. package/dist/core/runner/turn-attachments.d.ts +26 -22
  190. package/dist/core/runner/turn-attachments.js +24 -26
  191. package/dist/core/runner-deps.d.ts +1 -1
  192. package/dist/core/secret-env.d.ts +32 -2
  193. package/dist/core/secret-env.js +65 -3
  194. package/dist/core/sensitive-path-policy.js +3 -3
  195. package/dist/core/session-policy-store.d.ts +3 -1
  196. package/dist/core/session-policy-store.js +13 -9
  197. package/dist/core/session-store.d.ts +2 -5
  198. package/dist/core/side-query.d.ts +11 -1
  199. package/dist/core/side-query.js +9 -0
  200. package/dist/core/skill-grant-binding.d.ts +31 -2
  201. package/dist/core/skill-grant-binding.js +31 -1
  202. package/dist/core/skill-grant.d.ts +8 -5
  203. package/dist/core/skill-grant.js +6 -6
  204. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  205. package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
  206. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  207. package/dist/core/synthetic-read-verdict.js +2 -1
  208. package/dist/core/task-event.d.ts +32 -8
  209. package/dist/core/task-notification.js +16 -10
  210. package/dist/core/task-registry-agent.js +1 -0
  211. package/dist/core/task-registry-shared.d.ts +5 -0
  212. package/dist/core/task-spec.d.ts +12 -1
  213. package/dist/core/terminal-cause.d.ts +10 -0
  214. package/dist/core/tool-check-reading.d.ts +1 -0
  215. package/dist/core/tool-check-reading.js +3 -3
  216. package/dist/core/tool-policy.d.ts +16 -0
  217. package/dist/core/tool-roster.d.ts +112 -5
  218. package/dist/core/tool-roster.js +42 -1
  219. package/dist/core/tool-spec.d.ts +3 -1
  220. package/dist/core/types.d.ts +2 -2
  221. package/dist/core/types.js +1 -1
  222. package/dist/core/user-attachment.js +1 -1
  223. package/dist/core/wiring-manifest.d.ts +6 -3
  224. package/dist/engine/compaction/compaction.js +29 -3
  225. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  226. package/dist/engine/execution-env/node-execution-env.js +9 -12
  227. package/dist/engine/harness/agent-harness.d.ts +25 -2
  228. package/dist/engine/harness/agent-harness.js +41 -12
  229. package/dist/engine/harness/messages.d.ts +3 -1
  230. package/dist/engine/harness/messages.js +3 -2
  231. package/dist/engine/harness/types.d.ts +8 -0
  232. package/dist/engine/llm/rejected-images.d.ts +46 -0
  233. package/dist/engine/llm/rejected-images.js +54 -0
  234. package/dist/engine/llm/tool-turns.d.ts +2 -1
  235. package/dist/engine/llm/types.d.ts +18 -7
  236. package/dist/engine/loop/agent-loop.d.ts +8 -0
  237. package/dist/engine/loop/agent-loop.js +52 -15
  238. package/dist/engine/loop/types.d.ts +3 -1
  239. package/dist/engine/session/path-to-root.d.ts +38 -0
  240. package/dist/engine/session/path-to-root.js +39 -0
  241. package/dist/engine/session/storage-base.js +4 -21
  242. package/dist/index.d.ts +16 -10
  243. package/dist/index.js +11 -7
  244. package/dist/internal/harness-types.d.ts +1 -1
  245. package/dist/internal/harness.d.ts +1 -0
  246. package/dist/internal/llm.d.ts +1 -0
  247. package/dist/orchestration/workflow-observe.d.ts +17 -1
  248. package/dist/orchestration/workflow-observe.js +20 -0
  249. package/dist/orchestration/workflow-types.d.ts +32 -7
  250. package/dist/orchestration/workflow.js +739 -489
  251. package/dist/shell/counting-pass.d.ts +50 -0
  252. package/dist/shell/counting-pass.js +502 -0
  253. package/dist/shell/lex.d.ts +4 -2
  254. package/dist/shell/lex.js +93 -34
  255. package/dist/shell/shell-words.d.ts +1 -1
  256. package/dist/shell/shell-words.js +7 -6
  257. package/dist/stores/file/mailbox-store.js +6 -10
  258. package/dist/tools/fs/fs-bash.d.ts +6 -0
  259. package/dist/tools/fs/fs-bash.js +6 -3
  260. package/dist/tools/fs/index.js +6 -2
  261. package/dist/tools/fs/program-read-model.d.ts +13 -0
  262. package/dist/tools/fs/program-read-model.js +15 -0
  263. package/dist/tools/fs/program-read-model.rows.js +1 -1
  264. package/dist/tools/fs/read-deny.d.ts +13 -10
  265. package/dist/tools/fs/read-deny.js +25 -5
  266. package/dist/tools/fs/read-floor.d.ts +19 -0
  267. package/dist/tools/fs/read-floor.js +23 -0
  268. package/dist/tools/fs/shell-read-check.d.ts +1 -1
  269. package/dist/tools/fs/shell-read-check.js +2 -1
  270. package/dist/tools/fs/shell-read-judge.d.ts +16 -8
  271. package/dist/tools/fs/shell-read-judge.js +10 -6
  272. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  273. package/dist/tools/fs/shell-read-plan.js +22 -15
  274. package/dist/tools/fs/shell-read-start.js +1 -0
  275. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  276. package/dist/tools/fs/shell-reentry-text.js +25 -3
  277. package/dist/tools/monitor.d.ts +4 -0
  278. package/dist/tools/monitor.js +2 -0
  279. package/package.json +3 -2
  280. package/test/export-surface.snapshot.json +87 -1
  281. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  282. package/wire-changes/core@7.59.0.json +2459 -0
  283. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  284. package/wire-changes/primitives@7.59.0.json +29 -0
@@ -1,9 +1,10 @@
1
1
  import type { PendingAction } from "./checkpoint-store.js";
2
- import type { CallTargetReading } from "./effective-path-target.js";
2
+ import { type CallTargetReading } from "./effective-path-target.js";
3
3
  import { type SkillGrantSource } from "./skill-grant.js";
4
4
  import type { ReadLanding } from "../tools/fs/shell-read-identity.js";
5
5
  import type { ToolCallPathTarget, ToolFamily, ToolHostTarget } from "./tool-face.js";
6
- import { type ToolRosterEntry } from "./tool-roster.js";
6
+ import { type RosterFaceMember, type RosterIdentityCarrier, type ToolRosterEntry } from "./tool-roster.js";
7
+ import type { AssertAllKeysHandled } from "./ask-origin.js";
7
8
  type ParkedApproval = Extract<PendingAction, {
8
9
  kind: "tool_approval";
9
10
  }>;
@@ -26,19 +27,25 @@ export type ApprovalTargets = {
26
27
  export type ApprovalTargetReads = {
27
28
  readonly [candidate: string]: string;
28
29
  };
29
- /** The tool member as the row carries it: every member optional (a row is read, never trusted to be whole). */
30
+ /** The tool member of a row, read WHOLE: the identity the roster row carried (its four members and the mount site), its face and
31
+ * its declaration's digest, as the park minted them off that row ({@link ROSTER_APPROVAL_BINDING}). The optional members are
32
+ * absent exactly when the roster row had none (no path target, no URL slot, not the engine's mount). */
30
33
  export interface ApprovalTool {
31
- readonly capabilityId?: string;
32
- readonly contractId?: string;
33
- readonly shapeDigest?: string;
34
- readonly implementationRevision?: string;
35
- readonly family?: ToolFamily;
34
+ readonly capabilityId: string;
35
+ readonly contractId: string;
36
+ readonly shapeDigest: string;
37
+ readonly implementationRevision: string;
38
+ readonly engineMounted?: true;
39
+ readonly family: ToolFamily;
36
40
  readonly pathTarget?: ToolCallPathTarget;
37
41
  readonly hostTarget?: ToolHostTarget;
42
+ readonly declarationDigest: string;
38
43
  }
39
44
  export interface ApprovalObject {
40
- /** Absent on a row minted before the identity members (all four absent): such a row binds the tool's name alone. */
41
- readonly tool?: ApprovalTool;
45
+ /** The tool member, or the members a whole one would carry that the row lacks or carries out of their shape. */
46
+ readonly tool: ApprovalTool | {
47
+ readonly missing: readonly string[];
48
+ };
42
49
  /** The row's two target members as stored — read, validated, by the judge. */
43
50
  readonly targets?: unknown;
44
51
  readonly targetReads?: unknown;
@@ -70,9 +77,9 @@ export type ApprovalDisposition = "refuse_pending" | "reopen" | "veto";
70
77
  export interface ApprovalMismatch {
71
78
  readonly member: ApprovalMember;
72
79
  readonly disposition: ApprovalDisposition;
73
- /** The machine word: the reopen codes, `resume.target_moved` on a moved face or target (the vetoed call's
74
- * `tool_end.errorCode`); absent on a grants veto. */
75
- readonly code?: "resume.tool_unavailable" | "resume.tool_contract_mismatch" | "resume.target_moved" | "checkpoint.invalid_outcome";
80
+ /** The machine word: the reopen codes, `resume.target_moved` on a moved face, declaration or target (the vetoed call's
81
+ * `tool_end.errorCode`), the claim's refusal codes; absent on a grants veto. */
82
+ readonly code?: "resume.tool_unavailable" | "resume.tool_contract_mismatch" | "resume.target_moved" | "checkpoint.invalid_outcome" | "checkpoint.unsupported_version";
76
83
  readonly message: string;
77
84
  }
78
85
  /** What the station holds of the live call. */
@@ -92,10 +99,17 @@ export interface LiveApprovalObject {
92
99
  * person approved bytes whose target the row never recorded, and the targets member is not judged. */
93
100
  readonly decided?: unknown;
94
101
  }
102
+ declare const IDENTITY_MEMBERS: readonly ["capabilityId", "contractId", "shapeDigest", "implementationRevision", "engineMounted"];
103
+ declare const FACE_MEMBERS: readonly ["family", "pathTarget", "hostTarget"];
104
+ /** The two lists the judge compares are exactly the classification's (`ROSTER_APPROVAL_BINDING`): an identity carrier or a face
105
+ * member the table adds or drops is a compile error here until the judge reads it so (a roster key moved between classes while the
106
+ * carrier set stays the same — `name` beside `capabilityId` — is not). */
107
+ export type IdentityMembersAreTheTables = AssertAllKeysHandled<Exclude<RosterIdentityCarrier, (typeof IDENTITY_MEMBERS)[number]> | Exclude<(typeof IDENTITY_MEMBERS)[number], RosterIdentityCarrier>>;
108
+ export type FaceMembersAreTheTables = AssertAllKeysHandled<Exclude<RosterFaceMember, (typeof FACE_MEMBERS)[number]> | Exclude<(typeof FACE_MEMBERS)[number], RosterFaceMember>>;
95
109
  /**
96
110
  * THE judge of a parked approval at one station: `"match"`, or the first member the table names for the station that
97
- * the live call does not match, with its disposition. Absence is read per member: a tool member with no identity
98
- * binds the name alone, and one with SOME identity members is a replacement (never a pre-identity row); a grants
111
+ * the live call does not match, with its disposition. Absence is read per member: a tool member is whole or binds no tool
112
+ * (refused before the claim, never read by name or by default); a grants
99
113
  * member is judged whenever the call would activate a skill (a row with no digest cannot cover one); a targets member
100
114
  * is judged unless the decision rewrote the bytes to ones the row's binding does not cover, and one that is not a whole
101
115
  * role → location record is damage.
@@ -1,14 +1,28 @@
1
1
  import { canonicalize } from "./canonical-json.js";
2
2
  import { licenseCovers } from "./tool-policy.js";
3
+ import { pathTargetResolutionOf } from "./effective-path-target.js";
3
4
  import { parkedSkillApprovalRefusal } from "./skill-grant.js";
4
- import { toolIdentityOf } from "./tool-roster.js";
5
+ import { engineMountedRow, toolDeclarationDigestOf, toolIdentityOf } from "./tool-roster.js";
5
6
  import { inlineUntrusted } from "./untrusted-text.js";
7
+ import { isPlainRecord } from "./mods/kernel/receive.js";
6
8
  export const APPROVAL_TARGET_ROLES = Object.freeze(["protective", "declared"]);
9
+ const ALWAYS_MINTED = Object.freeze(["capabilityId", "contractId", "shapeDigest", "implementationRevision", "family", "declarationDigest"]);
10
+ const isString = (v) => typeof v === "string";
11
+ const absentOr = (shape) => (v) => v === undefined || shape(v);
12
+ const isSlot = (v) => isPlainRecord(v) && typeof v["param"] === "string";
13
+ const TOOL_MEMBER_SHAPES = Object.freeze({
14
+ capabilityId: isString, contractId: isString, shapeDigest: isString, implementationRevision: isString, family: isString, declarationDigest: isString,
15
+ engineMounted: absentOr((v) => v === true), pathTarget: absentOr(isSlot), hostTarget: absentOr(isSlot),
16
+ });
17
+ const unreadToolMembers = (row) => Object.keys(TOOL_MEMBER_SHAPES).filter((k) => !TOOL_MEMBER_SHAPES[k](row[k]));
18
+ const wholeTool = (row) => unreadToolMembers(row).length === 0;
7
19
  export function approvalObjectOf(row) {
8
- const { capabilityId, contractId, shapeDigest, implementationRevision, family, pathTarget, hostTarget, targets, targetReads, boundGrantDigest } = row;
9
- const carried = [capabilityId, contractId, shapeDigest, implementationRevision].some((m) => m !== undefined);
20
+ const { targets, targetReads, boundGrantDigest } = row;
21
+ const tool = wholeTool(row)
22
+ ? { capabilityId: row.capabilityId, contractId: row.contractId, shapeDigest: row.shapeDigest, implementationRevision: row.implementationRevision, ...(row.engineMounted === true ? { engineMounted: true } : {}), family: row.family, ...(row.pathTarget !== undefined ? { pathTarget: row.pathTarget } : {}), ...(row.hostTarget !== undefined ? { hostTarget: row.hostTarget } : {}), declarationDigest: row.declarationDigest }
23
+ : { missing: unreadToolMembers(row) };
10
24
  return {
11
- ...(carried ? { tool: { capabilityId, contractId, shapeDigest, implementationRevision, family, pathTarget, hostTarget } } : {}),
25
+ tool,
12
26
  ...(targets !== undefined ? { targets } : {}),
13
27
  ...(targetReads !== undefined ? { targetReads } : {}),
14
28
  ...(boundGrantDigest !== undefined ? { grants: boundGrantDigest } : {}),
@@ -24,33 +38,47 @@ export function approvalTargetsOf(reading, reads) {
24
38
  return { ...(Object.keys(targets).length > 0 ? { targets } : {}), ...(reads !== undefined ? { targetReads: Object.fromEntries(reads.map((r) => [r.key, r.landing])) } : {}) };
25
39
  }
26
40
  export const APPROVAL_STATION_MEMBERS = Object.freeze({
27
- claim: Object.freeze(["grants"]),
41
+ claim: Object.freeze(["tool", "grants"]),
28
42
  session: Object.freeze(["tool"]),
29
43
  execution: Object.freeze(["tool", "grants", "targets"]),
30
44
  });
31
- const IDENTITY_MEMBERS = Object.freeze(["capabilityId", "contractId", "shapeDigest", "implementationRevision"]);
45
+ const IDENTITY_MEMBERS = Object.freeze(["capabilityId", "contractId", "shapeDigest", "implementationRevision", "engineMounted"]);
46
+ const FACE_MEMBERS = Object.freeze(["family", "pathTarget", "hostTarget"]);
32
47
  const shown = (s) => `"${inlineUntrusted(s, 240)}"`;
33
48
  const vetoed = (name, why) => `The approved tool call "${name}" was not executed: ${why}, so the approval does not cover it (resume.target_moved). This approval is spent — the call has to be re-issued: its new card shows what it would act on now.`;
34
- function faceKey(family, pt, ht) {
35
- const slot = pt === undefined ? null : { param: pt.param, access: pt.access, aliases: [...(pt.aliases ?? [])], base: pt.base ?? "cwd", absent: pt.absent ?? "none", patternParam: pt.patternParam ?? null, skillScopeEligible: pt.skillScopeEligible === true };
36
- return canonicalize({ family: family ?? null, pathTarget: slot, hostTarget: ht === undefined ? null : { param: ht.param } });
49
+ function faceKey(face) {
50
+ const resolved = (k) => {
51
+ const pt = face.pathTarget;
52
+ if (k !== "pathTarget")
53
+ return face[k] ?? null;
54
+ return pt === undefined ? null : { param: pt.param, access: pt.access, aliases: [...(pt.aliases ?? [])], ...pathTargetResolutionOf(pt), patternParam: pt.patternParam ?? null, skillScopeEligible: pt.skillScopeEligible === true };
55
+ };
56
+ return canonicalize(Object.fromEntries(FACE_MEMBERS.map((k) => [k, resolved(k)])));
37
57
  }
38
- function judgeTool(row, live) {
58
+ function judgeTool(row, live, station) {
59
+ const bound = approvalObjectOf(row).tool;
60
+ if ("missing" in bound) {
61
+ const why = `carries no whole record of the tool it was asked for (${bound.missing.join(", ")} missing or not in its shape — a row parked by an engine before it recorded them, a call parked while its tool was off the leg's roster, or a damaged row), so which tool the approval covers cannot be read`;
62
+ if (station !== "claim")
63
+ return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, `its checkpoint row ${why}`) };
64
+ return { member: "tool", disposition: "refuse_pending", code: "checkpoint.unsupported_version", message: `this checkpoint's pending approval ${why}, and it is not redeemed; the checkpoint stays pending: deny it so the model can re-issue the call (a row that also predates the ask's origin is refused a deny too), finish a row an earlier engine parked on a worker of that release, or expire it` };
65
+ }
66
+ if (station === "claim")
67
+ return undefined;
39
68
  const entry = live.tool;
40
69
  if (entry === undefined)
41
70
  return { member: "tool", disposition: "reopen", code: "resume.tool_unavailable", message: `the approved tool "${row.toolName}" is no longer available on resume — refusing to continue as if it ran; the checkpoint is reopened for a retry with the tool present` };
42
- const bound = approvalObjectOf(row).tool;
43
- if (bound === undefined)
44
- return undefined;
45
- const id = toolIdentityOf(entry);
71
+ const id = { ...toolIdentityOf(entry), engineMounted: engineMountedRow(entry) ? true : undefined };
46
72
  const differ = IDENTITY_MEMBERS.filter((k) => bound[k] !== id[k]);
47
73
  if (differ.length > 0) {
48
- const named = differ.map((k) => (bound[k] === undefined ? `${k} (missing on the row)` : k)).join(", ");
49
- return { member: "tool", disposition: "reopen", code: "resume.tool_contract_mismatch", message: `the approved tool "${row.toolName}" on this leg is not the tool the approval was minted against (${named} differ) — refusing to execute a replacement wearing the name; the checkpoint is reopened for a retry with the original tool present` };
74
+ return { member: "tool", disposition: "reopen", code: "resume.tool_contract_mismatch", message: `the approved tool "${row.toolName}" on this leg is not the tool the approval was minted against (${differ.map((k) => (k === "engineMounted" ? "mount site" : k)).join(", ")} differ) — refusing to execute a replacement wearing the name; the checkpoint is reopened for a retry with the original tool present` };
75
+ }
76
+ if (faceKey(bound) !== faceKey(entry)) {
77
+ return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, "the tool's face (its display family, or the path target or URL slot it declares) changed after the approval") };
50
78
  }
51
- if (faceKey(bound.family, bound.pathTarget, bound.hostTarget) === faceKey(entry.family, entry.pathTarget, entry.hostTarget))
79
+ if (bound.declarationDigest === toolDeclarationDigestOf(entry))
52
80
  return undefined;
53
- return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, "the tool's face (its display family, or the path target or URL slot it declares) changed after the approval") };
81
+ return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, "the tool's declaration (what it does, reaches and trusts: its effect, egress, irreversibility, content origin, boundary legs, rule face or model gate) changed after the approval") };
54
82
  }
55
83
  function judgeTargets(row, live) {
56
84
  if ((row.targets === undefined && row.targetReads === undefined) || ("decided" in live && !licenseCovers(row.boundInputHash, live.decided)))
@@ -104,7 +132,7 @@ function judgeGrants(row, live, station) {
104
132
  }
105
133
  export function judgeApprovalObject(row, live, station) {
106
134
  for (const member of APPROVAL_STATION_MEMBERS[station]) {
107
- const miss = member === "tool" ? judgeTool(row, live) : member === "targets" ? judgeTargets(row, live) : judgeGrants(row, live, station === "claim" ? "claim" : "execution");
135
+ const miss = member === "tool" ? judgeTool(row, live, station) : member === "targets" ? judgeTargets(row, live) : judgeGrants(row, live, station === "claim" ? "claim" : "execution");
108
136
  if (miss !== undefined)
109
137
  return miss;
110
138
  }
@@ -470,7 +470,7 @@ export async function maybeCompact(opts) {
470
470
  const restatedEpoch = identityNow !== undefined ? selectCompactionEpoch(current, identityNow.layers, identityNow.sourceRevision) : undefined;
471
471
  const restatedListings = await opts.session.getAnnouncedListing().catch(() => undefined);
472
472
  if (opts.signal?.aborted === true) {
473
- throw Object.assign(new Error("compaction cancelled before commit — the abort signal fired during the summary call; nothing was persisted"), opts.manualCancelSignal?.aborted === true ? { [COMPACTION_MANUAL_CANCEL_FLAG]: true } : {});
473
+ throw Object.assign(new Error("compaction cancelled before commit — the abort signal fired after the summary was produced; nothing was persisted"), opts.manualCancelSignal?.aborted === true ? { [COMPACTION_MANUAL_CANCEL_FLAG]: true } : {});
474
474
  }
475
475
  await opts.session.appendCompaction(summary, firstKeptEntryId, summaryTokensBefore, {
476
476
  ...(details ?? {}),
@@ -144,6 +144,19 @@ export interface BackgroundAgentRecord {
144
144
  /** The explicit org WRITE grant that verdict carried; `null` = the org write face was read-only.
145
145
  * Same absent-reads-as-zero rule as {@link admittedOrgScopes} (absent ⇒ `null`). */
146
146
  admittedOrgWriteScope?: string | null;
147
+ /**
148
+ * The tighten-only floor the row's child was BORN under: the clamp table's projection of the spec the spawn built for it
149
+ * (`clampSeatsOf`, both carriers — the parent's clamps that rode it and the definition's own restrictions), the same shape
150
+ * as {@link import("./child-clamp-seats.js").ClampValues}. Written once, by the registration that creates the row
151
+ * (`{}` when nothing was clamped), and never rewritten: a revival builds its spec under the table's fold of THIS floor and
152
+ * the waking caller's own clamps, so whoever wakes the child can narrow it and nobody can widen it. Same reason as the
153
+ * org-admission pair above for why a policy fact rides a lookup-keys-only row: the tier-3 leg rebuilds the spec from the
154
+ * WAKER's mount, so without the row nothing of the spawning run's clamps reaches the revived cycle.
155
+ * ABSENT is not "no floor": a row that states none (written before rows carried it, or by a store that does not keep the
156
+ * member) is not revived — `readClampFloor` reads it as unreadable and both revival doors refuse
157
+ * (`revive.policy_floor_unreadable`). A store persists it verbatim: `{}` reads back as `{}`.
158
+ */
159
+ policyFloor?: import("./child-clamp-seats.js").ClampValues;
147
160
  /** Optimistic-concurrency revision. The writer always CASes with its OWN held rev (design/151
148
161
  * MED-8): a foreign row (stale leftover / another writer) has an unknown rev, so the CAS loses
149
162
  * instead of clobbering. Bumped by the store on every successful `update`. */
@@ -167,9 +180,9 @@ export interface BackgroundAgentRecord {
167
180
  *
168
181
  * Every member is optional on {@link BackgroundAgentRecord} (that is what makes them clearable);
169
182
  * identity, lifecycle, concurrency and GOVERNANCE fields are deliberately absent — a revival
170
- * inherits those. The org-admission freeze (`admittedOrgScopes` / `admittedOrgWriteScope`) is in
171
- * the governance group on purpose: clearing it would hand the next cycle a blank slate, which is
172
- * the widening the freeze exists to prevent.
183
+ * inherits those. The org-admission freeze (`admittedOrgScopes` / `admittedOrgWriteScope`) and the
184
+ * birth floor (`policyFloor`) are in the governance group on purpose: clearing either would hand the
185
+ * next cycle a blank slate, which is the widening each exists to prevent.
173
186
  */
174
187
  export declare const REVIVED_ROW_CLEARED_FIELDS: readonly ["settledAt", "stoppedBy", "completionId", "finalOutput", "finalOutputFull", "error", "errorCode", "errorRetryable", "errorKind", "errorRetryAfterMs", "resultIsPartial", "summary", "recentSteps", "editedFiles", "usage"];
175
188
  /** Erase {@link REVIVED_ROW_CLEARED_FIELDS} from a record a revival is about to write back. */
@@ -6,7 +6,7 @@ import { type StoreFidelity, type Checkpoint, type CheckpointFeature, type Check
6
6
  * had carried beside the one its word now names, and the members added after the table, each a capability a reader
7
7
  * must have. Downstream reads them for display only (`CheckpointError.detail.requires`).
8
8
  */
9
- 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"];
9
+ 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"];
10
10
  export type RequirementWord = (typeof REQUIREMENT_WORDS)[number];
11
11
  /** Runtime twin of {@link RequirementWord}. */
12
12
  export declare function isRequirementWord(word: unknown): word is RequirementWord;
@@ -332,6 +332,9 @@ export declare const PENDING_ACTION_REQUIREMENTS: {
332
332
  readonly engineMounted: {
333
333
  readonly word: "mount_site";
334
334
  };
335
+ readonly declarationDigest: {
336
+ readonly word: "tool_declaration";
337
+ };
335
338
  readonly targets: {
336
339
  readonly word: "approval_targets";
337
340
  };
@@ -365,6 +368,9 @@ export declare const PENDING_ACTION_REQUIREMENTS: {
365
368
  readonly kind: {
366
369
  readonly word: "binding";
367
370
  };
371
+ readonly requestedByCallId: {
372
+ readonly ignorable: "shown, never decided (card, listing, transcript or reported count): every read of the name renders, carries transcript or counts";
373
+ };
368
374
  };
369
375
  readonly task_done: {
370
376
  readonly kind: {
@@ -850,6 +856,9 @@ export declare const CHECKPOINT_REQUIREMENTS: {
850
856
  readonly engineMounted: {
851
857
  readonly word: "mount_site";
852
858
  };
859
+ readonly declarationDigest: {
860
+ readonly word: "tool_declaration";
861
+ };
853
862
  readonly targets: {
854
863
  readonly word: "approval_targets";
855
864
  };
@@ -883,6 +892,9 @@ export declare const CHECKPOINT_REQUIREMENTS: {
883
892
  readonly kind: {
884
893
  readonly word: "binding";
885
894
  };
895
+ readonly requestedByCallId: {
896
+ readonly ignorable: "shown, never decided (card, listing, transcript or reported count): every read of the name renders, carries transcript or counts";
897
+ };
886
898
  };
887
899
  readonly task_done: {
888
900
  readonly kind: {
@@ -37,6 +37,7 @@ export const REQUIREMENT_WORDS = Object.freeze([
37
37
  "mount_site",
38
38
  "skill_scopes",
39
39
  "run_origin",
40
+ "tool_declaration",
40
41
  ]);
41
42
  export function isRequirementWord(word) {
42
43
  return typeof word === "string" && REQUIREMENT_WORDS.includes(word);
@@ -135,6 +136,7 @@ export const PENDING_ACTION_REQUIREMENTS = {
135
136
  hostTarget: DECISION_READ,
136
137
  names: { word: "call_names" },
137
138
  engineMounted: { word: "mount_site" },
139
+ declarationDigest: { word: "tool_declaration" },
138
140
  targets: { word: "approval_targets" },
139
141
  targetReads: { word: "approval_target_reads" },
140
142
  hasBidiControls: SHOWN,
@@ -143,7 +145,7 @@ export const PENDING_ACTION_REQUIREMENTS = {
143
145
  },
144
146
  resource_limit: { kind: DECISION_READ, reason: DECISION_READ },
145
147
  review: { kind: DECISION_READ },
146
- plan_review: { kind: { word: "binding" } },
148
+ plan_review: { kind: { word: "binding" }, requestedByCallId: SHOWN },
147
149
  task_done: { kind: DECISION_READ },
148
150
  };
149
151
  export const CHECKPOINT_GATE_REQUIREMENTS = {
@@ -716,7 +716,8 @@ export type ResumeOutcome = {
716
716
  * trusted/untrusted delivery framing as {@link CheckpointState.pendingSteerQueue}). It rides the resume
717
717
  * continuation's steer tail as its OWN segment, appended AFTER any already-parked queue entry
718
718
  * (X5: both are delivered — the wake message never displaces a parked, undelivered supervisor steer;
719
- * each segment is framed under its own `trusted` semantics, never one merged trust domain). WITHOUT a
719
+ * each segment is framed under its own `trusted` semantics, never one merged trust domain). Under a held
720
+ * `inputId` it is judged by {@link judgeParkedSteerRepeat}: identical ⇒ that entry, once. WITHOUT a
720
721
  * `message`, the checkpoint must already carry a parked steer — a wake with nothing to
721
722
  * deliver is rejected (`wake.nothing_to_deliver`, anti spin-wake). Idempotency rides the existing
722
723
  * resolve CAS: a second wake of the same token loses the CAS (`checkpoint.already_resolved`). */
@@ -877,9 +878,9 @@ export type PendingAction = {
877
878
  * this action against, read off the leg's tool roster at the suspend station — `capabilityId`
878
879
  * (engine-minted over {source, peer, name, contractId}), `contractId`, `shapeDigest`,
879
880
  * `implementationRevision`. With the face below they are the TOOL member of the row's approval object
880
- * (`judgeApprovalObject`): an identity member that differs from the same-name row on the resuming leg, or is missing
881
- * while another is present, is a replacement wearing the name (`resume.tool_contract_mismatch`, a reopen); a face
882
- * that differs vetoes the call (`resume.target_moved`). All four ABSENT ⇒ a pre-identity row: the name alone is bound.
881
+ * (`judgeApprovalObject`): an identity member that differs from the same-name row on the resuming leg is a replacement
882
+ * wearing the name (`resume.tool_contract_mismatch`, a reopen); a face or declaration that differs vetoes the call
883
+ * (`resume.target_moved`). Any of them ABSENT (or the family, or the declaration digest) ⇒ the row binds no tool.
883
884
  */
884
885
  capabilityId?: string;
885
886
  contractId?: string;
@@ -890,7 +891,7 @@ export type PendingAction = {
890
891
  * display `family` + declared `pathTarget` — off the same roster row at the same mint. The pre-CAS resume-edit
891
892
  * recheck has no roster yet; it rebuilds the call face from these (`parkedCallFaceOf`) and judges the edit as
892
893
  * the live gate judged the original (merge-seam H1: without them a caller slot fell to the catalog's slot for
893
- * the NAME). Any member absent ⇒ pre-388 row ⇒ the recheck falls to the catalog, never a widened grant — including #635's resolution members, which a row written before them simply lacks (they then read as their documented defaults).
894
+ * the NAME). Read only on a whole tool member: an absent `pathTarget` (or resolution member) is then the declaration's own silence.
894
895
  */
895
896
  family?: import("./tool-face.js").ToolFamily;
896
897
  pathTarget?: import("./tool-face.js").ToolRosterPathTarget;
@@ -909,6 +910,8 @@ export type PendingAction = {
909
910
  * carries): what the identity members above cannot say (a host-mounted engine definition has the same ones). The pre-CAS
910
911
  * recheck rebuilds the face from the row (`parkedCallFaceOf`); absent ⇒ judged as an ordinary tool. Word `mount_site`. */
911
912
  engineMounted?: true;
913
+ /** The digest of the roster row's DECLARATION members (`toolDeclarationDigestOf`): a live row whose declaration differs vetoes the call (`resume.target_moved`). Word `tool_declaration`. */
914
+ declarationDigest?: string;
912
915
  /** The approval object's TARGETS (`approvalTargetsOf`): per reading of the path slot, where it resolved when the card
913
916
  * was asked; absent ⇒ not judged. A role resolving elsewhere at the execution vetoes the call (`resume.target_moved`). */
914
917
  targets?: import("./approval-object.js").ApprovalTargets;
@@ -964,9 +967,18 @@ export type PendingAction = {
964
967
  * reviews the PLAN, not a tool call — so this arm has no tool fields. Every consumer that reads the
965
968
  * `tool_approval` fields above MUST branch on `kind` FIRST: a `plan_review` checkpoint must never flow into
966
969
  * a `resource_limit`- or `tool_approval`-shaped continuation (a contract test pins this). The plan artifact
967
- * is a PROFILE concern (a REF — design/76 §9); core stores no plan here. */
970
+ * is a PROFILE concern (a REF — design/76 §9); core stores no plan here.
971
+ *
972
+ * `requestedByCallId` is the id of the tool call that ASKED for this pause (the `ExitPlanMode` call for the
973
+ * first-party plan tool): which transcript call carries the plan awaiting a decision, so a card can join the pause to
974
+ * the call that presented it instead of guessing by adjacency. It is PROVENANCE, not a binding — the pause
975
+ * still gates no call, `toolCallId` stays absent on this arm, and nothing on the resume path reads the id. Written
976
+ * once, at the park mint, from the engine-bound call id (a tool cannot name another call's id); the paused
977
+ * cause and the inbox summary echo it. ABSENT for a pause whose requester carried no call id (a revive context,
978
+ * a row a deployment minted itself, a row from an engine before this member). */
968
979
  | {
969
980
  kind: "plan_review";
981
+ requestedByCallId?: string;
970
982
  }
971
983
  /** design/144 §3 (X2) — the NON-GATE arm: nothing pends a decision. The shape of a deployment-minted
972
984
  * PARK checkpoint (approval-timeout park / pure suspend; paired with `gate.kind === "task_done"`, the
@@ -1962,6 +1974,13 @@ export interface CheckpointIndexFacts {
1962
1974
  /** Derive a row's {@link CheckpointIndexFacts}. Pure: reads no clock, writes nothing; the approval card is read
1963
1975
  * through {@link parkedApprovalCardOf} (the one card reading), the tool fields only off a `tool_approval` action. */
1964
1976
  export declare function checkpointIndexFacts(cp: Checkpoint): CheckpointIndexFacts;
1977
+ /**
1978
+ * The ONE reading of {@link PendingAction} `plan_review.requestedByCallId` — the id of the call that asked for a plan
1979
+ * pause. A non-empty string on a `plan_review` pending action; every other kind, an absent member and a damaged value
1980
+ * (a non-string, an empty string) read as `undefined`, so no consumer echoes a value the mint never wrote. The paused
1981
+ * cause and the inbox summary both read it here.
1982
+ */
1983
+ export declare function planReviewRequesterOf(pendingAction: PendingAction): string | undefined;
1965
1984
  /**
1966
1985
  * design/80 assistant-scheduler seam #1: a LIGHTWEIGHT projection of one PENDING
1967
1986
  * checkpoint, returned in bulk by {@link CheckpointStore.listByScope} so a supervisor scheduler can list a
@@ -2014,6 +2033,11 @@ export interface CheckpointSummary {
2014
2033
  * face) must not materialize the keys as `null` on the way out. Pinned in
2015
2034
  * `test/checkpoint-store.test.ts` ("tool-less park …"). */
2016
2035
  toolCallId?: string;
2036
+ /** The id of the tool call that asked for this plan pause ({@link PendingAction} `plan_review.requestedByCallId`) —
2037
+ * present ONLY on a `plan_review` row whose requester carried a call id; OMITTED on every other row (the
2038
+ * {@link toolCallId} absence-shape note applies). It names the call that PRESENTED the plan, not a call the pause
2039
+ * gates: `toolCallId` stays omitted on a plan_review row. */
2040
+ requestedByCallId?: string;
2017
2041
  /** The pending tool's name ({@link PendingAction} `tool_approval.toolName`) when this is an approval suspend.
2018
2042
  * OMITTED (not `null`) for a non-`tool_approval` pendingAction — see {@link toolCallId}'s absence-shape note. */
2019
2043
  toolName?: string;
@@ -2175,7 +2199,9 @@ export declare function summarizeCheckpoint(cp: Checkpoint, disclose?: (sentence
2175
2199
  * worker), `"env_factory_missing"` (retryable on a factory-wired worker),
2176
2200
  * `"governed_unwired"` (retryable on an org-wired worker), `"origin_missing"` (a pending approval row
2177
2201
  * minted before the ask's origin was persisted on the park — terminal for the row's bytes; the host
2178
- * decides the orphaned card itself, no worker version redeems it), `"ledger_event_unknown"` (a durable
2202
+ * decides the orphaned card itself, no worker version redeems it), `"tool_identity_missing"` (a pending approval row
2203
+ * whose tool member is not whole — parked before 7.58.0 recorded the declaration, or damaged: an allow is refused, a deny
2204
+ * settles it; a worker of the release that parked it still reads it), `"ledger_event_unknown"` (a durable
2179
2205
  * LEDGER carries an event kind this binary does not know, so the replay is refused rather than served
2180
2206
  * incomplete — the one arm that is not row-scoped: NO row in that data directory is readable here, so
2181
2207
  * the host rolls the binary forward instead of routing one token elsewhere), `"seat_retired"` (the row
@@ -2183,10 +2209,14 @@ export declare function summarizeCheckpoint(cp: Checkpoint, disclose?: (sentence
2183
2209
  * steer seat, which no worker version reads and the host decides itself, or a retired mode-seed member of
2184
2210
  * `inheritedGate`, which an engine at 7.38.x or earlier still reads once).
2185
2211
  * · `invalid_outcome` pre-CAS row-integrity arms: `"real_approval_damaged"`, `"real_approval_forged"`,
2186
- * `"read_face_damaged"`, `"read_face_forged"`, `"write_face_damaged"`, `"skill_grants_damaged"`, `"skill_scopes_damaged"`, `"constraint_chain_missing"`, `"hands_coordinates_damaged"`, `"requirements_damaged"` (all terminal for the row's
2212
+ * `"read_face_damaged"`, `"read_face_forged"`, `"write_face_damaged"`, `"skill_grants_damaged"`, `"skill_scopes_damaged"`, `"constraint_chain_missing"`, `"hands_coordinates_damaged"`, `"requirements_damaged"`, `"bound_input_hash_missing"` (all terminal for the row's
2187
2213
  * current bytes — no worker version redeems a damaged row).
2214
+ *
2215
+ * THE ONE RULE for `checkpoint.invalid_outcome` (registered in `docs/CLOSED-SETS.md`, which also says what a host reads from it): `detail.reason` is a
2216
+ * ROW-INTEGRITY word and only that, `detail.field` ({@link CheckpointErrorField}) names the cell of the decision to act on, a refusal carries at most
2217
+ * one of them, and a refusal with neither is never a damaged row.
2188
2218
  */
2189
- export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "governed_unwired" | "origin_missing" | "ledger_event_unknown" | "seat_retired" | "real_approval_damaged" | "real_approval_forged" | "read_face_damaged" | "read_face_forged"
2219
+ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "governed_unwired" | "origin_missing" | "tool_identity_missing" | "ledger_event_unknown" | "seat_retired" | "real_approval_damaged" | "real_approval_forged" | "read_face_damaged" | "read_face_forged"
2190
2220
  /** `state.writeFace` is present but not a well-formed section. No `_forged` twin: the section is
2191
2221
  * legal-and-absent at every version, so there is no version to judge a fabrication against — and a
2192
2222
  * fabricated "open" still needs the LIVE resolution to say open too. */
@@ -2199,6 +2229,10 @@ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "g
2199
2229
  * is present below v10, or does not equal the words the row's content carries (a segment dropped, or a word not
2200
2230
  * declared) — terminal for the row's bytes. */
2201
2231
  | "requirements_damaged"
2232
+ /** A pending tool approval whose row format is at or above the binding era carries no persisted `boundInputHash` — every mint at that
2233
+ * version writes one, so its absence is corruption or a caller-declared downgrade, and the decision-action input binding has nothing to
2234
+ * bind to. Terminal for the row's bytes (a pre-binding row, which never minted a hash, binds on `boundCallId` alone and is not this). */
2235
+ | "bound_input_hash_missing"
2202
2236
  /** On `resume.parent_constraint_mismatch`: a re-supplied chain entry whose path rules depend on the leg that installed it has
2203
2237
  * no installation record (a chain written before the record existed) / a record that does not cover the chain entry for
2204
2238
  * entry / a record member naming no absolute root. */
@@ -2237,7 +2271,7 @@ export type CheckpointConfigRefusalCode = (typeof CHECKPOINT_CONFIG_REFUSAL_CODE
2237
2271
  export declare const isCheckpointConfigRefusalCode: (word: unknown) => word is CheckpointConfigRefusalCode;
2238
2272
  /** 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
2239
2273
  * `docs/CLOSED-SETS.md`: a consumer holding a table over it is tsc-red on a new word until it places the word. */
2240
- export type CheckpointErrorField = "boundCallId" | "boundInputHash" | "boundGrantDigest" | "answer" | "hostDecision" | "approver" | "feedback" | "taskConfig" | "deps" | "inheritedGate";
2274
+ export type CheckpointErrorField = "boundCallId" | "boundInputHash" | "boundGrantDigest" | "answer" | "hostDecision" | "approver" | "feedback" | "outcome" | "updatedInput" | "decision" | "reason" | "taskConfig" | "deps" | "inheritedGate";
2241
2275
  /** A typed checkpoint-store error so callers branch on `code` (mirrors `SessionError`). */
2242
2276
  export declare class CheckpointError extends Error {
2243
2277
  readonly code: "checkpoint.already_exists" | "checkpoint.already_resolved" | "checkpoint.not_found"
@@ -2420,7 +2454,10 @@ export declare class CheckpointError extends Error {
2420
2454
  * resolve, or try to supply the minted record), or — design/252 G-7 — `"approver"` (the attribution is not a
2421
2455
  * well-formed identifier: re-decide with a plain, bounded, control-character-free string, or omit
2422
2456
  * it), or `"feedback"` (the allow's `feedback` is not fit to deliver — it carries the engine's `<system-reminder>` tag, is not a string, rides a deny,
2423
- * or rides a decide a machine made: re-decide with the words changed or dropped; the binding did not change). On a `checkpoint.config_refused` `field` names which INPUT carries the refusal — `"taskConfig"`
2457
+ * or rides a decide a machine made: re-decide with the words changed or dropped; the binding did not change), or — an approval decide's own
2458
+ * payload — `"outcome"` (the resume's outcome is not an object naming its gate: send one), `"updatedInput"` (the person's edit is not plain JSON data the
2459
+ * engine can capture: re-decide with a plain edit, or without one), `"decision"` (the verdict word is neither `allow` nor `deny`) or `"reason"` (the deny's
2460
+ * words are not a plain string, or carry the engine's `<system-reminder>` tag: change or drop them; the binding did not change). On a `checkpoint.config_refused` `field` names which INPUT carries the refusal — `"taskConfig"`
2424
2461
  * (the re-supplied config: correct it and resume the same token), `"deps"` (the deployment's own seat — and the policies the
2425
2462
  * caller re-supplies as inherited constraints: correct them and resume the same token) or `"inheritedGate"` (the row's record: no config reaches it; expire the row). The throw
2426
2463
  * sites always knew which arm fired; this carries that fact instead of dropping it (ruled
@@ -2633,7 +2670,10 @@ export declare class CheckpointError extends Error {
2633
2670
  * resolve, or try to supply the minted record), or — design/252 G-7 — `"approver"` (the attribution is not a
2634
2671
  * well-formed identifier: re-decide with a plain, bounded, control-character-free string, or omit
2635
2672
  * it), or `"feedback"` (the allow's `feedback` is not fit to deliver — it carries the engine's `<system-reminder>` tag, is not a string, rides a deny,
2636
- * or rides a decide a machine made: re-decide with the words changed or dropped; the binding did not change). On a `checkpoint.config_refused` `field` names which INPUT carries the refusal — `"taskConfig"`
2673
+ * or rides a decide a machine made: re-decide with the words changed or dropped; the binding did not change), or — an approval decide's own
2674
+ * payload — `"outcome"` (the resume's outcome is not an object naming its gate: send one), `"updatedInput"` (the person's edit is not plain JSON data the
2675
+ * engine can capture: re-decide with a plain edit, or without one), `"decision"` (the verdict word is neither `allow` nor `deny`) or `"reason"` (the deny's
2676
+ * words are not a plain string, or carry the engine's `<system-reminder>` tag: change or drop them; the binding did not change). On a `checkpoint.config_refused` `field` names which INPUT carries the refusal — `"taskConfig"`
2637
2677
  * (the re-supplied config: correct it and resume the same token), `"deps"` (the deployment's own seat — and the policies the
2638
2678
  * caller re-supplies as inherited constraints: correct them and resume the same token) or `"inheritedGate"` (the row's record: no config reaches it; expire the row). The throw
2639
2679
  * sites always knew which arm fired; this carries that fact instead of dropping it (ruled
@@ -3139,6 +3179,12 @@ export declare const ACTOR_ASSERTION_FROZEN_FIELDS: readonly ["id", "hostAsserte
3139
3179
  * on its own surface and parks it again through `setPendingSteer` if it still applies.
3140
3180
  */
3141
3181
  export declare function readPendingSteerQueue(state: Pick<CheckpointState, "pendingSteerQueue">): PendingSteerEntry[];
3182
+ /**
3183
+ * The parked queue's ONE identity judgment (the append below and the wake entrance read it): the held entry
3184
+ * when `entry` repeats it identically (the replay), `undefined` for a new `inputId`, else
3185
+ * `steering.duplicate_input_id` naming the facets that differ — the key alone is no proof of a replay.
3186
+ */
3187
+ export declare function judgeParkedSteerRepeat(queue: readonly PendingSteerEntry[], entry: Omit<PendingSteerEntry, "seq">): PendingSteerEntry | undefined;
3142
3188
  /**
3143
3189
  * design/171 §5.3/§6.3 — THE append, shared by every backend so the bounds and the ordering are one
3144
3190
  * implementation rather than one per store.
@@ -275,6 +275,12 @@ export function checkpointIndexFacts(cp) {
275
275
  hasBidiControls: tool?.hasBidiControls === true ? true : null,
276
276
  };
277
277
  }
278
+ export function planReviewRequesterOf(pendingAction) {
279
+ if (pendingAction.kind !== "plan_review")
280
+ return undefined;
281
+ const id = pendingAction.requestedByCallId;
282
+ return typeof id === "string" && id !== "" ? id : undefined;
283
+ }
278
284
  export function summarizeCheckpoint(cp, disclose) {
279
285
  const facts = checkpointIndexFacts(cp);
280
286
  const descriptor = facts.riskDescriptor;
@@ -285,6 +291,7 @@ export function summarizeCheckpoint(cp, disclose) {
285
291
  }
286
292
  const cardReading = parkedApprovalCardOf(cp.gate);
287
293
  const tool = cp.pendingAction.kind === "tool_approval" ? cp.pendingAction : undefined;
294
+ const requestedByCallId = planReviewRequesterOf(cp.pendingAction);
288
295
  let toolInput;
289
296
  if (tool !== undefined) {
290
297
  try {
@@ -313,6 +320,7 @@ export function summarizeCheckpoint(cp, disclose) {
313
320
  ...(cp.sourceTaskId !== undefined ? { sourceTaskId: cp.sourceTaskId } : {}),
314
321
  ...(cp.principal !== undefined ? { principal: cp.principal } : {}),
315
322
  ...(facts.toolCallId !== null ? { toolCallId: facts.toolCallId } : {}),
323
+ ...(requestedByCallId !== undefined ? { requestedByCallId } : {}),
316
324
  ...(facts.toolName !== null ? { toolName: facts.toolName } : {}),
317
325
  ...(cardReading.kind === "card" ? { approvalCard: cardReading.card } : {}),
318
326
  ...(toolInput !== undefined ? { toolInput } : {}),
@@ -536,15 +544,19 @@ export function readPendingSteerQueue(state) {
536
544
  }
537
545
  return [...(state.pendingSteerQueue ?? [])].sort((a, b) => a.seq - b.seq);
538
546
  }
547
+ export function judgeParkedSteerRepeat(queue, entry) {
548
+ const collision = queue.find((e) => e.inputId === entry.inputId);
549
+ if (collision === undefined)
550
+ return undefined;
551
+ const refusal = steerReplayRefusal(collision, entry, { seat: "parked", inputId: entry.inputId });
552
+ if (refusal !== undefined)
553
+ throw new CheckpointError("steering.duplicate_input_id", refusal.message, refusal.detail);
554
+ return collision;
555
+ }
539
556
  export function appendPendingSteer(state, entry) {
540
557
  const current = readPendingSteerQueue(state);
541
- const collision = current.find((e) => e.inputId === entry.inputId);
542
- if (collision !== undefined) {
543
- const refusal = steerReplayRefusal(collision, entry, { seat: "parked", inputId: entry.inputId });
544
- if (refusal !== undefined)
545
- throw new CheckpointError("steering.duplicate_input_id", refusal.message, refusal.detail);
558
+ if (judgeParkedSteerRepeat(current, entry) !== undefined)
546
559
  return current;
547
- }
548
560
  const nextSeq = current.reduce((max, e) => Math.max(max, e.seq), 0) + 1;
549
561
  const next = [...current, { ...entry, seq: nextSeq }];
550
562
  const totalEntries = next.length;
@@ -125,6 +125,12 @@ export declare const CLAMP_SET: Readonly<{
125
125
  readonly script: true;
126
126
  readonly carrier: "specSeat";
127
127
  }>;
128
+ classifyAllShell: Readonly<{
129
+ readonly law: "restricting";
130
+ readonly value: true;
131
+ readonly script: true;
132
+ readonly carrier: "specSeat";
133
+ }>;
128
134
  fileHistory: Readonly<{
129
135
  readonly law: "restricting";
130
136
  readonly value: "disabled";
@@ -257,6 +263,23 @@ export declare function clampRecordError(message: string): Error & {
257
263
  * whose value is `undefined` carries nothing and is read as absent (the retired-key door's presence rule).
258
264
  */
259
265
  export declare function assertClampRecord(record: unknown, owner: string, carrier?: ClampCarrier, extra?: readonly string[]): void;
266
+ /**
267
+ * Read a STATED floor — the clamp values a durable record says its run was born under — back under the table's law, or say
268
+ * why it cannot be read. A floor is the table's own value shape ({@link ClampValues}) and nothing looser: every key a row,
269
+ * a restricting row's value exactly its restricting value (a field row: exactly `{ <field>: <value> }`), an add-only row a
270
+ * non-empty list whose every entry its row's entry law accepts. `{}` is a floor (nothing was clamped); ABSENT is not — a
271
+ * record that states no floor cannot say what a revival under it would widen, and a key this build's table does not have
272
+ * (a newer writer's row) is refused rather than ignored, because ignoring it drops a restriction.
273
+ * The floor is judged and projected from ONE plain-data copy (`structuredClone`): a value that is not plain data refuses, and
274
+ * nothing an accessor answers on a second read can differ from what was judged.
275
+ */
276
+ export declare function readClampFloor(floor: unknown): {
277
+ ok: true;
278
+ floor: ClampValues;
279
+ } | {
280
+ ok: false;
281
+ why: string;
282
+ };
260
283
  /** The restricting values of every row that ANY of `records` carries — the clamp seat a waker hands a revival. */
261
284
  export declare function clampValuesOf(...records: ReadonlyArray<object | undefined>): ClampValues;
262
285
  /**
@@ -286,6 +309,12 @@ export declare const CHILD_CLAMP_SEATS_NOT_CARRIED: Readonly<Record<string, stri
286
309
  * shape it misses leaves the real constructor invisible while a namesake answers for it.
287
310
  */
288
311
  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"];
312
+ /** Do these clamps leave nobody on the leg to ask — the hard-headless clamp (`interactiveTools: false`) or the declaration
313
+ * that nobody can be asked (`approvalReach: "none"`)? The one reading {@link postureUnderClamps} and a revival's posture read. */
314
+ export declare function clampsReachNoPerson(clamps: {
315
+ readonly interactiveTools: boolean | undefined;
316
+ readonly approvalReach: TaskSpec["approvalReach"] | undefined;
317
+ }): boolean;
289
318
  /**
290
319
  * The interaction posture a leg keeps under the clamps it inherited: `"interactive"` promises a person on the leg, and a
291
320
  * leg that inherited the hard-headless clamp (`interactiveTools: false`) or the declaration that nobody can be asked