@plurnk/plurnk-service 1.18.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 (447) hide show
  1. package/.env.defaults +76 -13
  2. package/README.md +5 -3
  3. package/SPEC.md +924 -689
  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 +79 -37
  19. package/dist/content/read-projector.js.map +1 -1
  20. package/dist/content/scope-format.d.ts +9 -0
  21. package/dist/content/scope-format.d.ts.map +1 -0
  22. package/dist/content/scope-format.js +28 -0
  23. package/dist/content/scope-format.js.map +1 -0
  24. package/dist/core/AdministrativeLoop.d.ts +8 -0
  25. package/dist/core/AdministrativeLoop.d.ts.map +1 -0
  26. package/dist/core/AdministrativeLoop.js +16 -0
  27. package/dist/core/AdministrativeLoop.js.map +1 -0
  28. package/dist/core/AdmittedTurnExecutor.d.ts +2 -1
  29. package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
  30. package/dist/core/AdmittedTurnExecutor.js +19 -19
  31. package/dist/core/AdmittedTurnExecutor.js.map +1 -1
  32. package/dist/core/BareBatchRunner.d.ts +1 -2
  33. package/dist/core/BareBatchRunner.d.ts.map +1 -1
  34. package/dist/core/BareBatchRunner.js +7 -12
  35. package/dist/core/BareBatchRunner.js.map +1 -1
  36. package/dist/core/BudgetReadout.d.ts.map +1 -1
  37. package/dist/core/BudgetReadout.js +3 -4
  38. package/dist/core/BudgetReadout.js.map +1 -1
  39. package/dist/core/CapabilityPolicies.d.ts +4 -2
  40. package/dist/core/CapabilityPolicies.d.ts.map +1 -1
  41. package/dist/core/CapabilityPolicies.js +23 -2
  42. package/dist/core/CapabilityPolicies.js.map +1 -1
  43. package/dist/core/CapabilityResolver.d.ts +2 -2
  44. package/dist/core/CapabilityResolver.d.ts.map +1 -1
  45. package/dist/core/CapabilityResolver.js +6 -3
  46. package/dist/core/CapabilityResolver.js.map +1 -1
  47. package/dist/core/ChannelWrite.d.ts +3 -6
  48. package/dist/core/ChannelWrite.d.ts.map +1 -1
  49. package/dist/core/ChannelWrite.js +8 -8
  50. package/dist/core/ChannelWrite.js.map +1 -1
  51. package/dist/core/ChannelWrite.sql +17 -11
  52. package/dist/core/ClientInteractions.d.ts +11 -1
  53. package/dist/core/ClientInteractions.d.ts.map +1 -1
  54. package/dist/core/ClientInteractions.js +26 -2
  55. package/dist/core/ClientInteractions.js.map +1 -1
  56. package/dist/core/CoreSchemeServices.d.ts.map +1 -1
  57. package/dist/core/CoreSchemeServices.js +1 -0
  58. package/dist/core/CoreSchemeServices.js.map +1 -1
  59. package/dist/core/DataStatementRunner.js +6 -6
  60. package/dist/core/DataStatementRunner.js.map +1 -1
  61. package/dist/core/Dispatcher.d.ts +12 -4
  62. package/dist/core/Dispatcher.d.ts.map +1 -1
  63. package/dist/core/Dispatcher.js +112 -90
  64. package/dist/core/Dispatcher.js.map +1 -1
  65. package/dist/core/Dispatcher.sql +11 -26
  66. package/dist/core/DurableStatement.d.ts +4 -1
  67. package/dist/core/DurableStatement.d.ts.map +1 -1
  68. package/dist/core/DurableStatement.js +4 -4
  69. package/dist/core/DurableStatement.js.map +1 -1
  70. package/dist/core/EditMutations.d.ts.map +1 -1
  71. package/dist/core/EditMutations.js +5 -2
  72. package/dist/core/EditMutations.js.map +1 -1
  73. package/dist/core/Engine.d.ts +11 -9
  74. package/dist/core/Engine.d.ts.map +1 -1
  75. package/dist/core/Engine.js +27 -65
  76. package/dist/core/Engine.js.map +1 -1
  77. package/dist/core/Engine.sql +2 -22
  78. package/dist/core/EnvFlags.d.ts.map +1 -1
  79. package/dist/core/EnvFlags.js +4 -2
  80. package/dist/core/EnvFlags.js.map +1 -1
  81. package/dist/core/ExecutorRegistry.d.ts.map +1 -1
  82. package/dist/core/ExecutorRegistry.js +2 -1
  83. package/dist/core/ExecutorRegistry.js.map +1 -1
  84. package/dist/core/KillHandler.d.ts.map +1 -1
  85. package/dist/core/KillHandler.js +7 -12
  86. package/dist/core/KillHandler.js.map +1 -1
  87. package/dist/core/Knob.d.ts +9 -0
  88. package/dist/core/Knob.d.ts.map +1 -0
  89. package/dist/core/Knob.js +50 -0
  90. package/dist/core/Knob.js.map +1 -0
  91. package/dist/core/LogBody.d.ts.map +1 -1
  92. package/dist/core/LogBody.js +6 -35
  93. package/dist/core/LogBody.js.map +1 -1
  94. package/dist/core/LogEntryProjection.d.ts.map +1 -1
  95. package/dist/core/LogEntryProjection.js +4 -0
  96. package/dist/core/LogEntryProjection.js.map +1 -1
  97. package/dist/core/LogVisibility.d.ts.map +1 -1
  98. package/dist/core/LogVisibility.js +2 -1
  99. package/dist/core/LogVisibility.js.map +1 -1
  100. package/dist/core/LogWriter.js +2 -2
  101. package/dist/core/LogWriter.js.map +1 -1
  102. package/dist/core/LoopDriver.d.ts +1 -1
  103. package/dist/core/LoopDriver.d.ts.map +1 -1
  104. package/dist/core/LoopDriver.js +23 -29
  105. package/dist/core/LoopDriver.js.map +1 -1
  106. package/dist/core/LoopLifecycle.d.ts +4 -17
  107. package/dist/core/LoopLifecycle.d.ts.map +1 -1
  108. package/dist/core/LoopLifecycle.js +20 -22
  109. package/dist/core/LoopLifecycle.js.map +1 -1
  110. package/dist/core/LoopLifecycle.sql +36 -49
  111. package/dist/core/LoopOutcome.d.ts +10 -0
  112. package/dist/core/LoopOutcome.d.ts.map +1 -0
  113. package/dist/core/LoopOutcome.js +28 -0
  114. package/dist/core/LoopOutcome.js.map +1 -0
  115. package/dist/core/LoopPolicies.d.ts +7 -0
  116. package/dist/core/LoopPolicies.d.ts.map +1 -0
  117. package/dist/core/LoopPolicies.js +37 -0
  118. package/dist/core/LoopPolicies.js.map +1 -0
  119. package/dist/core/MessageResources.d.ts +15 -0
  120. package/dist/core/MessageResources.d.ts.map +1 -0
  121. package/dist/core/MessageResources.js +46 -0
  122. package/dist/core/MessageResources.js.map +1 -0
  123. package/dist/core/MessageResources.sql +36 -0
  124. package/dist/core/OperatorConfig.d.ts +2 -1
  125. package/dist/core/OperatorConfig.d.ts.map +1 -1
  126. package/dist/core/OperatorConfig.js +14 -6
  127. package/dist/core/OperatorConfig.js.map +1 -1
  128. package/dist/core/PacketBuilder.d.ts.map +1 -1
  129. package/dist/core/PacketBuilder.js +20 -35
  130. package/dist/core/PacketBuilder.js.map +1 -1
  131. package/dist/core/PacketBuilder.sql +24 -6
  132. package/dist/core/PatternSelection.d.ts +1 -1
  133. package/dist/core/PatternSelection.d.ts.map +1 -1
  134. package/dist/core/ProposalLifecycle.d.ts +3 -1
  135. package/dist/core/ProposalLifecycle.d.ts.map +1 -1
  136. package/dist/core/ProposalLifecycle.js +85 -22
  137. package/dist/core/ProposalLifecycle.js.map +1 -1
  138. package/dist/core/ProviderInstantiate.d.ts +1 -0
  139. package/dist/core/ProviderInstantiate.d.ts.map +1 -1
  140. package/dist/core/ProviderInstantiate.js +12 -7
  141. package/dist/core/ProviderInstantiate.js.map +1 -1
  142. package/dist/core/ReasoningView.d.ts +1 -2
  143. package/dist/core/ReasoningView.d.ts.map +1 -1
  144. package/dist/core/ReasoningView.js +9 -20
  145. package/dist/core/ReasoningView.js.map +1 -1
  146. package/dist/core/ResourceBindings.d.ts.map +1 -1
  147. package/dist/core/ResourceBindings.js +5 -4
  148. package/dist/core/ResourceBindings.js.map +1 -1
  149. package/dist/core/ResourceMutations.d.ts +4 -4
  150. package/dist/core/ResourceMutations.d.ts.map +1 -1
  151. package/dist/core/ResourceMutations.js +2 -3
  152. package/dist/core/ResourceMutations.js.map +1 -1
  153. package/dist/core/ResourceSelector.d.ts +10 -3
  154. package/dist/core/ResourceSelector.d.ts.map +1 -1
  155. package/dist/core/ResourceSelector.js +52 -13
  156. package/dist/core/ResourceSelector.js.map +1 -1
  157. package/dist/core/ResourceTransfers.d.ts.map +1 -1
  158. package/dist/core/ResourceTransfers.js +4 -2
  159. package/dist/core/ResourceTransfers.js.map +1 -1
  160. package/dist/core/SchemeRegistry.d.ts +2 -0
  161. package/dist/core/SchemeRegistry.d.ts.map +1 -1
  162. package/dist/core/SchemeRegistry.js +11 -5
  163. package/dist/core/SchemeRegistry.js.map +1 -1
  164. package/dist/core/StoredPacket.d.ts +3 -1
  165. package/dist/core/StoredPacket.d.ts.map +1 -1
  166. package/dist/core/StoredPacket.js +7 -3
  167. package/dist/core/StoredPacket.js.map +1 -1
  168. package/dist/core/StrikeRail.d.ts.map +1 -1
  169. package/dist/core/StrikeRail.js +9 -3
  170. package/dist/core/StrikeRail.js.map +1 -1
  171. package/dist/core/TerminalResult.d.ts +2 -2
  172. package/dist/core/TerminalResult.d.ts.map +1 -1
  173. package/dist/core/TerminalResult.js +15 -8
  174. package/dist/core/TerminalResult.js.map +1 -1
  175. package/dist/core/ToolInputSchema.d.ts.map +1 -1
  176. package/dist/core/ToolInputSchema.js +24 -8
  177. package/dist/core/ToolInputSchema.js.map +1 -1
  178. package/dist/core/ToolResources.d.ts +1 -0
  179. package/dist/core/ToolResources.d.ts.map +1 -1
  180. package/dist/core/ToolResources.js +45 -23
  181. package/dist/core/ToolResources.js.map +1 -1
  182. package/dist/core/Turn.d.ts +3 -1
  183. package/dist/core/Turn.d.ts.map +1 -1
  184. package/dist/core/Turn.js +4 -1
  185. package/dist/core/Turn.js.map +1 -1
  186. package/dist/core/Turn.sql +14 -2
  187. package/dist/core/TurnDispositionHandler.d.ts +13 -21
  188. package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
  189. package/dist/core/TurnDispositionHandler.js +32 -190
  190. package/dist/core/TurnDispositionHandler.js.map +1 -1
  191. package/dist/core/TurnMaterialization.d.ts +9 -7
  192. package/dist/core/TurnMaterialization.d.ts.map +1 -1
  193. package/dist/core/TurnMaterialization.js +63 -41
  194. package/dist/core/TurnMaterialization.js.map +1 -1
  195. package/dist/core/TurnMaterialization.sql +23 -6
  196. package/dist/core/TurnOps.js +1 -1
  197. package/dist/core/TurnRunner.d.ts +1 -3
  198. package/dist/core/TurnRunner.d.ts.map +1 -1
  199. package/dist/core/TurnRunner.js +148 -189
  200. package/dist/core/TurnRunner.js.map +1 -1
  201. package/dist/core/TurnRunner.sql +1 -24
  202. package/dist/core/TurnSources.sql +42 -11
  203. package/dist/core/WorkerName.d.ts +1 -1
  204. package/dist/core/WorkerName.d.ts.map +1 -1
  205. package/dist/core/WorkerName.js +3 -3
  206. package/dist/core/WorkerName.js.map +1 -1
  207. package/dist/core/ambient.sql +45 -19
  208. package/dist/core/attachments.d.ts +3 -1
  209. package/dist/core/attachments.d.ts.map +1 -1
  210. package/dist/core/attachments.js +4 -0
  211. package/dist/core/attachments.js.map +1 -1
  212. package/dist/core/caps/CoreInteractionCaps.d.ts +1 -1
  213. package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -1
  214. package/dist/core/caps/CoreInteractionCaps.js +4 -2
  215. package/dist/core/caps/CoreInteractionCaps.js.map +1 -1
  216. package/dist/core/caps/DbChannelCaps.js +6 -6
  217. package/dist/core/caps/DbChannelCaps.js.map +1 -1
  218. package/dist/core/caps/DbEntryCaps.js +1 -1
  219. package/dist/core/caps/DbEntryCaps.js.map +1 -1
  220. package/dist/core/caps/DbMessageCaps.d.ts +10 -0
  221. package/dist/core/caps/DbMessageCaps.d.ts.map +1 -0
  222. package/dist/core/caps/DbMessageCaps.js +39 -0
  223. package/dist/core/caps/DbMessageCaps.js.map +1 -0
  224. package/dist/core/caps/DbProjectionCaps.d.ts +2 -2
  225. package/dist/core/caps/DbProjectionCaps.d.ts.map +1 -1
  226. package/dist/core/caps/DbProjectionCaps.js +10 -4
  227. package/dist/core/caps/DbProjectionCaps.js.map +1 -1
  228. package/dist/core/caps/SchemeCtxImpl.d.ts +3 -1
  229. package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
  230. package/dist/core/caps/SchemeCtxImpl.js +11 -0
  231. package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
  232. package/dist/core/fork.sql +7 -6
  233. package/dist/core/git-state.d.ts +3 -2
  234. package/dist/core/git-state.d.ts.map +1 -1
  235. package/dist/core/git-state.js +37 -20
  236. package/dist/core/git-state.js.map +1 -1
  237. package/dist/core/packet-inject.js +1 -1
  238. package/dist/core/packet-wire.d.ts +11 -0
  239. package/dist/core/packet-wire.d.ts.map +1 -1
  240. package/dist/core/packet-wire.js +112 -88
  241. package/dist/core/packet-wire.js.map +1 -1
  242. package/dist/core/plurnk-uri.d.ts +4 -5
  243. package/dist/core/plurnk-uri.d.ts.map +1 -1
  244. package/dist/core/plurnk-uri.js +10 -31
  245. package/dist/core/plurnk-uri.js.map +1 -1
  246. package/dist/core/scheme-types.d.ts +3 -1
  247. package/dist/core/scheme-types.d.ts.map +1 -1
  248. package/dist/core/scheme-types.js +1 -1
  249. package/dist/core/scheme-types.js.map +1 -1
  250. package/dist/core/teaching.d.ts.map +1 -1
  251. package/dist/core/teaching.js +2 -1
  252. package/dist/core/teaching.js.map +1 -1
  253. package/dist/core/types.d.ts +1 -2
  254. package/dist/core/types.d.ts.map +1 -1
  255. package/dist/core/types.js +1 -1
  256. package/dist/core/types.js.map +1 -1
  257. package/dist/core/worker-ops.sql +3 -8
  258. package/dist/digest/Digest.d.ts.map +1 -1
  259. package/dist/digest/Digest.js +35 -30
  260. package/dist/digest/Digest.js.map +1 -1
  261. package/dist/digest/DigestRender.d.ts +1 -0
  262. package/dist/digest/DigestRender.d.ts.map +1 -1
  263. package/dist/digest/DigestRender.js +53 -1
  264. package/dist/digest/DigestRender.js.map +1 -1
  265. package/dist/digest/DigestRequiem.d.ts.map +1 -1
  266. package/dist/digest/DigestRequiem.js +13 -15
  267. package/dist/digest/DigestRequiem.js.map +1 -1
  268. package/dist/digest/digest-db.d.ts +3 -0
  269. package/dist/digest/digest-db.d.ts.map +1 -0
  270. package/dist/digest/digest-db.js +68 -0
  271. package/dist/digest/digest-db.js.map +1 -0
  272. package/dist/digest/digest-paths.d.ts +6 -0
  273. package/dist/digest/digest-paths.d.ts.map +1 -0
  274. package/dist/digest/digest-paths.js +23 -0
  275. package/dist/digest/digest-paths.js.map +1 -0
  276. package/dist/digest/digest-rows.d.ts +15 -0
  277. package/dist/digest/digest-rows.d.ts.map +1 -1
  278. package/dist/digest/digest.sql +13 -3
  279. package/dist/index.d.ts +0 -1
  280. package/dist/index.d.ts.map +1 -1
  281. package/dist/index.js +0 -1
  282. package/dist/index.js.map +1 -1
  283. package/dist/observe/genai.d.ts +2 -2
  284. package/dist/observe/genai.d.ts.map +1 -1
  285. package/dist/observe/genai.js +15 -5
  286. package/dist/observe/genai.js.map +1 -1
  287. package/dist/schemes/EffectPolicy.d.ts +0 -2
  288. package/dist/schemes/EffectPolicy.d.ts.map +1 -1
  289. package/dist/schemes/EffectPolicy.js +25 -36
  290. package/dist/schemes/EffectPolicy.js.map +1 -1
  291. package/dist/schemes/Exec.d.ts +4 -5
  292. package/dist/schemes/Exec.d.ts.map +1 -1
  293. package/dist/schemes/Exec.js +74 -62
  294. package/dist/schemes/Exec.js.map +1 -1
  295. package/dist/schemes/ExecOutputScheme.d.ts +6 -5
  296. package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
  297. package/dist/schemes/ExecOutputScheme.js +49 -16
  298. package/dist/schemes/ExecOutputScheme.js.map +1 -1
  299. package/dist/schemes/File.d.ts.map +1 -1
  300. package/dist/schemes/File.js +28 -20
  301. package/dist/schemes/File.js.map +1 -1
  302. package/dist/schemes/Log.d.ts +4 -4
  303. package/dist/schemes/Log.d.ts.map +1 -1
  304. package/dist/schemes/Log.js +29 -9
  305. package/dist/schemes/Log.js.map +1 -1
  306. package/dist/schemes/QuestionTool.d.ts.map +1 -1
  307. package/dist/schemes/QuestionTool.js +14 -1
  308. package/dist/schemes/QuestionTool.js.map +1 -1
  309. package/dist/schemes/TurnSource.d.ts +3 -2
  310. package/dist/schemes/TurnSource.d.ts.map +1 -1
  311. package/dist/schemes/TurnSource.js +80 -35
  312. package/dist/schemes/TurnSource.js.map +1 -1
  313. package/dist/schemes/Worker.d.ts.map +1 -1
  314. package/dist/schemes/Worker.js +22 -56
  315. package/dist/schemes/Worker.js.map +1 -1
  316. package/dist/schemes/_entry-crud.js +6 -6
  317. package/dist/schemes/_entry-crud.js.map +1 -1
  318. package/dist/schemes/_entry-crud.sql +19 -17
  319. package/dist/schemes/_entry-find.d.ts.map +1 -1
  320. package/dist/schemes/_entry-find.js +6 -5
  321. package/dist/schemes/_entry-find.js.map +1 -1
  322. package/dist/schemes/_entry-fts.d.ts.map +1 -1
  323. package/dist/schemes/_entry-fts.js +6 -3
  324. package/dist/schemes/_entry-fts.js.map +1 -1
  325. package/dist/schemes/_entry-fts.sql +25 -6
  326. package/dist/schemes/_entry-manifest.d.ts +1 -1
  327. package/dist/schemes/_entry-manifest.d.ts.map +1 -1
  328. package/dist/schemes/_entry-manifest.js +5 -3
  329. package/dist/schemes/_entry-manifest.js.map +1 -1
  330. package/dist/schemes/_entry-ops.js +4 -4
  331. package/dist/schemes/_entry-ops.js.map +1 -1
  332. package/dist/schemes/_entry-ops.sql +2 -2
  333. package/dist/schemes/_entry-readable.d.ts.map +1 -1
  334. package/dist/schemes/_entry-readable.js +5 -4
  335. package/dist/schemes/_entry-readable.js.map +1 -1
  336. package/dist/schemes/_entry-send.js +2 -2
  337. package/dist/schemes/_entry-send.js.map +1 -1
  338. package/dist/schemes/_search-exclusion.d.ts +1 -0
  339. package/dist/schemes/_search-exclusion.d.ts.map +1 -1
  340. package/dist/schemes/_search-exclusion.js +12 -0
  341. package/dist/schemes/_search-exclusion.js.map +1 -1
  342. package/dist/schemes/_search-index.js +4 -4
  343. package/dist/schemes/_search-index.js.map +1 -1
  344. package/dist/schemes/exec-abort.d.ts.map +1 -1
  345. package/dist/schemes/exec-abort.js +4 -3
  346. package/dist/schemes/exec-abort.js.map +1 -1
  347. package/dist/schemes/exec-lifetime.d.ts +11 -0
  348. package/dist/schemes/exec-lifetime.d.ts.map +1 -0
  349. package/dist/schemes/exec-lifetime.js +29 -0
  350. package/dist/schemes/exec-lifetime.js.map +1 -0
  351. package/dist/server/ClientReads.d.ts.map +1 -1
  352. package/dist/server/ClientReads.js +3 -1
  353. package/dist/server/ClientReads.js.map +1 -1
  354. package/dist/server/Daemon.d.ts +30 -7
  355. package/dist/server/Daemon.d.ts.map +1 -1
  356. package/dist/server/Daemon.js +107 -48
  357. package/dist/server/Daemon.js.map +1 -1
  358. package/dist/server/DaemonModule.d.ts +19 -5
  359. package/dist/server/DaemonModule.d.ts.map +1 -1
  360. package/dist/server/DrainSupervisor.d.ts +13 -11
  361. package/dist/server/DrainSupervisor.d.ts.map +1 -1
  362. package/dist/server/DrainSupervisor.js +87 -98
  363. package/dist/server/DrainSupervisor.js.map +1 -1
  364. package/dist/server/EnvFunctionality.d.ts +12 -3
  365. package/dist/server/EnvFunctionality.d.ts.map +1 -1
  366. package/dist/server/EnvFunctionality.js +19 -14
  367. package/dist/server/EnvFunctionality.js.map +1 -1
  368. package/dist/server/Functionality.d.ts +2 -2
  369. package/dist/server/Functionality.d.ts.map +1 -1
  370. package/dist/server/Functionality.js +97 -62
  371. package/dist/server/Functionality.js.map +1 -1
  372. package/dist/server/FunctionalityManager.d.ts +3 -1
  373. package/dist/server/FunctionalityManager.d.ts.map +1 -1
  374. package/dist/server/FunctionalityManager.js +11 -5
  375. package/dist/server/FunctionalityManager.js.map +1 -1
  376. package/dist/server/HttpListener.d.ts +16 -0
  377. package/dist/server/HttpListener.d.ts.map +1 -0
  378. package/dist/server/HttpListener.js +81 -0
  379. package/dist/server/HttpListener.js.map +1 -0
  380. package/dist/server/MembersFunctionality.d.ts.map +1 -1
  381. package/dist/server/MembersFunctionality.js +12 -16
  382. package/dist/server/MembersFunctionality.js.map +1 -1
  383. package/dist/server/PlurnkSkill.d.ts.map +1 -1
  384. package/dist/server/PlurnkSkill.js +1 -0
  385. package/dist/server/PlurnkSkill.js.map +1 -1
  386. package/dist/server/Retention.d.ts +11 -0
  387. package/dist/server/Retention.d.ts.map +1 -1
  388. package/dist/server/Retention.js +47 -2
  389. package/dist/server/Retention.js.map +1 -1
  390. package/dist/server/Retention.sql +32 -1
  391. package/dist/server/ServiceModules.d.ts.map +1 -1
  392. package/dist/server/ServiceModules.js +2 -0
  393. package/dist/server/ServiceModules.js.map +1 -1
  394. package/dist/server/SkillsFunctionality.d.ts +2 -0
  395. package/dist/server/SkillsFunctionality.d.ts.map +1 -1
  396. package/dist/server/SkillsFunctionality.js +22 -15
  397. package/dist/server/SkillsFunctionality.js.map +1 -1
  398. package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
  399. package/dist/server/WorkspaceCapabilities.js +1 -0
  400. package/dist/server/WorkspaceCapabilities.js.map +1 -1
  401. package/dist/server/WorkspaceStorage.d.ts +8 -0
  402. package/dist/server/WorkspaceStorage.d.ts.map +1 -0
  403. package/dist/server/WorkspaceStorage.js +26 -0
  404. package/dist/server/WorkspaceStorage.js.map +1 -0
  405. package/dist/server/client-input.d.ts +4 -3
  406. package/dist/server/client-input.d.ts.map +1 -1
  407. package/dist/server/client-input.js +24 -26
  408. package/dist/server/client-input.js.map +1 -1
  409. package/dist/server/dispatch-as-plurnk.js +2 -2
  410. package/dist/server/dispatch-as-plurnk.js.map +1 -1
  411. package/dist/server/drain.sql +69 -132
  412. package/dist/server/envelope.d.ts +2 -2
  413. package/dist/server/envelope.d.ts.map +1 -1
  414. package/dist/server/envelope.js +7 -9
  415. package/dist/server/envelope.js.map +1 -1
  416. package/dist/server/envelope.sql +10 -6
  417. package/dist/server/exec-poll-backoff.js +3 -3
  418. package/dist/server/exec-poll-backoff.js.map +1 -1
  419. package/dist/server/lifecycle-recovery.sql +8 -35
  420. package/dist/server/logEntry.sql +2 -2
  421. package/dist/server/loopDocs.js +3 -3
  422. package/dist/server/loopDocs.sql +4 -2
  423. package/dist/server/model-catalog.d.ts.map +1 -1
  424. package/dist/server/model-catalog.js +2 -2
  425. package/dist/server/model-catalog.js.map +1 -1
  426. package/dist/server/seam-loop.sql +0 -1
  427. package/dist/server/workspace-storage.sql +8 -0
  428. package/dist/service.d.ts.map +1 -1
  429. package/dist/service.js +21 -10
  430. package/dist/service.js.map +1 -1
  431. package/docs/copy-move.md +31 -0
  432. package/docs/env.md +19 -7
  433. package/docs/skills.md +2 -2
  434. package/migrations/002_workers.sql +26 -17
  435. package/migrations/003_loops.sql +82 -28
  436. package/migrations/005_entries.sql +135 -22
  437. package/migrations/006_log.sql +77 -25
  438. package/migrations/007_subscriptions.sql +10 -15
  439. package/package.json +35 -36
  440. package/dist/core/PromptFrames.d.ts +0 -12
  441. package/dist/core/PromptFrames.d.ts.map +0 -1
  442. package/dist/core/PromptFrames.js +0 -28
  443. package/dist/core/PromptFrames.js.map +0 -1
  444. package/dist/schemes/Prompt.d.ts +0 -8
  445. package/dist/schemes/Prompt.d.ts.map +0 -1
  446. package/dist/schemes/Prompt.js +0 -25
  447. package/dist/schemes/Prompt.js.map +0 -1
