commit d28d584f3d4e39687344eb4bf2386c640ddd7b1c
parent f4c80ae6906a226d4484051e89521ecb5008a044
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 12 Nov 2026 11:15:33 -0500
lookouts: two asks at once queue one run; the privacy test's LMDB read typechecks; the run test keeps its usage ledger in its temp dir
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/common/bin/lookoutPrivacy.test.ts b/common/bin/lookoutPrivacy.test.ts
@@ -140,7 +140,7 @@ test("the index build: neither the export index files nor any LMDB record carrie
try {
let seenCue = false;
for (const name of ["sums", "cues", "subs", "alts", "mtimes", "byChannel", "pageHashes", "subPageHashes", "channelStats", "posts", "postPageHashes", "channelPostsStats", "digests", "digestPageHashes", "channelDigestStats", "videoState", "meta"]) {
- const db = root.openDB<unknown, unknown>({ name, encoding: "msgpack" });
+ const db = root.openDB({ name, encoding: "msgpack" });
for (const { key, value } of db.getRange()) {
const text = JSON.stringify([key, value]);
if (text.includes(PUBLIC_CUE)) seenCue = true;
diff --git a/common/controller/lookoutRun.test.ts b/common/controller/lookoutRun.test.ts
@@ -26,6 +26,7 @@ Object.assign(process.env, {
EXPORT_BUILDS_DIR: path.join(ROOT, ".export-builds"),
ARCHILYZER_CONFIG_DIR: path.join(ROOT, "config"),
RENDER_PRIORITY_FILE: path.join(ROOT, "render.json"),
+ GENERATION_USAGE_FILE: path.join(ROOT, ".generation", "usage.jsonl"),
});
after(() => rmSync(ROOT, { recursive: true, force: true }));
diff --git a/common/controller/lookoutRun.ts b/common/controller/lookoutRun.ts
@@ -408,6 +408,12 @@ function jobsOf(): Map<string, string> {
return (g[JOBS_KEY] ??= new Map());
}
+const ENQUEUEING_KEY = Symbol.for("archilyzer.lookoutRun.enqueueing");
+function enqueueingOf(): Set<string> {
+ const g = globalThis as unknown as Record<symbol, Set<string> | undefined>;
+ return (g[ENQUEUEING_KEY] ??= new Set());
+}
+
/** The queued or running lookout-run jobs of a lookout: `{jobId, status}`. */
export function lookoutRunJobs(id: string): { jobId: string; status: string }[] {
const mine = jobsOf();
@@ -486,8 +492,14 @@ export async function enqueueLookoutRun(body: LookoutRunBody, deps: LookoutRunJo
}
const busy = lookoutRunJobs(item.id);
if (busy.length) return refuse(`a run of lookout "${item.id}" is already ${busy[0]!.status} (job ${busy[0]!.jobId})`);
+ // Two asks at once: the second is refused while the first is being queued.
+ const enqueueing = enqueueingOf();
+ if (enqueueing.has(item.id)) return refuse(`a run of lookout "${item.id}" is being queued`);
+ enqueueing.add(item.id);
const paths = deps.paths;
- const result = await runManagedFunction({
+ let result: StreamActionResult;
+ try {
+ result = await runManagedFunction({
kind: LOOKOUT_RUN_JOB_KIND,
queueKey: DRAFT_LOCAL_QUEUE,
paths,
@@ -545,8 +557,11 @@ export async function enqueueLookoutRun(body: LookoutRunBody, deps: LookoutRunJo
if (r.stopped === "cancelled" || signal.aborted) throw new Error("cancelled");
if (r.status === "failed") throw new Error("the model kept failing — the run is written as failed");
}),
- });
- if (result.ok) jobsOf().set(result.jobId, item.id);
+ });
+ if (result.ok) jobsOf().set(result.jobId, item.id);
+ } finally {
+ enqueueing.delete(item.id);
+ }
if (!result.ok) return { result };
return { result, model };
}