@sema-agent/core 7.72.0 → 7.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -5,7 +5,7 @@ import { countLines, retireRead, witnessesAfterDelivery } from "../../tools/fs/f
5
5
  import { expandHomeTilde, isAbsoluteForFamily, lexicalViewOf, pathFamilyOf, sha256, startsWithDriveLetter, withinAnyRoot } from "../../tools/fs/safety.js";
6
6
  import { relativeUnderRoot } from "../sensitive-path-policy.js";
7
7
  import { ORG_ADJUDICATION_TIMEOUT_MS } from "../permission-rule-org.js";
8
- import { isInstructionLaneEntry, mintInstructionFrames } from "../user-attachment.js";
8
+ import { instructionFrameOwnerOf, isInstructionLaneEntry, mintInstructionFrames } from "../user-attachment.js";
9
9
  import { deliverEngineNotice } from "../engine-notice.js";
10
10
  import { agentIdOf } from "../leg-identity.js";
11
11
  import { describeRejectedValue } from "../tool-search-setting.js";
@@ -399,6 +399,8 @@ export function createNestedMemoryLane(seat) {
399
399
  queue.unshift(...back);
400
400
  };
401
401
  let primed;
402
+ const firstLoadIncluded = new Map();
403
+ const firstLoadWithheld = new Map();
402
404
  const hostTexts = decl.hostRules.map((t) => {
403
405
  const shown = processInstructionText(normalizeFileText(t.text), decl.includes);
404
406
  return { ...t, shown, owner: OWNER_OF_LEVEL[t.level], anchored: hands !== undefined && isAbsoluteHostPath(t.name), conditional: t.rule && shown.globs !== undefined };
@@ -426,6 +428,12 @@ export function createNestedMemoryLane(seat) {
426
428
  const leg = seat.leg();
427
429
  if (leg === undefined || seat.signal.aborted)
428
430
  return [];
431
+ const forManifest = ask.forManifest === true;
432
+ const recordIncluded = (item, key) => {
433
+ if (forManifest && item.from !== undefined && !firstLoadIncluded.has(key)) {
434
+ firstLoadIncluded.set(key, Object.freeze({ path: key, includedBy: item.from.key, spelled: item.from.spelled }));
435
+ }
436
+ };
429
437
  const accesses = new Set();
430
438
  const current = new Map();
431
439
  const firstLoad = seen === undefined;
@@ -490,15 +498,29 @@ export function createNestedMemoryLane(seat) {
490
498
  fresh.push(d);
491
499
  say();
492
500
  };
493
- const withheld = (item, reason, past, target) => once(INSTRUCTIONS_WITHHELD, item.path, target === undefined ? reason : `${reason}\n${target}`, () => {
494
- if (delegated)
495
- return;
496
- const path = item.path;
497
- const r = rootLevelOf(path);
498
- const what = past !== undefined ? `An instruction text the deployment supplied, the first of ${past} past the ${NESTED_MEMORY_MAX_HOST_RULES} a task carries,` : item.from !== undefined ? `An instruction file that ${item.from.key} includes (\`@${item.from.spelled}\`)` : `An instruction file of ${r === 0 ? "the task root" : r > 0 ? "an additional working directory" : "a directory the model accessed"}`;
499
- const via = item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {};
500
- deliverEngineNotice(seat.deps.onNotice, { code: INSTRUCTIONS_WITHHELD, message: `${what} was not loaded: ${path} (${WITHHELD_TEXT[reason]}). ${WITHHELD_WAY_OUT[reason]}`, detail: { path, reason, sessionId: leg.sessionId, runId: leg.runId, ...via, ...(target !== undefined ? { target } : {}) } });
501
- });
501
+ const withheld = (item, reason, past, target, blockedAfterApproval) => {
502
+ if (forManifest && (item.rule === "any" || item.from !== undefined || reason === "too_many_texts" || reason === "unanchored")) {
503
+ const wKey = `${item.path}\u0000${reason}\u0000${target ?? ""}\u0000${item.from?.key ?? ""}\u0000${item.from?.spelled ?? ""}`;
504
+ if (!firstLoadWithheld.has(wKey)) {
505
+ firstLoadWithheld.set(wKey, Object.freeze({
506
+ path: item.path,
507
+ reason,
508
+ ...(target !== undefined ? { target } : {}),
509
+ ...(item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {}),
510
+ ...(blockedAfterApproval !== undefined ? { blockedAfterApproval } : {}),
511
+ }));
512
+ }
513
+ }
514
+ once(INSTRUCTIONS_WITHHELD, item.path, target === undefined ? reason : `${reason}\n${target}`, () => {
515
+ if (delegated)
516
+ return;
517
+ const path = item.path;
518
+ const r = rootLevelOf(path);
519
+ const what = past !== undefined ? `An instruction text the deployment supplied, the first of ${past} past the ${NESTED_MEMORY_MAX_HOST_RULES} a task carries,` : item.from !== undefined ? `An instruction file that ${item.from.key} includes (\`@${item.from.spelled}\`)` : `An instruction file of ${r === 0 ? "the task root" : r > 0 ? "an additional working directory" : "a directory the model accessed"}`;
520
+ const via = item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {};
521
+ deliverEngineNotice(seat.deps.onNotice, { code: INSTRUCTIONS_WITHHELD, message: `${what} was not loaded: ${path} (${WITHHELD_TEXT[reason]}). ${WITHHELD_WAY_OUT[reason]}`, detail: { path, reason, sessionId: leg.sessionId, runId: leg.runId, ...via, ...(target !== undefined ? { target } : {}) } });
522
+ });
523
+ };
502
524
  const tellOperator = (lane, path, why, sentence) => once(lane, path, why, () => {
503
525
  try {
504
526
  seat.deps.onError?.(new Error(sentence), { phase: "degraded", sessionId: leg.sessionId, classification: "attachment-read" });
@@ -510,10 +532,10 @@ export function createNestedMemoryLane(seat) {
510
532
  const unlimited = (path) => tellOperator("nested_memory_rule_paths", path, "no_limit", `instruction rule ${path} names \`paths:\` but it reads as no limit (nothing listed, only \`**\`, or a form the engine does not recognise), so the rule applies to every file; to limit it, list the globs (\`paths:\` then \`- src/**\` lines, or \`paths: [src/**, lib/**]\`); if every file is meant, remove the key`);
511
533
  const spansLines = (path) => tellOperator("nested_memory_rule_paths", path, "spans_lines", `instruction rule ${path} gives \`paths:\` as one text over several lines, which reads as a single glob that matches no file, so the rule is never loaded; for several globs list them (\`paths:\` then \`- src/**\` lines) or write them on one line separated by commas (\`paths: src/**, lib/**\`)`);
512
534
  const outside = new Map();
513
- const refusedOutside = (item, wide, key, target) => {
535
+ const refusedOutside = (item, wide, key, target, targetOk = false) => {
514
536
  const held = outside.get(item.path);
515
537
  const edge = !foundByLane(item) || item.approved === true;
516
- const told = held === undefined || (edge && !held.edge) ? { item, edge, key: key ?? item.path, target } : held;
538
+ const told = held === undefined || (edge && !held.edge) ? { item, edge, key: key ?? item.path, target, targetOk } : held;
517
539
  outside.set(item.path, { ...told, wide: wide || held?.wide === true });
518
540
  };
519
541
  const reads = [];
@@ -589,8 +611,8 @@ export function createNestedMemoryLane(seat) {
589
611
  if (info.value.kind === "directory")
590
612
  return [];
591
613
  const heldToItsRoots = async (key) => foundByLane(item) && item.approved !== true && !(await approvedByRequest(key));
592
- const outsideItsRoot = (key, judged) => {
593
- refusedOutside(item, false, key, judged);
614
+ const outsideItsRoot = (key, judged, targetOk) => {
615
+ refusedOutside(item, false, key, judged, targetOk);
594
616
  return member !== undefined ? [member] : [];
595
617
  };
596
618
  const target = await hands.reader.resolveTarget(item.path, { signal: seat.signal });
@@ -600,13 +622,13 @@ export function createNestedMemoryLane(seat) {
600
622
  withheld(item, "rule_denied");
601
623
  else if (card === "path_not_in_root") {
602
624
  const judged = judgedKeyOf(target);
603
- return (await heldToItsRoots(judged)) ? outsideItsRoot(undefined, judged) : (refusedOutside(item, true), []);
625
+ return (await heldToItsRoots(judged)) ? outsideItsRoot(undefined, judged, false) : (refusedOutside(item, true), []);
604
626
  }
605
627
  return [];
606
628
  }
607
629
  const key = target.key;
608
630
  if (!insideItsRoots(item.root, key) && (await heldToItsRoots(key)))
609
- return outsideItsRoot(key, key);
631
+ return outsideItsRoot(key, key, true);
610
632
  if (visited.has(key) || inFlight.has(key))
611
633
  return [];
612
634
  const stat = info.value.kind === "symlink" ? await hands.env.fileInfo(key, seat.signal).catch(() => undefined) : info;
@@ -616,6 +638,7 @@ export function createNestedMemoryLane(seat) {
616
638
  const entry = state.get(key);
617
639
  if (entry !== undefined && entry.lastReadAt === mtime && (!decl.includes || includesBy.has(key))) {
618
640
  visited.add(key);
641
+ recordIncluded(item, key);
619
642
  return includesAt(includesBy.get(key) ?? [], item, key);
620
643
  }
621
644
  p.count++;
@@ -624,7 +647,7 @@ export function createNestedMemoryLane(seat) {
624
647
  try {
625
648
  const verdict = await hands.judge({ file_path: item.path, ...(face !== undefined ? { face } : {}) }, NESTED_MEMORY_PROBE_FACE, { deadlineAt });
626
649
  if (verdict.verdict !== "no_objection") {
627
- withheld(item, verdict.verdict === "deny" ? "rule_denied" : verdict.verdict === "ask" ? "approval_required" : "admission_unknown");
650
+ withheld(item, readJudgeBlockOf(verdict));
628
651
  return [];
629
652
  }
630
653
  if (verdict.judged !== undefined && verdict.judged !== key) {
@@ -664,8 +687,10 @@ export function createNestedMemoryLane(seat) {
664
687
  const more = includesAt(targets, item, key);
665
688
  if (pending.has(key))
666
689
  return more;
667
- if (entry !== undefined && entry.hash === hash)
690
+ if (entry !== undefined && entry.hash === hash) {
691
+ recordIncluded(item, key);
668
692
  return more;
693
+ }
669
694
  if (shown.content.trim() === "") {
670
695
  if (entry !== undefined && isInstructionLaneEntry(entry))
671
696
  withdraw(key, item);
@@ -681,6 +706,7 @@ export function createNestedMemoryLane(seat) {
681
706
  const read = {
682
707
  supply: "path",
683
708
  owner: item.owner ?? "repository",
709
+ ...(item.from !== undefined ? { included: true } : {}),
684
710
  layer,
685
711
  label: key,
686
712
  text: cut.text,
@@ -697,6 +723,7 @@ export function createNestedMemoryLane(seat) {
697
723
  },
698
724
  };
699
725
  reads.push({ read, item, key });
726
+ recordIncluded(item, key);
700
727
  return more;
701
728
  };
702
729
  const includeTargetsOf = (paths, from) => {
@@ -813,7 +840,7 @@ export function createNestedMemoryLane(seat) {
813
840
  withheld({ path: spelled, from: { key: t.name, spelled } }, "unanchored");
814
841
  const cut = cutInstructionText(t.shown.content, cap, cpt);
815
842
  const layer = t.conditional ? "nested" : "root";
816
- if (last?.text !== cut.text || last.layer !== layer)
843
+ if (last?.text !== cut.text || last.layer !== layer || (last.owner !== undefined && last.owner !== t.owner))
817
844
  hostRead(t.name, layer, t.owner, cut);
818
845
  }
819
846
  for (const [name, last] of shownNow)
@@ -822,9 +849,27 @@ export function createNestedMemoryLane(seat) {
822
849
  }
823
850
  queueOwed(hostIncludes.filter(claim), true);
824
851
  await drain();
825
- for (const r of outside.values())
826
- if (!visited.has(r.key) && !(inFlight.has(r.key) && !withdrawing.has(r.key)) && !queued.has(itemId(r.item)))
827
- withheld(r.item, r.wide ? "outside_roots" : "outside_its_root", undefined, r.wide ? undefined : r.target);
852
+ for (const r of outside.values()) {
853
+ if (visited.has(r.key) || (inFlight.has(r.key) && !withdrawing.has(r.key)) || queued.has(itemId(r.item)))
854
+ continue;
855
+ let blockedAfterApproval;
856
+ if (!r.wide && forManifest && hands !== undefined) {
857
+ if (!r.targetOk)
858
+ blockedAfterApproval = "outside_roots";
859
+ else {
860
+ try {
861
+ const face = hands.readFace();
862
+ const verdict = await hands.judge({ file_path: r.item.path, ...(face !== undefined ? { face } : {}) }, NESTED_MEMORY_PROBE_FACE, { deadlineAt });
863
+ blockedAfterApproval = readJudgeBlockOf(verdict);
864
+ }
865
+ catch (err) {
866
+ unread(r.item.path, thrownText(err));
867
+ blockedAfterApproval = "admission_unknown";
868
+ }
869
+ }
870
+ }
871
+ withheld(r.item, r.wide ? "outside_roots" : "outside_its_root", undefined, r.wide ? undefined : r.target, blockedAfterApproval);
872
+ }
828
873
  const includeReads = reads.splice(0);
829
874
  reads.push(...rootLayer, ...includeReads, ...familyReads, ...nestedLayer);
830
875
  if (fresh.length > 0) {
@@ -868,7 +913,7 @@ export function createNestedMemoryLane(seat) {
868
913
  if (primed !== undefined)
869
914
  return;
870
915
  const echo = { fn: undefined };
871
- primed = { reads: await collect({}, echo), echo };
916
+ primed = { reads: await collect({ forManifest: true }, echo), echo };
872
917
  },
873
918
  async load(ask) {
874
919
  const held = primed;
@@ -902,8 +947,10 @@ export function createNestedMemoryLane(seat) {
902
947
  return reads.length === 0 ? [] : fitLoad(reads, leg).minted.frames;
903
948
  },
904
949
  selected() {
905
- if (hands === undefined)
906
- return undefined;
950
+ const withheldList = [...firstLoadWithheld.values()];
951
+ if (hands === undefined) {
952
+ return withheldList.length > 0 ? Object.freeze({ selected: Object.freeze([]), withheld: Object.freeze(withheldList) }) : undefined;
953
+ }
907
954
  const keys = roots.map(() => new Set());
908
955
  for (const key of [...state.keys(), ...inFlight]) {
909
956
  const r = withdrawing.has(key) ? -1 : rootLevelOf(key);
@@ -919,19 +966,31 @@ export function createNestedMemoryLane(seat) {
919
966
  return Object.freeze([...keys[r]].map((k) => relIn(r, k)).sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : a > b ? 1 : 0)));
920
967
  };
921
968
  const additional = roots.slice(1).map((x, i) => Object.freeze({ directory: x.directory, selected: of(i + 1) }));
922
- return Object.freeze({ selected: of(0), ...(decl.additionalDirectories ? { additionalDirectories: Object.freeze(additional) } : {}) });
969
+ const included = [...firstLoadIncluded.entries()].filter(([k]) => !withdrawing.has(k) && (state.has(k) || inFlight.has(k))).map(([, v]) => v);
970
+ return Object.freeze({
971
+ selected: of(0),
972
+ ...(decl.additionalDirectories ? { additionalDirectories: Object.freeze(additional) } : {}),
973
+ ...(included.length > 0 ? { included: Object.freeze(included) } : {}),
974
+ ...(withheldList.length > 0 ? { withheld: Object.freeze(withheldList) } : {}),
975
+ });
923
976
  },
924
977
  isMember,
925
978
  };
926
979
  }
927
- export async function primeInstructionLane(lane, manifest, report) {
980
+ function readJudgeBlockOf(verdict) {
981
+ return verdict.verdict === "no_objection" ? undefined : verdict.verdict === "deny" ? "rule_denied" : verdict.verdict === "ask" ? "approval_required" : "admission_unknown";
982
+ }
983
+ export async function primeInstructionReading(lane, report) {
928
984
  try {
929
985
  await lane.prime();
930
986
  }
931
987
  catch (err) {
932
988
  report(asThrownError(err));
933
989
  }
934
- const selected = lane.selected();
990
+ return lane.selected();
991
+ }
992
+ export async function primeInstructionLane(lane, manifest, report) {
993
+ const selected = await primeInstructionReading(lane, report);
935
994
  if (selected !== undefined)
936
995
  manifest.instructions = selected;
937
996
  }
@@ -941,8 +1000,10 @@ function lastHostTexts(messages) {
941
1000
  const a = userAttachmentOf(m);
942
1001
  if (a === undefined || a.supply !== "content_text" || (a.origin !== "nested_memory" && a.origin !== "project_instructions"))
943
1002
  continue;
944
- const blocks = m.content.slice(a.dataBlocks.start, a.dataBlocks.end);
945
- out.set(a.label, { text: a.withdraws !== undefined ? undefined : blocks.map((b) => (b.type === "text" ? (b.text ?? "") : "")).join(""), layer: a.origin === "project_instructions" ? "root" : "nested" });
1003
+ const content = m.content;
1004
+ const blocks = content.slice(a.dataBlocks.start, a.dataBlocks.end);
1005
+ const opening = content[0]?.type === "text" ? (content[0].text ?? "") : "";
1006
+ out.set(a.label, { text: a.withdraws !== undefined ? undefined : blocks.map((b) => (b.type === "text" ? (b.text ?? "") : "")).join(""), layer: a.origin === "project_instructions" ? "root" : "nested", owner: instructionFrameOwnerOf(opening) });
946
1007
  }
947
1008
  return out;
948
1009
  }
@@ -59,11 +59,12 @@ import { type PathRuleBases } from "../permission-rule-model.js";
59
59
  import { type BoundPathRule, type HeadLeads } from "../path-rule-binding.js";
60
60
  import { type RuleStoreFault } from "../rule-store-fault.js";
61
61
  import type { RunnerDeps } from "../runner-deps.js";
62
- import { type JudgedPathRow, type PathRuleDenyRow, type ReadDenyBuiltinConfig, type ReadDenyEntry, type ReadDenySeat, type WriteDenyMatcher } from "../../tools/fs/read-deny.js";
62
+ import { type JudgedPathRow, type PathRuleDenyRow, type ReadDenyBuiltinConfig, type ReadDenyEntry, type ReadDenyRootAnswer, type ReadDenySeat, type WriteDenyMatcher } from "../../tools/fs/read-deny.js";
63
63
  import { type HomeViewSource, type PlacedReadDenyMatcher } from "../../tools/fs/read-deny-home.js";
64
64
  import { type ReadStationMember } from "../../tools/fs/file-read-check.js";
65
65
  import { type ShellReadCheck } from "../../tools/fs/shell-read-check.js";
66
66
  import type { ReadAskRow } from "../../tools/fs/shell-read-judge.js";
67
+ import type { ConfinedDenyRows } from "../shell-read-silence.js";
67
68
  import { type SessionPermissionRules } from "../session-policy-store.js";
68
69
  import type { SkillGrantRecord } from "../skill-grant.js";
69
70
  import type { AgentTool, ExecutionEnv } from "../../internal/harness-types.js";
@@ -209,8 +210,9 @@ export interface PersonPathRows {
209
210
  * asking the store nothing new, the prepare read for the first request, and the newest read asked since the previous
210
211
  * request that the store has left unanswered past its bound. Bounded ({@link PERSON_READ_BOUND_MS}); never rejects. */
211
212
  forRequest(): Promise<PersonRowsRead>;
212
- /** Settles once the tables a reader takes are compiled: a pinned call's own; any other reader's (no id, or a call holding
213
- * no pin), the unit's newest — through every change that lands meanwhile, within {@link PATH_TABLES_READY_BOUND_MS} —
213
+ /** Settles once the tables a reader takes are compiled and the scopes of the bad rows of the read they stand on are judged (or
214
+ * their judgment ran out of time): a pinned call's own; any other reader's (no id, or a call holding no pin), the unit's newest —
215
+ * through every change that lands meanwhile, within {@link PATH_TABLES_READY_BOUND_MS} —
214
216
  * or at `signal` or the run's cut ({@link PersonPathRowsConfig.signal}). Never rejects: a reader whose wait was cut
215
217
  * checks its own signal and refuses; tables still compiling, or that could not be compiled, refuse at the read
216
218
  * ({@link PathTablesFacade.forCall}). */
@@ -305,11 +307,22 @@ export declare function readRootsOver(seats: {
305
307
  type WriteDenySeat = {
306
308
  readonly writeDenyMatch?: (p: string) => string | null;
307
309
  readonly writeDenyGuardsReads?: (pattern: string) => boolean;
310
+ readonly writeDenyUnder?: (p: string) => ReadDenyRootAnswer;
311
+ readonly writeDenyAtOrBelow?: (p: string) => string | null;
312
+ readonly writeDenyNamed?: {
313
+ readonly rows: readonly string[];
314
+ readonly ledBy: (entryName: string) => string | null;
315
+ };
308
316
  };
309
317
  export declare function denySeatsOf(t: PathTables): {
310
318
  readonly read: ReadDenySeat;
311
319
  readonly write: WriteDenySeat;
312
320
  };
321
+ /** The deny rows ONE call may meet, as a confined Runner's mode point reads them (`ConfinedDenyRows`): on the call's own tables
322
+ * (`forCall(toolCallId)`, the read its judgment started with) or on the ones in force now (`forCall(undefined)`), by the presence
323
+ * rules the station's boundary is built with ({@link denySeatsOf}). Rows that could not be read (`unreadFor`), no tables (a leg
324
+ * without hands) or tables that could not be handed over (a throw) count as both kinds of row. */
325
+ export declare function confinedDenyRowsOf(tables: Pick<PathTablesFacade, "forCall"> | undefined, unreadFor: (toolCallId: string | undefined) => boolean, toolCallId: string): ConfinedDenyRows;
313
326
  /**
314
327
  * The leg's read stations as ONE gate input, each judgment on its call's pinned read of the person's rules: the station in
315
328
  * the fold judges ahead of the rule lanes, so it takes the call's read before it judges — the read every later consumer of
@@ -360,19 +373,17 @@ export declare function personPathRowsOfTask(t: {
360
373
  /**
361
374
  * The run's ONE notice of stored rule rows (`config.entries_not_applied`, kind `stored_rule_row`; before 7.70.0 the code
362
375
  * `permission.rule_row_dropped`; audience user): the person's store served rows that take no part in the
363
- * checks (`EffectivePermissionRules.droppedRows`) — entries whose behavior word could not be read (no rows: the sentence names where
364
- * each was served and what was read there, the detail's `element` too), project-scoped rows whose scope root is not a complete absolute
365
- * path, and allow rows not written the way a rule is stored or a part of which could not be read — or deny and ask rows it could not
366
- * read whole, which apply as written when their tool, match and path read or their text says them and stand at their strictest reading
367
- * when neither did
368
- * (`EffectivePermissionRules.unreadableRows`, either personal partition's); minted by whichever read met them first, once per run. The
369
- * sentence names no path and one clause per kind of row present ({@link DROPPED_ROW_SENTENCE}, then {@link UNREADABLE_ROW_SENTENCE});
370
- * the rows ride the detail's `entries` (the left-out rows first, `entriesNotAppliedDetail`): `entry` is the rule text as the store
371
- * served it, through the one reading ({@link noticeRuleText}) every kind's `entry` uses — the machine-read side carries the
372
- * original, the sentence spells — `reason` the row's word, on a scope row only `scopeRoot` neutralized and bounded, on a row a part of
373
- * which could not be read the `member` that could not, on a deny or ask row so read its `behavior`, and on an entry that is no row its
374
- * `element` (`partition`, `index`, what was `read`); `count` is every row of both, `identity` their whole set. The trace keeps every
375
- * read's line.
376
+ * checks (`EffectivePermissionRules.droppedRows`) — project-scoped rows whose scope root is not a complete absolute path, allow rows
377
+ * not written the way a rule is stored or a part of which could not be read, and (for host-supplied views only) `element` entries —
378
+ * or rows it could not read whole (`EffectivePermissionRules.unreadableRows`, either personal partition's): deny/ask rows whose
379
+ * identity read (they apply as written), deny/ask rows whose identity did not read (strictest reading), and rows whose behavior word
380
+ * could not be read (`member: "behavior"`, strictest reading, without claiming `behavior: "ask"` on the notice entry); minted by
381
+ * whichever read met them first, once per run. The sentence names no path and one clause per kind of row present
382
+ * ({@link DROPPED_ROW_SENTENCE}, then {@link UNREADABLE_ROW_SENTENCE}); the rows ride the detail's `entries` (the left-out rows first,
383
+ * `entriesNotAppliedDetail`): `entry` is the rule text as the store served it, through the one reading ({@link noticeRuleText}) every
384
+ * kind's `entry` uses, `reason` the row's word, `scopeRoot` on a scope row neutralized and bounded, `member` on a row a part of which
385
+ * could not be read, `behavior` on a deny or ask row whose behavior word read, and `element` on a host-supplied element entry; `count`
386
+ * is every row of both, `identity` their whole set. The trace keeps every read's line.
376
387
  */
377
388
  export declare function ruleRowsDroppedNotice(onNotice: RunnerDeps["onNotice"], ids: {
378
389
  readonly sessionId: string;
@@ -1,6 +1,6 @@
1
1
  import { ownerStoreOf, ruleSourceOf } from "../permission-rule-provider.js";
2
2
  import { holdsRuleWriter, sameRuleIdentity } from "../permission-rule-store.js";
3
- import { identityUnread, reachesEveryCall, unreadableRowFaultsOf } from "./unreadable-person-rows.js";
3
+ import { identityUnread, reachesEveryCall, unreadableRowFaultsOf, unreadableRowsInScope } from "./unreadable-person-rows.js";
4
4
  import { readPrincipal } from "../principal-name.js";
5
5
  import { ORG_ADJUDICATION_TIMEOUT_MS, orgResolutionHeld, orgRowsStandOverFace } from "../permission-rule-org.js";
6
6
  import { canonicalize } from "../canonical-json.js";
@@ -112,15 +112,41 @@ export function createPersonPathRows(cfg) {
112
112
  if (changed && compile !== undefined)
113
113
  refreshUnitTables();
114
114
  };
115
+ const hasDroppedIn = (p, view) => p === "durable" && (view.droppedRows ?? []).some((d) => d.reason === "scope_root_not_absolute");
115
116
  const readRows = (p, view, before) => {
116
117
  const rows = view.rules.filter((r) => partitionOf(r.source) === p);
117
- if (!unreadableOf(p, view).some(identityUnread))
118
+ if (!unreadableOf(p, view).some(identityUnread) && !hasDroppedIn(p, view))
118
119
  return rows;
119
- return [...rows, ...(before?.rows ?? []).filter((w) => tightening(w) && !rows.some((r) => sameRuleIdentity(r, w)))];
120
+ const removed = view.removed ?? [];
121
+ return [...rows, ...(before?.rows ?? []).filter((w) => tightening(w) && !rows.some((r) => sameRuleIdentity(r, w)) && !removed.some((t) => sameRuleIdentity(t, w)))];
120
122
  };
121
123
  const lawed = (p, read) => read !== undefined ? read : (unit[p].ok?.rows ?? []).filter(tightening);
122
124
  const lawedUnreadable = (p, view) => (view !== undefined ? unreadableOf(p, view) : (unit[p].ok?.unreadable ?? []));
123
- const latestUnread = () => holdsPersonRows && partitions.some((p) => unit[p].failedSeq > (unit[p].ok?.seq ?? 0) || (unit[p].ok?.unreadable ?? []).some(reachesEveryCall));
125
+ const outOfScope = new WeakSet();
126
+ const scopesPending = new Set();
127
+ const scopesOf = new WeakMap();
128
+ const judgeScopes = (view) => {
129
+ if (scopesOf.has(view))
130
+ return scopesOf.get(view);
131
+ const project = holdsPersonRows ? (view.unreadableRows ?? []).filter((u) => identityUnread(u) && u.scope?.kind === "project") : [];
132
+ let judged;
133
+ if (project.length > 0) {
134
+ const inScope = projectScopeIdentity(project.map((u) => ({ scope: u.scope })), cfg.rootCanonical, cfg.leads).then((scopeIdentity) => new Set(unreadableRowsInScope(project, READ_RULE_TOOL, { cwd: cfg.root, sessionId: cfg.sessionId, ...(scopeIdentity !== undefined ? { scopeIdentity } : {}) })));
135
+ const settled = withGateTimeout(inScope, PATH_TABLES_READY_BOUND_MS, cfg.signal, "personRowScopes").then((rows) => {
136
+ for (const u of project)
137
+ if (!rows.has(u))
138
+ outOfScope.add(u);
139
+ }, () => undefined);
140
+ judged = settled;
141
+ scopesPending.add(settled);
142
+ void settled.then(() => scopesPending.delete(settled));
143
+ }
144
+ scopesOf.set(view, judged);
145
+ return judged;
146
+ };
147
+ const readScopes = new WeakMap();
148
+ const reachesEveryJudgment = (u) => reachesEveryCall(u) && !outOfScope.has(u);
149
+ const latestUnread = () => holdsPersonRows && partitions.some((p) => unit[p].failedSeq > (unit[p].ok?.seq ?? 0) || (unit[p].ok?.unreadable ?? []).some(reachesEveryJudgment));
124
150
  const unitLatestRules = () => partitions.flatMap((p) => {
125
151
  const cell = unit[p];
126
152
  return lawed(p, cell.ok !== undefined && cell.failedSeq <= cell.ok.seq ? cell.ok.rows : undefined);
@@ -146,12 +172,25 @@ export function createPersonPathRows(cfg) {
146
172
  cfg.onRowsDropped(view.droppedRows, view.unreadableRows);
147
173
  if (holdsPersonRows && view.unreadable !== undefined)
148
174
  announce(at, view.unreadable, faultsOfView(view));
149
- const unreadRows = holdsPersonRows ? (view.unreadableRows ?? []).filter(identityUnread) : [];
150
- if (unreadRows.length > 0)
151
- cfg.onUnread(at, unreadableRowFaultsOf(unreadRows), unreadRows.length);
175
+ const tellUnread = () => {
176
+ const unreadRows = holdsPersonRows ? (view.unreadableRows ?? []).filter((u) => identityUnread(u) && !outOfScope.has(u)) : [];
177
+ if (unreadRows.length > 0)
178
+ cfg.onUnread(at, unreadableRowFaultsOf(unreadRows), unreadRows.length);
179
+ };
180
+ const scoped = judgeScopes(view);
181
+ if (scoped === undefined)
182
+ tellUnread();
183
+ else
184
+ void scoped.then(tellUnread);
152
185
  land(outcomeOf(view));
153
186
  }, answer);
154
- const read = withGateTimeout(raw, PERSON_READ_BOUND_MS, cfg.signal, "personRules").then((view) => readOf(outcomeOf(view)), (err) => {
187
+ const read = withGateTimeout(raw, PERSON_READ_BOUND_MS, cfg.signal, "personRules").then((view) => {
188
+ const out = readOf(outcomeOf(view));
189
+ const scoped = judgeScopes(view);
190
+ if (scoped !== undefined)
191
+ readScopes.set(out, scoped);
192
+ return out;
193
+ }, (err) => {
155
194
  const failure = gateWaitFailureOf(err);
156
195
  const cut = failure === "aborted";
157
196
  const faults = [{ sources: sourcesOf(partitions), reason: failure === "timeout" ? "no_answer" : ruleStoreFaultReasonOf(err) }];
@@ -305,6 +344,9 @@ export function createPersonPathRows(cfg) {
305
344
  return;
306
345
  await withGateTimeout(cell.settled, left, signal, "pathTablesReady").catch(() => undefined);
307
346
  }
347
+ const left = deadline - Date.now();
348
+ if (scopesPending.size > 0 && left > 0)
349
+ await withGateTimeout(Promise.all([...scopesPending]), left, signal, "personRowScopes").catch(() => undefined);
308
350
  };
309
351
  const pinOf = (toolCallId) => {
310
352
  const p = toolCallId === undefined ? undefined : pins.get(toolCallId);
@@ -315,7 +357,7 @@ export function createPersonPathRows(cfg) {
315
357
  };
316
358
  const enter = (toolCallId, attempt, judged) => {
317
359
  const rows = readOnce("call").then((read) => (entry.read = read));
318
- const entry = { attempt, rows, tables: holdsPersonRows ? rows.then((read) => settleTables(entry, read)) : Promise.resolve(), ...(holdsPersonRows ? {} : { settled: {} }), ...(judged !== undefined ? { judged: { value: judged } } : {}) };
360
+ const entry = { attempt, rows, tables: holdsPersonRows ? rows.then((read) => Promise.all([settleTables(entry, read), readScopes.get(read)]).then(() => undefined)) : Promise.resolve(), ...(holdsPersonRows ? {} : { settled: {} }), ...(judged !== undefined ? { judged: { value: judged } } : {}) };
319
361
  pins.set(toolCallId, entry);
320
362
  return entry;
321
363
  };
@@ -380,7 +422,7 @@ export function createPersonPathRows(cfg) {
380
422
  holds: (toolCallId) => cfg.occurrences?.get(toolCallId) !== undefined,
381
423
  unreadFor: (toolCallId) => {
382
424
  const read = pinOf(toolCallId)?.read;
383
- return read !== undefined ? holdsPersonRows && (read.unreadable !== undefined || (read.unreadableRows ?? []).some(reachesEveryCall)) : latestUnread();
425
+ return read !== undefined ? holdsPersonRows && (read.unreadable !== undefined || (read.unreadableRows ?? []).some(reachesEveryJudgment)) : latestUnread();
384
426
  },
385
427
  attachTables: async (make) => {
386
428
  compile = make;
@@ -402,12 +444,21 @@ export function createPersonPathRows(cfg) {
402
444
  });
403
445
  const writeDeny = {
404
446
  face: "write",
447
+ get hasRows() {
448
+ return tablesFor(undefined).writeDeny.hasRows;
449
+ },
405
450
  get ruleRows() {
406
451
  return tablesFor(undefined).writeDeny.ruleRows;
407
452
  },
408
453
  matchPath: (path) => judging().writeDeny.matchPath(path),
409
454
  matchTarget: (canonicalKey, lexicalView, opts) => judging().writeDeny.matchTarget(canonicalKey, lexicalView, opts),
410
455
  guardsReads: (pattern) => judging().writeDeny.guardsReads?.(pattern) === true,
456
+ rowUnderRoot: (scope) => judging().writeDeny.rowUnderRoot?.(scope) ?? null,
457
+ rowAtOrBelow: (path) => judging().writeDeny.rowAtOrBelow?.(path) ?? null,
458
+ get unanchoredRows() {
459
+ return tablesFor(undefined).writeDeny.unanchoredRows ?? [];
460
+ },
461
+ rowLedByName: (name) => judging().writeDeny.rowLedByName?.(name) ?? null,
411
462
  homeViews: readDeny.homeViews,
412
463
  forCall: (id) => tablesFor(id).writeDeny,
413
464
  };
@@ -439,7 +490,7 @@ export function pathTablesCompile(seats) {
439
490
  const allow = person.readFaceRows?.allow ?? [];
440
491
  const asks = [...seats.legReadAskRows.map((r) => ({ ...r, policy: true })), ...(person.readFaceRows?.ask ?? [])];
441
492
  const readFaceRows = allow.length > 0 || asks.length > 0 ? { allow, ask: rowsWhereTheyLead(asks, await seats.leads.resolve(asks)) } : undefined;
442
- return { readDeny: placed.matcher, writeDeny: carryHomeViews(compileWriteDeny(led), placed.matcher.homeViews), readDirectories: [...new Set(await seats.canonicalize(person.readDirectories))], ...(readFaceRows !== undefined ? { readFaceRows } : {}), ruleRows: rows };
493
+ return { readDeny: placed.matcher, writeDeny: carryHomeViews(compileWriteDeny(placed.matcher), placed.matcher.homeViews), readDirectories: [...new Set(await seats.canonicalize(person.readDirectories))], ...(readFaceRows !== undefined ? { readFaceRows } : {}), ruleRows: rows };
443
494
  };
444
495
  }
445
496
  export function boundaryRowsOver(rows, personDirectories) {
@@ -463,14 +514,39 @@ const SEATS = new WeakMap();
463
514
  export function denySeatsOf(t) {
464
515
  let seats = SEATS.get(t);
465
516
  if (seats === undefined) {
517
+ const unanchored = t.writeDeny.unanchoredRows ?? [];
466
518
  seats = {
467
519
  read: readDenySeat(t.readDeny),
468
- write: t.writeDeny.ruleRows.length > 0 ? { writeDenyMatch: (p) => t.writeDeny.matchPath(p)?.pattern ?? null, writeDenyGuardsReads: (pattern) => t.writeDeny.guardsReads?.(pattern) === true } : {},
520
+ write: t.writeDeny.hasRows
521
+ ? {
522
+ writeDenyMatch: (p) => t.writeDeny.matchPath(p)?.pattern ?? null,
523
+ writeDenyGuardsReads: (pattern) => t.writeDeny.guardsReads?.(pattern) === true,
524
+ writeDenyUnder: (p) => {
525
+ const hit = t.writeDeny.rowUnderRoot?.(p) ?? null;
526
+ return hit === null ? null : hit.unplaced === true ? { unplaced: hit.pattern } : hit.pattern;
527
+ },
528
+ writeDenyAtOrBelow: (p) => t.writeDeny.rowAtOrBelow !== undefined ? (t.writeDeny.rowAtOrBelow(p)?.pattern ?? null) : (t.writeDeny.ruleRows[0]?.rule ?? null),
529
+ ...(unanchored.length > 0 ? { writeDenyNamed: { rows: unanchored, ledBy: (name) => t.writeDeny.rowLedByName?.(name) ?? null } } : {}),
530
+ }
531
+ : {},
469
532
  };
470
533
  SEATS.set(t, seats);
471
534
  }
472
535
  return seats;
473
536
  }
537
+ const EVERY_ROW = Object.freeze({ any: true, guardsWrites: true });
538
+ export function confinedDenyRowsOf(tables, unreadFor, toolCallId) {
539
+ try {
540
+ if (tables === undefined || unreadFor(toolCallId) || unreadFor(undefined))
541
+ return EVERY_ROW;
542
+ const seats = [tables.forCall(toolCallId), tables.forCall(undefined)].map(denySeatsOf);
543
+ const guardsWrites = seats.some((s) => s.write.writeDenyMatch !== undefined);
544
+ return { any: guardsWrites || seats.some((s) => s.read.denyMatch !== undefined), guardsWrites };
545
+ }
546
+ catch {
547
+ return EVERY_ROW;
548
+ }
549
+ }
474
550
  const VOUCHED = { disposition: "vouch", finding: "none" };
475
551
  export function onPinnedRead(rows, stations) {
476
552
  const check = composeReadChecks(stations);
@@ -556,7 +632,8 @@ const DROPPED_ROW_SENTENCE = {
556
632
  };
557
633
  const UNREADABLE_ROW_SENTENCE = {
558
634
  as_read: (n) => `${n} of your deny or ask rule rows came from the store with a part missing or not in plain form (the rule's text, its tool, match or path, the record of when it was added, or its scope), so ${n === 1 ? "it applies" : "they apply"} as written in every permission mode — a missing text read from the tool, match and path stored with ${n === 1 ? "it" : "them"}; where the tool, match or path is the part, all three read from ${n === 1 ? "its" : "their"} text, so ${n === 1 ? "it reaches" : "they reach"} what the rule's text says; where the scope is the part, everywhere (a row of this session's rules: in this session). Have the store send the whole row, or remove ${n === 1 ? "it" : "them"} from the store and add the rule again.`,
559
- strictest: (n) => `${n} of your deny or ask rule rows could not be read (the store sent neither a rule text this version reads nor the tool, match or path it names as plain data), so ${n === 1 ? "it is" : "they are"} not ignored: no allow rule of yours clears a call ${n === 1 ? "it" : "they"} may reach — ${n === 1 ? "its tool's" : "their tools'"} calls, or every call for a Read or Edit deny rule (the file, shell and search checks read those too) or when the tool cannot be read — while your other deny and ask rules still refuse and ask. Under the permission modes that ask, such a call is put to you; auto mode's classifier and bypass mode answer it without asking. Have the store send plain values, or remove ${n === 1 ? "it" : "them"} and add ${n === 1 ? "it" : "them"} again.`,
635
+ strictest: (n) => `${n} of your deny or ask rule rows could not be read (the store sent neither a rule text this version reads nor the tool, match or path it names as plain data), so ${n === 1 ? "it is" : "they are"} not ignored: no allow rule of yours clears a call ${n === 1 ? "it" : "they"} may reach — ${n === 1 ? "its tool's" : "their tools'"} calls, or every call for a Read or Edit deny rule (the file, shell and search checks read those too) or when the tool cannot be read — while your other deny and ask rules still refuse and ask. Under the permission modes that ask, such a call is put to you; auto mode's classifier and bypass mode answer it without asking. Have the store send plain values, or repair or remove ${n === 1 ? "it" : "them"} in the store.`,
636
+ behavior: (n) => `${n} of your stored rule rows could not be read because ${n === 1 ? "its" : "their"} behavior word could not be read (missing, not a text, or outside deny, ask and allow), so ${n === 1 ? "it is" : "they are"} not ignored: no allow rule of yours clears a call ${n === 1 ? "it" : "they"} may reach — ${n === 1 ? "its tool's" : "their tools'"} calls, or every call for Read or Edit or when the tool cannot be read — while your other deny and ask rules still refuse and ask; under the permission modes that ask, such a call is put to you (auto mode's classifier and bypass mode answer it without asking) — repair or remove ${n === 1 ? "it" : "them"} in the store.`,
560
637
  };
561
638
  export function ruleRowsDroppedNotice(onNotice, ids) {
562
639
  let sent = false;
@@ -572,7 +649,8 @@ export function ruleRowsDroppedNotice(onNotice, ids) {
572
649
  }),
573
650
  ...[
574
651
  [(unreadable ?? []).filter((r) => !identityUnread(r)).length, UNREADABLE_ROW_SENTENCE.as_read],
575
- [(unreadable ?? []).filter(identityUnread).length, UNREADABLE_ROW_SENTENCE.strictest],
652
+ [(unreadable ?? []).filter((r) => identityUnread(r) && r.member !== "behavior").length, UNREADABLE_ROW_SENTENCE.strictest],
653
+ [(unreadable ?? []).filter((r) => identityUnread(r) && r.member === "behavior").length, UNREADABLE_ROW_SENTENCE.behavior],
576
654
  ].flatMap(([n, say]) => (n > 0 ? [say(n)] : [])),
577
655
  ];
578
656
  deliverEngineNotice(onNotice, {
@@ -583,7 +661,7 @@ export function ruleRowsDroppedNotice(onNotice, ids) {
583
661
  entry: noticeRuleText(r.rule),
584
662
  reason: r.reason,
585
663
  ...(r.reason === "scope_root_not_absolute" ? { scopeRoot: inlineUntrusted(r.scopeRoot, 200) } : {}),
586
- ...("behavior" in r ? { behavior: r.behavior } : {}),
664
+ ...("behavior" in r && r.member !== "behavior" ? { behavior: r.behavior } : {}),
587
665
  ...("member" in r && r.member !== undefined ? { member: r.member } : {}),
588
666
  ...("element" in r && r.element !== undefined ? { element: { partition: r.element.partition, index: r.element.index, read: inlineUntrusted(r.element.read, 200) } } : {}),
589
667
  }))),