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
test(core): cover flow stages and immutable submission sizes [R1,R2,V4]
Corey Olson30e14bcb670d
diff --git a/test/flow-report.test.js b/test/flow-report.test.jsnew file mode 100644index 00000000..8e5474ac--- /dev/null+++ b/test/flow-report.test.js@@ -0,0 +1,144 @@+/** Hand-computed flow reporting uses real Git/SQLite and immutable native history [R1,R2]. */+import assert from 'node:assert/strict';+import { mkdtempSync } from 'node:fs';+import { rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { test } from 'node:test';+import * as store from '../src/board.js';+import { exportBoard } from '../src/exchange.js';+import { importBoard } from '../src/exchange.js';+import { proofStats } from '../src/stats.js';+import { runFixtureGit } from './fixture-child.js';++const BASE = Date.parse('2026-10-10T00:00:00Z');++/** Convert fixture minutes into exact UTC timestamps. */+function at(minutes) { return new Date(BASE + minutes * 60_000).toISOString(); }++/** Construct a captured submission size without inferring old history from today's Git tree. */+function submission(id, lines) {+ const head = id.toString(16).padStart(40, '0');+ return { commit: head, ...(lines === null ? {} : {+ submissionSize: { base: 'a'.repeat(40), head, lines, method: 'added-plus-deleted-no-renames' },+ }) };+}++/** Import immutable event history; deliberately stale current item rows cannot supply its answers. */+function fixture(t, entries) {+ const root = mkdtempSync(join(tmpdir(), 'pullboard-flow-report-'));+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, stdio: 'pipe' });+ const seed = store.openBoard(join(root, '.git', 'seed.sqlite'));+ store.register(seed, { lane: 'coordinator', path: root });+ store.register(seed, { lane: 'core', path: join(root, 'builder') });+ store.register(seed, { lane: 'review', path: join(root, 'reviewer') });+ for (let id = 1; id <= 8; id += 1) {+ store.addItem(seed, { by: 'coordinator', lane: 'core', title: `Report ${id}` });+ }+ const document = exportBoard(seed);+ store.closeBoard(seed);+ const joins = document.tables.agent.map(agent => [0, agent.agent_id, 'join', null, { lane: agent.agent_lane }]);+ document.tables.event = [...joins, ...entries].map((entry, order) => ({ entry, order }))+ .sort((a, b) => a.entry[0] - b.entry[0] || a.order - b.order)+ .map(({ entry: [minutes, by, kind, item, detail = {}] }, index) => ({+ event_id: index + 1, event_at: at(minutes), event_by: by, event_kind: kind,+ item_id: item, event_detail: JSON.stringify(detail),+ }));+ document.tables.sqlite_sequence.find(row => row.name === 'event').seq = document.tables.event.length;+ const board = store.openBoard(join(root, '.git', 'flow.sqlite'));+ importBoard(board, document);+ t.after(() => { store.closeBoard(board); rmSync(root, { recursive: true, force: true }); });+ return board;+}++/** A single known first attempt supplies exact size-edge controls. */+function simple(id, lines) {+ const submitted = submission(id, lines);+ return [+ [0, 'coordinator', 'add', id, { lane: 'core' }],+ [1, 'core-1', 'claim', id, { leaseUntil: at(200) }],+ [2, 'core-1', 'submit', id, submitted],+ [3, 'review-1', 'reserve', id, { until: at(200) }],+ [4, 'review-1', 'accept', id, { commit: submitted.commit }],+ [5, 'coordinator', 'merged', id],+ ];+}++/** The first-try denominator excludes genuinely unknown first decisions. */+function firstTry(accepted, decided, unknown = 0) {+ return { accepted, decided, rate: decided ? accepted / decided : null, unknown };+}++test('the flow report splits time into waiting for an agent, building, review, landing and rework [R1,R2]', t => {+ const first = submission(101, 99), second = submission(102, 900);+ const board = fixture(t, [+ [0, 'coordinator', 'add', 1, { lane: 'core', after: [2] }],+ [0, 'coordinator', 'add', 2, { lane: 'core' }],+ [0, 'coordinator', 'milestone_add', null, { name: 'Release', items: [1, 2] }],+ [0, 'coordinator', 'milestone_add', null, { name: 'Later', items: [3] }],+ [0, 'coordinator', 'line_setting', null, { key: 'focusMilestone', value: 'Release', reason: 'Current release' }],+ [115, 'coordinator', 'line_setting', null, { key: 'focusMilestone', value: 'Later', reason: 'Next release' }],+ [0, 'core-1', 'claim', 2, { leaseUntil: at(200) }],+ [2, 'core-1', 'submit', 2, submission(2, 100)],+ [3, 'review-1', 'reserve', 2, { until: at(200) }],+ [4, 'review-1', 'accept', 2, { commit: submission(2, 100).commit }],+ [10, 'coordinator', 'merged', 2],+ [12, 'coordinator', 'hold_item', 1, { reason: 'Needs a decision' }],+ [17, 'coordinator', 'unhold_item', 1, { reason: 'Decision recorded' }],+ [20, 'core-1', 'claim', 1, { leaseUntil: at(200) }],+ [30, 'core-1', 'submit', 1, first],+ [35, 'review-1', 'reserve', 1, { until: at(40) }],+ [45, 'review-1', 'reserve', 1, { until: at(200) }],+ [50, 'review-1', 'release', 1, { review: true }],+ [55, 'review-1', 'reserve', 1, { until: at(200) }],+ [60, 'review-1', 'reject', 1, { commit: first.commit }],+ [70, 'core-1', 'claim', 1, { leaseUntil: at(200) }],+ [80, 'core-1', 'submit', 1, second],+ [85, 'review-1', 'reserve', 1, { until: at(200) }],+ [90, 'review-1', 'accept', 1, { commit: second.commit }],+ [100, 'coordinator', 'merged', 1],+ ...simple(3, 299).map(([minute, ...entry]) => [minute === 0 ? 110 : minute + 119, ...entry]),+ ...simple(4, 300), ...simple(5, 799), ...simple(6, 800),+ ...simple(7, null),+ // A legacy landing with no original add/claim/submission/verdict cannot acquire fabricated zeroes.+ [100, 'coordinator', 'merged', 8],+ ]);+ const history = store.events(board);+ const report = proofStats(board, { now: BASE + 130 * 60_000 }).flow.report;+ assert.ok(report, 'the canonical observer exposes the requested report');+ const item = report.items.find(row => row.id === 1);+ assert.equal(item.lane, 'core');+ assert.equal(item.milestone, 'Release', 'group by latest recorded milestone membership, not mutable item rows');+ assert.deepEqual(item.stages, {+ ready: { minutes: 11, unknown: 0 }, // Dependency accepted at 4: 4-12 and 17-20.+ later: { minutes: 9, unknown: 0 }, // Dependency 0-4 and explicit hold 12-17.+ build: { minutes: 20, unknown: 0 }, // Both active claims, including the repair claim.+ reviewWait: { minutes: 20, unknown: 0 }, // 30-35, 40-45, 50-55, 80-85.+ review: { minutes: 20, unknown: 0 }, // 35-40, 45-50, 55-60, 85-90.+ mergeWait: { minutes: 10, unknown: 0 },+ rework: { minutes: 10, unknown: 0 }, // Reject-to-next-claim gap, 60-70; active repair is build.+ });+ const filedLater = report.items.find(row => row.id === 3);+ assert.deepEqual(filedLater.stages.later, { minutes: 5, unknown: 0 }, '110-115 is filed outside the recorded current milestone');+ assert.deepEqual(filedLater.stages.ready, { minutes: 5, unknown: 0 }, '115-120 waits in the newly focused milestone');+ assert.equal(report.items.find(row => row.id === 4).stages.build.minutes, 1, 'focus preference never invalidates an actual recorded claim outside the focus');+ assert.deepEqual(item.firstTry, firstTry(0, 1));+ assert.equal(item.submissionsPerLanded, 2);+ assert.deepEqual(item.sizeBuckets.under100, firstTry(0, 1), 'use first submission size, not its larger replacement');+ const unknown = report.items.find(row => row.id === 8);+ assert.equal(unknown.stages.build.minutes, null);+ assert.equal(unknown.stages.build.unknown, 1);+ assert.deepEqual(unknown.firstTry, firstTry(0, 0, 1));+ assert.equal(unknown.submissionsPerLanded, null);+ assert.deepEqual(report.overall.firstTry, firstTry(6, 7, 1));+ assert.equal(report.overall.submissionsPerLanded, null, 'an unknown historical submission count prevents a fabricated overall ratio');+ assert.deepEqual(report.overall.sizeBuckets, {+ under100: firstTry(0, 1), '100to300': firstTry(2, 2),+ '300to800': firstTry(2, 2), '800plus': firstTry(1, 1), unknown: firstTry(1, 1, 1),+ });+ assert.deepEqual(report.lanes.find(row => row.lane === 'core').firstTry, firstTry(6, 7, 0));+ const milestone = report.milestones.find(row => row.milestone === 'Release');+ assert.deepEqual(milestone.firstTry, firstTry(1, 2));+ assert.equal(milestone.submissionsPerLanded, 1.5);+ assert.deepEqual(store.events(board), history, 'reading the report writes no inferred history');+});diff --git a/test/flow-submit-size.test.js b/test/flow-submit-size.test.jsnew file mode 100644index 00000000..35d9c45b--- /dev/null+++ b/test/flow-submit-size.test.js@@ -0,0 +1,53 @@+/** Flow size buckets retain the exact observed Git comparison on the native submission [R1,R2,V4]. */+import assert from 'node:assert/strict';+import { mkdirSync, writeFileSync } from 'node:fs';+import { join } from 'node:path';+import { test } from 'node:test';+import * as store from '../src/board.js';+import { createE2eHelpers } from './e2e-helpers.js';++test('a native submit records its immutable changed-line base and head for flow buckets [R1,R2,V4]', { timeout: 60_000 }, t => {+ const helpers = createE2eHelpers();+ t.after(helpers.cleanup);+ const box = helpers.project('true');+ const added = box.run(box.repo, 'add', 'web', 'Measure submitted lines', '--specs', 'G1',+ '--criterion', 'The measured page exists.', '--check', 'test -f web/size.txt');+ assert.equal(added.code, 0, added.out + added.err);+ const claimed = box.run(box.web, 'claim', '1');+ assert.equal(claimed.code, 0, claimed.out + claimed.err);+ const base = box.git(box.repo, 'rev-parse', 'main');+ mkdirSync(join(box.web, 'web'), { recursive: true });+ writeFileSync(join(box.web, 'web/size.txt'), Array.from({ length: 100 }, (_, n) => `line ${n}\n`).join(''));+ box.git(box.web, 'add', 'web/size.txt');+ box.git(box.web, 'commit', '-q', '-m', 'feat(web): add measured page [G1]');+ const head = box.git(box.web, 'rev-parse', 'HEAD');+ const submitted = box.run(box.web, 'submit', '1');+ assert.equal(submitted.code, 0, submitted.out + submitted.err);+ const json = box.run(box.repo, 'stats', '--json');+ assert.equal(json.code, 0, json.out + json.err);+ const report = JSON.parse(json.out).stats.flow.report;+ assert.ok(report, 'stats JSON includes the same event-derived report');+ assert.deepEqual(report.items.find(item => item.id === 1).sizeBuckets['100to300'],+ { accepted: 0, decided: 0, rate: null, unknown: 1 }, 'a real undecided 100-line first attempt has a known bucket and an unknown verdict');+ const text = box.run(box.repo, 'stats');+ assert.equal(text.code, 0, text.out + text.err);+ assert.match(text.out, /flow report/u);+ assert.match(text.out, /waiting for an agent/u);+ assert.match(text.out, /filed for later/u);+ assert.match(text.out, /item #1/u);+ const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'));+ try {+ const events = store.events(board);+ const submission = events.findLast(event => event.event_kind === 'submit');+ const detail = JSON.parse(submission.event_detail);+ assert.deepEqual(detail.submissionSize, { base, head, lines: 100, method: 'added-plus-deleted-no-renames' },+ 'the observed count is bound to the actual submit comparison, rather than reconstructed from later main');+ assert.equal(detail.commit, head);+ const before = submission.event_detail;+ writeFileSync(join(box.repo, 'later.txt'), 'later trunk change\n');+ box.git(box.repo, 'add', 'later.txt');+ box.git(box.repo, 'commit', '-q', '-m', 'chore: advance the fixture trunk');+ assert.equal(store.events(board).find(event => event.event_id === submission.event_id).event_detail, before,+ 'advancing the trunk leaves the earlier submission measurement unchanged');+ } finally { store.closeBoard(board); }+});