@plurnk/plurnk-service 0.60.0 → 0.62.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 (104) hide show
  1. package/.env.example +54 -16
  2. package/PLURNK_PERSONALITY.md +53 -0
  3. package/SPEC.md +22 -18
  4. package/dist/core/Dispatcher.d.ts +61 -0
  5. package/dist/core/Dispatcher.d.ts.map +1 -0
  6. package/dist/core/Dispatcher.js +811 -0
  7. package/dist/core/Dispatcher.js.map +1 -0
  8. package/dist/core/Engine.d.ts +9 -46
  9. package/dist/core/Engine.d.ts.map +1 -1
  10. package/dist/core/Engine.js +209 -1513
  11. package/dist/core/Engine.js.map +1 -1
  12. package/dist/core/Engine.sql +7 -2
  13. package/dist/core/ExecutorRegistry.d.ts +2 -1
  14. package/dist/core/ExecutorRegistry.d.ts.map +1 -1
  15. package/dist/core/ExecutorRegistry.js +16 -3
  16. package/dist/core/ExecutorRegistry.js.map +1 -1
  17. package/dist/core/PacketBuilder.d.ts +64 -0
  18. package/dist/core/PacketBuilder.d.ts.map +1 -0
  19. package/dist/core/PacketBuilder.js +380 -0
  20. package/dist/core/PacketBuilder.js.map +1 -0
  21. package/dist/core/ProposalLifecycle.d.ts +56 -0
  22. package/dist/core/ProposalLifecycle.d.ts.map +1 -0
  23. package/dist/core/ProposalLifecycle.js +197 -0
  24. package/dist/core/ProposalLifecycle.js.map +1 -0
  25. package/dist/core/SchemeRegistry.d.ts +2 -0
  26. package/dist/core/SchemeRegistry.d.ts.map +1 -1
  27. package/dist/core/SchemeRegistry.js +20 -15
  28. package/dist/core/SchemeRegistry.js.map +1 -1
  29. package/dist/core/StrikeRail.d.ts +27 -0
  30. package/dist/core/StrikeRail.d.ts.map +1 -0
  31. package/dist/core/StrikeRail.js +147 -0
  32. package/dist/core/StrikeRail.js.map +1 -0
  33. package/dist/core/TelemetryChannel.d.ts +37 -0
  34. package/dist/core/TelemetryChannel.d.ts.map +1 -0
  35. package/dist/core/TelemetryChannel.js +77 -0
  36. package/dist/core/TelemetryChannel.js.map +1 -0
  37. package/dist/core/fork.d.ts +1 -0
  38. package/dist/core/fork.d.ts.map +1 -1
  39. package/dist/core/fork.js +17 -4
  40. package/dist/core/fork.js.map +1 -1
  41. package/dist/core/fork.sql +6 -0
  42. package/dist/core/packet-wire.js +1 -1
  43. package/dist/core/packet-wire.js.map +1 -1
  44. package/dist/core/plurnk-uri.d.ts +2 -0
  45. package/dist/core/plurnk-uri.d.ts.map +1 -1
  46. package/dist/core/plurnk-uri.js +11 -0
  47. package/dist/core/plurnk-uri.js.map +1 -1
  48. package/dist/core/run-cap.js +1 -1
  49. package/dist/core/run-cap.js.map +1 -1
  50. package/dist/digest/Digest.d.ts +14 -0
  51. package/dist/digest/Digest.d.ts.map +1 -0
  52. package/dist/digest/Digest.js +321 -0
  53. package/dist/digest/Digest.js.map +1 -0
  54. package/dist/digest/digest.sql +55 -0
  55. package/dist/schemes/Exec.d.ts.map +1 -1
  56. package/dist/schemes/Exec.js +22 -23
  57. package/dist/schemes/Exec.js.map +1 -1
  58. package/dist/schemes/File.d.ts.map +1 -1
  59. package/dist/schemes/File.js +7 -4
  60. package/dist/schemes/File.js.map +1 -1
  61. package/dist/schemes/Log.d.ts.map +1 -1
  62. package/dist/schemes/Log.js +5 -1
  63. package/dist/schemes/Log.js.map +1 -1
  64. package/dist/schemes/Run.js +3 -3
  65. package/dist/schemes/Run.js.map +1 -1
  66. package/dist/server/ClientConnection.d.ts.map +1 -1
  67. package/dist/server/ClientConnection.js +48 -2
  68. package/dist/server/ClientConnection.js.map +1 -1
  69. package/dist/server/Daemon.d.ts +1 -1
  70. package/dist/server/Daemon.d.ts.map +1 -1
  71. package/dist/server/Daemon.js +5 -1
  72. package/dist/server/Daemon.js.map +1 -1
  73. package/dist/server/methods/auth.d.ts +6 -0
  74. package/dist/server/methods/auth.d.ts.map +1 -0
  75. package/dist/server/methods/auth.js +45 -0
  76. package/dist/server/methods/auth.js.map +1 -0
  77. package/dist/server/methods/mcp_install.d.ts +6 -0
  78. package/dist/server/methods/mcp_install.d.ts.map +1 -0
  79. package/dist/server/methods/mcp_install.js +66 -0
  80. package/dist/server/methods/mcp_install.js.map +1 -0
  81. package/dist/server/methods/op_copy.d.ts.map +1 -1
  82. package/dist/server/methods/op_copy.js +1 -0
  83. package/dist/server/methods/op_copy.js.map +1 -1
  84. package/dist/server/methods/op_dispatch.d.ts.map +1 -1
  85. package/dist/server/methods/op_dispatch.js +1 -0
  86. package/dist/server/methods/op_dispatch.js.map +1 -1
  87. package/dist/server/methods/op_edit.d.ts.map +1 -1
  88. package/dist/server/methods/op_edit.js +1 -0
  89. package/dist/server/methods/op_edit.js.map +1 -1
  90. package/dist/server/methods/op_exec.d.ts.map +1 -1
  91. package/dist/server/methods/op_exec.js +1 -0
  92. package/dist/server/methods/op_exec.js.map +1 -1
  93. package/dist/server/methods/op_move.d.ts.map +1 -1
  94. package/dist/server/methods/op_move.js +1 -0
  95. package/dist/server/methods/op_move.js.map +1 -1
  96. package/dist/server/yolo.js +1 -1
  97. package/dist/server/yolo.js.map +1 -1
  98. package/dist/service.d.ts.map +1 -1
  99. package/dist/service.js +31 -2
  100. package/dist/service.js.map +1 -1
  101. package/docs/run.md +7 -3
  102. package/migrations/0000-00-00.01_schema.sql +3 -3
  103. package/package.json +22 -17
  104. package/requirements.md +2 -1