@@ -1,18 +1,22 @@
1
1
  var _a;
2
2
  import { PlurnkParser, parsePath } from "@plurnk/plurnk-parser";
3
3
  import { TurnDisposition } from "@plurnk/plurnk-contracts";
4
- import { foldAuthorityIntoPath, promptLoopPrefix, renderAddress, renderTarget, schemeNameOf } from "./plurnk-uri.js";
4
+ import Turn from "./Turn.js";
5
+ import { foldAuthorityIntoPath, renderAddress, renderTarget, schemeNameOf } from "./plurnk-uri.js";
6
+ import WorkerName from "./WorkerName.js";
5
7
  import { PathSyntax } from "@plurnk/plurnk-contracts";
6
8
  import Namespace from "./namespace.js";
7
9
  import CapabilityResolver from "./CapabilityResolver.js";
10
+ import CapabilityPolicies from "./CapabilityPolicies.js";
8
11
  import LoopPolicyReader from "./LoopPolicyReader.js";
9
12
  import SchemeCtxImpl from "./caps/SchemeCtxImpl.js";
10
13
  import Results from "./results.js";
11
14
  import { OperationFailureError } from "./results.js";
12
15
  import EffectPolicy from "../schemes/EffectPolicy.js";
13
16
  import { CoreSchemeAdapterBase } from "./CoreSchemeServices.js";
