Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 2c280fb9093ba2cc4983265825983ad831f87b23
parent de85933803824aa207adc571bbf12156792f6266
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 00:08:38 -0400

umtool: e2e for the inbox engine; test:scripts runs lib/pieces and lib/inbox

inbox-engine.spec.ts: one row per decision with the inbox's fields, the
generation era's decisions from the fixture's zeta, a parked piece's rows
hidden (never dropped, the note row's href still ending in note=<id>), the
lifecycle POST round trip and its refusals.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mpackage.json | 2+-
Aumtool/e2e/inbox-engine.spec.ts | 157+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 158 insertions(+), 1 deletion(-)

diff --git a/package.json b/package.json @@ -24,7 +24,7 @@ "wt": "node scripts/worktree.mjs", "e2e:sharded": "node scripts/run-sharded-e2e.mjs", "e2e:all": "node scripts/e2e-all.mjs", - "test:scripts": "node --test scripts/*.test.mjs umtool/report-to-video/*.test.mjs umtool/lib/*.test.mjs umtool/lib/report/*.test.mjs umtool/lib/annotations/*.test.mjs umtool/lib/articles/*.test.mjs", + "test:scripts": "node --test scripts/*.test.mjs umtool/report-to-video/*.test.mjs umtool/lib/*.test.mjs umtool/lib/report/*.test.mjs umtool/lib/annotations/*.test.mjs umtool/lib/articles/*.test.mjs umtool/lib/pieces/*.test.mjs umtool/lib/inbox/*.test.mjs", "test": "pnpm -r --no-bail --no-sort --workspace-concurrency=1 run test; a=$?; pnpm run test:scripts; b=$?; [ $a -eq 0 ] && [ $b -eq 0 ]", "typecheck": "pnpm -r --no-bail --no-sort --workspace-concurrency=1 exec tsc --noEmit", "lint": "pnpm --filter export run lint", diff --git a/umtool/e2e/inbox-engine.spec.ts b/umtool/e2e/inbox-engine.spec.ts @@ -0,0 +1,157 @@ +import { test, expect, type APIRequestContext } from "@playwright/test"; +import { warm, WARM_TIMEOUT } from "./warm"; + +// The inbox engine (plans/umtool-redesign.md, P2a): GET /api/browse/decisions +// keeps one row per decision and adds the inbox's fields; the generation era's +// decisions come from disk; a parked piece's decisions are hidden, never +// dropped; POST /api/pieces/lifecycle round-trips. Over the fixture's article in +// the making, zeta (e2e/fixtures/iterations-fixture.mjs): i1 and i2 done with +// reports, i3 a video revision, i4 failed -- and no current.json. +// +// WRITES the fixture's REPORTS_ROOT/.umtool/lifecycle.json (zeta parked, then +// active again) and a note on articles/zeta, deleted before the test ends. + +type Row = { + kind: string; + project: string; + projectKind?: string; + target: string; + href: string; + severity: "blocking" | "open" | "info"; + piece?: string; + category?: string; + group?: string; + action?: { label: string; href: string }; + lifecycle?: "active" | "parked" | "done"; + hidden?: boolean; +}; +type Group = { id: string; label: string; decisions: number; hidden: number; cards: { piece: string | null; kind: string; count: number }[] }; +type Inbox = { items: Row[]; projects: number; counts: Record<string, number>; groups: Group[]; hidden: number }; + +const ZETA = "a:articles/zeta"; + +const inbox = async (request: APIRequestContext): Promise<Inbox> => { + const r = await request.get("/api/browse/decisions"); + expect(r.ok()).toBe(true); + return r.json(); +}; +const lifecycle = (request: APIRequestContext, piece: unknown, state: unknown) => request.post("/api/pieces/lifecycle", { data: { piece, state } }); + +test.beforeAll(async ({ playwright }) => { + test.setTimeout(WARM_TIMEOUT); + await warm(playwright, ["/api/browse/decisions", "/api/pieces", "/api/notes?article=articles/zeta"]); +}); + +test.afterAll(async ({ request }) => { + await lifecycle(request, ZETA, "active"); +}); + +test("one row per decision, each with the inbox's fields; the counts add up", async ({ request }) => { + const { items, counts, groups, hidden } = await inbox(request); + expect(items.length).toBeGreaterThan(0); + expect(counts.blocking + counts.open + counts.info).toBe(items.length); + expect(groups.reduce((n, g) => n + g.decisions + g.hidden, 0)).toBe(items.length); + expect(hidden).toBe(items.filter((d) => d.hidden).length); + expect(groups.map((g) => g.id)).toEqual(["your-call", "review", "blocking", "notes", "open", "ready-to-finish", "quiet"]); + for (const d of items) { + expect(d.piece, `${d.kind} ${d.project}`).toMatch(/^[ap]:/); + expect(d.group).toBeTruthy(); + expect(d.category).toBeTruthy(); + expect(d.lifecycle).toBeTruthy(); + expect(typeof d.hidden).toBe("boolean"); + expect(d.action?.label).toBeTruthy(); + expect(d.action?.href).toBe(d.href); + } + // The rows openDecisions() always made are still there, project ids intact. + expect(items.some((d) => d.kind === "shadowed-name" && d.project === "find")).toBe(true); +}); + +test("the generation era's decisions come from disk", async ({ request }) => { + const { items } = await inbox(request); + const zeta = items.filter((d) => d.piece === ZETA); + const of = (kind: string) => zeta.filter((d) => d.kind === kind).map((d) => d.target).sort(); + // No current.json: every done iteration that could be current is ready. + expect(of("iteration-ready")).toEqual(["i1", "i2", "i3"]); + expect(of("iteration-failed")).toEqual(["i4"]); + const failed = zeta.find((d) => d.kind === "iteration-failed")!; + expect(failed.group).toBe("your-call"); + expect(failed.category).toBe("spend"); + expect(failed.project).toBe("sites/articles/zeta"); + expect(failed.projectKind).toBe("article"); + expect(failed.href).toBe("/articles/zeta?tab=iterations"); + const ready = zeta.find((d) => d.kind === "iteration-ready" && d.target === "i1")!; + expect(ready.group).toBe("review"); + expect(ready.action?.label).toBe("Make i1 current"); + // The project zeta's iterations made belongs to zeta's piece (linked by its + // iteration, not by slug), so its manifest decisions do too. + expect(items.some((d) => d.project === "gen-projects/zeta/i1" && d.piece === ZETA)).toBe(true); + // A published article with its video looks done: a suggestion, not a state. + const done = items.find((d) => d.kind === "looks-done" && d.piece === "a:priv/polemic-alpha"); + expect(done?.group).toBe("ready-to-finish"); + expect(done?.lifecycle).toBe("active"); +}); + +test("a parked piece's decisions are hidden, never dropped; active again shows them", async ({ request }) => { + // A note on zeta, so the MCP's contract is checked on a hidden row too. + const add = await request.post("/api/notes?article=articles/zeta", { data: { op: { op: "add", text: "Inbox engine.", anchor: { kind: "whole" } } } }); + expect(add.status()).toBe(200); + const noteId = (await add.json()).note.id as string; + try { + const before = await inbox(request); + const zetaRows = before.items.filter((d) => d.piece === ZETA); + expect(zetaRows.length).toBeGreaterThan(5); + expect(zetaRows.every((d) => !d.hidden && d.lifecycle === "active")).toBe(true); + + const park = await lifecycle(request, ZETA, "parked"); + expect(park.status()).toBe(200); + expect(await park.json()).toMatchObject({ piece: ZETA, state: "parked", by: "operator" }); + + const after = await inbox(request); + expect(after.items.length).toBe(before.items.length); + const parked = after.items.filter((d) => d.piece === ZETA); + expect(parked.length).toBe(zetaRows.length); + expect(parked.every((d) => d.hidden && d.lifecycle === "parked")).toBe(true); + expect(after.hidden).toBe(before.hidden + zetaRows.length); + // Hidden rows are counted per group and left out of the cards. + expect(after.groups.flatMap((g) => g.cards).some((c) => c.piece === ZETA)).toBe(false); + // The note row keeps the MCP's contract: project is the notes target, href ends in note=<id>. + const note = after.items.find((d) => d.kind === "open-note" && d.piece === ZETA)!; + expect(note.project).toBe("sites/articles/zeta"); + expect(note.href.endsWith(`note=${noteId}`)).toBe(true); + expect(note.action?.href.endsWith(`note=${noteId}`)).toBe(true); + + const pieces = await (await request.get("/api/pieces")).json(); + const z = pieces.pieces.find((p: { id: string }) => p.id === ZETA); + expect(z).toMatchObject({ kind: "article", site: "articles", report: "zeta", status: "in the making", stage: "research", lifecycle: "parked", lifecycleBy: "operator" }); + expect(z.projects.map((p: { id: string; via: string }) => `${p.id}:${p.via}`).sort()).toEqual(["gen-projects/zeta/i1:iteration", "gen-projects/zeta/i3:iteration"]); + expect(z.decisions.hidden).toBe(zetaRows.length); + + expect((await lifecycle(request, ZETA, "active")).status()).toBe(200); + const again = await inbox(request); + expect(again.items.filter((d) => d.piece === ZETA).every((d) => !d.hidden && d.lifecycle === "active")).toBe(true); + } finally { + await request.post("/api/notes?article=articles/zeta", { data: { op: { op: "delete", id: noteId } } }); + } +}); + +test("POST /api/pieces/lifecycle refuses junk", async ({ request }) => { + for (const [piece, state, status] of [ + ["articles/zeta", "parked", 400], // no namespace: ambiguous, refused + ["a:articles/zeta/extra", "parked", 400], + ["p:../etc", "parked", 400], + [ZETA, "shipped", 400], + [ZETA, null, 400], + [null, "parked", 400], + ["a:articles/no-such-article", "parked", 404], + ["p:no/such/project", "done", 404], + ["c:some-case", "parked", 404], + // A project zeta's iterations made is part of zeta's piece. + ["p:gen-projects/zeta/i1", "parked", 404], + ] as const) { + const r = await lifecycle(request, piece, state); + expect(r.status(), `${piece} ${state}`).toBe(status); + expect((await r.json()).error).toBeTruthy(); + } + const r = await request.post("/api/pieces/lifecycle", { data: "not json", headers: { "content-type": "text/plain" } }); + expect(r.status()).toBe(400); +});