@plurnk/plurnk-service 1.17.0 → 1.19.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 (501) hide show
  1. package/.env.defaults +95 -14
  2. package/README.md +5 -3
  3. package/SPEC.md +1756 -1442
  4. package/dist/Paths.js +3 -3
  5. package/dist/build-info.json +1 -1
  6. package/dist/content/body-preview.d.ts +1 -0
  7. package/dist/content/body-preview.d.ts.map +1 -1
  8. package/dist/content/body-preview.js +8 -10
  9. package/dist/content/body-preview.js.map +1 -1
  10. package/dist/content/edit-receipt.d.ts.map +1 -1
  11. package/dist/content/edit-receipt.js +30 -29
  12. package/dist/content/edit-receipt.js.map +1 -1
  13. package/dist/content/line-anchors.d.ts.map +1 -1
  14. package/dist/content/line-anchors.js +17 -5
  15. package/dist/content/line-anchors.js.map +1 -1
  16. package/dist/content/read-projector.d.ts +2 -2
  17. package/dist/content/read-projector.d.ts.map +1 -1
  18. package/dist/content/read-projector.js +81 -39
  19. package/dist/content/read-projector.js.map +1 -1
  20. package/dist/content/read-resolve.d.ts +1 -0
  21. package/dist/content/read-resolve.d.ts.map +1 -1
  22. package/dist/content/read-resolve.js +13 -10
  23. package/dist/content/read-resolve.js.map +1 -1
  24. package/dist/content/scope-format.d.ts +9 -0
  25. package/dist/content/scope-format.d.ts.map +1 -0
  26. package/dist/content/scope-format.js +28 -0
  27. package/dist/content/scope-format.js.map +1 -0
  28. package/dist/core/AdministrativeLoop.d.ts +8 -0
  29. package/dist/core/AdministrativeLoop.d.ts.map +1 -0
  30. package/dist/core/AdministrativeLoop.js +16 -0
  31. package/dist/core/AdministrativeLoop.js.map +1 -0
  32. package/dist/core/AdmittedTurnExecutor.d.ts +2 -2
  33. package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
  34. package/dist/core/AdmittedTurnExecutor.js +26 -26
  35. package/dist/core/AdmittedTurnExecutor.js.map +1 -1
  36. package/dist/core/BareBatchRunner.d.ts +1 -2
  37. package/dist/core/BareBatchRunner.d.ts.map +1 -1
  38. package/dist/core/BareBatchRunner.js +7 -12
  39. package/dist/core/BareBatchRunner.js.map +1 -1
  40. package/dist/core/BudgetReadout.d.ts.map +1 -1
  41. package/dist/core/BudgetReadout.js +3 -4
  42. package/dist/core/BudgetReadout.js.map +1 -1
  43. package/dist/core/CapabilityPolicies.d.ts +4 -2
  44. package/dist/core/CapabilityPolicies.d.ts.map +1 -1
  45. package/dist/core/CapabilityPolicies.js +23 -2
  46. package/dist/core/CapabilityPolicies.js.map +1 -1
  47. package/dist/core/CapabilityResolver.d.ts +2 -2
  48. package/dist/core/CapabilityResolver.d.ts.map +1 -1
  49. package/dist/core/CapabilityResolver.js +46 -36
  50. package/dist/core/CapabilityResolver.js.map +1 -1
  51. package/dist/core/ChannelWrite.d.ts +4 -6
  52. package/dist/core/ChannelWrite.d.ts.map +1 -1
  53. package/dist/core/ChannelWrite.js +8 -8
  54. package/dist/core/ChannelWrite.js.map +1 -1
  55. package/dist/core/ChannelWrite.sql +17 -11
  56. package/dist/core/ClientInteractions.d.ts +11 -1
  57. package/dist/core/ClientInteractions.d.ts.map +1 -1
  58. package/dist/core/ClientInteractions.js +26 -2
  59. package/dist/core/ClientInteractions.js.map +1 -1
  60. package/dist/core/CoreSchemeServices.d.ts.map +1 -1
  61. package/dist/core/CoreSchemeServices.js +1 -0
  62. package/dist/core/CoreSchemeServices.js.map +1 -1
  63. package/dist/core/DataStatementRunner.d.ts.map +1 -1
  64. package/dist/core/DataStatementRunner.js +198 -148
  65. package/dist/core/DataStatementRunner.js.map +1 -1
  66. package/dist/core/Dispatcher.d.ts +18 -5
  67. package/dist/core/Dispatcher.d.ts.map +1 -1
  68. package/dist/core/Dispatcher.js +135 -114
  69. package/dist/core/Dispatcher.js.map +1 -1
  70. package/dist/core/Dispatcher.sql +11 -26
  71. package/dist/core/DurableStatement.d.ts +4 -1
  72. package/dist/core/DurableStatement.d.ts.map +1 -1
  73. package/dist/core/DurableStatement.js +4 -4
  74. package/dist/core/DurableStatement.js.map +1 -1
  75. package/dist/core/EditMutations.d.ts.map +1 -1
  76. package/dist/core/EditMutations.js +5 -2
  77. package/dist/core/EditMutations.js.map +1 -1
  78. package/dist/core/Engine.d.ts +11 -9
  79. package/dist/core/Engine.d.ts.map +1 -1
  80. package/dist/core/Engine.js +27 -65
  81. package/dist/core/Engine.js.map +1 -1
  82. package/dist/core/Engine.sql +2 -22
  83. package/dist/core/EnvFlags.d.ts.map +1 -1
  84. package/dist/core/EnvFlags.js +4 -2
  85. package/dist/core/EnvFlags.js.map +1 -1
  86. package/dist/core/ExecutionOutputs.sql +8 -0
  87. package/dist/core/ExecutorRegistry.d.ts +4 -0
  88. package/dist/core/ExecutorRegistry.d.ts.map +1 -1
  89. package/dist/core/ExecutorRegistry.js +3 -1
  90. package/dist/core/ExecutorRegistry.js.map +1 -1
  91. package/dist/core/KillHandler.d.ts.map +1 -1
  92. package/dist/core/KillHandler.js +7 -12
  93. package/dist/core/KillHandler.js.map +1 -1
  94. package/dist/core/Knob.d.ts +9 -0
  95. package/dist/core/Knob.d.ts.map +1 -0
  96. package/dist/core/Knob.js +50 -0
  97. package/dist/core/Knob.js.map +1 -0
  98. package/dist/core/LogBody.d.ts.map +1 -1
  99. package/dist/core/LogBody.js +8 -36
  100. package/dist/core/LogBody.js.map +1 -1
  101. package/dist/core/LogEntryProjection.d.ts.map +1 -1
  102. package/dist/core/LogEntryProjection.js +8 -10
  103. package/dist/core/LogEntryProjection.js.map +1 -1
  104. package/dist/core/LogVisibility.d.ts.map +1 -1
  105. package/dist/core/LogVisibility.js +2 -1
  106. package/dist/core/LogVisibility.js.map +1 -1
  107. package/dist/core/LogWriter.d.ts.map +1 -1
  108. package/dist/core/LogWriter.js +11 -9
  109. package/dist/core/LogWriter.js.map +1 -1
  110. package/dist/core/LoopDriver.d.ts +1 -1
  111. package/dist/core/LoopDriver.d.ts.map +1 -1
  112. package/dist/core/LoopDriver.js +24 -32
  113. package/dist/core/LoopDriver.js.map +1 -1
  114. package/dist/core/LoopLifecycle.d.ts +4 -17
  115. package/dist/core/LoopLifecycle.d.ts.map +1 -1
  116. package/dist/core/LoopLifecycle.js +20 -22
  117. package/dist/core/LoopLifecycle.js.map +1 -1
  118. package/dist/core/LoopLifecycle.sql +36 -49
  119. package/dist/core/LoopOutcome.d.ts +10 -0
  120. package/dist/core/LoopOutcome.d.ts.map +1 -0
  121. package/dist/core/LoopOutcome.js +28 -0
  122. package/dist/core/LoopOutcome.js.map +1 -0
  123. package/dist/core/LoopPolicies.d.ts +7 -0
  124. package/dist/core/LoopPolicies.d.ts.map +1 -0
  125. package/dist/core/LoopPolicies.js +37 -0
  126. package/dist/core/LoopPolicies.js.map +1 -0
  127. package/dist/core/MessageResources.d.ts +15 -0
  128. package/dist/core/MessageResources.d.ts.map +1 -0
  129. package/dist/core/MessageResources.js +46 -0
  130. package/dist/core/MessageResources.js.map +1 -0
  131. package/dist/core/MessageResources.sql +36 -0
  132. package/dist/core/ModelCall.d.ts.map +1 -1
  133. package/dist/core/ModelCall.js +2 -6
  134. package/dist/core/ModelCall.js.map +1 -1
  135. package/dist/core/ModelCall.sql +7 -36
  136. package/dist/core/OperatorConfig.d.ts +2 -1
  137. package/dist/core/OperatorConfig.d.ts.map +1 -1
  138. package/dist/core/OperatorConfig.js +14 -6
  139. package/dist/core/OperatorConfig.js.map +1 -1
  140. package/dist/core/PacketBuilder.d.ts.map +1 -1
  141. package/dist/core/PacketBuilder.js +20 -35
  142. package/dist/core/PacketBuilder.js.map +1 -1
  143. package/dist/core/PacketBuilder.sql +24 -6
  144. package/dist/core/PatternSelection.d.ts +1 -1
  145. package/dist/core/PatternSelection.d.ts.map +1 -1
  146. package/dist/core/ProposalLifecycle.d.ts +3 -1
  147. package/dist/core/ProposalLifecycle.d.ts.map +1 -1
  148. package/dist/core/ProposalLifecycle.js +93 -28
  149. package/dist/core/ProposalLifecycle.js.map +1 -1
  150. package/dist/core/ProviderInstantiate.d.ts +1 -0
  151. package/dist/core/ProviderInstantiate.d.ts.map +1 -1
  152. package/dist/core/ProviderInstantiate.js +12 -7
  153. package/dist/core/ProviderInstantiate.js.map +1 -1
  154. package/dist/core/ReasoningView.d.ts +1 -2
  155. package/dist/core/ReasoningView.d.ts.map +1 -1
  156. package/dist/core/ReasoningView.js +9 -20
  157. package/dist/core/ReasoningView.js.map +1 -1
  158. package/dist/core/ResourceBindings.d.ts.map +1 -1
  159. package/dist/core/ResourceBindings.js +5 -4
  160. package/dist/core/ResourceBindings.js.map +1 -1
  161. package/dist/core/ResourceMutations.d.ts +4 -4
  162. package/dist/core/ResourceMutations.d.ts.map +1 -1
  163. package/dist/core/ResourceMutations.js +2 -3
  164. package/dist/core/ResourceMutations.js.map +1 -1
  165. package/dist/core/ResourceSelector.d.ts +10 -3
  166. package/dist/core/ResourceSelector.d.ts.map +1 -1
  167. package/dist/core/ResourceSelector.js +52 -13
  168. package/dist/core/ResourceSelector.js.map +1 -1
  169. package/dist/core/ResourceTransfers.d.ts.map +1 -1
  170. package/dist/core/ResourceTransfers.js +4 -2
  171. package/dist/core/ResourceTransfers.js.map +1 -1
  172. package/dist/core/RuntimeWorker.d.ts.map +1 -1
  173. package/dist/core/RuntimeWorker.js +6 -1
  174. package/dist/core/RuntimeWorker.js.map +1 -1
  175. package/dist/core/RuntimeWorker.sql +7 -1
  176. package/dist/core/SchemeRegistry.d.ts +2 -0
  177. package/dist/core/SchemeRegistry.d.ts.map +1 -1
  178. package/dist/core/SchemeRegistry.js +12 -6
  179. package/dist/core/SchemeRegistry.js.map +1 -1
  180. package/dist/core/StoredPacket.d.ts +3 -1
  181. package/dist/core/StoredPacket.d.ts.map +1 -1
  182. package/dist/core/StoredPacket.js +7 -3
  183. package/dist/core/StoredPacket.js.map +1 -1
  184. package/dist/core/StrikeRail.d.ts +2 -2
  185. package/dist/core/StrikeRail.d.ts.map +1 -1
  186. package/dist/core/StrikeRail.js +15 -7
  187. package/dist/core/StrikeRail.js.map +1 -1
  188. package/dist/core/TerminalResult.d.ts +2 -2
  189. package/dist/core/TerminalResult.d.ts.map +1 -1
  190. package/dist/core/TerminalResult.js +15 -8
  191. package/dist/core/TerminalResult.js.map +1 -1
  192. package/dist/core/ToolInputSchema.d.ts.map +1 -1
  193. package/dist/core/ToolInputSchema.js +24 -8
  194. package/dist/core/ToolInputSchema.js.map +1 -1
  195. package/dist/core/ToolResources.d.ts +1 -0
  196. package/dist/core/ToolResources.d.ts.map +1 -1
  197. package/dist/core/ToolResources.js +50 -26
  198. package/dist/core/ToolResources.js.map +1 -1
  199. package/dist/core/Turn.d.ts +3 -1
  200. package/dist/core/Turn.d.ts.map +1 -1
  201. package/dist/core/Turn.js +4 -1
  202. package/dist/core/Turn.js.map +1 -1
  203. package/dist/core/Turn.sql +14 -2
  204. package/dist/core/TurnDispositionHandler.d.ts +13 -23
  205. package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
  206. package/dist/core/TurnDispositionHandler.js +30 -180
  207. package/dist/core/TurnDispositionHandler.js.map +1 -1
  208. package/dist/core/TurnMaterialization.d.ts +9 -7
  209. package/dist/core/TurnMaterialization.d.ts.map +1 -1
  210. package/dist/core/TurnMaterialization.js +66 -46
  211. package/dist/core/TurnMaterialization.js.map +1 -1
  212. package/dist/core/TurnMaterialization.sql +23 -6
  213. package/dist/core/TurnOps.d.ts.map +1 -1
  214. package/dist/core/TurnOps.js +2 -2
  215. package/dist/core/TurnOps.js.map +1 -1
  216. package/dist/core/TurnRunner.d.ts +2 -8
  217. package/dist/core/TurnRunner.d.ts.map +1 -1
  218. package/dist/core/TurnRunner.js +1116 -1123
  219. package/dist/core/TurnRunner.js.map +1 -1
  220. package/dist/core/TurnRunner.sql +1 -24
  221. package/dist/core/TurnSources.sql +42 -11
  222. package/dist/core/WorkerControlHandler.d.ts.map +1 -1
  223. package/dist/core/WorkerControlHandler.js +23 -0
  224. package/dist/core/WorkerControlHandler.js.map +1 -1
  225. package/dist/core/WorkerName.d.ts +3 -6
  226. package/dist/core/WorkerName.d.ts.map +1 -1
  227. package/dist/core/WorkerName.js +10 -26
  228. package/dist/core/WorkerName.js.map +1 -1
  229. package/dist/core/WorkspaceGate.js +4 -4
  230. package/dist/core/WorkspaceGate.js.map +1 -1
  231. package/dist/core/ambient.sql +45 -19
  232. package/dist/core/attachments.d.ts +3 -1
  233. package/dist/core/attachments.d.ts.map +1 -1
  234. package/dist/core/attachments.js +4 -0
  235. package/dist/core/attachments.js.map +1 -1
  236. package/dist/core/caps/CoreInteractionCaps.d.ts +1 -1
  237. package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -1
  238. package/dist/core/caps/CoreInteractionCaps.js +4 -2
  239. package/dist/core/caps/CoreInteractionCaps.js.map +1 -1
  240. package/dist/core/caps/DbChannelCaps.js +6 -6
  241. package/dist/core/caps/DbChannelCaps.js.map +1 -1
  242. package/dist/core/caps/DbEntryCaps.js +1 -1
  243. package/dist/core/caps/DbEntryCaps.js.map +1 -1
  244. package/dist/core/caps/DbMessageCaps.d.ts +10 -0
  245. package/dist/core/caps/DbMessageCaps.d.ts.map +1 -0
  246. package/dist/core/caps/DbMessageCaps.js +39 -0
  247. package/dist/core/caps/DbMessageCaps.js.map +1 -0
  248. package/dist/core/caps/DbProjectionCaps.d.ts +2 -2
  249. package/dist/core/caps/DbProjectionCaps.d.ts.map +1 -1
  250. package/dist/core/caps/DbProjectionCaps.js +10 -4
  251. package/dist/core/caps/DbProjectionCaps.js.map +1 -1
  252. package/dist/core/caps/SchemeCtxImpl.d.ts +3 -1
  253. package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
  254. package/dist/core/caps/SchemeCtxImpl.js +11 -0
  255. package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
  256. package/dist/core/env-catalog.d.ts +28 -0
  257. package/dist/core/env-catalog.d.ts.map +1 -0
  258. package/dist/core/env-catalog.js +99 -0
  259. package/dist/core/env-catalog.js.map +1 -0
  260. package/dist/core/file-materialization.js +1 -1
  261. package/dist/core/file-materialization.js.map +1 -1
  262. package/dist/core/fork.sql +7 -6
  263. package/dist/core/git-state.d.ts +3 -2
  264. package/dist/core/git-state.d.ts.map +1 -1
  265. package/dist/core/git-state.js +38 -21
  266. package/dist/core/git-state.js.map +1 -1
  267. package/dist/core/operation-target-groups.d.ts.map +1 -1
  268. package/dist/core/operation-target-groups.js +2 -1
  269. package/dist/core/operation-target-groups.js.map +1 -1
  270. package/dist/core/packet-inject.js +1 -1
  271. package/dist/core/packet-wire.d.ts +11 -0
  272. package/dist/core/packet-wire.d.ts.map +1 -1
  273. package/dist/core/packet-wire.js +382 -333
  274. package/dist/core/packet-wire.js.map +1 -1
  275. package/dist/core/plurnk-uri.d.ts +4 -5
  276. package/dist/core/plurnk-uri.d.ts.map +1 -1
  277. package/dist/core/plurnk-uri.js +10 -31
  278. package/dist/core/plurnk-uri.js.map +1 -1
  279. package/dist/core/scheme-types.d.ts +3 -1
  280. package/dist/core/scheme-types.d.ts.map +1 -1
  281. package/dist/core/scheme-types.js +1 -1
  282. package/dist/core/scheme-types.js.map +1 -1
  283. package/dist/core/teaching.d.ts.map +1 -1
  284. package/dist/core/teaching.js +2 -1
  285. package/dist/core/teaching.js.map +1 -1
  286. package/dist/core/types.d.ts +1 -2
  287. package/dist/core/types.d.ts.map +1 -1
  288. package/dist/core/types.js +1 -1
  289. package/dist/core/types.js.map +1 -1
  290. package/dist/core/worker-ops.sql +3 -8
  291. package/dist/digest/Digest.d.ts.map +1 -1
  292. package/dist/digest/Digest.js +37 -30
  293. package/dist/digest/Digest.js.map +1 -1
  294. package/dist/digest/DigestRender.d.ts +2 -0
  295. package/dist/digest/DigestRender.d.ts.map +1 -1
  296. package/dist/digest/DigestRender.js +97 -9
  297. package/dist/digest/DigestRender.js.map +1 -1
  298. package/dist/digest/DigestRequiem.d.ts.map +1 -1
  299. package/dist/digest/DigestRequiem.js +13 -15
  300. package/dist/digest/DigestRequiem.js.map +1 -1
  301. package/dist/digest/digest-db.d.ts +3 -0
  302. package/dist/digest/digest-db.d.ts.map +1 -0
  303. package/dist/digest/digest-db.js +68 -0
  304. package/dist/digest/digest-db.js.map +1 -0
  305. package/dist/digest/digest-paths.d.ts +6 -0
  306. package/dist/digest/digest-paths.d.ts.map +1 -0
  307. package/dist/digest/digest-paths.js +23 -0
  308. package/dist/digest/digest-paths.js.map +1 -0
  309. package/dist/digest/digest-rows.d.ts +21 -0
  310. package/dist/digest/digest-rows.d.ts.map +1 -1
  311. package/dist/digest/digest.sql +24 -5
  312. package/dist/index.d.ts +0 -1
  313. package/dist/index.d.ts.map +1 -1
  314. package/dist/index.js +0 -1
  315. package/dist/index.js.map +1 -1
  316. package/dist/observe/genai.d.ts +2 -2
  317. package/dist/observe/genai.d.ts.map +1 -1
  318. package/dist/observe/genai.js +15 -5
  319. package/dist/observe/genai.js.map +1 -1
  320. package/dist/schemes/EffectPolicy.d.ts +0 -2
  321. package/dist/schemes/EffectPolicy.d.ts.map +1 -1
  322. package/dist/schemes/EffectPolicy.js +25 -36
  323. package/dist/schemes/EffectPolicy.js.map +1 -1
  324. package/dist/schemes/Exec.d.ts +4 -5
  325. package/dist/schemes/Exec.d.ts.map +1 -1
  326. package/dist/schemes/Exec.js +129 -82
  327. package/dist/schemes/Exec.js.map +1 -1
  328. package/dist/schemes/ExecOutputScheme.d.ts +6 -5
  329. package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
  330. package/dist/schemes/ExecOutputScheme.js +49 -16
  331. package/dist/schemes/ExecOutputScheme.js.map +1 -1
  332. package/dist/schemes/ExecScheduler.js +2 -2
  333. package/dist/schemes/ExecScheduler.js.map +1 -1
  334. package/dist/schemes/File.d.ts.map +1 -1
  335. package/dist/schemes/File.js +30 -21
  336. package/dist/schemes/File.js.map +1 -1
  337. package/dist/schemes/Log.d.ts +4 -4
  338. package/dist/schemes/Log.d.ts.map +1 -1
  339. package/dist/schemes/Log.js +30 -10
  340. package/dist/schemes/Log.js.map +1 -1
  341. package/dist/schemes/QuestionTool.d.ts.map +1 -1
  342. package/dist/schemes/QuestionTool.js +15 -2
  343. package/dist/schemes/QuestionTool.js.map +1 -1
  344. package/dist/schemes/TurnSource.d.ts +3 -2
  345. package/dist/schemes/TurnSource.d.ts.map +1 -1
  346. package/dist/schemes/TurnSource.js +87 -41
  347. package/dist/schemes/TurnSource.js.map +1 -1
  348. package/dist/schemes/Worker.d.ts.map +1 -1
  349. package/dist/schemes/Worker.js +22 -56
  350. package/dist/schemes/Worker.js.map +1 -1
  351. package/dist/schemes/_entry-crud.js +6 -6
  352. package/dist/schemes/_entry-crud.js.map +1 -1
  353. package/dist/schemes/_entry-crud.sql +37 -17
  354. package/dist/schemes/_entry-find.d.ts.map +1 -1
  355. package/dist/schemes/_entry-find.js +6 -5
  356. package/dist/schemes/_entry-find.js.map +1 -1
  357. package/dist/schemes/_entry-fts.d.ts.map +1 -1
  358. package/dist/schemes/_entry-fts.js +6 -3
  359. package/dist/schemes/_entry-fts.js.map +1 -1
  360. package/dist/schemes/_entry-fts.sql +25 -6
  361. package/dist/schemes/_entry-manifest.d.ts +1 -1
  362. package/dist/schemes/_entry-manifest.d.ts.map +1 -1
  363. package/dist/schemes/_entry-manifest.js +10 -17
  364. package/dist/schemes/_entry-manifest.js.map +1 -1
  365. package/dist/schemes/_entry-manifest.sql +1 -1
  366. package/dist/schemes/_entry-ops.js +4 -4
  367. package/dist/schemes/_entry-ops.js.map +1 -1
  368. package/dist/schemes/_entry-ops.sql +2 -2
  369. package/dist/schemes/_entry-readable.d.ts.map +1 -1
  370. package/dist/schemes/_entry-readable.js +5 -4
  371. package/dist/schemes/_entry-readable.js.map +1 -1
  372. package/dist/schemes/_entry-send.js +2 -2
  373. package/dist/schemes/_entry-send.js.map +1 -1
  374. package/dist/schemes/_search-exclusion.d.ts +1 -0
  375. package/dist/schemes/_search-exclusion.d.ts.map +1 -1
  376. package/dist/schemes/_search-exclusion.js +12 -0
  377. package/dist/schemes/_search-exclusion.js.map +1 -1
  378. package/dist/schemes/_search-index.d.ts +5 -1
  379. package/dist/schemes/_search-index.d.ts.map +1 -1
  380. package/dist/schemes/_search-index.js +99 -59
  381. package/dist/schemes/_search-index.js.map +1 -1
  382. package/dist/schemes/_search-index.sql +17 -0
  383. package/dist/schemes/exec-abort.d.ts.map +1 -1
  384. package/dist/schemes/exec-abort.js +5 -4
  385. package/dist/schemes/exec-abort.js.map +1 -1
  386. package/dist/schemes/exec-env.d.ts +3 -0
  387. package/dist/schemes/exec-env.d.ts.map +1 -1
  388. package/dist/schemes/exec-env.js +66 -15
  389. package/dist/schemes/exec-env.js.map +1 -1
  390. package/dist/schemes/exec-lifetime.d.ts +11 -0
  391. package/dist/schemes/exec-lifetime.d.ts.map +1 -0
  392. package/dist/schemes/exec-lifetime.js +29 -0
  393. package/dist/schemes/exec-lifetime.js.map +1 -0
  394. package/dist/schemes/exec-runtime.d.ts +1 -1
  395. package/dist/schemes/exec-runtime.d.ts.map +1 -1
  396. package/dist/schemes/exec-runtime.js +1 -1
  397. package/dist/schemes/exec-runtime.js.map +1 -1
  398. package/dist/server/ClientReads.d.ts.map +1 -1
  399. package/dist/server/ClientReads.js +5 -2
  400. package/dist/server/ClientReads.js.map +1 -1
  401. package/dist/server/Daemon.d.ts +31 -7
  402. package/dist/server/Daemon.d.ts.map +1 -1
  403. package/dist/server/Daemon.js +137 -60
  404. package/dist/server/Daemon.js.map +1 -1
  405. package/dist/server/DaemonModule.d.ts +25 -6
  406. package/dist/server/DaemonModule.d.ts.map +1 -1
  407. package/dist/server/DrainSupervisor.d.ts +13 -11
  408. package/dist/server/DrainSupervisor.d.ts.map +1 -1
  409. package/dist/server/DrainSupervisor.js +87 -98
  410. package/dist/server/DrainSupervisor.js.map +1 -1
  411. package/dist/server/EnvFunctionality.d.ts +52 -0
  412. package/dist/server/EnvFunctionality.d.ts.map +1 -0
  413. package/dist/server/EnvFunctionality.js +199 -0
  414. package/dist/server/EnvFunctionality.js.map +1 -0
  415. package/dist/server/Functionality.d.ts +4 -2
  416. package/dist/server/Functionality.d.ts.map +1 -1
  417. package/dist/server/Functionality.js +250 -106
  418. package/dist/server/Functionality.js.map +1 -1
  419. package/dist/server/FunctionalityManager.d.ts +5 -1
  420. package/dist/server/FunctionalityManager.d.ts.map +1 -1
  421. package/dist/server/FunctionalityManager.js +24 -8
  422. package/dist/server/FunctionalityManager.js.map +1 -1
  423. package/dist/server/HttpListener.d.ts +16 -0
  424. package/dist/server/HttpListener.d.ts.map +1 -0
  425. package/dist/server/HttpListener.js +81 -0
  426. package/dist/server/HttpListener.js.map +1 -0
  427. package/dist/server/MembersFunctionality.d.ts.map +1 -1
  428. package/dist/server/MembersFunctionality.js +12 -17
  429. package/dist/server/MembersFunctionality.js.map +1 -1
  430. package/dist/server/PlurnkSkill.d.ts.map +1 -1
  431. package/dist/server/PlurnkSkill.js +1 -0
  432. package/dist/server/PlurnkSkill.js.map +1 -1
  433. package/dist/server/Retention.d.ts +14 -0
  434. package/dist/server/Retention.d.ts.map +1 -1
  435. package/dist/server/Retention.js +52 -4
  436. package/dist/server/Retention.js.map +1 -1
  437. package/dist/server/Retention.sql +55 -1
  438. package/dist/server/ServiceModules.d.ts.map +1 -1
  439. package/dist/server/ServiceModules.js +2 -0
  440. package/dist/server/ServiceModules.js.map +1 -1
  441. package/dist/server/SkillsFunctionality.d.ts +2 -0
  442. package/dist/server/SkillsFunctionality.d.ts.map +1 -1
  443. package/dist/server/SkillsFunctionality.js +27 -17
  444. package/dist/server/SkillsFunctionality.js.map +1 -1
  445. package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
  446. package/dist/server/WorkspaceCapabilities.js +1 -0
  447. package/dist/server/WorkspaceCapabilities.js.map +1 -1
  448. package/dist/server/WorkspaceResidency.d.ts +2 -0
  449. package/dist/server/WorkspaceResidency.d.ts.map +1 -1
  450. package/dist/server/WorkspaceResidency.js +27 -0
  451. package/dist/server/WorkspaceResidency.js.map +1 -1
  452. package/dist/server/WorkspaceStorage.d.ts +8 -0
  453. package/dist/server/WorkspaceStorage.d.ts.map +1 -0
  454. package/dist/server/WorkspaceStorage.js +26 -0
  455. package/dist/server/WorkspaceStorage.js.map +1 -0
  456. package/dist/server/client-input.d.ts +4 -3
  457. package/dist/server/client-input.d.ts.map +1 -1
  458. package/dist/server/client-input.js +25 -27
  459. package/dist/server/client-input.js.map +1 -1
  460. package/dist/server/dispatch-as-plurnk.js +2 -2
  461. package/dist/server/dispatch-as-plurnk.js.map +1 -1
  462. package/dist/server/drain.sql +69 -132
  463. package/dist/server/envelope.d.ts +2 -3
  464. package/dist/server/envelope.d.ts.map +1 -1
  465. package/dist/server/envelope.js +7 -21
  466. package/dist/server/envelope.js.map +1 -1
  467. package/dist/server/envelope.sql +10 -6
  468. package/dist/server/exec-poll-backoff.js +3 -3
  469. package/dist/server/exec-poll-backoff.js.map +1 -1
  470. package/dist/server/lifecycle-recovery.sql +12 -38
  471. package/dist/server/logEntry.sql +2 -2
  472. package/dist/server/loopDocs.js +3 -3
  473. package/dist/server/loopDocs.sql +4 -2
  474. package/dist/server/model-catalog.d.ts.map +1 -1
  475. package/dist/server/model-catalog.js +2 -2
  476. package/dist/server/model-catalog.js.map +1 -1
  477. package/dist/server/seam-loop.sql +0 -1
  478. package/dist/server/workspace-capabilities.sql +45 -0
  479. package/dist/server/workspace-storage.sql +8 -0
  480. package/dist/service.d.ts.map +1 -1
  481. package/dist/service.js +37 -11
  482. package/dist/service.js.map +1 -1
  483. package/docs/copy-move.md +31 -0
  484. package/docs/env.md +67 -0
  485. package/docs/members.md +4 -4
  486. package/docs/skills.md +2 -2
  487. package/migrations/002_workers.sql +41 -17
  488. package/migrations/003_loops.sql +82 -28
  489. package/migrations/004_inference.sql +53 -12
  490. package/migrations/005_entries.sql +135 -14
  491. package/migrations/006_log.sql +79 -24
  492. package/migrations/007_subscriptions.sql +10 -15
  493. package/package.json +45 -36
  494. package/dist/core/PromptFrames.d.ts +0 -12
  495. package/dist/core/PromptFrames.d.ts.map +0 -1
  496. package/dist/core/PromptFrames.js +0 -28
  497. package/dist/core/PromptFrames.js.map +0 -1
  498. package/dist/schemes/Prompt.d.ts +0 -8
  499. package/dist/schemes/Prompt.d.ts.map +0 -1
  500. package/dist/schemes/Prompt.js +0 -25
  501. package/dist/schemes/Prompt.js.map +0 -1
