@sema-agent/core 7.70.0 → 7.71.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 (434) hide show
  1. package/CHANGELOG.md +728 -0
  2. package/dist/agents/agent-transcript-tool.js +43 -19
  3. package/dist/agents/inherited-tool-pool.d.ts +5 -1
  4. package/dist/agents/inherited-tool-pool.js +6 -0
  5. package/dist/agents/retain-ledger.js +2 -0
  6. package/dist/agents/send-message-tool.d.ts +12 -1
  7. package/dist/agents/send-message-tool.js +47 -9
  8. package/dist/agents/subagent.js +31 -10
  9. package/dist/agents/tool-filter.js +1 -2
  10. package/dist/agents/verify.js +13 -2
  11. package/dist/agents/yield-adoption.js +11 -1
  12. package/dist/brain/claude-model-id.d.ts +11 -0
  13. package/dist/brain/claude-model-id.js +3 -1
  14. package/dist/config/catalog.js +10 -1
  15. package/dist/config/defaults.d.ts +3 -0
  16. package/dist/config/defaults.js +1 -0
  17. package/dist/core/allow-entry.js +1 -2
  18. package/dist/core/ask-origin.d.ts +55 -21
  19. package/dist/core/ask-origin.js +19 -11
  20. package/dist/core/ask-question.d.ts +4 -7
  21. package/dist/core/ask-question.js +2 -4
  22. package/dist/core/ask-unresolvable-notice.d.ts +17 -3
  23. package/dist/core/ask-unresolvable-notice.js +18 -4
  24. package/dist/core/attachment-source.d.ts +1 -1
  25. package/dist/core/attachment-source.js +2 -0
  26. package/dist/core/auto-compaction.d.ts +14 -4
  27. package/dist/core/auto-compaction.js +3 -2
  28. package/dist/core/auto-strip.js +2 -0
  29. package/dist/core/caller-text.d.ts +2 -33
  30. package/dist/core/caller-text.js +2 -23
  31. package/dist/core/caller-tool-name.js +1 -2
  32. package/dist/core/canonical-json.d.ts +9 -0
  33. package/dist/core/canonical-json.js +6 -0
  34. package/dist/core/checkpoint-features.d.ts +43 -80
  35. package/dist/core/checkpoint-features.js +10 -20
  36. package/dist/core/checkpoint-generation.d.ts +89 -19
  37. package/dist/core/checkpoint-generation.js +89 -14
  38. package/dist/core/checkpoint-queries.d.ts +95 -15
  39. package/dist/core/checkpoint-queries.js +108 -7
  40. package/dist/core/checkpoint-rekey.d.ts +2 -1
  41. package/dist/core/checkpoint-rekey.js +2 -2
  42. package/dist/core/checkpoint-requirements.d.ts +7 -6
  43. package/dist/core/checkpoint-requirements.js +2 -5
  44. package/dist/core/checkpoint-row-verdict.d.ts +3 -4
  45. package/dist/core/checkpoint-row-verdict.js +20 -41
  46. package/dist/core/checkpoint-store.d.ts +65 -41
  47. package/dist/core/checkpoint-store.js +28 -14
  48. package/dist/core/command-sandbox.d.ts +5 -3
  49. package/dist/core/command-sandbox.js +17 -9
  50. package/dist/core/config-refusal-codes.d.ts +1 -1
  51. package/dist/core/config-refusal-codes.js +1 -0
  52. package/dist/core/declaration-words.d.ts +2 -1
  53. package/dist/core/declaration-words.js +13 -2
  54. package/dist/core/effective-path-target.d.ts +23 -0
  55. package/dist/core/effective-path-target.js +15 -1
  56. package/dist/core/engine-attestation.d.ts +5 -1
  57. package/dist/core/engine-attestation.js +1 -0
  58. package/dist/core/engine-capabilities.d.ts +14 -9
  59. package/dist/core/engine-capabilities.js +1 -1
  60. package/dist/core/engine-notice.d.ts +62 -32
  61. package/dist/core/engine-version.js +1 -1
  62. package/dist/core/entries-not-applied.d.ts +1 -1
  63. package/dist/core/entries-not-applied.js +1 -0
  64. package/dist/core/file-history-store.d.ts +95 -11
  65. package/dist/core/file-history-store.js +117 -19
  66. package/dist/core/gate-fold.js +13 -7
  67. package/dist/core/gate-lanes.js +9 -9
  68. package/dist/core/governance-codes.d.ts +56 -7
  69. package/dist/core/governance-codes.js +105 -7
  70. package/dist/core/grant-holder.d.ts +53 -0
  71. package/dist/core/grant-holder.js +80 -0
  72. package/dist/core/hooks.d.ts +7 -3
  73. package/dist/core/hooks.js +2 -2
  74. package/dist/core/locked-config.d.ts +7 -1
  75. package/dist/core/locked-config.js +9 -2
  76. package/dist/core/mcp-call-meta.d.ts +52 -7
  77. package/dist/core/mcp-call-meta.js +21 -2
  78. package/dist/core/mcp-host-read.d.ts +1 -1
  79. package/dist/core/mcp-server-spec.d.ts +18 -0
  80. package/dist/core/mcp-server-spec.js +1 -0
  81. package/dist/core/mcp.js +2 -2
  82. package/dist/core/member-outcome.d.ts +22 -1
  83. package/dist/core/member-outcome.js +18 -6
  84. package/dist/core/memory-engine/delegation-settlement.js +5 -5
  85. package/dist/core/memory-engine/engine.js +19 -19
  86. package/dist/core/memory-engine/file-backend.d.ts +7 -2
  87. package/dist/core/memory-engine/file-backend.js +14 -12
  88. package/dist/core/memory-engine/frontmatter.js +1 -1
  89. package/dist/core/memory-engine/index.d.ts +1 -0
  90. package/dist/core/memory-engine/index.js +1 -0
  91. package/dist/core/memory-engine/layout.d.ts +34 -9
  92. package/dist/core/memory-engine/layout.js +36 -19
  93. package/dist/core/memory-engine/memory-deployment.js +8 -8
  94. package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
  95. package/dist/core/memory-engine/mount-failed-notice.js +5 -2
  96. package/dist/core/mode-policy.d.ts +5 -0
  97. package/dist/core/mode-policy.js +6 -0
  98. package/dist/core/mods/host.d.ts +2 -1
  99. package/dist/core/mods/host.js +7 -6
  100. package/dist/core/mods/kernel/index.d.ts +1 -1
  101. package/dist/core/mods/kernel/index.js +1 -1
  102. package/dist/core/mods/kernel/registration.d.ts +5 -2
  103. package/dist/core/mods/kernel/registration.js +19 -3
  104. package/dist/core/mods/package.d.ts +12 -1
  105. package/dist/core/mods/package.js +36 -9
  106. package/dist/core/mods/stations.d.ts +7 -1
  107. package/dist/core/mods/stations.js +17 -3
  108. package/dist/core/mods/teammate-stations.d.ts +4 -1
  109. package/dist/core/mods/teammate-stations.js +1 -1
  110. package/dist/core/native-signal.d.ts +13 -0
  111. package/dist/core/native-signal.js +18 -0
  112. package/dist/core/park-resumability.d.ts +16 -14
  113. package/dist/core/park-resumability.js +9 -4
  114. package/dist/core/path-rule-binding.js +1 -1
  115. package/dist/core/permission-rule-model.d.ts +11 -5
  116. package/dist/core/permission-rule-model.js +5 -3
  117. package/dist/core/permission-rule-org.js +1 -1
  118. package/dist/core/permission-rule-provider.d.ts +5 -1
  119. package/dist/core/permission-rule-provider.js +6 -1
  120. package/dist/core/permission-rule-session.d.ts +35 -5
  121. package/dist/core/permission-rule-session.js +32 -1
  122. package/dist/core/permission-rule-store.d.ts +5 -1
  123. package/dist/core/permission-rule-store.js +28 -5
  124. package/dist/core/permission-rules.d.ts +2 -2
  125. package/dist/core/permission-rules.js +2 -3
  126. package/dist/core/principal-name.d.ts +12 -0
  127. package/dist/core/principal-name.js +6 -2
  128. package/dist/core/read-root-grant-screen.d.ts +7 -6
  129. package/dist/core/read-root-grant-screen.js +7 -8
  130. package/dist/core/remote-env.d.ts +42 -8
  131. package/dist/core/resume-config-judge.js +1 -1
  132. package/dist/core/resume-startup-cause.d.ts +19 -4
  133. package/dist/core/resume-startup-cause.js +25 -6
  134. package/dist/core/rewind-conversation.d.ts +4 -0
  135. package/dist/core/rewrite-rejudge.d.ts +9 -1
  136. package/dist/core/rewrite-rejudge.js +11 -1
  137. package/dist/core/rule-offer-read.js +3 -2
  138. package/dist/core/runner/assemble-result.d.ts +21 -11
  139. package/dist/core/runner/assemble-result.js +24 -4
  140. package/dist/core/runner/boundary-reminders.d.ts +104 -0
  141. package/dist/core/runner/boundary-reminders.js +108 -0
  142. package/dist/core/runner/branch-writeback.d.ts +21 -7
  143. package/dist/core/runner/branch-writeback.js +44 -6
  144. package/dist/core/runner/command-sandbox-frame.js +2 -1
  145. package/dist/core/runner/compact-session.js +11 -4
  146. package/dist/core/runner/constraint-layers.d.ts +24 -5
  147. package/dist/core/runner/constraint-layers.js +21 -2
  148. package/dist/core/runner/continuation-gate.js +3 -1
  149. package/dist/core/runner/contracts.d.ts +83 -13
  150. package/dist/core/runner/cross-boundary-lane.js +2 -1
  151. package/dist/core/runner/delegation-owner.d.ts +246 -45
  152. package/dist/core/runner/delegation-owner.js +237 -63
  153. package/dist/core/runner/expire-settle.d.ts +17 -0
  154. package/dist/core/runner/expire-settle.js +8 -2
  155. package/dist/core/runner/file-history-request.d.ts +4 -3
  156. package/dist/core/runner/file-history-request.js +4 -1
  157. package/dist/core/runner/file-history-restore.d.ts +11 -3
  158. package/dist/core/runner/file-history-restore.js +11 -3
  159. package/dist/core/runner/gate-exit.d.ts +22 -1
  160. package/dist/core/runner/gate-exit.js +12 -14
  161. package/dist/core/runner/nested-memory-content.js +1 -1
  162. package/dist/core/runner/nested-memory-lane.d.ts +10 -2
  163. package/dist/core/runner/nested-memory-lane.js +29 -8
  164. package/dist/core/runner/own-model-money-door.d.ts +13 -0
  165. package/dist/core/runner/own-model-money-door.js +17 -0
  166. package/dist/core/runner/park-commit.d.ts +4 -2
  167. package/dist/core/runner/park-commit.js +2 -1
  168. package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
  169. package/dist/core/runner/permission-rule-lanes.js +7 -0
  170. package/dist/core/runner/person-path-rows.js +1 -1
  171. package/dist/core/runner/placement-fence.d.ts +8 -2
  172. package/dist/core/runner/placement-fence.js +8 -3
  173. package/dist/core/runner/policy-throw.d.ts +3 -2
  174. package/dist/core/runner/policy-throw.js +2 -2
  175. package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
  176. package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
  177. package/dist/core/runner/prepare-artifact.d.ts +14 -1
  178. package/dist/core/runner/prepare-artifact.js +7 -2
  179. package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
  180. package/dist/core/runner/prepare-ask-lane.js +14 -5
  181. package/dist/core/runner/prepare-boundary-parks.js +5 -4
  182. package/dist/core/runner/prepare-config-doors.d.ts +9 -4
  183. package/dist/core/runner/prepare-config-doors.js +25 -8
  184. package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
  185. package/dist/core/runner/prepare-defer-classify.js +6 -6
  186. package/dist/core/runner/prepare-execution-env.d.ts +4 -1
  187. package/dist/core/runner/prepare-execution-env.js +8 -3
  188. package/dist/core/runner/prepare-file-history.d.ts +26 -0
  189. package/dist/core/runner/prepare-file-history.js +15 -1
  190. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
  191. package/dist/core/runner/prepare-inherited-gate.js +9 -2
  192. package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
  193. package/dist/core/runner/prepare-park-ask.js +8 -5
  194. package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
  195. package/dist/core/runner/prepare-policy-chain.js +18 -7
  196. package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
  197. package/dist/core/runner/prepare-prompt-assembly.js +4 -3
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
  199. package/dist/core/runner/prepare-suspend-saga.js +19 -5
  200. package/dist/core/runner/prepare-task.d.ts +2 -5
  201. package/dist/core/runner/prepare-task.js +71 -26
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -5
  203. package/dist/core/runner/prepare-workspace-restore.js +59 -28
  204. package/dist/core/runner/read-root-grant.d.ts +1 -0
  205. package/dist/core/runner/read-root-grant.js +1 -2
  206. package/dist/core/runner/resume-admission.d.ts +3 -0
  207. package/dist/core/runner/resume-admission.js +6 -4
  208. package/dist/core/runner/resume-apply.js +7 -5
  209. package/dist/core/runner/resume-claim.d.ts +2 -2
  210. package/dist/core/runner/resume-claim.js +4 -4
  211. package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
  212. package/dist/core/runner/resume-policy-outcome.js +6 -4
  213. package/dist/core/runner/resume-preflight.d.ts +3 -0
  214. package/dist/core/runner/resume-preflight.js +10 -3
  215. package/dist/core/runner/rewind-conversation.js +11 -4
  216. package/dist/core/runner/rewind-files.js +29 -14
  217. package/dist/core/runner/rewind-outcome.d.ts +27 -0
  218. package/dist/core/runner/rewind-outcome.js +14 -0
  219. package/dist/core/runner/run-attachment-seats.js +2 -1
  220. package/dist/core/runner/run-clock-and-content.js +2 -0
  221. package/dist/core/runner/run-identity-wiring.js +2 -0
  222. package/dist/core/runner/run-leg.js +11 -1
  223. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  224. package/dist/core/runner/run-notification-lane.js +2 -2
  225. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
  226. package/dist/core/runner/run-settle-and-teardown.js +52 -40
  227. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  228. package/dist/core/runner/run-stop-and-final-verify.js +5 -4
  229. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  230. package/dist/core/runner/run-terminal-adoption.js +3 -3
  231. package/dist/core/runner/run-turn-boundary.js +7 -0
  232. package/dist/core/runner/runtask.d.ts +7 -4
  233. package/dist/core/runner/runtask.js +18 -9
  234. package/dist/core/runner/session-call-grant-station.d.ts +64 -0
  235. package/dist/core/runner/session-call-grant-station.js +119 -0
  236. package/dist/core/runner/session-file-state-replay.js +2 -2
  237. package/dist/core/runner/session-prompt-seats.d.ts +95 -0
  238. package/dist/core/runner/session-prompt-seats.js +62 -0
  239. package/dist/core/runner/session-rule-policy.js +1 -1
  240. package/dist/core/runner/session-write-ledger.d.ts +8 -0
  241. package/dist/core/runner/session-write-ledger.js +16 -0
  242. package/dist/core/runner/side-call-account.js +5 -1
  243. package/dist/core/runner/stop-tail-notice.d.ts +7 -0
  244. package/dist/core/runner/stop-tail-notice.js +23 -8
  245. package/dist/core/runner/stream-reap.js +4 -2
  246. package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
  247. package/dist/core/runner/stream-settle-backstop.js +17 -18
  248. package/dist/core/runner/terminal-account.js +17 -8
  249. package/dist/core/runner/terminal-projection.d.ts +3 -2
  250. package/dist/core/runner/terminal-projection.js +1 -1
  251. package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
  252. package/dist/core/runner/tool-turn-repair-seat.js +12 -7
  253. package/dist/core/runner/turn-attachments.d.ts +22 -1
  254. package/dist/core/runner/turn-attachments.js +20 -3
  255. package/dist/core/runner-deps.d.ts +6 -2
  256. package/dist/core/secret-env.d.ts +26 -6
  257. package/dist/core/secret-env.js +6 -6
  258. package/dist/core/session-call-grant-screen.d.ts +58 -0
  259. package/dist/core/session-call-grant-screen.js +18 -0
  260. package/dist/core/session-call-grant.d.ts +93 -0
  261. package/dist/core/session-call-grant.js +524 -0
  262. package/dist/core/session-checkout.d.ts +3 -0
  263. package/dist/core/session-checkout.js +8 -3
  264. package/dist/core/session-policy-store.d.ts +14 -0
  265. package/dist/core/session-policy-store.js +16 -2
  266. package/dist/core/session-store.d.ts +18 -1
  267. package/dist/core/session-store.js +20 -4
  268. package/dist/core/session.d.ts +36 -4
  269. package/dist/core/shared-artifact-reads.d.ts +93 -0
  270. package/dist/core/shared-artifact-reads.js +94 -0
  271. package/dist/core/skill-grant.js +1 -1
  272. package/dist/core/skills-directory.d.ts +9 -45
  273. package/dist/core/skills-directory.js +9 -722
  274. package/dist/core/spend-account.js +3 -0
  275. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
  276. package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
  277. package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
  278. package/dist/core/store-contracts/file-history-store-contract.js +62 -2
  279. package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
  280. package/dist/core/store-contracts/grant-fixture.js +84 -0
  281. package/dist/core/store-contracts/session-repo-contract.js +18 -0
  282. package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
  283. package/dist/core/store-contracts/session-store-contract.js +211 -2
  284. package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
  285. package/dist/core/suspend-lane-reasons.d.ts +13 -0
  286. package/dist/core/suspend-lane-reasons.js +5 -0
  287. package/dist/core/synthetic-read-verdict.d.ts +5 -3
  288. package/dist/core/synthetic-read-verdict.js +1 -1
  289. package/dist/core/task-limits.d.ts +15 -0
  290. package/dist/core/task-notification.d.ts +33 -7
  291. package/dist/core/task-notification.js +34 -9
  292. package/dist/core/task-registry-agent.d.ts +1 -1
  293. package/dist/core/task-registry-agent.js +18 -7
  294. package/dist/core/task-registry-shared.d.ts +29 -4
  295. package/dist/core/task-registry-shared.js +7 -0
  296. package/dist/core/task-registry.d.ts +21 -1
  297. package/dist/core/task-registry.js +36 -9
  298. package/dist/core/task-result.d.ts +55 -1
  299. package/dist/core/task-spec.d.ts +17 -3
  300. package/dist/core/terminal-cause.d.ts +68 -5
  301. package/dist/core/tool-catalog-entries.js +1 -1
  302. package/dist/core/tool-check-reading.js +2 -1
  303. package/dist/core/tool-errors.js +1 -0
  304. package/dist/core/tool-list-grammar.d.ts +0 -47
  305. package/dist/core/tool-list-grammar.js +1 -75
  306. package/dist/core/tool-model-gate.d.ts +7 -11
  307. package/dist/core/tool-model-gate.js +5 -8
  308. package/dist/core/tool-name-aliases.js +2 -3
  309. package/dist/core/tool-name-readings.d.ts +4 -0
  310. package/dist/core/tool-name-readings.js +1 -0
  311. package/dist/core/tool-policy.d.ts +46 -4
  312. package/dist/core/tool-policy.js +47 -18
  313. package/dist/core/tool-result-store.d.ts +0 -24
  314. package/dist/core/tool-result-store.js +1 -36
  315. package/dist/core/tool-spec.d.ts +8 -4
  316. package/dist/core/untrusted-egress.js +2 -2
  317. package/dist/core/untrusted-text.d.ts +8 -0
  318. package/dist/core/untrusted-text.js +14 -0
  319. package/dist/core/user-attachment.d.ts +16 -1
  320. package/dist/core/user-attachment.js +42 -18
  321. package/dist/core/wiring-manifest.d.ts +4 -9
  322. package/dist/core/wiring-manifest.js +1 -1
  323. package/dist/core/workflow-journal-store.d.ts +55 -8
  324. package/dist/core/workflow-journal-store.js +34 -10
  325. package/dist/core/workflow-run-store-contract.js +56 -1
  326. package/dist/core/workflow-run-store.d.ts +43 -19
  327. package/dist/core/workflow-run-store.js +17 -2
  328. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  329. package/dist/engine/execution-env/node-execution-env.js +4 -0
  330. package/dist/engine/harness/agent-harness.d.ts +10 -5
  331. package/dist/engine/harness/agent-harness.js +12 -4
  332. package/dist/engine/harness/types.d.ts +18 -0
  333. package/dist/engine/llm/tool-turns.d.ts +1 -1
  334. package/dist/engine/llm/types.d.ts +5 -4
  335. package/dist/engine/session/memory-repo.d.ts +15 -3
  336. package/dist/engine/session/memory-repo.js +21 -3
  337. package/dist/engine/session/memory-storage.d.ts +5 -0
  338. package/dist/engine/session/memory-storage.js +8 -3
  339. package/dist/engine/session/repo-utils.d.ts +9 -0
  340. package/dist/engine/session/repo-utils.js +14 -0
  341. package/dist/engine/session/storage-base.d.ts +20 -7
  342. package/dist/engine/session/storage-base.js +13 -1
  343. package/dist/index.d.ts +37 -19
  344. package/dist/index.js +30 -15
  345. package/dist/internal/harness.d.ts +1 -1
  346. package/dist/internal/harness.js +1 -1
  347. package/dist/orchestration/run-workflow-tool.d.ts +13 -1
  348. package/dist/orchestration/run-workflow-tool.js +101 -32
  349. package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
  350. package/dist/orchestration/workflow-park-adoption.js +588 -323
  351. package/dist/orchestration/workflow-tree-id.d.ts +66 -0
  352. package/dist/orchestration/workflow-tree-id.js +66 -0
  353. package/dist/orchestration/workflow-types.d.ts +90 -11
  354. package/dist/orchestration/workflow-types.js +10 -1
  355. package/dist/orchestration/workflow.d.ts +30 -4
  356. package/dist/orchestration/workflow.js +424 -114
  357. package/dist/prompt-assembly/catalog/constitution.js +5 -1
  358. package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
  359. package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
  360. package/dist/prompt-assembly/catalog/environment.js +2 -2
  361. package/dist/prompt-assembly/catalog/events.d.ts +16 -0
  362. package/dist/prompt-assembly/catalog/events.js +2 -0
  363. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
  364. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
  365. package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
  366. package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
  367. package/dist/prompt-assembly/catalog/schema.js +2 -0
  368. package/dist/prompt-assembly/catalog/sections.js +3 -14
  369. package/dist/prompt-assembly/event-registry.js +2 -0
  370. package/dist/prompt-assembly/select.js +1 -0
  371. package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
  372. package/dist/prompt-assembly/tool-catalog.js +21 -7
  373. package/dist/prompt-assembly/types.d.ts +3 -0
  374. package/dist/prompts/default.d.ts +4 -1
  375. package/dist/prompts/default.js +6 -0
  376. package/dist/stores/file/checkpoint-store.d.ts +11 -10
  377. package/dist/stores/file/checkpoint-store.js +36 -10
  378. package/dist/stores/file/file-history-store.d.ts +6 -0
  379. package/dist/stores/file/file-history-store.js +21 -4
  380. package/dist/stores/file/fs-atomic.d.ts +1 -1
  381. package/dist/stores/file/index.d.ts +14 -4
  382. package/dist/stores/file/index.js +21 -5
  383. package/dist/stores/file/process-anchor.d.ts +9 -1
  384. package/dist/stores/file/session-policy-store.js +2 -17
  385. package/dist/stores/file/session-store.d.ts +27 -0
  386. package/dist/stores/file/session-store.js +81 -9
  387. package/dist/stores/file/workflow-journal-store.d.ts +14 -4
  388. package/dist/stores/file/workflow-journal-store.js +32 -24
  389. package/dist/stores/file/workflow-run-store.d.ts +15 -4
  390. package/dist/stores/file/workflow-run-store.js +76 -0
  391. package/dist/tools/artifact/artifact-tool.d.ts +10 -3
  392. package/dist/tools/artifact/artifact-tool.js +16 -1
  393. package/dist/tools/fs/bash-program-position.d.ts +10 -4
  394. package/dist/tools/fs/bash-program-position.js +11 -8
  395. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
  396. package/dist/tools/fs/bash-readonly-classifier.js +9 -2
  397. package/dist/tools/fs/find-actions.d.ts +30 -16
  398. package/dist/tools/fs/find-actions.js +272 -19
  399. package/dist/tools/fs/fs-bash.js +8 -5
  400. package/dist/tools/fs/fs-shared.d.ts +0 -29
  401. package/dist/tools/fs/fs-shared.js +0 -5
  402. package/dist/tools/fs/fs-write.js +2 -1
  403. package/dist/tools/fs/read-deny.d.ts +6 -1
  404. package/dist/tools/fs/read-deny.js +6 -1
  405. package/dist/tools/fs/read-floor.d.ts +6 -0
  406. package/dist/tools/fs/read-floor.js +5 -1
  407. package/dist/tools/fs/removal-actions.d.ts +43 -0
  408. package/dist/tools/fs/removal-actions.js +25 -0
  409. package/dist/tools/fs/removal-targets.d.ts +2 -21
  410. package/dist/tools/fs/removal-targets.js +2 -3
  411. package/dist/tools/fs/safety.d.ts +37 -1
  412. package/dist/tools/fs/safety.js +52 -0
  413. package/dist/tools/fs/shell-climb.d.ts +46 -0
  414. package/dist/tools/fs/shell-climb.js +79 -0
  415. package/dist/tools/fs/shell-read-check.js +47 -19
  416. package/dist/tools/fs/shell-read-establish.js +36 -22
  417. package/dist/tools/fs/shell-read-judge.d.ts +10 -2
  418. package/dist/tools/fs/shell-read-judge.js +4 -4
  419. package/dist/tools/fs/shell-read-plan.d.ts +3 -0
  420. package/dist/tools/fs/shell-read-plan.js +1 -1
  421. package/dist/tools/fs/shell-read-workdir.js +3 -2
  422. package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
  423. package/dist/tools/fs/shell-read-write-targets.js +3 -0
  424. package/package.json +2 -2
  425. package/test/export-surface.snapshot.json +169 -15
  426. package/wire-changes/core-stores-sql@7.71.0.json +40 -0
  427. package/wire-changes/core@7.71.0.json +5827 -0
  428. package/wire-changes/mods-kernel@7.71.0.json +52 -0
  429. package/wire-changes/primitives@7.71.0.json +473 -0
  430. package/wire-changes/wiki-gate@7.71.0.json +40 -0
  431. package/dist/core/frontmatter-fence.d.ts +0 -10
  432. package/dist/core/frontmatter-fence.js +0 -6
  433. package/dist/core/permission-rule-syntax.d.ts +0 -46
  434. package/dist/core/permission-rule-syntax.js +0 -52
