@sema-agent/core 7.54.1 → 7.56.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 (621) hide show
  1. package/CHANGELOG.md +950 -0
  2. package/dist/agents/agent-transcript-tool.js +2 -1
  3. package/dist/agents/builtin-agents.d.ts +12 -14
  4. package/dist/agents/cascade.js +1 -1
  5. package/dist/agents/cc-peer-directory.d.ts +36 -0
  6. package/dist/agents/cc-peer-directory.js +139 -0
  7. package/dist/agents/cc-peer-wire.d.ts +105 -0
  8. package/dist/agents/cc-peer-wire.js +98 -0
  9. package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
  10. package/dist/agents/cc-uds-peer-channel.js +457 -0
  11. package/dist/agents/child-model-seat.d.ts +0 -11
  12. package/dist/agents/child-model-seat.js +0 -3
  13. package/dist/agents/cross-session-envelope.d.ts +4 -1
  14. package/dist/agents/cross-session-envelope.js +8 -1
  15. package/dist/agents/cross-session-judge.d.ts +2 -2
  16. package/dist/agents/list-agents-tool.d.ts +3 -1
  17. package/dist/agents/list-agents-tool.js +9 -8
  18. package/dist/agents/observer.d.ts +4 -5
  19. package/dist/agents/observer.js +2 -1
  20. package/dist/agents/peer-admission.d.ts +6 -0
  21. package/dist/agents/peer-admission.js +4 -1
  22. package/dist/agents/peer-directory.d.ts +65 -13
  23. package/dist/agents/peer-directory.js +90 -25
  24. package/dist/agents/peer-notices.d.ts +1 -1
  25. package/dist/agents/peer-session-drain.d.ts +3 -1
  26. package/dist/agents/peer-session-drain.js +3 -2
  27. package/dist/agents/read-inbox-tool.js +2 -1
  28. package/dist/agents/repair-loop.js +2 -2
  29. package/dist/agents/retain-ledger.d.ts +1 -1
  30. package/dist/agents/roster-store.d.ts +1 -1
  31. package/dist/agents/send-message-tool.d.ts +10 -0
  32. package/dist/agents/send-message-tool.js +37 -8
  33. package/dist/agents/subagent.d.ts +39 -82
  34. package/dist/agents/subagent.js +109 -106
  35. package/dist/agents/tool-filter.d.ts +31 -46
  36. package/dist/agents/tool-filter.js +13 -33
  37. package/dist/agents/verify.d.ts +6 -5
  38. package/dist/agents/verify.js +3 -3
  39. package/dist/brain/anthropic.js +43 -81
  40. package/dist/brain/errors.d.ts +15 -0
  41. package/dist/brain/errors.js +10 -0
  42. package/dist/brain/media-degrade.d.ts +18 -7
  43. package/dist/brain/media-degrade.js +13 -2
  44. package/dist/brain/model-capability.d.ts +37 -0
  45. package/dist/brain/model-capability.js +34 -0
  46. package/dist/brain/model-presets.d.ts +6 -12
  47. package/dist/brain/model-presets.js +1 -6
  48. package/dist/brain/open-responses.js +27 -35
  49. package/dist/brain/openai.js +30 -98
  50. package/dist/brain/provider-dialect.d.ts +39 -3
  51. package/dist/brain/provider-dialect.js +28 -0
  52. package/dist/brain/reasoning-request.d.ts +96 -0
  53. package/dist/brain/reasoning-request.js +174 -0
  54. package/dist/brain/reasoning.d.ts +12 -12
  55. package/dist/brain/reasoning.js +4 -3
  56. package/dist/brain/request-params.d.ts +62 -9
  57. package/dist/brain/request-params.js +42 -7
  58. package/dist/brain/retry.d.ts +1 -1
  59. package/dist/brain/route-adjudicator.d.ts +15 -0
  60. package/dist/brain/route-adjudicator.js +15 -0
  61. package/dist/brain/status-sink.d.ts +20 -0
  62. package/dist/brain/status-sink.js +7 -0
  63. package/dist/brain/stream-engine.js +6 -5
  64. package/dist/brain/stream-shared.d.ts +1 -1
  65. package/dist/core/a2a.d.ts +2 -1
  66. package/dist/core/a2a.js +19 -13
  67. package/dist/core/advisor-verdict.d.ts +120 -0
  68. package/dist/core/advisor-verdict.js +92 -0
  69. package/dist/core/agent-definition.d.ts +17 -8
  70. package/dist/core/allow-entry.d.ts +69 -36
  71. package/dist/core/allow-entry.js +81 -52
  72. package/dist/core/allow-rule-shadow.d.ts +10 -3
  73. package/dist/core/approval-object.d.ts +2 -1
  74. package/dist/core/approval-object.js +6 -6
  75. package/dist/core/ask-origin.d.ts +127 -29
  76. package/dist/core/ask-origin.js +87 -25
  77. package/dist/core/ask-question.d.ts +51 -8
  78. package/dist/core/ask-question.js +12 -7
  79. package/dist/core/ask-unresolvable-notice.d.ts +8 -3
  80. package/dist/core/ask-unresolvable-notice.js +16 -2
  81. package/dist/core/auto-compaction.d.ts +11 -8
  82. package/dist/core/auto-compaction.js +4 -2
  83. package/dist/core/auto-mode-arming.d.ts +2 -2
  84. package/dist/core/auto-mode-defaults.d.ts +8 -8
  85. package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
  86. package/dist/core/auto-mode-prompt.d.ts +1 -1
  87. package/dist/core/auto-mode.d.ts +17 -9
  88. package/dist/core/auto-mode.js +9 -6
  89. package/dist/core/background-agent-store.d.ts +3 -3
  90. package/dist/core/canonical-json.d.ts +1 -1
  91. package/dist/core/canonical-json.js +2 -2
  92. package/dist/core/checkpoint-generation.d.ts +53 -0
  93. package/dist/core/checkpoint-generation.js +35 -0
  94. package/dist/core/checkpoint-queries.d.ts +180 -0
  95. package/dist/core/checkpoint-queries.js +272 -0
  96. package/dist/core/checkpoint-requirements.d.ts +19 -4
  97. package/dist/core/checkpoint-requirements.js +8 -14
  98. package/dist/core/checkpoint-store.d.ts +165 -72
  99. package/dist/core/checkpoint-store.js +79 -82
  100. package/dist/core/child-clamp-seats.d.ts +6 -0
  101. package/dist/core/child-clamp-seats.js +3 -16
  102. package/dist/core/compliance.d.ts +2 -2
  103. package/dist/core/context-edit.d.ts +6 -7
  104. package/dist/core/cross-boundary-taint.d.ts +11 -4
  105. package/dist/core/cross-boundary-taint.js +3 -3
  106. package/dist/core/decision-receipt.d.ts +37 -3
  107. package/dist/core/decision-receipt.js +19 -19
  108. package/dist/core/delegation-not-started.d.ts +6 -0
  109. package/dist/core/delegation-not-started.js +17 -0
  110. package/dist/core/effective-path-target.d.ts +1 -1
  111. package/dist/core/engine-attestation.d.ts +93 -0
  112. package/dist/core/engine-attestation.js +70 -0
  113. package/dist/core/engine-capabilities.d.ts +4 -1
  114. package/dist/core/engine-capabilities.js +1 -1
  115. package/dist/core/engine-notice.d.ts +45 -12
  116. package/dist/core/exec-output-tail.d.ts +1 -1
  117. package/dist/core/file-history-retention.d.ts +1 -1
  118. package/dist/core/file-history-store.d.ts +147 -21
  119. package/dist/core/file-history-store.js +58 -32
  120. package/dist/core/gate-fold.d.ts +1 -1
  121. package/dist/core/gate-fold.js +24 -11
  122. package/dist/core/gate-lanes.js +81 -68
  123. package/dist/core/gate-outcome.d.ts +40 -6
  124. package/dist/core/gate-outcome.js +56 -0
  125. package/dist/core/governance-codes.d.ts +17 -3
  126. package/dist/core/governance-codes.js +16 -0
  127. package/dist/core/hands-band.d.ts +1 -1
  128. package/dist/core/hooks.d.ts +21 -20
  129. package/dist/core/hooks.js +3 -1
  130. package/dist/core/host-floor.d.ts +128 -0
  131. package/dist/core/host-floor.js +206 -0
  132. package/dist/core/host-target.d.ts +84 -0
  133. package/dist/core/host-target.js +92 -0
  134. package/dist/core/image-downsample.d.ts +1 -1
  135. package/dist/core/lsp-diagnostics.d.ts +4 -4
  136. package/dist/core/lsp.d.ts +3 -3
  137. package/dist/core/mailbox-store.d.ts +4 -0
  138. package/dist/core/mcp-connection-pool.d.ts +18 -2
  139. package/dist/core/mcp-connection-pool.js +53 -6
  140. package/dist/core/mcp-failure.d.ts +23 -4
  141. package/dist/core/mcp-failure.js +26 -11
  142. package/dist/core/mcp-listing-drift.d.ts +10 -0
  143. package/dist/core/mcp-listing-drift.js +6 -0
  144. package/dist/core/mcp-server-link.d.ts +173 -0
  145. package/dist/core/mcp-server-link.js +127 -0
  146. package/dist/core/mcp-server-spec.d.ts +4 -2
  147. package/dist/core/mcp-session-end.d.ts +26 -0
  148. package/dist/core/mcp-session-end.js +29 -0
  149. package/dist/core/mcp-startup-request.d.ts +17 -0
  150. package/dist/core/mcp-startup-request.js +17 -0
  151. package/dist/core/mcp.d.ts +17 -13
  152. package/dist/core/mcp.js +240 -189
  153. package/dist/core/media-byte-cap.d.ts +1 -1
  154. package/dist/core/memory-engine/delegation-settlement.js +15 -24
  155. package/dist/core/memory-engine/engine.d.ts +9 -9
  156. package/dist/core/memory-engine/engine.js +4 -4
  157. package/dist/core/memory-engine/layout.d.ts +60 -8
  158. package/dist/core/memory-engine/layout.js +65 -6
  159. package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
  160. package/dist/core/memory-engine/tools.js +4 -1
  161. package/dist/core/mode-policy.d.ts +1 -1
  162. package/dist/core/model-seat.d.ts +10 -3
  163. package/dist/core/mods/classic-events.d.ts +67 -0
  164. package/dist/core/mods/classic-events.js +1 -0
  165. package/dist/core/mods/dollar.d.ts +13 -0
  166. package/dist/core/mods/extension-call.d.ts +31 -0
  167. package/dist/core/mods/extension-call.js +43 -0
  168. package/dist/core/mods/kernel/dispatch.d.ts +20 -3
  169. package/dist/core/mods/kernel/dispatch.js +140 -69
  170. package/dist/core/mods/kernel/events.d.ts +47 -11
  171. package/dist/core/mods/kernel/events.js +66 -42
  172. package/dist/core/mods/kernel/index.d.ts +4 -4
  173. package/dist/core/mods/kernel/index.js +2 -2
  174. package/dist/core/mods/kernel/receive.d.ts +39 -5
  175. package/dist/core/mods/kernel/receive.js +290 -17
  176. package/dist/core/mods/kernel/registration.d.ts +33 -2
  177. package/dist/core/mods/kernel/registration.js +6 -7
  178. package/dist/core/mods/kernel/site-rules.d.ts +44 -16
  179. package/dist/core/mods/kernel/site-rules.js +24 -42
  180. package/dist/core/mods/spec-seats.d.ts +69 -0
  181. package/dist/core/mods/spec-seats.js +114 -0
  182. package/dist/core/mods/stations.d.ts +28 -8
  183. package/dist/core/mods/stations.js +29 -13
  184. package/dist/core/mods/tool-call.d.ts +79 -0
  185. package/dist/core/mods/tool-call.js +152 -0
  186. package/dist/core/namespaced-rule-name.d.ts +44 -24
  187. package/dist/core/namespaced-rule-name.js +50 -43
  188. package/dist/core/output-style.d.ts +1 -1
  189. package/dist/core/param-rule-reach.d.ts +15 -0
  190. package/dist/core/param-rule-reach.js +30 -0
  191. package/dist/core/parent-spec-seat.d.ts +13 -1
  192. package/dist/core/parent-spec-seat.js +6 -0
  193. package/dist/core/park-selfcheck.js +1 -0
  194. package/dist/core/pause-registry.d.ts +16 -5
  195. package/dist/core/pause-registry.js +6 -2
  196. package/dist/core/peer-channel.d.ts +70 -0
  197. package/dist/core/peer-channel.js +1 -0
  198. package/dist/core/permission-rule-consent.d.ts +30 -5
  199. package/dist/core/permission-rule-consent.js +147 -50
  200. package/dist/core/permission-rule-model.d.ts +245 -65
  201. package/dist/core/permission-rule-model.js +421 -107
  202. package/dist/core/permission-rule-org.d.ts +6 -2
  203. package/dist/core/permission-rule-org.js +7 -3
  204. package/dist/core/permission-rule-provider.d.ts +6 -2
  205. package/dist/core/permission-rule-provider.js +41 -11
  206. package/dist/core/permission-rule-store.d.ts +22 -26
  207. package/dist/core/permission-rule-store.js +12 -6
  208. package/dist/core/permission-rule-sync.d.ts +11 -2
  209. package/dist/core/permission-rule-sync.js +11 -3
  210. package/dist/core/permission-rule-syntax.d.ts +5 -4
  211. package/dist/core/permission-rule-syntax.js +2 -2
  212. package/dist/core/permission-rules.d.ts +53 -15
  213. package/dist/core/permission-rules.js +125 -100
  214. package/dist/core/persisted-rule-arms.d.ts +6 -4
  215. package/dist/core/persisted-rule-arms.js +10 -12
  216. package/dist/core/present-plan-tool.js +3 -1
  217. package/dist/core/principal-name.d.ts +20 -0
  218. package/dist/core/principal-name.js +22 -0
  219. package/dist/core/prompt-section-seat.js +4 -6
  220. package/dist/core/protocol-http-auth.d.ts +26 -5
  221. package/dist/core/protocol-http-auth.js +137 -4
  222. package/dist/core/protocol-naming.d.ts +2 -2
  223. package/dist/core/read-only-shell-table.d.ts +1 -1
  224. package/dist/core/read-only-shell.d.ts +1 -1
  225. package/dist/core/retired-keys.d.ts +16 -0
  226. package/dist/core/retired-keys.js +16 -4
  227. package/dist/core/rewrite-rejudge.d.ts +60 -0
  228. package/dist/core/rewrite-rejudge.js +36 -0
  229. package/dist/core/roles.d.ts +34 -3
  230. package/dist/core/roles.js +66 -53
  231. package/dist/core/rule-lane-reads.d.ts +20 -15
  232. package/dist/core/rule-lane-reads.js +45 -17
  233. package/dist/core/rule-offer-read.d.ts +53 -0
  234. package/dist/core/rule-offer-read.js +146 -0
  235. package/dist/core/rule-owner.d.ts +46 -0
  236. package/dist/core/rule-owner.js +29 -0
  237. package/dist/core/runner/advisor-instructions.d.ts +70 -0
  238. package/dist/core/runner/advisor-instructions.js +61 -0
  239. package/dist/core/runner/advisor-tool.d.ts +33 -0
  240. package/dist/core/runner/advisor-tool.js +112 -0
  241. package/dist/core/runner/announce-once-ledger.d.ts +18 -26
  242. package/dist/core/runner/announce-once-ledger.js +19 -46
  243. package/dist/core/runner/approval-feedback.js +6 -3
  244. package/dist/core/runner/assemble-result.d.ts +2 -1
  245. package/dist/core/runner/assemble-result.js +1 -1
  246. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  247. package/dist/core/runner/caller-roster.d.ts +21 -2
  248. package/dist/core/runner/caller-roster.js +38 -0
  249. package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
  250. package/dist/core/runner/capability-withheld-seat.js +24 -0
  251. package/dist/core/runner/classifier-ladder.d.ts +33 -13
  252. package/dist/core/runner/classifier-ladder.js +15 -14
  253. package/dist/core/runner/compaction-restate.d.ts +10 -6
  254. package/dist/core/runner/compaction-restate.js +9 -3
  255. package/dist/core/runner/construction-doors.js +3 -0
  256. package/dist/core/runner/contracts.d.ts +40 -33
  257. package/dist/core/runner/conversation-segment.d.ts +28 -0
  258. package/dist/core/runner/conversation-segment.js +42 -0
  259. package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
  260. package/dist/core/runner/cross-boundary-lane.js +58 -34
  261. package/dist/core/runner/decide-continuation.d.ts +7 -4
  262. package/dist/core/runner/decide-continuation.js +2 -2
  263. package/dist/core/runner/denial-limit-arms.d.ts +4 -4
  264. package/dist/core/runner/denial-limit-arms.js +1 -1
  265. package/dist/core/runner/derived-route-fallback.d.ts +24 -24
  266. package/dist/core/runner/derived-route-fallback.js +9 -7
  267. package/dist/core/runner/file-history-request.d.ts +18 -0
  268. package/dist/core/runner/file-history-request.js +21 -13
  269. package/dist/core/runner/file-history-restore.d.ts +45 -0
  270. package/dist/core/runner/file-history-restore.js +46 -0
  271. package/dist/core/runner/gate-exit.d.ts +9 -3
  272. package/dist/core/runner/gate-exit.js +11 -5
  273. package/dist/core/runner/image.d.ts +7 -17
  274. package/dist/core/runner/image.js +9 -60
  275. package/dist/core/runner/initial-run-state.js +1 -1
  276. package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
  277. package/dist/core/runner/permission-rule-lanes.js +38 -15
  278. package/dist/core/runner/person-path-rows.d.ts +12 -9
  279. package/dist/core/runner/person-path-rows.js +19 -8
  280. package/dist/core/runner/prepare-advisor.d.ts +63 -0
  281. package/dist/core/runner/prepare-advisor.js +77 -0
  282. package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
  283. package/dist/core/runner/prepare-ask-lane.js +5 -2
  284. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
  285. package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
  286. package/dist/core/runner/prepare-config-doors.d.ts +31 -38
  287. package/dist/core/runner/prepare-config-doors.js +57 -34
  288. package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
  289. package/dist/core/runner/prepare-defer-classify.js +7 -8
  290. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  291. package/dist/core/runner/prepare-delegation-surface.js +1 -1
  292. package/dist/core/runner/prepare-file-history.d.ts +48 -8
  293. package/dist/core/runner/prepare-file-history.js +41 -73
  294. package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
  295. package/dist/core/runner/prepare-gate-stations.js +12 -8
  296. package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
  297. package/dist/core/runner/prepare-hands-readface.js +15 -14
  298. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
  299. package/dist/core/runner/prepare-inherited-gate.js +8 -6
  300. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  301. package/dist/core/runner/prepare-park-ask.js +12 -12
  302. package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
  303. package/dist/core/runner/prepare-policy-chain.js +68 -81
  304. package/dist/core/runner/prepare-project-context.d.ts +5 -2
  305. package/dist/core/runner/prepare-project-context.js +6 -3
  306. package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
  307. package/dist/core/runner/prepare-prompt-assembly.js +10 -8
  308. package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
  309. package/dist/core/runner/prepare-prompt-inputs.js +4 -6
  310. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
  311. package/dist/core/runner/prepare-protocol-tools.js +5 -4
  312. package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
  313. package/dist/core/runner/prepare-safety-scan.js +8 -23
  314. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  315. package/dist/core/runner/prepare-suspend-saga.js +5 -6
  316. package/dist/core/runner/prepare-task.d.ts +1 -1
  317. package/dist/core/runner/prepare-task.js +41 -35
  318. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
  319. package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
  320. package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
  321. package/dist/core/runner/prepare-turn-wiring.js +2 -7
  322. package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
  323. package/dist/core/runner/prepare-wiring-manifest.js +3 -3
  324. package/dist/core/runner/resume-admission.js +1 -1
  325. package/dist/core/runner/resume-apply.js +11 -12
  326. package/dist/core/runner/resume-checkpoint-screen.js +3 -0
  327. package/dist/core/runner/resume-claim.d.ts +4 -2
  328. package/dist/core/runner/resume-claim.js +15 -8
  329. package/dist/core/runner/resume-policy-outcome.js +1 -1
  330. package/dist/core/runner/retired-runner-deps.js +2 -1
  331. package/dist/core/runner/rewind-files.d.ts +15 -0
  332. package/dist/core/runner/rewind-files.js +132 -0
  333. package/dist/core/runner/run-attachment-seats.js +2 -2
  334. package/dist/core/runner/run-brain-sinks.d.ts +4 -1
  335. package/dist/core/runner/run-brain-sinks.js +4 -2
  336. package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
  337. package/dist/core/runner/run-compaction-machinery.js +2 -12
  338. package/dist/core/runner/run-git-lane.d.ts +1 -0
  339. package/dist/core/runner/run-harness-handlers.js +14 -7
  340. package/dist/core/runner/run-leg.d.ts +1 -1
  341. package/dist/core/runner/run-leg.js +43 -18
  342. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  343. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  344. package/dist/core/runner/run-turn-boundary.d.ts +1 -0
  345. package/dist/core/runner/run-turn-boundary.js +15 -22
  346. package/dist/core/runner/runtask.d.ts +3 -0
  347. package/dist/core/runner/runtask.js +8 -9
  348. package/dist/core/runner/session-read-file-states.d.ts +15 -0
  349. package/dist/core/runner/session-read-file-states.js +28 -0
  350. package/dist/core/runner/session-rule-policy.d.ts +22 -21
  351. package/dist/core/runner/session-rule-policy.js +17 -31
  352. package/dist/core/runner/shell-env-withheld.d.ts +33 -0
  353. package/dist/core/runner/shell-env-withheld.js +51 -0
  354. package/dist/core/runner/side-call-account.d.ts +32 -8
  355. package/dist/core/runner/side-call-account.js +23 -1
  356. package/dist/core/runner/skills-seat.js +6 -2
  357. package/dist/core/runner/stream-settle-backstop.js +1 -1
  358. package/dist/core/runner/strict-output-schema.d.ts +1 -1
  359. package/dist/core/runner/sub-agent-deny-lists.js +4 -6
  360. package/dist/core/runner/synthetic-tools.d.ts +16 -13
  361. package/dist/core/runner/synthetic-tools.js +8 -3
  362. package/dist/core/runner/tool-disclosure.d.ts +10 -12
  363. package/dist/core/runner/tool-disclosure.js +3 -4
  364. package/dist/core/runner/tool-end-body.d.ts +1 -1
  365. package/dist/core/runner/tool-end-body.js +10 -9
  366. package/dist/core/runner/tool-face-overlay.d.ts +2 -1
  367. package/dist/core/runner/tool-face-overlay.js +17 -1
  368. package/dist/core/runner/tool-not-executed.d.ts +5 -0
  369. package/dist/core/runner/tool-not-executed.js +11 -0
  370. package/dist/core/runner/tool-occurrence.d.ts +8 -0
  371. package/dist/core/runner/tool-occurrence.js +7 -0
  372. package/dist/core/runner/tool-progress-lane.d.ts +2 -2
  373. package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
  374. package/dist/core/runner/turn-attachments.d.ts +91 -80
  375. package/dist/core/runner/turn-attachments.js +62 -37
  376. package/dist/core/runner-deps.d.ts +42 -42
  377. package/dist/core/runtime-caps.d.ts +4 -4
  378. package/dist/core/safety-axis-vocab.d.ts +6 -4
  379. package/dist/core/safety-axis-vocab.js +6 -5
  380. package/dist/core/safety-merge-corpus.js +26 -2
  381. package/dist/core/same-plain-value.d.ts +40 -0
  382. package/dist/core/same-plain-value.js +49 -0
  383. package/dist/core/scheduler.d.ts +1 -1
  384. package/dist/core/secret-env.d.ts +26 -3
  385. package/dist/core/secret-env.js +44 -8
  386. package/dist/core/select-model.js +3 -3
  387. package/dist/core/sensitive-path-policy.d.ts +1 -1
  388. package/dist/core/sensitive-path-policy.js +1 -1
  389. package/dist/core/session-policy-store.d.ts +102 -35
  390. package/dist/core/session-policy-store.js +210 -48
  391. package/dist/core/session-reconcile.d.ts +2 -2
  392. package/dist/core/session-store.d.ts +106 -37
  393. package/dist/core/session-store.js +165 -91
  394. package/dist/core/session.d.ts +101 -57
  395. package/dist/core/session.js +53 -0
  396. package/dist/core/shared-memory/tools.js +3 -1
  397. package/dist/core/shared-memory/types.d.ts +1 -1
  398. package/dist/core/shell-read-silence.d.ts +11 -12
  399. package/dist/core/shell-read-silence.js +9 -5
  400. package/dist/core/shell-run-candidates.js +3 -1
  401. package/dist/core/shell-wrapper-projection.js +1 -1
  402. package/dist/core/shell-wrapper-table.d.ts +14 -7
  403. package/dist/core/shell-wrapper-table.js +5 -4
  404. package/dist/core/side-query.d.ts +10 -0
  405. package/dist/core/side-query.js +15 -1
  406. package/dist/core/skill-grant.d.ts +7 -2
  407. package/dist/core/skill-grant.js +5 -0
  408. package/dist/core/skills-directory.js +6 -2
  409. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
  410. package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
  411. package/dist/core/store-contracts/file-history-store-contract.js +74 -4
  412. package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
  413. package/dist/core/store-contracts/peer-directory-contract.js +14 -2
  414. package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
  415. package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
  416. package/dist/core/store-contracts/session-repo-contract.js +176 -0
  417. package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
  418. package/dist/core/store-contracts/session-store-contract.js +361 -51
  419. package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
  420. package/dist/core/stub-env.d.ts +2 -0
  421. package/dist/core/stub-env.js +1 -0
  422. package/dist/core/surrogate-safe-slice.d.ts +3 -3
  423. package/dist/core/synthetic-read-verdict.js +3 -3
  424. package/dist/core/task-event.d.ts +42 -8
  425. package/dist/core/task-notification.d.ts +19 -15
  426. package/dist/core/task-registry-agent.d.ts +4 -4
  427. package/dist/core/task-registry-shared.d.ts +4 -4
  428. package/dist/core/task-registry-shared.js +1 -0
  429. package/dist/core/task-registry.d.ts +13 -4
  430. package/dist/core/task-registry.js +14 -2
  431. package/dist/core/task-result.d.ts +21 -3
  432. package/dist/core/task-spec.d.ts +69 -64
  433. package/dist/core/task-stream.d.ts +6 -6
  434. package/dist/core/task-tool-shape.d.ts +4 -4
  435. package/dist/core/tighten-task-spec.d.ts +1 -1
  436. package/dist/core/tighten-task-spec.js +2 -1
  437. package/dist/core/tool-catalog-entries.d.ts +36 -2
  438. package/dist/core/tool-catalog-entries.js +69 -43
  439. package/dist/core/tool-check-reading.d.ts +11 -0
  440. package/dist/core/tool-check-reading.js +11 -6
  441. package/dist/core/tool-conformance.js +1 -0
  442. package/dist/core/tool-errors.d.ts +2 -2
  443. package/dist/core/tool-face-reader.js +5 -3
  444. package/dist/core/tool-face.d.ts +21 -2
  445. package/dist/core/tool-face.js +1 -1
  446. package/dist/core/tool-model-gate.d.ts +5 -5
  447. package/dist/core/tool-name-aliases.d.ts +29 -8
  448. package/dist/core/tool-name-aliases.js +22 -4
  449. package/dist/core/tool-name-readings.d.ts +10 -43
  450. package/dist/core/tool-name-readings.js +2 -11
  451. package/dist/core/tool-policy.d.ts +85 -196
  452. package/dist/core/tool-policy.js +150 -175
  453. package/dist/core/tool-registry.d.ts +14 -7
  454. package/dist/core/tool-registry.js +17 -7
  455. package/dist/core/tool-result-store.js +5 -1
  456. package/dist/core/tool-roster.d.ts +57 -33
  457. package/dist/core/tool-roster.js +56 -68
  458. package/dist/core/tool-spec-members.js +8 -3
  459. package/dist/core/tool-spec.d.ts +53 -31
  460. package/dist/core/tools.js +51 -10
  461. package/dist/core/trace.d.ts +6 -2
  462. package/dist/core/types.d.ts +1 -1
  463. package/dist/core/untrusted-egress.d.ts +1 -1
  464. package/dist/core/untrusted-text.d.ts +1 -1
  465. package/dist/core/user-attachment.d.ts +8 -1
  466. package/dist/core/user-attachment.js +64 -4
  467. package/dist/core/warm-resume.d.ts +1 -1
  468. package/dist/core/wiring-manifest.d.ts +58 -0
  469. package/dist/core/wiring-manifest.js +14 -5
  470. package/dist/core/workflow-journal-store.d.ts +62 -0
  471. package/dist/core/workflow-journal-store.js +78 -2
  472. package/dist/core/workflow-run-store.d.ts +6 -0
  473. package/dist/core/workflow-run-store.js +2 -0
  474. package/dist/engine/compaction/compaction.d.ts +9 -9
  475. package/dist/engine/compaction/compaction.js +3 -2
  476. package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
  477. package/dist/engine/execution-env/node-execution-env.js +54 -24
  478. package/dist/engine/harness/agent-harness.d.ts +39 -9
  479. package/dist/engine/harness/agent-harness.js +87 -33
  480. package/dist/engine/harness/types.d.ts +58 -9
  481. package/dist/engine/harness/types.js +12 -1
  482. package/dist/engine/llm/types.d.ts +36 -19
  483. package/dist/engine/llm/validation.d.ts +4 -1
  484. package/dist/engine/llm/validation.js +13 -1
  485. package/dist/engine/loop/agent-loop.d.ts +23 -1
  486. package/dist/engine/loop/agent-loop.js +26 -34
  487. package/dist/engine/loop/types.d.ts +31 -19
  488. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  489. package/dist/engine/session/memory-repo.d.ts +18 -12
  490. package/dist/engine/session/memory-repo.js +24 -9
  491. package/dist/engine/session/parent-chain-guard.d.ts +3 -2
  492. package/dist/engine/session/parent-chain-guard.js +1 -1
  493. package/dist/engine/session/repo-utils.d.ts +32 -3
  494. package/dist/engine/session/repo-utils.js +50 -5
  495. package/dist/index.d.ts +47 -23
  496. package/dist/index.js +35 -17
  497. package/dist/internal/harness-types.d.ts +1 -1
  498. package/dist/internal/harness.d.ts +3 -3
  499. package/dist/internal/harness.js +2 -2
  500. package/dist/internal/llm.d.ts +2 -2
  501. package/dist/internal/llm.js +1 -1
  502. package/dist/orchestration/goal.js +2 -2
  503. package/dist/orchestration/run-workflow-tool.d.ts +8 -6
  504. package/dist/orchestration/run-workflow-tool.js +10 -6
  505. package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
  506. package/dist/orchestration/workflow-types.d.ts +18 -0
  507. package/dist/orchestration/workflow-types.js +6 -0
  508. package/dist/orchestration/workflow.d.ts +5 -13
  509. package/dist/orchestration/workflow.js +57 -49
  510. package/dist/prompt-assembly/artifact.d.ts +2 -2
  511. package/dist/prompt-assembly/artifact.js +5 -3
  512. package/dist/prompt-assembly/assemble.d.ts +3 -2
  513. package/dist/prompt-assembly/assemble.js +1 -1
  514. package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
  515. package/dist/prompt-assembly/catalog/schema.js +34 -2
  516. package/dist/prompt-assembly/catalog/sections.js +0 -1
  517. package/dist/prompt-assembly/composer.d.ts +3 -1
  518. package/dist/prompt-assembly/composer.js +1 -1
  519. package/dist/prompt-assembly/event-registry.js +2 -0
  520. package/dist/prompt-assembly/overlay.js +3 -3
  521. package/dist/prompt-assembly/renderers.d.ts +1 -1
  522. package/dist/prompt-assembly/renderers.js +0 -3
  523. package/dist/prompt-assembly/role-base.d.ts +15 -0
  524. package/dist/prompt-assembly/role-base.js +9 -0
  525. package/dist/prompt-assembly/select.d.ts +39 -14
  526. package/dist/prompt-assembly/select.js +47 -16
  527. package/dist/prompt-assembly/sugar.d.ts +17 -11
  528. package/dist/prompt-assembly/sugar.js +8 -3
  529. package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
  530. package/dist/prompt-assembly/tool-catalog.js +117 -4
  531. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
  532. package/dist/prompt-assembly/turn-snapshot.js +0 -3
  533. package/dist/prompt-assembly/types.d.ts +0 -7
  534. package/dist/prompts/default.d.ts +14 -14
  535. package/dist/scenarios/full-body.d.ts +15 -15
  536. package/dist/scenarios/full-body.js +4 -3
  537. package/dist/shell/lex.js +10 -1
  538. package/dist/stores/file/adoption/adopt.d.ts +4 -3
  539. package/dist/stores/file/adoption/adopt.js +27 -33
  540. package/dist/stores/file/adoption/marker.d.ts +6 -13
  541. package/dist/stores/file/adoption/marker.js +9 -17
  542. package/dist/stores/file/checkpoint-store.d.ts +24 -0
  543. package/dist/stores/file/checkpoint-store.js +45 -7
  544. package/dist/stores/file/file-history-store.d.ts +20 -19
  545. package/dist/stores/file/file-history-store.js +157 -141
  546. package/dist/stores/file/fs-atomic.d.ts +15 -0
  547. package/dist/stores/file/fs-atomic.js +89 -14
  548. package/dist/stores/file/index.d.ts +1 -1
  549. package/dist/stores/file/index.js +2 -1
  550. package/dist/stores/file/mailbox-store.d.ts +3 -0
  551. package/dist/stores/file/mailbox-store.js +3 -1
  552. package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
  553. package/dist/stores/file/permission-rule-adopt.js +18 -18
  554. package/dist/stores/file/permission-rule-store.d.ts +18 -2
  555. package/dist/stores/file/permission-rule-store.js +31 -18
  556. package/dist/stores/file/session-policy-store.d.ts +3 -3
  557. package/dist/stores/file/session-store.d.ts +54 -16
  558. package/dist/stores/file/session-store.js +114 -85
  559. package/dist/stores/file/workflow-journal-store.d.ts +10 -4
  560. package/dist/stores/file/workflow-journal-store.js +28 -13
  561. package/dist/tools/artifact/artifact-text.d.ts +1 -1
  562. package/dist/tools/artifact/artifact-tool.js +5 -3
  563. package/dist/tools/fs/bash-program-position.d.ts +19 -2
  564. package/dist/tools/fs/bash-program-position.js +56 -9
  565. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
  566. package/dist/tools/fs/fs-bash.d.ts +2 -2
  567. package/dist/tools/fs/fs-bash.js +8 -6
  568. package/dist/tools/fs/fs-glob.d.ts +86 -0
  569. package/dist/tools/fs/fs-glob.js +226 -0
  570. package/dist/tools/fs/fs-read.js +14 -14
  571. package/dist/tools/fs/fs-search-tools.js +7 -7
  572. package/dist/tools/fs/fs-shared.d.ts +8 -8
  573. package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
  574. package/dist/tools/fs/notebook.d.ts +2 -2
  575. package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
  576. package/dist/tools/fs/pattern-kill-guard.js +397 -0
  577. package/dist/tools/fs/pdf.d.ts +9 -6
  578. package/dist/tools/fs/pdf.js +3 -3
  579. package/dist/tools/fs/program-read-model.d.ts +57 -7
  580. package/dist/tools/fs/program-read-model.js +11 -1
  581. package/dist/tools/fs/program-read-model.rows.js +78 -21
  582. package/dist/tools/fs/read-deny-home.js +3 -2
  583. package/dist/tools/fs/read-deny.d.ts +29 -7
  584. package/dist/tools/fs/read-deny.js +63 -22
  585. package/dist/tools/fs/removal-targets.d.ts +18 -8
  586. package/dist/tools/fs/removal-targets.js +47 -20
  587. package/dist/tools/fs/safety.d.ts +9 -9
  588. package/dist/tools/fs/search.d.ts +16 -6
  589. package/dist/tools/fs/search.js +20 -26
  590. package/dist/tools/fs/shell-read-argv.js +89 -12
  591. package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
  592. package/dist/tools/fs/shell-read-bindings.js +41 -0
  593. package/dist/tools/fs/shell-read-check.js +12 -20
  594. package/dist/tools/fs/shell-read-environment.d.ts +5 -1
  595. package/dist/tools/fs/shell-read-environment.js +3 -2
  596. package/dist/tools/fs/shell-read-establish.d.ts +15 -0
  597. package/dist/tools/fs/shell-read-establish.js +19 -20
  598. package/dist/tools/fs/shell-read-judge.d.ts +4 -0
  599. package/dist/tools/fs/shell-read-judge.js +5 -2
  600. package/dist/tools/fs/shell-read-plan.js +24 -16
  601. package/dist/tools/fs/shell-read-start.d.ts +6 -1
  602. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
  603. package/dist/tools/fs/shell-read-write-targets.js +2 -3
  604. package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
  605. package/dist/tools/fs/shell-reentry-text.js +40 -2
  606. package/dist/tools/loop-tick.d.ts +2 -2
  607. package/dist/tools/scheduler-tools.js +5 -1
  608. package/dist/tools/task-list.d.ts +7 -7
  609. package/dist/tools/task-list.js +5 -1
  610. package/dist/tools/todo.js +65 -64
  611. package/dist/tools/web.d.ts +20 -15
  612. package/dist/tools/web.js +55 -69
  613. package/dist/tools/worktree.d.ts +3 -3
  614. package/dist/tools/worktree.js +3 -1
  615. package/package.json +1 -1
  616. package/test/export-surface.snapshot.json +5894 -5638
  617. package/wire-changes/core@7.55.0.json +3318 -0
  618. package/wire-changes/core@7.56.0.json +3891 -0
  619. package/wire-changes/mods-kernel@7.56.0.json +303 -0
  620. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
  621. package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
