@sema-agent/core 7.52.0 → 7.54.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 (357) hide show
  1. package/CHANGELOG.md +470 -0
  2. package/LICENSE +3 -1
  3. package/README.md +3 -1
  4. package/dist/agents/cross-session-envelope.d.ts +8 -0
  5. package/dist/agents/cross-session-envelope.js +6 -0
  6. package/dist/agents/cross-session-judge.d.ts +21 -1
  7. package/dist/agents/cross-session-judge.js +8 -0
  8. package/dist/agents/cross-session-ref.d.ts +5 -0
  9. package/dist/agents/cross-session-ref.js +1 -0
  10. package/dist/agents/org-delivery-gate.d.ts +122 -0
  11. package/dist/agents/org-delivery-gate.js +69 -0
  12. package/dist/agents/peer-held-queue.d.ts +9 -4
  13. package/dist/agents/peer-held-queue.js +6 -5
  14. package/dist/agents/peer-session-drain.d.ts +35 -6
  15. package/dist/agents/peer-session-drain.js +271 -182
  16. package/dist/agents/read-inbox-tool.d.ts +7 -0
  17. package/dist/agents/read-inbox-tool.js +5 -1
  18. package/dist/agents/send-message-tool.js +3 -4
  19. package/dist/agents/subagent.d.ts +6 -5
  20. package/dist/agents/subagent.js +117 -83
  21. package/dist/agents/tool-filter.d.ts +25 -4
  22. package/dist/agents/tool-filter.js +13 -3
  23. package/dist/brain/anthropic.d.ts +6 -1
  24. package/dist/brain/anthropic.js +4 -4
  25. package/dist/brain/model-presets.js +2 -1
  26. package/dist/brain/route-adjudicator.d.ts +6 -0
  27. package/dist/brain/routing.d.ts +24 -1
  28. package/dist/brain/routing.js +54 -19
  29. package/dist/brain/timeout.js +5 -4
  30. package/dist/core/a2a.d.ts +5 -2
  31. package/dist/core/a2a.js +33 -14
  32. package/dist/core/allow-entry.d.ts +3 -1
  33. package/dist/core/allow-entry.js +3 -2
  34. package/dist/core/approval-object.d.ts +87 -0
  35. package/dist/core/approval-object.js +85 -0
  36. package/dist/core/arg-summary.d.ts +3 -2
  37. package/dist/core/arg-summary.js +17 -11
  38. package/dist/core/ask-origin.d.ts +43 -27
  39. package/dist/core/ask-origin.js +20 -11
  40. package/dist/core/ask-question.d.ts +0 -1
  41. package/dist/core/ask-question.js +4 -67
  42. package/dist/core/ask-unresolvable-notice.d.ts +3 -2
  43. package/dist/core/auto-compaction.d.ts +106 -50
  44. package/dist/core/auto-compaction.js +69 -53
  45. package/dist/core/auto-mode-prompt.d.ts +4 -2
  46. package/dist/core/auto-mode-prompt.js +4 -3
  47. package/dist/core/canonical-json.d.ts +69 -0
  48. package/dist/core/canonical-json.js +130 -8
  49. package/dist/core/checkpoint-requirements.d.ts +13 -7
  50. package/dist/core/checkpoint-requirements.js +4 -1
  51. package/dist/core/checkpoint-store.d.ts +60 -36
  52. package/dist/core/checkpoint-store.js +7 -6
  53. package/dist/core/child-clamp-seats.d.ts +45 -6
  54. package/dist/core/child-clamp-seats.js +56 -4
  55. package/dist/core/compliance.js +3 -1
  56. package/dist/core/consolidate-scope.d.ts +1 -1
  57. package/dist/core/cross-boundary-taint.d.ts +213 -0
  58. package/dist/core/cross-boundary-taint.js +196 -0
  59. package/dist/core/decision-receipt.d.ts +44 -1
  60. package/dist/core/decision-receipt.js +16 -0
  61. package/dist/core/effective-path-target.d.ts +28 -6
  62. package/dist/core/effective-path-target.js +28 -2
  63. package/dist/core/engine-notice.d.ts +47 -4
  64. package/dist/core/engine-notice.js +17 -1
  65. package/dist/core/engine-storage-backend.d.ts +73 -0
  66. package/dist/core/engine-storage-backend.js +1 -0
  67. package/dist/core/file-history-store.d.ts +6 -2
  68. package/dist/core/file-history-store.js +1 -0
  69. package/dist/core/gate-fold.js +13 -4
  70. package/dist/core/gate-lanes.js +41 -34
  71. package/dist/core/gate-outcome.d.ts +18 -9
  72. package/dist/core/governance-codes.d.ts +9 -2
  73. package/dist/core/governance-codes.js +9 -0
  74. package/dist/core/hands-band-screen.d.ts +7 -0
  75. package/dist/core/hands-band-screen.js +32 -0
  76. package/dist/core/hooks.d.ts +21 -19
  77. package/dist/core/hooks.js +6 -5
  78. package/dist/core/locked-config.d.ts +110 -31
  79. package/dist/core/locked-config.js +155 -42
  80. package/dist/core/lsp.d.ts +1 -1
  81. package/dist/core/mcp-probe.js +1 -1
  82. package/dist/core/mcp-server-spec.d.ts +152 -17
  83. package/dist/core/mcp-server-spec.js +223 -40
  84. package/dist/core/mcp.d.ts +21 -14
  85. package/dist/core/mcp.js +59 -54
  86. package/dist/core/memory-engine/engine.d.ts +14 -19
  87. package/dist/core/memory-engine/engine.js +9 -6
  88. package/dist/core/memory-engine/export-bundle.d.ts +1 -1
  89. package/dist/core/memory-engine/export-bundle.js +1 -1
  90. package/dist/core/memory-engine/file-backend.d.ts +2 -6
  91. package/dist/core/memory-engine/file-backend.js +1 -12
  92. package/dist/core/memory.d.ts +3 -3
  93. package/dist/core/mode-policy.d.ts +16 -26
  94. package/dist/core/mode-policy.js +5 -18
  95. package/dist/core/mods/kernel/dispatch.js +13 -15
  96. package/dist/core/mods/kernel/events.d.ts +9 -6
  97. package/dist/core/mods/kernel/events.js +2 -2
  98. package/dist/core/mods/kernel/receive.d.ts +41 -11
  99. package/dist/core/mods/kernel/receive.js +124 -54
  100. package/dist/core/mods/kernel/site-rules.d.ts +80 -15
  101. package/dist/core/mods/kernel/site-rules.js +232 -40
  102. package/dist/core/mods/stations.d.ts +0 -6
  103. package/dist/core/mods/stations.js +0 -7
  104. package/dist/core/mounted-mcp.d.ts +57 -0
  105. package/dist/core/mounted-mcp.js +71 -2
  106. package/dist/core/own-property-receipt.d.ts +13 -0
  107. package/dist/core/own-property-receipt.js +3 -1
  108. package/dist/core/parent-spec-seat.d.ts +12 -15
  109. package/dist/core/parent-spec-seat.js +14 -6
  110. package/dist/core/pause-registry.d.ts +35 -1
  111. package/dist/core/pause-registry.js +10 -0
  112. package/dist/core/permission-rule-consent.d.ts +18 -5
  113. package/dist/core/permission-rule-consent.js +13 -8
  114. package/dist/core/permission-rule-model.d.ts +87 -15
  115. package/dist/core/permission-rule-model.js +87 -8
  116. package/dist/core/permission-rule-org.d.ts +200 -33
  117. package/dist/core/permission-rule-org.js +217 -91
  118. package/dist/core/permission-rule-session.js +2 -2
  119. package/dist/core/permission-rule-store.d.ts +8 -0
  120. package/dist/core/permission-rule-store.js +1 -0
  121. package/dist/core/permission-rule-sync.js +3 -2
  122. package/dist/core/permission-rules.d.ts +7 -1
  123. package/dist/core/permission-rules.js +37 -8
  124. package/dist/core/read-only-shell.d.ts +1 -1
  125. package/dist/core/read-only-shell.js +30 -9
  126. package/dist/core/remote-env.d.ts +41 -1
  127. package/dist/core/remote-env.js +18 -0
  128. package/dist/core/resume-startup-cause.d.ts +18 -0
  129. package/dist/core/resume-startup-cause.js +12 -0
  130. package/dist/core/retention.js +7 -2
  131. package/dist/core/retired-keys.d.ts +8 -2
  132. package/dist/core/retired-keys.js +12 -1
  133. package/dist/core/roles.js +60 -10
  134. package/dist/core/rule-lane-reads.js +1 -1
  135. package/dist/core/runner/approval-feedback.d.ts +46 -0
  136. package/dist/core/runner/approval-feedback.js +41 -0
  137. package/dist/core/runner/compaction-call-options.d.ts +3 -3
  138. package/dist/core/runner/compaction-call-options.js +2 -2
  139. package/dist/core/runner/contracts.d.ts +34 -41
  140. package/dist/core/runner/cross-boundary-lane.d.ts +87 -0
  141. package/dist/core/runner/cross-boundary-lane.js +190 -0
  142. package/dist/core/runner/decide-continuation.d.ts +4 -4
  143. package/dist/core/runner/decide-continuation.js +3 -1
  144. package/dist/core/runner/gate-exit.d.ts +32 -12
  145. package/dist/core/runner/gate-exit.js +77 -34
  146. package/dist/core/runner/inherited-ask-grants.js +2 -2
  147. package/dist/core/runner/mcp-redial.d.ts +52 -10
  148. package/dist/core/runner/mcp-redial.js +38 -9
  149. package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
  150. package/dist/core/runner/permission-rule-lanes.js +22 -10
  151. package/dist/core/runner/person-path-rows.d.ts +5 -3
  152. package/dist/core/runner/person-path-rows.js +2 -2
  153. package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -4
  154. package/dist/core/runner/prepare-acquire-reconcile.js +3 -3
  155. package/dist/core/runner/prepare-ask-lane.js +3 -3
  156. package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -5
  157. package/dist/core/runner/prepare-caps-and-workflow.js +3 -3
  158. package/dist/core/runner/prepare-config-doors.d.ts +58 -15
  159. package/dist/core/runner/prepare-config-doors.js +167 -146
  160. package/dist/core/runner/prepare-context-lane.js +6 -3
  161. package/dist/core/runner/prepare-defer-classify.js +4 -7
  162. package/dist/core/runner/prepare-delegation-surface.d.ts +5 -4
  163. package/dist/core/runner/prepare-delegation-surface.js +8 -7
  164. package/dist/core/runner/prepare-execution-env.d.ts +1 -2
  165. package/dist/core/runner/prepare-execution-env.js +2 -1
  166. package/dist/core/runner/prepare-gate-stations.d.ts +2 -0
  167. package/dist/core/runner/prepare-gate-stations.js +4 -3
  168. package/dist/core/runner/prepare-hands-readface.d.ts +3 -3
  169. package/dist/core/runner/prepare-hands-readface.js +3 -2
  170. package/dist/core/runner/prepare-inherited-gate.d.ts +2 -0
  171. package/dist/core/runner/prepare-inherited-gate.js +3 -2
  172. package/dist/core/runner/prepare-listings.d.ts +1 -1
  173. package/dist/core/runner/prepare-listings.js +4 -2
  174. package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
  175. package/dist/core/runner/prepare-memory-engine-session.js +19 -6
  176. package/dist/core/runner/prepare-memory.d.ts +3 -2
  177. package/dist/core/runner/prepare-memory.js +6 -2
  178. package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
  179. package/dist/core/runner/prepare-offload-wrappers.js +2 -1
  180. package/dist/core/runner/prepare-park-ask.d.ts +1 -1
  181. package/dist/core/runner/prepare-park-ask.js +9 -3
  182. package/dist/core/runner/prepare-policy-chain.d.ts +1 -1
  183. package/dist/core/runner/prepare-policy-chain.js +14 -19
  184. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  185. package/dist/core/runner/prepare-project-context.js +6 -4
  186. package/dist/core/runner/prepare-prompt-assembly.d.ts +1 -1
  187. package/dist/core/runner/prepare-prompt-assembly.js +20 -16
  188. package/dist/core/runner/prepare-prompt-inputs.d.ts +12 -6
  189. package/dist/core/runner/prepare-prompt-inputs.js +6 -3
  190. package/dist/core/runner/prepare-protocol-tools.d.ts +7 -5
  191. package/dist/core/runner/prepare-protocol-tools.js +19 -12
  192. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  193. package/dist/core/runner/prepare-question-face.js +4 -3
  194. package/dist/core/runner/prepare-safety-scan.d.ts +7 -2
  195. package/dist/core/runner/prepare-safety-scan.js +34 -27
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +6 -2
  198. package/dist/core/runner/prepare-task.js +22 -19
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +10 -5
  200. package/dist/core/runner/prepare-turn-wiring.js +14 -49
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +10 -5
  202. package/dist/core/runner/prepare-wiring-manifest.js +9 -6
  203. package/dist/core/runner/prepare-workspace-restore.js +2 -2
  204. package/dist/core/runner/resume-admission.d.ts +4 -1
  205. package/dist/core/runner/resume-admission.js +16 -14
  206. package/dist/core/runner/resume-apply.js +4 -4
  207. package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
  208. package/dist/core/runner/resume-internals-and-config.js +3 -8
  209. package/dist/core/runner/resume-policy-outcome.d.ts +2 -2
  210. package/dist/core/runner/resume-policy-outcome.js +18 -15
  211. package/dist/core/runner/resume-preflight.js +2 -2
  212. package/dist/core/runner/resume-review-outcome.js +3 -3
  213. package/dist/core/runner/retired-runner-deps.d.ts +5 -6
  214. package/dist/core/runner/retired-runner-deps.js +1 -4
  215. package/dist/core/runner/run-leg.js +97 -43
  216. package/dist/core/runner/run-recovery-lanes.js +5 -3
  217. package/dist/core/runner/run-settle-and-teardown.js +2 -0
  218. package/dist/core/runner/run-terminal-adoption.js +21 -9
  219. package/dist/core/runner/run-turn-boundary.js +9 -3
  220. package/dist/core/runner/runtask.js +1 -1
  221. package/dist/core/runner/session-file-state-replay.d.ts +5 -2
  222. package/dist/core/runner/session-file-state-replay.js +3 -2
  223. package/dist/core/runner/skills-seat.d.ts +15 -0
  224. package/dist/core/runner/skills-seat.js +57 -0
  225. package/dist/core/runner/stream-steer-verb.js +2 -2
  226. package/dist/core/runner/sub-agent-deny-lists.d.ts +13 -11
  227. package/dist/core/runner/sub-agent-deny-lists.js +7 -5
  228. package/dist/core/runner/synthetic-tools.d.ts +5 -2
  229. package/dist/core/runner/synthetic-tools.js +2 -12
  230. package/dist/core/runner/tool-face-overlay.d.ts +24 -6
  231. package/dist/core/runner/tool-face-overlay.js +24 -15
  232. package/dist/core/runner-deps.d.ts +37 -22
  233. package/dist/core/session-policy-store.d.ts +19 -0
  234. package/dist/core/session-policy-store.js +22 -2
  235. package/dist/core/session-store.d.ts +35 -16
  236. package/dist/core/session-store.js +20 -12
  237. package/dist/core/{shell-lexer.d.ts → shell-run-candidates.d.ts} +36 -12
  238. package/dist/core/{shell-lexer.js → shell-run-candidates.js} +145 -225
  239. package/dist/core/shell-wrapper-table.d.ts +5 -3
  240. package/dist/core/shell-wrapper-table.js +1 -1
  241. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -2
  242. package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
  243. package/dist/core/store-contracts/session-store-contract.d.ts +49 -0
  244. package/dist/core/store-contracts/session-store-contract.js +639 -0
  245. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +12 -0
  246. package/dist/core/store-contracts/session-store-incarnation-contract.js +5 -2
  247. package/dist/core/task-event.d.ts +44 -6
  248. package/dist/core/task-notification.js +2 -2
  249. package/dist/core/task-registry-agent.js +1 -0
  250. package/dist/core/task-registry-shared.d.ts +5 -0
  251. package/dist/core/task-registry.d.ts +7 -0
  252. package/dist/core/task-registry.js +17 -0
  253. package/dist/core/task-result.d.ts +1 -1
  254. package/dist/core/task-spec.d.ts +7 -7
  255. package/dist/core/tighten-task-spec.d.ts +6 -4
  256. package/dist/core/tighten-task-spec.js +2 -2
  257. package/dist/core/tool-catalog-entries.d.ts +1 -1
  258. package/dist/core/tool-catalog-entries.js +52 -52
  259. package/dist/core/tool-face-reader.d.ts +49 -0
  260. package/dist/core/tool-face-reader.js +94 -0
  261. package/dist/core/tool-face.d.ts +17 -8
  262. package/dist/core/tool-face.js +1 -0
  263. package/dist/core/tool-policy.d.ts +67 -23
  264. package/dist/core/tool-policy.js +72 -60
  265. package/dist/core/tool-roster.d.ts +46 -28
  266. package/dist/core/tool-roster.js +91 -14
  267. package/dist/core/tool-spec-members.js +2 -2
  268. package/dist/core/tool-spec.d.ts +20 -4
  269. package/dist/core/tools.js +2 -0
  270. package/dist/core/trace.d.ts +24 -2
  271. package/dist/core/types.d.ts +3 -3
  272. package/dist/core/types.js +1 -1
  273. package/dist/core/untrusted-text.d.ts +23 -0
  274. package/dist/core/untrusted-text.js +10 -10
  275. package/dist/core/user-attachment.d.ts +56 -2
  276. package/dist/core/user-attachment.js +139 -56
  277. package/dist/core/wiring-manifest.d.ts +4 -2
  278. package/dist/engine/compaction/compaction.d.ts +2 -2
  279. package/dist/engine/compaction/utils.d.ts +2 -2
  280. package/dist/engine/harness/agent-harness.js +2 -1
  281. package/dist/engine/harness/types.d.ts +10 -4
  282. package/dist/engine/llm/types.d.ts +7 -2
  283. package/dist/engine/llm/types.js +2 -1
  284. package/dist/engine/loop/agent-loop.d.ts +12 -1
  285. package/dist/engine/loop/agent-loop.js +17 -5
  286. package/dist/engine/loop/types.d.ts +7 -1
  287. package/dist/engine/session/repo-utils.d.ts +5 -0
  288. package/dist/engine/session/repo-utils.js +9 -0
  289. package/dist/engine/session/storage-base.js +2 -2
  290. package/dist/index.d.ts +37 -17
  291. package/dist/index.js +31 -14
  292. package/dist/internal/harness.d.ts +1 -0
  293. package/dist/internal/harness.js +1 -0
  294. package/dist/internal/llm.d.ts +1 -1
  295. package/dist/internal/llm.js +1 -1
  296. package/dist/orchestration/goal.d.ts +24 -1
  297. package/dist/orchestration/goal.js +3 -2
  298. package/dist/orchestration/run-workflow-tool.d.ts +3 -0
  299. package/dist/orchestration/run-workflow-tool.js +1 -0
  300. package/dist/orchestration/workflow-governance.d.ts +1 -1
  301. package/dist/orchestration/workflow.d.ts +3 -0
  302. package/dist/orchestration/workflow.js +2 -1
  303. package/dist/prompt-assembly/artifact-store.d.ts +44 -9
  304. package/dist/prompt-assembly/artifact-store.js +38 -12
  305. package/dist/prompt-assembly/artifact.d.ts +12 -11
  306. package/dist/prompt-assembly/artifact.js +52 -21
  307. package/dist/prompt-assembly/assemble.d.ts +2 -0
  308. package/dist/prompt-assembly/assemble.js +2 -1
  309. package/dist/prompt-assembly/catalog/index.js +2 -1
  310. package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
  311. package/dist/prompt-assembly/catalog/memory.js +6 -0
  312. package/dist/prompt-assembly/catalog/schema.d.ts +19 -2
  313. package/dist/prompt-assembly/catalog/schema.js +3 -0
  314. package/dist/prompt-assembly/composer.d.ts +2 -0
  315. package/dist/prompt-assembly/composer.js +1 -1
  316. package/dist/prompt-assembly/overlay.d.ts +21 -11
  317. package/dist/prompt-assembly/overlay.js +57 -19
  318. package/dist/prompt-assembly/select.d.ts +21 -6
  319. package/dist/prompt-assembly/select.js +41 -4
  320. package/dist/prompts/default.d.ts +1 -12
  321. package/dist/prompts/default.js +0 -3
  322. package/dist/shell/lex.d.ts +87 -8
  323. package/dist/shell/lex.js +283 -49
  324. package/dist/stores/file/index.d.ts +8 -6
  325. package/dist/stores/file/permission-rule-store.d.ts +1 -1
  326. package/dist/stores/file/permission-rule-store.js +2 -1
  327. package/dist/tools/artifact/artifact-tool.js +14 -3
  328. package/dist/tools/fs/bash-program-position.d.ts +3 -15
  329. package/dist/tools/fs/bash-program-position.js +3 -10
  330. package/dist/tools/fs/bash-readonly-classifier.js +2 -0
  331. package/dist/tools/fs/fs-bash.d.ts +3 -3
  332. package/dist/tools/fs/fs-bash.js +72 -101
  333. package/dist/tools/fs/fs-read.d.ts +12 -0
  334. package/dist/tools/fs/fs-read.js +10 -9
  335. package/dist/tools/fs/fs-shared.d.ts +27 -31
  336. package/dist/tools/fs/fs-shared.js +12 -15
  337. package/dist/tools/fs/fs-write.js +1 -1
  338. package/dist/tools/fs/index.js +2 -2
  339. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  340. package/dist/tools/fs/read-deny-home.js +5 -4
  341. package/dist/tools/fs/read-deny.d.ts +16 -3
  342. package/dist/tools/fs/read-deny.js +12 -9
  343. package/dist/tools/fs/safety.d.ts +7 -6
  344. package/dist/tools/fs/shell-read-bindings.d.ts +5 -3
  345. package/dist/tools/fs/shell-read-bindings.js +15 -16
  346. package/dist/tools/fs/shell-read-device.js +1 -1
  347. package/dist/tools/fs/shell-read-plan.js +36 -47
  348. package/dist/tools/fs/shell-read-word.d.ts +1 -6
  349. package/dist/tools/fs/shell-read-word.js +2 -20
  350. package/dist/tools/fs/shell-reentry-text.js +1 -1
  351. package/dist/tools/web.d.ts +2 -2
  352. package/package.json +4 -1
  353. package/test/export-surface.snapshot.json +5651 -5457
  354. package/wire-changes/core@7.53.0.json +1968 -0
  355. package/wire-changes/core@7.54.0.json +2870 -0
  356. package/dist/core/shell-scan.d.ts +0 -60
  357. package/dist/core/shell-scan.js +0 -183
