Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(flow): replay text-free history under bounded policies [R1,R2,A1]
Corey Olson7dd75eb6cf98
diff --git a/docs/formats.md b/docs/formats.mdindex 58f1dd30..f7925da2 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -527,3 +527,11 @@ A row approved after the board’s compatibility baseline is reported as `agent-Engine 68 retains the existing validated verifier note in new acceptance-event detail. Earlier engines retain their original receipt shape; later person confirmations project current approval state beside that immutable history. No new row status or approval authority is inferred from a Git author or an unsigned receipt.The engine-68 `recordSpecApprovalBaseline` move carries `{agentId, baseline: {version: 1, file, anchor, rows: [{id, text, source}]}}`. `anchor` is the current commit or `null` before the first commit; exact source rows also cover uncommitted initial requirements. Only the authenticated coordinator may establish the snapshot; a person uses the main checkout’s coordinator path. Lane commands never seed or replace it. The first snapshot is indexed under `board_meta.spec_approval_baseline` with a `spec_approval_baseline` event. Replay writes metadata only, never checkout files. Sender attribution is authenticated normally, older engines refuse the new move, and later bootstrap attempts cannot replace or expand the original snapshot. No local sidecar establishes shared approval authority. The metadata snapshot must agree with its single original coordinator event; a partial restore with either half missing or changed is invalid. A malformed stored marker remains in place with an invalid-baseline diagnostic; it is not treated as an absent migration baseline or reseeded by later commands. Board imports remain trusted recovery operations; agreement of these records is a consistency check, not cryptographic authentication of an imported history.++## Offline flow replay++`pullboard flow replay --json` reads only event ids, kinds, times, item ids and seat ids from the board. The result includes `history: { version: 1, events: [...] }`; each event has only `event_id`, `event_kind`, `event_at`, `item_id` and `event_by`. No title, description, message, path, commit or event-detail JSON is fetched or exported. Save that history object as JSON and pass it with `--history <file>` to replay the same input on another board.++The default policy, `{"order":"recorded"}`, keeps recorded stage starts, durations and seat concurrency, reproducing complete measured cycles. `--policy <file>` accepts an explicit item-id order (a partial list prioritizes those ids), plus optional positive integer `settings.buildWip`, `settings.reviewWip` and `settings.landingWip`. These are hypothetical replay limits, not changes to the live board or machine. Unspecified limits come from observed concurrent stage intervals; recorded seat identities and their observed concurrency remain fixed. A different order or limit schedules ready work without preemption, retaining item arrivals and every measured build/review/landing interval. Recorded policy has exact observed start constraints; alternate policy has none of the observed queue delays.++`replay` reports landing order, each first-claim-to-landed time, and stage quartiles in minutes using the existing flow-window convention (fast/slow quarters use the sorted sample at floor(n/4) and floor(3n/4), with the middle pair averaged for an even median). These counterfactual predictions are not timings measured under an alternate live queue. Landing intervals are the recorded accept-to-merged spans, including observed waiting, not an estimate of CPU work. Incomplete, abandoned or missing-boundary cycles appear in `unmeasured`; they never become zero-duration work. Rejected complete attempts retain their actual builder/reviewer seats and durations. No wall clock or random values enter the replay result.diff --git a/src/cli.js b/src/cli.jsindex 0bbf19fd..73944a55 100644--- a/src/cli.js+++ b/src/cli.js@@ -568,6 +568,7 @@ const OPTIONS = {verbose: { type: 'boolean' },since: { type: 'string' },window: { type: 'string' },+ policy: { type: 'string' },decision: { type: 'boolean' },evidence: { type: 'string' },outcome: { type: 'string' },@@ -598,7 +599,9 @@ function parseCommandArgs(argv) {} catch { /* The final parser supplies the existing actionable usage error. */ }}const options = ['add', 'edit'].includes(command) ? { ...OPTIONS, wait: { type: 'boolean' } } : OPTIONS;- return parseArgs({ args: argv, options, allowPositionals: true });+ // Flow consumes a history file; show retains its existing boolean --history switch.+ const commandOptions = command === 'flow' ? { ...options, history: { type: 'string' } } : options;+ return parseArgs({ args: argv, options: commandOptions, allowPositionals: true });}/** Start an already-recorded request, recording an unavailable result if its child cannot start. */diff --git a/src/commands/flow.js b/src/commands/flow.jsnew file mode 100644index 00000000..cd42af9e--- /dev/null+++ b/src/commands/flow.js@@ -0,0 +1,32 @@+/** The read-only replay bench: structural history in, deterministic scheduling predictions out [R1,R2,A1]. */+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import {+ context,+ withBoard,+} from '../cli.js';+import { replayFlow } from '../flow-replay.js';+import { Refused } from '../refused.js';++/** Read explicit JSON data, never a script, with an actionable refusal for a malformed input. */+function readJson(root, file, label) {+ try { return JSON.parse(readFileSync(resolve(root, file), 'utf8')); }+ catch { throw new Refused('USAGE', `readable JSON is required for replay ${label}; correct the file and run pullboard flow replay again`); }+}++/** Run `pullboard flow replay`; exported history contains no detail, descriptions, paths or commit strings. */+export function run(io, { first, second, rest, values }) {+ if (first !== 'replay' || second || rest.length) throw new Refused('USAGE', 'run pullboard flow replay [--history <json>] [--policy <json>] --json');+ const ctx = context(io);+ const input = values.history === undefined ? withBoard(ctx, board => ({ version: 1,+ // Do not fetch event_detail: replay/export never reads a title, message, note, path or commit.+ events: board.db.prepare('SELECT event_id, event_kind, event_at, item_id, event_by FROM event ORDER BY event_id').all() })) : readJson(ctx.info.root, values.history, 'history');+ if (input?.version !== 1) throw new Refused('USAGE', 'replay history needs version 1 and an events array exported by pullboard flow replay --json');+ const policy = values.policy === undefined ? undefined : readJson(ctx.info.root, values.policy, 'policy');+ const result = replayFlow(input.events, policy);+ io.result?.(result);+ io.say(`flow replay: ${result.replay.mode}; ${result.replay.items.length} measured, ${result.replay.unmeasured.length} unmeasured`);+ io.say(`landing order: ${result.replay.landingOrder.map(id => `#${id}`).join(', ') || 'none'}`);+ for (const [stage, row] of Object.entries(result.replay.stages)) io.say(`${stage}: ${row.count} measured; fast ${row.fastQuarterMinutes ?? 'unknown'}, median ${row.medianMinutes ?? 'unknown'}, slow ${row.slowQuarterMinutes ?? 'unknown'} minutes`);+ return 0;+}diff --git a/src/flow-replay-history.js b/src/flow-replay-history.jsnew file mode 100644index 00000000..03e2afa0--- /dev/null+++ b/src/flow-replay-history.js@@ -0,0 +1,99 @@+/** Text-free lifecycle observations for an offline replay, never a second board state machine [R1,R2]. */+import { Refused } from './refused.js';++const KINDS = new Set(['join', 'add', 'claim', 'submit', 'reserve', 'accept', 'reject', 'merged', 'release', 'reopen', 'refreeze', 'lapse', 'escalate', 'withdraw']);++/** Project only structural identifiers, kinds and times; no event detail or current item row is read. */+export function replayHistory(events) {+ if (!Array.isArray(events)) throw new Refused('USAGE', 'replay history needs an events array exported by pullboard flow replay --json');+ const seen = new Set();+ const rows = [];+ for (const event of events) {+ if (!KINDS.has(event.event_kind)) continue;+ const id = event.event_id;+ const at = Date.parse(event.event_at);+ const item = event.item_id;+ const by = event.event_by;+ if (!Number.isSafeInteger(id) || id < 1 || seen.has(id) || !Number.isFinite(at)+ || typeof by !== 'string' || !/^[a-z][a-z0-9-]*$/u.test(by)+ || (event.event_kind !== 'join' && (!Number.isSafeInteger(item) || item < 1))) {+ throw new Refused('USAGE', 'replay history needs unique positive event ids, valid times, native seat ids and positive lifecycle item ids');+ }+ seen.add(id);+ rows.push({ event_id: id, event_at: new Date(at).toISOString(), event_kind: event.event_kind,+ item_id: event.event_kind === 'join' ? null : item, event_by: by });+ }+ rows.sort((a, b) => Date.parse(a.event_at) - Date.parse(b.event_at) || a.event_id - b.event_id);+ return { version: 1, events: rows };+}++/** Maximum simultaneous measured intervals; adjacent and zero-length intervals do not consume two places. */+export function observedCapacity(tasks) {+ const edges = tasks.flatMap(task => task.end > task.start ? [[task.start, 1], [task.end, -1]] : []);+ edges.sort((a, b) => a[0] - b[0] || a[1] - b[1]);+ let used = 0, peak = 1;+ for (const [, delta] of edges) { used += delta; peak = Math.max(peak, used); }+ return peak;+}++/** Compile only complete measured attempts; absent reservations or abandoned work stay explicitly unmeasured. */+export function replayObservations(history) {+ const items = new Map();+ const seats = new Map();+ const origin = history.events.length ? Date.parse(history.events[0].event_at) : 0;+ let nextTask = 0;+ for (const event of history.events) {+ const at = Date.parse(event.event_at), by = event.event_by, id = event.item_id;+ if (event.event_kind === 'join') { if (!seats.has(by)) seats.set(by, at); continue; }+ if (!items.has(id)) items.set(id, { id, tasks: [], missing: [], arrival: null, landed: null });+ const item = items.get(id);+ if (item.landed !== null) continue;+ /** Record an interval and its actual seat, retaining the previous attempt as its dependency. */+ const task = (stage, start, end, actor) => {+ if (!Number.isFinite(start) || end < start || typeof actor !== 'string') {+ item.missing.push(`missing ${stage} boundary`); return null;+ }+ const row = { id: nextTask++, item: id, stage, start, end, duration: end - start, by: actor,+ prior: item.tasks.at(-1) ?? null };+ item.tasks.push(row);+ return row;+ };+ switch (event.event_kind) {+ case 'add': item.arrival ??= at; break;+ case 'claim':+ if (item.claim) item.missing.push('abandoned build attempt');+ item.claim = { at, by }; break;+ case 'submit':+ task('build', item.claim?.at, at, item.claim?.by);+ item.claim = null; item.submitted = at; break;+ case 'reserve':+ if (item.reserve) item.missing.push('replaced review reservation');+ item.reserve = { at, by }; break;+ case 'accept':+ case 'reject':+ if (item.submitted === undefined || item.reserve?.by !== by || item.tasks.at(-1)?.stage !== 'build') item.missing.push('missing review boundary');+ task('review', item.reserve?.at, at, by);+ item.reserve = null;+ item.accepted = event.event_kind === 'accept' ? { at, by: null } : null;+ break;+ case 'merged':+ task('landing', item.accepted?.at, at, by);+ item.landed = at; item.landedEvent = event.event_id; break;+ case 'release': case 'reopen': case 'refreeze': case 'lapse': case 'escalate': case 'withdraw':+ item.missing.push(`unmeasured ${event.event_kind} interval`); break;+ }+ }+ const complete = [], unmeasured = [];+ for (const item of [...items.values()].sort((a, b) => a.id - b.id)) {+ if (item.arrival === null || item.landed === null || !item.tasks.length || item.tasks.at(-1).stage !== 'landing') item.missing.push('incomplete recorded cycle');+ if (item.tasks.some(task => task.start < item.arrival || task.prior && task.start < task.prior.end)) item.missing.push('overlapping or reversed item stages');+ if (item.missing.length) unmeasured.push({ id: item.id, reasons: [...new Set(item.missing)].sort() });+ else complete.push(item);+ }+ const tasks = complete.flatMap(item => item.tasks);+ const stages = Object.fromEntries(['build', 'review', 'landing'].map(stage => [stage, observedCapacity(tasks.filter(task => task.stage === stage))]));+ const actors = [...new Set(tasks.map(task => task.by))].sort();+ const resources = new Map(actors.map(by => [by, { available: seats.get(by) ?? origin,+ capacity: observedCapacity(tasks.filter(task => task.by === by)) }]));+ return { items: complete, tasks, unmeasured, stages, resources, origin };+}diff --git a/src/flow-replay.js b/src/flow-replay.jsnew file mode 100644index 00000000..e7c7e903--- /dev/null+++ b/src/flow-replay.js@@ -0,0 +1,97 @@+/** Deterministic scheduling of observed intervals; predictions are not measurements of an alternate live queue. */+import { Refused } from './refused.js';+import {+ replayHistory,+ replayObservations,+} from './flow-replay-history.js';++const MINUTE = 60_000;+const SETTINGS = { buildWip: 'build', reviewWip: 'review', landingWip: 'landing' };++/** Accept only hypothetical replay limits, never writing machine or board settings. */+function replayPolicy(input, observations) {+ const source = input ?? {};+ if (!source || typeof source !== 'object' || Array.isArray(source)+ || Object.keys(source).some(key => !['order', 'settings'].includes(key))) throw new Refused('USAGE', 'replay policy is an object with order and settings; read pullboard help flow');+ const order = source.order ?? 'recorded';+ if (order !== 'recorded' && (!Array.isArray(order) || order.some(id => !Number.isSafeInteger(id) || id < 1)+ || new Set(order).size !== order.length || order.some(id => !observations.items.some(item => item.id === id)))) {+ throw new Refused('USAGE', 'replay order is recorded or a list of distinct measured item ids');+ }+ const limits = source.settings ?? {};+ if (!limits || typeof limits !== 'object' || Array.isArray(limits)+ || Object.entries(limits).some(([key, value]) => !Object.hasOwn(SETTINGS, key) || !Number.isSafeInteger(value) || value < 1)) {+ throw new Refused('USAGE', 'replay settings accept positive buildWip, reviewWip and landingWip limits only');+ }+ const settings = Object.fromEntries(Object.entries(SETTINGS).map(([key, stage]) => [key, limits[key] ?? observations.stages[stage]]));+ const recorded = order === 'recorded' && Object.entries(SETTINGS).every(([key, stage]) => settings[key] === observations.stages[stage]);+ return { order, settings, recorded };+}++/** Match the existing flow window's quartile convention, retaining nulls when no interval is measured. */+function quartiles(values) {+ const sorted = [...values].sort((a, b) => a - b), count = sorted.length, middle = Math.floor(count / 2);+ return { count, fastQuarterMinutes: count ? sorted[Math.floor(count / 4)] : null,+ medianMinutes: count ? count % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2 : null,+ slowQuarterMinutes: count ? sorted[Math.min(count - 1, Math.floor(3 * count / 4))] : null,+ worstMinutes: count ? sorted.at(-1) : null };+}++/** Schedule each recorded attempt on its recorded seat; explicit order breaks ready-queue ties without preemption. */+function schedule(observations, policy) {+ const pending = new Map(observations.tasks.map(task => [task.id, task]));+ const completed = new Map(), running = [];+ const arrival = new Map(observations.items.map(item => [item.id, item.arrival]));+ const rank = new Map((Array.isArray(policy.order) ? policy.order : []).map((id, index) => [id, index]));+ const capacity = Object.fromEntries(Object.entries(SETTINGS).map(([key, stage]) => [stage, policy.settings[key]]));+ let now = observations.origin;+ /** A measured task starts after arrival, its prior stage and the seat's recorded availability. */+ const readyAt = task => Math.max(arrival.get(task.item), observations.resources.get(task.by).available,+ task.prior ? completed.get(task.prior.id)?.end ?? Infinity : -Infinity, policy.recorded ? task.start : -Infinity);+ /** Recorded decisions preserve their exact start constraints; counterfactual order selects among ready tasks. */+ const compare = (a, b) => policy.recorded ? a.start - b.start || a.id - b.id :+ (rank.get(a.item) ?? Infinity) - (rank.get(b.item) ?? Infinity) || arrival.get(a.item) - arrival.get(b.item) || a.item - b.item || a.id - b.id;+ while (pending.size || running.length) {+ for (let i = running.length - 1; i >= 0; i -= 1) {+ if (running[i].end <= now) { const row = running.splice(i, 1)[0]; completed.set(row.task.id, row); }+ }+ for (const task of [...pending.values()].sort(compare)) {+ if (readyAt(task) > now || running.filter(row => row.task.stage === task.stage).length >= capacity[task.stage]+ || running.filter(row => row.task.by === task.by).length >= observations.resources.get(task.by).capacity) continue;+ pending.delete(task.id);+ running.push({ task, start: now, end: now + task.duration });+ }+ if (!pending.size && !running.length) break;+ const next = Math.min(...running.map(row => row.end), ...[...pending.values()].map(readyAt).filter(at => at > now));+ if (!Number.isFinite(next)) throw new Refused('USAGE', 'replay history has an unschedulable dependency; export a complete lifecycle history');+ now = next;+ }+ return completed;+}++/** Reproduce complete recorded cycles or predict alternate scheduling with identical arrivals, seats and work intervals. */+export function replayFlow(events, inputPolicy) {+ const history = replayHistory(events), observations = replayObservations(history), policy = replayPolicy(inputPolicy, observations);+ const times = schedule(observations, policy);+ const items = observations.items.map(item => {+ const first = times.get(item.tasks[0].id), last = times.get(item.tasks.at(-1).id);+ const values = { build: 0, reviewWait: 0, review: 0, sendBackIdle: 0, mergeWait: 0 };+ for (const task of item.tasks) {+ const row = times.get(task.id), prior = task.prior && times.get(task.prior.id);+ if (task.stage === 'build') { values.build += task.duration / MINUTE; if (prior) values.sendBackIdle += (row.start - prior.end) / MINUTE; }+ if (task.stage === 'review') { values.review += task.duration / MINUTE; values.reviewWait += (row.start - prior.end) / MINUTE; }+ if (task.stage === 'landing') values.mergeWait += (row.end - prior.end) / MINUTE;+ }+ return { id: item.id, arrivalAt: new Date(item.arrival).toISOString(), claimAt: new Date(first.start).toISOString(),+ landedAt: new Date(last.end).toISOString(), cycleMinutes: (last.end - first.start) / MINUTE, stages: values };+ });+ const landingOrder = [...items].sort((a, b) => Date.parse(a.landedAt) - Date.parse(b.landedAt)+ || (policy.recorded ? observations.items.find(item => item.id === a.id).landedEvent - observations.items.find(item => item.id === b.id).landedEvent : 0) || a.id - b.id).map(item => item.id);+ const stages = Object.fromEntries(['build', 'reviewWait', 'review', 'sendBackIdle', 'mergeWait'].map(stage => [stage, quartiles(items.map(item => item.stages[stage]))]));+ return { history, replay: { mode: policy.recorded ? 'recorded' : 'predicted', policy: { order: policy.order, settings: policy.settings },+ items, landingOrder, stages, unmeasured: observations.unmeasured,+ assumptions: ['Recorded lifecycle intervals are retained, not interpreted as CPU time.',+ 'Seat identities and their observed concurrency are fixed; WIP limits are hypothetical replay inputs only.',+ 'Predicted queue times are not timings measured by running an alternate live policy.',+ 'Incomplete or abandoned attempts remain unmeasured, never zero-duration work.'] } };+}diff --git a/src/help.js b/src/help.jsindex 0b3d19e8..b38a63b7 100644--- a/src/help.js+++ b/src/help.js@@ -166,6 +166,8 @@ Coordinatorpullboard hold <lane|id> --off lift a lane or item holdReceipts+ pullboard flow replay [--history <json>] [--policy <json>] reproduce recorded flow or predict another item order and WIP limits+ --json includes text-free structural history; policy order is recorded or item ids, settings are buildWip/reviewWip/landingWippullboard stats [--since <date> | --window <duration>] proof numbers from the event log; --json for sites and tools--window 6h (also 30m or 1d): landed-item stage quartiles, tails and excess over targets;includes all attempts and sent-back idle; missing intervals stay unmeasured;@@ -284,7 +286,7 @@ const HELP_EXAMPLES = {flakes: 'pullboard flakes', 'flakes rerun': 'pullboard flakes rerun on', 'flakes quarantine': 'pullboard flakes quarantine on',verify: 'pullboard verify 12 accept --note "removed the fix; the test failed"',watch: 'pullboard watch --to web', answer: 'pullboard answer 12 "done"', pass: 'pullboard pass 12 "please decide"',- status: 'pullboard status', view: 'pullboard view', digest: 'pullboard digest --out briefing.md', mcp: 'pullboard mcp', stats: 'pullboard stats --since 2026-10-08', log: 'pullboard log 12', ledger: 'pullboard ledger',+ status: 'pullboard status', view: 'pullboard view', digest: 'pullboard digest --out briefing.md', mcp: 'pullboard mcp', flow: 'pullboard flow replay --json', stats: 'pullboard stats --since 2026-10-08', log: 'pullboard log 12', ledger: 'pullboard ledger',relay: 'pullboard relay on --all', 'relay recover': 'pullboard relay recover --skip 12','lane add': 'pullboard lane add web --owns apps/web/', lane: 'pullboard lane add web --owns apps/web/',queue: 'pullboard queue', roadmap: 'pullboard roadmap', rigor: 'pullboard rigor', 'rigor quality': 'pullboard rigor quality --rule silent-catch', 'rigor draft': 'pullboard rigor draft "refusal:MERGE_LOST" "Merges keep every hunk" --check "node bin/checks/merges.js" --red 0123456 --green 89abcde', milestone: 'pullboard milestone add "0.7.0" --items 12,13',diff --git a/test/flow-replay-policy.test.js b/test/flow-replay-policy.test.jsnew file mode 100644index 00000000..2167f30f--- /dev/null+++ b/test/flow-replay-policy.test.js@@ -0,0 +1,74 @@+/** Counterfactual queue boundaries, conservative evidence and text-free inputs [R1,R2,A1]. */+import assert from 'node:assert/strict';+import { test } from 'node:test';+import { replayFlow } from '../src/flow-replay.js';+import { main } from '../src/cli.js';++const BASE = Date.parse('2026-10-20T00:00:00Z');+/** Structural native events with deliberately unreadable private detail. */+function events(moves) {+ return moves.map(([minute, kind, item, by], index) => ({ event_id: index + 1,+ event_at: new Date(BASE + minute * 60_000).toISOString(), event_kind: kind, item_id: item, event_by: by,+ get event_detail() { throw new Error('private detail must never be read'); } }));+}++/** One complete rejected attempt followed by successful measured rework. */+function rework() {+ return events([[0, 'add', 1, 'coordinator'], [1, 'claim', 1, 'web-1'], [3, 'submit', 1, 'web-1'],+ [3, 'reserve', 1, 'review-1'], [4, 'reject', 1, 'review-1'], [5, 'claim', 1, 'web-2'],+ [8, 'submit', 1, 'web-2'], [9, 'reserve', 1, 'review-1'], [11, 'accept', 1, 'review-1'],+ [13, 'merged', 1, 'coordinator']]);+}++test('replay retains rejected work and fixed seats without reading private detail [R1,R2]', () => {+ const input = rework();+ const recorded = replayFlow(input);+ assert.deepEqual(recorded.replay.items[0].stages, { build: 5, reviewWait: 1, review: 3, sendBackIdle: 1, mergeWait: 2 });+ assert.equal(recorded.replay.items[0].cycleMinutes, 12);+ const predicted = replayFlow(input, { order: [1] });+ assert.equal(predicted.replay.items[0].cycleMinutes, 10, 'remove observed queue waits, not the rejected work');+ assert.equal(predicted.replay.stages.build.medianMinutes, 5);+ assert.equal(predicted.replay.stages.review.medianMinutes, 3);+ assert.deepEqual(new Set(predicted.history.events.map(event => event.event_by)), new Set(['coordinator', 'web-1', 'web-2', 'review-1']));+ assert.deepEqual(replayFlow([...input].reverse(), { order: [1] }), predicted, 'event ids and times define the same input ordering');+});++test('unmeasured cycles are reported rather than invented as zero work [R1,R2]', () => {+ const input = events([[0, 'add', 1, 'coordinator'], [1, 'claim', 1, 'web-1'], [2, 'submit', 1, 'web-1'],+ [3, 'accept', 1, 'review-1'], [4, 'merged', 1, 'coordinator'], [0, 'add', 2, 'coordinator']]);+ const result = replayFlow(input);+ assert.deepEqual(result.replay.items, []);+ assert.deepEqual(result.replay.unmeasured.map(item => item.id), [1, 2]);+ assert.match(result.replay.unmeasured[0].reasons.join(' '), /review boundary/u);+ assert.deepEqual(result.replay.stages.build, { count: 0, fastQuarterMinutes: null, medianMinutes: null, slowQuarterMinutes: null, worstMinutes: null });+});++test('recorded landing ties follow event order and hypothetical WIP does not manufacture seats [R1,R2]', () => {+ const input = events([[0, 'add', 1, 'coordinator'], [0, 'add', 2, 'coordinator'],+ [0, 'claim', 1, 'web-1'], [0, 'claim', 2, 'web-2'], [1, 'submit', 1, 'web-1'], [1, 'submit', 2, 'web-2'],+ [1, 'reserve', 2, 'review-1'], [2, 'accept', 2, 'review-1'], [2, 'reserve', 1, 'review-1'],+ [3, 'accept', 1, 'review-1'], [5, 'merged', 2, 'coordinator'], [5, 'merged', 1, 'coordinator']]);+ assert.deepEqual(replayFlow(input).replay.landingOrder, [2, 1]);+ const changed = replayFlow(input, { order: [1, 2], settings: { reviewWip: 2 } });+ assert.equal(changed.replay.items.find(item => item.id === 2).stages.reviewWait, 1,+ 'the one observed reviewer still reviews one item at a time even when global review WIP is two');+});++test('replay refuses invalid limits, unknown item priorities and malformed structural history [R1,R2,A1]', () => {+ for (const policy of [{ order: [1, 1] }, { order: [999] }, { settings: { reviewWip: 0 } },+ { settings: { buildWip: 1.5 } }, { settings: { gateSlots: 10 } }, { extra: true }]) {+ assert.throws(() => replayFlow(rework(), policy), /USAGE/u);+ }+ const invalid = rework();+ invalid[0] = { event_id: 1, event_at: 'not a timestamp', event_kind: 'add', item_id: 1, event_by: 'coordinator' };+ assert.throws(() => replayFlow(invalid), /USAGE/u);+});+++test('show retains its boolean history flag while flow accepts a history file [R1,A1]', async () => {+ let out = '', err = '';+ const code = await main(['help', 'show', '--history'], { stdout: { isTTY: false, write: text => { out += text; } },+ stderr: { write: text => { err += text; } } });+ assert.equal(code, 0, err);+ assert.match(out, /--history/u);+});