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.

perf(resume): batch decision replies and seat parents [C7,N19]

Corey Olson080f0217173b
diff --git a/src/board-query.js b/src/board-query.js
index 2d4f15f2..6f728ec1 100644
--- a/src/board-query.js
+++ b/src/board-query.js
@@ -294,8 +294,9 @@ export function withModel(board, agent) {
* @returns {any[]}
*/
export function listAgents(board) {
- return board.db.prepare(`SELECT agent.*, board_meta.meta_value AS agent_model FROM agent
- LEFT JOIN board_meta ON board_meta.meta_key='agent_model:' || agent.agent_id ORDER BY agent.rowid`).all().map(agent => ({ ...agent, agent_parent_session: agentParent(board, agent.agent_id) }));
+ return board.db.prepare(`SELECT agent.*, model.meta_value AS agent_model, parent.meta_value AS agent_parent_session FROM agent
+ LEFT JOIN board_meta model ON model.meta_key='agent_model:' || agent.agent_id
+ LEFT JOIN board_meta parent ON parent.meta_key='agent_parent_session:' || agent.agent_id ORDER BY agent.rowid`).all();
}
/** The optional engine-20 fields of a fact, present only when its event set them. */
diff --git a/src/board-read-auxiliary.js b/src/board-read-auxiliary.js
index 55043de4..92faad08 100644
--- a/src/board-read-auxiliary.js
+++ b/src/board-read-auxiliary.js
@@ -36,6 +36,13 @@ export function shoutDetails(board, id) {
return { ...shout, decision_state: shout.shout_decision ? (answer ? 'answered' : 'open') : null, decision_answer: answer };
}
+/** Read the first reply to every decision through its indexed answer key, without one query per ask. */
+export function decisionAnswers(board) {
+ return board.db.prepare(`SELECT reply.* FROM shout ask JOIN shout reply ON reply.shout_id=(
+ SELECT first.shout_id FROM shout first WHERE first.shout_answers=ask.shout_id ORDER BY first.shout_id LIMIT 1)
+ WHERE ask.shout_decision=1 ORDER BY ask.shout_id`).all();
+}
+
/** Requests remain visible to the coordinator until a done or declined answer closes them (A2). */
export function openRequests(board) {
return board.db.prepare(`SELECT * FROM shout ask WHERE ask.shout_request = 1
diff --git a/src/board.js b/src/board.js
index fcc862e1..4b86c936 100644
--- a/src/board.js
+++ b/src/board.js
@@ -11,6 +11,7 @@ export {
getShout,
allShouts,
shoutDetails,
+ decisionAnswers,
openRequests,
pendingRefreeze,
pendingRefreezeProblem,
diff --git a/src/cli.js b/src/cli.js
index 88209744..6a572f5a 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1028,8 +1028,9 @@ export function coordinatorDecisionSections(board, ctx) {
const openDecisions = store.openDecisions(board, COORDINATOR).map((ask) => ({
id: ask.shout_id, asker: ask.shout_from, question: ask.shout_text, at: ask.shout_at, age: span(ctx, ask.shout_at),
}));
+ const answers = new Map(store.decisionAnswers(board).map(answer => [answer.shout_answers, answer]));
const recentAnswers = shouts.filter((ask) => ask.shout_decision).flatMap((ask) => {
- const answer = store.shoutDetails(board, ask.shout_id).decision_answer;
+ const answer = answers.get(ask.shout_id);
if (!answer) return [];
const ageMs = ctx.clock.now().getTime() - Date.parse(answer.shout_at);
if (ageMs < 0 || ageMs > 24 * 60 * 60 * 1000) return [];
diff --git a/test/rigor-counters.test.js b/test/rigor-counters.test.js
index dacba5e6..fdb9dedf 100644
--- a/test/rigor-counters.test.js
+++ b/test/rigor-counters.test.js
@@ -16,6 +16,8 @@ import { RIGOR_TAIL_LIMIT } from '../src/rigor-counters.js';
import { undraftedRigor } from '../src/rigor-notices.js';
import { rigorSource } from '../src/rigor-source.js';
import { parseSpec } from '../src/spec.js';
+import { coordinatorDecisionSections } from '../src/cli.js';
+import { agentParent } from '../src/board-query.js';
const PREFIX = 'local:proof-stats:rigor:v1:';
@@ -261,3 +263,32 @@ test('invalid historical cause and decline grammar remain data during a current
assert.deepEqual(resumeRigorCounters(board, {}).causes, oracle);
assert.equal(resumeRigorCounters(board, {}).notice, null);
});
+
+
+test('resume batches first decision answers and parent identities without changing their meaning [C7,N19,H16]', t => {
+ const { board } = fixture(t);
+ const insert = board.db.prepare('INSERT INTO shout(shout_at,shout_from,shout_to,shout_text,shout_decision,shout_answers) VALUES(?,?,?,?,?,?)');
+ const now = Date.parse('2026-10-24T12:00:00.000Z');
+ const asks = [];
+ for (let n = 0; n < 12; n += 1) {
+ const ask = Number(insert.run('2026-10-22T00:00:00.000Z', 'coordinator', 'coordinator', `question ${n}`, 1, null).lastInsertRowid);
+ asks.push(ask);
+ if (n === 0) continue;
+ const at = new Date(now + (n === 1 ? -2 * 86400000 : n === 2 ? 1000 : -1000)).toISOString();
+ insert.run(at, 'coordinator', 'coordinator', `first ${n}`, 0, ask);
+ insert.run(new Date(now).toISOString(), 'coordinator', 'coordinator', `later ${n}`, 0, ask);
+ }
+ const expected = asks.flatMap(id => {
+ const { decision_answer: answer } = store.shoutDetails(board, id);
+ return answer ? [answer] : [];
+ });
+ assert.deepEqual(store.decisionAnswers(board), expected, 'the oldest answer stays authoritative, including historical duplicate replies');
+ const rows = coordinatorDecisionSections(board, { clock: { now: () => new Date(now) } });
+ assert.deepEqual(rows.recentAnswers.map(row => row.answer), expected.filter(row => {
+ const age = now - Date.parse(row.shout_at);
+ return age >= 0 && age <= 86400000;
+ }).map(row => row.shout_text));
+ board.db.prepare('INSERT INTO board_meta(meta_key,meta_value) VALUES(?,?)').run('agent_parent_session:coordinator', 'original-parent');
+ assert.deepEqual(store.listAgents(board).map(row => row.agent_parent_session),
+ store.listAgents(board).map(row => agentParent(board, row.agent_id)));
+});