@plurnk/plurnk-service 3.3.0 → 4.1.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 (309) hide show
  1. package/.env.defaults +4 -4
  2. package/INSTALL.md +6 -0
  3. package/README.md +2 -2
  4. package/SPEC.md +408 -179
  5. package/dist/build-info.json +1 -1
  6. package/dist/completions/_plurnk-service +1 -1
  7. package/dist/completions/plurnk-service.bash +1 -1
  8. package/dist/completions/plurnk-service.fish +2 -0
  9. package/dist/content/read-projector.js +1 -1
  10. package/dist/content/read-projector.js.map +1 -1
  11. package/dist/core/AdministrativeLoop.d.ts +1 -1
  12. package/dist/core/AdministrativeLoop.d.ts.map +1 -1
  13. package/dist/core/AdministrativeLoop.js +4 -1
  14. package/dist/core/AdministrativeLoop.js.map +1 -1
  15. package/dist/core/AdmittedTurnExecutor.d.ts +3 -1
  16. package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
  17. package/dist/core/AdmittedTurnExecutor.js +12 -0
  18. package/dist/core/AdmittedTurnExecutor.js.map +1 -1
  19. package/dist/core/BareBatchRunner.js +2 -1
  20. package/dist/core/BareBatchRunner.js.map +1 -1
  21. package/dist/core/ChannelWrite.d.ts +10 -0
  22. package/dist/core/ChannelWrite.d.ts.map +1 -1
  23. package/dist/core/ChannelWrite.js +10 -0
  24. package/dist/core/ChannelWrite.js.map +1 -1
  25. package/dist/core/ChannelWrite.sql +14 -2
  26. package/dist/core/ClientInteractions.d.ts.map +1 -1
  27. package/dist/core/ClientInteractions.js +2 -1
  28. package/dist/core/ClientInteractions.js.map +1 -1
  29. package/dist/core/CoreSchemeServices.d.ts.map +1 -1
  30. package/dist/core/CoreSchemeServices.js +5 -0
  31. package/dist/core/CoreSchemeServices.js.map +1 -1
  32. package/dist/core/DataStatementRunner.js +4 -6
  33. package/dist/core/DataStatementRunner.js.map +1 -1
  34. package/dist/core/Dispatcher.d.ts +4 -7
  35. package/dist/core/Dispatcher.d.ts.map +1 -1
  36. package/dist/core/Dispatcher.js +48 -68
  37. package/dist/core/Dispatcher.js.map +1 -1
  38. package/dist/core/Dispatcher.sql +2 -2
  39. package/dist/core/EditMutations.js +1 -0
  40. package/dist/core/EditMutations.js.map +1 -1
  41. package/dist/core/Engine.d.ts +8 -14
  42. package/dist/core/Engine.d.ts.map +1 -1
  43. package/dist/core/Engine.js +22 -24
  44. package/dist/core/Engine.js.map +1 -1
  45. package/dist/core/Engine.sql +6 -6
  46. package/dist/core/ExecutorRegistry.d.ts +0 -5
  47. package/dist/core/ExecutorRegistry.d.ts.map +1 -1
  48. package/dist/core/ExecutorRegistry.js +10 -18
  49. package/dist/core/ExecutorRegistry.js.map +1 -1
  50. package/dist/core/FileAddress.js +1 -1
  51. package/dist/core/FileAddress.js.map +1 -1
  52. package/dist/core/FilePublication.js +10 -74
  53. package/dist/core/FilePublication.js.map +1 -1
  54. package/dist/core/FileSnapshot.js +36 -100
  55. package/dist/core/FileSnapshot.js.map +1 -1
  56. package/dist/core/HostPaths.d.ts +1 -0
  57. package/dist/core/HostPaths.d.ts.map +1 -1
  58. package/dist/core/HostPaths.js +11 -1
  59. package/dist/core/HostPaths.js.map +1 -1
  60. package/dist/core/KillHandler.js +3 -1
  61. package/dist/core/KillHandler.js.map +1 -1
  62. package/dist/core/LiveSubscription.js +1 -1
  63. package/dist/core/LiveSubscription.js.map +1 -1
  64. package/dist/core/LogBody.js +1 -1
  65. package/dist/core/LogBody.js.map +1 -1
  66. package/dist/core/LogWriter.d.ts +4 -2
  67. package/dist/core/LogWriter.d.ts.map +1 -1
  68. package/dist/core/LogWriter.js +8 -4
  69. package/dist/core/LogWriter.js.map +1 -1
  70. package/dist/core/LoopDriver.d.ts +3 -3
  71. package/dist/core/LoopDriver.d.ts.map +1 -1
  72. package/dist/core/LoopDriver.js +15 -13
  73. package/dist/core/LoopDriver.js.map +1 -1
  74. package/dist/core/LoopLifecycle.d.ts +5 -0
  75. package/dist/core/LoopLifecycle.d.ts.map +1 -1
  76. package/dist/core/LoopLifecycle.js +14 -1
  77. package/dist/core/LoopLifecycle.js.map +1 -1
  78. package/dist/core/LoopLifecycle.sql +8 -0
  79. package/dist/core/MembershipMaterialization.js +2 -2
  80. package/dist/core/MembershipMaterialization.js.map +1 -1
  81. package/dist/core/MessageResources.d.ts +3 -0
  82. package/dist/core/MessageResources.d.ts.map +1 -1
  83. package/dist/core/MessageResources.js +15 -1
  84. package/dist/core/MessageResources.js.map +1 -1
  85. package/dist/core/OperationHistory.d.ts +18 -0
  86. package/dist/core/OperationHistory.d.ts.map +1 -0
  87. package/dist/core/OperationHistory.js +55 -0
  88. package/dist/core/OperationHistory.js.map +1 -0
  89. package/dist/core/OperatorConfig.d.ts +1 -2
  90. package/dist/core/OperatorConfig.d.ts.map +1 -1
  91. package/dist/core/OperatorConfig.js +26 -92
  92. package/dist/core/OperatorConfig.js.map +1 -1
  93. package/dist/core/PacketBuilder.d.ts.map +1 -1
  94. package/dist/core/PacketBuilder.js +22 -56
  95. package/dist/core/PacketBuilder.js.map +1 -1
  96. package/dist/core/PacketBuilder.sql +7 -8
  97. package/dist/core/ProblemLog.d.ts +1 -0
  98. package/dist/core/ProblemLog.d.ts.map +1 -1
  99. package/dist/core/ProblemLog.js +2 -2
  100. package/dist/core/ProblemLog.js.map +1 -1
  101. package/dist/core/ProposalLifecycle.d.ts.map +1 -1
  102. package/dist/core/ProposalLifecycle.js +13 -8
  103. package/dist/core/ProposalLifecycle.js.map +1 -1
  104. package/dist/core/ProposalPolicies.d.ts +4 -1
  105. package/dist/core/ProposalPolicies.d.ts.map +1 -1
  106. package/dist/core/ProposalPolicies.js +5 -2
  107. package/dist/core/ProposalPolicies.js.map +1 -1
  108. package/dist/core/ResourceMutations.js +2 -0
  109. package/dist/core/ResourceMutations.js.map +1 -1
  110. package/dist/core/ResourceSelector.js +1 -1
  111. package/dist/core/ResourceSelector.js.map +1 -1
  112. package/dist/core/SchemeRegistry.js +1 -1
  113. package/dist/core/SchemeRegistry.js.map +1 -1
  114. package/dist/core/ServiceHelp.js +1 -1
  115. package/dist/core/ServiceHelp.js.map +1 -1
  116. package/dist/core/ServiceTeardown.js +9 -12
  117. package/dist/core/ServiceTeardown.js.map +1 -1
  118. package/dist/core/StrikeRail.d.ts +2 -1
  119. package/dist/core/StrikeRail.d.ts.map +1 -1
  120. package/dist/core/StrikeRail.js +11 -6
  121. package/dist/core/StrikeRail.js.map +1 -1
  122. package/dist/core/TerminalResult.js +1 -1
  123. package/dist/core/TerminalResult.js.map +1 -1
  124. package/dist/core/TurnDispositionHandler.js +3 -2
  125. package/dist/core/TurnDispositionHandler.js.map +1 -1
  126. package/dist/core/TurnMaterialization.js +6 -4
  127. package/dist/core/TurnMaterialization.js.map +1 -1
  128. package/dist/core/TurnMaterialization.sql +1 -1
  129. package/dist/core/TurnOps.d.ts +0 -3
  130. package/dist/core/TurnOps.d.ts.map +1 -1
  131. package/dist/core/TurnOps.js +1 -27
  132. package/dist/core/TurnOps.js.map +1 -1
  133. package/dist/core/TurnRunner.d.ts +4 -2
  134. package/dist/core/TurnRunner.d.ts.map +1 -1
  135. package/dist/core/TurnRunner.js +61 -61
  136. package/dist/core/TurnRunner.js.map +1 -1
  137. package/dist/core/WorkerControlHandler.d.ts +2 -0
  138. package/dist/core/WorkerControlHandler.d.ts.map +1 -1
  139. package/dist/core/WorkerControlHandler.js +48 -16
  140. package/dist/core/WorkerControlHandler.js.map +1 -1
  141. package/dist/core/WorkerName.d.ts +0 -4
  142. package/dist/core/WorkerName.d.ts.map +1 -1
  143. package/dist/core/WorkerName.js +5 -30
  144. package/dist/core/WorkerName.js.map +1 -1
  145. package/dist/core/WorkerName.sql +4 -20
  146. package/dist/core/WorkerOwners.d.ts +1 -0
  147. package/dist/core/WorkerOwners.d.ts.map +1 -1
  148. package/dist/core/WorkerOwners.js +6 -0
  149. package/dist/core/WorkerOwners.js.map +1 -1
  150. package/dist/core/WorkerOwners.sql +7 -0
  151. package/dist/core/WorkspaceGate.d.ts +3 -1
  152. package/dist/core/WorkspaceGate.d.ts.map +1 -1
  153. package/dist/core/WorkspaceGate.js +59 -10
  154. package/dist/core/WorkspaceGate.js.map +1 -1
  155. package/dist/core/caps/SchemeCtxImpl.d.ts +2 -0
  156. package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
  157. package/dist/core/caps/SchemeCtxImpl.js +12 -0
  158. package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
  159. package/dist/core/env-catalog.js +1 -1
  160. package/dist/core/env-catalog.js.map +1 -1
  161. package/dist/core/fork.js +1 -1
  162. package/dist/core/fork.js.map +1 -1
  163. package/dist/core/fork.sql +5 -4
  164. package/dist/core/mutation-types.js +4 -1
  165. package/dist/core/mutation-types.js.map +1 -1
  166. package/dist/core/namespace.js +1 -1
  167. package/dist/core/namespace.js.map +1 -1
  168. package/dist/core/packet-wire.d.ts +7 -5
  169. package/dist/core/packet-wire.d.ts.map +1 -1
  170. package/dist/core/packet-wire.js +38 -20
  171. package/dist/core/packet-wire.js.map +1 -1
  172. package/dist/core/scheme-types.d.ts +4 -0
  173. package/dist/core/scheme-types.d.ts.map +1 -1
  174. package/dist/core/turn-signals.d.ts +4 -0
  175. package/dist/core/turn-signals.d.ts.map +1 -1
  176. package/dist/core/turn-signals.js +1 -0
  177. package/dist/core/turn-signals.js.map +1 -1
  178. package/dist/core/workspace-settings.js +1 -1
  179. package/dist/core/workspace-settings.js.map +1 -1
  180. package/dist/evidence/EvidenceReader.js +5 -5
  181. package/dist/evidence/EvidenceReader.js.map +1 -1
  182. package/dist/man/plurnk-service.1 +27 -6
  183. package/dist/schemes/Env.d.ts +7 -3
  184. package/dist/schemes/Env.d.ts.map +1 -1
  185. package/dist/schemes/Env.js +12 -6
  186. package/dist/schemes/Env.js.map +1 -1
  187. package/dist/schemes/Exec.d.ts.map +1 -1
  188. package/dist/schemes/Exec.js +33 -25
  189. package/dist/schemes/Exec.js.map +1 -1
  190. package/dist/schemes/ExecOutputScheme.js +3 -3
  191. package/dist/schemes/ExecOutputScheme.js.map +1 -1
  192. package/dist/schemes/ExecutionInput.js +1 -1
  193. package/dist/schemes/ExecutionInput.js.map +1 -1
  194. package/dist/schemes/File.js +15 -18
  195. package/dist/schemes/File.js.map +1 -1
  196. package/dist/schemes/Log.d.ts.map +1 -1
  197. package/dist/schemes/Log.js +21 -36
  198. package/dist/schemes/Log.js.map +1 -1
  199. package/dist/schemes/Log.sql +0 -9
  200. package/dist/schemes/ResourceTreeScheme.js +2 -5
  201. package/dist/schemes/ResourceTreeScheme.js.map +1 -1
  202. package/dist/schemes/TurnSource.js +1 -1
  203. package/dist/schemes/TurnSource.js.map +1 -1
  204. package/dist/schemes/Worker.d.ts.map +1 -1
  205. package/dist/schemes/Worker.js +10 -3
  206. package/dist/schemes/Worker.js.map +1 -1
  207. package/dist/schemes/_entry-crud.d.ts.map +1 -1
  208. package/dist/schemes/_entry-crud.js +2 -4
  209. package/dist/schemes/_entry-crud.js.map +1 -1
  210. package/dist/schemes/_entry-crud.sql +5 -3
  211. package/dist/schemes/_entry-find.js +3 -3
  212. package/dist/schemes/_entry-find.js.map +1 -1
  213. package/dist/schemes/_entry-manifest.d.ts.map +1 -1
  214. package/dist/schemes/_entry-manifest.js +3 -3
  215. package/dist/schemes/_entry-manifest.js.map +1 -1
  216. package/dist/schemes/_entry-manifest.sql +2 -0
  217. package/dist/schemes/_entry-ops.js +1 -1
  218. package/dist/schemes/_entry-ops.js.map +1 -1
  219. package/dist/schemes/_entry-send.js +1 -1
  220. package/dist/schemes/_entry-send.js.map +1 -1
  221. package/dist/server/ClientReads.d.ts +1 -0
  222. package/dist/server/ClientReads.d.ts.map +1 -1
  223. package/dist/server/ClientReads.js +7 -2
  224. package/dist/server/ClientReads.js.map +1 -1
  225. package/dist/server/Credentials.d.ts +48 -0
  226. package/dist/server/Credentials.d.ts.map +1 -0
  227. package/dist/server/Credentials.js +203 -0
  228. package/dist/server/Credentials.js.map +1 -0
  229. package/dist/server/Daemon.d.ts +40 -41
  230. package/dist/server/Daemon.d.ts.map +1 -1
  231. package/dist/server/Daemon.js +272 -206
  232. package/dist/server/Daemon.js.map +1 -1
  233. package/dist/server/DrainSupervisor.d.ts +5 -2
  234. package/dist/server/DrainSupervisor.d.ts.map +1 -1
  235. package/dist/server/DrainSupervisor.js +27 -31
  236. package/dist/server/DrainSupervisor.js.map +1 -1
  237. package/dist/server/EnvFunctionality.d.ts.map +1 -1
  238. package/dist/server/EnvFunctionality.js +2 -1
  239. package/dist/server/EnvFunctionality.js.map +1 -1
  240. package/dist/server/Functionality.d.ts +4 -2
  241. package/dist/server/Functionality.d.ts.map +1 -1
  242. package/dist/server/Functionality.js +110 -51
  243. package/dist/server/Functionality.js.map +1 -1
  244. package/dist/server/FunctionalityManager.js +1 -1
  245. package/dist/server/FunctionalityManager.js.map +1 -1
  246. package/dist/server/HttpListener.d.ts +1 -1
  247. package/dist/server/HttpListener.d.ts.map +1 -1
  248. package/dist/server/HttpListener.js.map +1 -1
  249. package/dist/server/MembersFunctionality.d.ts.map +1 -1
  250. package/dist/server/MembersFunctionality.js +4 -2
  251. package/dist/server/MembersFunctionality.js.map +1 -1
  252. package/dist/server/ModuleHost.d.ts +2 -1
  253. package/dist/server/ModuleHost.d.ts.map +1 -1
  254. package/dist/server/PlurnkSkill.js +4 -7
  255. package/dist/server/PlurnkSkill.js.map +1 -1
  256. package/dist/server/Rollback.js +1 -1
  257. package/dist/server/Rollback.js.map +1 -1
  258. package/dist/server/WorkerModelResolver.js +1 -0
  259. package/dist/server/WorkerModelResolver.js.map +1 -1
  260. package/dist/server/WorkerReferences.d.ts +14 -0
  261. package/dist/server/WorkerReferences.d.ts.map +1 -0
  262. package/dist/server/WorkerReferences.js +24 -0
  263. package/dist/server/WorkerReferences.js.map +1 -0
  264. package/dist/server/WorkerReferences.sql +31 -0
  265. package/dist/server/WorkspaceCapabilities.d.ts +2 -0
  266. package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
  267. package/dist/server/WorkspaceCapabilities.js +35 -18
  268. package/dist/server/WorkspaceCapabilities.js.map +1 -1
  269. package/dist/server/WorkspacePlugins.js +1 -0
  270. package/dist/server/WorkspacePlugins.js.map +1 -1
  271. package/dist/server/WorkspaceResidency.d.ts +3 -1
  272. package/dist/server/WorkspaceResidency.d.ts.map +1 -1
  273. package/dist/server/WorkspaceResidency.js +12 -5
  274. package/dist/server/WorkspaceResidency.js.map +1 -1
  275. package/dist/server/client-input.d.ts +2 -0
  276. package/dist/server/client-input.d.ts.map +1 -1
  277. package/dist/server/client-input.js +28 -0
  278. package/dist/server/client-input.js.map +1 -1
  279. package/dist/server/drain.sql +37 -40
  280. package/dist/server/envelope.d.ts +5 -9
  281. package/dist/server/envelope.d.ts.map +1 -1
  282. package/dist/server/envelope.js +21 -84
  283. package/dist/server/envelope.js.map +1 -1
  284. package/dist/server/envelope.sql +17 -17
  285. package/dist/server/lifecycle-recovery.sql +5 -15
  286. package/dist/server/logEntry.d.ts.map +1 -1
  287. package/dist/server/logEntry.js +6 -0
  288. package/dist/server/logEntry.js.map +1 -1
  289. package/dist/server/logEntry.sql +94 -6
  290. package/dist/server/module-discovery.d.ts +1 -1
  291. package/dist/server/module-discovery.d.ts.map +1 -1
  292. package/dist/server/module-discovery.js +1 -0
  293. package/dist/server/module-discovery.js.map +1 -1
  294. package/dist/server/seam-loop.sql +15 -7
  295. package/dist/server/seam-proposal-list.sql +10 -4
  296. package/dist/service.d.ts.map +1 -1
  297. package/dist/service.js +7 -1
  298. package/dist/service.js.map +1 -1
  299. package/docs/members.md +6 -4
  300. package/migrations/002_workers.sql +2 -2
  301. package/migrations/006_log.sql +1 -1
  302. package/migrations/018_worker_owners.sql +1 -1
  303. package/migrations/029_default_worker.sql +9 -0
  304. package/migrations/030_client_workers.sql +105 -0
  305. package/migrations/031_message_openers.sql +83 -0
  306. package/migrations/032_worker_references.sql +29 -0
  307. package/package.json +23 -22
  308. package/plurnk.nginx.conf +71 -0
  309. package/plurnk.service +2 -0
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import NativeContent from "./NativeContent.js";
3
2
  import { PlurnkParser, parsePath } from "@plurnk/plurnk-parser";