14
- import { InvalidOperationResultError } from "@plurnk/plurnk-schemes";
17
+ import { InvalidOperationResultError, MessageAttachments } from "@plurnk/plurnk-schemes";
15
18
  import ResourceMutations from "./ResourceMutations.js";
19
+ import ResourceSelector from "./ResourceSelector.js";
16
20
  import { primaryTargetOf } from "./statement-primary.js";
17
21
  import LogBody from "./LogBody.js";
18
22
  import LogVisibility from "./LogVisibility.js";
@@ -35,11 +39,6 @@ class Dispatcher {
35
39
  static #failure(code, status, detail, fields = {}, extensions = {}) {
36
40
  return Results.failure("engine:dispatcher", code, status, detail, fields, extensions);
37
41
  }
38
- static #statusResult(status, code, detail, fields = {}) {
39
- return status >= 400
40
- ? _a.#failure(code, status, detail, fields, { retryable: false })
41
- : { ...fields, status };
42
- }
43
42
  #db;
44
43
  #schemes;
45
44
  #mimetypes;
@@ -58,11 +57,12 @@ class Dispatcher {
58
57
  #wakeWorkerNotify;
59
58
  #injectWorker;
60
59
  #cancelWorker;
61
- #cancelDescendants;
60
+ #operationSettledNotify;
62
61
  // Per-turn running-worker READ obligations. {§join-blocking-collect}
63
62
  #liveSubscriptions;
64
63
  #lifecycle;
65
64
  #resourceMutations;
65
+ #resourceSelector;
66
66
  #entryAddresses;
67
67
  #capabilities;
68
68
  #workerControl;
@@ -70,7 +70,7 @@ class Dispatcher {
70
70
  #disposition;
71
71
  #logWriter;
72
72
  #dataRun;
73
- 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 }) {
74
74
  this.#db = db;
75
75
  this.#schemes = schemes;
76
76
  this.#mimetypes = mimetypes;
@@ -85,11 +85,20 @@ class Dispatcher {
85
85
  this.#wakeWorkerNotify = wakeWorkerNotify;
86
86
  this.#injectWorker = injectWorker;
87
87
  this.#cancelWorker = cancelWorker;
88
- this.#cancelDescendants = cancelDescendants;
88
+ this.#operationSettledNotify = operationSettledNotify;
89
89
  this.#liveSubscriptions = liveSubscriptions;
90
90
  this.#entryAddresses = entryAddresses;
91
91
  this.#capabilities = new CapabilityResolver(db, schemes, executors);
92
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
+ });
93
102
  this.#resourceMutations = new ResourceMutations({
