@plurnk/plurnk-service 3.2.0 → 4.0.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 (328) hide show
  1. package/.env.defaults +3 -3
  2. package/INSTALL.md +6 -0
  3. package/README.md +2 -2
  4. package/SPEC.md +489 -186
  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.map +1 -1
  16. package/dist/core/AdmittedTurnExecutor.js +8 -0
  17. package/dist/core/AdmittedTurnExecutor.js.map +1 -1
  18. package/dist/core/BareBatchRunner.js +2 -1
  19. package/dist/core/BareBatchRunner.js.map +1 -1
  20. package/dist/core/BudgetReadout.d.ts +1 -3
  21. package/dist/core/BudgetReadout.d.ts.map +1 -1
  22. package/dist/core/BudgetReadout.js +43 -46
  23. package/dist/core/BudgetReadout.js.map +1 -1
  24. package/dist/core/ChannelWrite.d.ts +10 -0
  25. package/dist/core/ChannelWrite.d.ts.map +1 -1
  26. package/dist/core/ChannelWrite.js +10 -0
  27. package/dist/core/ChannelWrite.js.map +1 -1
  28. package/dist/core/ChannelWrite.sql +14 -2
  29. package/dist/core/ClientInteractions.d.ts.map +1 -1
  30. package/dist/core/ClientInteractions.js +2 -1
  31. package/dist/core/ClientInteractions.js.map +1 -1
  32. package/dist/core/CoreSchemeServices.d.ts.map +1 -1
  33. package/dist/core/CoreSchemeServices.js +6 -0
  34. package/dist/core/CoreSchemeServices.js.map +1 -1
  35. package/dist/core/DataStatementRunner.js +4 -6
  36. package/dist/core/DataStatementRunner.js.map +1 -1
  37. package/dist/core/Dispatcher.d.ts +3 -7
  38. package/dist/core/Dispatcher.d.ts.map +1 -1
  39. package/dist/core/Dispatcher.js +53 -73
  40. package/dist/core/Dispatcher.js.map +1 -1
  41. package/dist/core/Dispatcher.sql +2 -2
  42. package/dist/core/EditMutations.js +1 -0
  43. package/dist/core/EditMutations.js.map +1 -1
  44. package/dist/core/Engine.d.ts +8 -14
  45. package/dist/core/Engine.d.ts.map +1 -1
  46. package/dist/core/Engine.js +22 -24
  47. package/dist/core/Engine.js.map +1 -1
  48. package/dist/core/Engine.sql +6 -6
  49. package/dist/core/ExecutorRegistry.d.ts +0 -5
  50. package/dist/core/ExecutorRegistry.d.ts.map +1 -1
  51. package/dist/core/ExecutorRegistry.js +10 -18
  52. package/dist/core/ExecutorRegistry.js.map +1 -1
  53. package/dist/core/FileAddress.js +1 -1
  54. package/dist/core/FileAddress.js.map +1 -1
  55. package/dist/core/FilePublication.js +10 -74
  56. package/dist/core/FilePublication.js.map +1 -1
  57. package/dist/core/FileSnapshot.js +36 -100
  58. package/dist/core/FileSnapshot.js.map +1 -1
  59. package/dist/core/HostPaths.d.ts +1 -0
  60. package/dist/core/HostPaths.d.ts.map +1 -1
  61. package/dist/core/HostPaths.js +11 -1
  62. package/dist/core/HostPaths.js.map +1 -1
  63. package/dist/core/KillHandler.js +3 -1
  64. package/dist/core/KillHandler.js.map +1 -1
  65. package/dist/core/LiveSubscription.js +1 -1
  66. package/dist/core/LiveSubscription.js.map +1 -1
  67. package/dist/core/LogBody.js +1 -1
  68. package/dist/core/LogBody.js.map +1 -1
  69. package/dist/core/LogWriter.js +1 -1
  70. package/dist/core/LogWriter.js.map +1 -1
  71. package/dist/core/LoopDriver.d.ts +3 -3
  72. package/dist/core/LoopDriver.d.ts.map +1 -1
  73. package/dist/core/LoopDriver.js +15 -13
  74. package/dist/core/LoopDriver.js.map +1 -1
  75. package/dist/core/LoopLifecycle.d.ts +5 -0
  76. package/dist/core/LoopLifecycle.d.ts.map +1 -1
  77. package/dist/core/LoopLifecycle.js +14 -1
  78. package/dist/core/LoopLifecycle.js.map +1 -1
  79. package/dist/core/LoopLifecycle.sql +11 -2
  80. package/dist/core/MembershipMaterialization.js +2 -2
  81. package/dist/core/MembershipMaterialization.js.map +1 -1
  82. package/dist/core/MessageResources.d.ts +3 -0
  83. package/dist/core/MessageResources.d.ts.map +1 -1
  84. package/dist/core/MessageResources.js +15 -1
  85. package/dist/core/MessageResources.js.map +1 -1
  86. package/dist/core/OperatorConfig.d.ts +1 -2
  87. package/dist/core/OperatorConfig.d.ts.map +1 -1
  88. package/dist/core/OperatorConfig.js +26 -92
  89. package/dist/core/OperatorConfig.js.map +1 -1
  90. package/dist/core/PacketBuilder.d.ts.map +1 -1
  91. package/dist/core/PacketBuilder.js +21 -18
  92. package/dist/core/PacketBuilder.js.map +1 -1
  93. package/dist/core/PacketBuilder.sql +18 -5
  94. package/dist/core/ProblemLog.d.ts +1 -0
  95. package/dist/core/ProblemLog.d.ts.map +1 -1
  96. package/dist/core/ProblemLog.js +2 -2
  97. package/dist/core/ProblemLog.js.map +1 -1
  98. package/dist/core/ProposalLifecycle.d.ts +1 -0
  99. package/dist/core/ProposalLifecycle.d.ts.map +1 -1
  100. package/dist/core/ProposalLifecycle.js +14 -8
  101. package/dist/core/ProposalLifecycle.js.map +1 -1
  102. package/dist/core/ProposalPolicies.d.ts +4 -1
  103. package/dist/core/ProposalPolicies.d.ts.map +1 -1
  104. package/dist/core/ProposalPolicies.js +5 -2
  105. package/dist/core/ProposalPolicies.js.map +1 -1
  106. package/dist/core/ResourceMutations.js +2 -0
  107. package/dist/core/ResourceMutations.js.map +1 -1
  108. package/dist/core/ResourceSelector.js +1 -1
  109. package/dist/core/ResourceSelector.js.map +1 -1
  110. package/dist/core/SchemeRegistry.js +1 -1
  111. package/dist/core/SchemeRegistry.js.map +1 -1
  112. package/dist/core/ServiceHelp.js +1 -1
  113. package/dist/core/ServiceHelp.js.map +1 -1
  114. package/dist/core/ServiceTeardown.js +9 -12
  115. package/dist/core/ServiceTeardown.js.map +1 -1
  116. package/dist/core/StrikeRail.d.ts +2 -1
  117. package/dist/core/StrikeRail.d.ts.map +1 -1
  118. package/dist/core/StrikeRail.js +11 -6
  119. package/dist/core/StrikeRail.js.map +1 -1
  120. package/dist/core/TerminalResult.js +1 -1
  121. package/dist/core/TerminalResult.js.map +1 -1
  122. package/dist/core/TurnDispositionHandler.d.ts +1 -1
  123. package/dist/core/TurnDispositionHandler.d.ts.map +1 -1
  124. package/dist/core/TurnDispositionHandler.js +8 -5
  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.js +1 -0
  130. package/dist/core/TurnOps.js.map +1 -1
  131. package/dist/core/TurnRunner.d.ts +4 -2
  132. package/dist/core/TurnRunner.d.ts.map +1 -1
  133. package/dist/core/TurnRunner.js +63 -51
  134. package/dist/core/TurnRunner.js.map +1 -1
  135. package/dist/core/WorkerControlHandler.d.ts +2 -0
  136. package/dist/core/WorkerControlHandler.d.ts.map +1 -1
  137. package/dist/core/WorkerControlHandler.js +84 -16
  138. package/dist/core/WorkerControlHandler.js.map +1 -1
  139. package/dist/core/WorkerName.d.ts +0 -4
  140. package/dist/core/WorkerName.d.ts.map +1 -1
  141. package/dist/core/WorkerName.js +5 -30
  142. package/dist/core/WorkerName.js.map +1 -1
  143. package/dist/core/WorkerName.sql +4 -20
  144. package/dist/core/WorkerOwners.d.ts +1 -0
  145. package/dist/core/WorkerOwners.d.ts.map +1 -1
  146. package/dist/core/WorkerOwners.js +6 -0
  147. package/dist/core/WorkerOwners.js.map +1 -1
  148. package/dist/core/WorkerOwners.sql +7 -0
  149. package/dist/core/WorkspaceGate.d.ts +3 -1
  150. package/dist/core/WorkspaceGate.d.ts.map +1 -1
  151. package/dist/core/WorkspaceGate.js +59 -10
  152. package/dist/core/WorkspaceGate.js.map +1 -1
  153. package/dist/core/caps/SchemeCtxImpl.d.ts +3 -0
  154. package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
  155. package/dist/core/caps/SchemeCtxImpl.js +14 -0
  156. package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
  157. package/dist/core/env-catalog.js +1 -1
  158. package/dist/core/env-catalog.js.map +1 -1
  159. package/dist/core/fork.js +1 -1
  160. package/dist/core/fork.js.map +1 -1
  161. package/dist/core/fork.sql +7 -6
  162. package/dist/core/mutation-types.d.ts +1 -0
  163. package/dist/core/mutation-types.d.ts.map +1 -1
  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 +1 -1
  169. package/dist/core/packet-wire.d.ts.map +1 -1
  170. package/dist/core/packet-wire.js +24 -15
  171. package/dist/core/packet-wire.js.map +1 -1
  172. package/dist/core/plurnk-uri.d.ts +1 -1
  173. package/dist/core/plurnk-uri.d.ts.map +1 -1
  174. package/dist/core/plurnk-uri.js +1 -1
  175. package/dist/core/plurnk-uri.js.map +1 -1
  176. package/dist/core/scheme-types.d.ts +5 -0
  177. package/dist/core/scheme-types.d.ts.map +1 -1
  178. package/dist/core/turn-signals.d.ts +4 -0
  179. package/dist/core/turn-signals.d.ts.map +1 -1
  180. package/dist/core/turn-signals.js +1 -0
  181. package/dist/core/turn-signals.js.map +1 -1
  182. package/dist/core/workspace-settings.js +1 -1
  183. package/dist/core/workspace-settings.js.map +1 -1
  184. package/dist/evidence/EvidenceReader.js +5 -5
  185. package/dist/evidence/EvidenceReader.js.map +1 -1
  186. package/dist/man/plurnk-service.1 +27 -6
  187. package/dist/schemes/Env.d.ts +7 -3
  188. package/dist/schemes/Env.d.ts.map +1 -1
  189. package/dist/schemes/Env.js +12 -6
  190. package/dist/schemes/Env.js.map +1 -1
  191. package/dist/schemes/Exec.d.ts.map +1 -1
  192. package/dist/schemes/Exec.js +37 -25
  193. package/dist/schemes/Exec.js.map +1 -1
  194. package/dist/schemes/ExecOutputScheme.js +3 -3
  195. package/dist/schemes/ExecOutputScheme.js.map +1 -1
  196. package/dist/schemes/ExecutionInput.d.ts +2 -1
  197. package/dist/schemes/ExecutionInput.d.ts.map +1 -1
  198. package/dist/schemes/ExecutionInput.js +45 -7
  199. package/dist/schemes/ExecutionInput.js.map +1 -1
  200. package/dist/schemes/File.d.ts.map +1 -1
  201. package/dist/schemes/File.js +32 -23
  202. package/dist/schemes/File.js.map +1 -1
  203. package/dist/schemes/Log.d.ts.map +1 -1
  204. package/dist/schemes/Log.js +23 -5
  205. package/dist/schemes/Log.js.map +1 -1
  206. package/dist/schemes/Log.sql +24 -1
  207. package/dist/schemes/ResourceTreeScheme.js +2 -5
  208. package/dist/schemes/ResourceTreeScheme.js.map +1 -1
  209. package/dist/schemes/TurnSource.js +1 -1
  210. package/dist/schemes/TurnSource.js.map +1 -1
  211. package/dist/schemes/Worker.d.ts.map +1 -1
  212. package/dist/schemes/Worker.js +10 -3
  213. package/dist/schemes/Worker.js.map +1 -1
  214. package/dist/schemes/_entry-crud.d.ts.map +1 -1
  215. package/dist/schemes/_entry-crud.js +2 -4
  216. package/dist/schemes/_entry-crud.js.map +1 -1
  217. package/dist/schemes/_entry-crud.sql +5 -3
  218. package/dist/schemes/_entry-find.js +3 -3
  219. package/dist/schemes/_entry-find.js.map +1 -1
  220. package/dist/schemes/_entry-manifest.d.ts.map +1 -1
  221. package/dist/schemes/_entry-manifest.js +3 -3
  222. package/dist/schemes/_entry-manifest.js.map +1 -1
  223. package/dist/schemes/_entry-manifest.sql +2 -0
  224. package/dist/schemes/_entry-ops.js +1 -1
  225. package/dist/schemes/_entry-ops.js.map +1 -1
  226. package/dist/schemes/_entry-send.js +1 -1
  227. package/dist/schemes/_entry-send.js.map +1 -1
  228. package/dist/server/ClientReads.d.ts +1 -0
  229. package/dist/server/ClientReads.d.ts.map +1 -1
  230. package/dist/server/ClientReads.js +7 -2
  231. package/dist/server/ClientReads.js.map +1 -1
  232. package/dist/server/Credentials.d.ts +48 -0
  233. package/dist/server/Credentials.d.ts.map +1 -0
  234. package/dist/server/Credentials.js +203 -0
  235. package/dist/server/Credentials.js.map +1 -0
  236. package/dist/server/Daemon.d.ts +44 -39
  237. package/dist/server/Daemon.d.ts.map +1 -1
  238. package/dist/server/Daemon.js +287 -172
  239. package/dist/server/Daemon.js.map +1 -1
  240. package/dist/server/DrainSupervisor.d.ts +8 -3
  241. package/dist/server/DrainSupervisor.d.ts.map +1 -1
  242. package/dist/server/DrainSupervisor.js +44 -32
  243. package/dist/server/DrainSupervisor.js.map +1 -1
  244. package/dist/server/EnvFunctionality.d.ts.map +1 -1
  245. package/dist/server/EnvFunctionality.js +2 -1
  246. package/dist/server/EnvFunctionality.js.map +1 -1
  247. package/dist/server/Functionality.d.ts +4 -2
  248. package/dist/server/Functionality.d.ts.map +1 -1
  249. package/dist/server/Functionality.js +192 -96
  250. package/dist/server/Functionality.js.map +1 -1
  251. package/dist/server/FunctionalityManager.d.ts +1 -4
  252. package/dist/server/FunctionalityManager.d.ts.map +1 -1
  253. package/dist/server/FunctionalityManager.js +6 -6
  254. package/dist/server/FunctionalityManager.js.map +1 -1
  255. package/dist/server/HttpListener.d.ts +1 -1
  256. package/dist/server/HttpListener.d.ts.map +1 -1
  257. package/dist/server/HttpListener.js.map +1 -1
  258. package/dist/server/MembersFunctionality.d.ts +7 -8
  259. package/dist/server/MembersFunctionality.d.ts.map +1 -1
  260. package/dist/server/MembersFunctionality.js +90 -56
  261. package/dist/server/MembersFunctionality.js.map +1 -1
  262. package/dist/server/MessageAbandonment.d.ts +7 -0
  263. package/dist/server/MessageAbandonment.d.ts.map +1 -0
  264. package/dist/server/MessageAbandonment.js +57 -0
  265. package/dist/server/MessageAbandonment.js.map +1 -0
  266. package/dist/server/ModuleHost.d.ts +2 -1
  267. package/dist/server/ModuleHost.d.ts.map +1 -1
  268. package/dist/server/PlurnkSkill.js +4 -7
  269. package/dist/server/PlurnkSkill.js.map +1 -1
  270. package/dist/server/Rollback.d.ts +29 -0
  271. package/dist/server/Rollback.d.ts.map +1 -0
  272. package/dist/server/Rollback.js +111 -0
  273. package/dist/server/Rollback.js.map +1 -0
  274. package/dist/server/WorkerModelResolver.js +1 -0
  275. package/dist/server/WorkerModelResolver.js.map +1 -1
  276. package/dist/server/WorkerReferences.d.ts +14 -0
  277. package/dist/server/WorkerReferences.d.ts.map +1 -0
  278. package/dist/server/WorkerReferences.js +24 -0
  279. package/dist/server/WorkerReferences.js.map +1 -0
  280. package/dist/server/WorkerReferences.sql +31 -0
  281. package/dist/server/WorkspaceCapabilities.d.ts +2 -0
  282. package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
  283. package/dist/server/WorkspaceCapabilities.js +35 -18
  284. package/dist/server/WorkspaceCapabilities.js.map +1 -1
  285. package/dist/server/WorkspacePlugins.js +1 -0
  286. package/dist/server/WorkspacePlugins.js.map +1 -1
  287. package/dist/server/WorkspaceResidency.d.ts +3 -1
  288. package/dist/server/WorkspaceResidency.d.ts.map +1 -1
  289. package/dist/server/WorkspaceResidency.js +12 -5
  290. package/dist/server/WorkspaceResidency.js.map +1 -1
  291. package/dist/server/client-input.d.ts +2 -0
  292. package/dist/server/client-input.d.ts.map +1 -1
  293. package/dist/server/client-input.js +28 -0
  294. package/dist/server/client-input.js.map +1 -1
  295. package/dist/server/drain.sql +46 -40
  296. package/dist/server/envelope.d.ts +5 -9
  297. package/dist/server/envelope.d.ts.map +1 -1
  298. package/dist/server/envelope.js +21 -84
  299. package/dist/server/envelope.js.map +1 -1
  300. package/dist/server/envelope.sql +17 -17
  301. package/dist/server/lifecycle-recovery.sql +5 -15
  302. package/dist/server/logEntry.d.ts.map +1 -1
  303. package/dist/server/logEntry.js +6 -0
  304. package/dist/server/logEntry.js.map +1 -1
  305. package/dist/server/logEntry.sql +94 -6
  306. package/dist/server/module-discovery.d.ts +1 -1
  307. package/dist/server/module-discovery.d.ts.map +1 -1
  308. package/dist/server/module-discovery.js +1 -0
  309. package/dist/server/module-discovery.js.map +1 -1
  310. package/dist/server/seam-loop.sql +15 -7
  311. package/dist/server/seam-proposal-list.sql +10 -4
  312. package/dist/service.d.ts.map +1 -1
  313. package/dist/service.js +7 -1
  314. package/dist/service.js.map +1 -1
  315. package/docs/members.md +20 -13
  316. package/migrations/002_workers.sql +2 -2
  317. package/migrations/006_log.sql +1 -1
  318. package/migrations/018_worker_owners.sql +1 -1
  319. package/migrations/026_message_obligations.sql +32 -0
  320. package/migrations/027_members_identity.sql +20 -0
  321. package/migrations/028_mutation_patch.sql +20 -0
  322. package/migrations/029_default_worker.sql +9 -0
  323. package/migrations/030_client_workers.sql +105 -0
  324. package/migrations/031_message_openers.sql +83 -0
  325. package/migrations/032_worker_references.sql +29 -0
  326. package/package.json +24 -24
  327. package/plurnk.nginx.conf +71 -0
  328. 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,28 @@ 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, recording each finding, decision, and next action in a NOTE as it happens.",
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
124
  // {§continued-without-note} — said once, in the next packet, of a continuing turn that carried no NOTE.