@@ -34,8 +34,30 @@
34
34
  * refused and disclosed — identity comparison alone cannot catch it, and an in-memory-only mark would
35
35
  * accept revision N−1 after a restart. Signature / predecessor chaining belongs to the privilege-
36
36
  * separation ticket; the high-water mark is the floor that needs no key distribution.
37
+ *
38
+ * ## One reading of a row
39
+ *
40
+ * A snapshot is installed and served on its ENVELOPE ({@link validateOrgSnapshot}: revision, observation
41
+ * time, a rules list) and the anti-rollback fence; what its rows say never decides which snapshot is in
42
+ * force. Whether the rules are a list is judged in ONE place ({@link listRefusalOf}) for the partition and for
43
+ * every store that hands a resolution over — rules that are not a list, or that carry more places than a rule set may
44
+ * (the same cap the rule compiler holds a set to), are governance nobody can read (the
45
+ * partition refuses the snapshot; the org lane answers unavailable), never a policy of zero rows — and ONE reader
46
+ * ({@link orgRuleListOf}) copies the whole list in one receipt: a member of a row that cannot be read is left out of
47
+ * that row's copy alone, and every row is judged on its copy. A snapshot the partition holds — fetched or read back
48
+ * from its persistence — is that same copy ({@link orgSnapshotCopyOf}). Every row is then read by ONE reader
49
+ * ({@link readOrgRules}), the same for every store that hands a resolution over, on its policy members
50
+ * ({@link ORG_ROW_POLICY_MEMBERS}): a row is READ when its behavior is `deny` or `ask` and its text is a shell command
51
+ * rule under that behavior. Any other row — another grammar's rule, a shell rule the validator refuses, a row
52
+ * with no text, a behavior this layer has no bucket for — is UNREADABLE, and stands at its strictest
53
+ * reading over the calls it may reach ({@link OrgRowReach}): an `ask` row asks a person, every other row
54
+ * refuses. Readable deny and ask rows hold as published beside it. One unreadable row therefore never
55
+ * takes the rest of the policy down with it, and never turns a published deny into a question; the
56
+ * snapshot is served DEGRADED, and every resolution and every adjudication over it names the unreadable
57
+ * rows ({@link describeUnreadableOrgRows}).
37
58
  */
