@sema-agent/core 7.72.0 → 7.74.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 (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -20,6 +20,7 @@ import { canonicalExpectedScopes, expectedScopesInvalid, firstOutsideExpectedSco
20
20
  import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
21
21
  import { admittingLandings, cutPerLanding, LandingsNeedAdmission, requireLandingsAdmitted } from "./landing-admission.js";
22
22
  import { thrownText } from "../thrown-value.js";
23
+ import { deletionRecordFrom } from "./deletion-record.js";
23
24
  import { deliverEngineNotice } from "../engine-notice.js";
24
25
  import { optionKeys, receiveOptions } from "../own-property-receipt.js";
25
26
  export { DEFAULT_MAX_ENTRY_DEPTH, MEMORY_INDEX_FILENAME, scanEntryFiles } from "./entry-scan.js";
@@ -1153,11 +1154,8 @@ export class FileMemoryEngineBackend {
1153
1154
  }
1154
1155
  resurrectionBackstopVerdict(id) {
1155
1156
  const digest = this.deletedIdsDigestLocked();
1156
- if (digest.ids.has(id))
1157
- return "erased";
1158
- if (digest.state === "damaged" || this.chainDegradedMarkerPresent())
1159
- return "degraded";
1160
- return "clear";
1157
+ const record = deletionRecordFrom({ deletedRev: digest.ids.has(id) ? null : undefined, sound: digest.state !== "damaged" && !this.chainDegradedMarkerPresent() });
1158
+ return record.kind === "deleted" ? "erased" : record.kind === "undecidable" ? "degraded" : "clear";
1161
1159
  }
1162
1160
  retrievalDeletedIds() {
1163
1161
  return this.deletedIdsDigestLocked().ids;
@@ -3070,6 +3068,10 @@ export class FileMemoryEngineBackend {
3070
3068
  }
3071
3069
  }
3072
3070
  }
3071
+ if (out.state === "complete" && this.chainDegradedMarkerPresent()) {
3072
+ out.state = "damaged";
3073
+ out.reason ??= `evidence chain carries durable degradation marker (${CHAIN_DEGRADED_FILE} — out-of-band tail truncation)`;
3074
+ }
3073
3075
  if (this.auditJournalPending())
3074
3076
  continue;
3075
3077
  if (readControlFileOrAbsent(transfersPath, "transfer evidence log") !== rawBefore)
@@ -32,7 +32,7 @@ export declare function retireGoneProjections(rows: readonly ProjectionLedgerRow
32
32
  /** What a mount says about the files it left: one line per file, by scope — the seat only, never content. The announcement
33
33
  * renderer keeps an item to the inline label bound (160 characters), so the quoted seat is held to its room and what a person
34
34
  * acts on comes before a cause (a seat name cut past that bound would take the rest of the line with it). Three arms, each
35
- * saying what is true of it: a copy changed here (it may be saved back unless the file goes), something else standing at the
35
+ * saying what is true of it: a copy changed here (not saved back if deleted, else delete the file), something else standing at the
36
36
  * seat (nothing is asked of the person), a copy that could not be removed. */
37
37
  export declare function retirementNotices(r: ProjectionRetirement): Map<string | undefined, string[]>;
38
38
  /** The one wording of a ledger fault: unreadable at a mount (nothing removed — the notice is said before the record is written, so
@@ -82,7 +82,7 @@ export function retirementNotices(r) {
82
82
  }
83
83
  };
84
84
  for (const row of r.changed)
85
- say(row.scope, `${q(row.rel)}: gone from the store at this name, changed here since it was placed — kept; it may be saved back unless you delete the file`);
85
+ say(row.scope, `${q(row.rel)}: gone from the store at this name, changed here since it was placed — kept; not saved back if deleted, else delete the file`);
86
86
  for (const row of r.replaced)
87
87
  say(row.scope, `${q(row.rel)}: the store places no entry at this name any more, and this file is now a different note — left as found`);
88
88
  for (const { row, why } of r.failed)
@@ -1,4 +1,5 @@
1
1
  import type { ExecutionEnv } from "../../internal/harness-types.js";
2
+ import { PROJECT_ID_REGEX, type ProjectSeat } from "../project-seat.js";
2
3
  /** Per-segment cap, measured AFTER encoding. A conservative portability policy adopted as contract
3
4
  * (research (d) recommendation — NOT a verified third-party hard limit; uuidv7 = 36 chars fits). */
4
5
  export declare const SCOPE_SEGMENT_MAX_ENCODED = 64;
@@ -132,10 +133,8 @@ export declare function assertScopeContractPlacement(args: {
132
133
  /** Repo-root marker file: minted once (by scaffold/deployment, NEVER by the engine), committed, and
133
134
  * from then on the project's identity survives clone/copy/rename/machine/cloud-sandbox. */
134
135
  export declare const PROJECT_MARKER_PATH = ".sema/project";
135
- /** projectId 格式单源:generic UUID,version nibble 不收紧——宽读严写(读面认外部/
136
- * 历史 v4;铸造面 formatProjectMarker / center mint 统一产 uuidv7)。center 侧自持镜像+dev-only
137
- * drift 锁对着这条(registry-core coreTypes 先例)。 */
138
- export declare const PROJECT_ID_REGEX: RegExp;
136
+ /** The project id's one format (defined beside the project seat, `../project-seat.ts`). */
137
+ export { PROJECT_ID_REGEX };
139
138
  /** Canonicalize a project UUID for equality comparisons across markers, declarations, and v2 write keys. */
140
139
  export declare function normalizeProjectId(projectId: string): string;
141
140
  /** Serialize a marker file body (scaffold-side helper; the engine itself never writes one). */
@@ -212,7 +211,7 @@ export declare function resolveProjectId(fs: ProjectMarkerFs, rootDir: string):
212
211
  markerDir: string;
213
212
  } | null>;
214
213
  /** A leg's project identity. `marker` = the checkout's `.sema/project` (a declaration, when present,
215
- * equals it); `declared` = `TaskSpec.projectId` in a checkout that carries no marker. */
214
+ * equals it); `declared` = `TaskSpec.project.id` (or the seat its parent handed it) in a checkout that carries no marker. */
216
215
  export interface SessionProject {
217
216
  readonly id: string;
218
217
  readonly source: "marker" | "declared";
@@ -224,6 +223,9 @@ export interface SessionProjectVerdict {
224
223
  readonly root: string;
225
224
  /** ABSENT = no marker and no declaration, or the marker could not be read ({@link markerFault} says why). */
226
225
  readonly project?: SessionProject;
226
+ /** The leg's project SEAT: the verdict's id with the texts that belong to it ({@link resolveSessionProject} says which) — present
227
+ * iff {@link project} is. What the leg hands its children and what its project texts are read from. */
228
+ readonly seat?: ProjectSeat;
227
229
  /** Why the marker could not be read (nested / corrupt / unreadable), on a leg that declared no project — reported by
228
230
  * the caller, NOT thrown here: only a reader that consumes project identity refuses with it (memory v2 `proj:` /
229
231
  * `userproj:` keys). A leg that DECLARED a project consumes it, so there the fault is thrown. */
@@ -238,16 +240,19 @@ export declare function projectMarkerUnreadableOf(fault: SessionProjectVerdict["
238
240
  readonly markerPath?: string;
239
241
  } | undefined;
240
242
  /**
241
- * The leg's ONE project-identity judge, called once per leg on the task root. Precedence:
242
- * 1. `declared` (`TaskSpec.projectId`): validated UUID (`config.project_id_invalid`); checked against any workspace
243
- * marker (`config.project_identity_mismatch` on disagreement, marker's own code on unreadable marker).
243
+ * The leg's ONE project-identity judge, called once per leg on the task root, over seats already screened
244
+ * (`screenProjectSeat`, at the spec's read and at the internals' door). Precedence:
245
+ * 1. `declared` (`TaskSpec.project`): checked against any workspace marker (`config.project_identity_mismatch` on
246
+ * disagreement, the marker's own code on an unreadable marker).
244
247
  * 2. The leg's own workspace marker (`.sema/project`): decides when present (`source: "marker"`), even over an
245
- * inherited `defaultProjectId`; an unreadable marker on a leg with no `declared` yields `{ root, markerFault }`
246
- * (no project verdict — identical to a root leg).
247
- * 3. `defaultProjectId` (a delegated child's inherited parent verdict, passed via trusted internals): used ONLY when
248
- * both (1) and (2) yield none (`source: "declared"`), never compared against the child's marker.
248
+ * `inherited` seat; an unreadable marker on a leg with no `declared` yields `{ root, markerFault }` (no project verdict —
249
+ * identical to a root leg).
250
+ * 3. `inherited` (the seat a delegated child's parent handed it, on the trusted internals): its id is used ONLY when both (1)
251
+ * and (2) yield none (`source: "declared"`), never compared against the child's marker.
252
+ * The texts belong to the id: the verdict's {@link SessionProjectVerdict.seat} is `declared` whole; else `inherited` whole when its
253
+ * id is the verdict's id (no marker, or a marker naming that id); else the verdict's id alone.
249
254
  */
250
- export declare function resolveSessionProject(fs: ProjectMarkerFs, taskRoot: string, declared: string | undefined, defaultProjectId?: string): Promise<SessionProjectVerdict>;
255
+ export declare function resolveSessionProject(fs: ProjectMarkerFs, taskRoot: string, declared: ProjectSeat | undefined, inherited?: ProjectSeat): Promise<SessionProjectVerdict>;
251
256
  /**
252
257
  * Under `scopeContract: "v2"`, enforce project-identity consistency for a memory session against the leg's ONE
253
258
  * verdict ({@link SessionProjectVerdict}): rethrow an unreadable-marker fault for sessions consuming project identity
@@ -4,8 +4,8 @@ import { err, FileError, ok } from "../../internal/harness.js";
4
4
  import { performsIo } from "../remote-env.js";
5
5
  import { thrownText } from "../thrown-value.js";
6
6
  import { envErrorDetail } from "../../tools/fs/env-error-detail.js";
7
- import { describeRejectedValue } from "../tool-search-setting.js";
8
7
  import { physicalPathOfExisting } from "../physical-path.js";
8
+ import { PROJECT_ID_REGEX } from "../project-seat.js";
9
9
  function pathSegmentsDualFamily(p) {
10
10
  return p.split(/[\\/]/).filter(Boolean);
11
11
  }
@@ -198,7 +198,7 @@ export function assertScopeContractPlacement(args) {
198
198
  }
199
199
  }
200
200
  export const PROJECT_MARKER_PATH = ".sema/project";
201
- export const PROJECT_ID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
201
+ export { PROJECT_ID_REGEX };
202
202
  const UUID_RE = PROJECT_ID_REGEX;
203
203
  export function normalizeProjectId(projectId) {
204
204
  return projectId.toLowerCase();
@@ -354,11 +354,8 @@ export function projectMarkerUnreadableOf(fault) {
354
354
  return undefined;
355
355
  return d.reason === "repo_root_unreadable" || d.markerPath === undefined ? { reason: d.reason } : { reason: d.reason, markerPath: d.markerPath };
356
356
  }
357
- export async function resolveSessionProject(fs, taskRoot, declared, defaultProjectId) {
358
- if (declared !== undefined && (typeof declared !== "string" || !UUID_RE.test(declared))) {
359
- throw identityError("config.project_id_invalid", `TaskSpec.projectId must be a project UUID (the id a \`.sema/project\` marker carries), got ${describeRejectedValue(declared)}; the leg is refused rather than filed under no project.`);
360
- }
361
- const declaredId = declared !== undefined ? normalizeProjectId(declared) : undefined;
357
+ export async function resolveSessionProject(fs, taskRoot, declared, inherited) {
358
+ const declaredId = declared !== undefined ? normalizeProjectId(declared.id) : undefined;
362
359
  let marker;
363
360
  try {
364
361
  marker = await resolveProjectId(fs, taskRoot);
@@ -368,16 +365,19 @@ export async function resolveSessionProject(fs, taskRoot, declared, defaultProje
368
365
  throw e;
369
366
  return { root: taskRoot, markerFault: e };
370
367
  }
371
- if (marker !== null) {
372
- if (declaredId !== undefined && declaredId !== marker.projectId) {
373
- const markerPath = join(marker.markerDir, PROJECT_MARKER_PATH);
374
- throw identityError("config.project_identity_mismatch", `TaskSpec.projectId declares ${declaredId}, but this checkout's project marker ${markerPath} carries ${marker.projectId} — ` +
375
- `the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
376
- }
377
- return { root: taskRoot, project: { id: marker.projectId, source: "marker" } };
368
+ if (marker !== null && declaredId !== undefined && declaredId !== marker.projectId) {
369
+ const markerPath = join(marker.markerDir, PROJECT_MARKER_PATH);
370
+ throw identityError("config.project_identity_mismatch", `TaskSpec.project.id declares ${declaredId}, but this checkout's project marker ${markerPath} carries ${marker.projectId} — ` +
371
+ `the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
378
372
  }
379
- const fallbackId = declaredId ?? (defaultProjectId !== undefined ? normalizeProjectId(defaultProjectId) : undefined);
380
- return fallbackId !== undefined ? { root: taskRoot, project: { id: fallbackId, source: "declared" } } : { root: taskRoot };
373
+ const verdict = marker !== null ? { id: marker.projectId, source: "marker" }
374
+ : declaredId !== undefined ? { id: declaredId, source: "declared" }
375
+ : inherited !== undefined ? { id: normalizeProjectId(inherited.id), source: "declared" }
376
+ : undefined;
377
+ if (verdict === undefined)
378
+ return { root: taskRoot };
379
+ const owner = declared ?? (inherited !== undefined && normalizeProjectId(inherited.id) === verdict.id ? inherited : undefined);
380
+ return { root: taskRoot, project: verdict, seat: Object.freeze({ ...owner, id: verdict.id }) };
381
381
  }
382
382
  export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
383
383
  const consumesProjectIdentity = [...scopes, ...(writeScope !== null ? [writeScope] : [])]
@@ -393,10 +393,10 @@ export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
393
393
  const verdict = sessionProject.project;
394
394
  if (verdict === undefined) {
395
395
  throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
396
- `but this leg has no project verdict (no .sema/project marker and no TaskSpec.projectId) — refusing a project-scoped write without a project identity.`, { kind: "write_without_verdict", writeScope, writeProjectId: w.projectId });
396
+ `but this leg has no project verdict (no .sema/project marker and no TaskSpec.project) — refusing a project-scoped write without a project identity.`, { kind: "write_without_verdict", writeScope, writeProjectId: w.projectId });
397
397
  }
398
398
  if (normalizeProjectId(w.projectId) !== normalizeProjectId(verdict.id)) {
399
399
  throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
400
- `but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.projectId"}) is ${verdict.id} — refusing a mis-addressed write.`, { kind: "write_project_mismatch", writeScope, writeProjectId: w.projectId, verdictProjectId: verdict.id, verdictSource: verdict.source });
400
+ `but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.project.id"}) is ${verdict.id} — refusing a mis-addressed write.`, { kind: "write_project_mismatch", writeScope, writeProjectId: w.projectId, verdictProjectId: verdict.id, verdictSource: verdict.source });
401
401
  }
402
402
  }
@@ -3,13 +3,14 @@ import { screenInboundEntries } from "./data-plane.js";
3
3
  import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
4
4
  import { MAX_MEMORY_BYTES } from "../memory.js";
5
5
  import { reconcileMemoryEntries } from "./sync.js";
6
+ import { memoryDeletionRecords } from "./deletion-record.js";
6
7
  import { MEMORY_ORIGIN_CAUSES } from "./types.js";
7
8
  import { directoryPinOf, landingPathOf } from "./layout.js";
8
9
  import { egressText } from "../untrusted-egress.js";
9
10
  import { REDACTION_MARKS, userinfoHolds } from "@sema-agent/primitives";
10
11
  import { isReplicableScope } from "./scope-contract.js";
11
12
  const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
12
- "and entries deleted on one side since the last round come back from the other side";
13
+ "and entries deleted on one side since the last round come back from the other side unless that side's store records the deletion and reads it";
13
14
  const REFUSAL_ROWS = {
14
15
  scope: {
15
16
  why: "a cursor is the baseline of one (scope, peer) partition",
@@ -38,8 +39,8 @@ const REFUSAL_ROWS = {
38
39
  outs: () => [
39
40
  "rebind — when this store holds the entries the baseline was taken over (the same store, moved to this root or bound before " +
40
41
  "cursors carried a store), persist the cursor with its store set to this store's identity (memorySyncStoreOf) and sync again",
41
- "clear — delete the cursor and sync from none, accepting that an entry deleted on either side since the last completed round " +
42
- "comes back from the other side",
42
+ "clear — delete the cursor and sync from none, accepting that deletions without a baseline no longer cross and an entry deleted on either side since the last completed round " +
43
+ "comes back from the other side unless that side's store records the deletion and reads it (a recorded deletion blocks landing as a conflict and never deletes on the peer)",
43
44
  ],
44
45
  },
45
46
  "store-plane": {
@@ -444,7 +445,26 @@ export async function syncMemoryScope(opts) {
444
445
  });
445
446
  }
446
447
  }
447
- for (const f of screenInboundEntries(resp.serverEntries.filter((e) => !rejected.has(e.id)))) {
448
+ const heldIds = new Set(fetched.map((e) => e.id));
449
+ const unbaselined = resp.serverEntries.filter((e) => !rejected.has(e.id) && baseRevs[e.id] === undefined && !heldIds.has(e.id));
450
+ const deletionBlocked = new Set();
451
+ if (unbaselined.length > 0) {
452
+ const judged = reconcileMemoryEntries({}, [], unbaselined, { local: await memoryDeletionRecords(backend, unbaselined.map((e) => e.id), scope) });
453
+ for (const c of judged.conflicts) {
454
+ deletionBlocked.add(c.id);
455
+ const record = c.deletion?.record;
456
+ conflicts.push({
457
+ side: "local",
458
+ id: c.id,
459
+ reason: record?.kind === "undecidable"
460
+ ? `deletion_record_unreadable: the center offers ${JSON.stringify(c.id)}, which this store does not hold, and whether this store deleted it cannot be read (${record.why}) — not brought back`
461
+ : `deleted_here: this store deleted ${JSON.stringify(c.id)}${c.baseRev !== undefined ? ` at rev ${JSON.stringify(c.baseRev)}` : ""} and the center offers it at rev ${JSON.stringify(c.remote?.rev)} — not brought back (re-judged next round; nothing deleted on the center)`,
462
+ ...(c.remote?.rev !== undefined ? { currentRev: c.remote.rev } : {}),
463
+ });
464
+ }
465
+ }
466
+ const landable = (id) => !rejected.has(id) && !deletionBlocked.has(id);
467
+ for (const f of screenInboundEntries(resp.serverEntries.filter((e) => landable(e.id)))) {
448
468
  rejected.add(f.id);
449
469
  conflicts.push({
450
470
  side: "local",
@@ -491,7 +511,7 @@ export async function syncMemoryScope(opts) {
491
511
  }
492
512
  const patches = [
493
513
  ...resp.serverEntries
494
- .filter((e) => !rejected.has(e.id))
514
+ .filter((e) => landable(e.id))
495
515
  .map((e) => {
496
516
  const base = baseRevs[e.id];
497
517
  return base !== undefined
@@ -514,7 +534,7 @@ export async function syncMemoryScope(opts) {
514
534
  let nextCursor = cursor;
515
535
  const warnings = [];
516
536
  if (cursorAdvanced) {
517
- const pulledRevById = new Map(resp.serverEntries.map((e) => [e.id, e.rev]));
537
+ const pulledRevById = new Map(resp.serverEntries.filter((e) => landable(e.id)).map((e) => [e.id, e.rev]));
518
538
  const pushedRevById = new Map(request.entries.map((e) => [e.id, e.rev]));
519
539
  const serverAppliedIds = new Set(resp.applied.filter((a) => a.op !== "delete").map((a) => a.id));
520
540
  const disputedIds = new Set(resp.conflicts.map((c) => c.id));
@@ -1,4 +1,5 @@
1
1
  import type { MemoryEntry, ScoredMemoryEntry } from "./types.js";
2
+ import type { DeletionRecord } from "./deletion-record.js";
2
3
  /**
3
4
  * design/142 §3 — the per-replica per-scope sync cursor: the COMMON BASELINE a reconciliation run
4
5
  * judges divergence against (`id → rev` as of the last completed sync round). This is a NEW
@@ -36,6 +37,20 @@ export interface MemorySyncConflict {
36
37
  local?: MemoryEntry;
37
38
  remote?: MemoryEntry;
38
39
  baseRev?: string;
40
+ /** Present when no baseline answered for the id and the absent side's deletion record blocked it from landing on that
41
+ * side: `record` is that side's answer (`deleted` at any version — `baseRev` carries the deleted version when known —
42
+ * or `undecidable`). A deletion record never emits a delete for the other side. */
43
+ deletion?: {
44
+ side: "local" | "remote";
45
+ record: DeletionRecord;
46
+ };
47
+ }
48
+ /** Each side's deletion records for ids it does not hold (`memoryDeletionRecords`): consulted only for an id present on
49
+ * the other side with no baseline. A side whose records are not given is judged as holding none — the caller holding
50
+ * that side's store passes them (a client's push half leaves the peer's side to the peer, which judges it). */
51
+ export interface MemorySyncDeletions {
52
+ local?: ReadonlyMap<string, DeletionRecord>;
53
+ remote?: ReadonlyMap<string, DeletionRecord>;
39
54
  }
40
55
  export interface MemorySyncPlan {
41
56
  /** Entries the LOCAL side should send to the peer (new here or changed-here-only). 独立轨 F8 —
@@ -77,10 +92,13 @@ export interface MemorySyncPlan {
77
92
  * - changed on BOTH sides, or delete-on-one × edit-on-the-other → conflict (caller's ladder);
78
93
  * - deleted on one side × UNCHANGED on the other → the delete propagates (deleteLocal/deleteRemote,
79
94
  * CAS on baseRev: without this leg removals never cross and the plan livelocks);
80
- * - present only on one side with NO baseline → new entry → propagate;
95
+ * - present only on one side with NO baseline → the absent side's deletion record ({@link MemorySyncDeletions}) decides
96
+ * only whether the id may land on that side: `never` (or omitted) ⇒ new entry → propagate; deleted (at any version)
97
+ * or `undecidable` ⇒ conflict carrying `deletion`, never a delete on the present side. Deletions cross only where a
98
+ * baseline exists;
81
99
  * - absent on both but present in baseline → cleared (cursor cleanup).
82
100
  */
83
- export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): MemorySyncPlan;
101
+ export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[], deletions?: MemorySyncDeletions): MemorySyncPlan;
84
102
  /** The baseline to persist AFTER a sync round completes: every id both sides now agree on. The
85
103
  * caller passes the POST-round entry sets (after applying push/pull and resolving conflicts). */
86
104
  export declare function nextSyncBaseline(local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): Record<string, string>;
@@ -1,4 +1,4 @@
1
- export function reconcileMemoryEntries(baseRevs, local, remote) {
1
+ export function reconcileMemoryEntries(baseRevs, local, remote, deletions) {
2
2
  const plan = { push: [], pull: [], deleteLocal: [], deleteRemote: [], conflicts: [], cleared: [] };
3
3
  const localById = new Map(local.map((e) => [e.id, e]));
4
4
  const remoteById = new Map(remote.map((e) => [e.id, e]));
@@ -20,22 +20,23 @@ export function reconcileMemoryEntries(baseRevs, local, remote) {
20
20
  plan.pull.push(r);
21
21
  continue;
22
22
  }
23
- if (l !== undefined) {
24
- if (base === undefined)
25
- plan.push.push(l);
26
- else if (l.rev !== base)
27
- plan.conflicts.push({ id, local: l, baseRev: base });
28
- else
29
- plan.deleteLocal.push({ id, baseRev: base });
30
- continue;
31
- }
32
- if (r !== undefined) {
33
- if (base === undefined)
34
- plan.pull.push(r);
35
- else if (r.rev !== base)
36
- plan.conflicts.push({ id, remote: r, baseRev: base });
37
- else
38
- plan.deleteRemote.push({ id, baseRev: base });
23
+ if (l !== undefined || r !== undefined) {
24
+ const present = (l ?? r);
25
+ const side = l !== undefined ? { local: l } : { remote: r };
26
+ if (base !== undefined) {
27
+ if (present.rev !== base)
28
+ plan.conflicts.push({ id, ...side, baseRev: base });
29
+ else
30
+ (l !== undefined ? plan.deleteLocal : plan.deleteRemote).push({ id, baseRev: base });
31
+ }
32
+ else {
33
+ const absentSide = l !== undefined ? "remote" : "local";
34
+ const record = deletions?.[absentSide]?.get(id);
35
+ if (record === undefined || record.kind === "never")
36
+ (l !== undefined ? plan.push : plan.pull).push(present);
37
+ else
38
+ plan.conflicts.push({ id, ...side, ...(record.kind === "deleted" && record.rev !== undefined ? { baseRev: record.rev } : {}), deletion: { side: absentSide, record } });
39
+ }
39
40
  continue;
40
41
  }
41
42
  plan.cleared.push(id);
@@ -163,11 +163,15 @@ export declare function createModeGatePolicy(modeRef: {
163
163
  readonly current: PermissionMode;
164
164
  }, seats: ModeGateSeats): ToolPolicy;
165
165
  /**
166
- * The mode a resumed leg REQUESTS: the re-passed spec's word, else the word the checkpoint row recorded — except where the
167
- * resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the one answer the
168
- * pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the word the leg had before it
169
- * (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the leg's own default),
170
- * unless the resume names another mode — the approver's choice. A re-passed `plan` does not keep an approved plan open.
166
+ * The mode a resumed leg REQUESTS. Without a mode the approval names: the re-passed spec's word, else the word the checkpoint row
167
+ * recorded — except where the resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the
168
+ * one answer the pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the resume's word, else to the
169
+ * word the leg had before it (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the
170
+ * leg's own default). A re-passed `plan` does not keep an approved plan open.
171
+ * The mode the person's approval names (`outcome.permissionMode`, the one the decided row records), on whatever row it decides: a
172
+ * tightening of that mode holds unconditionally; a widening holds only where the ceiling it is folded under is known — the parent's
173
+ * mode with the deployment's cap (the leg's ceilings fold it after). A leg with a parent whose mode this resume was not handed
174
+ * (`parentModeUnknown`) has no known ceiling: the widening is withheld and the leg requests the mode it would without it.
171
175
  */
172
176
  export declare function modeRequestAfterResume(seat: PermissionMode | undefined, recorded: {
173
177
  readonly permissionMode?: PermissionMode;
@@ -175,7 +179,18 @@ export declare function modeRequestAfterResume(seat: PermissionMode | undefined,
175
179
  }, outcome: {
176
180
  readonly gate: string;
177
181
  readonly decision?: string;
178
- } | undefined): PermissionMode | undefined;
182
+ readonly permissionMode?: PermissionMode;
183
+ } | undefined, parentModeUnknown?: true): PermissionMode | undefined;
184
+ /** The mode an approval named that {@link modeRequestAfterResume} withholds (a widening with no known ceiling), else `undefined` —
185
+ * the one fact a leg says when it does not take the mode a person approved. */
186
+ export declare function withheldApprovalMode(seat: PermissionMode | undefined, recorded: {
187
+ readonly permissionMode?: PermissionMode;
188
+ readonly prePlanMode?: PermissionMode;
189
+ }, outcome: {
190
+ readonly gate: string;
191
+ readonly decision?: string;
192
+ readonly permissionMode?: PermissionMode;
193
+ } | undefined, parentModeUnknown?: true): PermissionMode | undefined;
179
194
  /**
180
195
  * The permission MODE's door — two refusals in the pre-first-await stretch, each by name and never a fold back to
181
196
  * absence (a mode a caller believes it declared must not silently run as another): a `permissionMode` outside
@@ -256,6 +271,7 @@ export interface PermissionModeFold {
256
271
  * announced for a word nobody asked for — and the leg declares `default`. A word somebody asked for (the caller, a steer, the
257
272
  * word a checkpoint recorded because the leg ran under it) folds as it always does, announced.
258
273
  * A static answer: an arming that fails at run time (the classifier's leg cannot be built) is not foreseen here.
274
+ * A `requested`, `ceiling` or `whenUnset` outside its set is refused (`config.permission_mode_invalid`, `detail.field` names which).
259
275
  */
260
276
  export declare function foldPermissionMode(input: PermissionModeFoldInput): PermissionModeFold;
261
277
  /** `RunnerDeps.permissionModeWhenUnset` read: absent, or a start word — anything else is refused by name, never read as `default`. */
@@ -347,6 +363,9 @@ export declare class PermissionModeController {
347
363
  * A decision read is what starts it; an observation that did would arm a leg earlier than its own gate, and so move
348
364
  * who answers the leg's next ask. */
349
365
  get observed(): PermissionMode;
366
+ /** The effective mode this leg would run under were `word` asked for now — the same fold ({@link foldPermissionMode}) over the
367
+ * same ceiling (observed) and arming facts, with `word` as the request; an observation: nothing is steered, armed or announced. */
368
+ armsAs(word: PermissionMode): PermissionMode;
350
369
  /** The three-member answer as it stands right now. */
351
370
  receipt(): PermissionModeReceipt;
352
371
  private receiptOf;
@@ -106,11 +106,17 @@ export function createModeGatePolicy(modeRef, seats) {
106
106
  },
107
107
  };
108
108
  }
109
- export function modeRequestAfterResume(seat, recorded, outcome) {
110
- const exitsPlan = outcome !== undefined && outcome.decision !== "reject" && approvalRequestsPlanExit(outcome.gate, recorded.permissionMode);
111
- if (!exitsPlan)
112
- return seat ?? recorded.permissionMode;
113
- return seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
109
+ export function modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) {
110
+ const approved = outcome !== undefined && outcome.decision !== "reject";
111
+ const unnamed = !approved || !approvalRequestsPlanExit(outcome.gate, recorded.permissionMode) ? (seat ?? recorded.permissionMode) : seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
112
+ const named = approved ? outcome.permissionMode : undefined;
113
+ if (named === undefined)
114
+ return unnamed;
115
+ return parentModeUnknown !== true || clampPermissionMode(named, unnamed ?? "default").effective === named ? named : unnamed;
116
+ }
117
+ export function withheldApprovalMode(seat, recorded, outcome, parentModeUnknown) {
118
+ const named = outcome !== undefined && outcome.decision !== "reject" ? outcome.permissionMode : undefined;
119
+ return named !== undefined && modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) !== named ? named : undefined;
114
120
  }
115
121
  export function refusePermissionModeDoors(spec) {
116
122
  const mode = spec.permissionMode;
@@ -153,9 +159,21 @@ function autoModeArmFactOf(word, a) {
153
159
  }
154
160
  return { armed: true, reason: "armed" };
155
161
  }
162
+ function refuseFoldModeWord(field, value, allowed) {
163
+ const e = new Error(`foldPermissionMode: ${field} must be one of ${allowed.map((w) => JSON.stringify(w)).join(", ")} when present (got ${describeRejectedValue(value)}) — omit it to leave it unset.`);
164
+ e.code = "config.permission_mode_invalid";
165
+ e.detail = { field };
166
+ throw e;
167
+ }
156
168
  export function foldPermissionMode(input) {
157
- const { requested, ceiling, arming } = input;
158
- const { effective: word, clamped } = ceiling === undefined ? { effective: requested ?? input.whenUnset ?? "default", clamped: false } : clampPermissionMode(requested, ceiling);
169
+ const { requested, ceiling, whenUnset, arming } = input;
170
+ if (requested !== undefined && !isPermissionMode(requested))
171
+ refuseFoldModeWord("requested", requested, PERMISSION_MODES);
172
+ if (ceiling !== undefined && !isPermissionMode(ceiling))
173
+ refuseFoldModeWord("ceiling", ceiling, PERMISSION_MODES);
174
+ if (whenUnset !== undefined && !PERMISSION_MODE_START_WORDS.includes(whenUnset))
175
+ refuseFoldModeWord("whenUnset", whenUnset, PERMISSION_MODE_START_WORDS);
176
+ const { effective: word, clamped } = ceiling === undefined ? { effective: requested ?? whenUnset ?? "default", clamped: false } : clampPermissionMode(requested, ceiling);
159
177
  const base = requested !== undefined ? { requested } : {};
160
178
  const autoMode = arming === undefined ? undefined : autoModeArmFactOf(word, arming);
161
179
  const armed = autoMode !== undefined ? { autoMode } : {};
@@ -236,13 +254,20 @@ export class PermissionModeController {
236
254
  const arming = this.arming;
237
255
  if (effective === "auto" && !this.armedForAuto && arming?.armAuto !== undefined) {
238
256
  this.armedForAuto = true;
239
- void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault"));
257
+ void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => {
258
+ this.armedForAuto = false;
259
+ this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault");
260
+ });
240
261
  }
241
262
  return effective;
242
263
  }
243
264
  get observed() {
244
265
  return this.receiptOf(true).effective;
245
266
  }
267
+ armsAs(word) {
268
+ const ceiling = this.ceilingNow(true);
269
+ return foldPermissionMode({ requested: word, ...(ceiling !== undefined ? { ceiling } : {}), ...(this.whenUnset !== undefined ? { whenUnset: this.whenUnset } : {}), ...(this.arming !== undefined ? { arming: this.arming } : {}) }).receipt.effective;
270
+ }
246
271
  receipt() {
247
272
  return this.receiptOf(false);
248
273
  }
@@ -97,14 +97,16 @@ export interface Brain {
97
97
  * per-call identity the request is dispatched with (the `getApiKeyAndHeaders` result), so a seat can
98
98
  * judge the exact request it is about to make. The engine's model lane asks it before EVERY hop it
99
99
  * dispatches — the requested model first — and does not dispatch a hop it refuses (the walk moves on;
100
- * no hop served ⇒ the requested model's refusal is the answer). First-party brains implement it against
100
+ * no hop served ⇒ the requested model's refusal is the answer); a failover chain also asks each leg right
101
+ * before it sends that leg, and does not send a leg that does not go ahead. First-party brains implement it against
101
102
  * their own config; the decorators (routing/failover/circuit-breaker) and the engine's model lane
102
103
  * re-dispatch it the way their `stream` would. `undefined` = this brain cannot judge (a custom brain
103
104
  * without the face) — callers must treat that as "no judgment", never as OK or as broken. A refusal is
104
105
  * an `ok: false` verdict, never a throw (the first-party faces include the per-call key handed beside its
105
106
  * lane's own key header, `route.credential_answer_conflict`). It answers SYNCHRONOUSLY. A throw, a Promise or
106
- * any other answer that is not a verdict is a defect — the model lane and a derived seat's pre-flight read
107
- * it as the route refused (`route.judgment_failed`), a failover chain's face a throw as that leg refused.
107
+ * any other answer that is not a verdict is a defect — the model lane, a derived seat's pre-flight and a failover
108
+ * chain's ask before a leg read it as the route refused (`route.judgment_failed`), a failover chain's face a throw as
109
+ * that leg refused.
108
110
  *
109
111
  * The same law runs again inside the first-party brains' request build (single source, called
110
112
  * twice): a broken pairing that skips the pre-flight still refuses loudly at the request instead
@@ -118,8 +120,9 @@ export interface Brain {
118
120
  * only hop of a request with no chain, the first hop of a walk), `"fallback"` for a later hop of its chain. Present ONLY on that ask: a
119
121
  * refusal answered to it means the call was not sent (save a request cancelled while it was judged: the Brain answers that one,
120
122
  * aborted). Absent on every other ask (a read face such as `routePairingStatus`, a derived seat's pre-flight, a host's own check).
121
- * The engine's one-target decorators hand it on as they hand on the second argument; a failover chain asks its legs without it (its
122
- * judgment is the chain's — which leg is sent is decided after); a host's own decorator hands it on to be heard below it.
123
+ * The engine's one-target decorators hand it on as they hand on the second argument; a failover chain asks its legs without it, both
124
+ * when it judges for the chain and when it asks a leg right before sending it (the gateway does not know which hop of a walk it
125
+ * serves); a host's own decorator hands it on to be heard below it.
123
126
  */
124
127
  export interface RouteJudgmentDispatch {
125
128
  readonly hop: "requested" | "fallback";