@@ -17,7 +17,7 @@ export declare const SUBAGENT_DELIVERY_NOTES: string;
17
17
  /**
18
18
  * Memory **safety** rules — a STANDALONE prompt asset, NOT injected by core. The flag-driven injection
19
19
  * (`memoryEnabled`/`consolidationEnabled` → a `memory.safety` constitution block) was retired in
20
- * RB-482 #16 along with both flags; the engine now injects the CC-verbatim `# Memory` instruction via
20
+ * RB-482 #16 along with both flags; the engine now injects the `# Memory` instruction via
21
21
  * the memory engine's `injection.block` instead. A deployment composing its own prompt is responsible
22
22
  * for including this block, and should treat it as non-suppressible: it carries the load-bearing
23
23
  * constraints (declarative-fact-not-command + the no-secrets rule + the
@@ -71,8 +71,8 @@ export declare const EXECUTION_ENVIRONMENT_OPEN_READS: string;
71
71
  /** The isolated-worktree notice, composed only when the task really runs in an isolated git worktree. */
72
72
  export declare const WORKTREE_NOTICE: string;
73
73
  /**
74
- * RB-314 — CC 2.1.220 `atp` (@597127 (cli250.js:44534)) VERBATIM. Rides the variable `# Environment` tail (see
75
- * {@link buildEnvironmentContext}), which is exactly where 220 emits it: both env-block assemblers
74
+ * RB-314 — Rides the variable `# Environment` tail (see
75
+ * {@link buildEnvironmentContext}), which is exactly where the reference emits it: both env-block assemblers
76
76
  * (@596927 `IMy`, @596976 `OMy`) push `worktree ? atp : null` directly after the isolated-copy
77
77
  * directive. Deliberately NOT folded into {@link WORKTREE_NOTICE}: that block is composed only for
78
78
  * `isolation: "worktree"` spawns, while the hazard belongs to ANY run whose cwd is a linked worktree
@@ -120,7 +120,7 @@ export interface EnvironmentFacts {
120
120
  /** design/99 §E14 — the working tree's toplevel (`git rev-parse --show-toplevel`). Lets the agent/shell know
121
121
  * it may be in a linked worktree rather than the main checkout. */
