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(inbox): distinguish native news from legacy tags [R2,N26,H16]
Corey Olsona9ac2a72c10b
diff --git a/docs/formats.md b/docs/formats.mdindex 3997bb6e..e6bcd0a2 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -447,7 +447,8 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `guards` | board | `missing`, `changed`, `stale` || `rigor-notice` | rigor | `cause`, `items`, `occurrences`, `neverAgain`, `engine`, automatic-Rigor `drafts` || `rigor-draft` | rigor | `id`, `target`, `cause`, exact typed `source`, `unproved` (always true), `items`, `occurrences`, `engine` |-| `shout` | sender | `shout`, `to`, `decision`, `request`, `answers`, `news`, `newsFormat` |+| `shout` | sender | `shout`, `to`, `decision`, `request`, `answers` |+| `shout_news` | sender | `shout`, `to`, `decision`, `request`, `answers` || `flake-observation` | reporting agent | `engine`, `observation` || `flake-repair` | reporting agent | `engine`, `key`, `item` || `health-scan` | observing agent | `active`, `engine` |@@ -652,11 +653,12 @@ With `reviewsFirst` on, ordinary `next` offers an eligible review before a buildWith numeric `wipPerReviewer` on, a new claim that would exceed that limit is refused as `LINE_WIP_LIMIT`, naming the oldest eligible pending review when there is one. Live claimed items and outstanding submissions count; expired claims do not. The shared pure `lineWipLimit` function computes the total cap without rounding, using at least one observed reviewer. Renewals remain possible. The native claim carries the configured verifier and family policies so its suggested review never relaxes those guards. With `takeoverMinutes` on, a sent-back item's idle interval can end its original builder's first-refusal window early; a live claim is never stolen, and normal claim appends preserve the old history. Disabled controls retain the previous behavior. New claims under these controls carry a true `lineCapacity` argument and the line-capacity engine floor; marker-absent older recorded claims keep their historical meaning during replay.-Explicit announcement news adds `news: true, newsFormat: 1` to a shout event without adding a SQLite column.+The explicit top-level `news: true` shout argument emits a native `shout_news` event instead of `shout`, without adding a SQLite column. Its canonical message row remains in `shout`; consumers resolve its recipient and text in the same way as other messages.Only coordinator or person messages to `all` may be news; combining news with an item,decision, request or answer refuses as `BAD_NEWS`. Its unassigned activity-news engine leaf is-numbered at landing; news takes the maximum applicable feature engine floor. Unversioned old-metadata remains an ordinary message. Older ordinary+numbered at landing; news takes the maximum applicable feature engine floor. Old `shout` events+remain ordinary messages regardless of arbitrary metadata matching any news tags. `watch --kinds`+continues to select literal kinds: include `shout,shout_news` to follow both. Older ordinaryshout arguments retain their historical replay conditions. Untyped broadcasts retain theirexisting direct delivery, including governing holds and questions.diff --git a/docs/formats.test.js b/docs/formats.test.jsindex e0b97039..0f01bac5 100644--- a/docs/formats.test.js+++ b/docs/formats.test.js@@ -727,6 +727,7 @@ test('[A5] schema, versions, event kinds and event detail fields match live beha'rigor-notice': 'rigor','rigor-draft': 'rigor',shout: 'sender',+ shout_news: 'sender',pass: 'coordinator',answer: 'answerer','flake-observation': 'reporting agent',diff --git a/src/activity-feed.js b/src/activity-feed.jsindex 5bdd45ef..2dc130fe 100644--- a/src/activity-feed.js+++ b/src/activity-feed.js@@ -69,10 +69,9 @@ function activityEntry(event, text, extra = {}) {...(event.item_id === null ? {} : { item: event.item_id }), text, ...extra };}-/** Treat only a versioned authorized announcement as news; old arbitrary metadata stays direct. */+/** Only the new native kind expresses news intent; arbitrary old shout metadata stays direct. */export function isActivityNews(event, message) {- const detail = activityEventDetail(event);- return event.event_kind === 'shout' && detail?.news === true && detail.newsFormat === 1+ return event.event_kind === 'shout_news'&& event.item_id === null && ['coordinator', 'person'].includes(message?.shout_from)&& event.event_by === message.shout_from && message.shout_to === 'all'&& !message.shout_decision && !message.shout_request && message.shout_answers === null;@@ -97,7 +96,7 @@ export function projectAgentActivity({ agent, interests, events, shouts, changescontinue;}if (event.event_id <= after) continue;- if (['shout', 'pass', 'answer'].includes(event.event_kind)) {+ if (['shout', 'shout_news', 'pass', 'answer'].includes(event.event_kind)) {const shout = messages.get(detail.shout);if (shout) {entries.push(activityEntry(event, shout.shout_text, { shout: shout.shout_id }));diff --git a/src/activity-news.js b/src/activity-news.jsindex 10d54a45..8fa2b018 100644--- a/src/activity-news.js+++ b/src/activity-news.js@@ -3,16 +3,16 @@ import { Refused } from './refused.js';import { ACTIVITY_NEWS_ENGINE } from './activity-news-engine.js';/** Validate explicitly marked board-wide news without weakening any existing message audience. */-export function activityNewsDetail(message, engine) {+export function activityNewsFlag(message, engine) {const { news, from, to, item, decision, request, answers, detail } = message;if (engine >= ACTIVITY_NEWS_ENGINE && detail && ['news', 'newsFormat'].some(key => Object.hasOwn(detail, key))) {throw new Refused('BAD_NEWS', 'mark news explicitly on the message, not inside internal event detail; send an ordinary message for coordination');}- if (news === undefined || news === false) return {};+ if (news === undefined || news === false) return false;if (news !== true || ![COORDINATOR, 'person'].includes(from) || to !== 'all'|| item !== undefined || decision || request || (answers !== null && answers !== undefined)) {throw new Refused('BAD_NEWS', 'news is a coordinator or person announcement to all, without an item, decision, request or answer; send an ordinary message for coordination');}if (engine < ACTIVITY_NEWS_ENGINE) throw new Refused('ENGINE_VERSION', `news requires engine ${ACTIVITY_NEWS_ENGINE}; upgrade linked devices before sending it`);- return { news: true, newsFormat: 1 };+ return true;}diff --git a/src/board-query.js b/src/board-query.jsindex aa4013f6..2e990ad8 100644--- a/src/board-query.js+++ b/src/board-query.js@@ -478,17 +478,14 @@ export function agentActivity(board, agentId, { after = 0, newsAfter = 0, workinfor (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','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'- AND json_extract(CASE WHEN json_valid(event_detail) THEN event_detail ELSE '{}' END,'$.news')=1- AND json_extract(CASE WHEN json_valid(event_detail) THEN event_detail ELSE '{}' END,'$.newsFormat')=1+ 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'- && activityEventDetail(event)?.news === true && activityEventDetail(event)?.newsFormat === 1)- .map(event => activityEventDetail(event).shout).filter(id => Number.isSafeInteger(id) && id > 0);+ 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(',')})diff --git a/src/board.js b/src/board.jsindex 377b3d54..7d0ed351 100644--- a/src/board.js+++ b/src/board.js@@ -1,4 +1,4 @@-import { activityNewsDetail } from './activity-news.js';+import { activityNewsFlag } from './activity-news.js';import {focusOrder,focusReasons,@@ -1654,7 +1654,7 @@ export { getItem } from './board-query.js';* @param {{ from: string, to: string, text: string, lanes: string[], item?: number, decision?: boolean, answers?: number | null, evidence?: any, request?: boolean, news?: boolean, channel?: 'terminal' | 'view', detail?: object }} message - detail: extra event fields* @returns {number}*/-function insertShout(board, { from, to, text, lanes, item, decision = false, answers = null, evidence = null, request = false, channel = 'terminal', detail = {} }) {+function insertShout(board, { from, to, text, lanes, item, decision = false, answers = null, evidence = null, request = false, news = false, channel = 'terminal', detail = {} }) {const engine = board.executionEngineVersion ?? ENGINE_VERSION;if (item !== undefined) {if (engine < ITEM_SHOUT_ENGINE) throw new Refused('ENGINE_VERSION', 'item messages require engine 93; upgrade every linked device before sending one');@@ -1697,12 +1697,12 @@ function insertShout(board, { from, to, text, lanes, item, decision = false, ansif (personAnswer && !['terminal', 'view'].includes(channel)) {throw new Refused('B26_PERSON_CHANNEL', 'record the person answer through the terminal or the view; run pullboard view');}- return persistShout(board, { from, to, text, decision, answers, evidence, request, channel, detail, outcome, personAnswer });+ return persistShout(board, { from, to, text, decision, answers, evidence, request, news, channel, detail, outcome, personAnswer });}/** Persist a validated message or a fixed internal notice inside the caller's transaction. */function persistShout(board, { from, to, text, decision = false, answers = null, evidence = null, request = false,- channel = 'terminal', detail = {}, outcome = '', personAnswer = false }) {+ channel = 'terminal', detail = {}, outcome = '', personAnswer = false, news = false }) {const result = board.db.prepare(`INSERT INTO shout (shout_from, shout_to, shout_text, shout_at, shout_decision, shout_answers,@@ -1712,7 +1712,7 @@ function persistShout(board, { from, to, text, decision = false, answers = null,).run(from, to, text.trim(), now(board), decision ? 1 : 0, answers, evidence?.kind ?? null, evidence ? evidence.outcome.trim() : null, evidence?.item ?? null, evidence?.commit ?? null, request ? 1 : 0, outcome);const id = Number(result.lastInsertRowid);- logEvent(board, from, answers === null ? 'shout' : decision ? 'pass' : 'answer', detail.item ?? null, { shout: id, to, decision: Boolean(decision), request: Boolean(request), answers, ...(outcome ? { outcome } : {}), ...(personAnswer ? { channel } : {}), ...detail });+ logEvent(board, from, answers === null ? (news ? 'shout_news' : 'shout') : decision ? 'pass' : 'answer', detail.item ?? null, { shout: id, to, decision: Boolean(decision), request: Boolean(request), answers, ...(outcome ? { outcome } : {}), ...(personAnswer ? { channel } : {}), ...detail });return id;}@@ -1724,8 +1724,8 @@ function persistShout(board, { from, to, text, decision = false, answers = null,* @returns {number}*/export function shout(board, message) {- return atomic(board, () => insertShout(board, { ...message, detail: { ...message.detail,- ...activityNewsDetail(message, board.executionEngineVersion ?? ENGINE_VERSION) } }));+ 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 --git a/src/watch.js b/src/watch.jsindex 34fc877e..b1794519 100644--- a/src/watch.js+++ b/src/watch.js@@ -21,7 +21,7 @@ import { Refused } from './refused.js';import { runningView } from './view-session.js';/** The kinds that carry a shout, so --to can match their addressee. */-const SHOUT_KINDS = new Set(['shout', 'answer', 'pass']);+const SHOUT_KINDS = new Set(['shout', 'shout_news', 'answer', 'pass']);/** How long to wait before following the stream again after it drops. */const RECONNECT_MS = 200;diff --git a/test/activity-feed.test.js b/test/activity-feed.test.jsindex 9a290888..8ca1016b 100644--- a/test/activity-feed.test.js+++ b/test/activity-feed.test.js@@ -7,7 +7,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';+import { exportBoard, importBoard } from '../src/exchange.js';import { applyEngineMove, prepareEngineMove } from '../src/engine.js';import { ACTIVITY_NEWS_ENGINE } from '../src/activity-news-engine.js';import { ITEM_SHOUT_ENGINE } from '../src/item-shout-engine.js';@@ -352,4 +352,16 @@ test('old ordinary shout replay does not become newly typed news [H16,N26]', (t)assert.ok(coordinator.entries.some(entry => entry.text === 'Legacy agent metadata cannot hide a direct message.'));assert.deepEqual(coordinator.digests, []);assert.deepEqual(exportBoard(board), nativeBeforeRead, 'reading does not rewrite legacy metadata or native receipts');+ const typedMove = prepareEngineMove(board, 'shout', [{ from: 'coordinator', to: 'all', lanes: ['web'],+ text: 'New typed news survives ordered replay and native export.', news: true }]);+ const typed = applyEngineMove(board, typedMove, { sequence: 4, at: new Date().toISOString() });+ assert.equal(typed.error, undefined);+ assert.equal(typed.events[0].event_kind, 'shout_news', 'only the new-engine typed path emits the new native kind');+ const replica = store.openBoard(':memory:');+ t.after(() => store.closeBoard(replica));+ importBoard(replica, exportBoard(board));+ assert.deepEqual(store.events(replica), store.events(board), 'native export/import preserves old and new exact event rows');+ const restored = store.agentActivity(replica, 'web-1', { sessionStart: true });+ assert.ok(restored.entries.some(entry => entry.text === exactText), 'native restore never upgrades old detail into news');+ assert.deepEqual(restored.digests.find(digest => digest.kind === 'news')?.shouts, [typed.result]);});diff --git a/test/shout-item-cli.test.js b/test/shout-item-cli.test.jsindex 95ae8722..d8b2ba0b 100644--- a/test/shout-item-cli.test.js+++ b/test/shout-item-cli.test.js@@ -49,6 +49,8 @@ test('explicit news follows normal CLI and API argument authority [R2,N26,H16,A2assert.deepEqual(delivered.activity.digests.find(digest => digest.kind === 'news')?.shouts, [id]);const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));try {+ assert.ok(store.events(board).some(event => event.event_kind === 'shout_news'+ && JSON.parse(event.event_detail).shout === id), 'the real CLI records news with its distinct native kind');const before = store.events(board);for (const [root, args] of [[box.web, ['shout', 'all', 'An agent cannot hide a broadcast', '--news', '--json']],[box.repo, ['shout', 'all', 'A decision is not expendable news', '--news', '--decision', '--json']]]) {diff --git a/test/watch.test.js b/test/watch.test.jsindex 7f2806ec..6d1a47ee 100644--- a/test/watch.test.js+++ b/test/watch.test.js@@ -437,3 +437,29 @@ test('a shout about an item reaches only the people on it [B7,A2,N19]', async (t}assert.equal(box.cli(box.root, 'inbox').shouts.some((shout) => shout.shout_text === 'a seat reports only to coordination'), true);});+++test('watch follows typed news by native kind and canonical addressee [A2,N26,H16]', async (t) => {+ const box = project();+ const before = events(box).length;+ const watch = startWatch(box, ['--json', '--kinds', 'shout_news', '--to', 'app']);+ t.after(() => watch.stop('SIGKILL'));+ await watch.note(line => /following the board directly/u.test(line), 10_000, 'typed-news watch startup'); // budget: startup hang ceiling, not a latency claim.+ box.cli(box.root, 'shout', 'all', 'The first private release is ready', '--news');+ const first = events(box).at(-1);+ assert.equal(first.event_kind, 'shout_news');+ await watch.line(line => JSON.parse(line).sequence === first.event_id, 5_000, 'first typed news'); // budget: stream hang ceiling, not a latency claim.+ box.cli(box.root, 'shout', 'all', 'An ordinary governing message keeps its original kind');+ const ordinary = events(box).at(-1);+ assert.equal(ordinary.event_kind, 'shout');+ box.cli(box.root, 'shout', 'all', 'The second private release is ready', '--news');+ const second = events(box).at(-1);+ await watch.line(line => JSON.parse(line).sequence === second.event_id, 5_000, 'second typed news'); // budget: ordered-stream hang ceiling, not a latency claim.+ assert.deepEqual(await watch.stop('SIGTERM'), { code: 0, signal: null });+ const printed = watch.out.lines.map(({ line }) => JSON.parse(line));+ assert.deepEqual(printed.map(record => record.sequence), [first.event_id, second.event_id], 'kind filtering remains literal');+ assert.deepEqual(printed.map(record => record.detail),+ ['to all: The first private release is ready', 'to all: The second private release is ready'], 'news resolves the same canonical recipient and text');+ assert.ok(printed.every(record => record.kind === 'shout_news' && record.actor === 'coordinator' && record.item === null));+ assert.equal(events(box).length, before + 3, 'watch creates no native event');+});