@@ -1,17 +1,22 @@
1
1
  var _a;
2
- import { PlurnkParser, TurnDisposition, parsePath } from "@plurnk/plurnk-contracts";
3
- import { foldAuthorityIntoPath, promptLoopPrefix, renderAddress, renderTarget, schemeNameOf } from "./plurnk-uri.js";
2
+ import { PlurnkParser, parsePath } from "@plurnk/plurnk-parser";
3
+ import { TurnDisposition } from "@plurnk/plurnk-contracts";
4
+ import Turn from "./Turn.js";
5
+ import { foldAuthorityIntoPath, renderAddress, renderTarget, schemeNameOf } from "./plurnk-uri.js";
6
+ import WorkerName from "./WorkerName.js";
4
7
  import { PathSyntax } from "@plurnk/plurnk-contracts";
5
8
  import Namespace from "./namespace.js";
6
9
  import CapabilityResolver from "./CapabilityResolver.js";
10
+ import CapabilityPolicies from "./CapabilityPolicies.js";
7
11
  import LoopPolicyReader from "./LoopPolicyReader.js";
8
12
  import SchemeCtxImpl from "./caps/SchemeCtxImpl.js";
9
13
  import Results from "./results.js";
10
14
  import { OperationFailureError } from "./results.js";
11
15
  import EffectPolicy from "../schemes/EffectPolicy.js";
