commit 7755c58e89259cd24a35e42720ebf122d675b46b
parent e5f19a7cfeb3200dff44df6f144cce2d79a892c3
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 15:28:00 -0500
jobs: a queued x-run is never re-queued on boot -- an X sequence starts only on a person's click
The boot pass re-queued any replayable queued meta, x-run included. A new
JobKindMeta flag, startedByPerson (set on x-run), closes such a meta as
`person` with PERSON_RESTART_REASON; the run's file then reads interrupted
and Resume on /review is the click.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/common/jobs/bootQueuedJobs.test.ts b/common/jobs/bootQueuedJobs.test.ts
@@ -9,6 +9,7 @@ import type { JobSpec } from "./jobSpec";
import {
INTERRUPTED_REASON,
PUBLISH_RESTART_REASON,
+ PERSON_RESTART_REASON,
STORAGE_PASS_WAIT_MS,
processIsAlive,
settleAfterStoragePass,
@@ -595,3 +596,23 @@ test("a queued publish stage is cancelled as `publish`, never re-queued, even wi
await rm(f.root, { recursive: true, force: true });
}
});
+
+// Lane x-console: an X run left QUEUED by a restart is never re-queued — an X
+// sequence starts only on a person's click (its run reads interrupted, and
+// Resume on /review is that click) — even with a fresh, replayable spec.
+test("a queued x-run is cancelled as `person`, never re-queued", async () => {
+ const run: JobSpec = { kind: "x-run", slug: "_x-run", params: { run: "xr-01JZZZZZZZZZZZZZZZZZZZZZZZ" } };
+ const f = await fixture([
+ { id: "X1", kind: "x-run", queueKey: "platform:twitter", spec: run },
+ { id: "F1", spec: SPEC },
+ ]);
+ try {
+ const rq = recordingRequeue();
+ const res = await settleQueuedJobMetas({ paths: f.paths, requeue: rq.fn, bootedAt: BOOT, log: () => {} });
+ assert.deepEqual(rq.calls, [SPEC]);
+ assert.deepEqual(res.cancelled.map((c) => [c.id, c.category]), [["X1", "person"]]);
+ assert.equal((await f.read("X1")).cancelReason, PERSON_RESTART_REASON);
+ } finally {
+ await rm(f.root, { recursive: true, force: true });
+ }
+});
diff --git a/common/jobs/bootQueuedJobs.ts b/common/jobs/bootQueuedJobs.ts
@@ -4,7 +4,7 @@ import { writeFileAtomic } from "../lib/jsonFile-server";
import type { Paths } from "../lib/paths";
import { metaPath, readJobMeta, type JobMeta } from "./jobMeta";
import type { JobSpec } from "./jobSpec";
-import { isPublishStageJobKind } from "./jobKinds";
+import { getJobKind, isPublishStageJobKind } from "./jobKinds";
// THE BOOT PASS OVER STALE `queued` METAS (release 9, B4b).
//
@@ -27,7 +27,8 @@ import { isPublishStageJobKind } from "./jobKinds";
// paced; nor is a publish stage (release 18, `publish-*`): the publish
// lane and Publish now re-derive stages from the stamps on disk, and a
// stage re-queued with its run's preconditions would wait on a run that
-// is gone;
+// is gone; nor is a kind that starts only on a person's click
+// (`startedByPerson`: the X run);
// 3. a meta queued more than REQUEUE_MAX_AGE_MS before this boot is stale;
// 4. a meta with no replay spec cannot be re-queued;
// 5. of what is left, only the NEWEST meta per kind + channel + params is
@@ -55,7 +56,7 @@ export type RequeueFn = (
) => Promise<{ ok: true; jobId: string } | { ok: false; error: string }>;
export type CancelCategory =
- "idle" | "sync" | "publish" | "stale" | "no-spec" | "superseded" | "refused";
+ "idle" | "sync" | "publish" | "person" | "stale" | "no-spec" | "superseded" | "refused";
export type BootQueuedResult = {
requeued: { id: string; newId: string }[];
@@ -65,6 +66,8 @@ export type BootQueuedResult = {
export const RESTART_REASON = "server restarted before it ran";
export const PUBLISH_RESTART_REASON =
"server restarted; the publish lane re-derives stages from on-disk state";
+export const PERSON_RESTART_REASON =
+ "server restarted; this kind starts only on a person's click (an X run: Resume it on /review)";
export const REQUEUE_MAX_AGE_MS = 24 * 60 * 60 * 1000;
// Key a spec by what it would DO: kind + channel + bucket + params, with the
@@ -294,6 +297,9 @@ export async function settleQueuedJobMetas(
);
} else if (isPublishStageJobKind(meta.kind)) {
await cancel(meta, "publish", PUBLISH_RESTART_REASON);
+ } else if (getJobKind(meta.kind)?.startedByPerson) {
+ // An X run starts only on a person's click, never by a boot.
+ await cancel(meta, "person", PERSON_RESTART_REASON);
} else if (
typeof meta.queuedAt !== "number" ||
opts.bootedAt - meta.queuedAt > maxAgeMs
diff --git a/common/jobs/jobKinds.test.ts b/common/jobs/jobKinds.test.ts
@@ -430,4 +430,6 @@ test("x-run: a network, drainable, replayable ingest kind on X's queue that a re
assert.equal(meta.replayable, true);
assert.equal(isIngestKind("x-run"), true);
assert.equal(meta.resumeOnBoot, undefined);
+ // A restart never re-queues one left queued (jobs/bootQueuedJobs.ts).
+ assert.equal(meta.startedByPerson, true);
});
diff --git a/common/jobs/jobKinds.ts b/common/jobs/jobKinds.ts
@@ -96,6 +96,13 @@ export type JobKindMeta = {
// interrupted twice in a row, and is off with `jobs.resumeInterruptedOnBoot`
// or on an idle boot.
resumeOnBoot?: boolean;
+ // Whether a job of this kind starts ONLY on a person's click: one left
+ // QUEUED by a restart is closed, never re-queued by the boot pass
+ // (jobs/bootQueuedJobs.ts), whatever its spec says. The X run (operator: an
+ // X sequence starts only when a person says so) — its run file then reads
+ // as interrupted, and Resume on /review is the person's click. Absent
+ // means false.
+ startedByPerson?: boolean;
};
// One entry per kind known to the system. `label` is included only where the
@@ -672,6 +679,7 @@ const JOB_KINDS: Record<string, JobKindMeta> = {
replayable: true,
queueKeyStrategy: "platform",
network: true,
+ startedByPerson: true,
},
// Forum thread pages the operator saved from a browser, imported into a
// forum-thread channel (controller/importForumPages.ts). Offline — nothing is