@nodetool-ai/reliability-harness 0.8.1
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/README.md +34 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/cli.d.ts +73 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +201 -0
- package/dist/cli.js.map +1 -0
- package/dist/compare.d.ts +98 -0
- package/dist/compare.d.ts.map +1 -0
- package/dist/compare.js +267 -0
- package/dist/compare.js.map +1 -0
- package/dist/core/diff.d.ts +39 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/diff.js +114 -0
- package/dist/core/diff.js.map +1 -0
- package/dist/core/golden.d.ts +50 -0
- package/dist/core/golden.d.ts.map +1 -0
- package/dist/core/golden.js +150 -0
- package/dist/core/golden.js.map +1 -0
- package/dist/core/invariants/index.d.ts +32 -0
- package/dist/core/invariants/index.d.ts.map +1 -0
- package/dist/core/invariants/index.js +44 -0
- package/dist/core/invariants/index.js.map +1 -0
- package/dist/core/invariants/leaks.d.ts +22 -0
- package/dist/core/invariants/leaks.d.ts.map +1 -0
- package/dist/core/invariants/leaks.js +55 -0
- package/dist/core/invariants/leaks.js.map +1 -0
- package/dist/core/invariants/lifecycle.d.ts +19 -0
- package/dist/core/invariants/lifecycle.d.ts.map +1 -0
- package/dist/core/invariants/lifecycle.js +95 -0
- package/dist/core/invariants/lifecycle.js.map +1 -0
- package/dist/core/invariants/protocol-validity.d.ts +4 -0
- package/dist/core/invariants/protocol-validity.d.ts.map +1 -0
- package/dist/core/invariants/protocol-validity.js +131 -0
- package/dist/core/invariants/protocol-validity.js.map +1 -0
- package/dist/core/invariants/state-machine.d.ts +29 -0
- package/dist/core/invariants/state-machine.d.ts.map +1 -0
- package/dist/core/invariants/state-machine.js +79 -0
- package/dist/core/invariants/state-machine.js.map +1 -0
- package/dist/core/invariants/status-sets.d.ts +27 -0
- package/dist/core/invariants/status-sets.d.ts.map +1 -0
- package/dist/core/invariants/status-sets.js +51 -0
- package/dist/core/invariants/status-sets.js.map +1 -0
- package/dist/core/invariants/terminal-uniqueness.d.ts +23 -0
- package/dist/core/invariants/terminal-uniqueness.d.ts.map +1 -0
- package/dist/core/invariants/terminal-uniqueness.js +99 -0
- package/dist/core/invariants/terminal-uniqueness.js.map +1 -0
- package/dist/core/invariants/types.d.ts +25 -0
- package/dist/core/invariants/types.d.ts.map +1 -0
- package/dist/core/invariants/types.js +2 -0
- package/dist/core/invariants/types.js.map +1 -0
- package/dist/core/journey.d.ts +121 -0
- package/dist/core/journey.d.ts.map +1 -0
- package/dist/core/journey.js +166 -0
- package/dist/core/journey.js.map +1 -0
- package/dist/core/normalize.d.ts +86 -0
- package/dist/core/normalize.d.ts.map +1 -0
- package/dist/core/normalize.js +182 -0
- package/dist/core/normalize.js.map +1 -0
- package/dist/core/record.d.ts +160 -0
- package/dist/core/record.d.ts.map +1 -0
- package/dist/core/record.js +74 -0
- package/dist/core/record.js.map +1 -0
- package/dist/core/stable-json.d.ts +13 -0
- package/dist/core/stable-json.d.ts.map +1 -0
- package/dist/core/stable-json.js +28 -0
- package/dist/core/stable-json.js.map +1 -0
- package/dist/drivers/anchors.d.ts +29 -0
- package/dist/drivers/anchors.d.ts.map +1 -0
- package/dist/drivers/anchors.js +48 -0
- package/dist/drivers/anchors.js.map +1 -0
- package/dist/drivers/app-headless.d.ts +39 -0
- package/dist/drivers/app-headless.d.ts.map +1 -0
- package/dist/drivers/app-headless.js +123 -0
- package/dist/drivers/app-headless.js.map +1 -0
- package/dist/drivers/browser.d.ts +34 -0
- package/dist/drivers/browser.d.ts.map +1 -0
- package/dist/drivers/browser.js +176 -0
- package/dist/drivers/browser.js.map +1 -0
- package/dist/drivers/cli.d.ts +13 -0
- package/dist/drivers/cli.d.ts.map +1 -0
- package/dist/drivers/cli.js +82 -0
- package/dist/drivers/cli.js.map +1 -0
- package/dist/drivers/fixture-nodes.d.ts +124 -0
- package/dist/drivers/fixture-nodes.d.ts.map +1 -0
- package/dist/drivers/fixture-nodes.js +189 -0
- package/dist/drivers/fixture-nodes.js.map +1 -0
- package/dist/drivers/index.d.ts +18 -0
- package/dist/drivers/index.d.ts.map +1 -0
- package/dist/drivers/index.js +12 -0
- package/dist/drivers/index.js.map +1 -0
- package/dist/drivers/kernel.d.ts +8 -0
- package/dist/drivers/kernel.d.ts.map +1 -0
- package/dist/drivers/kernel.js +247 -0
- package/dist/drivers/kernel.js.map +1 -0
- package/dist/drivers/packaged.d.ts +28 -0
- package/dist/drivers/packaged.d.ts.map +1 -0
- package/dist/drivers/packaged.js +303 -0
- package/dist/drivers/packaged.js.map +1 -0
- package/dist/drivers/python-bridge.d.ts +22 -0
- package/dist/drivers/python-bridge.d.ts.map +1 -0
- package/dist/drivers/python-bridge.js +48 -0
- package/dist/drivers/python-bridge.js.map +1 -0
- package/dist/drivers/registry.d.ts +11 -0
- package/dist/drivers/registry.d.ts.map +1 -0
- package/dist/drivers/registry.js +18 -0
- package/dist/drivers/registry.js.map +1 -0
- package/dist/drivers/relay-fields.d.ts +70 -0
- package/dist/drivers/relay-fields.d.ts.map +1 -0
- package/dist/drivers/relay-fields.js +104 -0
- package/dist/drivers/relay-fields.js.map +1 -0
- package/dist/drivers/repo-root.d.ts +9 -0
- package/dist/drivers/repo-root.d.ts.map +1 -0
- package/dist/drivers/repo-root.js +39 -0
- package/dist/drivers/repo-root.js.map +1 -0
- package/dist/drivers/spawn-cli.d.ts +8 -0
- package/dist/drivers/spawn-cli.d.ts.map +1 -0
- package/dist/drivers/spawn-cli.js +41 -0
- package/dist/drivers/spawn-cli.js.map +1 -0
- package/dist/drivers/types.d.ts +18 -0
- package/dist/drivers/types.d.ts.map +1 -0
- package/dist/drivers/types.js +2 -0
- package/dist/drivers/types.js.map +1 -0
- package/dist/drivers/ws-server.d.ts +8 -0
- package/dist/drivers/ws-server.d.ts.map +1 -0
- package/dist/drivers/ws-server.js +382 -0
- package/dist/drivers/ws-server.js.map +1 -0
- package/dist/faults/bridge-faults.d.ts +7 -0
- package/dist/faults/bridge-faults.d.ts.map +1 -0
- package/dist/faults/bridge-faults.js +90 -0
- package/dist/faults/bridge-faults.js.map +1 -0
- package/dist/faults/host-faults.d.ts +40 -0
- package/dist/faults/host-faults.d.ts.map +1 -0
- package/dist/faults/host-faults.js +70 -0
- package/dist/faults/host-faults.js.map +1 -0
- package/dist/faults/index.d.ts +21 -0
- package/dist/faults/index.d.ts.map +1 -0
- package/dist/faults/index.js +29 -0
- package/dist/faults/index.js.map +1 -0
- package/dist/faults/net-proxy.d.ts +75 -0
- package/dist/faults/net-proxy.d.ts.map +1 -0
- package/dist/faults/net-proxy.js +305 -0
- package/dist/faults/net-proxy.js.map +1 -0
- package/dist/faults/provider-faults.d.ts +12 -0
- package/dist/faults/provider-faults.d.ts.map +1 -0
- package/dist/faults/provider-faults.js +110 -0
- package/dist/faults/provider-faults.js.map +1 -0
- package/dist/faults/registry.d.ts +17 -0
- package/dist/faults/registry.d.ts.map +1 -0
- package/dist/faults/registry.js +15 -0
- package/dist/faults/registry.js.map +1 -0
- package/dist/faults/types.d.ts +42 -0
- package/dist/faults/types.d.ts.map +1 -0
- package/dist/faults/types.js +2 -0
- package/dist/faults/types.js.map +1 -0
- package/dist/faults/ws-faults.d.ts +6 -0
- package/dist/faults/ws-faults.d.ts.map +1 -0
- package/dist/faults/ws-faults.js +48 -0
- package/dist/faults/ws-faults.js.map +1 -0
- package/dist/faults/ws-proxy.d.ts +36 -0
- package/dist/faults/ws-proxy.d.ts.map +1 -0
- package/dist/faults/ws-proxy.js +40 -0
- package/dist/faults/ws-proxy.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Packaged driver (§12) — stages the backend bundle the same way
|
|
3
|
+
* `npm run backend:smoke` does (`scripts/bundle-backend.mjs` +
|
|
4
|
+
* `scripts/smoke-backend-bundle.mjs`'s packaged-module-layout trick), boots
|
|
5
|
+
* the staged `server.mjs` on a free port, and runs the journey against it
|
|
6
|
+
* over the real WS protocol — the same msgpack codec `ws-server.ts` uses
|
|
7
|
+
* (`@nodetool-ai/websocket`'s `packWebSocketMessage`/`unpackWebSocketMessage`
|
|
8
|
+
* is the wire protocol itself, not an internal seam). Journey 15 (§5): "the
|
|
9
|
+
* packaged-backend journey ring".
|
|
10
|
+
*
|
|
11
|
+
* EXPENSIVE: staging alone copies/rewrites hundreds of MB and takes minutes,
|
|
12
|
+
* so `stageBackendBundle` is opt-in — callers (tests, the CLI) gate it behind
|
|
13
|
+
* an env flag (`RELIABILITY_PACKAGED=1`) and otherwise point `bundleDir` at
|
|
14
|
+
* an already-staged tree. The driver itself has no such gate: given a bundle,
|
|
15
|
+
* `run()` always boots it for real.
|
|
16
|
+
*/
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { randomBytes } from "node:crypto";
|
|
19
|
+
import { existsSync } from "node:fs";
|
|
20
|
+
import { mkdtemp, rename, rm } from "node:fs/promises";
|
|
21
|
+
import net from "node:net";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
import { WebSocket } from "ws";
|
|
25
|
+
import { packWebSocketMessage, unpackWebSocketMessage } from "@nodetool-ai/websocket";
|
|
26
|
+
import { makeFrame } from "../core/record.js";
|
|
27
|
+
import { AnchorWaiter } from "./anchors.js";
|
|
28
|
+
import { isConnectionControlMessage, stripRelayOnlyFields } from "./relay-fields.js";
|
|
29
|
+
import { findRepoRoot } from "./repo-root.js";
|
|
30
|
+
const TERMINAL_JOB_STATUSES = new Set(["completed", "failed", "cancelled", "suspended"]);
|
|
31
|
+
const DEFAULT_HEALTH_TIMEOUT_MS = 120_000;
|
|
32
|
+
function freePort() {
|
|
33
|
+
return new Promise((resolvePromise, reject) => {
|
|
34
|
+
const srv = net.createServer();
|
|
35
|
+
srv.on("error", reject);
|
|
36
|
+
srv.listen(0, "127.0.0.1", () => {
|
|
37
|
+
const address = srv.address();
|
|
38
|
+
const port = typeof address === "object" && address !== null ? address.port : 0;
|
|
39
|
+
srv.close(() => resolvePromise(port));
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
44
|
+
/**
|
|
45
|
+
* Stages the backend bundle via the exact entry point `npm run backend:smoke`
|
|
46
|
+
* uses (`npm run prepare-backend --workspace=electron`, i.e.
|
|
47
|
+
* `scripts/bundle-backend.mjs`). Expensive (minutes) — call once per journey
|
|
48
|
+
* session, not per journey.
|
|
49
|
+
*/
|
|
50
|
+
export async function stageBackendBundle(repoRoot = findRepoRoot()) {
|
|
51
|
+
await new Promise((resolvePromise, reject) => {
|
|
52
|
+
const child = spawn("npm", ["run", "prepare-backend", "--workspace=electron"], {
|
|
53
|
+
cwd: repoRoot,
|
|
54
|
+
stdio: "inherit"
|
|
55
|
+
});
|
|
56
|
+
child.on("exit", (code) => {
|
|
57
|
+
if (code === 0)
|
|
58
|
+
resolvePromise();
|
|
59
|
+
else
|
|
60
|
+
reject(new Error(`prepare-backend exited with code ${code}`));
|
|
61
|
+
});
|
|
62
|
+
child.on("error", reject);
|
|
63
|
+
});
|
|
64
|
+
return join(repoRoot, "electron", "backend-bundle");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Electron-builder's `afterPack` promotes the staged `_modules/` to
|
|
68
|
+
* `node_modules/` in the packed app — `_modules` only exists pre-pack to
|
|
69
|
+
* dodge electron-builder's own `node_modules` exclusion rule
|
|
70
|
+
* (`scripts/smoke-backend-bundle.mjs`'s exact comment). Node needs the real
|
|
71
|
+
* name to resolve `server.mjs`'s externals, so this driver does the same
|
|
72
|
+
* rename, and restores it afterward so a staged tree round-trips through a
|
|
73
|
+
* driver run unchanged.
|
|
74
|
+
*/
|
|
75
|
+
async function withPackagedModuleLayout(bundleDir) {
|
|
76
|
+
const staged = join(bundleDir, "_modules");
|
|
77
|
+
const packaged = join(bundleDir, "node_modules");
|
|
78
|
+
if (existsSync(packaged))
|
|
79
|
+
return async () => { };
|
|
80
|
+
if (!existsSync(staged)) {
|
|
81
|
+
throw new Error(`neither _modules/ nor node_modules/ exists in ${bundleDir} — stage it first ` +
|
|
82
|
+
`(npm run prepare-backend --workspace=electron, or stageBackendBundle())`);
|
|
83
|
+
}
|
|
84
|
+
await rename(staged, packaged);
|
|
85
|
+
return async () => {
|
|
86
|
+
await rename(packaged, staged);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function resolveNodeBinary(bundleDir, override) {
|
|
90
|
+
if (override)
|
|
91
|
+
return override;
|
|
92
|
+
const bundled = join(bundleDir, "runtime", process.platform === "win32" ? "node.exe" : "node");
|
|
93
|
+
return existsSync(bundled) ? bundled : process.execPath;
|
|
94
|
+
}
|
|
95
|
+
async function bootServer(bundleDir, nodeBinary, healthTimeoutMs) {
|
|
96
|
+
const restoreModuleLayout = await withPackagedModuleLayout(bundleDir);
|
|
97
|
+
const port = await freePort();
|
|
98
|
+
const dataDir = await mkdtemp(join(tmpdir(), "nodetool-reliability-packaged-"));
|
|
99
|
+
const output = [];
|
|
100
|
+
const child = spawn(nodeBinary, ["server.mjs"], {
|
|
101
|
+
cwd: bundleDir,
|
|
102
|
+
env: {
|
|
103
|
+
...process.env,
|
|
104
|
+
PORT: String(port),
|
|
105
|
+
HOME: dataDir,
|
|
106
|
+
XDG_DATA_HOME: dataDir,
|
|
107
|
+
APPDATA: dataDir,
|
|
108
|
+
SECRETS_MASTER_KEY: randomBytes(32).toString("base64"),
|
|
109
|
+
NODETOOL_LOG_LEVEL: process.env["NODETOOL_LOG_LEVEL"] ?? "warn"
|
|
110
|
+
},
|
|
111
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
112
|
+
});
|
|
113
|
+
child.stdout?.on("data", (buf) => output.push(buf.toString()));
|
|
114
|
+
child.stderr?.on("data", (buf) => output.push(buf.toString()));
|
|
115
|
+
let exited = false;
|
|
116
|
+
child.on("exit", () => {
|
|
117
|
+
exited = true;
|
|
118
|
+
});
|
|
119
|
+
const deadline = Date.now() + healthTimeoutMs;
|
|
120
|
+
let healthy = false;
|
|
121
|
+
while (Date.now() < deadline && !exited && !healthy) {
|
|
122
|
+
await sleep(500);
|
|
123
|
+
try {
|
|
124
|
+
const res = await fetch(`http://127.0.0.1:${port}/health`);
|
|
125
|
+
healthy = res.ok;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Not up yet.
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (!healthy) {
|
|
132
|
+
if (!exited)
|
|
133
|
+
child.kill("SIGKILL");
|
|
134
|
+
await restoreModuleLayout();
|
|
135
|
+
await rm(dataDir, { recursive: true, force: true }).catch(() => { });
|
|
136
|
+
throw new Error(`packaged driver: server.mjs never answered /health within ${healthTimeoutMs}ms\n` +
|
|
137
|
+
`--- server output ---\n${output.join("").trimEnd() || "(no output)"}`);
|
|
138
|
+
}
|
|
139
|
+
return { child, port, output, restoreModuleLayout, dataDir };
|
|
140
|
+
}
|
|
141
|
+
async function teardownServer(server) {
|
|
142
|
+
if (server.child.exitCode === null && server.child.signalCode === null) {
|
|
143
|
+
server.child.kill("SIGTERM");
|
|
144
|
+
const hardKill = setTimeout(() => server.child.kill("SIGKILL"), 10_000);
|
|
145
|
+
await new Promise((resolvePromise) => {
|
|
146
|
+
server.child.once("exit", () => resolvePromise());
|
|
147
|
+
});
|
|
148
|
+
clearTimeout(hardKill);
|
|
149
|
+
}
|
|
150
|
+
await server.restoreModuleLayout();
|
|
151
|
+
await rm(server.dataDir, { recursive: true, force: true }).catch(() => { });
|
|
152
|
+
}
|
|
153
|
+
function requireJobId(jobId, journeyName, action) {
|
|
154
|
+
if (!jobId) {
|
|
155
|
+
throw new Error(`journey "${journeyName}": "${action}" interaction fired before a job_id was observed`);
|
|
156
|
+
}
|
|
157
|
+
return jobId;
|
|
158
|
+
}
|
|
159
|
+
export class PackagedDriver {
|
|
160
|
+
options;
|
|
161
|
+
name = "packaged";
|
|
162
|
+
constructor(options = {}) {
|
|
163
|
+
this.options = options;
|
|
164
|
+
}
|
|
165
|
+
/** True when a bundle is staged at the configured (or default) location. */
|
|
166
|
+
isStaged() {
|
|
167
|
+
const bundleDir = this.options.bundleDir ?? join(findRepoRoot(), "electron", "backend-bundle");
|
|
168
|
+
return existsSync(join(bundleDir, "server.mjs"));
|
|
169
|
+
}
|
|
170
|
+
async run(journey) {
|
|
171
|
+
const bundleDir = this.options.bundleDir ?? join(findRepoRoot(), "electron", "backend-bundle");
|
|
172
|
+
if (!existsSync(join(bundleDir, "server.mjs"))) {
|
|
173
|
+
throw new Error(`packaged driver: no staged bundle at ${bundleDir} — run ` +
|
|
174
|
+
`stageBackendBundle() or 'npm run prepare-backend --workspace=electron' first`);
|
|
175
|
+
}
|
|
176
|
+
const nodeBinary = resolveNodeBinary(bundleDir, this.options.nodeBinary);
|
|
177
|
+
const server = await bootServer(bundleDir, nodeBinary, this.options.healthTimeoutMs ?? DEFAULT_HEALTH_TIMEOUT_MS);
|
|
178
|
+
const frames = [];
|
|
179
|
+
let seq = 0;
|
|
180
|
+
const waiter = new AnchorWaiter();
|
|
181
|
+
let jobId = null;
|
|
182
|
+
let terminalStatus = null;
|
|
183
|
+
let terminalError = null;
|
|
184
|
+
const seenJobUpdateStatuses = new Set();
|
|
185
|
+
let resolveTerminal;
|
|
186
|
+
const terminalPromise = new Promise((resolvePromise) => {
|
|
187
|
+
resolveTerminal = resolvePromise;
|
|
188
|
+
});
|
|
189
|
+
const ws = new WebSocket(`ws://127.0.0.1:${server.port}/ws`);
|
|
190
|
+
ws.on("message", (data, isBinary) => {
|
|
191
|
+
const raw = (isBinary ? unpackWebSocketMessage(data) : JSON.parse(data.toString("utf8")));
|
|
192
|
+
// The packaged server is a relay, exactly like `ws-server.ts`'s surface:
|
|
193
|
+
// it boots the real `server.mjs`, whose Fastify plugin announces the
|
|
194
|
+
// connection and whose `WebSocketClientSession` backfills run identity
|
|
195
|
+
// onto frames the kernel oracle emits bare. Both are cancelled here so
|
|
196
|
+
// the packaged stream is comparable to the oracle frame-for-frame.
|
|
197
|
+
if (isConnectionControlMessage(raw))
|
|
198
|
+
return;
|
|
199
|
+
const message = stripRelayOnlyFields(raw);
|
|
200
|
+
waiter.notify(message);
|
|
201
|
+
if (typeof message["job_id"] === "string") {
|
|
202
|
+
jobId = message["job_id"];
|
|
203
|
+
}
|
|
204
|
+
if (typeof message["type"] !== "string")
|
|
205
|
+
return;
|
|
206
|
+
if (message["type"] === "job_update") {
|
|
207
|
+
const status = String(message["status"]);
|
|
208
|
+
if (seenJobUpdateStatuses.has(status))
|
|
209
|
+
return;
|
|
210
|
+
seenJobUpdateStatuses.add(status);
|
|
211
|
+
if (TERMINAL_JOB_STATUSES.has(status)) {
|
|
212
|
+
terminalStatus = status;
|
|
213
|
+
terminalError =
|
|
214
|
+
typeof message["error"] === "string" ? message["error"] : null;
|
|
215
|
+
frames.push(makeFrame(seq++, "packaged", "server_to_client", message));
|
|
216
|
+
resolveTerminal();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
frames.push(makeFrame(seq++, "packaged", "server_to_client", message));
|
|
221
|
+
});
|
|
222
|
+
try {
|
|
223
|
+
await new Promise((resolvePromise, reject) => {
|
|
224
|
+
ws.once("open", () => resolvePromise());
|
|
225
|
+
ws.once("error", reject);
|
|
226
|
+
});
|
|
227
|
+
const send = (command, data) => {
|
|
228
|
+
const envelope = { command, data };
|
|
229
|
+
frames.push(makeFrame(seq++, "packaged", "client_to_server", envelope));
|
|
230
|
+
ws.send(packWebSocketMessage(envelope));
|
|
231
|
+
};
|
|
232
|
+
const interactions = journey.interactions.length > 0 ? journey.interactions : [{ action: "run" }];
|
|
233
|
+
for (const interaction of interactions) {
|
|
234
|
+
if (interaction.at) {
|
|
235
|
+
await waiter.wait(interaction.at);
|
|
236
|
+
}
|
|
237
|
+
switch (interaction.action) {
|
|
238
|
+
case "run":
|
|
239
|
+
send("run_job", {
|
|
240
|
+
graph: journey.workflow,
|
|
241
|
+
workflow_id: journey.manifest.name,
|
|
242
|
+
params: journey.manifest.params,
|
|
243
|
+
execution_options: { persistence: "session" }
|
|
244
|
+
});
|
|
245
|
+
break;
|
|
246
|
+
case "cancel":
|
|
247
|
+
send("cancel_job", {
|
|
248
|
+
job_id: requireJobId(jobId, journey.manifest.name, "cancel")
|
|
249
|
+
});
|
|
250
|
+
break;
|
|
251
|
+
case "stream_input":
|
|
252
|
+
if (!interaction.nodeId) {
|
|
253
|
+
throw new Error(`journey "${journey.manifest.name}": "stream_input" interaction needs nodeId`);
|
|
254
|
+
}
|
|
255
|
+
send("stream_input", {
|
|
256
|
+
job_id: requireJobId(jobId, journey.manifest.name, "stream_input"),
|
|
257
|
+
input: interaction.nodeId,
|
|
258
|
+
value: interaction.value
|
|
259
|
+
});
|
|
260
|
+
break;
|
|
261
|
+
case "end_input_stream":
|
|
262
|
+
if (!interaction.nodeId) {
|
|
263
|
+
throw new Error(`journey "${journey.manifest.name}": "end_input_stream" interaction needs nodeId`);
|
|
264
|
+
}
|
|
265
|
+
send("end_input_stream", {
|
|
266
|
+
job_id: requireJobId(jobId, journey.manifest.name, "end_input_stream"),
|
|
267
|
+
input: interaction.nodeId
|
|
268
|
+
});
|
|
269
|
+
break;
|
|
270
|
+
case "reconnect":
|
|
271
|
+
throw new Error(`journey "${journey.manifest.name}": packaged driver does not support ` +
|
|
272
|
+
`the "reconnect" interaction`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const timeoutMs = journey.manifest.timeoutMs + 30_000;
|
|
276
|
+
await Promise.race([
|
|
277
|
+
terminalPromise,
|
|
278
|
+
sleep(timeoutMs).then(() => {
|
|
279
|
+
throw new Error(`journey "${journey.manifest.name}": packaged driver timed out after ${timeoutMs}ms ` +
|
|
280
|
+
`waiting for a terminal job_update`);
|
|
281
|
+
})
|
|
282
|
+
]);
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
ws.close();
|
|
286
|
+
await teardownServer(server);
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
journeyId: journey.manifest.name,
|
|
290
|
+
surface: this.name,
|
|
291
|
+
jobId,
|
|
292
|
+
workflowId: journey.manifest.name,
|
|
293
|
+
startedAt: frames.length > 0 ? frames[0].ts : null,
|
|
294
|
+
finishedAt: frames.length > 0 ? frames[frames.length - 1].ts : null,
|
|
295
|
+
durationMs: null,
|
|
296
|
+
status: terminalStatus ?? "unknown",
|
|
297
|
+
error: terminalError,
|
|
298
|
+
params: journey.manifest.params,
|
|
299
|
+
frames
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=packaged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packaged.js","sourceRoot":"","sources":["../../src/drivers/packaged.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEtF,OAAO,EAAE,SAAS,EAAiC,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CA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shim `PythonStdioBridge` spawns in place of a real
|
|
3
|
+
* `python` (see `packages/runtime/tests/fixtures/fake-python-interpreter.mjs`
|
|
4
|
+
* for why the indirection over the fixture worker exists). */
|
|
5
|
+
export declare function fakePythonInterpreterPath(): string;
|
|
6
|
+
/** Journeys never wait on a real Python install, so a misbehaving (or
|
|
7
|
+
* deliberately never-ready) fake should fail fast instead of eating a
|
|
8
|
+
* journey's `timeoutMs` budget. */
|
|
9
|
+
export declare const FAKE_BRIDGE_STARTUP_TIMEOUT_MS = 3000;
|
|
10
|
+
/**
|
|
11
|
+
* `BridgeFactory` (`@nodetool-ai/execution`'s facade hook) that spawns the
|
|
12
|
+
* faithful stdio fake instead of a real Python worker whenever a journey's
|
|
13
|
+
* graph contains a node type the TS registry can't resolve. Reused
|
|
14
|
+
* unmodified by every `bridge-*` fault — those faults act by setting the
|
|
15
|
+
* `FAKE_WORKER_*` env vars the fake fixture reads, not by changing this
|
|
16
|
+
* factory. Both the kernel driver (directly, as `ExecutionSession`'s
|
|
17
|
+
* `bridgeFactory`) and the ws-server driver (via its own `resolveExecutor`,
|
|
18
|
+
* `connectPythonBridgeForGraph` isn't wired into `WebSocketClientSession`
|
|
19
|
+
* automatically the way it is into `ExecutionSession`) use this one factory.
|
|
20
|
+
*/
|
|
21
|
+
export declare const journeyPythonBridgeFactory: BridgeFactory;
|
|
22
|
+
//# sourceMappingURL=python-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python-bridge.d.ts","sourceRoot":"","sources":["../../src/drivers/python-bridge.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D;;8DAE8D;AAC9D,wBAAgB,yBAAyB,IAAI,MAAM,CASlD;AAED;;mCAEmC;AACnC,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,EAAE,aAOrC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Python-bridge wiring for journey 7 (`python-node-workflow`) and
|
|
3
|
+
* task D3's `bridge-*` fault modules (`faults/bridge-faults.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Both the kernel driver and the ws-server driver route any graph node type
|
|
6
|
+
* the TS registry can't resolve to E2's faithful stdio fake
|
|
7
|
+
* (`packages/runtime/tests/fixtures/fake-python-stdio-worker.ts`) — the same
|
|
8
|
+
* fake `python-stdio-bridge.test.ts` drives directly — launched through the
|
|
9
|
+
* same `fake-python-interpreter.mjs` shim, never the real
|
|
10
|
+
* `python -m nodetool.worker --stdio`. `connectPythonBridgeForGraph`
|
|
11
|
+
* (`@nodetool-ai/runtime`) already gates the spawn on "does this graph
|
|
12
|
+
* actually contain an unresolved node type", so wiring this factory in as
|
|
13
|
+
* the default for every journey (not just journey 7) costs nothing: a graph
|
|
14
|
+
* built entirely from real TS nodes never triggers a spawn.
|
|
15
|
+
*
|
|
16
|
+
* Fault modules act purely by setting the `FAKE_WORKER_*` env vars the fake
|
|
17
|
+
* fixture reads (ambient, exactly like `python-stdio-bridge.test.ts`'s own
|
|
18
|
+
* `makeBridge` helper) — this factory never changes.
|
|
19
|
+
*/
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
import { connectPythonBridgeForGraph } from "@nodetool-ai/runtime";
|
|
22
|
+
import { findRepoRoot } from "./repo-root.js";
|
|
23
|
+
/** The interpreter shim `PythonStdioBridge` spawns in place of a real
|
|
24
|
+
* `python` (see `packages/runtime/tests/fixtures/fake-python-interpreter.mjs`
|
|
25
|
+
* for why the indirection over the fixture worker exists). */
|
|
26
|
+
export function fakePythonInterpreterPath() {
|
|
27
|
+
return join(findRepoRoot(), "packages", "runtime", "tests", "fixtures", "fake-python-interpreter.mjs");
|
|
28
|
+
}
|
|
29
|
+
/** Journeys never wait on a real Python install, so a misbehaving (or
|
|
30
|
+
* deliberately never-ready) fake should fail fast instead of eating a
|
|
31
|
+
* journey's `timeoutMs` budget. */
|
|
32
|
+
export const FAKE_BRIDGE_STARTUP_TIMEOUT_MS = 3000;
|
|
33
|
+
/**
|
|
34
|
+
* `BridgeFactory` (`@nodetool-ai/execution`'s facade hook) that spawns the
|
|
35
|
+
* faithful stdio fake instead of a real Python worker whenever a journey's
|
|
36
|
+
* graph contains a node type the TS registry can't resolve. Reused
|
|
37
|
+
* unmodified by every `bridge-*` fault — those faults act by setting the
|
|
38
|
+
* `FAKE_WORKER_*` env vars the fake fixture reads, not by changing this
|
|
39
|
+
* factory. Both the kernel driver (directly, as `ExecutionSession`'s
|
|
40
|
+
* `bridgeFactory`) and the ws-server driver (via its own `resolveExecutor`,
|
|
41
|
+
* `connectPythonBridgeForGraph` isn't wired into `WebSocketClientSession`
|
|
42
|
+
* automatically the way it is into `ExecutionSession`) use this one factory.
|
|
43
|
+
*/
|
|
44
|
+
export const journeyPythonBridgeFactory = (nodes, hasTsExecutor) => connectPythonBridgeForGraph(nodes, hasTsExecutor, {
|
|
45
|
+
pythonPath: fakePythonInterpreterPath(),
|
|
46
|
+
startupTimeoutMs: FAKE_BRIDGE_STARTUP_TIMEOUT_MS
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=python-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python-bridge.js","sourceRoot":"","sources":["../../src/drivers/python-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;8DAE8D;AAC9D,MAAM,UAAU,yBAAyB;IACvC,OAAO,IAAI,CACT,YAAY,EAAE,EACd,UAAU,EACV,SAAS,EACT,OAAO,EACP,UAAU,EACV,6BAA6B,CAC9B,CAAC;AACJ,CAAC;AAED;;mCAEmC;AACnC,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAkB,CACvD,KAAK,EACL,aAAa,EACb,EAAE,CACF,2BAA2B,CAAC,KAAK,EAAE,aAAa,EAAE;IAChD,UAAU,EAAE,yBAAyB,EAAE;IACvC,gBAAgB,EAAE,8BAA8B;CACjD,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node registry shared by the kernel driver and, via `registerFixtureNodes`,
|
|
3
|
+
* added onto the ws-server driver's own registry — the same real node
|
|
4
|
+
* classes (`registerBaseNodes`) run on both surfaces, so journeys exercise
|
|
5
|
+
* identical node behavior everywhere. See `fixture-nodes.ts` for the three
|
|
6
|
+
* nodes neither surface's real registry has.
|
|
7
|
+
*/
|
|
8
|
+
import { NodeRegistry } from "@nodetool-ai/node-sdk";
|
|
9
|
+
/** Fresh registry for one kernel-driver run: real base nodes + harness fixtures. */
|
|
10
|
+
export declare function buildJourneyRegistry(): NodeRegistry;
|
|
11
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/drivers/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,oFAAoF;AACpF,wBAAgB,oBAAoB,IAAI,YAAY,CAKnD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node registry shared by the kernel driver and, via `registerFixtureNodes`,
|
|
3
|
+
* added onto the ws-server driver's own registry — the same real node
|
|
4
|
+
* classes (`registerBaseNodes`) run on both surfaces, so journeys exercise
|
|
5
|
+
* identical node behavior everywhere. See `fixture-nodes.ts` for the three
|
|
6
|
+
* nodes neither surface's real registry has.
|
|
7
|
+
*/
|
|
8
|
+
import { NodeRegistry } from "@nodetool-ai/node-sdk";
|
|
9
|
+
import { registerBaseNodes } from "@nodetool-ai/base-nodes";
|
|
10
|
+
import { registerFixtureNodes } from "./fixture-nodes.js";
|
|
11
|
+
/** Fresh registry for one kernel-driver run: real base nodes + harness fixtures. */
|
|
12
|
+
export function buildJourneyRegistry() {
|
|
13
|
+
const registry = new NodeRegistry();
|
|
14
|
+
registerBaseNodes(registry);
|
|
15
|
+
registerFixtureNodes(registry);
|
|
16
|
+
return registry;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/drivers/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,oFAAoF;AACpF,MAAM,UAAU,oBAAoB;IAClC,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IACpC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay-only field policy, shared by every driver whose surface speaks the
|
|
3
|
+
* WS wire protocol (`ws-server.ts`, `packaged.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Both of those surfaces run the same relay — `WebSocketClientSession` — so
|
|
6
|
+
* both receive the same downstream enrichment the kernel oracle's raw stream
|
|
7
|
+
* never carries. `packages/protocol/src/messages.ts` specifies this: `job_id`
|
|
8
|
+
* is "Stamped downstream by the relay (the unified websocket runner and the
|
|
9
|
+
* browser runner), not by the kernel actor, so it is optional on the wire",
|
|
10
|
+
* and `generation_complete` is emitted by the actor as "a BARE event" with
|
|
11
|
+
* `job_id` and `index` "stamped DOWNSTREAM by the relay".
|
|
12
|
+
*
|
|
13
|
+
* Lives here rather than in each driver because a rule that only one relay
|
|
14
|
+
* surface applies is not a policy, it is a discrepancy — `packaged.ts` not
|
|
15
|
+
* having it is exactly what made the Ring 2 release gate unpassable.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Message `type`s the relay backfills `job_id` onto uniformly (its "outbound
|
|
19
|
+
* spread", `websocket-client-session.ts`) that the kernel's own emissions for
|
|
20
|
+
* these types (`runner.ts`/`actor.ts`) never carry at all. Scoped per-type
|
|
21
|
+
* (not a blanket drop) because `job_update` DOES set both, and `edge_update`
|
|
22
|
+
* DOES set `job_id`, on the raw kernel stream too — dropping either there
|
|
23
|
+
* would hide a real regression instead of a harmless relay addition. Kept as
|
|
24
|
+
* a driver-local rule (not a `normalize.ts` field list) because
|
|
25
|
+
* `normalize.ts`'s generic per-key visitor has other callers — including its
|
|
26
|
+
* own unit tests — that legitimately expect `job_id`/`workflow_id` preserved
|
|
27
|
+
* on a `node_update`. The relay drivers are the only place that actually
|
|
28
|
+
* knows which of these are relay-only enrichment on their wire protocol.
|
|
29
|
+
*/
|
|
30
|
+
export declare const RELAY_ONLY_JOB_ID_TYPES: ReadonlySet<string>;
|
|
31
|
+
/** As {@link RELAY_ONLY_JOB_ID_TYPES}, for `workflow_id`. Includes
|
|
32
|
+
* `edge_update` — the kernel stamps `job_id` there but never `workflow_id`. */
|
|
33
|
+
export declare const RELAY_ONLY_WORKFLOW_ID_TYPES: ReadonlySet<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Message `type`s that exist only as connection-scoped transport control and
|
|
36
|
+
* are never part of a run's stream. `sdk_execution_target` is sent once per
|
|
37
|
+
* socket, at upgrade time and BEFORE any workflow is submitted, by the
|
|
38
|
+
* production Fastify plugin when an SDK live-runner registry is wired
|
|
39
|
+
* (`packages/websocket/src/plugins/websocket.ts`). `renderer_registered` is
|
|
40
|
+
* the same shape for the frontend-renderer registry: sent once per socket
|
|
41
|
+
* right after `connect()`, naming a `renderer_id` no other surface has
|
|
42
|
+
* anything to compare against. The kernel oracle has no connection to
|
|
43
|
+
* announce, so there is nothing to compare either against.
|
|
44
|
+
*
|
|
45
|
+
* The rest are the relay's own timers and observers, which fire on wall-clock
|
|
46
|
+
* cadence rather than on anything the run does
|
|
47
|
+
* (`websocket-client-session.ts`): `system_stats` ~1s after connect and every
|
|
48
|
+
* 5s after, `ping` every 25s, `pong` in reply to a client ping,
|
|
49
|
+
* `resource_change` whenever a model or resource event lands. Whether one of
|
|
50
|
+
* them interleaves into a run depends on how long the run happens to take, so
|
|
51
|
+
* recording them makes the stream non-deterministic —
|
|
52
|
+
* a `system_stats` landing mid-run is what failed `linear-text-pipeline` on
|
|
53
|
+
* the packaged surface in Ring 1 (run 31619279663), which in turn blocked
|
|
54
|
+
* the Fly deploy of 2868cffe. They are all outbound *control* frames in the
|
|
55
|
+
* protocol's own taxonomy (`outboundControlMessageSchemas`), not
|
|
56
|
+
* `ProcessingMessage`s, so no run assertion loses coverage by dropping them.
|
|
57
|
+
*/
|
|
58
|
+
export declare const CONNECTION_CONTROL_MESSAGE_TYPES: ReadonlySet<string>;
|
|
59
|
+
/** True when `message` is transport control rather than a run frame — callers
|
|
60
|
+
* drop these before recording (see {@link CONNECTION_CONTROL_MESSAGE_TYPES}). */
|
|
61
|
+
export declare function isConnectionControlMessage(message: Record<string, unknown>): boolean;
|
|
62
|
+
/** Strips fields the relay adds that the kernel driver's raw stream never has,
|
|
63
|
+
* so the two are comparable frame-for-frame (see
|
|
64
|
+
* {@link RELAY_ONLY_JOB_ID_TYPES}/{@link RELAY_ONLY_WORKFLOW_ID_TYPES}).
|
|
65
|
+
* `generation_complete.index` is the same kind of addition — an
|
|
66
|
+
* arrival-order stamp (`websocket-client-session.ts`'s
|
|
67
|
+
* `generationIndexByNode`) the kernel's own `generation_complete` emission
|
|
68
|
+
* never sets. */
|
|
69
|
+
export declare function stripRelayOnlyFields(message: Record<string, unknown>): Record<string, unknown>;
|
|
70
|
+
//# sourceMappingURL=relay-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-fields.d.ts","sourceRoot":"","sources":["../../src/drivers/relay-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAStD,CAAC;AAEH;+EAC+E;AAC/E,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,CAM3D,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,gCAAgC,EAAE,WAAW,CAAC,MAAM,CAO/D,CAAC;AAEH;iFACiF;AACjF,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAEpF;AAED;;;;;;iBAMiB;AACjB,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay-only field policy, shared by every driver whose surface speaks the
|
|
3
|
+
* WS wire protocol (`ws-server.ts`, `packaged.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Both of those surfaces run the same relay — `WebSocketClientSession` — so
|
|
6
|
+
* both receive the same downstream enrichment the kernel oracle's raw stream
|
|
7
|
+
* never carries. `packages/protocol/src/messages.ts` specifies this: `job_id`
|
|
8
|
+
* is "Stamped downstream by the relay (the unified websocket runner and the
|
|
9
|
+
* browser runner), not by the kernel actor, so it is optional on the wire",
|
|
10
|
+
* and `generation_complete` is emitted by the actor as "a BARE event" with
|
|
11
|
+
* `job_id` and `index` "stamped DOWNSTREAM by the relay".
|
|
12
|
+
*
|
|
13
|
+
* Lives here rather than in each driver because a rule that only one relay
|
|
14
|
+
* surface applies is not a policy, it is a discrepancy — `packaged.ts` not
|
|
15
|
+
* having it is exactly what made the Ring 2 release gate unpassable.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Message `type`s the relay backfills `job_id` onto uniformly (its "outbound
|
|
19
|
+
* spread", `websocket-client-session.ts`) that the kernel's own emissions for
|
|
20
|
+
* these types (`runner.ts`/`actor.ts`) never carry at all. Scoped per-type
|
|
21
|
+
* (not a blanket drop) because `job_update` DOES set both, and `edge_update`
|
|
22
|
+
* DOES set `job_id`, on the raw kernel stream too — dropping either there
|
|
23
|
+
* would hide a real regression instead of a harmless relay addition. Kept as
|
|
24
|
+
* a driver-local rule (not a `normalize.ts` field list) because
|
|
25
|
+
* `normalize.ts`'s generic per-key visitor has other callers — including its
|
|
26
|
+
* own unit tests — that legitimately expect `job_id`/`workflow_id` preserved
|
|
27
|
+
* on a `node_update`. The relay drivers are the only place that actually
|
|
28
|
+
* knows which of these are relay-only enrichment on their wire protocol.
|
|
29
|
+
*/
|
|
30
|
+
export const RELAY_ONLY_JOB_ID_TYPES = new Set([
|
|
31
|
+
"node_update",
|
|
32
|
+
"generation_complete",
|
|
33
|
+
"output_update",
|
|
34
|
+
// `llm_call` (task D1, journey 8 — the first journey to run a real LLM
|
|
35
|
+
// node): the relay backfills `job_id`/`workflow_id` here the same way it
|
|
36
|
+
// does for `node_update`; the kernel's own `llm_call` emission
|
|
37
|
+
// (`BaseProvider`'s tracing helper) never carries either.
|
|
38
|
+
"llm_call"
|
|
39
|
+
]);
|
|
40
|
+
/** As {@link RELAY_ONLY_JOB_ID_TYPES}, for `workflow_id`. Includes
|
|
41
|
+
* `edge_update` — the kernel stamps `job_id` there but never `workflow_id`. */
|
|
42
|
+
export const RELAY_ONLY_WORKFLOW_ID_TYPES = new Set([
|
|
43
|
+
"node_update",
|
|
44
|
+
"generation_complete",
|
|
45
|
+
"output_update",
|
|
46
|
+
"edge_update",
|
|
47
|
+
"llm_call"
|
|
48
|
+
]);
|
|
49
|
+
/**
|
|
50
|
+
* Message `type`s that exist only as connection-scoped transport control and
|
|
51
|
+
* are never part of a run's stream. `sdk_execution_target` is sent once per
|
|
52
|
+
* socket, at upgrade time and BEFORE any workflow is submitted, by the
|
|
53
|
+
* production Fastify plugin when an SDK live-runner registry is wired
|
|
54
|
+
* (`packages/websocket/src/plugins/websocket.ts`). `renderer_registered` is
|
|
55
|
+
* the same shape for the frontend-renderer registry: sent once per socket
|
|
56
|
+
* right after `connect()`, naming a `renderer_id` no other surface has
|
|
57
|
+
* anything to compare against. The kernel oracle has no connection to
|
|
58
|
+
* announce, so there is nothing to compare either against.
|
|
59
|
+
*
|
|
60
|
+
* The rest are the relay's own timers and observers, which fire on wall-clock
|
|
61
|
+
* cadence rather than on anything the run does
|
|
62
|
+
* (`websocket-client-session.ts`): `system_stats` ~1s after connect and every
|
|
63
|
+
* 5s after, `ping` every 25s, `pong` in reply to a client ping,
|
|
64
|
+
* `resource_change` whenever a model or resource event lands. Whether one of
|
|
65
|
+
* them interleaves into a run depends on how long the run happens to take, so
|
|
66
|
+
* recording them makes the stream non-deterministic —
|
|
67
|
+
* a `system_stats` landing mid-run is what failed `linear-text-pipeline` on
|
|
68
|
+
* the packaged surface in Ring 1 (run 31619279663), which in turn blocked
|
|
69
|
+
* the Fly deploy of 2868cffe. They are all outbound *control* frames in the
|
|
70
|
+
* protocol's own taxonomy (`outboundControlMessageSchemas`), not
|
|
71
|
+
* `ProcessingMessage`s, so no run assertion loses coverage by dropping them.
|
|
72
|
+
*/
|
|
73
|
+
export const CONNECTION_CONTROL_MESSAGE_TYPES = new Set([
|
|
74
|
+
"sdk_execution_target",
|
|
75
|
+
"renderer_registered",
|
|
76
|
+
"system_stats",
|
|
77
|
+
"resource_change",
|
|
78
|
+
"ping",
|
|
79
|
+
"pong"
|
|
80
|
+
]);
|
|
81
|
+
/** True when `message` is transport control rather than a run frame — callers
|
|
82
|
+
* drop these before recording (see {@link CONNECTION_CONTROL_MESSAGE_TYPES}). */
|
|
83
|
+
export function isConnectionControlMessage(message) {
|
|
84
|
+
return CONNECTION_CONTROL_MESSAGE_TYPES.has(String(message["type"]));
|
|
85
|
+
}
|
|
86
|
+
/** Strips fields the relay adds that the kernel driver's raw stream never has,
|
|
87
|
+
* so the two are comparable frame-for-frame (see
|
|
88
|
+
* {@link RELAY_ONLY_JOB_ID_TYPES}/{@link RELAY_ONLY_WORKFLOW_ID_TYPES}).
|
|
89
|
+
* `generation_complete.index` is the same kind of addition — an
|
|
90
|
+
* arrival-order stamp (`websocket-client-session.ts`'s
|
|
91
|
+
* `generationIndexByNode`) the kernel's own `generation_complete` emission
|
|
92
|
+
* never sets. */
|
|
93
|
+
export function stripRelayOnlyFields(message) {
|
|
94
|
+
const type = String(message["type"]);
|
|
95
|
+
const rest = { ...message };
|
|
96
|
+
if (RELAY_ONLY_JOB_ID_TYPES.has(type))
|
|
97
|
+
delete rest["job_id"];
|
|
98
|
+
if (RELAY_ONLY_WORKFLOW_ID_TYPES.has(type))
|
|
99
|
+
delete rest["workflow_id"];
|
|
100
|
+
if (type === "generation_complete")
|
|
101
|
+
delete rest["index"];
|
|
102
|
+
return rest;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=relay-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-fields.js","sourceRoot":"","sources":["../../src/drivers/relay-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAClE,aAAa;IACb,qBAAqB;IACrB,eAAe;IACf,uEAAuE;IACvE,yEAAyE;IACzE,+DAA+D;IAC/D,0DAA0D;IAC1D,UAAU;CACX,CAAC,CAAC;AAEH;+EAC+E;AAC/E,MAAM,CAAC,MAAM,4BAA4B,GAAwB,IAAI,GAAG,CAAC;IACvE,aAAa;IACb,qBAAqB;IACrB,eAAe;IACf,aAAa;IACb,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAwB,IAAI,GAAG,CAAC;IAC3E,sBAAsB;IACtB,qBAAqB;IACrB,cAAc;IACd,iBAAiB;IACjB,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH;iFACiF;AACjF,MAAM,UAAU,0BAA0B,CAAC,OAAgC;IACzE,OAAO,gCAAgC,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;;iBAMiB;AACjB,MAAM,UAAU,oBAAoB,CAClC,OAAgC;IAEhC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;IAC5B,IAAI,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7D,IAAI,4BAA4B,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC;IACvE,IAAI,IAAI,KAAK,qBAAqB;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Walks up from this module to the checked-out repo root (the directory
|
|
2
|
+
* whose `packages/cli/src/nodetool.ts` exists) — works from both `src/`
|
|
3
|
+
* (ts-node/tsx dev) and `dist/` (built) locations since it only depends on
|
|
4
|
+
* directory depth, not file extension. */
|
|
5
|
+
export declare function findRepoRoot(): string;
|
|
6
|
+
/** The workspace-hoisted `tsx` binary, falling back to a bare `tsx` for a
|
|
7
|
+
* shell to resolve if the root install ever changes shape. */
|
|
8
|
+
export declare function resolveTsxBin(repoRoot: string): string;
|
|
9
|
+
//# sourceMappingURL=repo-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-root.d.ts","sourceRoot":"","sources":["../../src/drivers/repo-root.ts"],"names":[],"mappings":"AAcA;;;0CAG0C;AAC1C,wBAAgB,YAAY,IAAI,MAAM,CAerC;AAED;8DAC8D;AAC9D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQtD"}
|