107
125
  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
126
  // {§notice-directive} — what each notice of the model's own output asks of it: MUST where the card says MUST
112
127
  // or the output was refused, SHOULD where a near-miss was accepted.
113
128
  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.",
129
+ note: "YOU MUST emit at least one NOTE in every turn.",
130
+ emission: "YOU MUST ONLY emit fenced operations; with the parameters, pattern, and terse aside on the fenced operation line.",
116
131
  advisory: "YOU SHOULD write the canonical form.",
117
132
  output: "YOU SHOULD emit fewer or shorter operations per turn.",
118
133
  });
@@ -122,9 +137,9 @@ const INVALID_EMISSION_RECOVERY_MESSAGE = "Response rejected before dispatch; no
122
137
  // `length` finish is the engine's own allowance ending the emission, and it
123
138
  // outranks every other diagnosis (parser symptom, rails verdict) on every
124
139
  // path. Null means the emission was not cut by the allowance.
125
- const allowanceCutMessage = (finishReason, grant) => finishReason !== "length"
140
+ const outputCut = ({ split, response }, provider) => split.callMetadata.finishReason !== "length"
126
141
  ? null
127
- : `Emission truncated at the output allowance${grant === null ? "" : ` (${grant} tokens)`}`;
142
+ : { grant: response.capacity.responseMax ?? provider.outputBudget };
128
143
  const readEmissionAttempts = () => Knob.integer("PLURNK_SERVICE_EMISSION_ATTEMPTS", 1);
