// The measure extras' test fixture (measure-extras.test.mjs), made from the // synthetic measure slice the weight-video lanes shared (real quartering-diet // ledger rows, fake cut times; 438 KB): only what the goal stack, the moving // start, the promise clock and the diet badge read -- every goal, remembered // weight, promise and check, the diet events that change the state's diet -- // and of each state only the fields they read. // // node umtool/report-to-video/fixtures/measure-extras/make-fixture.mjs // // writes measure.json beside this file. Synthetic times, like every fixture. import { readFileSync, writeFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; // SYNTHETIC (CONTRACT addenda, 6 Nov): a second speaker's claim on the scale-video // promise and its outcome, so the promise clock's counterparty and refunded // stamp have something to draw. NOT ledger rows -- the measure-ledger lane // writes the real ones (her X post, her video). Each is marked `synthetic`. export function addSyntheticPromiseRows(slice) { const claim = { t: 716, row: "SYNTH-c01", segment: "s179", date: "2026-10-24", asOf: null, kind: "promiseClaim", value: null, qualifier: null, display: "paid for it", label: "I bought the 5 bags — where's the scale video?", deadline: null, regime: null, event: null, promise: "p01", speaker: "madamsavvy", source: "post", synthetic: true, }; const outcome = { t: 722, row: "SYNTH-o01", segment: "s180", date: "2026-10-31", asOf: null, kind: "promiseOutcome", value: null, qualifier: null, display: "refunded", label: "Your refund has been processed… best of luck on your weight loss journey", deadline: null, regime: null, event: null, promise: "p01", speaker: "madamsavvy", outcome: "refunded", source: "clip", synthetic: true, }; for (const e of [claim, outcome]) { const i = slice.events.findIndex((x) => x.t > e.t); const at = i < 0 ? slice.events.length : i; const before = slice.state[at]; slice.events.splice(at, 0, e); slice.state.splice(at + 1, 0, { ...structuredClone(before), t: e.t }); } slice.state = slice.state.map((s) => ({ ...s, promises: (s.promises ?? []).map((p) => (p.row !== "p01" ? p : { ...p, claims: s.t >= claim.t ? [{ row: claim.row, speaker: "madamsavvy", date: claim.date, label: claim.label, synthetic: true }] : [], outcome: s.t >= outcome.t ? { kind: "refunded", date: outcome.date, row: outcome.row, synthetic: true } : null, })), })); return slice; } if (import.meta.url === `file://${process.argv[1]}`) { const src = process.argv[2]; if (!src) { console.error("usage: make-fixture.mjs "); process.exit(2); } const m = JSON.parse(readFileSync(src, "utf8")); const KINDS = new Set(["goal", "goalLoss", "remembered", "promise", "promiseCheck"]); const EVENT_KEYS = ["t", "row", "segment", "date", "asOf", "kind", "value", "qualifier", "display", "label", "deadline", "regime", "event", "promise", "source"]; const STATE_KEYS = ["t", "goal", "goals", "diet", "promises"]; const pick = (o, keys) => Object.fromEntries(keys.filter((k) => o[k] !== undefined).map((k) => [k, o[k]])); const events = []; const state = [pick(m.state[0], STATE_KEYS)]; let dietKey = null; m.events.forEach((e, i) => { const s = m.state[i + 1]; const d = s?.diet ? `${s.diet.regime}|${s.diet.n}|${s.diet.display}` : "none"; const keep = KINDS.has(e.kind) || (e.kind === "diet" && d !== dietKey); dietKey = d; if (!keep) return; events.push({ ...pick(e, EVENT_KEYS), ...(e.kind === "promise" || e.kind === "promiseCheck" ? { quote: e.quote } : {}) }); state.push(pick(s, STATE_KEYS)); }); const out = { version: m.version, unit: m.unit, scale: m.scale, asOfRender: m.asOfRender, scopes: m.scopes, events, hidden: [], state, totals: pick(m.totals, ["goals", "goalRepeats", "diets", "peakDrift"]), _fixture: "measure-extras test fixture: made by make-fixture.mjs from the lanes' synthetic measure slice (real ledger rows, fake cut times)", }; addSyntheticPromiseRows(out); out._fixture += "; SYNTHETIC rows SYNTH-c01 (a promiseClaim by madamsavvy) and SYNTH-o01 (a refunded promiseOutcome) added by addSyntheticPromiseRows"; const file = fileURLToPath(new URL("./measure.json", import.meta.url)); writeFileSync(file, JSON.stringify(out) + "\n"); console.log(`${file}: ${events.length} events, ${(JSON.stringify(out).length / 1024).toFixed(1)} KB`); }