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(core): detect older writers in flow report counters [R1,R2]
Corey Olson56c0050ce4ea
diff --git a/src/proof-counter-read.js b/src/proof-counter-read.jsindex db89a557..fd3401db 100644--- a/src/proof-counter-read.js+++ b/src/proof-counter-read.js@@ -61,7 +61,7 @@ export function counterProofStats(board, boundary, now) {const creators = items.filter(item => item.creator !== undefined).map(item => ({ event_kind: 'add', item_id: item.id, event_by: item.creator }));const corrections = proofCounterRows(board, 'bar').map(row => decodedProofEvent({ ...row, event_kind: 'edit' }, row.detail));const verdicts = board.db.prepare('SELECT * FROM verdict ORDER BY verdict_id').all();- const flow = { reportPolicy: summary.reportVersion === 1 ? proofCounter(board, 'report-policy') : null, items: items.filter(item => item.id !== null && item.id !== undefined).map(item => item.flow),+ const flow = { reportPolicy: summary.reportVersion === 1 && summary.reportLast === summary.last ? proofCounter(board, 'report-policy') : null, items: items.filter(item => item.id !== null && item.id !== undefined).map(item => item.flow),actors: actors.filter(actor => actor.id !== 'clock').map(actor => actor.flow), dailyEvents: proofCounterRows(board, 'daily') };return { ...counts, agentCount: attributed.agents.length, familyCount: attributed.families.length, ...attributed,bars: barStats([...creators, ...corrections], verdicts, boundary), caught: counterCaught(board, boundary),diff --git a/src/proof-counters.js b/src/proof-counters.jsindex 3f1f5571..839a9c62 100644--- a/src/proof-counters.js+++ b/src/proof-counters.js@@ -67,7 +67,7 @@ export function clearProofCounters(board) {/** Start a bounded all-time aggregate; window-specific contributions live in separate event shards. */function emptySummary() {return { last: 0, submissions: 0, rejections: 0, merged: 0, mergedWithoutAccept: 0,- firstEventAt: null, lastEventAt: null, invalid: false, reportVersion: 1 };+ firstEventAt: null, lastEventAt: null, invalid: false, reportVersion: 1, reportLast: 0 };}/** Advance an item's acceptance audit separately from its flow lifecycle, whose rules differ. */@@ -165,6 +165,7 @@ export function appendProofCounter(board, event) {}if (reporting && JSON.stringify(reportPolicy) !== beforePolicy) put(board, 'report-policy', reportPolicy);appendRuleProof(board, event, detail, key => proofCounter(board, key), (key, value) => put(board, key, value));+ summary.reportLast = event.event_id;put(board, 'summary', summary);}@@ -183,6 +184,7 @@ export function rebuildProofCounters(board) {clearProofCounters(board);ensureRigorCounters(board);put(board, 'summary', emptySummary());+ put(board, 'report-policy', newReportPolicy());replayProofTail(board, 0);}@@ -190,7 +192,7 @@ export function rebuildProofCounters(board) {export function ensureProofCounters(board) {ensureRigorCounters(board);const summary = proofCounter(board, 'summary');- if (!summary || summary.reportVersion !== 1) { rebuildProofCounters(board); return; }+ if (!summary || summary.reportVersion !== 1 || summary.reportLast !== summary.last) { rebuildProofCounters(board); return; }replayProofTail(board, summary.last);}diff --git a/test/flow-report-cache.test.js b/test/flow-report-cache.test.jsindex a1c96207..e2cf0510 100644--- a/test/flow-report-cache.test.js+++ b/test/flow-report-cache.test.js@@ -12,16 +12,26 @@ import { ensureProofCounters } from '../src/proof-counters.js';import { runFixtureGit } from './fixture-child.js';/** Construct a native board whose append path maintains current report shards. */-function fixture(t) {+function fixture(t, { item = true } = {}) {const root = mkdtempSync(join(tmpdir(), 'pullboard-report-cache-'));runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, stdio: 'pipe' });const board = store.openBoard(join(root, '.git', 'board.sqlite'));store.register(board, { lane: 'coordinator', path: root });- store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Known open history' });+ if (item) store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Known open history' });t.after(() => { store.closeBoard(board); rmSync(root, { recursive: true, force: true }); });return board;}+test('an empty indexed board has a measured empty report rather than a missing capability [R1,R2]', t => {+ const board = fixture(t, { item: false });+ const report = proofStats(board).flow.report;+ assert.deepEqual(report.items, []);+ assert.deepEqual(report.lanes, []);+ assert.deepEqual(report.milestones, []);+ assert.deepEqual(report.overall.firstTry, { accepted: 0, decided: 0, rate: null, unknown: 0 });+ assert.equal(report.overall.submissionsPerLanded, null);+});+test('flow report indexed projection matches canonical replay without hot raw history reads [R1,R2]', t => {const board = fixture(t);const now = Date.now() + 60_000;@@ -57,6 +67,22 @@ test('old v2 counters retain fast metrics and explicitly unavailable reports untassert.deepEqual(store.events(board), before, 'writer backfill changes only local derived counters');});+test('an older writer cannot make retained report capability look current [R1,R2,H16]', t => {+ const board = fixture(t);+ const key = 'local:proof-stats:v2:summary';+ const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(key);+ const summary = JSON.parse(row.meta_value);+ summary.data.reportLast = summary.data.last - 1;+ board.db.prepare('UPDATE board_meta SET meta_value=? WHERE meta_key=?').run(JSON.stringify(summary), key);+ const stale = proofStats(board);+ assert.equal(stale.flow.queues.open.size, 1, 'existing native counters remain usable');+ assert.deepEqual(stale.flow.report, { available: false }, 'retained version alone cannot certify intervening older-writer events');+ const before = store.events(board);+ ensureProofCounters(board);+ assert.ok(proofStats(board).flow.report.items);+ assert.deepEqual(store.events(board), before, 'repair changes derived counters only');+});+test('retained refreezes keep active build time and prototype-like recorded names remain ordinary groups [R1,R2]', () => {const base = Date.parse('2026-10-10T00:00:00Z');const commit = 'a'.repeat(40);