Skip to content

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.

refactor(line): share the active reviewer window [N2,R1,H16]

Corey Olson962321c84a06
diff --git a/docs/formats.md b/docs/formats.md
index 9652570b..73551476 100644
--- a/docs/formats.md
+++ b/docs/formats.md
@@ -627,6 +627,6 @@ its number at landing; no event-log or envelope format changes.
### Line capacity decisions
-With `reviewsFirst` on, ordinary `next` offers an eligible review before a build when outstanding submissions exceed `wipPerReviewer` times the active-reviewer count (or ratio 3 while that numeric control is off). No permanent builder/reviewer seat type or role flag is required. Active reviewers are distinct registered seats with a reservation or verdict inside the flow window; its default is the last hour, and an empty window counts as one reviewer. The window uses the same validated boundaries as `stats --window`.
+With `reviewsFirst` on, ordinary `next` offers an eligible review before a build when outstanding submissions exceed `wipPerReviewer` times the active-reviewer count (or ratio 3 while that numeric control is off). No permanent builder/reviewer seat type or role flag is required. Active reviewers are distinct registered seats with a reservation or verdict inside the flow window; its default is the last hour, and an empty window counts as one reviewer. The window uses the same validated boundaries as `stats --window`; its native duration is the shared `ACTIVE_REVIEWER_WINDOW_MINUTES` constant (60), not the measurement metadata or a new board setting.
With numeric `wipPerReviewer` on, a new claim that would exceed that limit is refused as `LINE_WIP_LIMIT`, naming the oldest eligible pending review when there is one. Live claimed items and outstanding submissions count; expired claims do not. The shared pure `lineWipLimit` function computes the total cap without rounding, using at least one observed reviewer. Renewals remain possible. The native claim carries the configured verifier and family policies so its suggested review never relaxes those guards. With `takeoverMinutes` on, a sent-back item's idle interval can end its original builder's first-refusal window early; a live claim is never stolen, and normal claim appends preserve the old history. Disabled controls retain the previous behavior. New claims under these controls carry a true `lineCapacity` argument and the line-capacity engine floor; marker-absent older recorded claims keep their historical meaning during replay.
diff --git a/src/line-capacity.js b/src/line-capacity.js
index 925e6d3c..57e31929 100644
--- a/src/line-capacity.js
+++ b/src/line-capacity.js
@@ -4,7 +4,7 @@ import { LINE_CAPACITY_ENGINE } from './line-capacity-engine.js';
import { lineSettings } from './line-settings.js';
import { flowWindowBounds } from './stats-flow-window.js';
import { Refused } from './refused.js';
-import { lineWipLimit } from './line-wip-limit.js';
+import { ACTIVE_REVIEWER_WINDOW_MINUTES, lineWipLimit } from './line-wip-limit.js';
/** Old ordered claims keep their original semantics even beside newer recorded controls. */
export function capacitySettings(board) {
@@ -12,7 +12,7 @@ export function capacitySettings(board) {
}
/** The controller and capacity count use the same validated flow-window boundaries; the default is one hour. */
-export function lineCapacitySnapshot(board, { windowMinutes = 60 } = {}) {
+export function lineCapacitySnapshot(board, { windowMinutes = ACTIVE_REVIEWER_WINDOW_MINUTES } = {}) {
const at = board.clock.now().getTime();
const window = flowWindowBounds(windowMinutes, at);
const reviewers = board.db.prepare(`SELECT DISTINCT event_by FROM event JOIN agent ON agent_id=event_by
diff --git a/src/line-wip-limit.js b/src/line-wip-limit.js
index b42d776f..69d1e313 100644
--- a/src/line-wip-limit.js
+++ b/src/line-wip-limit.js
@@ -1,4 +1,7 @@
/** One pure total-WIP cap for recorded native decisions and counterfactual replay [N2,R1,H16]. */
+/** The recorded controller currently observes review activity over one hour; a future setting is separate. */
+export const ACTIVE_REVIEWER_WINDOW_MINUTES = 60;
+
/**
* Return the cap from an already validated line-setting ratio and observed distinct reviewer count.
* Off has no cap; an empty observation window uses one reviewer. Fractional caps are not rounded:
diff --git a/test/line-capacity.test.js b/test/line-capacity.test.js
index ae497745..293016bc 100644
--- a/test/line-capacity.test.js
+++ b/test/line-capacity.test.js
@@ -48,8 +48,10 @@ test('capacity counts distinct review actors in the same bounded flow window, no
store.reserveReview(f.board, first, { agentId: f.reviewer, leaseMs: HOUR, policy: 'any' });
store.reserveReview(f.board, second, { agentId: 'coordinator', leaseMs: HOUR, policy: 'any' });
assert.equal(lineCapacitySnapshot(f.board).activeReviewers, 2, 'a core seat and coordinator are both observed reviewers; renewals do not duplicate them');
- f.advance(2 * HOUR);
- assert.equal(lineCapacitySnapshot(f.board).activeReviewers, 1);
+ f.advance(HOUR);
+ assert.equal(lineCapacitySnapshot(f.board).activeReviewers, 2, 'the shared sixty-minute boundary is inclusive');
+ f.advance(1);
+ assert.equal(lineCapacitySnapshot(f.board).activeReviewers, 1, 'activity just outside the window expires');
assert.equal(lineCapacitySnapshot(f.board, { windowMinutes: 180 }).activeReviewers, 2, 'the explicit flow window changes both bounds');
assert.throws(() => lineCapacitySnapshot(f.board, { windowMinutes: Infinity }), { code: 'USAGE' });
});