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(stats): preserve missing ends and one window snapshot [R1,R2]
Corey Olsonb67e986a87ff
diff --git a/src/commands/stats.js b/src/commands/stats.jsindex 201804fb..8cbf976b 100644--- a/src/commands/stats.js+++ b/src/commands/stats.js@@ -34,10 +34,16 @@ export function run(io, { values }) {const windowMinutes = values.window === undefined ? undefined : flowWindowMinutes(values.window);const now = ctx.clock.now().getTime();const { stats, agents, window } = withBoard(ctx, (board) => {- const stats = proofStats(board, { since: values.since, now });- return { stats, agents: store.listAgents(board), ...(windowMinutes === undefined ? {} : {- window: flowStats(store.events(board), null, now, stats, { windowMinutes }).window,- }) };+ // Keep counters and optional raw-history window on the same read snapshot while other seats append.+ if (windowMinutes !== undefined) board.db.exec('SAVEPOINT stats_window_read');+ try {+ const stats = proofStats(board, { since: values.since, now });+ return { stats, agents: store.listAgents(board), ...(windowMinutes === undefined ? {} : {+ window: flowStats(store.events(board), null, now, stats, { windowMinutes }).window,+ }) };+ } finally {+ if (windowMinutes !== undefined) board.db.exec('RELEASE stats_window_read');+ }});const waits = gateReceipt.gateWaitStats(ctx.info.root);io.result?.({ stats, gateWaits: waits.stats, ...(window ? { window } : {}) });diff --git a/src/stats-flow-window.js b/src/stats-flow-window.jsindex cac25323..e96fc03b 100644--- a/src/stats-flow-window.js+++ b/src/stats-flow-window.js@@ -33,6 +33,14 @@ export function observeFlowVerdict(item, by) {trace.cursor = null;}+/** Preserve a missing required boundary without substituting a different move's timestamp. */+export function observeFlowGap(item) {+ const trace = item.windowTrace;+ if (!trace?.cursor) return;+ if (!trace.missing.includes(trace.cursor.stage)) trace.missing.push(trace.cursor.stage);+ trace.cursor = null;+}+/** Freeze nested observations along with the existing immutable prepared lifecycle. */export function frozenWindowTrace(trace) {return Object.freeze({ ...trace, cursor: trace.cursor ? Object.freeze({ ...trace.cursor }) : null,diff --git a/src/stats-flow.js b/src/stats-flow.jsindex 7345bb02..6103062c 100644--- a/src/stats-flow.js+++ b/src/stats-flow.js@@ -3,6 +3,7 @@ import {newWindowTrace,observeFlowStage,observeFlowVerdict,+ observeFlowGap,frozenWindowTrace,projectFlowWindow,} from './stats-flow-window.js';@@ -87,6 +88,7 @@ export function moveFlowItem(item, event, detail, at) {break;}case 'merged':+ if (item.windowTrace?.cursor?.stage !== 'mergeWait') observeFlowGap(item);observeFlowStage(item, null, at, event.event_by);item.mergeAt ??= at; item.state = 'merged'; break;case 'reopen':diff --git a/test/stats-cli.test.js b/test/stats-cli.test.jsindex 059b6f3d..87107f04 100644--- a/test/stats-cli.test.js+++ b/test/stats-cli.test.js@@ -249,6 +249,7 @@ test('[R1,R2,A1] stats window and ordinary counters share one SQLite snapshot whconst clock = { now: () => new Date('2026-10-08T13:00:00Z') };const original = DatabaseSync.prototype.exec;let injected = false;+ /** Append on a second real connection after the existing statistics snapshot is released. */DatabaseSync.prototype.exec = function (sql) {const result = original.call(this, sql);if (!injected && sql === 'RELEASE proof_stats_read') {