4
3
  import { PathSyntax, PlurnkParseError, UNKNOWN_POSITION } from "@plurnk/plurnk-contracts";
@@ -6,14 +5,16 @@ import WorkerOwners from "./WorkerOwners.js";
6
5
  import { setTimeout as delay } from "node:timers/promises";
7
6
  import { aggregateProviderAccounting } from "@plurnk/plurnk-providers";
8
7
  const comparePosition = (a, b) => a.line - b.line || a.column - b.column;
8
+ import { Mimetypes } from "@plurnk/plurnk-mimetypes";
9
9
  import FabricatedLog from "./FabricatedLog.js";
10
10
  import Meta, { Knob } from "@plurnk/plurnk-meta";
11
11
  import GitMembership from "./git-membership.js";
12
12
  import { acceptedKinds } from "./attachments.js";
13
- import GitState from "./git-state.js";
13
+ import GitState, {} from "./git-state.js";
14
14
  import WorkspaceSettings from "./workspace-settings.js";
15
15
  import { generatedPathname } from "./plurnk-uri.js";
16
16
  import { contentWeight } from "./content-weight.js";
17
+ import LiveSubscriptions from "./LiveSubscriptions.js";
17
18
  import { readFile } from "node:fs/promises";
18
19
  import { resolve as resolvePath } from "node:path";
