feat(web-probe): add typed Kafka live fanout validation

This commit is contained in:
Codex
2026-07-10 11:52:05 +02:00
parent b9e804014b
commit a496268713
20 changed files with 1544 additions and 25 deletions
@@ -0,0 +1,70 @@
import assert from "node:assert/strict";
import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { test } from "bun:test";
import { nodeWebObserveStatusNodeScript } from "./web-observe-scripts";
async function runStatusScript(stateDir: string, commandId: string): Promise<Record<string, any>> {
const child = Bun.spawn(["bash", "-lc", nodeWebObserveStatusNodeScript(1, "NC01", "v03", commandId)], {
env: { ...process.env, state_dir: stateDir },
stdout: "pipe",
stderr: "pipe",
});
const [stdout, stderr, exitCode] = await Promise.all([
new Response(child.stdout).text(),
new Response(child.stderr).text(),
child.exited,
]);
assert.equal(exitCode, 0, stderr);
return JSON.parse(stdout) as Record<string, any>;
}
test("observe status returns one exact completed command without prompt payloads", async () => {
const stateDir = await mkdtemp(join(tmpdir(), "unidesk-web-observe-exact-status-"));
const commandId = "cmd-fixture";
await mkdir(join(stateDir, "commands", "done"), { recursive: true });
await mkdir(join(stateDir, "commands", "processing"), { recursive: true });
await writeFile(join(stateDir, "commands", "done", `${commandId}.json`), JSON.stringify({
ok: true,
commandId,
type: "validateRealtimeFanout",
completedAt: "2026-07-10T12:00:00.000Z",
result: {
ok: true,
status: "passed",
profile: "pure-kafka-live",
sessionId: "ses_fixture",
traceIds: ["trc_first", "trc_second"],
runIds: ["run_fixture"],
commandIds: ["cmd_runner_first", "cmd_runner_second"],
reportPath: "/tmp/report.json",
reportSha256: "sha256:fixture",
prompt: "must-not-leak",
},
}) + "\n");
await writeFile(join(stateDir, "commands", "processing", `${commandId}.json`), JSON.stringify({
ok: null,
commandId,
type: "validateRealtimeFanout",
}) + "\n");
const status = await runStatusScript(stateDir, commandId);
assert.equal(status.exactCommand.phase, "done");
assert.equal(status.exactCommand.type, "validateRealtimeFanout");
assert.equal(status.exactCommand.result.reportSha256, "sha256:fixture");
assert.equal(status.exactCommand.result.prompt, undefined);
assert.equal(status.exactCommand.valuesRedacted, true);
});
test("observe status keeps exact command not-found structured", async () => {
const stateDir = await mkdtemp(join(tmpdir(), "unidesk-web-observe-exact-missing-"));
const status = await runStatusScript(stateDir, "cmd-missing");
assert.deepEqual(status.exactCommand, {
commandId: "cmd-missing",
phase: "not-found",
ok: false,
valuesRedacted: true,
});
});