38
- import { type PersistedRule, type RuleRejectCode } from "./permission-rule-model.js";
59
+ import { type ParsedRule, type PersistedRule, type RuleRejectCode } from "./permission-rule-model.js";
60
+ import type { DenyFace } from "../tools/fs/read-deny.js";
39
61
  import type { PermissionRuleStore } from "./permission-rule-provider.js";
40
62
  /** One org rule. There is structurally no allow bucket (design/179 §9: the org layer only tightens). */
41
63
  export interface OrgPermissionRule {
@@ -171,42 +193,183 @@ export declare const UNGOVERNED_ORG_RESOLUTION: Readonly<OrgRuleResolution>;
171
193
  * bound is refused loudly, never coerced.
172
194
  */
173
195
  export declare function createOrgRulePartition(cfg: OrgRulePartitionConfig): OrgRulePartition;
196
+ /** Whether two snapshots carry the same POLICY: row for row, the same policy members ({@link ORG_ROW_POLICY_MEMBERS}) — never
197
+ * observation metadata, never a member no judgment reads (which a copy may carry or leave out). The ONE test of "the same
198
+ * revision, the same content": the partition's equal-revision guard asks it of two snapshots it holds in one form
199
+ * ({@link orgSnapshotCopyOf}), and a persistence backend asks it of what it stores. */
200
+ export declare function sameOrgPolicyContent(a: OrgRuleSnapshot, b: OrgRuleSnapshot): boolean;
174
201
  /**
175
- * Which entries of an org snapshot the CURRENT rule validator refuses — the published deny/ask rules
176
- * that can match nothing on this build. Empty ⟺ every rule is enforceable.
202
+ * Which calls an UNREADABLE row may reach — the calls its strictest reading stands over.
177
203
  *
178
- * Separate from {@link validateOrgSnapshot} because BOTH gates need it: the install gate (a fetched
179
- * snapshot) and the serving gate (backlog #177 — a snapshot persisted by an earlier build is read back
180
- * and served without ever having met this validator). It reports every offender rather than the first,
181
- * since a refusal an administrator cannot act on names no line to fix.
204
+ * `"every"` when the row names no tool this layer can place: no rule text, a head the rule syntax cannot read, the lone
205
+ * `*`, or a tool with no rule grammar (a misspelled tool name and a tool this build does not know look the same, and
206
+ * both may be the shell). Otherwise the rule WORD it names — a shell tool's head is the command word, as a call's is —
207
+ * and, for a tool whose path rules speak for a face ({@link PATH_RULE_FACES}), the faces of the column its strictest
208
+ * behavior reads: such a row reaches what a readable rule of its tool could reach, and nothing else.
209
+ */
210
+ export type OrgRowReach = "every" | {
211
+ readonly words: readonly string[];
212
+ readonly faces: readonly DenyFace[];
213
+ };
214
+ /**
215
+ * A row the layer cannot read: its text (as published; the rendering of the scalar its `rule` holds when that is not a string;
216
+ * `<unreadable>` when it holds none — a structure is no value, {@link orgRowPolicyOf}), its 1-based place in the
217
+ * snapshot, why (`code`, and `detail` for a row whose shape — not its text — is at fault), the behavior it stands at, and
218
+ * the calls it reaches. `behavior` is the row's STRICTEST reading: `ask` only when the row says `ask`, `deny` for a row
219
+ * that says `deny` and for one whose behavior cannot be read.
220
+ */
221
+ export interface UnreadableOrgRow {
222
+ readonly kind: "unreadable";
223
+ readonly index: number;
224
+ readonly rule: string;
225
+ readonly code: RuleRejectCode;
226
+ readonly detail?: string;
227
+ readonly behavior: "deny" | "ask";
228
+ readonly reach: OrgRowReach;
229
+ }
230
+ /** A row the layer reads: a shell command rule under the behavior it publishes. */
231
+ export interface ReadOrgRow {
232
+ readonly kind: "read";
233
+ readonly index: number;
234
+ readonly rule: string;
235
+ readonly behavior: "deny" | "ask";
236
+ readonly parsed: ParsedRule;
237
+ }
238
+ /** One call as the org layer judges it: the rule words it answers to (`laneToolNamesOf`; one word is enough), its shell
239
+ * command when it is the shell tool's, and the face of its path target when it has one (`callPathFaceOf`). */
240
+ export interface OrgRuleCall {
241
+ readonly tool: string | readonly string[];
242
+ readonly command?: string;
243
+ readonly face?: DenyFace;
244
+ }
245
+ /** Every row of a snapshot read once, and the one judgment of a call against them. */
246
+ export interface OrgRulesReading {
247
+ readonly rows: readonly (ReadOrgRow | UnreadableOrgRow)[];
248
+ readonly unreadable: readonly UnreadableOrgRow[];
249
+ verdictFor(call: OrgRuleCall): OrgRuleVerdict | undefined;
250
+ }
251
+ /**
252
+ * The members of an org row the layer reads to judge a call — the row's POLICY. A row IS these members: every reader holds and
253
+ * judges a row as its policy ({@link orgRowPolicyOf}), and two rows with the same policy members are the same policy
254
+ * ({@link sameOrgPolicyContent}). Any other member a row carries is never judged, held, served or persisted (the receipt reads
255
+ * each of a row's own members once — a getter on one runs once — and copies none of what it holds beyond a scalar).
256
+ */
257
+ export declare const ORG_ROW_POLICY_MEMBERS: readonly ["rule", "behavior"];
258
+ /** A JSON scalar — the only value a member the partition keeps holds as data. */
259
+ type Scalar = string | number | boolean | null;
260
+ type ScalarMembers<K extends string> = {
261
+ [P in K]?: Scalar;
262
+ };
263
+ type OrgRowPolicy = Readonly<ScalarMembers<(typeof ORG_ROW_POLICY_MEMBERS)[number]>>;
264
+ /**
265
+ * The envelope's rules LIST, read once: `refused` when it is not a list of at most the cap's places ({@link listRefusalOf} —
266
+ * judged before the list is received, so an oversized or sparse list builds no row) or cannot be received at all;
267
+ * otherwise its rows, each as its policy ({@link orgRowPolicyOf}) — the list received whole in one receipt
268
+ * ({@link ORG_RULES_RECEIPT}), so a row's member that cannot be read is that row's alone, a row that cannot be read at all (and
269
+ * a hole) is a row with nothing in it (`{}`: no rule text, read at its strictest reading) and the rows beside it are untouched.
270
+ * The ONE reader of the list — the partition holds a snapshot's rows as these, fetched and read back alike
271
+ * ({@link orgSnapshotCopyOf}), and every reading of rows ({@link readOrgRules}) reads them through it — so no store's rows can be
272
+ * read two ways, and no row can take the reading of another down with it.
273
+ */
274
+ export declare function orgRuleListOf(rules: unknown): {
275
+ readonly rows: readonly OrgRowPolicy[];
276
+ } | {
277
+ readonly refused: string;
278
+ };
279
+ /** A snapshot the partition holds whose rules the list judgment refused: the envelope it carried and the words it was refused in,
280
+ * judged ONCE, on the list as it stood at the receipt. It has no `rules` at all (so no reading can take it for a table of zero
281
+ * rows) and keeps none of the caller's value (a list past the cap is a live array, and the partition awaits its persistence
282
+ * between the receipt and the validator, so a source that shrank the list it handed over in between would otherwise be admitted,
283
+ * uncopied and mutable, on a judgment it no longer meets). It is never installed or served. */
284
+ export interface RefusedOrgSnapshot extends Omit<OrgRuleSnapshot, "rules"> {
285
+ readonly refused: string;
286
+ }
287
+ /** What the partition holds of one snapshot, fetched or read back: one that can be installed, or the refusal of one that cannot.
288
+ * Read it by its shape — `rules` is on the first arm only, and {@link validateOrgSnapshot} is the one way from a held snapshot to an
289
+ * installable one. */
290
+ export type HeldOrgSnapshot = OrgRuleSnapshot | RefusedOrgSnapshot;
291
+ /** A snapshot as the partition holds it — fetched from the source or read back from its persistence alike: its envelope's members
292
+ * ({@link ORG_SNAPSHOT_ENVELOPE_MEMBERS} through {@link scalarMembersOf}; anything else it carries is never read or kept), its
293
+ * rows as the one list reader reads them (each row its policy) — so a snapshot read back reads, and compares, exactly as the one
294
+ * fetched, and what is persisted is never larger than these. Rules the list judgment refuses (not a list, a Proxy, past the cap)
295
+ * are held as that refusal alone ({@link RefusedOrgSnapshot}; the list judgment runs no code of the value's); such a snapshot — and
296
+ * one that is not an object, whose envelope has no members — is never installed or served. A list that cannot be received, and a
297
+ * Proxy snapshot (its traps would answer for the envelope), throw: an envelope that cannot be copied. Exported for the pins; the
298
+ * package root does not carry it. */
299
+ export declare function orgSnapshotCopyOf(v: unknown): HeldOrgSnapshot;
300
+ /**
301
+ * The ONE reading of an org snapshot's rows: each row read once ({@link readOrgRow}), and the one judgment of a call
302
+ * against them. Every reader of org rows goes through it — the partition's degraded line, the lane's adjudication,
303
+ * {@link orgRuleVerdictFor}, {@link unenforceableOrgRules} and the shadow view — so no two of them can read one row two ways.
304
+ *
305
+ * A call meets the rows in three answers. DENY: a readable deny reaches one of its program runs, or an unreadable row
306
+ * standing at deny reaches the call — the first such row in snapshot order speaks. ASK: a readable rule the call cannot be
307
+ * READ against (the lexer's reason — a rule that cannot be judged may be a deny, so it outranks a reached ask), else a
308
+ * readable ask reaching it or an unreadable row standing at ask reaching it, the first in snapshot order. Otherwise none.
309
+ * An unreadable row's verdict carries its reason ({@link unreadableOrgRowReason}) beside its text.
310
+ *
311
+ * The rows are read off the one list reader's copy ({@link orgRuleListOf}): rules that are not a list come back `refused` —
312
+ * the org's rules cannot be read, which is never a policy of zero rows — and a row is judged on what its copy holds: a policy
313
+ * member that could not be read is one the row does not have (no `rule` ⇒ no rule text, every call; no `behavior` ⇒ its
314
+ * strictest reading over the calls of the tool it names), read like any other unreadable row while the rows beside it keep
315
+ * their effect.
316
+ */
317
+ export declare function readOrgRules(rules: unknown): OrgRulesReading | {
318
+ readonly refused: string;
319
+ };
320
+ /**
321
+ * Which rows of an org snapshot this layer cannot read, each with its code — the rows that stand at their strictest
322
+ * reading instead of as published. Empty ⟺ every row is read. Every unreadable row is reported, a row with no rule text
323
+ * or a behavior other than deny / ask included (its text rendered when it is not a string). Rules that are not a list, or a
324
+ * list past the cap, throw the one list judgment's sentence ({@link readListedOrgRules}) — never a reading of fewer rows.
182
325
  */
183
326
  export declare function unenforceableOrgRules(rules: readonly OrgPermissionRule[]): Array<{
184
327
  rule: string;
185
328
  code: RuleRejectCode;
186
329
  }>;
330
+ /** The reason an unreadable row's verdict carries — its place in the snapshot, its code, and the repair. */
331
+ export declare function unreadableOrgRowReason(row: Pick<UnreadableOrgRow, "index" | "code" | "detail">): string;
332
+ /** The ONE clause for an org verdict that carries an `unreadable` reason — a rule the call could not be read against, or
333
+ * a row this layer cannot read — on a refusal and on a question alike. */
334
+ export declare function orgUnreadableClause(reason: string): string;
335
+ /**
336
+ * The ONE line naming a snapshot's unreadable rows (count, the first {@link DISCLOSED_UNREADABLE_ROWS} by place, text and
337
+ * code, the rest summarized), or `undefined` when every row is read. The partition puts it on every resolution that
338
+ * serves such a snapshot, and the org lane hands it to its operator sink on every adjudication over one, so the two seats
339
+ * describe one snapshot in one sentence. Each text is escaped — the characters that most often make a row unreadable are
340
+ * exactly the ones that do not render.
341
+ */
342
+ export declare function describeUnreadableOrgRows(unreadable: readonly UnreadableOrgRow[], revision?: unknown): string | undefined;
187
343
  /**
188
- * design/182 §7.2 — which org rule speaks for this command, if any. Deny outranks ask; within a
189
- * behavior the first textual match wins (reporting order only — all denies are the same one answer).
190
- * Matching uses the SAME parser and the SAME tightening reach the personal deny/ask rows use
191
- * ({@link programRunReachOf}: an interpreter-headed prefix deny like `Bash(node:*)` is a
192
- * legitimately wide tightening and matches; a segment hit is a hit; a call the lexer cannot read
193
- * against a rule is an ASK with the reason — fail closed, never silence).
194
- *
195
- * The skip below is a defensive floor, and what stands behind it is worth stating precisely: rules that
196
- * arrive from the org partition's `resolve` ({@link createOrgRulePartition}) have passed {@link validateOrgSnapshot} on BOTH the install
197
- * and the serving path (backlog #177), so an unenforceable entry cannot reach here through the overlay
198
- * — the whole snapshot is refused, or the resolution reports `unavailable`, and either way it is
199
- * disclosed. A caller that hands this function a snapshot it obtained ELSEWHERE gets no such guarantee:
200
- * the skip is silent, and naming the dead entries is that caller's job — {@link unenforceableOrgRules}
201
- * is the shared way to do it.
344
+ * Envelope validation of one held snapshot — what the staleness bound and the anti-rollback fence need to judge it. Answers
345
+ * the snapshot as an installable one, or the words it is refused in: a finite revision, a finite observation time not in the
346
+ * future beyond the skew allowance, and rules that are a LIST ({@link listRefusalOf}, judged at the receipt — a held snapshot
347
+ * whose list was refused there is answered in those words). The rows inside are not judged here: a row this layer cannot
348
+ * read is read as such by {@link readOrgRules}, and never takes the rest of the snapshot down with it.
349
+ *
350
+ * Run on BOTH the fetch path (before install) and the serving path (before a persisted snapshot adjudicates), so the
351
+ * two cannot diverge on what an installable snapshot is — see backlog #177. The only way from a {@link HeldOrgSnapshot} to an
352
+ * installable {@link OrgRuleSnapshot}: install and serve read the `admitted` arm.
202
353
  */
203
- export declare function orgRuleVerdictFor(rules: readonly OrgPermissionRule[], call: {
204
- tool: string;
205
- command: string;
206
- }): OrgRuleVerdict | undefined;
207
- /** The org layer's answer for one call: which rule spoke, with what behavior — and, when the call could
208
- * not be READ against the org's rules, the lexer's reason beside the first rule it could not judge
209
- * (`behavior` is then `ask`: the org published a rule that may reach this call, and nobody can say). */
354
+ export declare function validateOrgSnapshot(s: HeldOrgSnapshot, nowMs: number): {
355
+ readonly admitted: OrgRuleSnapshot;
356
+ } | {
357
+ readonly refused: string;
358
+ };
359
+ /**
360
+ * design/182 §7.2 — which org rule speaks for this call, if any: {@link readOrgRules}'s judgment, over a snapshot read for
361
+ * this call alone. Matching uses the SAME parser and the SAME tightening reach the personal deny/ask rows use
362
+ * ({@link programRunReachOf}: an interpreter-headed prefix deny like `Bash(node:*)` is a legitimately wide tightening and
363
+ * matches; a segment hit is a hit; a call the lexer cannot read against a rule is an ASK with the reason — fail closed,
364
+ * never silence), and a row this layer cannot read stands at its strictest reading over the calls it may reach. A caller
365
+ * judging many calls against one snapshot reads it once with {@link readOrgRules} instead. Rules that are not a list, or a
366
+ * list past the cap, throw the one list judgment's sentence ({@link readListedOrgRules}) — never a verdict over fewer rows.
367
+ */
368
+ export declare function orgRuleVerdictFor(rules: readonly OrgPermissionRule[], call: OrgRuleCall): OrgRuleVerdict | undefined;
369
+ /** The org layer's answer for one call: which rule spoke, with what behavior — and, when the rule could not be judged
370
+ * against the call, why (`unreadable`): either the call could not be READ against it (the lexer's reason; `behavior` is
371
+ * then `ask` — the org published a rule that may reach this call, and nobody can say), or the row is not one this layer
372
+ * reads ({@link unreadableOrgRowReason}; `behavior` is the row's strictest reading). */
210
373
  export interface OrgRuleVerdict {
211
374
  readonly behavior: "deny" | "ask";
212
375
  readonly rule: string;
@@ -234,14 +397,18 @@ export interface OrgRuleVerdict {
234
397
  * either way. org ASK rules do not shadow: the personal lane never consumes a `requiresRealApproval`
235
398
  * ask, so the two never actually meet on one call.
236
399
  *
237
- * design/382 §2.6 — a Read directory rule is never org-shadowed in this version: the org layer has no
238
- * Read grammar (a snapshot carrying one refuses whole at the validator), so there is no deny that could
239
- * reach it, and its `command` is a PATH that must not be fed to the shell lane's segment reader as
240
- * though it were a command line.
400
+ * An UNREADABLE row standing at deny refuses every call it reaches ({@link readOrgRules}), so it shadows every personal
401
+ * rule of a tool it reaches — by the rule word, or by the face that tool's calls are on — exactly as the gate refuses
402
+ * those calls; one standing at ask does not shadow, as a readable ask does not.
403
+ *
404
+ * design/382 §2.6 — no READABLE org row reaches a Read directory rule in this version: the org layer has no Read
405
+ * grammar, and the rule's `command` is a PATH that must not be fed to the shell lane's segment reader as though it
406
+ * were a command line.
241
407
  */
242
408
  export declare function orgRuleShadows(orgRules: readonly OrgPermissionRule[], rule: Pick<PersistedRule, "tool" | "command">): boolean;
243
- /** The shadow predicate with the org denies parsed ONCE — what a read over many rows uses. */
409
+ /** The shadow predicate with the org rows read ONCE — what a read over many rows uses. */
244
410
  export declare function compileOrgShadowPredicate(orgRules: readonly OrgPermissionRule[]): (rule: Pick<PersistedRule, "tool" | "command">) => boolean;
245
411
  /** Does this store carry a write face? Re-exported convenience for org-ticket integrations that need to
246
412
  * distinguish a read-only projection from a writable personal bucket without importing the writer seam. */
247
413
  export declare function isWritablePermissionRuleStore(store: PermissionRuleStore): boolean;
414
+ export {};