commit 33707841f6545bbd23b46d0d5bec0cbb49de747d
parent 3bcceb3cb9a04b958a16ea3d82e167900b5c7da9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 10 Nov 2026 16:05:09 -0500
umtool: the readiness bar never says ✓ for what it does not know -- Render's "rendered" is a render on record (a take's preview on disk, the take panel's own test), not verdicts.json; a reducer that threw (decisionsRead's `failed`) leaves its pills at "—"; X's jar is "—" with its reason while the editor does not answer (xJarStatus: `known`), still never waited on past 0.4 s; the stub editor can be down; unit-tested and an e2e -- L7b review item 8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
7 files changed, 108 insertions(+), 27 deletions(-)
diff --git a/umtool/e2e/fixtures/editor-stub-services.mjs b/umtool/e2e/fixtures/editor-stub-services.mjs
@@ -2,7 +2,9 @@
// what a spec put there (`POST /__stub/services {alerts, x}`, the stub's own door, no token; `{}` resets to no
// alerts) -- the payload editor/app/lib/cookieAlerts.ts serves, so the Inbox's X jar row (lib/inbox/xJar.ts)
// reads the same shape it reads from the real editor. Nothing here asks X anything.
-const state = { alerts: [], pending: [], x: null };
+// `down: true`: the services route answers 503, as an editor that is not up does (readiness.spec.ts: the X jar pill
+// is "—" then, never ✓).
+const state = { alerts: [], pending: [], x: null, down: false };
/** The spec's door. True when it answered. */
export function servicesControl(req, res, url, { json, readBody }) {
@@ -11,6 +13,7 @@ export function servicesControl(req, res, url, { json, readBody }) {
state.alerts = Array.isArray(body?.alerts) ? body.alerts : [];
state.pending = Array.isArray(body?.pending) ? body.pending : [];
state.x = body?.x && typeof body.x === "object" ? body.x : null;
+ state.down = body?.down === true;
json(res, 200, { ok: true, alerts: state.alerts.length });
});
return true;
@@ -20,6 +23,7 @@ export function servicesControl(req, res, url, { json, readBody }) {
export function servicesRoute(req, res, url, { json }) {
if (req.method !== "GET" || url.pathname !== "/api/ops/services") return false;
req.resume();
+ if (state.down) return json(res, 503, { error: "the editor is down (stub)" }), true;
json(res, 200, { ok: true, alerts: state.alerts, pending: state.pending, ...(state.x ? { x: state.x } : {}) });
return true;
}
diff --git a/umtool/e2e/readiness.spec.ts b/umtool/e2e/readiness.spec.ts
@@ -108,3 +108,17 @@ test("X jar: — with no X post and no X work waiting; ! while the editor says X
const state = Object.fromEntries(r.pills.map((p) => [p.id, p.state]));
expect(state).toMatchObject({ "quote-check": "count", render: "count", "x-jar": "bad" });
});
+
+test("X jar: ✓ on a cut with an X post while the editor says nothing waits; — (never ✓) while the editor does not answer, and the page does not wait for it", async ({ page, request }) => {
+ const W = "reports/review-pass-fixture"; // p-5 is an X post
+ await page.goto(urls.workspaceHref(W));
+ await expect(pill(page, "x-jar")).toHaveAttribute("data-ready-state", "ok", { timeout: 30_000 });
+ await request.post(`${STUB}/__stub/services`, { data: { alerts: [], down: true } });
+ const t0 = Date.now();
+ const r = await request.get(`/api/report/readiness?project=${encodeURIComponent(W)}`);
+ expect(Date.now() - t0).toBeLessThan(5_000);
+ const x = ((await r.json()) as { pills: { id: string; state: string; title: string }[] }).pills.find((p) => p.id === "x-jar");
+ expect(x).toMatchObject({ state: "none", title: "the editor did not answer: X's jar is not known" });
+ await page.reload();
+ await expect(pill(page, "x-jar")).toHaveAttribute("data-ready-state", "none", { timeout: 30_000 });
+});
diff --git a/umtool/lib/inbox/readiness.mjs b/umtool/lib/inbox/readiness.mjs
@@ -7,7 +7,8 @@
// state "bad" a blocking row (or X's jar stale): something downstream would lie or die
// "count" rows that are open or informational, `count` of them
// "ok" none, and the check applies (it has run, or there is something for it to judge)
-// "none" it does not apply here (no quote check, no clip, nothing rendered, no X post)
+// "none" it does not apply here (no quote check, no clip, nothing rendered, no X post) -- or it is NOT
+// KNOWN: the project's checks did not read, the editor did not answer for X's jar. Never ✓ then.
/** Which pill a row of the Inbox's is. */
export const PILL_KINDS = {
@@ -40,7 +41,8 @@ export const pillOf = (kind) => pillOfKind.get(kind) ?? null;
*
* @param {{
* rows: Row[],
- * facts: { quoteCheck: boolean, linksChecked: boolean, clips: number, xPosts: number, built: boolean, rendered: boolean, missing?: string[] },
+ * facts: { quoteCheck: boolean, linksChecked: boolean, clips: number, xPosts: number, built: boolean, rendered: boolean, missing?: string[],
+ * decisionsKnown?: boolean, xKnown?: boolean },
* hrefs: { decisions: string, home: string, deliver: string, takes: string, cut: string, xSettings: string, review: (take: string) => string },
* }} o
* @returns {Pill[]}
@@ -60,6 +62,8 @@ export function readinessPills({ rows, facts, hrefs }) {
if (bad.length) return { id, label, state: "bad", count: bad.length, title: words(bad), href: badHref(bad), select: null };
const n = rs.length + extra.length;
if (n) return { id, label, state: "count", count: n, title: [rs.length ? words(rs) : null, ...extra.map((x) => x.why)].filter(Boolean).join(" · "), href: countHref(rs), select: extra[0]?.select ?? null };
+ // A check that did not read is not known: "—", never ✓ (the reducer threw; its rows are not "nothing wrong").
+ if (ok && id !== "x-jar" && facts.decisionsKnown === false) return { id, label, state: "none", count: 0, title: "the project's checks could not be read", href: okHref, select: null };
if (ok) return { id, label, state: "ok", count: 0, title: okTitle, href: okHref, select: null };
return { id, label, state: "none", count: 0, title: noneTitle, href: okHref, select: null };
};
@@ -91,8 +95,9 @@ export function readinessPills({ rows, facts, hrefs }) {
extra: missing.map((id) => ({ why: `${id}: no media fetched`, select: id })),
}),
pill("render", {
+ // A render on record (a take's preview, the take panel's reader) or a build the checks call current.
ok: facts.built || facts.rendered,
- okTitle: facts.built ? "the build is current with the draft" : "rendered; every version judged",
+ okTitle: facts.rendered ? "rendered; every version judged" : "the build is current with the draft",
noneTitle: "never rendered (Render ▾)",
okHref: hrefs.takes,
badHref: () => hrefs.deliver,
@@ -104,9 +109,10 @@ export function readinessPills({ rows, facts, hrefs }) {
// X's jar is the machine's: stale while X work waits on it (the editor's alert), whichever piece it is for.
((p) => (p.state === "count" ? { ...p, state: "bad" } : p))(
pill("x-jar", {
- ok: facts.xPosts > 0,
+ // ✓ only on the editor's word: a jar it did not answer for is not known.
+ ok: facts.xPosts > 0 && facts.xKnown !== false,
okTitle: "X's cookie jar: no X work waiting on it",
- noneTitle: "no X post in the cut",
+ noneTitle: facts.xKnown === false ? "the editor did not answer: X's jar is not known" : "no X post in the cut",
okHref: hrefs.xSettings,
badHref: (rs) => rs[0]?.href ?? hrefs.xSettings,
}),
diff --git a/umtool/lib/inbox/readiness.test.mjs b/umtool/lib/inbox/readiness.test.mjs
@@ -0,0 +1,31 @@
+// The readiness bar's pills (lib/inbox/readiness.mjs): the Inbox's rows bucketed, and what is NOT known never ✓.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { readinessPills } from "./readiness.mjs";
+
+const hrefs = { decisions: "/d", home: "/", deliver: "/deliver", takes: "/takes", cut: "/cut", xSettings: "http://e/settings", review: (t) => `/review/${t}` };
+const facts = { quoteCheck: true, linksChecked: true, clips: 3, xPosts: 1, built: true, rendered: true, decisionsKnown: true, xKnown: true };
+const state = (pills) => Object.fromEntries(pills.map((p) => [p.id, p.state]));
+
+test("a piece with nothing waiting: ✓ each, the checks known", () => {
+ assert.deepEqual(state(readinessPills({ rows: [], facts, hrefs })), { "quote-check": "ok", links: "ok", captures: "ok", render: "ok", "x-jar": "ok" });
+});
+
+test("rows: blocking is !, the rest a count; X's stale jar is ! wherever it is", () => {
+ const rows = [
+ { kind: "clip-quote-moved", target: "c1", why: "heard 13 s early", href: "/d", severity: "blocking" },
+ { kind: "links-unchecked", target: "QR links", why: "never checked", href: "/d", severity: "info" },
+ { kind: "version-unjudged", target: "v2", why: "no verdict", href: "/p", severity: "open" },
+ { kind: "x-jar-stale", target: "x", why: "3 h old", href: "http://e/settings", severity: "blocking" },
+ ];
+ const p = readinessPills({ rows, facts, hrefs });
+ assert.deepEqual(state(p), { "quote-check": "bad", links: "count", captures: "ok", render: "count", "x-jar": "bad" });
+ assert.equal(p.find((x) => x.id === "render").href, "/review/v2");
+});
+
+test("not known is never ✓: the checks did not read -- —; the editor did not answer for X's jar -- —; nothing rendered -- —", () => {
+ assert.deepEqual(state(readinessPills({ rows: [], facts: { ...facts, decisionsKnown: false }, hrefs })), { "quote-check": "none", links: "none", captures: "none", render: "none", "x-jar": "ok" });
+ const x = readinessPills({ rows: [], facts: { ...facts, xKnown: false }, hrefs }).find((p) => p.id === "x-jar");
+ assert.deepEqual([x.state, x.title], ["none", "the editor did not answer: X's jar is not known"]);
+ assert.equal(readinessPills({ rows: [], facts: { ...facts, built: false, rendered: false }, hrefs }).find((p) => p.id === "render").state, "none");
+});
diff --git a/umtool/lib/inbox/readiness.ts b/umtool/lib/inbox/readiness.ts
@@ -1,13 +1,14 @@
import { stat } from "node:fs/promises";
import path from "node:path";
import type { ProjectRef } from "@/lib/project-types";
-import { decisionsForProject } from "@/lib/projects";
+import { decisionsRead } from "@/lib/projects";
+import { listTakes } from "@/lib/report/takes.mjs";
import { readManifest } from "@/lib/projects/report.mjs";
import { homeHref, projectHref, takesHref, versionReviewHref } from "@/lib/hrefs";
import { editorUrl } from "@/lib/articles/generation";
import { QUOTE_CHECK_FILE } from "@/lib/report/quoteCheck.mjs";
import { projectCallsOf } from "./projectCalls";
-import { xJarDecisions } from "./xJar";
+import { xJarStatus } from "./xJar";
import { readinessPills } from "./readiness.mjs";
// ---------------------------------------------------------------------------
@@ -24,23 +25,28 @@ const exists = (f: string) => stat(/* turbopackIgnore: true */ f).then(() => tru
export async function readinessOf(ref: ProjectRef): Promise<Readiness> {
try {
- const [decisions, calls, xjar, manifest, quoteCheck, linksChecked] = await Promise.all([
- decisionsForProject(ref).catch(() => []),
+ const [read, calls, jar, manifest, quoteCheck, linksChecked, takes] = await Promise.all([
+ decisionsRead(ref).catch(() => ({ value: [], failed: true })),
projectCallsOf(ref),
- xJarDecisions().catch(() => []),
+ xJarStatus(),
readManifest(ref.dir).catch(() => null) as Promise<Record<string, unknown> | null>,
exists(path.join(ref.dir, QUOTE_CHECK_FILE)),
exists(path.join(ref.dir, "out", "links.json")),
+ listTakes(ref.dir).then((r) => r.takes, () => []),
]);
+ const decisions = read.value;
+ const xjar = jar.row ? [jar.row] : [];
const timeline = (Array.isArray(manifest?.timeline) ? manifest.timeline : []) as Record<string, unknown>[];
const clips = timeline.filter((e) => e?.type === "clip").length;
const xPosts = timeline.filter((e) => e?.type === "post" && (e.platform === "x" || /^https?:\/\/(x|twitter)\.com\//.test(String(e.url ?? "")))).length;
const rows = [...decisions, ...calls, ...xjar];
- const built = !rows.some((r) => r.kind === "unbuilt" || r.kind === "stale-build");
- const rendered = calls.some((r) => r.kind === "version-unjudged") || (await exists(path.join(ref.dir, "takes", "verdicts.json")));
+ // Current only when the checks read and say so (no unbuilt or stale-build row).
+ const built = !read.failed && !rows.some((r) => r.kind === "unbuilt" || r.kind === "stale-build");
+ // A render on record: a take or version with a preview on disk (the take panel's own test, previewSize).
+ const rendered = (takes as { previewSize: number | null }[]).some((t) => t.previewSize != null);
const pills = readinessPills({
rows: rows as never,
- facts: { quoteCheck, linksChecked, clips, xPosts, built, rendered },
+ facts: { quoteCheck, linksChecked, clips, xPosts, built, rendered, decisionsKnown: !read.failed, xKnown: jar.known },
hrefs: {
decisions: projectHref(ref.id, { tab: "overview" }),
home: homeHref(),
diff --git a/umtool/lib/inbox/xJar.ts b/umtool/lib/inbox/xJar.ts
@@ -18,7 +18,9 @@ const memoMs = () => {
/** The editor's services answer from a stat: a late answer still lands in the memo for the next read. */
const WAIT_MS = 400;
-type Memo = { at: number; value: Promise<Decision | null> } | null;
+/** What the editor said of X's jar: its row when X work waits on a stale jar; `known` false when it did not answer. */
+type JarRead = { row: Decision | null; known: boolean };
+type Memo = { at: number; value: Promise<JarRead> } | null;
const g = globalThis as typeof globalThis & { __umtoolXJarMemo?: Memo };
/** Forget the memo (a spec that changed the stub's services; a Recheck). */
@@ -26,21 +28,29 @@ export function clearXJarMemo(): void {
g.__umtoolXJarMemo = null;
}
-async function ask(): Promise<Decision | null> {
+async function ask(): Promise<JarRead> {
const payload = await askEditor("/api/ops/services", { fresh: true });
- return xJarDecision(payload, { href: `${editorUrl()}/settings` }) as Decision | null;
+ return { row: xJarDecision(payload, { href: `${editorUrl()}/settings` }) as Decision | null, known: !!payload && typeof payload === "object" };
}
-/** The X jar's row when X work waits on it, else none. Never throws. */
-export async function xJarDecisions({ fresh = false }: { fresh?: boolean } = {}): Promise<Decision[]> {
+/**
+ * What the editor says of X's jar, never waited on past WAIT_MS: `known` false when it did not answer (down, slow,
+ * an error) -- the readiness bar says "—" then, never ✓ (umtool redesign L7b). Never throws.
+ */
+export async function xJarStatus({ fresh = false }: { fresh?: boolean } = {}): Promise<JarRead> {
const m = g.__umtoolXJarMemo;
- let value: Promise<Decision | null>;
+ let value: Promise<JarRead>;
if (m && !fresh && Date.now() - m.at < memoMs()) value = m.value;
else {
- value = ask().catch(() => null);
+ value = ask().catch(() => ({ row: null, known: false }));
g.__umtoolXJarMemo = { at: Date.now(), value };
}
- const timeout = new Promise<null>((resolve) => setTimeout(() => resolve(null), WAIT_MS).unref?.());
- const row = await Promise.race([value, timeout]).catch(() => null);
+ const timeout = new Promise<JarRead>((resolve) => setTimeout(() => resolve({ row: null, known: false }), WAIT_MS).unref?.());
+ return Promise.race([value, timeout]).catch(() => ({ row: null, known: false }));
+}
+
+/** The X jar's row when X work waits on it, else none. Never throws. */
+export async function xJarDecisions({ fresh = false }: { fresh?: boolean } = {}): Promise<Decision[]> {
+ const { row } = await xJarStatus({ fresh });
return row ? [row] : [];
}
diff --git a/umtool/lib/projects.ts b/umtool/lib/projects.ts
@@ -67,7 +67,7 @@ export const ALL_DECISION_KINDS: string[] = [
type ProjectCaches = {
walk: { at: number; refs: ProjectRef[] } | null;
summary: Map<string, { sig: string; value: ProjectSummary }>;
- decision: Map<string, { sig: string; value: Decision[] }>;
+ decision: Map<string, { sig: string; value: Decision[]; failed?: boolean }>;
};
const CACHES = ((globalThis as { __umtoolProjectCaches?: ProjectCaches }).__umtoolProjectCaches ??= {
walk: null,
@@ -276,11 +276,20 @@ export async function listFolders(): Promise<Map<string, FolderNode>> {
// literal the app needs inside the registry's own module.
// ---------------------------------------------------------------------------
export async function decisionsForProject(p: ProjectRef): Promise<Decision[]> {
+ return (await decisionsRead(p)).value;
+}
+
+/**
+ * The project's decisions and whether its kind's reducer READ (the readiness bar, umtool redesign L7b: a reducer
+ * that threw is "not known", never "nothing wrong"). Same cache as decisionsForProject.
+ */
+export async function decisionsRead(p: ProjectRef): Promise<{ value: Decision[]; failed: boolean }> {
const sig = await signatureOf(p);
const hit = decisionCache.get(p.id);
- if (hit && hit.sig === sig) return hit.value;
+ if (hit && hit.sig === sig) return { value: hit.value, failed: !!hit.failed };
let out: Decision[] = [];
+ let failed = false;
try {
if (p.kind === SONG_KIND) {
// Keyed by BASENAME while the song routes still are -- and the test for
@@ -298,6 +307,7 @@ export async function decisionsForProject(p: ProjectRef): Promise<Decision[]> {
}
} catch {
out = [];
+ failed = true;
}
// Routing failures are kind-independent, so they are added here rather than
@@ -340,8 +350,8 @@ export async function decisionsForProject(p: ProjectRef): Promise<Decision[]> {
const title = (await summariseProject(p)).title;
const value = out.map((d) => ({ ...d, project: p.id, projectTitle: title, projectKind: p.kind }));
- decisionCache.set(p.id, { sig, value });
- return value;
+ decisionCache.set(p.id, { sig, value, failed });
+ return { value, failed };
}
const RANK: Record<string, number> = { blocking: 0, open: 1, info: 2 };