129
144
  // The wall's abort reason — runLoop branches a mid-turn teardown to the 504 terminal on it.
130
145
  export const LOOP_TIMEOUT_REASON = "loop_timeout";
@@ -141,11 +156,12 @@ const turnResult = ({ createdTurnIds, turnId }, status, facts = {}) => ({
141
156
  capacityHardStop: false,
142
157
  providerParked: false,
143
158
  emptyTurn: false,
159
+ outputCut: null,
144
160
  emissionAttempts: 0,
145
161
  emissionExhausted: false,
146
162
  ...facts,
147
163
  });
148
- class TurnRunner {
164
+ export default class TurnRunner {
149
165
  #db;
150
166
  #schemes;
151
167
  #mimetypes;
@@ -189,7 +205,7 @@ class TurnRunner {
189
205
  this.#dispatch = dispatch;
190
206
  this.#resolveWorkerProviderIdentity = resolveWorkerProviderIdentity;
191
207
  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 });
208
+ this.#bareBatch = new BareBatchRunner({ db: this.#db, providerAttributions: this.#providerAttributions.bind(this), providerFailure: TurnRunner.#providerFailure });
193
209
  this.#admitted = new AdmittedTurnExecutor({ db: this.#db, schemes: this.#schemes, notices: this.#notices, problems: this.#problems, dispatcher: this.#dispatcher, bareBatch: this.#bareBatch });
194
210
  }