12
16
  import { CoreSchemeAdapterBase } from "./CoreSchemeServices.js";
13
- import { InvalidOperationResultError } from "@plurnk/plurnk-schemes";
17
+ import { InvalidOperationResultError, MessageAttachments } from "@plurnk/plurnk-schemes";
14
18
  import ResourceMutations from "./ResourceMutations.js";
19
+ import ResourceSelector from "./ResourceSelector.js";
15
20
  import { primaryTargetOf } from "./statement-primary.js";
16
21
  import LogBody from "./LogBody.js";
17
22
  import LogVisibility from "./LogVisibility.js";
@@ -24,20 +29,16 @@ import LogWriter from "./LogWriter.js";
24
29
  import LogEntryProjection from "./LogEntryProjection.js";
25
30
  import DataStatementRunner from "./DataStatementRunner.js";
26
31
  import ResourceBindings from "./ResourceBindings.js";
32
+ import { isExecution } from "@plurnk/plurnk-contracts";
27
33
  // SPEC {§scheme-surface}: writer must be in target scheme's manifest.writableBy.
28
34
  // READ/FIND are not gated — they read, never mutating an entry.
29
- const MUTATING_OPS = new Set(["EDIT", "SEND", "COPY", "MOVE", "EXEC", "KILL", "FORK", "WORK"]);
35
+ const MUTATING_OPS = new Set(["EDIT", "SEND", "COPY", "MOVE", "KILL", "FORK", "WORK"]);
30
36
  // Op dispatch ({§op-methods-op-dispatch}): admission, operation-owner routing,