94
103
  schemes,
95
104
  liveSubscriptions,
@@ -97,11 +106,7 @@ class Dispatcher {
97
106
  checkWritable: (statement, origin, workspaceId) => this.#checkWritable(statement, origin, workspaceId),
98
107
  checkCapabilities: (statement, ctx) => this.#checkCapabilities(statement, ctx),
99
108
  editTargetIdentity: (statement, workspaceId, workerId) => this.#editTargetIdentity(statement, workspaceId, workerId),
100
- canonicalFilePath: (pathname, workspaceId) => this.#canonicalFilePath(pathname, workspaceId),
101
- prepareDataRepresentation: (args) => this.#prepareDataRepresentation({
102
- ...args,
103
- handler: args.handler,
104
- }),
109
+ selection: this.#resourceSelector,
105
110
  resolveDataEntryAddress: (args) => this.#entryAddresses.resolve(args),
106
111
  readEntry: (scheme, address, ctx) => this.#readEntry(scheme, address, ctx),
107
112
  writeEntry: (scheme, address, entry, ctx) => this.#writeEntry(scheme, address, entry, ctx),
@@ -110,7 +115,7 @@ class Dispatcher {
110
115
  });
111
116
  this.#workerControl = new WorkerControlHandler({ db: this.#db, failure: _a.#failure });