@@ -124,8 +124,10 @@ export function erasureRequestInvalid(input) {
124
124
  }
125
125
  return undefined;
126
126
  }
127
- export function erasureScopeRefusal(where) {
128
- return erasureCodedError(`${where}: the request names or resolves to a scope outside its expectedScopes, or to an id whose scope this store cannot attribute — the whole request is refused (nothing was deleted, nothing was recorded; no count, id or scope is reported)`, "config.memory_erasure_scope");
127
+ export const ERASURE_REFUSED = "This erasure request is refused:";
128
+ export const MEMORY_IMPORT_REFUSED = "This memory import is refused:";
129
+ export function erasureScopeRefusal() {
130
+ return erasureCodedError(`${ERASURE_REFUSED} it names or resolves to a scope outside its expectedScopes, or to an id whose scope this store cannot attribute, so the whole request is refused (nothing was deleted, nothing was recorded; no count, id or scope is reported)`, "config.memory_erasure_scope");
129
131
  }
130
132
  function erasureCodedError(message, code) {
131
133
  const e = new Error(message);
@@ -760,7 +762,7 @@ export class FileMemoryEngineBackend {
760
762
  catch (err) {
761
763
  if (err.code === "ENOENT")
762
764
  return [];
763
- throw erasureCodedError(`eraseWithEvidence: the shadow directory could not be listed (${thrownText(err)}) — a scope erasure cannot claim a clean delete over a directory it could not look into; fix the filesystem fault and retry (nothing was deleted, nothing was recorded)`, "memory.erasure_census_incomplete");
765
+ throw erasureCodedError(`${ERASURE_REFUSED} the shadow directory could not be listed (${thrownText(err)}) — a scope erasure cannot claim a clean delete over a directory it could not look into; fix the filesystem fault and retry (nothing was deleted, nothing was recorded)`, "memory.erasure_census_incomplete");
764
766
  }
765
767
  return names
766
768
  .filter((name) => name.endsWith(".md"))
@@ -2598,7 +2600,7 @@ export class FileMemoryEngineBackend {
2598
2600
  }
2599
2601
  async erasureAnchorOf(requestId) {
2600
2602
  if (typeof requestId !== "string" || requestId.length === 0)
2601
- throw erasureCodedError("erasureAnchorOf: requestId is required (a non-empty string)", "config.memory_erasure_request");
2603
+ throw erasureCodedError("Reading an erasure request's anchor is refused: requestId is required (a non-empty string)", "config.memory_erasure_request");
2602
2604
  const lock = await this.acquireTxnLock();
2603
2605
  try {
2604
2606
  this.assertTxnLockOwnership(lock.token);
@@ -2618,7 +2620,7 @@ export class FileMemoryEngineBackend {
2618
2620
  const captured = captureErasureInput(input);
2619
2621
  const bad = erasureRequestInvalid(captured);
2620
2622
  if (bad !== undefined)
2621
- throw erasureCodedError(`eraseWithEvidence: ${bad}`, "config.memory_erasure_request");
2623
+ throw erasureCodedError(`${ERASURE_REFUSED} ${bad}`, "config.memory_erasure_request");
2622
2624
  const requestId = captured.requestId;
2623
2625
  const select = captured.select;
2624
2626
  const grant = captured.expectedScopes !== undefined ? canonicalExpectedScopes(captured.expectedScopes) : undefined;
@@ -2641,13 +2643,13 @@ export class FileMemoryEngineBackend {
2641
2643
  const recorded = priorAnchor.expectedScopes;
2642
2644
  const same = recorded === undefined || grant === undefined ? recorded === grant : recorded.length === grant.length && recorded.every((s, i) => grant[i] === s);
2643
2645
  if (!same) {
2644
- throw erasureCodedError(`eraseWithEvidence: requestId ${JSON.stringify(requestId)} was first executed under a different expectedScopes set — a requestId names one request under one authorization; nothing is reported`, "config.memory_erasure_scope");
2646
+ throw erasureCodedError(`${ERASURE_REFUSED} requestId ${JSON.stringify(requestId)} was first executed under a different expectedScopes set — a requestId names one request under one authorization; nothing is reported`, "config.memory_erasure_scope");
2645
2647
  }
2646
2648
  }
2647
2649
  if (grant !== undefined && firstOutsideExpectedScopes(grant, selectorScopes) >= 0)
2648
- throw erasureScopeRefusal("eraseWithEvidence");
2650
+ throw erasureScopeRefusal();
2649
2651
  if (priorAnchor !== undefined && priorAnchor.selectHash !== selectHash) {
2650
- throw erasureCodedError(`eraseWithEvidence: requestId ${JSON.stringify(requestId)} was first executed with a DIFFERENT selector — a requestId names ONE request; use a new requestId for a new selector (the first request's selector hash is on its anchor row, never in this text)`, "memory.erasure_selector_mismatch");
2652
+ throw erasureCodedError(`${ERASURE_REFUSED} requestId ${JSON.stringify(requestId)} was first executed with a DIFFERENT selector — a requestId names ONE request; use a new requestId for a new selector (the first request's selector hash is on its anchor row, never in this text)`, "memory.erasure_selector_mismatch");
2651
2653
  }
2652
2654
  const replay = priorAnchor !== undefined;
2653
2655
  let chainScopes;
@@ -2671,7 +2673,7 @@ export class FileMemoryEngineBackend {
2671
2673
  if (census === undefined) {
2672
2674
  census = this.censusProjectionsLocked();
2673
2675
  if (!census.complete) {
2674
- throw erasureCodedError("eraseWithEvidence: the store-wide projection census could not read every scope — an erasure attestation cannot claim a clean delete over a store that cannot be fully read; fix the filesystem fault and retry (nothing was deleted, nothing was recorded)", "memory.erasure_census_incomplete");
2676
+ throw erasureCodedError(`${ERASURE_REFUSED} the store-wide projection census could not read every scope — an erasure attestation cannot claim a clean delete over a store that cannot be fully read; fix the filesystem fault and retry (nothing was deleted, nothing was recorded)`, "memory.erasure_census_incomplete");
2675
2677
  }
2676
2678
  }
2677
2679
  return census;
@@ -2713,7 +2715,7 @@ export class FileMemoryEngineBackend {
2713
2715
  }
2714
2716
  const judged = resolvedIds.map((id) => !replay || rowPresent(id) || (takeCensus().byId.get(id) ?? []).length > 0 ? (boundScope(id) ?? (rowPresent(id) ? undefined : chainScopeOf(id))) : recorded.has(id) ? (recorded.get(id) ?? undefined) : chainScopeOf(id));
2715
2717
  if (firstOutsideExpectedScopes(grant, judged) >= 0)
2716
- throw erasureScopeRefusal("eraseWithEvidence");
2718
+ throw erasureScopeRefusal();
2717
2719
  }
2718
2720
  const priorDeletes = new Map();
2719
2721
  for (const r of chain) {
@@ -3442,7 +3444,7 @@ export class FileMemoryEngineBackend {
3442
3444
  }
3443
3445
  async custodyImport(rows, opts, timings) {
3444
3446
  if (typeof opts?.bundleHash !== "string" || opts.bundleHash.length === 0 || typeof opts.sourceStoreId !== "string" || opts.sourceStoreId.length === 0) {
3445
- throw erasureCodedError("custodyImport: bundleHash and sourceStoreId are required (the remint namespace and the origin stamp)", "config.memory_import_request");
3447
+ throw erasureCodedError(`${MEMORY_IMPORT_REFUSED} bundleHash and sourceStoreId are required (the remint namespace and the origin stamp)`, "config.memory_import_request");
3446
3448
  }
3447
3449
  const lock = await this.acquireTxnLock(timings);
3448
3450
  try {
@@ -3510,7 +3512,7 @@ export class FileMemoryEngineBackend {
3510
3512
  const bundleHash = typeof plan?.bundleHash === "string" ? plan.bundleHash : "";
3511
3513
  const sourceStoreId = typeof plan?.sourceStoreId === "string" ? plan.sourceStoreId : "";
3512
3514
  if (!/^[0-9a-f]{64}$/.test(bundleHash) || sourceStoreId.length === 0) {
3513
- throw erasureCodedError("importBundleCommit: plan.bundleHash must be the 64-hex bundle digest and sourceStoreId a non-empty string", "config.memory_import_request");
3515
+ throw erasureCodedError(`${MEMORY_IMPORT_REFUSED} plan.bundleHash must be the 64-hex bundle digest and sourceStoreId a non-empty string`, "config.memory_import_request");
3514
3516
  }
3515
3517
  const lock = await this.acquireTxnLock(timings);
3516
3518
  try {
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { FRONTMATTER_FENCE, isFrontmatterFence, UNCLOSED_FRONTMATTER_REASON } from "../frontmatter-fence.js";
2
+ import { FRONTMATTER_FENCE, isFrontmatterFence, UNCLOSED_FRONTMATTER_REASON } from "@sema-agent/primitives";
3
3
  import { MEMORY_ORIGIN_CAUSES } from "./types.js";
4
4
  const ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$/;
5
5
  export function isValidEntryId(value) {
@@ -8,6 +8,7 @@ export { computeBundleSectionHashes, computeMemoryBundleHash, memoryBundleInvali
8
8
  export { ControlPlaneCorruptError, deriveControlPlaneDir, deriveRepoControlPlaneDir, deriveRepoKey, deriveRepoMemoryDir, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, resolveMemoryEngineRoot, scopeDirFor, scopeDirName, scopeRegistryShape, layoutNeedsAdoption, adoptRootScopeLayout, v1MemoryPathKeyResolver, unresolvedProjectionDebts, scanFuseKey, type AdoptRootScopeLayoutOptions, type ScopeRegistryShape, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, type ControlPlaneRebuildReceipt, type StrictControlPlaneLedger, type ChallengeAppendResult, type ChallengeAssignment, type ChallengeEvent, type ChallengedHistoryRow, type LineagePendingTxn, type LineagePromotion, SESSION_CAPTURE_OPTOUT_DIR, type SessionCaptureOptOutRecord, type SessionCaptureOptOutMarkOutcome, type SessionCaptureRecordStore, sessionRecordBindsIncarnation, usableSessionIncarnation, type SessionIdentityRead, } from "./layout.js";
9
9
  export { readV2HeaderHints, isInstructionEntry, type V2HeaderHints } from "./header-hints.js";
10
10
  export { parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, committedOriginOf, originEquals, ambiguousOriginRepresentation, type ParsedEntryFile } from "./frontmatter.js";
11
+ export { isValidEntryId } from "./frontmatter.js";
11
12
  export { consolidationExposedFrontmatter } from "./frontmatter.js";
12
13
  export { committedDistilledOf, distilledEquals } from "./frontmatter.js";
13
14
  export { deriveShadowedSet } from "./shadowing.js";
@@ -8,6 +8,7 @@ export { computeBundleSectionHashes, computeMemoryBundleHash, memoryBundleInvali
8
8
  export { ControlPlaneCorruptError, deriveControlPlaneDir, deriveRepoControlPlaneDir, deriveRepoKey, deriveRepoMemoryDir, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, resolveMemoryEngineRoot, scopeDirFor, scopeDirName, scopeRegistryShape, layoutNeedsAdoption, adoptRootScopeLayout, v1MemoryPathKeyResolver, unresolvedProjectionDebts, scanFuseKey, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, SESSION_CAPTURE_OPTOUT_DIR, sessionRecordBindsIncarnation, usableSessionIncarnation, } from "./layout.js";
9
9
  export { readV2HeaderHints, isInstructionEntry } from "./header-hints.js";
10
10
  export { parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, committedOriginOf, originEquals, ambiguousOriginRepresentation } from "./frontmatter.js";
11
+ export { isValidEntryId } from "./frontmatter.js";
11
12
  export { consolidationExposedFrontmatter } from "./frontmatter.js";
12
13
  export { committedDistilledOf, distilledEquals } from "./frontmatter.js";
13
14
  export { deriveShadowedSet } from "./shadowing.js";
@@ -16,11 +16,32 @@ export declare class ControlPlaneCorruptError extends Error {
16
16
  * branching on message text is banned (§B8). Only `"lock-ownership"` is minted today (the
17
17
  * recoverable-as-incomplete family); absent = every other corruption (a definite state, throw). */
18
18
  readonly facet?: "lock-ownership";
19
+ /** {@link ROOT_ANCHOR_DAMAGED} on the refusal of a store whose root anchor cannot be trusted ({@link rootAnchorRefusal}), with
20
+ * `detail` the two directories {@link reanchorMemoryStoreRoot} takes; absent on every other corruption. */
21
+ readonly code?: typeof ROOT_ANCHOR_DAMAGED;
22
+ readonly detail?: RootAnchorRefusalDetail;
19
23
  constructor(message: string, opts?: {
20
24
  cause?: unknown;
21
25
  facet?: "lock-ownership";
26
+ rootAnchor?: RootAnchorRefusalDetail;
22
27
  });
23
28
  }
29
+ /** The code a store is refused with when its control plane's root anchor cannot be trusted: absent while the control plane holds
30
+ * the store's account (a store last opened by an engine that recorded none, or an anchor removed by hand), or present and not a
31
+ * record (a link, not a regular file, not JSON, out of shape, an unknown version). Carried by a {@link ControlPlaneCorruptError}
32
+ * (the control plane's own damage class); the remedy is the one re-anchor. Not carried by an anchor the file system would not let
33
+ * the engine read (permissions, an I/O fault), nor by the refusal of a control plane that may have travelled with a moved engine
34
+ * root and whose own anchor cannot be read (its remedy is another). */
35
+ export declare const ROOT_ANCHOR_DAMAGED: "memory.root_anchor_damaged";
36
+ /** What a {@link ROOT_ANCHOR_DAMAGED} refusal carries beside its sentence: `path`, the store directory as its opener spelled it, and
37
+ * `controlDir`, its control plane — the two arguments of {@link reanchorMemoryStoreRoot} (`reanchorMemoryStoreRoot(path, { controlDir })`). */
38
+ export type RootAnchorRefusalDetail = {
39
+ readonly path: string;
40
+ readonly controlDir: string;
41
+ };
42
+ /** Whether `thrown` is a {@link ROOT_ANCHOR_DAMAGED} refusal, read off its `code` (a hostile accessor reads as absent): the reading
43
+ * the memory phase's person-facing notice classifies it by. */
44
+ export declare function isRootAnchorRefusal(thrown: unknown): boolean;
24
45
  /**
25
46
  * CC-style repo PARTITION key: the repo root path, canonicalized, then slugged. Collisions across
26
47
  * repos require pathological sibling names and only merge their memory dirs (never corrupt them).
@@ -489,10 +510,12 @@ export declare function ensureDirExists(dir: string): void;
489
510
  export declare const LEDGER_FILE = "revs.json";
490
511
  /** The control-plane file recording the store root's physical path ({@link anchorStoreRoot}). */
491
512
  export declare const ROOT_ANCHOR_FILE = "root-anchor.json";
492
- /** What an ABSENT anchor means: a control plane holding nothing records the root (a first open — reached only when no one
493
- * expects the store there: {@link anchorStoreRoot} refuses that case before it asks, {@link storeAbsence}); one already
494
- * holding a store backfills while the arm is open and refuses once it is not. */
495
- export declare function absentAnchorReading(controlPlaneHoldsStore: boolean, backfillArmOpen?: boolean): "record" | "backfill" | "refuse";
513
+ /** What an ABSENT anchor means — the one law, whatever brought the control plane here (an engine that recorded no anchor, a
514
+ * one-shot key migration, a host's copy, an anchor removed by hand): a control plane holding nothing records the root (a first
515
+ * open — reached only when no one expects the store there: {@link anchorStoreRoot} refuses that case before it asks,
516
+ * {@link storeAbsence}); one already holding a store's account refuses ({@link rootAnchorRefusal}), and the one remedy is
517
+ * {@link reanchorMemoryStoreRoot}. The anchor has two writers: that first record, and the re-anchor. */
518
+ export declare function absentAnchorReading(controlPlaneHoldsStore: boolean): "record" | "refuse";
496
519
  /** Forget every store this process opened and saw. Exported for the pins (a cell that removes a store it wrote and opens another at the
497
520
  * same path); not part of the package surface. */
498
521
  export declare function forgetStoresSeenInProcess(): void;
@@ -558,7 +581,7 @@ export declare function assertRootNotSensitive(of: StoreRootKind, root: string):
558
581
  export declare function assertStoreRootsNotSensitive(dir: string, controlDir: string): void;
559
582
  /** Options of {@link anchorStoreRoot}. */
560
583
  export interface AnchorStoreRootOptions {
561
- /** Where `memory.root_anchor_backfilled` goes. */
584
+ /** Where `memory.root_anchor_rerecorded` and `memory.control_plane_new_over_memory` go. */
562
585
  onIncident?: MemoryPartitionIncidentSink;
563
586
  /** The clock `recordedAt` reads (the opener's injected clock). */
564
587
  now?: () => number;
@@ -588,8 +611,8 @@ export interface AnchorStoreRootOptions {
588
611
  * the control plane): an opener racing to record the anchor at that moment makes this open refuse and the next succeed. No anchor
589
612
  * otherwise ⇒ {@link absentAnchorReading}, decided under the anchor's lock (a racing opener
590
613
  * that recorded it first is judged against): a control plane holding nothing creates the root and records
591
- * it (a first open, only when no one expects the store); one already holding a store backfills it and discloses `memory.root_anchor_backfilled` (its root may
592
- * already have been re-pointed — undecidable, said). Nothing is kept between calls: the anchor is read every
614
+ * it (a first open, only when no one expects the store); one already holding a store's account is refused
615
+ * {@link ROOT_ANCHOR_DAMAGED} before the root is created or an anchor written, its remedy the re-anchor. Nothing is kept between calls: the anchor is read every
593
616
  * time, so a re-anchor ({@link reanchorMemoryStoreRoot}) reaches every live holder at its next face. With `remember`, every return
594
617
  * makes the store one this process opened, and one it saw when the store holds content ({@link storeAbsence}).
595
618
  */
@@ -677,7 +700,8 @@ export declare function erasureSweepRecordPathOf(storeRoot: string, requestId: s
677
700
  export declare function erasureSweepOwedAt(file: ErasureSweepRecordFile, storeRoot: string, requestId: string): string[];
678
701
  /**
679
702
  * The ONE way a recorded root anchor changes: point it at where `dir` resolves now — a store moved on
680
- * purpose, or an anchor that is damaged. `opts.controlDir` names the store's control plane exactly as its
703
+ * purpose, an anchor that is damaged, or one that is absent while the control plane holds the store's account
704
+ * (the {@link ROOT_ANCHOR_DAMAGED} refusal's `detail.path` and `detail.controlDir` are its two arguments). `opts.controlDir` names the store's control plane exactly as its
681
705
  * opener does (the explicit `controlDir` the backend / engine was given, absent for the derived one) and
682
706
  * resolves through the same reading ({@link effectiveControlRootOf}). Refused (`config.memory_reanchor`) when
683
707
  * `dir` is not an existing directory, and when that control plane holds neither an anchor nor a store — a
@@ -686,7 +710,8 @@ export declare function erasureSweepOwedAt(file: ErasureSweepRecordFile, storeRo
686
710
  * store's transaction lock ({@link acquireStoreTxnLock}; a commit in progress is waited for, never crossed) and
687
711
  * is refused while the control plane owes anything at the recorded root ({@link rootBoundObligationOf}: a
688
712
  * committed transaction pending recovery — its journal names paths under the recorded root and is replayed
689
- * there first, never carried over). Every live holder judges against the new anchor at its next face.
713
+ * there first, never carried over; with the anchor absent no release from this one on opens the store to replay it, so that
714
+ * refusal names the releases that do). Every live holder judges against the new anchor at its next face.
690
715
  * `opts.expectedFrom` is the root the caller confirmed the store moved from — a refusal's `detail.recorded`, handed back as it
691
716
  * came: compared character for character, under the anchor's lock and before the re-anchor writes, with the physical root the
692
717
  * anchor records; another root, or an anchor that is absent or cannot be read, refuses (`config.memory_reanchor`) and records
@@ -22,13 +22,23 @@ export const CURSORS_FILE = "cursors.json";
22
22
  export const CONTROL_PLANE_DIR = ".engine";
23
23
  export class ControlPlaneCorruptError extends Error {
24
24
  facet;
25
+ code;
26
+ detail;
25
27
  constructor(message, opts) {
26
28
  super(message, opts?.cause !== undefined ? { cause: opts.cause } : undefined);
27
29
  this.name = "ControlPlaneCorruptError";
28
30
  if (opts?.facet !== undefined)
29
31
  this.facet = opts.facet;
32
+ if (opts?.rootAnchor !== undefined) {
33
+ this.code = ROOT_ANCHOR_DAMAGED;
34
+ this.detail = { path: opts.rootAnchor.path, controlDir: opts.rootAnchor.controlDir };
35
+ }
30
36
  }
31
37
  }
38
+ export const ROOT_ANCHOR_DAMAGED = "memory.root_anchor_damaged";
39
+ export function isRootAnchorRefusal(thrown) {
40
+ return readMember(thrown, "code") === ROOT_ANCHOR_DAMAGED;
41
+ }
32
42
  function slugifyPath(absPath) {
33
43
  return absPath.normalize("NFC").replace(/[^A-Za-z0-9]/g, "-");
34
44
  }
@@ -1116,17 +1126,21 @@ export function ensureDirExists(dir) {
1116
1126
  }
1117
1127
  export const LEDGER_FILE = "revs.json";
1118
1128
  export const ROOT_ANCHOR_FILE = "root-anchor.json";
1119
- const ANCHOR_BACKFILL_ARM_OPEN = true;
1120
- export function absentAnchorReading(controlPlaneHoldsStore, backfillArmOpen = ANCHOR_BACKFILL_ARM_OPEN) {
1121
- if (!controlPlaneHoldsStore)
1122
- return "record";
1123
- return backfillArmOpen ? "backfill" : "refuse";
1129
+ export function absentAnchorReading(controlPlaneHoldsStore) {
1130
+ return controlPlaneHoldsStore ? "refuse" : "record";
1124
1131
  }
1125
1132
  function reanchorRemedy(dir, controlDir) {
1126
1133
  return `once the store root is where it belongs, call reanchorMemoryStoreRoot(${JSON.stringify(dir)}, { controlDir: ${JSON.stringify(controlDir)} }) and reopen`;
1127
1134
  }
1128
- function damagedAnchorError(controlDir, dir, why, cause) {
1129
- return new ControlPlaneCorruptError(`memory store root anchor ${join(controlDir, ROOT_ANCHOR_FILE)} is damaged (${why}) — the store root cannot be checked against it, so nothing in the store was opened; ${reanchorRemedy(dir, controlDir)}`, cause !== undefined ? { cause } : undefined);
1135
+ function rootAnchorRefusal(controlDir, dir, anchor, cause, coded = true) {
1136
+ const at = join(controlDir, ROOT_ANCHOR_FILE);
1137
+ const what = anchor.absent === true
1138
+ ? `memory store root anchor ${at} is absent while the control plane holds a store — the store was last opened by an engine that recorded no anchor (before 7.49.0), or the anchor was removed`
1139
+ : `memory store root anchor ${at} is damaged (${anchor.why})`;
1140
+ return new ControlPlaneCorruptError(`${what} — the store root cannot be checked against it, so nothing in the store was opened; ${reanchorRemedy(dir, controlDir)}`, { ...(cause !== undefined ? { cause } : {}), ...(coded ? { rootAnchor: { path: dir, controlDir } } : {}) });
1141
+ }
1142
+ function damagedAnchorError(controlDir, dir, why, cause, coded = true) {
1143
+ return rootAnchorRefusal(controlDir, dir, { why }, cause, coded);
1130
1144
  }
1131
1145
  function readStoreRootAnchor(controlDir, dir) {
1132
1146
  let raw;
@@ -1143,7 +1157,9 @@ function readStoreRootAnchor(controlDir, dir) {
1143
1157
  const code = err.code;
1144
1158
  if (code === "ENOENT" && fd === undefined)
1145
1159
  return undefined;
1146
- throw damagedAnchorError(controlDir, dir, code === "ELOOP" ? "a symbolic link, not the record" : `unreadable: ${code ?? thrownLabel(err)}`, err);
1160
+ if (code === "ELOOP")
1161
+ throw damagedAnchorError(controlDir, dir, "a symbolic link, not the record", err);
1162
+ throw damagedAnchorError(controlDir, dir, `unreadable: ${code ?? thrownLabel(err)}`, err, false);
1147
1163
  }
1148
1164
  finally {
1149
1165
  if (fd !== undefined)
@@ -1297,15 +1313,12 @@ function judgeStoreRootAnchor(dir, controlDir, opts) {
1297
1313
  return racedJudged;
1298
1314
  const reading = raced !== undefined ? "rerecord" : absentAnchorReading(controlPlaneHoldsStore(controlDir));
1299
1315
  if (reading === "refuse")
1300
- throw damagedAnchorError(controlDir, dir, "absent, while the control plane holds a store");
1316
+ throw rootAnchorRefusal(controlDir, dir, { absent: true });
1301
1317
  const overMemory = reading === "record" && treeHoldsRecord(dir, "memory");
1302
1318
  ensureDirExists(dir);
1303
1319
  const realpath = landingPathOf(dir);
1304
1320
  writeStoreRootAnchor(controlDir, lock, token, { v: 1, realpath, spelling: dir, recordedAt: (opts.now ?? Date.now)() });
1305
- if (reading === "backfill") {
1306
- discloseLayoutIncident(opts.onIncident, "memory.root_anchor_backfilled", `memory store root anchor recorded for a store that had none: ${dir} resolves to ${realpath} (control plane ${controlDir}) — from now on the store opens only there; where the root resolved before this open cannot be told`);
1307
- }
1308
- else if (reading === "rerecord") {
1321
+ if (reading === "rerecord") {
1309
1322
  discloseLayoutIncident(opts.onIncident, "memory.root_anchor_rerecorded", `memory store root anchor recorded again: ${dir} now resolves to ${realpath}, not to ${raced?.realpath ?? "(unreadable)"} its control plane ${controlDir} had recorded; nothing stands at the old root any more and the store held no memory — only what opening or reading it leaves — so there was nothing to guard; from now on the store opens at ${realpath}`);
1310
1323
  }
1311
1324
  else if (overMemory) {
@@ -1520,7 +1533,7 @@ function rootBoundObligationOf(controlDir) {
1520
1533
  return { owed: "a committed transaction is still pending recovery", remedy: "open it once so the journal replays" };
1521
1534
  }
1522
1535
  function reanchorRefusal(sentence) {
1523
- const e = new Error(`reanchorMemoryStoreRoot: ${sentence}`);
1536
+ const e = new Error(`Moving the memory store's root is refused: ${sentence}`);
1524
1537
  e.code = "config.memory_reanchor";
1525
1538
  return e;
1526
1539
  }
@@ -1558,7 +1571,11 @@ export async function reanchorMemoryStoreRoot(dir, opts = {}) {
1558
1571
  }
1559
1572
  const obligation = rootBoundObligationOf(controlDir);
1560
1573
  if (obligation !== undefined) {
1561
- throw reanchorRefusal(`${obligation.owed} at the recorded root — put the store back at ${from ?? "the root it was last opened at"}, ${obligation.remedy}, then re-anchor (control plane ${controlDir})`);
1574
+ throw reanchorRefusal(from === undefined && !unreadable
1575
+ ? `${obligation.owed}, and the store has no root anchor (it was last opened by an engine before 7.49.0, which recorded none, or the anchor was removed) — this engine opens such a store only once it is re-anchored, and re-anchors it only once nothing is owed: put the store back at the root it was last opened at, open it once there with any release from 7.49.0 to 7.70.x (that records its anchor and replays the journal; 7.63.x or below when the journal carries the bare-map ledger form, which 7.64.0 and later refuse), then upgrade (control plane ${controlDir})`
1576
+ : from === undefined
1577
+ ? `${obligation.owed}, and the store's root anchor cannot be used (it is damaged, or this process cannot read it) — a release that refuses the anchor cannot replay the journal, and this engine re-anchors only once nothing is owed: if the anchor file is intact and only unreadable to this process (permissions, an I/O fault), restore access and call again; if it is damaged, remove ${ROOT_ANCHOR_FILE} from the control plane first, put the store back at the root it was last opened at, open it once there with any release from 7.49.0 to 7.70.x (that records its anchor and replays the journal; 7.63.x or below when the journal carries the bare-map ledger form, which 7.64.0 and later refuse), then upgrade (control plane ${controlDir})`
1578
+ : `${obligation.owed} at the recorded root — put the store back at ${from}, ${obligation.remedy}, then re-anchor (control plane ${controlDir})`);
1562
1579
  }
1563
1580
  let still;
1564
1581
  try {
@@ -3184,7 +3201,7 @@ export async function stageImportLatch(docs, bundleHash, rows, now) {
3184
3201
  export async function releaseImportLatch(store, txnId) {
3185
3202
  const prefix = "import:";
3186
3203
  if (!txnId.startsWith(prefix) || !/^[0-9a-f]{64}$/.test(txnId.slice(prefix.length))) {
3187
- throw new ControlPlaneCorruptError(`releaseImportLatch: ${JSON.stringify(txnId)} is not an import-latch transaction id (import:<64-hex bundleHash>)`);
3204
+ throw new ControlPlaneCorruptError(`The import latch was not released: ${JSON.stringify(txnId)} is not an import-latch transaction id (import:<64-hex bundleHash>)`);
3188
3205
  }
3189
3206
  const receipt = importReceiptName(txnId.slice(prefix.length));
3190
3207
  let bytes;
@@ -3192,17 +3209,17 @@ export async function releaseImportLatch(store, txnId) {
3192
3209
  bytes = await store.getObject("import-receipt", receipt);
3193
3210
  }
3194
3211
  catch (err) {
3195
- throw new ControlPlaneCorruptError(`releaseImportLatch: the completion receipt ${receipt} could not be read (${thrownText(err)}) — a probe failure is not absence (fail-closed), and absence would refuse the release`, { cause: err });
3212
+ throw new ControlPlaneCorruptError(`The import latch was not released: the completion receipt ${receipt} could not be read (${thrownText(err)}) — a probe failure is not absence (fail-closed), and absence would refuse the release`, { cause: err });
3196
3213
  }
3197
3214
  if (bytes === undefined) {
3198
- throw new ControlPlaneCorruptError(`releaseImportLatch: no completion receipt ${receipt} — the import's governance legs are not proven landed, the latch stays; re-run the same bundle import to converge`);
3215
+ throw new ControlPlaneCorruptError(`The import latch was not released: no completion receipt ${receipt} — the import's governance legs are not proven landed, the latch stays; re-run the same bundle import to converge`);
3199
3216
  }
3200
3217
  await store.updateDoc("lineage", coerceLineage, (rec) => {
3201
3218
  const txn = rec.pending[txnId];
3202
3219
  if (txn === undefined)
3203
3220
  return { result: undefined };
3204
3221
  if (!isLatchOnlyTxn(txn)) {
3205
- throw new ControlPlaneCorruptError(`releaseImportLatch: pending transaction ${txnId} is NOT an import latch — refusing (this channel never discards a real staged transaction)`);
3222
+ throw new ControlPlaneCorruptError(`The import latch was not released: pending transaction ${txnId} is NOT an import latch — refusing (this channel never discards a real staged transaction)`);
3206
3223
  }
3207
3224
  delete rec.pending[txnId];
3208
3225
  return { next: rec, result: undefined };
@@ -3,7 +3,7 @@ import { join } from "node:path";
3
3
  import { MemoryEngine } from "./engine.js";
4
4
  import { derivePersonalControlDir, derivePersonalMemoryDir, judgeMemoryStoreSeat, memoryPlaneStore, memoryScopePlaneOf, mergeErasureAttestations, refuseAbsentPlaneStores, refuseMemoryStoreInput } from "./dual-root.js";
5
5
  import { acquireStoreTxnLock, assertRootNotSensitive, assertStoreTxnLockOwnership, controlPlanePinOf, ControlPlaneCorruptError, directoryPinOf, refuseAbsentStore, renewStoreTxnLock, resolveMemoryEngineRoot, storeAbsence, storeHoldsRecord, storeOpenArtifactFault, TXN_LOCK_STALE_MS } from "./layout.js";
6
- import { captureErasureInput, erasureRequestInvalid, erasureSelectHash } from "./file-backend.js";
6
+ import { captureErasureInput, ERASURE_REFUSED, erasureRequestInvalid, erasureSelectHash } from "./file-backend.js";
7
7
  import { canonicalExpectedScopes } from "./export-bundle.js";
8
8
  import { isEngineCodeShape, thrownLabel, thrownText } from "../thrown-value.js";
9
9
  import { chooseSessionWriteHome } from "./session-write-home.js";
@@ -85,7 +85,7 @@ export function createMemoryDeployment(input) {
85
85
  if (req.expectedScopes !== undefined) {
86
86
  const seats = new Set(canonicalExpectedScopes(req.expectedScopes).map(seat));
87
87
  if (seats.size > 1) {
88
- throw coded("eraseMemoryEntries: the request's expectedScopes name scopes kept in two of this deployment's memory stores, and one request is judged in one store's lock — send one request per store (nothing was deleted, nothing was recorded; no scope is reported)", "config.memory_erasure_scope");
88
+ throw coded(`${ERASURE_REFUSED} the request's expectedScopes name scopes kept in two of this deployment's memory stores, and one request is judged in one store's lock — send one request per store (nothing was deleted, nothing was recorded; no scope is reported)`, "config.memory_erasure_scope");
89
89
  }
90
90
  return [[...seats][0] ?? "project"];
91
91
  }
@@ -98,7 +98,7 @@ export function createMemoryDeployment(input) {
98
98
  const req = captureErasureInput(raw);
99
99
  const bad = erasureRequestInvalid(req);
100
100
  if (bad !== undefined)
101
- throw coded(`eraseMemoryEntries: ${bad}`, "config.memory_erasure_request");
101
+ throw coded(`${ERASURE_REFUSED} ${bad}`, "config.memory_erasure_request");
102
102
  refuseAbsentPlaneStores(backend, engineRoot, planesOf(req, hasPersonalStore()).includes("personal") || !existsSync(engineRoot));
103
103
  const lockDir = join(engineRoot, MEMORY_DEPLOYMENT_ERASURE_LOCK_DIR);
104
104
  const lock = await acquireStoreTxnLock(lockDir, { now: Date.now });
@@ -122,7 +122,7 @@ export function createMemoryDeployment(input) {
122
122
  lost = err;
123
123
  }
124
124
  }
125
- throw new ControlPlaneCorruptError(`eraseMemoryEntries: the deployment's erasure lock was lost ${when} (the holder stalled past its stale line and another erasure took it) — the stores this request executed keep their anchors; a replay of the same requestId converges them`, { cause: lost, facet: "lock-ownership" });
125
+ throw new ControlPlaneCorruptError(`This erasure request lost the deployment's erasure lock ${when} (the holder stalled past its stale line and another erasure took it) — the stores this request executed keep their anchors; a replay of the same requestId converges them`, { cause: lost, facet: "lock-ownership" });
126
126
  };
127
127
  try {
128
128
  const personalInSet = hasPersonalStore();
@@ -137,11 +137,11 @@ export function createMemoryDeployment(input) {
137
137
  const recorded = anchor.expectedScopes;
138
138
  const sameGrant = recorded === undefined || grant === undefined ? recorded === grant : recorded.length === grant.length && recorded.every((s, i) => grant[i] === s);
139
139
  if (!sameGrant) {
140
- throw coded(`eraseMemoryEntries: requestId ${JSON.stringify(req.requestId)} was first executed under a different expectedScopes set — a requestId names one request under one authorization; nothing is reported`, "config.memory_erasure_scope");
140
+ throw coded(`${ERASURE_REFUSED} requestId ${JSON.stringify(req.requestId)} was first executed under a different expectedScopes set — a requestId names one request under one authorization; nothing is reported`, "config.memory_erasure_scope");
141
141
  }
142
142
  if (anchor.selectHash === selectHash && reach.includes(store))
143
143
  continue;
144
- throw coded(`eraseMemoryEntries: requestId ${JSON.stringify(req.requestId)} was first executed ${anchor.selectHash === selectHash ? "in another of this deployment's memory stores" : "with a DIFFERENT selector"} — a requestId names ONE request in the deployment; use a new requestId for a new selector (nothing was deleted, nothing was recorded)`, "memory.erasure_selector_mismatch");
144
+ throw coded(`${ERASURE_REFUSED} requestId ${JSON.stringify(req.requestId)} was first executed ${anchor.selectHash === selectHash ? "in another of this deployment's memory stores" : "with a DIFFERENT selector"} — a requestId names ONE request in the deployment; use a new requestId for a new selector (nothing was deleted, nothing was recorded)`, "memory.erasure_selector_mismatch");
145
145
  }
146
146
  let receipt;
147
147
  const executed = [];
@@ -201,7 +201,7 @@ function refusedAfterExecuting(err, executed, refusing, erased) {
201
201
  if (!(err instanceof Error))
202
202
  return err;
203
203
  const done = executed.map((plane) => `the ${plane} store`).join(" and ");
204
- const sentence = `eraseMemoryEntries: this request had already executed in ${done} (${erased} ${erased === 1 ? "entry" : "entries"} erased there; each keeps its anchor and a replay of the same requestId converges every store) when the ${refusing} store refused it — what follows describes the refusing store alone: ${err.message}`;
204
+ const sentence = `This erasure request had already executed in ${done} (${erased} ${erased === 1 ? "entry" : "entries"} erased there; each keeps its anchor and a replay of the same requestId converges every store) when the ${refusing} store refused it — what follows describes the refusing store alone: ${err.message}`;
205
205
  try {
206
206
  const copy = Object.create(Object.getPrototypeOf(err), Object.getOwnPropertyDescriptors(err));
207
207
  Object.defineProperty(copy, "message", { value: sentence, writable: true, configurable: true, enumerable: false });
@@ -217,7 +217,7 @@ async function anchorOf(store, requestId) {
217
217
  return face.erasureAnchorOf.call(store, requestId);
218
218
  if (typeof face.eraseWithEvidence !== "function")
219
219
  return undefined;
220
- throw coded("eraseMemoryEntries: another store of this deployment has an erasure-evidence face but no anchor read (erasureAnchorOf), so whether it already executed this requestId cannot be judged — nothing was deleted", "memory.erasure_evidence_unavailable");
220
+ throw coded(`${ERASURE_REFUSED} another store of this deployment has an erasure-evidence face but no anchor read (erasureAnchorOf), so whether it already executed this requestId cannot be judged — nothing was deleted`, "memory.erasure_evidence_unavailable");
221
221
  }
222
222
  function personalOpenFault(err, mount) {
223
223
  if (err instanceof ControlPlaneCorruptError)
@@ -16,8 +16,10 @@
16
16
  */
17
17
  import type { EngineNotice } from "../types.js";
18
18
  import { type StoreFormRefusalCode, type StoreFormRefusalReading, type TargetOutsideStoreReason } from "./layout.js";
19
- /** Why the store did not mount: the store-form refusal's own code when the mount was refused for the store's physical form, else `"unclassified"`. */
20
- export type MemoryMountFailedCause = StoreFormRefusalCode | "unclassified";
19
+ /** Why the store did not mount: the store-form refusal's own code when the mount was refused for the store's physical form,
20
+ * {@link ROOT_ANCHOR_DAMAGED} when it was refused because its root anchor cannot be trusted (one re-anchor restores it), else
21
+ * `"unclassified"`. */
22
+ export type MemoryMountFailedCause = StoreFormRefusalCode | "memory.root_anchor_damaged" | "unclassified";
21
23
  /** The code whose cases the person hears apart — the one reading of the family that carries a case word. */
22
24
  type OutsideCode = Extract<StoreFormRefusalReading, {
23
25
  readonly outsideReason: TargetOutsideStoreReason;
@@ -29,8 +31,8 @@ export type MemoryMountFailedReading = {
29
31
  readonly cause: OutsideCode;
30
32
  readonly outsideReason: TargetOutsideStoreReason;
31
33
  };
32
- /** What a mount failure reports, read once from the thrown value through the family's one reader ({@link storeFormRefusalReadingOf});
33
- * anything that reading does not name is `"unclassified"`. */
34
+ /** What a mount failure reports, read once from the thrown value through the family's one reader ({@link storeFormRefusalReadingOf})
35
+ * and the root anchor's ({@link isRootAnchorRefusal}); anything neither names is `"unclassified"`. */
34
36
  export declare function memoryMountFailedReadingOf(thrown: unknown): MemoryMountFailedReading;
35
37
  export declare function memoryMountFailedNotice(input: {
36
38
  sessionId: string;
@@ -45,7 +47,7 @@ export type CaptureOptOutUnpersistedRetry = "transient" | "until_fixed";
45
47
  * `record_unpersisted`: the record store did not durably land the record (or the in-flight guard before it failed); every other cause is
46
48
  * why the memory phase failed before the record was made — a mount failure's cause ({@link MemoryMountFailedCause}), read by its one
47
49
  * reader. The store-form family is `until_fixed` — the layout the engine was handed is not the one it needs, and the same request is
48
- * refused until it is; `record_unpersisted` and `unclassified` are `transient` — a record store briefly unavailable heals, a read-only
50
+ * refused until it is — and so is `memory.root_anchor_damaged` (refused at every open until the store is re-anchored); `record_unpersisted` and `unclassified` are `transient` — a record store briefly unavailable heals, a read-only
49
51
  * volume does not, and the engine cannot tell which. `satisfies` over the mount causes and the record's own: a cause added to the mount
50
52
  * failures without its word here is a tsc error. */
51
53
  export declare const CAPTURE_OPTOUT_UNPERSISTED_RETRY: Readonly<{
@@ -57,6 +59,7 @@ export declare const CAPTURE_OPTOUT_UNPERSISTED_RETRY: Readonly<{
57
59
  readonly "memory.store_root_sensitive": "until_fixed";
58
60
  readonly "memory.control_plane_split": "until_fixed";
59
61
  readonly "memory.store_absent": "until_fixed";
62
+ readonly "memory.root_anchor_damaged": "until_fixed";
60
63
  readonly unclassified: "transient";
61
64
  }>;
62
65
  export type CaptureOptOutUnpersistedCause = keyof typeof CAPTURE_OPTOUT_UNPERSISTED_RETRY;
@@ -1,4 +1,4 @@
1
- import { STORE_ABSENT, storeAbsence, storeFormRefusalReadingOf } from "./layout.js";
1
+ import { ROOT_ANCHOR_DAMAGED, STORE_ABSENT, isRootAnchorRefusal, storeAbsence, storeFormRefusalReadingOf } from "./layout.js";
2
2
  const OPERATOR_TAIL = "Whoever runs this deployment can do this (the service log names the exact step); the next run mounts it again.";
3
3
  const OUTSIDE = {
4
4
  act_outside: {
@@ -29,6 +29,7 @@ const CLAUSE = {
29
29
  "memory.store_root_sensitive": "the memory store is configured inside a directory the engine's write guard protects (a credential or access-control directory)",
30
30
  "memory.control_plane_split": "since the memory store's location was moved, what is kept beside it stands in two places that disagree",
31
31
  "memory.store_absent": "the memory store this deployment had is no longer where it was set up (its folder was moved away, or the disk it lives on is not mounted)",
32
+ "memory.root_anchor_damaged": "the memory store was left by an older version of the engine, which did not record where the store lives — or the file that records it was removed or is damaged; the engine changed none of the store's memory and removed none of it",
32
33
  unclassified: "the memory store could not be opened",
33
34
  };
34
35
  const RESTORE = {
@@ -38,12 +39,13 @@ const RESTORE = {
38
39
  "memory.store_root_sensitive": "point the memory store at a directory outside the protected one",
39
40
  "memory.control_plane_split": "keep one of the two copies of each record the service log names and remove the other",
40
41
  "memory.store_absent": "put the memory folder back where it was, or mount its disk (it opens again as it was); to start over with empty memory on purpose instead, start the service again — unless the service is set up to require this memory, which then has to be set up again as a new, empty memory",
42
+ "memory.root_anchor_damaged": "re-anchor the store once — one call, given the store's directory and the directory kept beside it, both named in the service log (if that call is refused, its own message says what comes first); the store then opens with its memory",
41
43
  unclassified: "check the service log for why the memory store could not be opened",
42
44
  };
43
45
  export function memoryMountFailedReadingOf(thrown) {
44
46
  const refusal = storeFormRefusalReadingOf(thrown);
45
47
  if (refusal === undefined)
46
- return { cause: "unclassified" };
48
+ return { cause: isRootAnchorRefusal(thrown) ? ROOT_ANCHOR_DAMAGED : "unclassified" };
47
49
  return "outsideReason" in refusal ? { cause: refusal.code, outsideReason: refusal.outsideReason } : { cause: refusal.code };
48
50
  }
49
51
  function mountFailedWordsOf(reading) {
@@ -67,6 +69,7 @@ export const CAPTURE_OPTOUT_UNPERSISTED_RETRY = Object.freeze({
67
69
  "memory.store_root_sensitive": "until_fixed",
68
70
  "memory.control_plane_split": "until_fixed",
69
71
  "memory.store_absent": "until_fixed",
72
+ "memory.root_anchor_damaged": "until_fixed",
70
73
  unclassified: "transient",
71
74
  });
72
75
  export function captureMarkUnpersistedReadingOf(controlDir) {
@@ -320,6 +320,11 @@ export declare class PermissionModeController {
320
320
  /** The declared word the leg had when a steer (or the model's `EnterPlanMode`) last moved it into `plan`, while it is
321
321
  * there; a leg that started in plan has none, and a steer out of plan clears it. A checkpoint row records it. */
322
322
  get prePlanMode(): PermissionMode | undefined;
323
+ /** {@link prePlanMode} as it runs: the word (already declared under the ceiling it was entered under) folded against the
324
+ * deployment's arming facts as {@link observed} folds the leg's own (an `auto` with no classifier face, or under the deny bit,
325
+ * runs `default`). An observation: read through the ceilings' `observed`, it starts no arming. Absent when the leg is not in a
326
+ * plan entered from another mode. */
327
+ get prePlanModeObserved(): PermissionMode | undefined;
323
328
  /** The word the caller asked for right now: the newest steer that still counts, else the spec's. */
324
329
  get requested(): PermissionMode | undefined;
325
330
  private ceilingNow;
@@ -206,6 +206,12 @@ export class PermissionModeController {
206
206
  get prePlanMode() {
207
207
  return this.declared === "plan" ? this.prePlan : undefined;
208
208
  }
209
+ get prePlanModeObserved() {
210
+ const word = this.answerOf(true).declared === "plan" ? this.prePlan : undefined;
211
+ if (word === undefined)
212
+ return undefined;
213
+ return foldPermissionMode({ requested: word, ...(this.arming !== undefined ? { arming: this.arming } : {}) }).receipt.effective;
214
+ }
209
215
  get requested() {
210
216
  return this.steers.at(-1)?.word ?? this.requestedBySpec;
211
217
  }
@@ -20,7 +20,8 @@ export declare function modsReportToOnError(onError: RunnerDeps["onError"], sess
20
20
  type RefusedRecord = Extract<ModAdmissionRecord, {
21
21
  readonly refusedBy: string;
22
22
  }>;
23
- /** The notice for a registration admission refused: the run goes on without it. */
23
+ /** The notice for a registration admission refused: the run goes on without it. A task-seat registration (a skill's included)
24
+ * is the person's fact; a deployment-seat one is the operator's, under its own code — one fact, one code, one audience. */
24
25
  export declare function registrationRefusedNotice(record: RefusedRecord, sessionId: string): EngineNotice;
25
26
  /** A leg's registrations as its admission takes them: both seats, and the skills' registrations riding the task seat after the
26
27
  * task's own (same screen, unique names in the run). Listed ONCE per leg — read before the leg's environment exists (whether
@@ -1,4 +1,4 @@
1
- import { MODS_REGISTRATION_REFUSED_CODE } from "./kernel/index.js";
1
+ import { MODS_REGISTRATION_REFUSED_DEPLOYMENT_CODE, MODS_REGISTRATION_REFUSED_CODE } from "./kernel/index.js";
2
2
  import { skillSeatsOf } from "./spec-seats.js";
3
3
  export function modSeatsOf(spec, deps) {
4
4
  return { ...(deps.mods !== undefined ? { deployment: deps.mods } : {}), ...(spec.mods !== undefined ? { task: spec.mods } : {}) };
@@ -13,12 +13,13 @@ export function modsReportToOnError(onError, sessionId) {
13
13
  };
14
14
  }
15
15
  const REGISTRATION_REFUSED = "mods.registration_refused";
16
+ const REGISTRATION_REFUSED_DEPLOYMENT = "mods.registration_refused_deployment";
16
17
  export function registrationRefusedNotice(record, sessionId) {
17
- return {
18
- code: REGISTRATION_REFUSED,
19
- message: `extension "${record.name}" (${record.seat} seat) was not mounted: ${record.refusedBy} refused it — ${record.reason}`,
20
- detail: { name: record.name, seat: record.seat, tier: record.tier, ...(record.provenance !== undefined ? { provenance: record.provenance } : {}), refusedBy: record.refusedBy, reason: record.reason, sessionId },
21
- };
18
+ const message = `extension "${record.name}" (${record.seat} seat) was not mounted: ${record.refusedBy} refused it — ${record.reason}`;
19
+ const detail = { name: record.name, seat: record.seat, tier: record.tier, ...(record.provenance !== undefined ? { provenance: record.provenance } : {}), refusedBy: record.refusedBy, reason: record.reason, sessionId };
20
+ if (record.seat === "deployment")
21
+ return { code: REGISTRATION_REFUSED_DEPLOYMENT, message, detail };
22
+ return { code: REGISTRATION_REFUSED, message, detail };
22
23
  }
23
24
  export function listLegModSeats(input) {
24
25
  const seats = modSeatsOf(input.spec, input.deps);
@@ -2,5 +2,5 @@
2
2
  export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAILURE_ANSWERS, MOD_ABORT_POSTURES, NEXT_TO_TABLE, SEAT_TIER_TABLE, MOD_EVENT_TABLE, nextToRefusal, expandModPattern, expandOnSide, failureRefuses, isModEventName, stationOn, readOnSide, type ModTier, type ModRegistrationTier, type ModSeat, type ModEventSide, type ModBusSide, type ModFailureAnswer, type ModAbortPosture, type ModStation, type ModEventRow, type ModEventName, } from "./events.js";
3
3
  export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, clockMsRefusal, resolveModBudgetMs, type ModBudgetReading, } from "./budget.js";
4
4
  export { MOD_FAILURE_CAUSES, type ModFailureCause, type ModEventPayload, type ModAnswerCheck, type ModAnswerRanks, type ModDispatchRun, type ModAnswerer, type ModMatcher, type ModSkip, } from "./site-rules.js";
5
- export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES, type ModTraceOutcome, type ModUses, type ModOrigin, type ModPluginFacts, type ModDollarBase, type ModTraceEntry, type ModCaughtError, type ModNext, type ModHandler, type ModHandlerOptions, type ModEventPair, type ModEventMap, type ModTypedNext, type ModTypedHandler, type On, type MappedOn, type ModRegistration, type ModAdmissionRecord, type ModSeats, } from "./registration.js";
5
+ export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MODS_REGISTRATION_REFUSED_DEPLOYMENT_CODE, MOD_TRACE_OUTCOMES, type ModTraceOutcome, type ModUses, type ModOrigin, type ModPluginFacts, type ModDollarBase, type ModTraceEntry, type ModCaughtError, type ModNext, type ModHandler, type ModHandlerOptions, type ModEventPair, type ModEventMap, type ModTypedNext, type ModTypedHandler, type On, type MappedOn, type ModRegistration, type ModAdmissionRecord, type ModSeats, } from "./registration.js";
6
6
  export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModCallEntry, type ModCallEntries, type ModDispatchOutcome, type ModDispatchOptions, type ModParticipant, type ModBus, type ModMountedHandler, type ModBusInput, type ModTimer, } from "./dispatch.js";
@@ -1,5 +1,5 @@
1
1
  export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAILURE_ANSWERS, MOD_ABORT_POSTURES, NEXT_TO_TABLE, SEAT_TIER_TABLE, MOD_EVENT_TABLE, nextToRefusal, expandModPattern, expandOnSide, failureRefuses, isModEventName, stationOn, readOnSide, } from "./events.js";
2
2
  export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, clockMsRefusal, resolveModBudgetMs, } from "./budget.js";
3
3
  export { MOD_FAILURE_CAUSES, } from "./site-rules.js";
4
- export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES, } from "./registration.js";
4
+ export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MODS_REGISTRATION_REFUSED_DEPLOYMENT_CODE, MOD_TRACE_OUTCOMES, } from "./registration.js";
5
5
  export { admitMods, } from "./dispatch.js";