195
211
  async #recordInference(args) {
@@ -334,7 +350,7 @@ class TurnRunner {
334
350
  return await this.#settleAdmittedTurn(args, request, emission);
335
351
  }
336
352
  catch (cause) {
337
- const status = _a.#failureStatus(cause, turnSignal);
353
+ const status = TurnRunner.#failureStatus(cause, turnSignal);
338
354
  const completionFailures = [];
339
355
  for (const createdTurnId of createdTurnIds) {
340
356
  try {
@@ -503,10 +519,10 @@ class TurnRunner {
503
519
  await Turn.complete(this.#db, initializationTurn.id, 200);
504
520
  return;
505
521
  }
506
- // {§worker-initialization-entry} — the example turn keeps the NOTE contract the card teaches:
507
- // when the surveys run, one NOTE leads them.
522
+ // {§worker-initialization-entry} — the example turn shows the NOTE practice the card teaches:
523
+ // when the surveys run, one NOTE opens them and one closes them.
508
524
  const programStatements = admittedInitializationStatements.some((statement) => statement.op === "FIND")
509
- ? [INITIALIZATION_NOTE, ...admittedInitializationStatements]
525
+ ? [INITIALIZATION_NOTE, ...admittedInitializationStatements, INITIALIZATION_NEXT_NOTE]
510
526
  : admittedInitializationStatements;
511
527
  const program = TurnOps.renderInternal(programStatements);
512
528
  const admitted = PlurnkParser.parseStatements(program).items.flatMap((item) => item.kind === "statement" ? [item.statement] : []);
@@ -1013,12 +1029,12 @@ class TurnRunner {
1013
1029
  attempts.turnWireAccounting.push(...completedResponse.accounting);
1014
1030
  await modelCall.observeResponse(completedResponse, null, attempts.wire.nativeInputs);
1015
1031
  attempts.railEvidence = attempts.railGrammar === undefined ? undefined : completedResponse.grammarEvidence;
1016
- const split = this.#splitResponse(completedResponse, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed, this.#executors()?.jsonBodyRuntimes(workspaceId) ?? []);
1032
+ const split = this.#splitResponse(completedResponse, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed);
1017
1033
  attempts.split = split;
1018
1034
  await this.#classifyProviderAttempt(attempts, attemptRow.id, split, attempt, split.emissionValid);
1019
1035
  return split.emissionValid ? "admitted" : "rejected";
1020
1036
  }
1021
- // {§notifications-reasoning-event} — only the parent emission is conversational;
1037
+ // {§notifications-reasoning-event} — only the parent emission is observed;
1022
1038
  // BARE has no observer on its isolated calls. Reasoning deltas cite the physical
1023
1039
  // request they stream in; a new request or the call's end closes the open span.
1024
1040
  #reasoningObserver({ workspaceId, workerId, loopId }, turnId, modelCall) {
@@ -1121,12 +1137,12 @@ class TurnRunner {
1121
1137
  throw error;
1122
1138
  }
1123
1139
  attempts.recoveryFailures += 1;
1124
- const failure = _a.#providerFailure(error, attempts.signal);
1140
+ const failure = TurnRunner.#providerFailure(error, attempts.signal);
1125
1141
  if (error.attempt !== undefined) {
1126
1142
  // {§provider-interrupted-attempt} — the interrupted response stays durable
1127
1143
  // as an unaccepted attempt; it is never admitted or replayed.
1128
1144
  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);
1145
+ await this.#classifyProviderAttempt(attempts, attemptId, this.#splitResponse(error.attempt, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed), attempts.currentEmissionAttempt, false);
1130
1146
  }
1131
1147
  else {
1132
1148
  await modelCall.fail(failure, error.capacity ?? null);
@@ -1181,7 +1197,7 @@ class TurnRunner {
1181
1197
  }
1182
1198
  const { provider, workspaceId, workerId, loopId } = args;
1183
1199
  const { turnId } = request;
1184
- const failure = _a.#providerFailure(err, attempts.signal);
1200
+ const failure = TurnRunner.#providerFailure(err, attempts.signal);
1185
1201
  const capacityFailure = err instanceof ProviderError && err.kind === "capacity_exceeded";
1186
1202
  // {§provider-interrupted-attempt} — a provider-declared interruption
1187
1203
  // carries response evidence without becoming a completed exchange.
@@ -1189,7 +1205,7 @@ class TurnRunner {
1189
1205
  if (err instanceof ProviderError && err.attempt !== undefined) {
1190
1206
  attempts.response = err.attempt;
1191
1207
  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) ?? []);
1208
+ attempts.split = this.#splitResponse(err.attempt, this.#executors()?.availableRuntimes(workspaceId) ?? [], attempts.wellFormed);
1193
1209
  await this.#classifyProviderAttempt(attempts, attempts.attemptId, attempts.split, attempts.currentEmissionAttempt, false);
1194
1210
  }
1195
1211
  else {
@@ -1282,14 +1298,14 @@ class TurnRunner {
1282
1298
  // {§invalid-emission-attempts} — the informed turn carries the parser's own
1283
1299
  // diagnostic and position: the model sees WHY, not only that it was refused.
1284
1300
  const diagnostic = split.parseErrors[0];
1285
- const cut = allowanceCutMessage(split.callMetadata.finishReason, response.capacity.responseMax ?? provider.outputBudget);
1301
+ const cut = outputCut(emission, provider);
1286
1302
  if (cut !== null) {
1287
1303
  this.#notices.push(workspaceId, workerId, loopId, {
1288
1304
  source: "engine:capacity",
1289
1305
  kind: "output_truncated",
1290
1306
  level: "error",
1291
1307
  directive: DIRECTIVE.output,
1292
- message: `${cut}; no operations were performed.`,
1308
+ message: `Emission truncated at ${outputAllowance(cut)}; no operations were performed.`,
1293
1309
  });
1294
1310
  }
1295
1311
  else {
@@ -1311,6 +1327,7 @@ class TurnRunner {
1311
1327
  return turnResult(request, TURN_STATUS_IMPLICIT_CONTINUE, {
1312
1328
  outcomes: [{ op: null, status: 500, problemType: "https://problems.plurnk.xyz/engine/invalid-emission-exhausted" }],
1313
1329
  fingerprint: `frame-contract-violation:${turnId}`,
1330
+ outputCut: cut,
1314
1331
  emissionAttempts: emission.emissionAttempts,
1315
1332
  emissionExhausted: true,
1316
1333
  rejectedModelEntryId,
@@ -1325,16 +1342,16 @@ class TurnRunner {
1325
1342
  for (const notice of parseNotices) {
1326
1343
  this.#notices.push(workspaceId, workerId, loopId, notice);
1327
1344
  }
1328
- const allowanceCut = allowanceCutMessage(callMetadata.finishReason, response.capacity.responseMax ?? provider.outputBudget);
1345
+ const cut = outputCut(emission, provider);
1329
1346
  // {§empty-turn} — a response cut at the output allowance with nothing admitted names the
1330
1347
  // cut, so the model reads the ceiling, never a parser symptom (#478).
1331
- if (split.emptyTurn && allowanceCut !== null) {
1348
+ if (split.emptyTurn && cut !== null) {
1332
1349
  this.#notices.push(workspaceId, workerId, loopId, {
1333
1350
  source: "engine:turn",
1334
1351
  kind: "output_truncated",
1335
1352
  level: "warn",
1336
1353
  directive: DIRECTIVE.output,
1337
- message: `${allowanceCut}; no authored operations were performed.`,
1354
+ message: `Emission truncated at ${outputAllowance(cut)}; no authored operations were performed.`,
1338
1355
  });
1339
1356
  }
1340
1357
  // Non-fatal provider transport notices on an accepted turn. Forward each
@@ -1356,12 +1373,12 @@ class TurnRunner {
1356
1373
  : {}),
1357
1374
  });
1358
1375
  }
1359
- if (allowanceCut !== null) {
1376
+ if (cut !== null) {
1360
1377
  this.#notices.push(workspaceId, workerId, loopId, {
1361
1378
  source: "engine:capacity",
1362
1379
  kind: "output_truncated",
1363
1380
  directive: DIRECTIVE.output,
1364
- message: `${allowanceCut}.`,
1381
+ message: `Emission truncated at ${outputAllowance(cut)}.`,
1365
1382
  level: "warn",
1366
1383
  });
1367
1384
  }
@@ -1402,7 +1419,7 @@ class TurnRunner {
1402
1419
  // Phase 6 — the admitted program runs under the workspace's command ceiling and
1403
1420
  // the turn settles on the executor's verdict.
1404
1421
  async #settleAdmittedTurn(args, request, emission) {
1405
- const { childProvider, workspaceId, workerId, loopId, onDispatch, onSettled } = args;
1422
+ const { provider, childProvider, workspaceId, workerId, loopId, onDispatch, onSettled } = args;
1406
1423
  const { split } = emission;
1407
1424
  const coordinates = { workerName: request.workerName, loopSeq: request.loopSeq, turnSeq: request.seq };
1408
1425
  // {§operator-config-workspace-max-commands} — workspace maxCommands
@@ -1440,8 +1457,8 @@ class TurnRunner {
1440
1457
  onSettled,
1441
1458
  });
1442
1459
  // {§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.
1460
+ // forward in its program or from its reasoning, is told so in the next packet, in the card's own
1461
+ // words. An empty turn has its own no-operation row instead.
1445
1462
  const ops = split.packetAssistant.ops;
1446
1463
  if ((executed.status === 102 || executed.status === 202) && ops.length > 0
1447
1464
  && !ops.some((statement) => "op" in statement && statement.op === "NOTE")) {
@@ -1449,17 +1466,12 @@ class TurnRunner {
1449
1466
  source: "engine:turn", kind: "continued_without_note", level: "warn", directive: DIRECTIVE.note, message: CONTINUED_WITHOUT_NOTE,
1450
1467
  });
1451
1468
  }
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
1469
  return turnResult(request, executed.status, {
1459
1470
  outcomes: executed.outcomes,
1460
1471
  progressed: executed.progressed,
1461
1472
  fingerprint: executed.fingerprint,
1462
1473
  emptyTurn: executed.emptyTurn,
1474
+ outputCut: outputCut(emission, provider),
1463
1475
  emissionAttempts: emission.emissionAttempts,
1464
1476
  });
1465
1477
  }
@@ -1510,7 +1522,7 @@ class TurnRunner {
1510
1522
  return true;
1511
1523
  };
1512
1524
  }
