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
feat(activity): link main receipts to item history [R2,N26]
Corey Olson9f151310b878
diff --git a/src/activity-feed.js b/src/activity-feed.jsnew file mode 100644index 00000000..8caeceb2--- /dev/null+++ b/src/activity-feed.js@@ -0,0 +1,15 @@+/** Read item activity without duplicating a landing's immutable board-wide receipt [R2,N26]. */++/** Include a batch's main-moving receipt only for the exact item ids that receipt records. */+export function itemActivity(board, id) {+ return board.db.prepare(`+ SELECT * FROM event WHERE item_id = ?+ UNION ALL+ SELECT * FROM event WHERE item_id IS NULL AND event_kind = 'main-moved'+ AND EXISTS (+ SELECT 1 FROM json_each(CASE WHEN json_valid(event_detail) THEN event_detail ELSE '{}' END, '$.items')+ WHERE type = 'integer' AND value = ?+ )+ ORDER BY event_id+ `).all(id, id);+}diff --git a/src/board-query.js b/src/board-query.jsindex 60202e5c..0c9e8055 100644--- a/src/board-query.js+++ b/src/board-query.js@@ -1,4 +1,5 @@import { itemById } from './board-item-read.js';+import { itemActivity } from './activity-feed.js';export { itemById };import { outsideSource } from './outside-source.js';import {@@ -219,7 +220,7 @@ export function events(board, { itemId } = {}) {export function itemThread(board, id) {itemById(board, id);const withdrawals = new Map([...verdictWithdrawals(board, id).values()].map(row => [row.acceptEventId, row]));- return events(board, { itemId: id }).map((event) => event.event_kind === 'fact'+ return itemActivity(board, id).map((event) => event.event_kind === 'fact'? { type: 'fact', ...factFromEvent(event) }: { type: 'move', eventId: event.event_id, kind: event.event_kind, by: event.event_by,...(withdrawals.has(event.event_id) ? { withdrawn: true, withdrawal: withdrawals.get(event.event_id) } : {}),diff --git a/test/activity-feed.test.js b/test/activity-feed.test.jsindex 818fd8d6..02e917d2 100644--- a/test/activity-feed.test.js+++ b/test/activity-feed.test.js@@ -6,6 +6,7 @@ import { after, test } from 'node:test';import * as store from '../src/board.js';import { createE2eHelpers } from './e2e-helpers.js';import { submitFixture } from './board-submit-fixture.js';+import { exportBoard } from '../src/exchange.js';const e2e = createE2eHelpers();after(e2e.cleanup);@@ -48,7 +49,21 @@ test('status moves are feed events and the board sends no status shout [B3,R2,N2assert.equal(thread.find(entry => entry.kind === 'main-moved').detail.sha, commit);assert.equal(store.itemThread(board, other).some(entry => entry.kind === 'main-moved'), false, 'an unrelated item gets no landing activity');assert.deepEqual(board.db.prepare('SELECT * FROM shout ORDER BY shout_id').all(), beforeShouts, 'routine lifecycle writes no status shout');- store.shout(board, { from: 'web-1', to: 'coordinator', lanes: ['web', 'api'], text: 'Who should coordinate the next review?' });+ const snapshot = exportBoard(board);+ assert.deepEqual(store.itemThread(board, item), thread, 'reading activity again is stable');+ assert.deepEqual(exportBoard(board), snapshot, 'projection never writes another receipt');+ assert.equal(store.events(board).filter(event => event.event_kind === 'main-moved').length, 1, 'one original batch receipt serves all item readers');+ store.claim(board, other, { agentId: 'web-1', lane: 'web', leaseMs: 3600000, head: base, freeze });+ submitFixture(board, other, { agentId: 'web-1', commit, tree });+ store.verify(board, other, { agentId: reviewer, decision: 'REJECT', reason: 'TEST_FAILURE', note: 'Synthetic private refusal fixture.',+ head: commit, digest: freeze().digest, policy: 'any', familyPolicy: 'off', reopenFirstRefusalMinutes: 30,+ review: { commit, head: commit, trunk: base, paths: ['web/activity.txt'] } });+ assert.equal(store.itemThread(board, other).at(-1).kind, 'reject', 'a rejection remains item activity');+ const notices = board.db.prepare('SELECT * FROM shout WHERE shout_id > ? ORDER BY shout_id').all(beforeShouts.at(-1)?.shout_id ?? 0);+ assert.equal(notices.length, 1, 'the actionable first-refusal notice survives; no routine reject shout is added');+ assert.equal(notices[0].shout_to, 'web-1');+ assert.match(notices[0].shout_text, /waits for you until.*claim it to resume/u);+ store.shout(board, { from: 'web-1', to: 'coordinator', lanes: ['web', 'api'], text: 'My work was submitted.' });assert.equal(board.db.prepare('SELECT shout_text FROM shout ORDER BY shout_id DESC LIMIT 1').get().shout_text,- 'Who should coordinate the next review?', 'agent-written coordination remains a shout');+ 'My work was submitted.', 'agent-written messages are never suppressed, even when they mention status');});