31
37
  // durable log writing, and proposal lifecycle.
32
38
  class Dispatcher {
33
39
  static #failure(code, status, detail, fields = {}, extensions = {}) {
34
40
  return Results.failure("engine:dispatcher", code, status, detail, fields, extensions);
35
41
  }
36
- static #statusResult(status, code, detail, fields = {}) {
37
- return status >= 400
38
- ? _a.#failure(code, status, detail, fields, { retryable: false })
39
- : { ...fields, status };
40
- }
41
42
  #db;
42
43
  #schemes;
43
44
  #mimetypes;
@@ -56,11 +57,12 @@ class Dispatcher {
56
57
  #wakeWorkerNotify;
57
58
  #injectWorker;
58
59
  #cancelWorker;
59
- #cancelDescendants;
60
+ #operationSettledNotify;
60
61
  // Per-turn running-worker READ obligations. {§join-blocking-collect}
61
62
  #liveSubscriptions;
62
63
  #lifecycle;
63
64
  #resourceMutations;
65
+ #resourceSelector;
64
66
  #entryAddresses;
65
67
  #capabilities;
66
68
  #workerControl;
@@ -68,7 +70,7 @@ class Dispatcher {
68
70
  #disposition;
69
71
  #logWriter;
70
72
  #dataRun;
71
- constructor({ db, lifecycle, schemes, mimetypes, weigh, notices, proposals, interactions, executors, loopSignal, settleDerivations, streamEventNotify, wakeWorkerNotify, injectWorker, cancelWorker, cancelDescendants, liveSubscriptions, entryAddresses }) {
73
+ constructor({ db, lifecycle, schemes, mimetypes, weigh, notices, proposals, interactions, executors, loopSignal, settleDerivations, streamEventNotify, wakeWorkerNotify, injectWorker, cancelWorker, operationSettledNotify, liveSubscriptions, entryAddresses }) {
72
74
  this.#db = db;
73
75
  this.#schemes = schemes;
74
76
  this.#mimetypes = mimetypes;
@@ -83,11 +85,20 @@ class Dispatcher {
83
85
  this.#wakeWorkerNotify = wakeWorkerNotify;
84
86
  this.#injectWorker = injectWorker;
85
87
  this.#cancelWorker = cancelWorker;
86
- this.#cancelDescendants = cancelDescendants;
88
+ this.#operationSettledNotify = operationSettledNotify;
87
89
  this.#liveSubscriptions = liveSubscriptions;
88
90
  this.#entryAddresses = entryAddresses;
89
91
  this.#capabilities = new CapabilityResolver(db, schemes, executors);
90
92
  this.#lifecycle = lifecycle;
93
+ this.#resourceSelector = new ResourceSelector({
94
+ schemes,
95
+ admitRead: (statement, ctx) => this.#checkCapabilities(statement, ctx),
96
+ canonicalFilePath: (pathname, workspaceId) => this.#canonicalFilePath(pathname, workspaceId),
97
+ prepareDataRepresentation: (args) => this.#prepareDataRepresentation({
98
+ ...args,
99
+ handler: args.handler,
100
+ }),
101
+ });
91
102
  this.#resourceMutations = new ResourceMutations({
92
103
  schemes,
93
104
  liveSubscriptions,
@@ -95,11 +106,7 @@ class Dispatcher {
95
106
  checkWritable: (statement, origin, workspaceId) => this.#checkWritable(statement, origin, workspaceId),
96
107
  checkCapabilities: (statement, ctx) => this.#checkCapabilities(statement, ctx),
97
108
  editTargetIdentity: (statement, workspaceId, workerId) => this.#editTargetIdentity(statement, workspaceId, workerId),
98
- canonicalFilePath: (pathname, workspaceId) => this.#canonicalFilePath(pathname, workspaceId),
99
- prepareDataRepresentation: (args) => this.#prepareDataRepresentation({
100
- ...args,
101
- handler: args.handler,
102
- }),
109
+ selection: this.#resourceSelector,
103
110
  resolveDataEntryAddress: (args) => this.#entryAddresses.resolve(args),