112
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 });
113
- 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 });
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) });
114
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 });
115
120
  this.#dataRun = new DataStatementRunner({ schemes: this.#schemes, liveSubscriptions: this.#liveSubscriptions, resolveDataEntryAddress: this.#resolveDataEntryAddress.bind(this), prepareDataRepresentation: this.#prepareDataRepresentation.bind(this), failure: _a.#failure });
116
121
  }
@@ -334,6 +339,7 @@ class Dispatcher {
334
339
  turnId: context.turnId, sequence: context.sequence, origin: context.origin, curationPlan: null, modelCallId: null,
335
340
  });
336
341
  context.onDispatch?.(logEntryId);
342
+ await this.#notifySettled(context, logEntryId);
337
343
  return result;
338
344
  }
339
345
  const matchingPathCount = typeof found.matchingPathCount === "number" ? found.matchingPathCount : paths.length;
@@ -356,14 +362,11 @@ class Dispatcher {
356
362
  return Results.assert({ ...(results.find(({ status }) => status >= 400) ?? results[results.length - 1]), rowsWritten: results.length });
357
363
  }
358
364
  async #dispatchOne(context, schemeCtx) {
359
- const { statement, workspaceId, workerId, loopId, turnId, sequence, origin, onDispatch, onSettled, } = context;
365
+ const { statement, workspaceId, workerId, loopId, turnId, sequence, origin, onDispatch, } = context;
360
366
  let result;