122
122
  gitWorktreeRoot?: string;
123
- /** design/119 (CC 198): cwd is a LINKED git worktree (git-dir ≠ git-common-dir) — an isolated copy. */
123
+ /** design/119: cwd is a LINKED git worktree (git-dir ≠ git-common-dir) — an isolated copy. */
124
124
  isLinkedWorktree?: boolean;
125
125
  /** design/119 (CC --add-dir parity): extra directories the file tools may access (canonical). */
126
126
  additionalDirectories?: readonly string[];
@@ -164,7 +164,7 @@ export interface EnvironmentFacts {
164
164
  /** A1 — outbound-network posture; `none` renders an explicit downloads-will-fail caveat (TB
165
165
  * autopsy 2026-07-05: agents burned budget retrying downloads in a no-egress sandbox). */
166
166
  sandboxEgress?: "none" | "allowlist" | "full";
167
- /** H4 (CC 2.1.198 git snapshot) — the pre-rendered {@link buildGitSnapshot} block. env-tail
167
+ /** H4 — the pre-rendered {@link buildGitSnapshot} block. env-tail
168
168
  * migration (#254 shape): NO LONGER RENDERED by {@link buildEnvironmentContext} — the snapshot is
169
169
  * the turn-dynamic git view and rides the `git_status` frame (re-sent only when the rendered view
170
170
  * changes); the field remains as a structured data carrier for callers that assembled it. */
@@ -185,17 +185,17 @@ export interface EnvironmentFacts {
185
185
  * it twice could drift). Renders ONE neutral declarative line; absent ⇒ nothing renders.
186
186
  */
187
187
  externalContentTarget?: boolean;
188
- /** CC 2.1.198 `MZn` Scratchpad port (system-prompt diff 档 2026-07-08 §13, 活体逐字双证) — the
188
+ /** Scratchpad port — the
189
189
  * session-scoped temp directory the agent should use instead of `/tmp` (parallel tasks/multi-tenant
190
190
  * deployments clobber each other's `/tmp`; project checkouts collect stray temp files without it).
191
191
  * DEPLOYMENT-supplied, and only injected when set — the deployment MUST have created (or be about to
192
- * create) the directory; core renders the CC-verbatim section with this path interpolated (§6.3:
192
+ * create) the directory; core renders the section with this path interpolated (§6.3:
193
193
  * never advertise a directory the task doesn't have). */
194
194
  scratchpadDir?: string;
195
195
  }