104
111
  readEntry: (scheme, address, ctx) => this.#readEntry(scheme, address, ctx),
105
112
  writeEntry: (scheme, address, entry, ctx) => this.#writeEntry(scheme, address, entry, ctx),
@@ -108,7 +115,7 @@ class Dispatcher {
108
115
  });
109
116
  this.#workerControl = new WorkerControlHandler({ db: this.#db, failure: _a.#failure });
110
117
  this.#kill = new KillHandler({ db: this.#db, schemes: this.#schemes, liveSubscriptions: this.#liveSubscriptions, cancelWorker: this.#cancelWorker, resolveDataEntryAddress: this.#resolveDataEntryAddress.bind(this), boundEntryContext: this.#boundEntryContext.bind(this), handlerContext: this.#handlerContext.bind(this), deleteEntry: this.#deleteEntry.bind(this), failure: _a.#failure });
111
- this.#disposition = new TurnDispositionHandler({ db: this.#db, cancelDescendants: this.#cancelDescendants, lifecycle: this.#lifecycle, nextPacketBoundaries: this.#nextPacketBoundaries.bind(this), unobservedFailureCount: this.#unobservedFailureCount.bind(this), pendingSet: this.#pendingSet.bind(this), hasLiveWork: this.hasLiveWork.bind(this), failure: _a.#failure, statusResult: _a.#statusResult, unobservedFailures: _a.#unobservedFailures });
118
+ this.#disposition = new TurnDispositionHandler({ db: this.#db, lifecycle: this.#lifecycle, unobservedFailureCount: this.#unobservedFailureCount.bind(this), pendingSet: this.#pendingSet.bind(this), hasLiveWork: this.hasLiveWork.bind(this) });
112
119
  this.#logWriter = new LogWriter({ db: this.#db, weighContent: this.#weighContent, extractTarget: this.#extractTarget.bind(this), canonColumns: this.#canonColumns.bind(this), signalToJson: this.#signalToJson.bind(this), isProposal: _a.#isProposal });
113
120
  this.#dataRun = new DataStatementRunner({ schemes: this.#schemes, liveSubscriptions: this.#liveSubscriptions, resolveDataEntryAddress: this.#resolveDataEntryAddress.bind(this), prepareDataRepresentation: this.#prepareDataRepresentation.bind(this), failure: _a.#failure });
114
121
  }
@@ -332,16 +339,18 @@ class Dispatcher {
332
339
  turnId: context.turnId, sequence: context.sequence, origin: context.origin, curationPlan: null, modelCallId: null,
333
340
  });
334
341
  context.onDispatch?.(logEntryId);
342
+ await this.#notifySettled(context, logEntryId);
335
343
  return result;
336
344
  }
345
+ const matchingPathCount = typeof found.matchingPathCount === "number" ? found.matchingPathCount : paths.length;
337
346
  const results = [];
338
347
  for (const [index, path] of paths.entries()) {
339
348
  const target = parsePath(path);
340
349
  if (target === null)
341
350
  throw new InvalidOperationResultError(`FIND named an unparseable path: ${path}`);
342
- results.push(await this.dispatch({ ...context, statement: { ...statement, target }, sequence: context.sequence + index }));
351
+ const fanout = { target: statement.target.raw, matched: matchingPathCount, index, count: paths.length };
352
+ results.push(await this.dispatch({ ...context, statement: { ...statement, target }, sequence: context.sequence + index, fanout }));
343
353
  }