1513
- #splitResponse(response, executors = [], wellFormed, jsonBodyExecutors = []) {
1525
+ #splitResponse(response, executors = [], wellFormed) {
1514
1526
  const { assistant } = response;
1515
1527
  const preParsedOps = assistant.ops;
1516
1528
  const ops = [];
@@ -1529,9 +1541,9 @@ class TurnRunner {
1529
1541
  // {§observability-boundary} — the parse is observed without its input;
1530
1542
  // only the resulting statement count is attributable.
1531
1543
  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 }) });
1544
+ // {§executor-heading}: explicit invocations parse without registration; available names
1545
+ // also admit slotless headings. Dispatch resolves the then-current workspace registry.
1546
+ const result = PlurnkParser.parse(assistant.content, { executors, ...(wellFormed === undefined ? {} : { wellFormed }) });
1535
1547
  span.setAttribute("statements", result.items.filter((item) => item.kind === "statement").length);
1536
1548
  return result;
1537
1549
  });
@@ -1595,7 +1607,9 @@ class TurnRunner {
1595
1607
  });
1596
1608
  }
1597
1609
  else {
1598
- parseErrors.push({ message: err.message, line: err.line, column: err.column, source: err.source, ...(err.recovery === undefined ? {} : { recovery: err.recovery }) });
1610
+ parseErrors.push({ message: err.message, line: err.line, column: err.column, source: err.source,
1611
+ ...(err.recovery === undefined ? {} : { recovery: err.recovery }),
1612
+ ...(item.attempt === undefined ? {} : { attempt: item.attempt }) });
1599
1613
  }
1600
1614
  }
1601
1615
  else {
@@ -1678,6 +1692,4 @@ class TurnRunner {
1678
1692
  return this.#admitted.executeAdmittedTurn(...args);
1679
1693
  }
1680
1694
  }
1681
- _a = TurnRunner;
1682
- export default TurnRunner;
1683
1695
  //# sourceMappingURL=TurnRunner.js.map