196
196
  /**
197
- * CC 2.1.198 `# Scratchpad Directory` section (bundle `MZn`, L590674; 活体 2026-07-08 byte-match) with the
198
- * path parameterized for the deployment. Wording is verbatim CC — including the closing permission-prompts
197
+ * The `# Scratchpad Directory` section with the
198
+ * path parameterized for the deployment. Wording as in the reference — including the closing permission-prompts
199
199
  * sentence, which holds for sema too (an approval-gated deployment normally allowlists its own scratchpad) —
200
200
  * PLUS one sema-added ephemerality sentence (ruled 2026-08-05): sema deployments run under durable suspend /
201
201
  * multi-replica serving where the scratchpad is a local-disk copy that does NOT survive a cross-replica
@@ -204,22 +204,22 @@ export interface EnvironmentFacts {
204
204
  * in a directory that can vanish mid-task. Volatility magnitude only — no serving-layer mechanism names.
205
205
  */
206
206
  export declare function buildScratchpadSection(scratchpadDir: string): string;
207
- /** CC 2.1.198 `Juo` — the git status truncation bound (chars) for {@link buildGitSnapshot}. */
207
+ /** The git status truncation bound (chars) for {@link buildGitSnapshot}. */
208
208
  export declare const GIT_STATUS_MAX_CHARS = 2000;