361
367
  let curationPlan = null;
362
- // {§send-prompt-acceptance} — a model SEND addressed to one of this loop's own prompts
363
- // means what an untargeted SEND means; the address the packet showed it is accepted.
364
- const ownPrompt = statement.op === "SEND" && origin === "model" && await this.#isOwnPromptAddress(statement.target, workerId, loopId);
365
- const denial = ownPrompt ? null : (this.#checkWritable(statement, origin, workspaceId)
366
- ?? await this.#checkCapabilities(statement, schemeCtx));
368
+ const denial = this.#checkWritable(statement, origin, workspaceId)
369
+ ?? await this.#checkCapabilities(statement, schemeCtx);
367
370
  if (denial !== null) {
368
371
  result = denial;
369
372
  }
@@ -377,18 +380,23 @@ class Dispatcher {
377
380
  if (statement.op === "EDIT") {
378
381
  result = await this.#resourceMutations.edit(statement, schemeCtx, context.editSequence);
379
382
  }
380
- else if (statement.op === "SEND" && (statement.target === null || ownPrompt)) {
383
+ else if (statement.op === "SEND" && statement.target === null) {
381
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}` }) };
382
395
  }
383
396
  else if (TurnDisposition.is(statement)) {
384
- result = await this.#disposition.handle(statement, {
385
- workspaceId,
386
- workerId,
387
- loopId,
388
- turnId,
389
- sequence,
390
- origin,
391
- });
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 });
392
400
  }
393
401
  else if (statement.op === "KILL" && schemeNameOf(statement.target) === "log") {
394
402
  const curation = await this.#runLogCuration(statement, schemeCtx, context.logSelectionMaxId);
@@ -461,7 +469,7 @@ class Dispatcher {
461
469
  });
462
470
  onDispatch?.(logEntryId);
463
471
  // Proposal lifecycle (SPEC.md {§engine-rails} + {§methods-proposal-resolve}; {§proposal-202-pauses}). When a
464
- // side-effecting op returns status 202 (a waiting TASK parks rather
472
+ // side-effecting op returns status 202 (a WAIT parks rather
465
473
  // than proposing — #isProposal), the entry is written
466
474
  // state='proposed'; dispatch then PAUSES on a per-entry waiter until
467
475
  // resolution arrives via Engine.resolveProposal (from a client-interface resume,
@@ -471,17 +479,21 @@ class Dispatcher {
471
479
  // Effect-gated auto-run (read/pure runtimes, {§exec-readpure-ungated}):
472
480
  // An execution stores its one canonical effect fact before admission. Reuse
473
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.
474
485
  const effect = result.attrs?.effect;
475
486
  let autoAccept = false;
476
- if (isExecution(statement) || (statement.op === "SEND"
477
- && 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) {
478
490
  if (!EffectPolicy.isEffect(effect)) {
479
491
  throw new InvalidOperationResultError("Execution proposal omitted its canonical effect fact.");
480
492
  }
481
493
  autoAccept = EffectPolicy.decide(effect) === "auto";
482
494
  }
483
495
  if (autoAccept) {
484
- 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 });
485
497
  const effective = await this.#resourceMutations.settleProposal({
486
498
  statement,
487
499
  result,
@@ -490,7 +502,7 @@ class Dispatcher {
490
502
  ids: { workspaceId, workerId, loopId, turnId },
491
503
  });
492
504
  const post = await this.#proposals.applyResolution(logEntryId, effective);
493
- await onSettled?.(logEntryId);
505
+ await this.#notifySettled(context, logEntryId);
494
506
  return post;
495
507
  }
496
508
  // Register the resolution waiter SYNCHRONOUSLY before any await
@@ -504,14 +516,14 @@ class Dispatcher {
504
516
  // not an observer and cannot silently degrade into client ownership.
505
517
  let resolutionPromise;
506
518
  try {
507
- resolutionPromise = this.#proposals.awaitResolution(logEntryId);
519
+ resolutionPromise = this.#proposals.awaitResolution(logEntryId, this.#loopSignal(loopId));
508
520
  const event = await this.#proposals.pending(logEntryId);
509
521
  this.#proposals.settleOwned(event);
510
522
  this.#proposals.notifyPending(event);
511
523
  }
512
524
  catch (cause) {
513
525
  await this.#proposals.failPreparation(logEntryId, cause);
514
- await onSettled?.(logEntryId);
526
+ await this.#notifySettled(context, logEntryId);
515
527
  throw cause;
516
528
  }
517
529
  const resolution = await resolutionPromise;
@@ -519,7 +531,7 @@ class Dispatcher {
519
531
  // file, spawns the process, etc.). Its operation result is
520
532
  // preserved: an apply failure keeps its original status and
521
533
  // Problem Details instead of masquerading as a client rejection.
522
- 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 });
523
535
  const effective = await this.#resourceMutations.settleProposal({
524
536
  statement,
525
537
  result,
@@ -528,12 +540,16 @@ class Dispatcher {
528
540
  ids: { workspaceId, workerId, loopId, turnId },
529
541
  });
530
542
  const post = await this.#proposals.applyResolution(logEntryId, effective);
531
- await onSettled?.(logEntryId);
543
+ await this.#notifySettled(context, logEntryId);
532
544
  return post;
533
545
  }
534
- await onSettled?.(logEntryId);
546
+ await this.#notifySettled(context, logEntryId);
535
547
  return result;
536
548
  }
549
+ async #notifySettled(context, logEntryId) {
550
+ await context.onSettled?.(logEntryId);
551
+ await this.#operationSettledNotify?.(context.workspaceId, logEntryId);
552
+ }
537
553
  // {§op-look}: resolve a READ and return its content without writing a
538
554
  // log_entries row: the client's out-of-band inspection primitive (LOOK → READ,
539
555
  // invisible to the model). READ never mutates and never proposes, so this is
@@ -618,7 +634,7 @@ class Dispatcher {
618
634
  if (metadata !== null && manifest.metadataModifier !== true) {
619
635
  return {
620
636
  address: null,
621
- 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 }),
622
638
  };
623
639
  }
624
640
  const resolved = priorResolution ?? await this.#resolveDataEntryAddress({
@@ -697,6 +713,8 @@ class Dispatcher {
697
713
  db: this.#db,
698
714
  workspaceId, workerId, loopId, turnId,
699
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),
700
718
  signal: this.#loopSignal(loopId),
701
719
  streamEventNotify: this.#streamEventNotify,
702
720
  wakeWorkerNotify: this.#wakeWorkerNotify,
@@ -766,7 +784,7 @@ class Dispatcher {
766
784
  return _a.#failure("send-target-not-a-recipient", 400, "The addressed scheme is not a SEND recipient.", {}, {
767
785
  target: statement.target?.raw ?? String(target),
768
786
  stage: "dispatch",
769
- 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.",
770
788
  retryable: false,
771
789
  });
772
790
  }
@@ -795,7 +813,7 @@ class Dispatcher {
795
813
  // owner; a known policy denial is one factual, non-presumptuous 403.
796
814
  async #checkCapabilities(statement, ctx) {
797
815
  await LoopPolicyReader.read(this.#db, ctx.loopId);
798
- 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);
799
817
  if (denied === null)
800
818
  return null;
801
819
  const { descriptor, scope } = denied;
@@ -808,6 +826,10 @@ class Dispatcher {
808
826
  return _a.#failure("capability-denied", 403, `Capability '${route}' is denied by ${scope} policy.`, {}, {
809
827
  ...descriptor,
810
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 } : {}),
811
833
  retryable: false,
812
834
  });
813
835
  }
@@ -925,20 +947,22 @@ class Dispatcher {
925
947
  modelCallId,
926
948
  });
927
949
  context.onDispatch?.(logEntryId);
928
- await context.onSettled?.(logEntryId);
950
+ await this.#notifySettled(context, logEntryId);
929
951
  return result;
930
952
  }
931
- // {§send-prompt-acceptance} `prompt://<this worker>/<this loop>/<id>` names a prompt the loop
932
- // contains; a SEND to it is the response, exactly as if untargeted. Another worker's or
933
- // another loop's prompt is not a recipient and keeps the ordinary refusal.
934
- // {§send-response-receipt} — a response names the prompts it answers, so the receipt
935
- // says where the text went. {§send-looks-like-operation} — a model response whose first
936
- // line is an operation heading is a mis-fenced operation, not a reply: the 2026-09-11
937
- // dogfood put four operations on the line after their fences, delivered all four to the
938
- // 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}
939
963
  async #respond(statement, schemeCtx, origin, workerId, loopId) {
940
964
  if (origin === "model") {
941
- const heading = this.#operationHeading(statement.body?.raw ?? "", schemeCtx);
965
+ const heading = this.#operationHeading(typeof statement.body === "string" ? statement.body : statement.body?.raw ?? "", schemeCtx);
942
966
  if (heading !== null) {
943
967
  return _a.#failure("send-looks-like-operation", 400, `The response begins with the operation heading \`${heading}\`; nothing ran and nothing was delivered.`, {}, {
944
968
  heading,
@@ -948,7 +972,24 @@ class Dispatcher {
948
972
  });
949
973
  }
950
974
  }
951
- 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) }) };
952
993
  }
