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
chore(merge): compose accepted activity and lock visibility [C7,H16]
Corey Olsonf54299f4d832
diff --cc src/board-query.jsindex 79aa4803,ec8b2806..5bcfa64e--- a/src/board-query.js+++ b/src/board-query.js@@@ -449,8 -442,80 +451,86 @@@ export function agentParent(board, id)return board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get(`agent_parent_session:${id}`)?.meta_value ?? null;}+/** Every stamped receipt for one item, in recorded order. */+export function proofReceipts(board, itemId) {+ return board.db.prepare("SELECT event_id, event_detail FROM event WHERE item_id = ? AND event_kind = 'proof-run' ORDER BY event_id").all(itemId)+ .map(row => ({ eventId: row.event_id, ...JSON.parse(row.event_detail).receipt }));+}++++ /** Read the adjacent batch receipt, never a per-item scan of all landing history. */+ function activityBatchBase(board, event) {+ const detail = activityEventDetail(event);+ if (!detail) return null;+ for (const [operator, order] of [['>', 'ASC'], ['<', 'DESC']]) {+ const batch = board.db.prepare(`SELECT json_extract(CASE WHEN json_valid(event_detail) THEN event_detail ELSE '{}' END,'$.batch.id') AS id,+ json_extract(CASE WHEN json_valid(event_detail) THEN event_detail ELSE '{}' END,'$.batch.base') AS base,+ json_extract(CASE WHEN json_valid(event_detail) THEN event_detail ELSE '{}' END,'$.batch.tip') AS tip+ FROM event WHERE event_kind='landing_batch' AND event_id${operator}? ORDER BY event_id ${order} LIMIT 1`).get(event.event_id);+ if (batch?.id === detail.batch && batch.tip === detail.sha && /^[a-f0-9]{40}$/u.test(batch.base ?? '')) return batch.base;+ }+ return null;+ }++ /**+ * One canonical activity history boundary for inbox readers; batch item queries rather than+ * re-reading every global landing receipt for each item. Projection never acknowledges messages.+ */+ export function agentActivity(board, agentId, { after = 0, newsAfter = 0, workingFiles = [], changesForMain, sessionStart = false } = {}) {+ const agent = board.db.prepare('SELECT * FROM agent WHERE agent_id=?').get(agentId);+ if (!agent) throw new Refused('NO_AGENT', `no agent ${agentId}; join your own worktree first`);+ if (![after, newsAfter].every(value => Number.isSafeInteger(value) && value >= 0)) {+ throw new Refused('BAD_ACTIVITY_CURSOR', 'activity cursors are nonnegative event ids; remove the damaged local inbox cursor and read inbox again');+ }+ // Freeze a high-water mark before any Git seam or other query; later events must remain pending.+ const { cursor, shoutCursor } = board.db.prepare(`SELECT+ (SELECT COALESCE(MAX(event_id),0) FROM event) AS cursor,+ (SELECT COALESCE(MAX(shout_id),0) FROM shout) AS shoutCursor`).get();+ const items = listItems(board, { all: true });+ const builds = items.filter(item => item.item_status === 'claimed' && item.item_owner === agentId);+ const observed = typeof workingFiles === 'function' ? workingFiles(builds) : workingFiles;+ const observedFiles = Array.isArray(observed) ? observed : observed.files;+ const interests = activityInterests(agent, items, { workingFiles: observedFiles, at: now(board) });+ interests.unknownWorkingFiles = !Array.isArray(observed) && observed.unknown === true;+ const wanted = [...new Set([...interests.related, ...[...interests.byId.values()]+ .filter(item => item.item_lane === agent.agent_lane).map(item => item.item_id)])];+ const rows = new Map();+ for (let offset = 0; offset < wanted.length; offset += 500) {+ const ids = wanted.slice(offset, offset + 500);+ for (const event of board.db.prepare(`SELECT * FROM event WHERE event_id>? AND event_id<=? AND item_id IN (${ids.map(() => '?').join(',')}) ORDER BY event_id`).all(after, cursor, ...ids)) rows.set(event.event_id, event);+ }+ for (const event of board.db.prepare(`SELECT * FROM event WHERE event_id>? AND event_id<=?+ AND event_kind IN ('main-moved','row_decision','row_apply','row_draft','shout','shout_news','pass','answer') ORDER BY event_id`).all(after, cursor)) rows.set(event.event_id, event);+ if (sessionStart) for (const event of board.db.prepare(`SELECT * FROM event WHERE event_id>? AND event_id<=? AND event_kind='shout_news'+ ORDER BY event_id`).all(newsAfter, cursor)) rows.set(event.event_id, event);+ const messages = board.db.prepare(`SELECT * ${UNREAD_SQL} AND shout_id<=? ORDER BY shout_id`)+ .all(...unreadShoutBindings(agent.agent_last_shout_id, agentId, agent.agent_lane), shoutCursor);+ // News delivery uses its own cursor so ordinary inbox reads cannot consume a future session's digest.+ const possibleNewsIds = [...rows.values()].filter(event => event.event_kind === 'shout_news')+ .map(event => activityEventDetail(event)?.shout).filter(id => Number.isSafeInteger(id) && id > 0);+ for (let offset = 0; offset < possibleNewsIds.length; offset += 500) {+ const ids = possibleNewsIds.slice(offset, offset + 500);+ messages.push(...board.db.prepare(`SELECT * FROM shout WHERE shout_id IN (${ids.map(() => '?').join(',')})+ AND shout_to='all' AND shout_from IN ('coordinator','person') AND shout_decision=0+ AND shout_request=0 AND shout_answers IS NULL`).all(...ids));+ }+ const byShout = new Map(messages.map(message => [message.shout_id, message]));+ const newsIds = [...rows.values()].filter(event => isActivityNews(event, byShout.get(activityEventDetail(event)?.shout)))+ .map(event => activityEventDetail(event).shout);+ for (const event of rows.values()) if (event.event_kind === 'main-moved') event.activityBase = activityBatchBase(board, event);+ for (const event of rows.values()) if (event.event_kind === 'row_apply') {+ const ids = activityEventDetail(event)?.events;+ event.activityRows = [];+ if (!Array.isArray(ids)) continue;+ for (let offset = 0; offset < ids.length; offset += 500) {+ const chunk = ids.slice(offset, offset + 500).filter(id => Number.isSafeInteger(id) && id > 0 && id < event.event_id);+ if (chunk.length) for (const row of board.db.prepare(`SELECT * FROM event WHERE event_kind='row_decision'+ AND event_id IN (${chunk.map(() => '?').join(',')})`).all(...chunk)) {+ const id = activityEventDetail(row)?.record?.id;+ if (typeof id === 'string') event.activityRows.push(id);+ }+ }+ }+ return { ...projectAgentActivity({ agent, interests, events: [...rows.values()].toSorted((a, b) => a.event_id - b.event_id),+ shouts: messages, changesForMain, sessionStart, after, newsAfter, cursor }), shoutCursor, newsShouts: newsIds };+ }diff --cc src/board.jsindex 8669a726,38e71024..a661d703--- a/src/board.js+++ b/src/board.js@@@ -1736,8 -1695,8 +1701,9 @@@ function persistShout(board, { from, to* @returns {number}*/export function shout(board, message) {+ if ((board.executionEngineVersion ?? ENGINE_VERSION) >= PROOF_RUN_ENGINE) refuseLongShout(message.text);- return atomic(board, () => insertShout(board, message));+ return atomic(board, () => insertShout(board, { ...message,+ news: activityNewsFlag(message, board.executionEngineVersion ?? ENGINE_VERSION) }));}/** Record one current health snapshot atomically, notifying each new or resolved episode once [A6]. */diff --cc test/move-registry.test.jsindex 929f49a3,ec9ede8a..de6942c7--- a/test/move-registry.test.js+++ b/test/move-registry.test.js@@@ -15,10 -16,11 +16,13 @@@ import { exportBoard, importBoard } froimport { applyEngineMove, ENGINE_OPERATIONS } from '../src/engine.js';import { relayMoveActor } from '../src/relay-sender.js';import { NEXT_STEPS } from '../src/next-step-words.js';+import { MOVE_REGISTRY, minimumMoveEngine } from '../src/move-registry.js';+import { PROOF_RUN_ENGINE } from '../src/proof-run-engine.js';+import { ENGINE_VERSION } from '../src/machine.js';- import { REGISTRY_AT } from './move-registry-fixture.js';+ import { REGISTRY_AT, registryFixtureBoard } from './move-registry-fixture.js';+ import { importsIn } from '../src/module-imports.js';+ import { readdirSync } from 'node:fs';-import { minimumMoveEngine } from '../src/move-registry.js';+ import { SPEC_REVISION_ENGINE } from '../src/spec-revision-engine.js';const SNAPSHOT = JSON.parse(readFileSync(new URL('./move-registry-baseline.json', import.meta.url), 'utf8'));const CONSUMERS = ['src/engine.js', 'src/relay-sender.js', 'src/next-step-words.js'];