Lead decision 59. task_current picks each task's current snapshot, skipping a poll row whose read_at is at or before the latest self row's at; tasks_open reads it. Prototype on Node 24 and 26, two mutants caught, and Dewey's fixture replayed: tasks_open now differs from v3a only on #42 (in-progress). The notes add an S3 poller rule: compare a read against task_current, not the raw latest row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
28 lines
2.1 KiB
JavaScript
28 lines
2.1 KiB
JavaScript
// Replays Dewey's slice 1 mockup fixture (read-only) into schema v3a and v3b, the way
|
|
// checks/slice1-verify.mjs check 15 does, and compares tasks_open. No browser.
|
|
import { readFileSync } from "node:fs";
|
|
import { DatabaseSync } from "node:sqlite";
|
|
import vm from "node:vm";
|
|
import { createHash } from "node:crypto";
|
|
const [dataJs, v3a, v3b] = process.argv.slice(2);
|
|
const ctx = { window: {} }; vm.createContext(ctx); vm.runInContext(readFileSync(dataJs, "utf8"), ctx);
|
|
const S = ctx.window.S1;
|
|
const order = ["decisions", "messages", "deliveries", "decision_events", "role_claims", "events", "task_snapshots"];
|
|
const run = (file) => {
|
|
const schema = readFileSync(file, "utf8");
|
|
const db = new DatabaseSync(":memory:"); db.exec(schema);
|
|
const cols = Object.fromEntries(order.map((t) => [t, db.prepare(`PRAGMA table_info(${t})`).all().map((c) => c.name).filter((c) => c !== "seq")]));
|
|
const rows = order.flatMap((t, ti) => S[t].map((r) => ({ t, ti, r }))).sort((a, b) => a.r.at.localeCompare(b.r.at) || a.ti - b.ti);
|
|
let bad = 0;
|
|
for (const { t, r } of rows) { try { db.prepare(`INSERT INTO ${t} (${cols[t].join(",")}) VALUES (${cols[t].map(() => "?").join(",")})`).run(...cols[t].map((c) => r[c] ?? null)); } catch (e) { bad++; console.log("refused", t, e.message); } }
|
|
const open = db.prepare("SELECT task_ref, bucket FROM tasks_open").all().map((x) => `${x.task_ref} ${S.lookups.buckets[x.bucket]}`).sort();
|
|
const ext = db.prepare("SELECT task_ref FROM task_external_changes ORDER BY task_ref").all().map((x) => x.task_ref);
|
|
const urgent = db.prepare("SELECT id FROM urgent_inbox ORDER BY id").all().map((x) => x.id);
|
|
console.log(file.split("/").pop(), createHash("sha256").update(schema).digest("hex").slice(0, 8), `rows ${rows.length} refused ${bad}`);
|
|
return { open, ext, urgent };
|
|
};
|
|
const a = run(v3a), b = run(v3b);
|
|
console.log("tasks_open only in v3a:", JSON.stringify(a.open.filter((x) => !b.open.includes(x))));
|
|
console.log("tasks_open only in v3b:", JSON.stringify(b.open.filter((x) => !a.open.includes(x))));
|
|
console.log("task_external_changes same:", a.ext.join() === b.ext.join(), "| urgent_inbox same:", a.urgent.join() === b.urgent.join());
|