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.

fix(shout): retain minimum SQLite and literal item text [B7,A2,N19]

Corey Olson7d8a78be59c2
diff --git a/src/board.js b/src/board.js
index 5b9c9e94..5a8f1c13 100644
--- a/src/board.js
+++ b/src/board.js
@@ -5,6 +5,7 @@ import {
itemShoutReader,
shoutItemId,
UNREAD_SHOUT_SQL,
+ unreadShoutBindings,
} from './shout-audience.js';
import { recordVerdict } from './verdict-assurance.js';
import { logEvent } from './board-event-log.js';
@@ -2153,7 +2154,7 @@ export function inbox(board, agentId) {
if (!agent) throw new Refused('NO_AGENT', `no agent ${agentId}`);
const shouts = board.db
.prepare(`SELECT * ${UNREAD_SQL} ORDER BY shout_id`)
- .all(agent.agent_last_shout_id, agentId, agent.agent_lane, agentId);
+ .all(...unreadShoutBindings(agent.agent_last_shout_id, agentId, agent.agent_lane));
const last = shouts.at(-1)?.shout_id ?? agent.agent_last_shout_id;
board.db.prepare('UPDATE agent SET agent_last_shout_id = ? WHERE agent_id = ?').run(last, agentId);
if (agentId !== COORDINATOR) return shouts;
@@ -2175,7 +2176,7 @@ export function unreadCount(board, agentId) {
if (!agent) return 0;
const { total } = board.db
.prepare(`SELECT COUNT(*) AS total ${UNREAD_SQL}`)
- .get(agent.agent_last_shout_id, agentId, agent.agent_lane, agentId);
+ .get(...unreadShoutBindings(agent.agent_last_shout_id, agentId, agent.agent_lane));
return total;
}
@@ -2653,7 +2654,7 @@ export function peekShouts(board, agentId, limit = 2) {
if (!agent) return [];
return board.db
.prepare(`SELECT * ${UNREAD_SQL} ORDER BY shout_id DESC LIMIT ?`)
- .all(agent.agent_last_shout_id, agentId, agent.agent_lane, agentId, limit)
+ .all(...unreadShoutBindings(agent.agent_last_shout_id, agentId, agent.agent_lane), limit)
.reverse();
}
diff --git a/src/commands/shout.js b/src/commands/shout.js
index ba71893b..e2b07fab 100644
--- a/src/commands/shout.js
+++ b/src/commands/shout.js
@@ -22,7 +22,7 @@ export async function run(io, { first, second, rest, values }) {
return act(async (ctx, board, me) => {
const evidence = values.evidence === undefined ? null : evidenceFrom(ctx, values);
const recipients = ['all', 'person', ...laneNames(ctx.config), ...board.db.prepare('SELECT agent_id FROM agent').all().map((agent) => agent.agent_id)];
- const hasRecipient = first && recipients.includes(first);
+ const hasRecipient = first && recipients.includes(first) && (values.item === undefined || second !== undefined);
const to = values.item !== undefined ? `item:${values.item}` : hasRecipient ? first : values.decision ? (me.id === COORDINATOR ? 'person' : COORDINATOR) : first ?? '';
const text = [hasRecipient ? second : first, ...(hasRecipient ? rest : [second, ...rest])].filter(Boolean).join(' ');
const id = await ordered(ctx, board, 'shout', [{ from: personShout(io, me) ? store.PERSON : me.id, to, text, ...(values.item !== undefined ? { item: Number(values.item) } : {}), lanes: laneNames(ctx.config), decision: Boolean(values.decision), evidence }]);
diff --git a/src/shout-audience.js b/src/shout-audience.js
index dc90de4e..fbffa9ac 100644
--- a/src/shout-audience.js
+++ b/src/shout-audience.js
@@ -34,7 +34,12 @@ export function shoutMatchesAudience(db, to, audience) {
return [...audience].some((agent) => itemShoutReader(db, item, agent));
}
-/** Existing four inbox parameters stay cursor, seat, lane, seat; indexed parameters reuse the seat identity. */
-export const UNREAD_SHOUT_SQL = `FROM shout WHERE shout_id > ?1 AND shout_from != ?2 AND
- (shout_to IN ('all', ?3, ?4) OR (shout_to = '${COORDINATION_SHOUT}' AND ?2 IN ('coordinator', 'person')) OR EXISTS (SELECT 1 FROM item WHERE shout_to = 'item:' || item_id AND
- (?2 = 'coordinator' OR COALESCE(item_owner, item_built_by) = ?2 OR COALESCE(item_review_by, item_verified_by) = ?2)))`;
+/** Positional bindings work on the supported minimum Node SQLite API as well as newer releases. */
+export const UNREAD_SHOUT_SQL = `FROM shout WHERE shout_id > ? AND shout_from != ? AND
+ (shout_to IN ('all', ?, ?) OR (shout_to = '${COORDINATION_SHOUT}' AND ? IN ('coordinator', 'person')) OR EXISTS (SELECT 1 FROM item WHERE shout_to = 'item:' || item_id AND
+ (? = 'coordinator' OR COALESCE(item_owner, item_built_by) = ? OR COALESCE(item_review_by, item_verified_by) = ?)))`;
+
+/** Bind every positional identity occurrence explicitly, including item-role checks. */
+export function unreadShoutBindings(cursor, seat, lane) {
+ return [cursor, seat, lane, seat, seat, seat, seat, seat];
+}
diff --git a/test/shout-item-cli.test.js b/test/shout-item-cli.test.js
new file mode 100644
index 00000000..779bfb40
--- /dev/null
+++ b/test/shout-item-cli.test.js
@@ -0,0 +1,33 @@
+/** Literal item-message text survives ordinary recipient words [B7,A2,N19]. */
+import assert from 'node:assert/strict';
+import { after, test } from 'node:test';
+import { join } from 'node:path';
+import * as store from '../src/board.js';
+import { createE2eHelpers } from './e2e-helpers.js';
+
+const fixtures = createE2eHelpers();
+after(fixtures.cleanup);
+
+test('an explicit item keeps all, person and lane names as literal message text [B7,A2,N19]', () => {
+ const box = fixtures.project('true');
+ const added = box.run(box.repo, 'add', 'web', 'Literal item messages', '--specs', 'G1', '--criterion', 'item messages retain text');
+ assert.equal(added.code, 0, added.err);
+ for (const text of ['all', 'person', 'web']) {
+ const sent = box.run(box.web, 'shout', '--item', '1', text, '--json');
+ assert.equal(sent.code, 0, `${text}: ${sent.err}${sent.out}`);
+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));
+ try {
+ const row = store.getShout(board, JSON.parse(sent.out).id);
+ assert.equal(row.shout_to, 'item:1');
+ assert.equal(row.shout_text, text);
+ } finally { store.closeBoard(board); }
+ }
+ const explicit = box.run(box.web, 'shout', 'web', 'explicit recipient with item', '--item', '1', '--json');
+ assert.equal(explicit.code, 0, explicit.err);
+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));
+ try {
+ const row = store.getShout(board, JSON.parse(explicit.out).id);
+ assert.equal(row.shout_to, 'item:1');
+ assert.equal(row.shout_text, 'explicit recipient with item');
+ } finally { store.closeBoard(board); }
+});