@@ -0,0 +1,380 @@
1
+ import { renderAddress } from "./plurnk-uri.js";
2
+ import { teachingLine, docsExcludeSet } from "./teaching.js";
3
+ import { readPacketInject, readSystemPolicy, readProjectPolicy } from "./packet-inject.js";
4
+ import { readFile } from "node:fs/promises";
5
+ import Paths from "../Paths.js";
6
+ // Shared module imported by both Engine and bin/digest.ts, so wire
7
+ // projection and digest projection are structurally one function — no
8
+ // drift between wire and digest possible.
9
+ import PacketWire from "./packet-wire.js";
10
+ const DEFAULT_BUDGET_CEILING = 0.9;
11
+ // Substituted into the budget readout after the assembled packet is measured
12
+ // (the figure depends on the packet's own rendered size — chicken/egg).
13
+ const TOKENS_FREE_PLACEHOLDER = "{{tokensFree}}";
14
+ const TOKEN_USAGE_PLACEHOLDER = "{{tokenUsage}}";
15
+ const TOKEN_PERCENT_PLACEHOLDER = "{{tokenPercent}}";
16
+ // PLURNK_BUDGET_CEILING is dual-mode: <=1 is a fraction of the provider's
17
+ // context window, >1 is an absolute token wall — lets a demo pin a tiny
18
+ // ceiling regardless of the model's real window to force the grinder.
19
+ const readCeiling = () => {
20
+ const raw = process.env.PLURNK_BUDGET_CEILING;
21
+ if (raw === undefined || raw.length === 0)
22
+ return DEFAULT_BUDGET_CEILING;
23
+ const n = Number.parseFloat(raw);
24
+ if (!Number.isFinite(n) || n <= 0)
25
+ return DEFAULT_BUDGET_CEILING;
26
+ return n;
27
+ };
28
+ // Packet assembly (SPEC §packet-construction) + the budget grinder (§grinder):
29
+ // builds the spec'd request packet, measures it, and reclaims window on overflow.
30
+ export default class PacketBuilder {
31
+ static computeCeiling(contextSize, config) {
32
+ // Absolute wall (config > 1) is window-independent — the point of the >1
33
+ // mode is to pin a ceiling even when the provider reports no window; cap at
34
+ // the real window when one is known. Ratio mode needs a window to scale.
35
+ if (config > 1)
36
+ return contextSize === null ? Math.floor(config) : Math.min(Math.floor(config), contextSize);
37
+ return contextSize === null ? null : Math.floor(contextSize * config);
38
+ }
39
+ #db;
40
+ #schemes;
41
+ #telemetry;
42
+ // Boot-discovered runtime executors, late-injected on Engine after daemon
43
+ // start() — read through a thunk so the post-construction set is visible.
44
+ #executors;
45
+ #budgetCeiling;
46
+ constructor({ db, schemes, telemetry, executors }) {
47
+ this.#db = db;
48
+ this.#schemes = schemes;
49
+ this.#telemetry = telemetry;
50
+ this.#executors = executors;
51
+ this.#budgetCeiling = readCeiling();
52
+ }
53
+ ceilingFor(provider) {
54
+ return PacketBuilder.computeCeiling(provider.contextSize, this.#budgetCeiling);
55
+ }
56
+ // Assemble the request half of the spec'd packet (Packet.json §system
57
+ // and §user) BEFORE the provider call. The same packet object is then
58
+ // completed with assistant + assistantRaw after the model responds, so
59
+ // the stored packet and the wire payload share one source of truth.
60
+ async buildRequestPacket({ initialMessages, requirements, sessionId, runId, loopId, currentTurnSeq, provider, gitStatus, telemetryErrors: presetTelemetry, }) {
61
+ const byRole = (role) => initialMessages.filter((m) => m.role === role).map((m) => m.content).join("\n\n");
62
+ // plurnk.md (grammar/dialects) ONLY — the definition is the hot-path grammar.
63
+ // The scheme catalogue is its own `schemes` section below tools (§schemes-directory),
64
+ // NOT appended here: grammar 0.49+ is scheme-agnostic, so the service advertises
65
+ // the scheme set at packet-time (grammar#239 item 7) via SchemeRegistry.teach().
66
+ const system_definition = byRole("system");
67
+ // the prompt section sources from the loop's most recent prompt entry first
68
+ // (plurnk:///prompt/<loop_id>/<N> for the highest N written to date).
69
+ // This is what inject + the turn-1 foist write into. Falls back to
70
+ // the runLoop caller's messages.user for tests that bypass the
71
+ // foist mechanism entirely.
72
+ const promptRows = (await this.#db.drain_get_all_prompt_bodies_for_loop.all({ pattern: `/prompt/${loopId}/%` }))
73
+ .filter((r) => typeof r.content === "string" && r.content.length > 0);
74
+ const promptCap = Number.parseInt(process.env.PLURNK_PROMPT_PREVIEW_CHARS ?? "", 10);
75
+ const prompt = promptRows.length > 0
76
+ ? PacketWire.renderActivePrompts(promptRows, Number.isInteger(promptCap) ? promptCap : -1)
77
+ : byRole("user");
78
+ // Requirements is engine-sourced, NOT threaded from callers — that threading is
79
+ // exactly how it went missing (callers read the sysprompt but never the
80
+ // requirements). Read Paths.defaultRequirements (PLURNK_REQUIREMENTS env →
81
+ // requirements.md) fresh each build so edits take effect; a non-empty param wins.
82
+ const baseRequirements = requirements.length > 0 ? requirements : await readFile(Paths.defaultRequirements, "utf8");
83
+ // No injected syntax line: the grammar already headlines the system definition (§Syntax) and
84
+ // leads requirements.md, so a third copy here was pure duplication in the model's packet. PLAN
85
+ // is mandated unconditionally by plurnk.md §Imperatives (grammar 0.70 requires every turn to
86
+ // lead with PLAN), so the service injects no separate plan directive either (the former
87
+ // PLURNK_PLAN gating is retired — PLURNK_PLAN is no longer a flag).
88
+ const log = await this.#buildLog(runId);
89
+ const telemetryErrors = presetTelemetry ?? await this.buildTelemetryErrors(loopId, currentTurnSeq);
90
+ const countTokens = (t) => provider.countTokens(t); // §provider-surface-counttokens
91
+ const tools = this.#collectTools();
92
+ // Budget readout (SPEC.md §tokenomics). Two-pass: render the budget from
93
+ // the structured log's subtotals with a {{tokensFree}} placeholder, build
94
+ // the section list, measure the assembled total, resolve free, substitute.
95
+ // Subtotals come from the real log render — meta and fences included — not
96
+ // a serialized approximation. ceiling is the provider's window ×
97
+ // PLURNK_BUDGET_CEILING (null when no window is reported → headline
98
+ // omitted, section lines still shown). §tokenomics-render-weight-budget
99
+ const ceiling = this.ceilingFor(provider);
100
+ const budgetReadout = this.#renderBudget(PacketWire.measureLogBudget(log, countTokens), ceiling);
101
+ // The default packet: an ordered list of addressable sections (§packet-construction).
102
+ // `slot` is a TRUST boundary (and the prompt-cache boundary): system holds only
103
+ // framework-authored, non-injectable sections — the static head (definition/tools/
104
+ // schemes/policy) forms the cached prefix, then the volatile-but-trusted tail of
105
+ // errors/git/budget; user holds injectable content (the log, the operator prompt) plus
106
+ // the requirements footer. The budget section carries its {{tokensFree}} placeholders
107
+ // here; they resolve below once the assembled total is known.
108
+ const inject = await readPacketInject(); // #240 — operator section, per-turn, fail-hard on a broken path
109
+ const sessionRoot = (await this.#db.envelope_get_session.get({ id: sessionId }))?.project_root ?? null;
110
+ const systemPolicy = await readSystemPolicy(); // ~/.plurnk/AGENTS.md (or PLURNK_POLICY)
111
+ const projectPolicy = await readProjectPolicy(sessionRoot); // <projectRoot>/AGENTS.md (or PLURNK_PROJECT)
112
+ // Child-orientation (§child-orientation): the live things THIS run holds — open streams +
113
+ // unconcluded child runs — surfaced every turn as terse `* <status> <path>` pointers (same shape
114
+ // as errors) just above the errors section. Orienting STATE so the model never loses track of
115
+ // what it's holding (the premature-terminate trap), never advice on what to do. Empty → omitted.
116
+ const childStreams = (await this.#db.engine_child_streams_open.all({ run_id: runId }))
117
+ .map((s) => ({ status: "active", path: renderAddress(s.scheme, s.pathname) }));
118
+ const childRuns = (await this.#db.engine_child_runs_live.all({ run_id: runId }))
119
+ .map((r) => ({ status: r.status, path: `run://${r.name}` }));
120
+ const defaults = [
121
+ { name: "definition", slot: "system", header: null, content: system_definition, tokens: 0 },
122
+ { name: "tools", slot: "system", header: null, content: tools.join("\n"), tokens: 0 }, // titleless — the examples flow on from plurnk.md (definition) directly above
123
+ { name: "schemes", slot: "system", header: "Plurnk Service Schemes", content: this.#schemes.teach(), tokens: 0 },
124
+ ...(inject !== null ? [{ name: "inject", slot: "system", header: "Plurnk Operator Notes", content: inject, tokens: 0 }] : []),
125
+ // policy: the client's privileged rules — ~/.plurnk/AGENTS.md (system) then <root>/AGENTS.md (project) — below grammar/tools/schemes, above budget-the-law. AGENTS is POLICY here, never a curatable READable entry. Empty content ⇒ section omitted.
126
+ { name: "system-policy", slot: "system", header: "Plurnk Service Policy", content: systemPolicy ?? "", tokens: 0 },
127
+ { name: "project-policy", slot: "system", header: "Project Policy", content: projectPolicy ?? "", tokens: 0 },
128
+ // The packet split is a TRUST boundary: system carries only framework-authored, non-injectable
129
+ // sections; anything that could carry attacker-reachable text (a READ result, exec output, the
130
+ // model's own mirrored bytes) stays in user. errors + git are framework status — the errors
131
+ // section is uri+status POINTERS (the error item + body live in the log), git is counts — so
132
+ // neither is an injection surface; both sit at the bottom of system, just above budget-the-law.
133
+ // child-orientation: what THIS run holds live — streams then runs — just above errors. Terse
134
+ // pointers (the path is the actionable address the model READs/OPENs/KILLs), never advice. §child-orientation
135
+ { name: "child-streams", slot: "system", header: "Plurnk Service Child Streams", content: PacketWire.renderChildPointers(childStreams), tokens: 0 },
136
+ { name: "child-runs", slot: "system", header: "Plurnk Service Child Runs", content: PacketWire.renderChildPointers(childRuns), tokens: 0 },
137
+ { name: "errors", slot: "system", header: "Plurnk Service Errors", content: PacketWire.renderErrors(telemetryErrors), tokens: 0 },
138
+ { name: "git", slot: "system", header: "Plurnk Service Git Status", content: PacketWire.renderGit(gitStatus), tokens: 0 },
139
+ // budget is the very last system line — LAW (a hard ceiling the model must obey), the final word before the model acts.
140
+ { name: "budget", slot: "system", header: "Plurnk Service Budget", content: budgetReadout, tokens: 0 },
141
+ // log in the user slot: injectable content (READ results, exec output, the model's own mirror) — data, never rules — kept at the action point so the model consults its history.
142
+ { name: "log", slot: "user", header: "Plurnk Service Log", content: PacketWire.renderLog(log, countTokens), tokens: 0 },
143
+ // the ACTIVE user prompts (all the current loop holds, in order — a loop admits injected
144
+ // prompts) render at the BOTTOM, just above requirements — at the action point, closest to
145
+ // the model's turn. Each is a bare heredoc (the fence is the link); §prompt-fold.
146
+ { name: "prompt", slot: "user", header: "Plurnk Service Active User Prompts", content: prompt, tokens: 0 },
147
+ // requirements renders LAST — the user-slot footer, the syntax contract closest to the model's turn (a recency carve-out for weak models).
148
+ { name: "requirements", slot: "user", header: "Plurnk Service Requirements", content: baseRequirements, tokens: 0 },
149
+ ];
150
+ // Plugin packet control (§packet-construction): trusted schemes rewrite the
151
+ // default list — add, remove, reorder — in-process, before measurement.
152
+ const sections = await this.#schemes.transformSections(defaults);
153
+ // Pass 1: measure the assembled total with the placeholder budget in
154
+ // place, resolve free/percent, substitute into the budget section.
155
+ let total = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
156
+ if (ceiling !== null) {
157
+ const budgetSec = sections.find((s) => s.name === "budget"); // a plugin may have removed it
158
+ if (budgetSec) {
159
+ // Curation pressure gates on OCCUPANCY (§tokenomics-pressure-gates-on-occupancy, #308):
160
+ // the Turns/Heaviest tables are a standing FOLD-target list, and a high-headroom model
161
+ // reads them as a todo — burning turns on token hygiene at 3% of a 64k window. Under
162
+ // half-full, the headline's numbers stand alone (truncate at the first blank line) and
163
+ // the total RE-measures — the substituted figures must reconcile with what ships.
164
+ // A null ceiling can't calibrate, so the full readout stays.
165
+ if ((total / ceiling) * 100 < 50) {
166
+ const cut = budgetSec.content.indexOf("\n\n");
167
+ if (cut !== -1) {
168
+ budgetSec.content = budgetSec.content.slice(0, cut);
169
+ total = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
170
+ }
171
+ }
172
+ const tokensFree = Math.max(0, ceiling - total); // free floors at 0 on overshoot — §tokenomics-over-budget-floor
173
+ const percent = (total / ceiling) * 100; // usage as % of the ceiling — §tokenomics-context-percent
174
+ budgetSec.content = budgetSec.content
175
+ .replace(TOKEN_USAGE_PLACEHOLDER, String(total))
176
+ // Any nonzero usage under 1% is "<1" — Math.round alone claimed "1%" from 0.51%,
177
+ // overstating a near-empty window.
178
+ .replace(TOKEN_PERCENT_PLACEHOLDER, total > 0 && percent < 1 ? "<1" : String(Math.round(percent)))
179
+ .replace(TOKENS_FREE_PLACEHOLDER, String(tokensFree));
180
+ }
181
+ }
182
+ // Pass 2: per-section render-weight + the assembled packet total (post
183
+ // substitution — the placeholder/number length delta is negligible).
184
+ for (const s of sections)
185
+ s.tokens = countTokens(PacketWire.renderSection(s));
186
+ const packetTokens = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
187
+ return { tokens: packetTokens, sections, telemetryErrors };
188
+ }
189
+ // Budget readout body, rendered into the `## Plurnk Service Budget` section.
190
+ // Headline `ceiling/free` only when a ceiling exists; section lines for the
191
+ // curatable index/log weight the model can FOLD back. tokensFree is a
192
+ // placeholder here — buildRequestPacket substitutes it after measuring the packet.
193
+ #renderBudget(log, ceiling) {
194
+ const lines = [];
195
+ if (ceiling !== null)
196
+ lines.push(`Token Ceiling ${ceiling} · Token Usage ${TOKEN_USAGE_PLACEHOLDER} (${TOKEN_PERCENT_PLACEHOLDER}%) · Tokens Free ${TOKENS_FREE_PLACEHOLDER}`);
197
+ if (log.entries > 0) {
198
+ if (lines.length > 0)
199
+ lines.push("");
200
+ lines.push(`Log entries: ${log.entries} entries, ${log.tokens} tokens`);
201
+ // Per-turn weight — chronological (oldest first); the turn is the grinder's
202
+ // rollback unit and the rail folds the newest first (§tokenomics {§tokenomics-turn-totals}).
203
+ if (log.byTurn.length > 0) {
204
+ lines.push("", "Turns:", "| turn | tokens |", "|---|--:|");
205
+ for (const t of log.byTurn)
206
+ lines.push(`| ${t.turn} | ${t.tokens} |`);
207
+ }
208
+ // The heaviest individual log items — the FOLD targets behind the weight
209
+ // (§tokenomics {§tokenomics-largest-entries}). "items", not "entries": the readout
210
+ // lists log:/// rows (log items), distinct from catalog entries (plurnk.md: "EDIT
211
+ // is only for entries. Do not attempt to edit log items.").
212
+ if (log.largest.length > 0) {
213
+ lines.push("", "Heaviest items:", "| item | tokens |", "|---|--:|");
214
+ for (const e of log.largest)
215
+ lines.push(`| ${e.path} | ${e.tokens} |`);
216
+ }
217
+ }
218
+ return lines.join("\n");
219
+ }
220
+ // The ## Plurnk Service Tools capability sheet (SPEC §tools). A hook: each enabled
221
+ // capability contributes one line, rendered above Requirements so the model sees what
222
+ // it can do before the rules. Each available executor tag contributes its self-documenting
223
+ // example (plurnk-execs#7), retiring the blind EXEC.
224
+ // The capability sheet — the live tool surface (wired executor tags). §tools-capability-sheet
225
+ #collectTools() {
226
+ const tools = [];
227
+ // Each available runtime tag contributes its self-documenting example —
228
+ // the example carries syntax + purpose, so there's no prose line. Tags
229
+ // with no example (sh/node, covered by the core prompt) contribute
230
+ // nothing; available-only, so the model never sees an unusable tag. `* `
231
+ // bullets + bare op forms match the packet's list/op rendering (no `- `,
232
+ // no backticks — see packet-wire.ts).
233
+ const executors = this.#executors();
234
+ if (executors !== undefined) {
235
+ const excluded = docsExcludeSet();
236
+ for (const tag of executors.availableRuntimes()) {
237
+ if (excluded.has(tag))
238
+ continue; // #240 — PLURNK_DOCS_EXCLUDE drops the oneliner + the doc
239
+ const entry = executors.entry(tag);
240
+ // #240 — identical treatment with the scheme directory: the example IS the oneliner,
241
+ // the fuller doc (materialized at plurnk://docs/<tag>.md) rides an inline link whose
242
+ // token cost lives on that manifest entry. No example → no line (like a provisional scheme).
243
+ if (entry?.example)
244
+ tools.push(teachingLine(entry.example));
245
+ }
246
+ }
247
+ return tools;
248
+ }
249
+ // #note12 — the daughter-provided reference docs (schemes' + execs' `documentation`),
250
+ // materialized at plurnk:///docs/<name>.md by loop_run (like operator docs) so the
251
+ // catalogue's doc-links READ and the manifest carries each doc's token cost.
252
+ docEntries() {
253
+ const out = this.#schemes.docs(); // scheme docs already drop PLURNK_DOCS_EXCLUDE names
254
+ const executors = this.#executors();
255
+ if (executors !== undefined) {
256
+ const excluded = docsExcludeSet();
257
+ for (const tag of executors.availableRuntimes()) {
258
+ if (excluded.has(tag))
259
+ continue; // #240 — exec docs honor the same exclude
260
+ const doc = executors.entry(tag)?.documentation;
261
+ if (doc !== undefined && doc.length > 0)
262
+ out.push({ name: tag, content: doc });
263
+ }
264
+ }
265
+ return out;
266
+ }
267
+ // SPEC §grinder — the budget grinder. Runs pre-LLM (in runTurn, after the packet
268
+ // is built, before provider.generate); fires only on actual overflow. Two
269
+ // passes, re-measuring between. Folds (never deletes) — the prior turn's logs,
270
+ // then the catalog except the manifest lifeline. The strike it raises and the
271
+ // hard-stop it can signal are returned to runLoop, which owns abandonment.
272
+ // §grinder-overflow-only — fires only on actual overflow, never speculatively
273
+ async enforceBudget({ packet, provider, runId, loopId, turnId, mintSequence, rebuild }) {
274
+ const ceiling = this.ceilingFor(provider);
275
+ const measure = (p) => p.tokens;
276
+ if (ceiling === null || measure(packet) <= ceiling)
277
+ return { packet, fit: true, struck: false };
278
+ // The grinder may compact ONLY the newest turn — the immediately-prior turn's emissions
279
+ // (turn N>1), or, when there is no prior turn (turn 1), THIS turn's own foists. It NEVER
280
+ // reaches older history; the model alone curates history via FOLD/KILL, and the engine never
281
+ // janitors stale context. §grinder-newest-turn-only
282
+ let foldedAny = false;
283
+ const priorLogs = await this.#db.engine_grinder_prior_turn_logs.all({ loop_id: loopId, turn_id: turnId });
284
+ if (priorLogs.length > 0) {
285
+ await this.#db.engine_grinder_fold_prior_turn_logs.run({ loop_id: loopId, turn_id: turnId });
286
+ foldedAny = true;
287
+ }
288
+ else {
289
+ // Turn 1 — no prior turn: fold THIS turn's own foists (the catalog/prompt that overflowed). §grinder-turn-1-self-fold (#2)
290
+ const curLogs = await this.#db.engine_grinder_current_turn_logs.all({ loop_id: loopId, turn_id: turnId });
291
+ if (curLogs.length > 0) {
292
+ await this.#db.engine_grinder_fold_current_turn_logs.run({ loop_id: loopId, turn_id: turnId });
293
+ foldedAny = true;
294
+ }
295
+ }
296
+ if (!foldedAny)
297
+ return { packet, fit: measure(packet) <= ceiling, struck: false };
298
+ // Mint the overflow as a terse op='error' log row BEFORE the rebuild, so the rebuild's
299
+ // re-derived errors section surfaces it THIS turn — the warning lands at strike 1, not a
300
+ // turn late. The row is grinder-exempt, so it stacks into a visible recurrence trail. It
301
+ // sits at the turn's reserved running sequence (mintSequence) so it never collides with the
302
+ // post-generate dispatch rows. §telemetry-uniform-error-channel, §grinder-overflow-error-row
303
+ await this.#telemetry.mintEngineError("budget_overflow", { runId, loopId, turnId, sequence: mintSequence });
304
+ const current = await rebuild();
305
+ // Every compaction is a strike — including turn 0/1 (no soft exemption, #4). §grinder-compaction-strikes
306
+ return { packet: current, fit: measure(current) <= ceiling, struck: true };
307
+ }
308
+ // Complete the packet by adding the model's response. After this the
309
+ // packet matches Packet.json fully and is ready for storage.
310
+ completePacket(requestPacket, assistant, assistantRaw, provider) {
311
+ const assistantTokens = provider.countTokens(assistant.content);
312
+ return {
313
+ tokens: requestPacket.tokens + assistantTokens,
314
+ sections: requestPacket.sections,
315
+ telemetryErrors: requestPacket.telemetryErrors,
316
+ assistant,
317
+ assistantRaw,
318
+ };
319
+ }
320
+ // SPEC §telemetry: model-facing alert surface.
321
+ // Two sources, merged on each packet build:
322
+ // 1. Previous-turn action-bound failures (status_rx >= 400 on log_entries).
323
+ // 2. Engine-buffered actionless failures (no_send, parse, watchdog, rails).
324
+ // Buffer drains on read — each error appears in exactly one packet.
325
+ async buildTelemetryErrors(loopId, currentTurnSeq) {
326
+ // The uniform error channel (§telemetry-uniform-error-channel): every 4xx/5xx log row
327
+ // becomes a LogCoordinate-positioned TelemetryEvent — a terse pointer; the model READs the
328
+ // row for its term + detail. Buffer events that point at the model's own emission keep their
329
+ // ContentOffset position. info-level notices (progress) are not errors and never surface here.
330
+ const rows = await this.#db.engine_render_telemetry_errors.all({ loop_id: loopId, current_turn_seq: currentTurnSeq });
331
+ const logErrors = rows.map((r) => ({
332
+ source: "engine:rail",
333
+ kind: "log_error",
334
+ level: "error",
335
+ status: r.status_rx,
336
+ position: { type: "log-coordinate", coordinate: `${r.loop_seq}/${r.turn_seq}/${r.sequence}/${r.op}` },
337
+ }));
338
+ const bufferEvents = this.#telemetry.drain(loopId).filter((e) => e.level !== "info");
339
+ return [...bufferEvents, ...logErrors];
340
+ }
341
+ // SPEC §packet the log section — chronological action-entries for the loop.
342
+ // Snapshot is taken at packet build (pre-dispatch this turn), so it
343
+ // reflects "what has happened before this turn." Each row carries a
344
+ // log:///<loop_seq>/<turn_seq>/<sequence> coordinate the model can READ.
345
+ async #buildLog(runId) {
346
+ // SPEC §packet-terms: runs own log entries — log is the run's history,
347
+ // not the loop's. Span all loops in the run so the model sees
348
+ // earlier loops' work as conversational memory.
349
+ //
350
+ // User prompts are first-class log entries: runTurn writes a
351
+ // client-origin SEND[200] row at sequence=0 of each new
352
+ // turn-1. Prompts thus surface naturally in this query — no
353
+ // synthetic / shim layer.
354
+ const rows = await this.#db.engine_render_log.all({ run_id: runId });
355
+ return rows.map((r) => ({
356
+ coordinate: `${r.loop_seq}/${r.turn_seq}/${r.sequence}`,
357
+ origin: r.origin,
358
+ op: r.op,
359
+ suffix: r.suffix,
360
+ signal: r.signal === null ? null : JSON.parse(r.signal),
361
+ target: {
362
+ scheme: r.scheme,
363
+ username: r.username, password: r.password,
364
+ hostname: r.hostname, port: r.port,
365
+ pathname: r.pathname,
366
+ params: r.params === null ? null : JSON.parse(r.params),
367
+ fragment: r.fragment,
368
+ },
369
+ status: r.status_rx,
370
+ rx: r.mimetype_rx === "application/json" ? JSON.parse(r.rx) : r.rx,
371
+ mimetype_rx: r.mimetype_rx,
372
+ tx: r.mimetype_tx === "application/json" ? JSON.parse(r.tx) : r.tx,
373
+ mimetype_tx: r.mimetype_tx,
374
+ folded: r.expanded === 0,
375
+ source: r.source,
376
+ attrs: r.attrs === null ? null : JSON.parse(r.attrs),
377
+ }));
378
+ }
379
+ }
380
+ //# sourceMappingURL=PacketBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PacketBuilder.js","sourceRoot":"","sources":["../../src/core/PacketBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,mEAAmE;AACnE,sEAAsE;AACtE,0CAA0C;AAC1C,OAAO,UAAkC,MAAM,kBAAkB,CAAC;AAKlE,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,6EAA6E;AAC7E,wEAAwE;AACxE,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AACjD,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AACjD,MAAM,yBAAyB,GAAG,kBAAkB,CAAC;AAErD,0EAA0E;AAC1E,wEAAwE;AACxE,sEAAsE;AACtE,MAAM,WAAW,GAAG,GAAW,EAAE;IAC7B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAC9C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAA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AI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;SACvD,CAAC,CAAC,CAAC;IACR,CAAC;CACJ"}
@@ -0,0 +1,56 @@
1
+ import type { PlurnkStatement } from "@plurnk/plurnk-grammar";
2
+ import type { Db } from "./Db.ts";
3
+ import type SchemeRegistry from "./SchemeRegistry.ts";
4
+ import type ExecutorRegistry from "./ExecutorRegistry.ts";
5
+ import type TelemetryChannel from "./TelemetryChannel.ts";
6
+ import type { StreamEventNotify, WakeRunNotify } from "./ChannelWrite.ts";
7
+ import type { LoopFlags } from "./scheme-types.ts";
8
+ import type { DispatchResult } from "./Dispatcher.ts";
9
+ export type ProposalDecision = "accept" | "reject" | "cancel";
10
+ export interface ProposalResolution {
11
+ decision: ProposalDecision;
12
+ body?: string;
13
+ outcome?: string;
14
+ }
15
+ export interface ProposalPendingEvent {
16
+ logEntryId: number;
17
+ sessionId: number;
18
+ runId: number;
19
+ loopId: number;
20
+ turnId: number;
21
+ op: string;
22
+ target: {
23
+ scheme: string | null;
24
+ pathname: string | null;
25
+ };
26
+ body: string;
27
+ attrs: object;
28
+ flags: LoopFlags;
29
+ staleClobberRisk: boolean;
30
+ }
31
+ export default class ProposalLifecycle {
32
+ #private;
33
+ constructor({ db, schemes, telemetry, streamEventNotify, wakeRunNotify, tokenize, executors, loopSignal }: {
34
+ db: Db;
35
+ schemes: SchemeRegistry;
36
+ telemetry: TelemetryChannel;
37
+ streamEventNotify?: StreamEventNotify;
38
+ wakeRunNotify?: WakeRunNotify;
39
+ tokenize: (text: string) => number;
40
+ executors: () => ExecutorRegistry | undefined;
41
+ loopSignal: (loopId: number) => AbortSignal | undefined;
42
+ });
43
+ resolve(logEntryId: number, resolution: ProposalResolution): void;
44
+ pendingIds(): number[];
45
+ onPending(listener: (event: ProposalPendingEvent) => void): void;
46
+ notifyPending(event: ProposalPendingEvent): void;
47
+ awaitResolution(logEntryId: number): Promise<ProposalResolution>;
48
+ runApply(statement: PlurnkStatement, originalResult: DispatchResult, resolution: ProposalResolution, ids: {
49
+ sessionId: number;
50
+ runId: number;
51
+ loopId: number;
52
+ turnId: number;
53
+ }): Promise<ProposalResolution>;
54
+ applyResolution(logEntryId: number, resolution: ProposalResolution): Promise<DispatchResult>;
55
+ }
56
+ //# sourceMappingURL=ProposalLifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProposalLifecycle.d.ts","sourceRoot":"","sources":["../../src/core/ProposalLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAuB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC9D,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,gBAAgB,CAAC;IAK3B,IAAI,CAAC,EAAE,MAAM,CAAC;IAKd,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAYD,MAAM,WAAW,oBAAoB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,I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