19
20
  import { homedir } from "node:os";
@@ -29,9 +30,17 @@ export const resolveOperatorGrammarPath = (value) => {
29
30
  import PacketWire from "./packet-wire.js";
30
31
  import { RECEIPT_RESERVE, reserved } from "./ContextFit.js";
31
32
  import Results, { OperationFailureError } from "./results.js";
32
- import Turn from "./Turn.js";
33
+ import Turn, {} from "./Turn.js";
34
+ // TurnRunner owns one inference cycle and any initialization turn
35
+ // that precedes provider admission; Engine retains the surrounding loop
36
+ // lifecycle and public facade.
37
+ import NoticeChannel from "./NoticeChannel.js";
33
38
  import ProviderRecovery from "./ProviderRecovery.js";
34
- import StoredPacket from "./StoredPacket.js";
39
+ import ProblemLog from "./ProblemLog.js";
40
+ import StrikeRail, {} from "./StrikeRail.js";
41
+ import PacketBuilder, {} from "./PacketBuilder.js";
42
+ import StoredPacket, {} from "./StoredPacket.js";
43
+ import Dispatcher from "./Dispatcher.js";
35
44
  import { observed, observedSync } from "../observe/spans.js";
36
45
  import { genAiRequestName, genAiRequestOptions, settleGenAiResponse } from "../observe/genai.js";
37
46
  import { PROVIDER_CALLS, recordCounter } from "../observe/metrics.js";
@@ -88,7 +97,7 @@ import { ProviderError, scopeEnvToAlias } from "@plurnk/plurnk-providers";
88
97
  import ProviderInstantiate from "./ProviderInstantiate.js";
89
98
  import TurnMaterialization from "./TurnMaterialization.js";
90
99
  import BareBatchRunner from "./BareBatchRunner.js";
91
- import { TURN_STATUS_IMPLICIT_CONTINUE } from "./turn-signals.js";
100
+ import { ENGINE_PROBLEMS, TURN_STATUS_IMPLICIT_CONTINUE, outputAllowance } from "./turn-signals.js";
92
101
  import AdmittedTurnExecutor from "./AdmittedTurnExecutor.js";
93
102
  // {§context-wall} — the window's one terminal: the packet cannot fit the model's window even as receipts.
94
103
  const WINDOW_OVERFLOW_DETAIL = "Context window overflow: the packet cannot fit the model's window even as receipts.";
@@ -97,22 +106,25 @@ const windowOverflowFailure = (overflow) => Results.failure("engine:context", "w
97
106
  // {§context-over-budget-row} — the row is the mandate; the gauge is the one home for the numbers
98
107
  // ({§context-gauge}), which the row's own charge would otherwise put out of agreement.
99
108
  const OVER_BUDGET_DETAIL = "Context exceeds budget. YOU MUST ONLY KILL, MOVE or NOTE this turn.";
100
- // {§worker-initialization-entry} — the one NOTE that leads the initialization surveys, labelled as the
101
- // card's own first NOTE example is.
109
+ // {§worker-initialization-entry} — the two NOTEs that open and close the initialization surveys, labelled
110
+ // as the card's own first and last NOTE examples are.
102
111
  const INITIALIZATION_NOTE = {
103
- op: "NOTE", aside: "summary", metadata: null, target: null, lineMarker: null,
104
- body: "Surveyed tooling, documentation, extended context, and project root.", position: UNKNOWN_POSITION,
112
+ op: "NOTE", aside: "plan", metadata: null, target: null, lineMarker: null,
113
+ body: [
114
+ "1. Survey the tooling, documentation, extended context, and project root: what exists decides what can be done.",
115
+ "2. Read the Open Message and restate what it asks for and what will show it is done.",
116
+ "3. Do the work, saving all new plans, findings, and decisions in NOTEs for later turns.",
117
+ ].join("\n"),
118
+ position: UNKNOWN_POSITION,
119
+ };
120
+ const INITIALIZATION_NEXT_NOTE = {
121
+ op: "NOTE", aside: "next", metadata: null, target: null, lineMarker: null,
122
+ body: "Read and resolve the Open Message.", position: UNKNOWN_POSITION,
105
123
  };
106
- // {§continued-without-note} — said once, in the next packet, of a continuing turn that carried no NOTE.
107
- const CONTINUED_WITHOUT_NOTE = "The turn continued without a NOTE.";
108
- // Trial (#1073): a continuing turn that carried NOTEs and no other operation is told so under the same
109
- // per-turn rule; it is a notice, never a strike.
110
- const NOTED_WITHOUT_OPERATION = "The turn carried NOTEs and no other operation.";
111
124
  // {§notice-directive} — what each notice of the model's own output asks of it: MUST where the card says MUST
112
125
  // or the output was refused, SHOULD where a near-miss was accepted.
113
126
  const DIRECTIVE = Object.freeze({
114
- note: "YOU MUST record at least one NOTE along with other operations.",
115
- emission: "YOU MUST ONLY emit fenced operations; with the parameters, pattern, and terse aside on the fenced Operation line.",
127
+ emission: "YOU MUST ONLY emit fenced operation batches; with the parameters, pattern, and terse aside on the fenced operation line.",
116
128
  advisory: "YOU SHOULD write the canonical form.",
117
129
  output: "YOU SHOULD emit fewer or shorter operations per turn.",
118
130
  });
@@ -122,9 +134,9 @@ const INVALID_EMISSION_RECOVERY_MESSAGE = "Response rejected before dispatch; no
122
134
  // `length` finish is the engine's own allowance ending the emission, and it
123
135
  // outranks every other diagnosis (parser symptom, rails verdict) on every
124
136
  // path. Null means the emission was not cut by the allowance.
125
- const allowanceCutMessage = (finishReason, grant) => finishReason !== "length"
137
+ const outputCut = ({ split, response }, provider) => split.callMetadata.finishReason !== "length"
126
138
  ? null
127
- : `Emission truncated at the output allowance${grant === null ? "" : ` (${grant} tokens)`}`;
139
+ : { grant: response.capacity.responseMax ?? provider.outputBudget };
128
140
  const readEmissionAttempts = () => Knob.integer("PLURNK_SERVICE_EMISSION_ATTEMPTS", 1);
129
141
  // The wall's abort reason — runLoop branches a mid-turn teardown to the 504 terminal on it.
130
142
  export const LOOP_TIMEOUT_REASON = "loop_timeout";
@@ -141,11 +153,12 @@ const turnResult = ({ createdTurnIds, turnId }, status, facts = {}) => ({
141
153
  capacityHardStop: false,
142
154
  providerParked: false,
143
155
  emptyTurn: false,
156
+ outputCut: null,
144
157
  emissionAttempts: 0,
145
158
  emissionExhausted: false,
146
159
  ...facts,
147
160
  });
148
- class TurnRunner {
161
+ export default class TurnRunner {
149
162
  #db;
150
163
  #schemes;
151
164
  #mimetypes;
@@ -189,7 +202,7 @@ class TurnRunner {
189
202
  this.#dispatch = dispatch;
190
203
  this.#resolveWorkerProviderIdentity = resolveWorkerProviderIdentity;
191
204
  this.#materialization = new TurnMaterialization({ db: this.#db, weighContent: this.#weighContent, mimetypes: this.#mimetypes });
192
- this.#bareBatch = new BareBatchRunner({ db: this.#db, providerAttributions: this.#providerAttributions.bind(this), providerFailure: _a.#providerFailure });
205
+ this.#bareBatch = new BareBatchRunner({ db: this.#db, providerAttributions: this.#providerAttributions.bind(this), providerFailure: TurnRunner.#providerFailure });
193
206
  this.#admitted = new AdmittedTurnExecutor({ db: this.#db, schemes: this.#schemes, notices: this.#notices, problems: this.#problems, dispatcher: this.#dispatcher, bareBatch: this.#bareBatch });
194
207
  }
195
208
  async #recordInference(args) {
@@ -334,7 +347,7 @@ class TurnRunner {
334
347
  return await this.#settleAdmittedTurn(args, request, emission);
335
348
  }
336
349
  catch (cause) {
337
- const status = _a.#failureStatus(cause, turnSignal);
350
+ const status = TurnRunner.#failureStatus(cause, turnSignal);
338
351
  const completionFailures = [];
339
352
  for (const createdTurnId of createdTurnIds) {
340
353
  try {
@@ -503,10 +516,10 @@ class TurnRunner {
503
516
  await Turn.complete(this.#db, initializationTurn.id, 200);
504
517
  return;
505
518
  }
506
- // {§worker-initialization-entry} — the example turn keeps the NOTE contract the card teaches:
507
- // when the surveys run, one NOTE leads them.
519
+ // {§worker-initialization-entry} — the example turn shows the NOTE practice the card teaches:
520
+ // when the surveys run, one NOTE opens them and one closes them.
508
521
  const programStatements = admittedInitializationStatements.some((statement) => statement.op === "FIND")
509
- ? [INITIALIZATION_NOTE, ...admittedInitializationStatements]
522
+ ? [INITIALIZATION_NOTE, ...admittedInitializationStatements, INITIALIZATION_NEXT_NOTE]
510
523
  : admittedInitializationStatements;
511
524
  const program = TurnOps.renderInternal(programStatements);
512
525
  const admitted = PlurnkParser.parseStatements(program).items.flatMap((item) => item.kind === "statement" ? [item.statement] : []);
@@ -1013,12 +1026,12 @@ class TurnRunner {
1013
1026
  attempts.turnWireAccounting.push(...completedResponse.accounting);
1014
1027
  await modelCall.observeResponse(completedResponse, null, attempts.wire.nativeInputs);
1015
1028
  attempts.railEvidence = attempts.railGrammar === undefined ? undefined : completedResponse.grammarEvidence;
1016
- const split = this.#splitResponse(completedResponse, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed, this.#executors()?.jsonBodyRuntimes(workspaceId) ?? []);
1029
+ const split = this.#splitResponse(completedResponse, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed);
1017
1030
  attempts.split = split;
1018
1031
  await this.#classifyProviderAttempt(attempts, attemptRow.id, split, attempt, split.emissionValid);
1019
1032
  return split.emissionValid ? "admitted" : "rejected";
1020
1033
  }
1021
- // {§notifications-reasoning-event} — only the parent emission is conversational;
1034
+ // {§notifications-reasoning-event} — only the parent emission is observed;
1022
1035
  // BARE has no observer on its isolated calls. Reasoning deltas cite the physical
1023
1036
  // request they stream in; a new request or the call's end closes the open span.
1024
1037
  #reasoningObserver({ workspaceId, workerId, loopId }, turnId, modelCall) {
@@ -1121,12 +1134,12 @@ class TurnRunner {
1121
1134
  throw error;
1122
1135
  }
1123
1136
  attempts.recoveryFailures += 1;
1124
- const failure = _a.#providerFailure(error, attempts.signal);
1137
+ const failure = TurnRunner.#providerFailure(error, attempts.signal);
1125
1138
  if (error.attempt !== undefined) {
1126
1139
  // {§provider-interrupted-attempt} — the interrupted response stays durable
1127
1140
  // as an unaccepted attempt; it is never admitted or replayed.
1128
1141
  await modelCall.observeResponse(error.attempt, failure, attempts.wire.nativeInputs);
1129
- await this.#classifyProviderAttempt(attempts, attemptId, this.#splitResponse(error.attempt, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed, this.#executors()?.jsonBodyRuntimes(workspaceId) ?? []), attempts.currentEmissionAttempt, false);
1142
+ await this.#classifyProviderAttempt(attempts, attemptId, this.#splitResponse(error.attempt, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed), attempts.currentEmissionAttempt, false);
1130
1143
  }
1131
1144
  else {
1132
1145
  await modelCall.fail(failure, error.capacity ?? null);
@@ -1181,7 +1194,7 @@ class TurnRunner {
1181
1194
  }
1182
1195
  const { provider, workspaceId, workerId, loopId } = args;
1183
1196
  const { turnId } = request;
1184
- const failure = _a.#providerFailure(err, attempts.signal);
1197
+ const failure = TurnRunner.#providerFailure(err, attempts.signal);
1185
1198
  const capacityFailure = err instanceof ProviderError && err.kind === "capacity_exceeded";
1186
1199
  // {§provider-interrupted-attempt} — a provider-declared interruption
1187
1200
  // carries response evidence without becoming a completed exchange.
@@ -1189,7 +1202,7 @@ class TurnRunner {
1189
1202
  if (err instanceof ProviderError && err.attempt !== undefined) {
1190
1203
  attempts.response = err.attempt;
1191
1204
  await attempts.modelCall.observeResponse(err.attempt, failure, attempts.wire.nativeInputs);
1192
- attempts.split = this.#splitResponse(err.attempt, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed, this.#executors()?.jsonBodyRuntimes(workspaceId) ?? []);
1205
+ attempts.split = this.#splitResponse(err.attempt, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed);
1193
1206
  await this.#classifyProviderAttempt(attempts, attempts.attemptId, attempts.split, attempts.currentEmissionAttempt, false);
1194
1207
  }
1195
1208
  else {
@@ -1282,14 +1295,14 @@ class TurnRunner {
1282
1295
  // {§invalid-emission-attempts} — the informed turn carries the parser's own
1283
1296
  // diagnostic and position: the model sees WHY, not only that it was refused.
1284
1297
  const diagnostic = split.parseErrors[0];
1285
- const cut = allowanceCutMessage(split.callMetadata.finishReason, response.capacity.responseMax ?? provider.outputBudget);
1298
+ const cut = outputCut(emission, provider);
1286
1299
  if (cut !== null) {
1287
1300
  this.#notices.push(workspaceId, workerId, loopId, {
1288
1301
  source: "engine:capacity",
1289
1302
  kind: "output_truncated",
1290
1303
  level: "error",
1291
1304
  directive: DIRECTIVE.output,
1292
- message: `${cut}; no operations were performed.`,
1305
+ message: `Emission truncated at ${outputAllowance(cut)}; no operations were performed.`,
1293
1306
  });
1294
1307
  }
1295
1308
  else {
@@ -1311,6 +1324,7 @@ class TurnRunner {
1311
1324
  return turnResult(request, TURN_STATUS_IMPLICIT_CONTINUE, {
1312
1325
  outcomes: [{ op: null, status: 500, problemType: "https://problems.plurnk.xyz/engine/invalid-emission-exhausted" }],
1313
1326
  fingerprint: `frame-contract-violation:${turnId}`,
1327
+ outputCut: cut,
1314
1328
  emissionAttempts: emission.emissionAttempts,
1315
1329
  emissionExhausted: true,
1316
1330
  rejectedModelEntryId,
@@ -1325,16 +1339,16 @@ class TurnRunner {
1325
1339
  for (const notice of parseNotices) {
1326
1340
  this.#notices.push(workspaceId, workerId, loopId, notice);
1327
1341
  }
1328
- const allowanceCut = allowanceCutMessage(callMetadata.finishReason, response.capacity.responseMax ?? provider.outputBudget);
1342
+ const cut = outputCut(emission, provider);
1329
1343
  // {§empty-turn} — a response cut at the output allowance with nothing admitted names the
1330
1344
  // cut, so the model reads the ceiling, never a parser symptom (#478).
1331
- if (split.emptyTurn && allowanceCut !== null) {
1345
+ if (split.emptyTurn && cut !== null) {
1332
1346
  this.#notices.push(workspaceId, workerId, loopId, {
1333
1347
  source: "engine:turn",
1334
1348
  kind: "output_truncated",
1335
1349
  level: "warn",
1336
1350
  directive: DIRECTIVE.output,
1337
- message: `${allowanceCut}; no authored operations were performed.`,
1351
+ message: `Emission truncated at ${outputAllowance(cut)}; no authored operations were performed.`,
1338
1352
  });
1339
1353
  }
1340
1354
  // Non-fatal provider transport notices on an accepted turn. Forward each
@@ -1356,12 +1370,12 @@ class TurnRunner {
1356
1370
  : {}),
1357
1371
  });
1358
1372
  }
1359
- if (allowanceCut !== null) {
1373
+ if (cut !== null) {
1360
1374
  this.#notices.push(workspaceId, workerId, loopId, {
1361
1375
  source: "engine:capacity",
1362
1376
  kind: "output_truncated",
1363
1377
  directive: DIRECTIVE.output,
1364
- message: `${allowanceCut}.`,
1378
+ message: `Emission truncated at ${outputAllowance(cut)}.`,
1365
1379
  level: "warn",
1366
1380
  });
1367
1381
  }
@@ -1402,7 +1416,7 @@ class TurnRunner {
1402
1416
  // Phase 6 — the admitted program runs under the workspace's command ceiling and
1403
1417
  // the turn settles on the executor's verdict.
1404
1418
  async #settleAdmittedTurn(args, request, emission) {
1405
- const { childProvider, workspaceId, workerId, loopId, onDispatch, onSettled } = args;
1419
+ const { provider, childProvider, workspaceId, workerId, loopId, onDispatch, onSettled } = args;
1406
1420
  const { split } = emission;
1407
1421
  const coordinates = { workerName: request.workerName, loopSeq: request.loopSeq, turnSeq: request.seq };
1408
1422
  // {§operator-config-workspace-max-commands} — workspace maxCommands
@@ -1414,6 +1428,7 @@ class TurnRunner {
1414
1428
  source: split.sourceBacked ? split.packetAssistant.content : null,
1415
1429
  emission: split.emissionStatements === null ? null : {
1416
1430
  content: TurnOps.renderEmission(split.emissionStatements),
1431
+ statements: split.emissionStatements,
1417
1432
  ...coordinates,
1418
1433
  },
1419
1434
  reasoning: split.packetAssistant.reasoning ? { content: split.packetAssistant.reasoning, ...coordinates } : null,
@@ -1439,27 +1454,12 @@ class TurnRunner {
1439
1454
  onDispatch,
1440
1455
  onSettled,
1441
1456
  });
1442
- // {§continued-without-note} — a turn the loop continues past or parks on, having carried no NOTE
1443
- // forward in its program or from its reasoning, is told so in the next packet. An empty turn has
1444
- // its own no-operation row instead.
1445
- const ops = split.packetAssistant.ops;
1446
- if ((executed.status === 102 || executed.status === 202) && ops.length > 0
1447
- && !ops.some((statement) => "op" in statement && statement.op === "NOTE")) {
1448
- this.#notices.push(workspaceId, workerId, loopId, {
1449
- source: "engine:turn", kind: "continued_without_note", level: "warn", directive: DIRECTIVE.note, message: CONTINUED_WITHOUT_NOTE,
1450
- });
1451
- }
1452
- const annotationOnly = ops.length > 0 && ops.every((statement) => "op" in statement && statement.op === "NOTE");
1453
- if ((executed.status === 102 || executed.status === 202) && annotationOnly) {
1454
- this.#notices.push(workspaceId, workerId, loopId, {
1455
- source: "engine:turn", kind: "noted_without_operation", level: "warn", directive: DIRECTIVE.note, message: NOTED_WITHOUT_OPERATION,
1456
- });
1457
- }
1458
1457
  return turnResult(request, executed.status, {
1459
1458
  outcomes: executed.outcomes,
1460
1459
  progressed: executed.progressed,
1461
1460
  fingerprint: executed.fingerprint,
1462
1461
  emptyTurn: executed.emptyTurn,
1462
+ outputCut: outputCut(emission, provider),
1463
1463
  emissionAttempts: emission.emissionAttempts,
1464
1464
  });
1465
1465
  }
@@ -1510,7 +1510,7 @@ class TurnRunner {
1510
1510
  return true;
1511
1511
  };
1512
1512
  }
1513
- #splitResponse(response, executors = [], wellFormed, jsonBodyExecutors = []) {
1513
+ #splitResponse(response, executors = [], wellFormed) {
1514
1514
  const { assistant } = response;
1515
1515
  const preParsedOps = assistant.ops;
1516
1516
  const ops = [];
@@ -1529,9 +1529,9 @@ class TurnRunner {
1529
1529
  // {§observability-boundary} — the parse is observed without its input;
1530
1530
  // only the resulting statement count is attributable.
1531
1531
  const parsed = observedSync("contracts.parse", {}, (span) => {
1532
- // {§fence-heading-in-body} {§interstitial-fence} — the executors this workspace can run
1533
- // are heading tags to the parser; anything else tagged is a code block.
1534
- const result = PlurnkParser.parse(assistant.content, { executors, jsonBodyExecutors, ...(wellFormed === undefined ? {} : { wellFormed }) });
1532
+ // {§executor-heading}: explicit invocations parse without registration; available names
1533
+ // also admit slotless headings. Dispatch resolves the then-current workspace registry.
1534
+ const result = PlurnkParser.parse(assistant.content, { executors, ...(wellFormed === undefined ? {} : { wellFormed }) });
1535
1535
  span.setAttribute("statements", result.items.filter((item) => item.kind === "statement").length);
1536
1536
  return result;
1537
1537
  });
@@ -1595,7 +1595,9 @@ class TurnRunner {
1595
1595
  });
1596
1596
  }
1597
1597
  else {
1598
- parseErrors.push({ message: err.message, line: err.line, column: err.column, source: err.source, ...(err.recovery === undefined ? {} : { recovery: err.recovery }) });
1598
+ parseErrors.push({ message: err.message, line: err.line, column: err.column, source: err.source,
1599
+ ...(err.recovery === undefined ? {} : { recovery: err.recovery }),
1600
+ ...(item.attempt === undefined ? {} : { attempt: item.attempt }) });
1599
1601
  }
1600
1602
  }
1601
1603
  else {
@@ -1678,6 +1680,4 @@ class TurnRunner {
1678
1680
  return this.#admitted.executeAdmittedTurn(...args);
1679
1681
  }
1680
1682
  }
1681
- _a = TurnRunner;
1682
- export default TurnRunner;
1683
1683
  //# sourceMappingURL=TurnRunner.js.map