953
994
  // The first non-blank line, when it parses alone as one clean heading naming an operation
954
995
  // this worker could perform: a Plurnk operation, or a registered executor or MCP service.
@@ -972,38 +1013,21 @@ class Dispatcher {
972
1013
  return null;
973
1014
  return line;
974
1015
  }
975
- // The loop's Active Prompts, oldest first, exactly as the packet lists them.
976
- async #activePrompts(workerId, loopId) {
977
- const worker = await this.#db.worker_get.get({ id: workerId });
978
- if (worker === undefined)
979
- throw new Error(`worker ${workerId} does not exist`);
980
- const loopSeq = (await this.#db.engine_loop_sequence.get({ loop_id: loopId }))?.sequence ?? loopId;
981
- const prefix = promptLoopPrefix(loopSeq);
982
- const rows = await this.#db.drain_get_all_prompt_bodies_for_loop.all({
983
- worker_id: workerId,
984
- pattern: `${prefix}%`,
985
- prefix_len: prefix.length,
986
- });
987
- 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);
988
1020
  }
989
- async #isOwnPromptAddress(target, workerId, loopId) {
990
- if (target === null || target.kind !== "url" || target.scheme !== "prompt")
991
- return false;
992
- const worker = await this.#db.worker_get.get({ id: workerId });
993
- if (worker === undefined || target.hostname !== worker.name)
994
- return false;
995
- const loopSeq = (await this.#db.engine_loop_sequence.get({ loop_id: loopId }))?.sequence ?? loopId;
996
- return target.pathname.startsWith(promptLoopPrefix(loopSeq));
1021
+ async settleProgram(ctx, wait) {
1022
+ return this.#disposition.settle(ctx, wait);
997
1023
  }
998
- // {§send-premature-terminate} The pending set is judged at TASK's dispatch point,
999
- // after earlier operations have executed. Every non-SEND/TASK/KILL model operation
1000
- // requires a new packet, independently of its result or log visibility.
1001
- async #pendingSet(workerId, turnId) {
1024
+ // {§send-premature-terminate}: judge observation boundaries after the whole program settles.
1025
+ async #pendingSet(workerId, turnId, loopId) {
1002
1026
  const pending = [];
1003
- // {§worker-obligations} — the stream and child legs are one durable row.
1004
- 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 });
1005
1029
  if (held === undefined)
