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(stats): expose missing ends and mixed window revisions [R1,R2]
Corey Olson814f4cb717c2
diff --git a/test/stats-cli.test.js b/test/stats-cli.test.jsindex bf0624f7..059b6f3d 100644--- a/test/stats-cli.test.js+++ b/test/stats-cli.test.js@@ -6,6 +6,7 @@ import { mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { test } from 'node:test';+import { DatabaseSync } from 'node:sqlite';import * as store from '../src/board.js';import { main } from '../src/cli.js';import { proofStats } from '../src/stats.js';@@ -241,3 +242,30 @@ test('[R1,R2,A1] stats window exposes measured tails in text and JSON without reassert.equal(ambiguous.data.error.code, 'USAGE');assert.deepEqual(store.events(board), before);});+++test('[R1,R2,A1] stats window and ordinary counters share one SQLite snapshot while another seat appends', async t => {+ const { root, board } = fixture(t);+ const clock = { now: () => new Date('2026-10-08T13:00:00Z') };+ const original = DatabaseSync.prototype.exec;+ let injected = false;+ DatabaseSync.prototype.exec = function (sql) {+ const result = original.call(this, sql);+ if (!injected && sql === 'RELEASE proof_stats_read') {+ injected = true;+ const id = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Concurrent landing' });+ store.logEvent(board, 'coordinator', 'merged', id, { commit: 'f'.repeat(40) });+ }+ return result;+ };+ let json;+ try { json = await run(root, ['stats', '--window', '6h', '--json'], clock); }+ finally { DatabaseSync.prototype.exec = original; }+ assert.equal(json.code, 0, json.stderr);+ assert.equal(injected, true, 'the separate writer committed at the recorded read boundary');+ assert.equal(json.data.stats.merged, 1);+ assert.equal(json.data.window.landedItems, 1, 'one response cannot combine old counters and a newer window');+ const next = await run(root, ['stats', '--window', '6h', '--json'], clock);+ assert.equal(next.data.stats.merged, 2);+ assert.equal(next.data.window.landedItems, 2, 'the next observation sees both committed receipts');+});diff --git a/test/stats-flow.test.js b/test/stats-flow.test.jsindex d422b7a2..0df566f6 100644--- a/test/stats-flow.test.js+++ b/test/stats-flow.test.js@@ -215,6 +215,35 @@ test('flow windows retain recorded idle after reopen and builder release [R1,R2]assert.equal(window.stages.build.totalMinutes, 50, 'released building work remains measured');});+test('flow windows never substitute a merge receipt for an unrecorded stage end [R1,R2]', t => {+ const commit = 'a'.repeat(40);+ const { board, stats } = fixture(t, [+ [0, 'coordinator', 'add', 1, { lane: 'core' }],+ [10, 'core-1', 'claim', 1, { leaseUntil: at(1000) }],+ [50, 'coordinator', 'merged', 1],+ [0, 'coordinator', 'add', 2, { lane: 'core' }],+ [10, 'core-2', 'submit', 2, { commit }],+ [50, 'coordinator', 'merged', 2],+ [0, 'coordinator', 'add', 3, { lane: 'core' }],+ [0, 'core-3', 'claim', 3, { leaseUntil: at(1000) }],+ [10, 'core-3', 'submit', 3, { commit }],+ [20, 'review-1', 'reserve', 3, { until: at(1000) }],+ [50, 'coordinator', 'merged', 3],+ [0, 'coordinator', 'add', 4, { lane: 'core' }],+ [0, 'core-4', 'claim', 4, { leaseUntil: at(1000) }],+ [10, 'core-4', 'submit', 4, { commit }],+ [20, 'review-1', 'reserve', 4, { until: at(1000) }],+ [30, 'review-1', 'reject', 4, { commit }],+ [50, 'coordinator', 'merged', 4],+ ], 100);+ const window = flowStats(store.events(board), null, BASE + 100 * 60_000, stats(), { windowMinutes: 100 }).window;+ assert.equal(window.stages.build.count, 2, 'a merge without a submit cannot finish building');+ assert.equal(window.stages.reviewWait.count, 2, 'a merge without a reservation cannot finish waiting');+ assert.equal(window.stages.review.count, 1, 'a merge without a verdict cannot finish reviewing');+ assert.equal(window.stages.sendBackIdle.count, 0, 'a merge without a reclaim cannot finish sent-back idle');+ assert.equal(window.stages.mergeWait.count, 0, 'no acceptance-to-landing interval was recorded');+});+test('flow numbers match a hand computation through rework, released reviews and every live queue [R1,R2]', t => {const a = 'a'.repeat(40), b = 'b'.repeat(40), c = 'c'.repeat(40);const entries = [