209
- /** The CC-verbatim first paragraph of the git snapshot (CC 2.1.198 `Quo` head sentence). Kept as a
209
+ /** The first paragraph of the git snapshot. Kept as a
210
210
  * named constant so the git-status FRAME renderer (the snapshot's carrier since the env-tail
211
211
  * migration) can swap exactly this paragraph for its own update-semantics preamble — under the
212
212
  * frame protocol the snapshot IS re-sent when the visible view changes, so the "will not update"
213
213
  * claim would be false there. {@link buildGitSnapshot} itself still renders it byte-exact. */
214
214
  export declare const GIT_SNAPSHOT_CC_PREAMBLE = "This is the git status at the start of the conversation. Note that this status is a snapshot in time, and will not update during the conversation.";
215
215
  /**
216
- * H4 — the CC 2.1.198 ENV git snapshot block (B1/B2; template + truncation copy verified against
217
- * observed Claude Code v2.1.198 behavior). Pure renderer — the Runner gathers the raw values through the
216
+ * H4 — the ENV git snapshot block (B1/B2).
217
+ * Pure renderer — the Runner gathers the raw values through the
218
218
  * ExecutionEnv seam (remote = the container's repo) and calls this once per prepareTask (a durable
219
219
  * resume re-prepares → re-snapshots, CC new-session 同型). env-tail migration (#254 shape): the
220
220
  * rendered block now feeds the `git_status` TURN FRAME (src/core/runner/git-status-frame.ts, which
221
221
  * swaps the {@link GIT_SNAPSHOT_CC_PREAMBLE} for an update-semantics preamble) instead of the
222
- * `# Environment` system-prompt section — the template body itself stays CC-verbatim.
222
+ * `# Environment` system-prompt section — the template body itself is unchanged.
223
223
  *
224
224
  * Sanitization (deliberate CC deviation — CC injects raw): status/log/branch/user are REPO-controlled
225
225
  * text (filenames, commit subjects, an untrusted clone's config) landing in the TRUSTED prompt region →
@@ -10,9 +10,9 @@ import type { ToolSpec, RoleSpec } from "../core/types.js";
10
10
  * `prepareTask` when the trusted assembler wires those deps/flags. This bundle is only the caller-composed factories.
11
11
  */