1006
- throw new Error(`worker ${workerId} does not exist`);
1030
+ throw new Error(`loop ${loopId} does not exist`);
1007
1031
  if (held.streams === 1)
1008
1032
  pending.push("streams");
1009
1033
  if (held.workers === 1)
@@ -1016,7 +1040,7 @@ class Dispatcher {
1016
1040
  receipts.push("stream completion");
1017
1041
  if (receipts.length > 0)
1018
1042
  pending.push("receipts");
1019
- // The final-strike escape hatch cannot discard an unobserved failure.
1043
+ // A failed stream result is still owed to the model before ordinary completion.
1020
1044
  if (boundaries.streamTerminations.some(({ closeStatus }) => closeStatus >= 400))
1021
1045
  pending.push("failed-stream-results");
1022
1046
  if (boundaries.childTerminations)
@@ -1046,11 +1070,9 @@ class Dispatcher {
1046
1070
  const failedRows = await this.#db.engine_turn_failures.all({ turn_id: turnId });
1047
1071
  return failedRows.length;
1048
1072
  }
1049
- // A live obligation to wait on: a spawned child or an open stream (not retrievals, which land
1050
- // next turn regardless). The wait-side twin of #pendingSet's stream+child legs ({§wait-obligation-matrix}).
1051
- async hasLiveWork(workerId) {
1052
- // {§worker-obligations} — one durable row answers both legs.
1053
- 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 });
1054
1076
  return held !== undefined && (held.streams === 1 || held.workers === 1);
1055
1077
  }
1056
1078
  async #runLogCuration(statement, ctx, admittedMaxId) {
@@ -1103,7 +1125,7 @@ class Dispatcher {
1103
1125
  const routedScheme = schemeNameOf(path);
1104
1126
  const manifest = routedScheme === null
1105
1127
  ? undefined
1106
- : this.#schemes.manifestFor(routedScheme, workspaceId);
1128
+ : this.#schemes.manifestAt(routedScheme, path, workspaceId);
1107
1129
  const foldNs = scheme !== null
1108
1130
  && manifest !== undefined
1109
1131
  && (manifest.authority ?? "namespace") === "namespace";