The version probe writes nothing to the state root; existing tests learn the new backend and routes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-24 20:33:13 +02:00
commit f38f420df1
2 changed files with 18 additions and 13 deletions

View file

@ -230,7 +230,7 @@ test("every flag has an environment twin, and the thread cap defaults to 8", asy
assert.equal(answer.body.worker.env.OMP_NUM_THREADS, "16");
assert.deepEqual(await backendOf(viaEnv), {
state: "ready", pid: answer.body.worker.pid, port: (await backendOf(viaEnv)).port, threads: 16, pythonEnv: "test-env",
kimodoCommit: "abc1234", modelsRoot: viaEnv.modelsRoot, lastError: null,
kimodoCommit: "abc1234", modelsRoot: viaEnv.modelsRoot, lastError: null, blender: "Blender 0.0.0 (stub)",
});
} finally {
await viaEnv.stop();
@ -701,7 +701,7 @@ test("health, operator state and the unknown", async () => {
assert.equal(unknown.raw, "not found\n");
const state = await operatorState(daemon);
assert.equal(state.host, os.hostname());
assert.deepEqual(Object.keys(state.routes), ["health", "operatorState", "generate"]);
assert.deepEqual(Object.keys(state.routes), ["health", "operatorState", "generate", "artifacts", "restFbx"]);
} finally {
await daemon.stop();
}
@ -1463,7 +1463,7 @@ test("a failing or hung Blender fails the job, leaks nothing, and leaves nothing
assert.equal(silent.body.error, "fbx-export-failed (no result)");
const before = daemon.starts().length;
const hung = await generate(daemon, exportRequest({ clipName: "hang", exportTimeoutMs: 700 }));
const hung = await generate(daemon, exportRequest({ clipName: "hang", exportTimeoutMs: 2500 }));
assert.equal(hung.status, 502);
assert.equal(hung.body.error, "fbx-export-failed (signal SIGKILL)");
const [run] = daemon.starts().slice(before);
@ -1497,7 +1497,8 @@ test("losing the lease kills a running export within a second and records nothin
const daemon = await idunnDaemon({ leased: true });
try {
await until(() => existsSync(path.join(daemon.stateRoot, "vili.service.cc")), "the service store", 10);
assert.equal(daemon.starts().length, 1, "the version probe ran once the lease was held");
await until(() => daemon.starts().length === 1, "the version probe, run once the lease was held");
assert.equal(existsSync(path.join(daemon.stateRoot, "logs")), false, "the probe writes nothing to the state root");
const pending = generate(daemon, exportRequest({ clipName: "slow" }));
const run = await until(() => exportStarts(daemon)[0], "the export to start");
rmSync(daemon.lease);

View file

@ -501,13 +501,17 @@ let exportScriptDigest = null;
const scriptDigest = () => (exportScriptDigest ??= `sha256:${createHash("sha256").update(readFileSync(exportScript)).digest("hex")}`);
// Runs the sealed Blender in its own process group, niced, under the write gate. Both streams go to
// logs/export.log line by line through mayWrite(), and only there. Resolves { code, signal, first, result }: the
// exit, the first stdout line and the last `VILI-FBX ` line's payload. It rejects only with LeaseLost.
async function runBlender(argv, timeoutMs) {
// logs/export.log line by line through mayWrite(), and only there; the version probe is not logged, so it writes
// nothing to the state root. Resolves { code, signal, first, result }: the exit, the first stdout line and the last
// `VILI-FBX ` line's payload. It rejects only with LeaseLost.
async function runBlender(argv, timeoutMs, logged = true) {
guard();
await mkdir(path.join(args.stateRoot, "logs"), { recursive: true });
guard(); // synchronous with the log open and the spawn below: no await between them
const sink = openSync(path.join(args.stateRoot, "logs", "export.log"), "a");
let sink = null;
if (logged) {
await mkdir(path.join(args.stateRoot, "logs"), { recursive: true });
guard(); // synchronous with the log open and the spawn below: no await between them
sink = openSync(path.join(args.stateRoot, "logs", "export.log"), "a");
}
const proc = spawn(args.blender, argv, {
cwd: __dirname,
env: exportEnv(),
@ -517,7 +521,7 @@ async function runBlender(argv, timeoutMs) {
});
exportGroups.add(proc);
const seen = { first: null, result: null };
let sinkOpen = true;
let sinkOpen = sink !== null;
for (const [stream, isStdout] of [[proc.stdout, true], [proc.stderr, false]]) {
if (!stream) continue;
readline.createInterface({ input: stream }).on("line", (line) => {
@ -547,15 +551,15 @@ async function runBlender(argv, timeoutMs) {
const exit = await finished;
clearTimeout(timer);
exportGroups.delete(proc);
if (sink !== null) closeSync(sink);
sinkOpen = false;
closeSync(sink);
return { ...exit, ...seen };
}
// Blender answers once at start: `blender --version`, 15 s. Ready only when it exits 0 and names itself.
async function probeBlender() {
if (!args.blender) return;
const run = await runBlender(["-b", "--factory-startup", "--version"], 15000);
const run = await runBlender(["-b", "--factory-startup", "--version"], 15000, false);
guard();
blender.version = run.code === 0 && run.first?.startsWith("Blender ") ? run.first : null;
}