12
12
  export interface CodeToolsConfig {
13
- /** web_fetch policy. 🔴 `allowHosts` stays UNSET by default — passing `[]` would refuse ALL hosts (truthy empty,
14
- * `web.ts` `if (allowHosts && !allowlisted)`), breaking single-tenant TOC web fetch. A MULTI-TENANT deployment
15
- * MUST pass an explicit allowlist; the SSRF floor (`isPrivateHost`) applies regardless. */
13
+ /** web_fetch's factory options (fetch seam, byte / time caps, summarizer). Which hosts it may reach is NOT one of them: that is the
14
+ * deployment's host floor (`RunnerDeps.hostFloor`, every structured egress, read from the run on every hop) — a MULTI-TENANT
15
+ * deployment declares one there; the private-network floor applies regardless. */
16
16
  webFetch?: WebFetchConfig;
17
17
  /** WebSearch backend (BRAIN/model-service leg). Absent ⇒ WebSearch is not assembled (core ships no backend). */
18
18
  webSearch?: WebSearchConfig;
@@ -20,14 +20,14 @@ export interface CodeToolsConfig {
20
20
  * surface as the leader's own instances (one `TaskListStore`), bounded by what the spawning run mounts and trimmed
21
21
  * by the spawn tier (`SubagentToolOptions.inheritedTools`). Tools composed BESIDE the bundle are not inherited: a
22
22
  * host hands those per spawn through `subagent.extraTools`, behind its own gates.
23
- * 合车复审修③: when this carries NO explicit `systemPrompt`, the assembler defaults it to
24
- * `CODE_SYSTEM_PROMPT` — a code-scenario child holds Bash/Write side-effect tools, so it keeps the code
23
+ * 合车复审修③: when this names NO role base (neither `promptRole` nor `systemPrompt`), the assembler defaults it
24
+ * to `promptRole: "code"` — a code-scenario child holds Bash/Write side-effect tools, so it keeps the code
25
25
  * constitution (snapshot-before-mutate / destructive-op care / git discipline) instead of falling to the
26
26
  * lean SUBAGENT_PROMPT (the G1 default, which is the right upstream-anchor shape only for bare
27
- * general-purpose delegation). Pass an explicit `systemPrompt` here to override. */
27
+ * general-purpose delegation). Pass an explicit `promptRole` / `systemPrompt` here to override. */
28
28
  subagent?: SubagentToolOptions;
29
29
  /**
30
- * TodoWrite (CONTEXT leg). Default true, BUT mutually exclusive with the task-list family (CC 209
30
+ * TodoWrite (CONTEXT leg). Default true, BUT mutually exclusive with the task-list family (
31
31
  * parity: TodoWrite is enabled only when the task list is off). With `taskList` on (the default),
32
32
  * TodoWrite is NOT mounted even when `todoWrite: true` is set explicitly — the exclusion gate wins;
33
33
  * pass `taskList: false` to get TodoWrite back. `todoWrite: false` always drops it.
@@ -36,8 +36,8 @@ export interface CodeToolsConfig {
36
36
  */
37
37
  todoWrite?: boolean;
38
38
  /**
39
- * design/119 → CC209 对齐批B B3: the structured task-list family (TaskCreate/TaskGet/TaskUpdate/
40
- * TaskList — stable ids, status transitions, dependencies). Default TRUE (CC 209 alignment: the task
39
+ * design/119 → B3: the structured task-list family (TaskCreate/TaskGet/TaskUpdate/
40
+ * TaskList — stable ids, status transitions, dependencies). Default TRUE (the task
41
41
  * list is on unless explicitly disabled, and TodoWrite is its off-state fallback — the two families
42
42
  * are mutually exclusive, never co-mounted). Only an explicit `taskList: false` reverts to the
43
43
  * TodoWrite shape.
@@ -47,7 +47,7 @@ export interface CodeToolsConfig {
47
47
  */
48
48
  taskList?: boolean;
49
49
  /**
50
- * design/147 §6 D2 (CC 2.1.216 shared team task list): a shared {@link TaskListStore} for the
50
+ * design/147 §6 D2 (shared team task list): a shared {@link TaskListStore} for the
51
51
  * task-list family. Mount the SAME instance into each teammate's bundle to share one team task
52
52
  * list (the `owner` claim semantics come alive); absent ⇒ the private per-run list (unchanged
53
53
  * default). Ignored when `taskList: false`. This bundle's own Agent children share it by inheritance.
@@ -58,15 +58,15 @@ export interface CodeToolsConfig {
58
58
  * Single-source bundle of the `code` scenario's `spec.tools`-class tools, so each deployment doesn't re-wire it
59
59
  * (the single-source discipline: a scenario is data — a named bundle).
60
60
  * Profile-as-data — the engine iterates `spec.tools` branch-free; nothing keys off the scenario name. A trusted
61
- * assembler (service) calls this, sets `systemPrompt = CODE_SYSTEM_PROMPT` (or `role = CODE_ROLE`) +
61
+ * assembler (service) calls this, sets `promptRole = "code"` (or `roles.default = CODE_ROLE`) +
62
62
  * `enablePlanMode:true`, and wires the deps seams (executionEnv/onQuestion/lspManager/skillSpecs/memoryStore/
63
63
  * selfOrchestration) — that is what makes a run the `code` scenario. Returns ONLY the caller-composed tools.
64
64
  */
65
65
  export declare function assembleCodeTools(cfg?: CodeToolsConfig): ToolSpec[];
66
66
  /**
67
- * RoleSpec preset for the `code` scenario's coding role. Selected via the existing
68
- * `spec.systemPrompt ?? resolvedRole.systemPrompt` chain (no new field, no new conditional). `thinking:"high"` is a
69
- * sensible floor; the assembler/SDK can raise it (effort→thinking) per request. The global DEFAULT_SYSTEM_PROMPT
70
- * stays neutral.
67
+ * RoleSpec preset for the `code` scenario's coding role: the catalog's coding role base by word (`promptRole:
68
+ * "code"`), the role-base decision's second source — it applies when the task names no role base of its own.
69
+ * `thinking:"high"` is a sensible floor; the assembler/SDK can raise it (effort→thinking) per request. The global
70
+ * DEFAULT_SYSTEM_PROMPT stays neutral.
71
71
  */
72
72
  export declare const CODE_ROLE: RoleSpec;
@@ -2,7 +2,7 @@ import { webFetchToolSpec, createWebSearchTool } from "../tools/web.js";
2
2
  import { createTodoWriteTool } from "../tools/todo.js";
3
3
  import { createTaskListTools } from "../tools/task-list.js";
4
4
  import { createSubagentTool } from "../agents/subagent.js";
5
- import { CODE_SYSTEM_PROMPT } from "../prompts/default.js";
5
+ import { namesRoleBase } from "../prompt-assembly/role-base.js";
6
6
  export function assembleCodeTools(cfg = {}) {
7
7
  const web = [webFetchToolSpec(cfg.webFetch ?? {})];
8
8
  if (cfg.webSearch)
@@ -19,13 +19,14 @@ export function assembleCodeTools(cfg = {}) {
19
19
  }
20
20
  const tools = [...web];
21
21
  if (cfg.subagent) {
22
+ const roleBase = namesRoleBase(cfg.subagent) ? {} : { promptRole: "code" };
22
23
  tools.push(createSubagentTool({
23
24
  ...cfg.subagent,
24
- systemPrompt: cfg.subagent.systemPrompt ?? CODE_SYSTEM_PROMPT,
25
+ ...roleBase,
25
26
  inheritedTools: cfg.subagent.inheritedTools ?? [...web, ...scaffolds],
26
27
  }));
27
28
  }
28
29
  tools.push(...scaffolds);
29
30
  return tools;
30
31
  }
31
- export const CODE_ROLE = { systemPrompt: CODE_SYSTEM_PROMPT, thinking: "high" };
32
+ export const CODE_ROLE = { promptRole: "code", thinking: "high" };
package/dist/shell/lex.js CHANGED
@@ -1169,6 +1169,7 @@ function scan(source, connectorsAreText, segments, level, list) {
1169
1169
  let assignmentSeen = false;
1170
1170
  let subscriptsClosed = false;
1171
1171
  let commandWord;
1172
+ let arithParens = 0;
1172
1173
  let w = new WordBuilder();
1173
1174
  const next = (j) => past(source, j + 1);
1174
1175
  const quotedBy = () => (inSingle || inDouble ? regionBy : undefined);
@@ -1503,7 +1504,7 @@ function scan(source, connectorsAreText, segments, level, list) {
1503
1504
  take(ch, i);
1504
1505
  continue;
1505
1506
  }
1506
- if (ch === "#" && !w.started) {
1507
+ if (ch === "#" && !w.started && arithParens === 0) {
1507
1508
  const nl = source.indexOf("\n", i);
1508
1509
  i = nl < 0 ? source.length : nl - 1;
1509
1510
  continue;
@@ -1531,6 +1532,14 @@ function scan(source, connectorsAreText, segments, level, list) {
1531
1532
  const r = endWord() ?? operandOwed(i);
1532
1533
  if (r !== undefined)
1533
1534
  return r;
1535
+ if (ch === "(") {
1536
+ if (arithParens > 0)
1537
+ arithParens++;
1538
+ else if (split && source[next(i)] === "(")
1539
+ arithParens = 1;
1540
+ }
1541
+ else if (arithParens > 0)
1542
+ arithParens--;
1534
1543
  current().tokens.push({ kind: "group", op: ch });
1535
1544
  resetPosition();
1536
1545
  continue;
@@ -56,7 +56,8 @@
56
56
  * file half ships the freeze face, the acceptance face and the rebind legs.
57
57
  */
58
58
  import type { PermissionRuleSyncTransport } from "../../../core/permission-rule-sync.js";
59
- import { type AdoptionReceipt, type AdoptionSource, type AffectedDeploymentConfig } from "./marker.js";
59
+ import { type AdoptionReceipt, type AffectedDeploymentConfig } from "./marker.js";
60
+ import { type RuleOwner } from "../../../core/rule-owner.js";
60
61
  /** The per-leg context handed to a carriage leg: rows the far side REFUSES go here — preserved and
61
62
  * disclosed, never deleted (design/183 §7.2). Quarantining never fails the leg. */
62
63
  export interface AdoptionCarriageLegContext {
@@ -79,7 +80,7 @@ export interface AdoptionCarriageLeg {
79
80
  export interface AdoptLocalDataRootOptions {
80
81
  /** The data root (the directory `FileStorageBackend` and the independent file stores build over). */
81
82
  root: string;
82
- from: AdoptionSource;
83
+ from: RuleOwner;
83
84
  toPrincipal: string;
84
85
  /** The claim REFERENCE for the new identity's credentials (minted by the server; design/183 §4.3).
85
86
  * A reference, never the credential bytes — the marker file is a plain-text sidecar. */
@@ -141,7 +142,7 @@ export type AdoptionStatus = {
141
142
  state: "none";
142
143
  } | {
143
144
  state: "in-flight";
144
- from: AdoptionSource;
145
+ from: RuleOwner;
145
146
  toPrincipal: string;
146
147
  phase: 2 | 3 | 4 | 5;
147
148
  } | {
@@ -7,6 +7,8 @@ import { SESSION_POLICY_MARK_SUFFIX, attributeSessionPolicyRow, judgeSessionPoli
7
7
  import { SessionPolicyError } from "../../../core/session-policy-store.js";
8
8
  import { thrownText } from "../../../core/thrown-value.js";
9
9
  import { AdoptionError, NOT_MIGRATED_BY_DESIGN, readRootAdoptionFile, writeRootAdoptionFile, } from "./marker.js";
10
+ import { readRuleOwner, ruleOwnerText, sameRuleOwner } from "../../../core/rule-owner.js";
11
+ import { principalNameOf } from "../../../core/principal-name.js";
10
12
  const CONFIG_ACCOUNT_FILE = "adoption-configs.json";
11
13
  function baselineConfigs(toPrincipal) {
12
14
  return [
@@ -282,12 +284,6 @@ const ZERO_ACTION_STORES = [
282
284
  ];
283
285
  const SESSION_POLICY_LEG = "session-policy";
284
286
  const CARRIAGE_BIT_PREFIX = "carriage:";
285
- function sameSource(a, b) {
286
- return a.kind === "principal" ? b.kind === "principal" && a.principal === b.principal : b.kind === "local-owner";
287
- }
288
- function sourceText(o) {
289
- return o.kind === "principal" ? `principal "${o.principal}"` : "the local owner";
290
- }
291
287
  function receiptFromTerminal(root, adopted) {
292
288
  const account = readConfigAccountEvidence(root);
293
289
  const accountBinds = account !== undefined && account.adoptionId === adopted.immutableReport.adoptionId;
@@ -325,33 +321,34 @@ function answerFromExisting(root, existing, from, toPrincipal) {
325
321
  if (existing === undefined)
326
322
  return undefined;
327
323
  if ("adopted" in existing) {
328
- if (existing.adopted.toPrincipal === toPrincipal && sameSource(existing.adopted.from, from)) {
324
+ if (existing.adopted.toPrincipal === toPrincipal && sameRuleOwner(existing.adopted.from, from)) {
329
325
  return receiptFromTerminal(root, existing.adopted);
330
326
  }
331
- throw new AdoptionError("adoption_retarget", `this data root already carries a completed adoption (${sourceText(existing.adopted.from)} → "${existing.adopted.toPrincipal}") — ` +
327
+ throw new AdoptionError("adoption_retarget", `this data root already carries a completed adoption (${ruleOwnerText(existing.adopted.from)} → "${existing.adopted.toPrincipal}") — ` +
332
328
  `a second adoption of the same root is a multi-tenant transfer, not a shape this protocol supports`);
333
329
  }
334
- if (existing.marker.toPrincipal !== toPrincipal || !sameSource(existing.marker.from, from)) {
330
+ if (existing.marker.toPrincipal !== toPrincipal || !sameRuleOwner(existing.marker.from, from)) {
335
331
  throw new AdoptionError("adoption_in_flight_mismatch", `an adoption toward "${existing.marker.toPrincipal}" is already in flight in this data root (phase ${existing.marker.phase}) — ` +
336
332
  `refusing to start a different one (resume the original, or repair the marker by hand)`);
337
333
  }
338
334
  return undefined;
339
335
  }
340
336
  export async function adoptLocalDataRoot(opts) {
341
- if (typeof opts.toPrincipal !== "string" || opts.toPrincipal === "") {
342
- throw new AdoptionError("adoption_bad_request", "adoptLocalDataRoot requires the adopting principal — adoption is the act of giving this data root an identity");
337
+ if (principalNameOf(opts.toPrincipal) === undefined) {
338
+ throw new AdoptionError("adoption_bad_request", "adoptLocalDataRoot requires the adopting principal, a principal name — adoption is the act of giving this data root an identity");
343
339
  }
344
- if (opts.from.kind === "principal" && (typeof opts.from.principal !== "string" || opts.from.principal === "")) {
345
- throw new AdoptionError("adoption_bad_request", "a principal-form source requires a non-empty principal — local-single-user identity is the local-owner kind, never an empty string");
340
+ const from = readRuleOwner(opts.from);
341
+ if (from === undefined) {
342
+ throw new AdoptionError("adoption_bad_request", "the adoption source must be the local-owner kind or a principal owner whose principal is a principal name — local-single-user identity is the local-owner kind, never a blank string");
346
343
  }
347
- if (opts.from.kind === "principal" && opts.from.principal === opts.toPrincipal) {
344
+ if (from.kind === "principal" && from.principal === opts.toPrincipal) {
348
345
  throw new AdoptionError("adoption_bad_request", `the data root already belongs to "${opts.toPrincipal}" — there is nothing to adopt`);
349
346
  }
350
347
  if (typeof opts.credentials.ref !== "string" || opts.credentials.ref === "") {
351
348
  throw new AdoptionError("adoption_bad_request", "the credentials claim ref must be a non-empty reference (the claim is what makes the new identity redeemable)");
352
349
  }
353
- if (opts.from === null || typeof opts.from !== "object" || opts.credentials === null || typeof opts.credentials !== "object") {
354
- throw new AdoptionError("adoption_bad_request", "adoptLocalDataRoot requires `from` and `credentials` objects");
350
+ if (opts.credentials === null || typeof opts.credentials !== "object") {
351
+ throw new AdoptionError("adoption_bad_request", "adoptLocalDataRoot requires a `credentials` object");
355
352
  }
356
353
  if (opts.additionalConfigs !== undefined && !Array.isArray(opts.additionalConfigs)) {
357
354
  throw new AdoptionError("adoption_bad_request", "additionalConfigs must be an array when supplied");
@@ -368,9 +365,6 @@ export async function adoptLocalDataRoot(opts) {
368
365
  if (opts.onError !== undefined && typeof opts.onError !== "function") {
369
366
  throw new AdoptionError("adoption_bad_request", "`onError` must be callable when supplied");
370
367
  }
371
- if (opts.from.kind !== "local-owner" && opts.from.kind !== "principal") {
372
- throw new AdoptionError("adoption_bad_request", "the adoption source must be the local-owner kind or a named principal");
373
- }
374
368
  if (opts.credentials.issuedBy !== "server") {
375
369
  throw new AdoptionError("adoption_bad_request", `the credentials claim must be server-issued (got issuedBy: ${JSON.stringify(opts.credentials.issuedBy)}) — the server mints the new identity`);
376
370
  }
@@ -402,7 +396,7 @@ export async function adoptLocalDataRoot(opts) {
402
396
  }
403
397
  }
404
398
  ensureDir(opts.root);
405
- const pre = answerFromExisting(opts.root, readRootAdoptionFile(opts.root), opts.from, opts.toPrincipal);
399
+ const pre = answerFromExisting(opts.root, readRootAdoptionFile(opts.root), from, opts.toPrincipal);
406
400
  if (pre !== undefined) {
407
401
  const account = readConfigAccountEvidence(opts.root);
408
402
  if (account !== undefined && account.adoptionId === pre.immutableReport.adoptionId)
@@ -425,7 +419,7 @@ export async function adoptLocalDataRoot(opts) {
425
419
  }
426
420
  try {
427
421
  const existing = readRootAdoptionFile(opts.root);
428
- const answered = answerFromExisting(opts.root, existing, opts.from, opts.toPrincipal);
422
+ const answered = answerFromExisting(opts.root, existing, from, opts.toPrincipal);
429
423
  if (answered !== undefined) {
430
424
  rebuildConfigAccountIfUnbound(opts.root, answered.immutableReport);
431
425
  return receiptFromTerminal(opts.root, {
@@ -481,7 +475,7 @@ export async function adoptLocalDataRoot(opts) {
481
475
  `They would never run, and reporting them as done would be a lie; post-adoption carriage rides each store's normal channel.`);
482
476
  }
483
477
  if (plan !== existing.marker.plan) {
484
- publishMarker(opts.root, adoptionId, opts.from, opts.toPrincipal, phase, plan, legBits);
478
+ publishMarker(opts.root, adoptionId, from, opts.toPrincipal, phase, plan, legBits);
485
479
  }
486
480
  const accountInFlight = readConfigAccount(opts.root);
487
481
  if (accountInFlight === undefined || accountInFlight.adoptionId !== adoptionId) {
@@ -496,7 +490,7 @@ export async function adoptLocalDataRoot(opts) {
496
490
  legBits = {};
497
491
  plan = { ...(offeredRulesDir !== undefined ? { rulesDir: offeredRulesDir } : {}), carriage: offeredCarriage, credentialsRef: opts.credentials.ref };
498
492
  upsertConfigAccount(opts.root, adoptionId, opts.toPrincipal, opts.additionalConfigs ?? []);
499
- publishMarker(opts.root, adoptionId, opts.from, opts.toPrincipal, 2, plan, legBits);
493
+ publishMarker(opts.root, adoptionId, from, opts.toPrincipal, 2, plan, legBits);
500
494
  }
501
495
  const legs = [];
502
496
  if (phase < 3) {
@@ -505,7 +499,7 @@ export async function adoptLocalDataRoot(opts) {
505
499
  try {
506
500
  nested = await adoptFilePermissionRuleStore({
507
501
  dir: opts.rules.dir,
508
- from: opts.from,
502
+ from,
509
503
  toPrincipal: opts.toPrincipal,
510
504
  transport: opts.rules.transport,
511
505
  ...(opts.now !== undefined ? { now: opts.now } : {}),
@@ -526,15 +520,15 @@ export async function adoptLocalDataRoot(opts) {
526
520
  }
527
521
  }
528
522
  if (legBits[SESSION_POLICY_LEG]?.done !== true) {
529
- const rows = rewriteSessionPolicyRows(opts.root, opts.from.kind === "principal" ? opts.from.principal : null, opts.toPrincipal);
523
+ const rows = rewriteSessionPolicyRows(opts.root, from.kind === "principal" ? from.principal : null, opts.toPrincipal);
530
524
  legBits = { ...legBits, [SESSION_POLICY_LEG]: { done: true, rows } };
531
- publishMarker(opts.root, adoptionId, opts.from, opts.toPrincipal, 2, plan, legBits);
525
+ publishMarker(opts.root, adoptionId, from, opts.toPrincipal, 2, plan, legBits);
532
526
  }
533
- publishMarker(opts.root, adoptionId, opts.from, opts.toPrincipal, 3, plan, legBits);
527
+ publishMarker(opts.root, adoptionId, from, opts.toPrincipal, 3, plan, legBits);
534
528
  phase = 3;
535
529
  }
536
530
  if (phase < 4) {
537
- publishMarker(opts.root, adoptionId, opts.from, opts.toPrincipal, 4, plan, legBits);
531
+ publishMarker(opts.root, adoptionId, from, opts.toPrincipal, 4, plan, legBits);
538
532
  phase = 4;
539
533
  }
540
534
  if (phase < 5) {
@@ -575,9 +569,9 @@ export async function adoptLocalDataRoot(opts) {
575
569
  ...(quarantined > 0 ? { quarantined } : {}),
576
570
  },
577
571
  };
578
- publishMarker(opts.root, adoptionId, opts.from, opts.toPrincipal, 4, plan, legBits);
572
+ publishMarker(opts.root, adoptionId, from, opts.toPrincipal, 4, plan, legBits);
579
573
  }
580
- publishMarker(opts.root, adoptionId, opts.from, opts.toPrincipal, 5, plan, legBits);
574
+ publishMarker(opts.root, adoptionId, from, opts.toPrincipal, 5, plan, legBits);
581
575
  phase = 5;
582
576
  }
583
577
  if (plan.rulesDir !== undefined)
@@ -609,7 +603,7 @@ export async function adoptLocalDataRoot(opts) {
609
603
  }
610
604
  const immutableReport = {
611
605
  adoptionId,
612
- from: opts.from,
606
+ from,
613
607
  toPrincipal: opts.toPrincipal,
614
608
  atMs,
615
609
  credentials: opts.credentials,
@@ -619,9 +613,9 @@ export async function adoptLocalDataRoot(opts) {
619
613
  };
620
614
  writeRootAdoptionFile(opts.root, {
621
615
  schemaVersion: 1,
622
- adopted: { from: opts.from, toPrincipal: opts.toPrincipal, atMs: immutableReport.atMs, immutableReport },
616
+ adopted: { from, toPrincipal: opts.toPrincipal, atMs: immutableReport.atMs, immutableReport },
623
617
  });
624
- return receiptFromTerminal(opts.root, { from: opts.from, toPrincipal: opts.toPrincipal, atMs: immutableReport.atMs, immutableReport });
618
+ return receiptFromTerminal(opts.root, { from, toPrincipal: opts.toPrincipal, atMs: immutableReport.atMs, immutableReport });
625
619
  }
626
620
  finally {
627
621
  adoptionLock.release();
@@ -14,17 +14,10 @@
14
14
  * with the same (from → toPrincipal) short-circuits to the recorded receipt) and it carries the
15
15
  * IMMUTABLE report — the byte-stable half of every receipt.
16
16
  *
17
- * This module is deliberately tiny and dependency-light (node:fs + the atomic-write primitive): every
18
- * file store imports the gate from here, so it must never grow an import back into a store.
17
+ * This module is deliberately tiny and dependency-light (node:fs, the atomic-write primitive, the import-free owner
18
+ * reading): every file store imports the gate from here, so it must never grow an import back into a store.
19
19
  */
20
- /** Who the data root belonged to before adoption. Shape-identical to the rule domain's `RuleOwner`
21
- * (design/182): local-single-user identity is a STRUCTURAL ABSENCE, never a sentinel string. */
22
- export type AdoptionSource = {
23
- kind: "local-owner";
24
- } | {
25
- kind: "principal";
26
- principal: string;
27
- };
20
+ import { type RuleOwner } from "../../../core/rule-owner.js";
28
21
  /** Typed refusal codes (design/183 §7.3): every adoption refusal is discriminable — from `not_found`,
29
22
  * from a broken deployment, and from each other. */
30
23
  export type AdoptionErrorCode =
@@ -81,7 +74,7 @@ export interface AdoptionLegReport {
81
74
  export interface AdoptionReport {
82
75
  /** Minted at phase ② — the binding anchor config-witness receipts must carry. */
83
76
  adoptionId: string;
84
- from: AdoptionSource;
77
+ from: RuleOwner;
85
78
  toPrincipal: string;
86
79
  atMs: number;
87
80
  /** The claim REFERENCE for the new identity's credentials — never the credentials themselves (the
@@ -120,7 +113,7 @@ export type RootAdoptionFile = {
120
113
  schemaVersion: 1;
121
114
  marker: {
122
115
  adoptionId: string;
123
- from: AdoptionSource;
116
+ from: RuleOwner;
124
117
  toPrincipal: string;
125
118
  phase: 2 | 3 | 4 | 5;
126
119
  /** The migration plan recorded at phase ② and grown MONOTONICALLY across resumes — what a
@@ -147,7 +140,7 @@ export type RootAdoptionFile = {
147
140
  } | {
148
141
  schemaVersion: 1;
149
142
  adopted: {
150
- from: AdoptionSource;
143
+ from: RuleOwner;
151
144
  toPrincipal: string;
152
145
  atMs: number;
153
146
  immutableReport: AdoptionReport;
@@ -1,5 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
+ import { readRuleOwner, sameRuleOwner } from "../../../core/rule-owner.js";
4
+ import { principalNameOf } from "../../../core/principal-name.js";
3
5
  import { atomicWriteFile, ensureDir } from "../fs-atomic.js";
4
6
  export class AdoptionError extends Error {
5
7
  code;
@@ -26,14 +28,6 @@ export const BASELINE_CONFIG_IDENTITIES = [
26
28
  { deployment: "env", key: "REQUIRE_PRINCIPAL" },
27
29
  { deployment: "core-decl", key: "localOwnerRules" },
28
30
  ];
29
- function isSource(v) {
30
- if (v === null || typeof v !== "object")
31
- return false;
32
- const s = v;
33
- if (s.kind === "local-owner")
34
- return true;
35
- return s.kind === "principal" && typeof s.principal === "string" && s.principal !== "";
36
- }
37
31
  function isRootAdoptionFileShape(v) {
38
32
  if (v === null || typeof v !== "object")
39
33
  return false;
@@ -45,8 +39,8 @@ function isRootAdoptionFileShape(v) {
45
39
  if (m === null ||
46
40
  typeof m !== "object" ||
47
41
  typeof m.adoptionId !== "string" ||
48
- !isSource(m.from) ||
49
- typeof m.toPrincipal !== "string" ||
42
+ readRuleOwner(m.from) === undefined ||
43
+ principalNameOf(m.toPrincipal) === undefined ||
50
44
  typeof m.phase !== "number" ||
51
45
  ![2, 3, 4, 5].includes(m.phase)) {
52
46
  return false;
@@ -91,21 +85,19 @@ function isRootAdoptionFileShape(v) {
91
85
  }
92
86
  if ("adopted" in f && !("marker" in f)) {
93
87
  const a = f.adopted;
88
+ const from = readRuleOwner(a?.from);
94
89
  if (a === null ||
95
90
  typeof a !== "object" ||
96
- !isSource(a.from) ||
97
- typeof a.toPrincipal !== "string" ||
91
+ from === undefined ||
92
+ principalNameOf(a.toPrincipal) === undefined ||
98
93
  typeof a.atMs !== "number" ||
99
94
  a.immutableReport === null ||
100
95
  typeof a.immutableReport !== "object") {
101
96
  return false;
102
97
  }
103
98
  const r = a.immutableReport;
104
- const sameFrom = isSource(r.from) &&
105
- (r.from.kind === "local-owner"
106
- ? a.from.kind === "local-owner"
107
- : a.from.kind === "principal" &&
108
- r.from.principal === a.from.principal);
99
+ const reportFrom = readRuleOwner(r.from);
100
+ const sameFrom = reportFrom !== undefined && sameRuleOwner(reportFrom, from);
109
101
  const okCount = (n) => n === undefined || (typeof n === "number" && Number.isSafeInteger(n) && n >= 0);
110
102
  const configIds = new Set();
111
103
  const configsOk = Array.isArray(r.affectedDeploymentConfigs) &&
@@ -1,6 +1,8 @@
1
1
  import { type ExecutionOutcomeRecordWord } from "../../core/checkpoint-execution-record.js";
2
+ import { type HolderJudge } from "../../core/checkpoint-generation.js";
2
3
  import { type Checkpoint, type PendingSteerInput, type CheckpointFaultMode, type CheckpointStore, type CheckpointSummary, type CheckpointToken, type ReopenReason, type ResolveExpectation, type ResumeOutcome } from "../../core/checkpoint-store.js";
3
4
  import type { GateOutcome } from "../../core/gate-outcome.js";
5
+ import { type CheckpointDeleteGuard, type CheckpointOverdueCursor, type CheckpointOverdueQuery, type CheckpointPage, type CheckpointRowRead, type CheckpointSessionCursor, type CheckpointSessionQuery } from "../../core/checkpoint-queries.js";
4
6
  import { type CorruptReadInfo } from "./corrupt-read-sink.js";
5
7
  export interface FileCheckpointStoreOptions {
6
8
  /** This store's half of {@link import("./shared-ledger.js").LedgerPaths.onCorruptRead}. */
@@ -11,6 +13,13 @@ export interface FileCheckpointStoreOptions {
11
13
  fsync?: boolean;
12
14
  /** Compact the ledger into a snapshot once it exceeds this many events (then truncate). Default 1000. */
13
15
  compactEvery?: number;
16
+ /** The session head read (a session store's `headOf`) {@link FileCheckpointStore.deleteSessionCheckpoints} judges its guard by;
17
+ * without it the store has no `deleteSessionCheckpoints` member. */
18
+ sessionHeadOf?: (sessionId: string) => Promise<{
19
+ readonly owner: string | null;
20
+ } | undefined>;
21
+ /** The judge of a resolve's claim holder ({@link HolderJudge}); with it the store declares `fence = { holder: true }`. */
22
+ holderIsCurrent?: HolderJudge;
14
23
  }
15
24
  export declare class FileCheckpointStore implements CheckpointStore {
16
25
  /** design/173 §2.3 — honest declaration on the restart-survival axis the vocabulary claims: rows
@@ -34,6 +43,11 @@ export declare class FileCheckpointStore implements CheckpointStore {
34
43
  readonly execution: {
35
44
  readonly outcome: true;
36
45
  };
46
+ /** Declared exactly when the store was built with a `holderIsCurrent` judge. */
47
+ readonly fence?: {
48
+ readonly holder: true;
49
+ };
50
+ private readonly holderIsCurrent;
37
51
  private readonly fsyncEnabled;
38
52
  private readonly compactEvery;
39
53
  /** RB-134: the directory's ONE authority (map + token mutex + append log), joined not rebuilt. */
@@ -42,6 +56,11 @@ export declare class FileCheckpointStore implements CheckpointStore {
42
56
  private get cps();
43
57
  /** One-shot crash fault (mirrors `InMemoryCheckpointStore.testInjectFault`). */
44
58
  private fault;
59
+ /** The guarded {@link FileCheckpointStoreOptions.onCorruptRead} seat (the ledger's replay and this store's projection share it). */
60
+ private readonly discloseCorrupt;
61
+ private readonly ledgerPath;
62
+ /** Present exactly when the store was built with a session head read (`FileCheckpointStoreOptions.sessionHeadOf`). */
63
+ readonly deleteSessionCheckpoints?: (sessionId: string, guard: CheckpointDeleteGuard) => Promise<number>;
45
64
  constructor(root: string, opts?: FileCheckpointStoreOptions);
46
65
  /** Serialize an op behind any in-flight op on the same token (the in-process per-token async mutex). */
47
66
  private withLock;
@@ -66,6 +85,11 @@ export declare class FileCheckpointStore implements CheckpointStore {
66
85
  reap(scope: string, cutoff: number): Promise<number>;
67
86
  listByScope(scope: string): Promise<CheckpointSummary[]>;
68
87
  listScopes(): Promise<string[]>;
88
+ /** The listing faces' disclosure: a row read past a damage is reported through the corrupt-read seat, named by its non-secret
89
+ * identity (never its token). */
90
+ private listingDisclose;
91
+ listOverdue(query: CheckpointOverdueQuery): Promise<CheckpointPage<CheckpointSummary, CheckpointOverdueCursor>>;
92
+ listBySession(query: CheckpointSessionQuery): Promise<CheckpointPage<CheckpointRowRead, CheckpointSessionCursor>>;
69
93
  /** Force a compaction now (test/inspection). The snapshot rewrite + RB-167 closeForSwap swap that
70
94
  * makes `replay` read the full state from the snapshot alone is the base's {@link LedgerCore.compact}. */
71
95
  compactNow(): void;