Test: the spawn is gated at the spawn, not by the request's earlier checks
The fake Idunn signer can lose the lease once a job's meta.json exists, which pins the guards in startWorker (no logs or embeddings directory, no worker). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d35f8e408b
commit
f69e24eeff
2 changed files with 31 additions and 3 deletions
|
|
@ -1,17 +1,24 @@
|
|||
// Test seam only: the shipped Idunn runtime (scripts/idunn-entry.mjs idunnRuntime) over a signer whose write lease is
|
||||
// a file, so the lease gate is tested without Idunn's authority files. Present = leased. The daemon's own flags
|
||||
// arrive on argv as they do for the hand-run daemon.
|
||||
import { existsSync, appendFileSync } from "node:fs";
|
||||
import { existsSync, appendFileSync, readdirSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { idunnRuntime } from "../idunn-entry.mjs";
|
||||
import { serve } from "../vili-daemon.mjs";
|
||||
|
||||
const leasePath = process.env.FAKE_IDUNN_LEASE;
|
||||
const healthLog = process.env.FAKE_IDUNN_HEALTH_LOG;
|
||||
const answer = process.env.FAKE_IDUNN_ANSWER_THROWS !== "1";
|
||||
// An artifacts directory: the lease is gone from the moment a job there has written its meta.json, so a test can
|
||||
// lose it between a job's first write and the spawn of its worker.
|
||||
const loseAfterMeta = process.env.FAKE_IDUNN_LOSE_AFTER_META;
|
||||
|
||||
const signer = {
|
||||
assertWriteLease() {
|
||||
if (!existsSync(leasePath)) throw new Error("no lease");
|
||||
if (loseAfterMeta && existsSync(loseAfterMeta) && readdirSync(loseAfterMeta).some((job) => existsSync(path.join(loseAfterMeta, job, "meta.json")))) {
|
||||
throw new Error("lease lost");
|
||||
}
|
||||
return "lease";
|
||||
},
|
||||
answerRouteObservation(request) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue