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
fix(flow): share moving total-WIP replay limits [R1,R2,H16]
Corey Olsone2dbe9a9c520
diff --git a/docs/formats.md b/docs/formats.mdindex 45228d75..77e24804 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -551,7 +551,7 @@ The engine-68 `recordSpecApprovalBaseline` move carries `{agentId, baseline: {ve`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) and the board's `settings.reviewsFirst`, `wipPerReviewer`, `landingBatchSize` and `landingCadenceMinutes`, with the same ranges and off values as `settings line`. `barReady` and `takeoverMinutes` are refused by name as “not modelled by replay”, even when off. Internal stage capacities are not public setting names. Explicit controls are scheduling predictions, never live setting writes. WIP uses the ceiling of the ratio times distinct observed reviewer seats, bounded further by each recorded seat's observed concurrency. Reviews-first prioritizes ready reviews without preemption. Landing batches take at most the requested number of ready items; the next batch waits for prior completion and the requested start-to-start cadence. Off or unspecified controls retain observed capacities without adding a batch/cadence restriction. Every prediction retains recorded arrivals, seats and work intervals; those intervals include observed waiting and are not CPU measurements.+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) and the board's `settings.reviewsFirst`, `wipPerReviewer`, `landingBatchSize` and `landingCadenceMinutes`, with the same ranges and off values as `settings line`. `barReady` and `takeoverMinutes` are refused by name as “not modelled by replay”, even when off. Internal stage capacities are not public setting names. Explicit controls are scheduling predictions, never live setting writes. Predicted WIP uses the shared unrounded total cap over claimed and submitted items, with distinct reservation/verdict actors inside the trailing 60-minute window ending at each simulated moment; an empty window counts as one reviewer. Only complete measured cycles supply simulated activity; incomplete work remains explicitly unmeasured. Recorded seat concurrency still bounds every stage. Reviews-first prioritizes ready reviews only above the native submitted-backlog threshold, without preemption. Landing batches take at most the requested number of ready items; the next batch waits for prior completion and the requested start-to-start cadence. Off or unspecified controls retain observed capacities without adding a batch/cadence restriction. Every prediction retains recorded arrivals, seats and work intervals; those intervals include observed waiting and are not CPU measurements.`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/flow-replay.js b/src/flow-replay.jsindex 23e12f44..7a351084 100644--- a/src/flow-replay.js+++ b/src/flow-replay.js@@ -1,5 +1,9 @@/** Deterministic scheduling of observed intervals; predictions are not measurements of an alternate live queue. */import { Refused } from './refused.js';+import {+ ACTIVE_REVIEWER_WINDOW_MINUTES,+ lineWipLimit,+} from './line-wip-limit.js';import {replayHistory,replayObservations,@@ -29,12 +33,7 @@ function replayPolicy(input, observations) {throw new Refused('USAGE', `replay ${key} must use its supported board line-setting range; read pullboard settings line`);}}- const reviewers = new Set(observations.tasks.filter(task => task.stage === 'review').map(task => task.by)).size;- const capacity = { ...observations.stages };- if (settings.wipPerReviewer !== undefined && settings.wipPerReviewer !== false) {- capacity.build = capacity.review = Math.max(1, Math.ceil(settings.wipPerReviewer * reviewers));- }- return { order, settings: { ...settings }, capacity, reviewers, recorded: order === 'recorded' && !Object.keys(settings).length };+ return { order, settings: { ...settings }, capacity: { ...observations.stages }, recorded: order === 'recorded' && !Object.keys(settings).length };}@@ -51,6 +50,7 @@ function quartiles(values) {function schedule(observations, policy) {const pending = new Map(observations.tasks.map(task => [task.id, task]));const completed = new Map(), running = [];+ const activeWip = new Set(), submitted = new Set(), reviewActivity = [];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 = policy.capacity;@@ -61,31 +61,53 @@ function schedule(observations, policy) {/** 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);+ /** Count only reservations and verdicts already reached by this simulated clock, including the window boundary. */+ const activeReviewers = () => new Set(reviewActivity.filter(event => event.at >= now - ACTIVE_REVIEWER_WINDOW_MINUTES * MINUTE+ && event.at <= now).map(event => event.by)).size;+ /** Native reviews-first is a backlog threshold, independent of the opt-in total-WIP admission cap. */+ const prioritizeReviews = () => policy.settings.reviewsFirst === true+ && submitted.size > lineWipLimit(typeof policy.settings.wipPerReviewer === 'number' ? policy.settings.wipPerReviewer : 3, activeReviewers());/** 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 :- (policy.settings.reviewsFirst ? Number(b.stage === 'review') - Number(a.stage === 'review') : 0)+ (prioritizeReviews() ? Number(b.stage === 'review') - Number(a.stage === 'review') : 0)|| (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); }+ if (running[i].end <= now) {+ const row = running.splice(i, 1)[0];+ completed.set(row.task.id, row);+ if (row.task.stage === 'build') submitted.add(row.task.item);+ if (row.task.stage === 'review') {+ submitted.delete(row.task.item);+ activeWip.delete(row.task.item);+ reviewActivity.push({ at: row.end, by: row.task.by });+ }+ }}if (batched && !batch.size && now >= Math.max(batchStarted + cadence, batchFinished)) {const ready = [...pending.values()].filter(task => task.stage === 'landing' && readyAt(task) <= now).sort(compare).slice(0, batchSize);if (ready.length) { batch = new Set(ready.map(task => task.id)); batchUnstarted = true; }}+ let started = false;for (const task of [...pending.values()].sort(compare)) {if (batched && task.stage === 'landing' && !batch.has(task.id)) continue;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;+ if (!policy.recorded && task.stage === 'build' && typeof policy.settings.wipPerReviewer === 'number'+ && activeWip.size + 1 > lineWipLimit(policy.settings.wipPerReviewer, activeReviewers())) continue;if (batched && task.stage === 'landing' && batchUnstarted) { batchStarted = now; batchUnstarted = false; }pending.delete(task.id);+ if (task.stage === 'build') activeWip.add(task.item);+ if (task.stage === 'review') reviewActivity.push({ at: now, by: task.by });running.push({ task, start: now, end: now + task.duration });+ started = true;}if (batched && batch.size && [...batch].every(id => completed.has(id))) {batchFinished = Math.max(...[...batch].map(id => completed.get(id).end));batch.clear();continue;}+ if (started) continue; // A new reservation may admit another build at this same simulated instant.if (!pending.size && !running.length) break;const batchAt = batched && !batch.size && [...pending.values()].some(task => task.stage === 'landing' && readyAt(task) <= now)? Math.max(batchStarted + cadence, batchFinished) : Infinity;@@ -119,7 +141,8 @@ export function replayFlow(events, inputPolicy) {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; modelled board controls change scheduling only.',- `WIP uses ceil(ratio times ${policy.reviewers} distinct observed reviewer seats), not an invented workforce.`,+ `Predicted total WIP uses the native unrounded cap and distinct simulated reservation/verdict actors in the trailing ${ACTIVE_REVIEWER_WINDOW_MINUTES}-minute window, minimum one.`,+ 'Only complete measured cycles supply simulated reviewer activity; incomplete or abandoned work stays explicitly unmeasured.','Landing batches contain ready items only; the next batch waits for prior completion and its start-to-start cadence.','Predicted queue times are not timings measured by running an alternate live policy.','Incomplete or abandoned attempts remain unmeasured, never zero-duration work.'] } };