Archilyzer · Source

archilyzer

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

commit cee2bb4c92f9bc007241935de052027406ab449f
parent a087e71a0c2502bfdb633371158754717358030e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 21:44:59 -0400

tests: three flakes — a directory mtime, two fixed holds, an uncheck before the save settled

- relocateChannelMedia.test.ts, "reconcile: an extra and a changed file":
  writing stale.json moved the target's v1/ mtime, and when the setup crossed
  a second boundary rsync (whole seconds) itemized `.d..t v1/` as a third
  difference. Every directory's mtime is pinned on both sides now (proved with
  a forced 1.1 s delay: red before, green after).
- queue-lock.test.mjs, "--with" (and "two weighted jobs", the same kind): a
  fixed 700 ms / 1500 ms hold raced the next run's start under parallel test
  files. The holding runs wait on a gate file the test opens once what it
  checks has happened (capped at 20 s, so a wrong admission still fails the
  order assertion rather than hanging).
- editor/e2e/backfill.spec.ts: the lane is unchecked only once the first save
  has settled on the page ("Saved.", the button back, nothing unsaved), and the
  second save is seen to settle before the lane is polled.

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

Diffstat:
Mcommon/controller/relocateChannelMedia.test.ts | 15+++++++++++++++
Meditor/e2e/backfill.spec.ts | 17+++++++++++++++--
Mscripts/queue-lock.test.mjs | 34+++++++++++++++++++++++++++++++---
3 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/common/controller/relocateChannelMedia.test.ts b/common/controller/relocateChannelMedia.test.ts @@ -749,6 +749,15 @@ async function leftoverCopies(channelDir: string): Promise<string[]> { // rsync -a of the tree, so the seeded "already copied" target is byte-for-byte // what a completed copy phase would have left — including mtimes, which the // re-verify compares. Over `media/` only: it holds no links. +// Every directory under (and including) `dir` set to MTIME, so a test's +// itemized drift is the files' alone, whatever second the setup ran in. +async function pinDirTimes(dir: string): Promise<void> { + for (const entry of await readdir(dir, { withFileTypes: true })) { + if (entry.isDirectory()) await pinDirTimes(path.join(dir, entry.name)); + } + await utimes(dir, MTIME, MTIME); +} + async function copyTree(src: string, dest: string): Promise<void> { await mkdir(dest, { recursive: true }); for (const entry of await readdir(src, { withFileTypes: true })) { @@ -1612,6 +1621,12 @@ test("reconcile: an extra and a changed file on the destination are settled, and await copyTree(mediaLink, target); await writeFile(path.join(target, "v1", "stale.json"), "{}"); await writeFile(path.join(target, "v1", "transcript.live_chat.json"), '{"v":1}'); + // Every directory's mtime pinned on both sides: writing stale.json moved + // the target's v1/ mtime, and when the setup crossed a second boundary + // rsync (comparing whole seconds) itemized `.d..t v1/` as a third + // difference — the release 28 flake. Only the two files differ now. + await pinDirTimes(mediaLink); + await pinDirTimes(target); await seedMarker(paths, "alpha", { target, direction: "out", phase: "copy" }); const lines: string[] = []; diff --git a/editor/e2e/backfill.spec.ts b/editor/e2e/backfill.spec.ts @@ -512,9 +512,22 @@ test("a lane can be scoped to one operation from its console, and the scope is a ) .toEqual({ enabled: true, operations: ["diarization"] }); - // Switch it back off so an armed lane does not bleed into the next spec. - await lane.getByLabel("Enable auto-backfill").uncheck(); + // Switch it back off so an armed lane does not bleed into the next spec — + // once the first save has SETTLED on the page (its "Saved.", the button + // back, nothing unsaved). Unchecking while it was still settling was the + // release 28 flake: the form could adopt the saved copy after the uncheck, + // and the second save then wrote the lane on again. + const enable = lane.getByLabel("Enable auto-backfill"); + await expect(lane.getByRole("status")).toHaveText("Saved."); + await expect(lane.getByRole("button", { name: "Save policy" })).toBeEnabled(); + await expect(lane.getByText("Unsaved changes")).toHaveCount(0); + await expect(enable).toBeChecked(); + await enable.uncheck(); + await expect(enable).not.toBeChecked(); + await expect(lane.getByText("Unsaved changes")).toBeVisible(); await lane.getByRole("button", { name: "Save policy" }).click(); + await expect(lane.getByRole("button", { name: "Save policy" })).toBeEnabled(); + await expect(lane.getByText("Unsaved changes")).toHaveCount(0); await expect.poll(laneArmed, { timeout: 30_000 }).toBe(false); }); diff --git a/scripts/queue-lock.test.mjs b/scripts/queue-lock.test.mjs @@ -97,6 +97,26 @@ function markerCmd(logFile, id, holdMs) { ]; } +// The same, held until `gateFile` exists (or `maxMs` passes) rather than for a +// fixed time: a test opens the gate once what it means to see has happened, so +// a loaded machine's slow start of the NEXT run cannot outlast the hold. (A +// fixed hold was the release 28 flake: under `test:scripts`' parallel files, +// the second run sometimes started after the first had already ended.) The +// cap keeps a run that should have been admitted, and was not, from hanging +// the test: it ends, and the order assertion names what went wrong. +function gateCmd(logFile, id, gateFile, maxMs = 20_000) { + return [ + process.execPath, + "-e", + `const fs=require("fs");` + + `fs.appendFileSync(${JSON.stringify(logFile)},"S${id}");` + + `const t0=Date.now();` + + `const tick=()=>{if(fs.existsSync(${JSON.stringify(gateFile)})||Date.now()-t0>${maxMs}){fs.appendFileSync(${JSON.stringify(logFile)},"E${id}");}else setTimeout(tick,20);};` + + `tick();`, + ]; +} +const openGate = (gateFile) => fs.writeFileSync(gateFile, ""); + const delay = (ms) => new Promise((r) => setTimeout(r, ms)); test("serializes concurrent invocations", async () => { @@ -636,12 +656,16 @@ test("two weighted jobs run side by side; a third waits for headroom, named in t meminfo(env.HEAVY_MEMINFO_FILE, 8000); const jobs = path.join(dir, "heavy.lock.jobs"); const tickets = () => (fs.existsSync(jobs) ? fs.readdirSync(jobs).filter((n) => n.endsWith(".json")).length : 0); - const a = startLock(["--heavy", "--estimate", "1500", "--", ...markerCmd(log, "a", 1500)], env); + // a and b hold until c has been seen waiting: their overlap, and c's wait, + // are then by the gate, not by how fast this machine starts a process. + const gate = path.join(dir, "gate-ab"); + const a = startLock(["--heavy", "--estimate", "1500", "--", ...gateCmd(log, "a", gate)], env); await until(() => tickets() === 1); - const b = startLock(["--heavy", "--estimate", "1500", "--", ...markerCmd(log, "b", 1500)], env); + const b = startLock(["--heavy", "--estimate", "1500", "--", ...gateCmd(log, "b", gate)], env); await until(() => tickets() === 2); const c = startLock(["--heavy", "--estimate", "1500", "--", ...markerCmd(log, "c", 50)], env); await c.waitFor(/waiting for memory — 8000 MB available, 3000 MB promised to 2 running jobs, the floor is 6000 MB/); + openGate(gate); const [ra, rb, rc] = await Promise.all([a.done, b.done, c.done]); assert.equal(ra.code, 0, ra.stderr); assert.equal(rb.code, 0, rb.stderr); @@ -793,11 +817,15 @@ test("--with: a suite that shares a tree holds the other suite's queue too", asy const dir = tmpDir(); const log = path.join(dir, "order.log"); const env = heavyEnv(dir, { E2E_QUEUE_LOCK_FILE: path.join(dir, "q.lock") }); - const editor = startLock(["--name", "e2e-editor", "--with", "e2e-export", "--estimate", "100", "--", ...markerCmd(log, "e", 700)], env); + // The editor holds until umtool has run: umtool's start "beside the editor" + // is then the lock's doing, not a race against a 700 ms hold. + const gate = path.join(dir, "gate-e"); + const editor = startLock(["--name", "e2e-editor", "--with", "e2e-export", "--estimate", "100", "--", ...gateCmd(log, "e", gate)], env); await until(() => fs.existsSync(path.join(dir, "q.lock.e2e-export.holder.json"))); const exp = startLock(["--name", "e2e-export", "--estimate", "100", "--", ...markerCmd(log, "x", 50)], env); await exp.waitFor(/waiting for the e2e queue — held by .*pid \d+/); const umtool = await runLock(["--name", "e2e-umtool", "--estimate", "100", "--", ...markerCmd(log, "u", 50)], env); + openGate(gate); for (const r of [await editor.done, await exp.done, umtool]) assert.equal(r.code, 0, r.stderr); const order = fs.readFileSync(log, "utf8"); assert.ok(order.indexOf("Sx") > order.indexOf("Ee"), `export ran beside the editor: ${order}`);