@plurnk/plurnk-service 3.3.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.
- package/.env.defaults +1 -1
- package/INSTALL.md +6 -0
- package/README.md +2 -2
- package/SPEC.md +380 -159
- package/dist/build-info.json +1 -1
- package/dist/completions/_plurnk-service +1 -1
- package/dist/completions/plurnk-service.bash +1 -1
- package/dist/completions/plurnk-service.fish +2 -0
- package/dist/content/read-projector.js +1 -1
- package/dist/content/read-projector.js.map +1 -1
- package/dist/core/AdministrativeLoop.d.ts +1 -1
- package/dist/core/AdministrativeLoop.d.ts.map +1 -1
- package/dist/core/AdministrativeLoop.js +4 -1
- package/dist/core/AdministrativeLoop.js.map +1 -1
- package/dist/core/AdmittedTurnExecutor.d.ts.map +1 -1
- package/dist/core/AdmittedTurnExecutor.js +8 -0
- package/dist/core/AdmittedTurnExecutor.js.map +1 -1
- package/dist/core/BareBatchRunner.js +2 -1
- package/dist/core/BareBatchRunner.js.map +1 -1
- package/dist/core/ChannelWrite.d.ts +10 -0
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +10 -0
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +14 -2
- package/dist/core/ClientInteractions.d.ts.map +1 -1
- package/dist/core/ClientInteractions.js +2 -1
- package/dist/core/ClientInteractions.js.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +5 -0
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/DataStatementRunner.js +4 -6
- package/dist/core/DataStatementRunner.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +3 -7
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +46 -68
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/Dispatcher.sql +2 -2
- package/dist/core/EditMutations.js +1 -0
- package/dist/core/EditMutations.js.map +1 -1
- package/dist/core/Engine.d.ts +8 -14
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +22 -24
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +6 -6
- package/dist/core/ExecutorRegistry.d.ts +0 -5
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +10 -18
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/FileAddress.js +1 -1
- package/dist/core/FileAddress.js.map +1 -1
- package/dist/core/FilePublication.js +10 -74
- package/dist/core/FilePublication.js.map +1 -1
- package/dist/core/FileSnapshot.js +36 -100
- package/dist/core/FileSnapshot.js.map +1 -1
- package/dist/core/HostPaths.d.ts +1 -0
- package/dist/core/HostPaths.d.ts.map +1 -1
- package/dist/core/HostPaths.js +11 -1
- package/dist/core/HostPaths.js.map +1 -1
- package/dist/core/KillHandler.js +3 -1
- package/dist/core/KillHandler.js.map +1 -1
- package/dist/core/LiveSubscription.js +1 -1
- package/dist/core/LiveSubscription.js.map +1 -1
- package/dist/core/LogBody.js +1 -1
- package/dist/core/LogBody.js.map +1 -1
- package/dist/core/LogWriter.js +1 -1
- package/dist/core/LogWriter.js.map +1 -1
- package/dist/core/LoopDriver.d.ts +3 -3
- package/dist/core/LoopDriver.d.ts.map +1 -1
- package/dist/core/LoopDriver.js +15 -13
- package/dist/core/LoopDriver.js.map +1 -1
- package/dist/core/LoopLifecycle.d.ts +5 -0
- package/dist/core/LoopLifecycle.d.ts.map +1 -1
- package/dist/core/LoopLifecycle.js +14 -1
- package/dist/core/LoopLifecycle.js.map +1 -1
- package/dist/core/LoopLifecycle.sql +8 -0
- package/dist/core/MembershipMaterialization.js +2 -2
- package/dist/core/MembershipMaterialization.js.map +1 -1
- package/dist/core/MessageResources.d.ts +3 -0
- package/dist/core/MessageResources.d.ts.map +1 -1
- package/dist/core/MessageResources.js +15 -1
- package/dist/core/MessageResources.js.map +1 -1
- package/dist/core/OperatorConfig.d.ts +1 -2
- package/dist/core/OperatorConfig.d.ts.map +1 -1
- package/dist/core/OperatorConfig.js +26 -92
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/PacketBuilder.js +6 -6
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/PacketBuilder.sql +7 -8
- package/dist/core/ProblemLog.d.ts +1 -0
- package/dist/core/ProblemLog.d.ts.map +1 -1
- package/dist/core/ProblemLog.js +2 -2
- package/dist/core/ProblemLog.js.map +1 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +13 -8
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ProposalPolicies.d.ts +4 -1
- package/dist/core/ProposalPolicies.d.ts.map +1 -1
- package/dist/core/ProposalPolicies.js +5 -2
- package/dist/core/ProposalPolicies.js.map +1 -1
- package/dist/core/ResourceMutations.js +2 -0
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/ResourceSelector.js +1 -1
- package/dist/core/ResourceSelector.js.map +1 -1
- package/dist/core/SchemeRegistry.js +1 -1
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/ServiceHelp.js +1 -1
- package/dist/core/ServiceHelp.js.map +1 -1
- package/dist/core/ServiceTeardown.js +9 -12
- package/dist/core/ServiceTeardown.js.map +1 -1
- package/dist/core/StrikeRail.d.ts +2 -1
- package/dist/core/StrikeRail.d.ts.map +1 -1
- package/dist/core/StrikeRail.js +11 -6
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/TerminalResult.js +1 -1
- package/dist/core/TerminalResult.js.map +1 -1
- package/dist/core/TurnDispositionHandler.js +3 -2
- package/dist/core/TurnDispositionHandler.js.map +1 -1
- package/dist/core/TurnMaterialization.js +6 -4
- package/dist/core/TurnMaterialization.js.map +1 -1
- package/dist/core/TurnMaterialization.sql +1 -1
- package/dist/core/TurnOps.js +1 -0
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +4 -2
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +63 -51
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/WorkerControlHandler.d.ts +2 -0
- package/dist/core/WorkerControlHandler.d.ts.map +1 -1
- package/dist/core/WorkerControlHandler.js +48 -16
- package/dist/core/WorkerControlHandler.js.map +1 -1
- package/dist/core/WorkerName.d.ts +0 -4
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +5 -30
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkerName.sql +4 -20
- package/dist/core/WorkerOwners.d.ts +1 -0
- package/dist/core/WorkerOwners.d.ts.map +1 -1
- package/dist/core/WorkerOwners.js +6 -0
- package/dist/core/WorkerOwners.js.map +1 -1
- package/dist/core/WorkerOwners.sql +7 -0
- package/dist/core/WorkspaceGate.d.ts +3 -1
- package/dist/core/WorkspaceGate.d.ts.map +1 -1
- package/dist/core/WorkspaceGate.js +59 -10
- package/dist/core/WorkspaceGate.js.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.d.ts +2 -0
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
- package/dist/core/caps/SchemeCtxImpl.js +12 -0
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
- package/dist/core/env-catalog.js +1 -1
- package/dist/core/env-catalog.js.map +1 -1
- package/dist/core/fork.js +1 -1
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +5 -4
- package/dist/core/mutation-types.js +4 -1
- package/dist/core/mutation-types.js.map +1 -1
- package/dist/core/namespace.js +1 -1
- package/dist/core/namespace.js.map +1 -1
- package/dist/core/packet-wire.d.ts +1 -1
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +19 -14
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/scheme-types.d.ts +4 -0
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/turn-signals.d.ts +4 -0
- package/dist/core/turn-signals.d.ts.map +1 -1
- package/dist/core/turn-signals.js +1 -0
- package/dist/core/turn-signals.js.map +1 -1
- package/dist/core/workspace-settings.js +1 -1
- package/dist/core/workspace-settings.js.map +1 -1
- package/dist/evidence/EvidenceReader.js +5 -5
- package/dist/evidence/EvidenceReader.js.map +1 -1
- package/dist/man/plurnk-service.1 +24 -3
- package/dist/schemes/Env.d.ts +7 -3
- package/dist/schemes/Env.d.ts.map +1 -1
- package/dist/schemes/Env.js +12 -6
- package/dist/schemes/Env.js.map +1 -1
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +33 -25
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +3 -3
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/ExecutionInput.js +1 -1
- package/dist/schemes/ExecutionInput.js.map +1 -1
- package/dist/schemes/File.js +15 -18
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +19 -4
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/ResourceTreeScheme.js +2 -5
- package/dist/schemes/ResourceTreeScheme.js.map +1 -1
- package/dist/schemes/TurnSource.js +1 -1
- package/dist/schemes/TurnSource.js.map +1 -1
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +10 -3
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-crud.d.ts.map +1 -1
- package/dist/schemes/_entry-crud.js +2 -4
- package/dist/schemes/_entry-crud.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +5 -3
- package/dist/schemes/_entry-find.js +3 -3
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +3 -3
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-manifest.sql +2 -0
- package/dist/schemes/_entry-ops.js +1 -1
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-send.js +1 -1
- package/dist/schemes/_entry-send.js.map +1 -1
- package/dist/server/ClientReads.d.ts +1 -0
- package/dist/server/ClientReads.d.ts.map +1 -1
- package/dist/server/ClientReads.js +7 -2
- package/dist/server/ClientReads.js.map +1 -1
- package/dist/server/Credentials.d.ts +48 -0
- package/dist/server/Credentials.d.ts.map +1 -0
- package/dist/server/Credentials.js +203 -0
- package/dist/server/Credentials.js.map +1 -0
- package/dist/server/Daemon.d.ts +40 -41
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +272 -206
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +5 -2
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +27 -31
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/EnvFunctionality.d.ts.map +1 -1
- package/dist/server/EnvFunctionality.js +2 -1
- package/dist/server/EnvFunctionality.js.map +1 -1
- package/dist/server/Functionality.d.ts +4 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +110 -51
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.js +1 -1
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/HttpListener.d.ts +1 -1
- package/dist/server/HttpListener.d.ts.map +1 -1
- package/dist/server/HttpListener.js.map +1 -1
- package/dist/server/MembersFunctionality.d.ts.map +1 -1
- package/dist/server/MembersFunctionality.js +4 -2
- package/dist/server/MembersFunctionality.js.map +1 -1
- package/dist/server/ModuleHost.d.ts +2 -1
- package/dist/server/ModuleHost.d.ts.map +1 -1
- package/dist/server/PlurnkSkill.js +4 -7
- package/dist/server/PlurnkSkill.js.map +1 -1
- package/dist/server/Rollback.js +1 -1
- package/dist/server/Rollback.js.map +1 -1
- package/dist/server/WorkerModelResolver.js +1 -0
- package/dist/server/WorkerModelResolver.js.map +1 -1
- package/dist/server/WorkerReferences.d.ts +14 -0
- package/dist/server/WorkerReferences.d.ts.map +1 -0
- package/dist/server/WorkerReferences.js +24 -0
- package/dist/server/WorkerReferences.js.map +1 -0
- package/dist/server/WorkerReferences.sql +31 -0
- package/dist/server/WorkspaceCapabilities.d.ts +2 -0
- package/dist/server/WorkspaceCapabilities.d.ts.map +1 -1
- package/dist/server/WorkspaceCapabilities.js +35 -18
- package/dist/server/WorkspaceCapabilities.js.map +1 -1
- package/dist/server/WorkspacePlugins.js +1 -0
- package/dist/server/WorkspacePlugins.js.map +1 -1
- package/dist/server/WorkspaceResidency.d.ts +3 -1
- package/dist/server/WorkspaceResidency.d.ts.map +1 -1
- package/dist/server/WorkspaceResidency.js +12 -5
- package/dist/server/WorkspaceResidency.js.map +1 -1
- package/dist/server/client-input.d.ts +2 -0
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +28 -0
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/drain.sql +37 -40
- package/dist/server/envelope.d.ts +5 -9
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +21 -84
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +17 -17
- package/dist/server/lifecycle-recovery.sql +5 -15
- package/dist/server/logEntry.d.ts.map +1 -1
- package/dist/server/logEntry.js +6 -0
- package/dist/server/logEntry.js.map +1 -1
- package/dist/server/logEntry.sql +94 -6
- package/dist/server/module-discovery.d.ts +1 -1
- package/dist/server/module-discovery.d.ts.map +1 -1
- package/dist/server/module-discovery.js +1 -0
- package/dist/server/module-discovery.js.map +1 -1
- package/dist/server/seam-loop.sql +15 -7
- package/dist/server/seam-proposal-list.sql +10 -4
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +7 -1
- package/dist/service.js.map +1 -1
- package/docs/members.md +6 -4
- package/migrations/002_workers.sql +2 -2
- package/migrations/006_log.sql +1 -1
- package/migrations/018_worker_owners.sql +1 -1
- package/migrations/029_default_worker.sql +9 -0
- package/migrations/030_client_workers.sql +105 -0
- package/migrations/031_message_openers.sql +83 -0
- package/migrations/032_worker_references.sql +29 -0
- package/package.json +23 -22
- package/plurnk.nginx.conf +71 -0
- package/plurnk.service +2 -0
package/dist/core/TurnRunner.js
CHANGED
|
@@ -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
|
|
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
|
|
101
|
-
// card's own first NOTE
|
|
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: "
|
|
104
|
-
body:
|
|
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
|
|
115
|
-
emission: "YOU MUST ONLY emit fenced operations; with the parameters, pattern, and terse aside on the fenced
|
|
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
|
|
140
|
+
const outputCut = ({ split, response }, provider) => split.callMetadata.finishReason !== "length"
|
|
126
141
|
? null
|
|
127
|
-
:
|
|
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:
|
|
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 =
|
|
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
|
|
507
|
-
// when the surveys run, one NOTE
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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:
|
|
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
|
|
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 &&
|
|
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:
|
|
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 (
|
|
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:
|
|
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
|
|
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
|
|
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
|
-
// {§
|
|
1533
|
-
//
|
|
1534
|
-
const result = PlurnkParser.parse(assistant.content, { executors,
|
|
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,
|
|
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
|