344
- const matchingPathCount = typeof found.matchingPathCount === "number" ? found.matchingPathCount : paths.length;
345
354
  if (matchingPathCount > paths.length) {
346
355
  this.#notices.push(context.workspaceId, context.workerId, context.loopId, {
347
356
  source: "engine:dispatcher",
@@ -353,14 +362,11 @@ class Dispatcher {
353
362
  return Results.assert({ ...(results.find(({ status }) => status >= 400) ?? results[results.length - 1]), rowsWritten: results.length });
354
363
  }
355
364
  async #dispatchOne(context, schemeCtx) {
356
- const { statement, workspaceId, workerId, loopId, turnId, sequence, origin, onDispatch, onSettled, } = context;
365
+ const { statement, workspaceId, workerId, loopId, turnId, sequence, origin, onDispatch, } = context;
357
366
  let result;
358
367
  let curationPlan = null;
359
- // {§send-prompt-acceptance} — a model SEND addressed to one of this loop's own prompts
360
- // means what an untargeted SEND means; the address the packet showed it is accepted.
361
- const ownPrompt = statement.op === "SEND" && origin === "model" && await this.#isOwnPromptAddress(statement.target, workerId, loopId);
362
- const denial = ownPrompt ? null : (this.#checkWritable(statement, origin, workspaceId)
363
- ?? await this.#checkCapabilities(statement, schemeCtx));
368
+ const denial = this.#checkWritable(statement, origin, workspaceId)
369
+ ?? await this.#checkCapabilities(statement, schemeCtx);
364
370
  if (denial !== null) {
365
371
  result = denial;
366
372
  }
@@ -374,19 +380,23 @@ class Dispatcher {
374
380
  if (statement.op === "EDIT") {
375
381
  result = await this.#resourceMutations.edit(statement, schemeCtx, context.editSequence);
376
382
  }
377
- else if (statement.op === "SEND" && (statement.target === null || ownPrompt)) {
383
+ else if (statement.op === "SEND" && statement.target === null) {
378
384
  result = await this.#respond(statement, schemeCtx, origin, workerId, loopId);
385
+ if (context.proseAnswer === true && result.status === 200)
386
+ result = await this.#answered(result, workerId, loopId);
387
+ }
388
+ else if (statement.op === "NOTE") {
389
+ await Turn.recordSource(this.#db, turnId, "note", statement.body ?? "", { sequence });
390
+ const coordinate = await this.#db.engine_loop_turn_seqs.get({ loop_id: loopId, turn_id: turnId });
391
+ if (coordinate === undefined)
392
+ throw new Error(`NOTE has no turn coordinate for ${turnId}`);
393
+ const workerName = await WorkerName.forId(this.#db, workerId);
394
+ result = { status: 200, resource: renderAddress({ scheme: "note", authority: workerName, pathname: `/${coordinate.loop_seq}/${coordinate.turn_seq}/${sequence}` }) };
379
395
  }
380
396
  else if (TurnDisposition.is(statement)) {
381
- result = await this.#disposition.handle(statement, {
382
- workspaceId,
383
- workerId,
384
- loopId,
385
- turnId,
386
- sequence,
387
- origin,
388
- allowUnobservedRetrievalCompletion: context.allowUnobservedRetrievalCompletion,
389
- });
397
+ // {§turn-disposition} — WAIT is the park; whatever it names is its label in the
398
+ // row, never a join: the next wake is a message, a child's end, a stream's close.
399
+ result = await this.#disposition.handle({ workerId, loopId, turnId, origin });
390
400
  }
391
401
  else if (statement.op === "KILL" && schemeNameOf(statement.target) === "log") {
392
402
  const curation = await this.#runLogCuration(statement, schemeCtx, context.logSelectionMaxId);
@@ -410,8 +420,8 @@ class Dispatcher {
410
420
  else if (statement.op === "KILL") {
411
421
  result = await this.#kill.handleKill(statement, schemeCtx);
412
422
  }
413
- else if (statement.op === "EXEC") {
414
- // EXEC routes unconditionally to its operation owner after
423
+ else if (isExecution(statement)) {
424
+ // An execution routes unconditionally to its operation owner after
415
425
  // the shared capability resolver admits its runtime/tool.
416
426
  result = await this.#dataRun.run("exec", statement, schemeCtx);
417
427
  }
@@ -436,6 +446,11 @@ class Dispatcher {
436
446
  }
437
447
  }
438
448
  }
449
+ // {§read-fan-out} — a row read on behalf of a glob names the statement it came from.
450
+ if (context.fanout !== undefined) {
451
+ const attrs = typeof result.attrs === "object" && result.attrs !== null ? result.attrs : {};
452
+ result = { ...result, attrs: { ...attrs, fanout: context.fanout } };
453
+ }
439
454
  // Persist log curation for forensics; packet rendering suppresses its
440
455
  // successful receipts while the exact state effects remain durable.
441
456
  // A running-worker READ arms this turn's blocking collect.
@@ -454,7 +469,7 @@ class Dispatcher {
454
469
  });
455
470
  onDispatch?.(logEntryId);
456
471
  // Proposal lifecycle (SPEC.md {§engine-rails} + {§methods-proposal-resolve}; {§proposal-202-pauses}). When a
457
- // side-effecting op returns status 202 (a waiting TASK parks rather
472
+ // side-effecting op returns status 202 (a WAIT parks rather
458
473
  // than proposing — #isProposal), the entry is written
459
474
  // state='proposed'; dispatch then PAUSES on a per-entry waiter until
460
475
  // resolution arrives via Engine.resolveProposal (from a client-interface resume,
@@ -462,19 +477,23 @@ class Dispatcher {
462
477
  // result the caller sees, so runTurn never branches on a pending state.
463
478
  if (_a.#isProposal(statement, result)) {
464
479
  // Effect-gated auto-run (read/pure runtimes, {§exec-readpure-ungated}):
465
- // EXEC stores its one canonical effect fact before admission. Reuse
480
+ // An execution stores its one canonical effect fact before admission. Reuse
466
481
  // that exact fact here; no human gate or loop/proposal notification.
482
+ // {§exec-host-proposes} — the rule is the effect, not the op: an execution and a
483
+ // runtime SEND MUST declare one, and any other proposal that declares one (an
484
+ // outbound HTTP mutation, {§http-outbound-proposes}) is mapped by the same panel.
467
485
  const effect = result.attrs?.effect;
468
486
  let autoAccept = false;
469
- if (statement.op === "EXEC" || (statement.op === "SEND"
470
- && this.#schemes.isRuntimeScheme(schemeNameOf(statement.target) ?? "", workspaceId))) {
487
+ const mustDeclareEffect = isExecution(statement) || (statement.op === "SEND"
488
+ && this.#schemes.isRuntimeScheme(schemeNameOf(statement.target) ?? "", workspaceId));
489
+ if (mustDeclareEffect || effect !== undefined) {
471
490
  if (!EffectPolicy.isEffect(effect)) {
472
491
  throw new InvalidOperationResultError("Execution proposal omitted its canonical effect fact.");
473
492
  }
474
493
  autoAccept = EffectPolicy.decide(effect) === "auto";
475
494
  }
476
495
  if (autoAccept) {
477
- const initialSettlement = await this.#proposals.workerApply(statement, result, { decision: "accept" }, { workspaceId, workerId, loopId, turnId });
496
+ const initialSettlement = await this.#proposals.workerApply(statement, result, { decision: "accept" }, { workspaceId, workerId, loopId, turnId, resources: schemeCtx.resources });
478
497
  const effective = await this.#resourceMutations.settleProposal({
479
498
  statement,
480
499
  result,
@@ -483,7 +502,7 @@ class Dispatcher {
483
502
  ids: { workspaceId, workerId, loopId, turnId },
484
503
  });
485
504
  const post = await this.#proposals.applyResolution(logEntryId, effective);
486
- await onSettled?.(logEntryId);
505
+ await this.#notifySettled(context, logEntryId);
487
506
  return post;
488
507
  }
489
508
  // Register the resolution waiter SYNCHRONOUSLY before any await
@@ -497,14 +516,14 @@ class Dispatcher {
497
516
  // not an observer and cannot silently degrade into client ownership.
498
517
  let resolutionPromise;
499
518
  try {
500
- resolutionPromise = this.#proposals.awaitResolution(logEntryId);
519
+ resolutionPromise = this.#proposals.awaitResolution(logEntryId, this.#loopSignal(loopId));
501
520
  const event = await this.#proposals.pending(logEntryId);
502
521
  this.#proposals.settleOwned(event);
503
522
  this.#proposals.notifyPending(event);
504
523
  }
505
524
  catch (cause) {
506
525
  await this.#proposals.failPreparation(logEntryId, cause);
507
- await onSettled?.(logEntryId);
526
+ await this.#notifySettled(context, logEntryId);
508
527
  throw cause;
509
528
  }
510
529
  const resolution = await resolutionPromise;
@@ -512,7 +531,7 @@ class Dispatcher {
512
531
  // file, spawns the process, etc.). Its operation result is
513
532
  // preserved: an apply failure keeps its original status and
514
533
  // Problem Details instead of masquerading as a client rejection.
515
- const initialSettlement = await this.#proposals.workerApply(statement, result, resolution, { workspaceId, workerId, loopId, turnId });
534
+ const initialSettlement = await this.#proposals.workerApply(statement, result, resolution, { workspaceId, workerId, loopId, turnId, resources: schemeCtx.resources });
516
535
  const effective = await this.#resourceMutations.settleProposal({
517
536
  statement,
518
537
  result,
@@ -521,12 +540,16 @@ class Dispatcher {
521
540
  ids: { workspaceId, workerId, loopId, turnId },
522
541
  });
523
542
  const post = await this.#proposals.applyResolution(logEntryId, effective);
524
- await onSettled?.(logEntryId);
543
+ await this.#notifySettled(context, logEntryId);
525
544
  return post;
526
545
  }
527
- await onSettled?.(logEntryId);
546
+ await this.#notifySettled(context, logEntryId);
528
547
  return result;
529
548
  }
549
+ async #notifySettled(context, logEntryId) {
550
+ await context.onSettled?.(logEntryId);
551
+ await this.#operationSettledNotify?.(context.workspaceId, logEntryId);
552
+ }
530
553
  // {§op-look}: resolve a READ and return its content without writing a
531
554
  // log_entries row: the client's out-of-band inspection primitive (LOOK → READ,
532
555
  // invisible to the model). READ never mutates and never proposes, so this is
@@ -611,7 +634,7 @@ class Dispatcher {
611
634
  if (metadata !== null && manifest.metadataModifier !== true) {
612
635
  return {
613
636
  address: null,
614
- result: _a.#failure("scheme-metadata-unsupported", 400, `Scheme '${routedScheme}' does not accept the [metadata] modifier.`, {}, { scheme: routedScheme, retryable: false }),
637
+ result: _a.#failure("scheme-metadata-unsupported", 400, `Resource acquisition from '${routedScheme}' does not accept the [metadata] modifier.`, {}, { scheme: routedScheme, retryable: false }),
615
638
  };
616
639
  }
617
640
  const resolved = priorResolution ?? await this.#resolveDataEntryAddress({
@@ -645,7 +668,7 @@ class Dispatcher {
645
668
  result: prepared.status === 200 ? null : prepared,
646
669
  };
647
670
  }
648
- // An accepted EXEC reads a non-file source through the same registered
671
+ // An accepted execution reads a non-file source through the same registered
649
672
  // handler and addressed context as an authored READ. {§exec-target-routing}
650
673
  async readExecSource(statement, ctx) {
651
674
  return ResourceBindings.using(this.#schemes, ctx, (boundCtx) => this.#readExecSource(statement, boundCtx));
@@ -655,7 +678,7 @@ class Dispatcher {
655
678
  const binding = await ResourceBindings.resolve(statement.target, ctx);
656
679
  const manifest = binding?.manifest;
657
680
  if (manifest !== undefined && manifest.category !== "data") {
658
- return { nativePath: null, result: _a.#failure("exec-source-not-data", 501, `Scheme '${schemeName}' is not a data source for EXEC.`, {}, {
681
+ return { nativePath: null, result: _a.#failure("exec-source-not-data", 501, `Scheme '${schemeName}' is not a data source for an execution.`, {}, {
659
682
  scheme: schemeName,
660
683
  category: manifest.category,
661
684
  retryable: false,
@@ -677,7 +700,7 @@ class Dispatcher {
677
700
  return { result, nativePath: null };
678
701
  const nativePath = await source.nativePath();
679
702
  if (nativePath === null)
680
- return { nativePath: null, result: _a.#failure("entry-not-found", 404, "The EXEC source file no longer exists.", {}, { target: target.raw }) };
703
+ return { nativePath: null, result: _a.#failure("entry-not-found", 404, "The execution's source file no longer exists.", {}, { target: target.raw }) };
681
704
  return { result, nativePath };
682
705
  }
683
706
  // The one place per-dispatch coordinates are built; a caller that carries no
@@ -690,6 +713,8 @@ class Dispatcher {
690
713
  db: this.#db,
691
714
  workspaceId, workerId, loopId, turnId,
692
715
  writer: origin,
716
+ resources: { capture: (targets) => ResourceBindings.using(this.#schemes, context, (bound) => this.#resourceSelector.capture(targets, bound)) },
717
+ replyToMessage: (statement) => this.#respond(statement, context, origin, workerId, loopId),
693
718
  signal: this.#loopSignal(loopId),
694
719
  streamEventNotify: this.#streamEventNotify,
695
720
  wakeWorkerNotify: this.#wakeWorkerNotify,
@@ -713,13 +738,13 @@ class Dispatcher {
713
738
  // - COPY: dst scheme writableBy applies.
714
739
  // - MOVE: both src (delete) and dst (write) schemes' writableBy apply.
715
740
  #checkWritable(statement, origin, workspaceId) {
716
- if (!MUTATING_OPS.has(statement.op))
741
+ if (!isExecution(statement) && !MUTATING_OPS.has(statement.op))
717
742
  return null;
718
743
  if (TurnDisposition.is(statement) || statement.op === "SEND" && statement.target === null)
719
744
  return null;
720
- // EXEC's operation authority always belongs to the exec scheme;
745
+ // An execution's operation authority always belongs to the exec scheme;
721
746
  // runtime-specific resource authority is gated separately below.
722
- if (statement.op === "EXEC") {
747
+ if (isExecution(statement)) {
723
748
  return this.#denyIfDisallowed("exec", origin, workspaceId);
724
749
  }
725
750
  // {§stream-control}, {§exec-input}: process control is not a write to
@@ -759,7 +784,7 @@ class Dispatcher {
759
784
  return _a.#failure("send-target-not-a-recipient", 400, "The addressed scheme is not a SEND recipient.", {}, {
760
785
  target: statement.target?.raw ?? String(target),
761
786
  stage: "dispatch",
762
- recovery: "A targetless SEND answers the active prompt; a directed SEND requires a recipient that implements SEND.",
787
+ recovery: "A targetless SEND answers the open messages; a directed SEND requires a recipient that implements SEND.",
763
788
  retryable: false,
764
789
  });
765
790
  }
@@ -788,7 +813,7 @@ class Dispatcher {
788
813
  // owner; a known policy denial is one factual, non-presumptuous 403.
789
814
  async #checkCapabilities(statement, ctx) {
790
815
  await LoopPolicyReader.read(this.#db, ctx.loopId);
791
- const denied = await this.#capabilities.denial(statement, ctx.workspaceId, ctx.writer, async (target) => (await ResourceBindings.resolve(target, ctx))?.manifest);
816
+ const denied = await this.#capabilities.denial(statement, ctx.workspaceId, ctx.writer, async (target) => (await ResourceBindings.resolve(target, ctx))?.manifest, ctx.loopId);
792
817
  if (denied === null)
793
818
  return null;
794
819
  const { descriptor, scope } = denied;
@@ -801,6 +826,10 @@ class Dispatcher {
801
826
  return _a.#failure("capability-denied", 403, `Capability '${route}' is denied by ${scope} policy.`, {}, {
802
827
  ...descriptor,
803
828
  policyScope: scope,
829
+ // {§loop-attendance} — the innermost ring subtracts for a reason the model can act
830
+ // on, so it says it. Every other scope is the operator's configuration and speaks
831
+ // for itself.
832
+ ...(scope === "loop" ? { recovery: CapabilityPolicies.UNATTENDED_RECOVERY } : {}),
804
833
  retryable: false,
805
834
  });
806
835
  }
@@ -918,20 +947,22 @@ class Dispatcher {
918
947
  modelCallId,
919
948
  });
920
949
  context.onDispatch?.(logEntryId);
921
- await context.onSettled?.(logEntryId);
950
+ await this.#notifySettled(context, logEntryId);
922
951
  return result;
923
952
  }
924
- // {§send-prompt-acceptance} `prompt://<this worker>/<this loop>/<id>` names a prompt the loop
925
- // contains; a SEND to it is the response, exactly as if untargeted. Another worker's or
926
- // another loop's prompt is not a recipient and keeps the ordinary refusal.
927
- // {§send-response-receipt} — a response names the prompts it answers, so the receipt
928
- // says where the text went. {§send-looks-like-operation} — a model response whose first
929
- // line is an operation heading is a mis-fenced operation, not a reply: the 2026-09-11
930
- // dogfood put four operations on the line after their fences, delivered all four to the
931
- // user as 200 replies, then waited fifteen minutes for receipts that could never come.
953
+ // {§loop-answer} a prose answer's row names where the answer lives, ops://<worker>/<loop>, and
954
+ // renders under its own leaf ({§log-coordinate-hierarchy}) rather than as a SEND.
955
+ async #answered(result, workerId, loopId) {
956
+ const loop = await this.#db.engine_loop_sequence.get({ loop_id: loopId });
957
+ if (loop === undefined)
958
+ throw new Error(`prose answer has no loop sequence for loop ${loopId}`);
959
+ const resource = renderAddress({ scheme: "ops", authority: await WorkerName.forId(this.#db, workerId), pathname: `/${loop.sequence}` });
960
+ return { ...result, resource, attrs: { ...(result.attrs ?? {}), answer: "prose" } };
961
+ }
962
+ // {§send-response-receipt} {§send-looks-like-operation}
932
963
  async #respond(statement, schemeCtx, origin, workerId, loopId) {
933
964
  if (origin === "model") {
934
- const heading = this.#operationHeading(statement.body?.raw ?? "", schemeCtx);
965
+ const heading = this.#operationHeading(typeof statement.body === "string" ? statement.body : statement.body?.raw ?? "", schemeCtx);
935
966
  if (heading !== null) {
936
967
  return _a.#failure("send-looks-like-operation", 400, `The response begins with the operation heading \`${heading}\`; nothing ran and nothing was delivered.`, {}, {
937
968
  heading,
@@ -941,7 +972,24 @@ class Dispatcher {
941
972
  });
942
973
  }
943
974
  }
944
- return { status: 200, recipients: await this.#activePrompts(workerId, loopId) };
975
+ const captured = await MessageAttachments.capture(statement.metadata, schemeCtx.resources, "message:reply");
976
+ if ("failure" in captured)
977
+ return captured.failure;
978
+ const target = statement.target;
979
+ let answers;
980
+ if (target === null) {
981
+ answers = await this.#openMessages(loopId);
982
+ }
983
+ else {
984
+ const message = await this.#db.message_source_by_address.get({
985
+ workspace_id: schemeCtx.workspaceId, path: target.raw,
986
+ });
987
+ if (message === undefined)
988
+ return _a.#failure("message-not-found", 404, `No accepted message exists at ${target.raw}.`, {}, { retryable: false });
989
+ answers = [message.path];
990
+ }
991
+ return { status: 200, answers,
992
+ ...(captured.attachments.length === 0 ? {} : { attachments: MessageAttachments.receipts(captured.attachments) }) };
945
993
  }
946
994
  // The first non-blank line, when it parses alone as one clean heading naming an operation
947
995
  // this worker could perform: a Plurnk operation, or a registered executor or MCP service.
@@ -959,45 +1007,27 @@ class Dispatcher {
959
1007
  // on a reply's first line a multi-word literal is prose, not a mis-fenced operation.
960
1008
  if ("matcher" in statement && statement.matcher?.dialect === "glob" && /\s/u.test(statement.matcher.raw))
961
1009
  return null;
962
- if (statement.op !== "EXEC")
1010
+ if (!isExecution(statement))
963
1011
  return line;
964
- const executor = statement.executor;
965
- if (executor === null || schemeCtx.executors?.entry(executor, schemeCtx.workspaceId) === undefined)
1012
+ if (schemeCtx.executors?.entry(statement.runtime, schemeCtx.workspaceId) === undefined)
966
1013
  return null;
967
1014
  return line;
968
1015
  }
969
- // The loop's Active Prompts, oldest first, exactly as the packet lists them.
970
- async #activePrompts(workerId, loopId) {
971
- const worker = await this.#db.worker_get.get({ id: workerId });
972
- if (worker === undefined)
973
- throw new Error(`worker ${workerId} does not exist`);
974
- const loopSeq = (await this.#db.engine_loop_sequence.get({ loop_id: loopId }))?.sequence ?? loopId;
975
- const prefix = promptLoopPrefix(loopSeq);
976
- const rows = await this.#db.drain_get_all_prompt_bodies_for_loop.all({
977
- worker_id: workerId,
978
- pattern: `${prefix}%`,
979
- prefix_len: prefix.length,
980
- });
981
- return rows.map((row) => `prompt://${worker.name}${row.pathname}`);
1016
+ // {§send-response-receipt}: published unanswered source addresses, oldest first.
1017
+ async #openMessages(loopId) {
1018
+ const rows = await this.#db.engine_open_messages.all({ loop_id: loopId });
1019
+ return rows.map((row) => row.path);
982
1020
  }
983
- async #isOwnPromptAddress(target, workerId, loopId) {
984
- if (target === null || target.kind !== "url" || target.scheme !== "prompt")
985
- return false;
986
- const worker = await this.#db.worker_get.get({ id: workerId });
987
- if (worker === undefined || target.hostname !== worker.name)
988
- return false;
989
- const loopSeq = (await this.#db.engine_loop_sequence.get({ loop_id: loopId }))?.sequence ?? loopId;
990
- return target.pathname.startsWith(promptLoopPrefix(loopSeq));
1021
+ async settleProgram(ctx, wait) {
1022
+ return this.#disposition.settle(ctx, wait);
991
1023
  }
992
- // {§send-premature-terminate} The pending set is judged at TASK's dispatch point,
993
- // after earlier operations have executed. Every non-SEND/TASK/KILL model operation
994
- // requires a new packet, independently of its result or log visibility.
995
- async #pendingSet(workerId, turnId) {
1024
+ // {§send-premature-terminate}: judge observation boundaries after the whole program settles.
1025
+ async #pendingSet(workerId, turnId, loopId) {
996
1026
  const pending = [];
997
- // {§worker-obligations} — the stream and child legs are one durable row.
998
- const held = await this.#db.worker_live_obligations.get({ worker_id: workerId });
1027
+ // {§worker-obligations} — all held work shares one durable projection.
1028
+ const held = await this.#db.loop_live_obligations.get({ loop_id: loopId });
999
1029
  if (held === undefined)
1000
- throw new Error(`worker ${workerId} does not exist`);
1030
+ throw new Error(`loop ${loopId} does not exist`);
1001
1031
  if (held.streams === 1)
1002
1032
  pending.push("streams");
1003
1033
  if (held.workers === 1)
@@ -1010,7 +1040,7 @@ class Dispatcher {
1010
1040
  receipts.push("stream completion");
1011
1041
  if (receipts.length > 0)
1012
1042
  pending.push("receipts");
1013
- // The final-strike escape hatch cannot discard an unobserved failure.
1043
+ // A failed stream result is still owed to the model before ordinary completion.
1014
1044
  if (boundaries.streamTerminations.some(({ closeStatus }) => closeStatus >= 400))
1015
1045
  pending.push("failed-stream-results");
1016
1046
  if (boundaries.childTerminations)
@@ -1040,18 +1070,9 @@ class Dispatcher {
1040
1070
  const failedRows = await this.#db.engine_turn_failures.all({ turn_id: turnId });
1041
1071
  return failedRows.length;
1042
1072
  }
1043
- static #unobservedFailures(failCount) {
1044
- return _a.#failure("unobserved-failures", 409, `Completion deferred: ${failCount} operation${failCount === 1 ? "" : "s"} failed in the same turn. The failure${failCount === 1 ? " is" : "s are"} in this packet; address ${failCount === 1 ? "it" : "them"} or complete with a TASK now.`, {}, {
1045
- failures: failCount,
1046
- stage: "completion",
1047
- retryable: true,
1048
- });
1049
- }
1050
- // A live obligation to wait on: a spawned child or an open stream (not retrievals, which land
1051
- // next turn regardless). The wait-side twin of #pendingSet's stream+child legs ({§wait-obligation-matrix}).
1052
- async hasLiveWork(workerId) {
1053
- // {§worker-obligations} — one durable row answers both legs.
1054
- const held = await this.#db.worker_live_obligations.get({ worker_id: workerId });
1073
+ // {§wait-obligation-matrix}: retrievals land next turn; only held work permits parking.
1074
+ async hasLiveWork(loopId) {
1075
+ const held = await this.#db.loop_live_obligations.get({ loop_id: loopId });
1055
1076
  return held !== undefined && (held.streams === 1 || held.workers === 1);
1056
1077
  }
1057
1078
  async #runLogCuration(statement, ctx, admittedMaxId) {
@@ -1104,7 +1125,7 @@ class Dispatcher {
1104
1125
  const routedScheme = schemeNameOf(path);
1105
1126
  const manifest = routedScheme === null
1106
1127
  ? undefined
1107
- : this.#schemes.manifestFor(routedScheme, workspaceId);
1128
+ : this.#schemes.manifestAt(routedScheme, path, workspaceId);
1108
1129
  const foldNs = scheme !== null
1109
1130
  && manifest !== undefined
1110
1131
  && (manifest.authority ?? "namespace") === "namespace";