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(decisions): index only validated option inputs [H3,H16]

Corey Olson515f537bb0ba
diff --git a/docs/formats.md b/docs/formats.md
index cba59cbd..7d195b84 100644
--- a/docs/formats.md
+++ b/docs/formats.md
@@ -655,4 +655,4 @@ With numeric `wipPerReviewer` on, a new claim that would exceed that limit is re
### Item decision options
-A `shout` ordered move may carry `options`, an array of at least two distinct nonempty strings, only with `decision: true` and an item. The move requires the decision-queue engine leaf; older shouts retain their original meaning. The authoritative item event carries `decisionOptions` and `item`; `board_meta` keys `item_decision:<shout-id>` index those options for the open queue. Passing a question to the person copies its original options and item into the new decision index. Answers append ordinary answer events on the item; neither asking nor answering changes the claim or lease.
+A `shout` ordered move may carry `options`, an array of at least two distinct nonempty strings, only with `decision: true` and an item. The move requires the decision-queue engine leaf; older shouts retain their original meaning. Only the validated top-level `options` argument creates structured choices; legacy opaque `detail` is never reinterpreted. The item event carries `decisionOptions` and `item`; `board_meta` keys `item_decision:<shout-id>` index those options for the open queue. Passing a question to the person copies its original options and item into the new decision index. Answers append ordinary answer events on the item; neither asking nor answering changes the claim or lease.
diff --git a/src/board.js b/src/board.js
index 3e76c80c..917186ce 100644
--- a/src/board.js
+++ b/src/board.js
@@ -1663,7 +1663,8 @@ export { getItem } from './board-query.js';
*/
function insertShout(board, { from, to, text, lanes, item, decision = false, answers = null, evidence = null, request = false, channel = 'terminal', detail = {}, options }) {
const engine = board.executionEngineVersion ?? ENGINE_VERSION;
- detail = { ...detail, ...itemDecisionDetail(board, { options, decision, item, from }, engine) };
+ const validatedDecision = itemDecisionDetail(board, { options, decision, item, from }, engine);
+ detail = { ...detail, ...validatedDecision };
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');
to = itemShoutTarget(board.db, item);
@@ -1705,12 +1706,12 @@ function insertShout(board, { from, to, text, lanes, item, decision = false, ans
if (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, channel, detail, outcome, personAnswer, decisionRecord: validatedDecision.decisionOptions ? { item, options: validatedDecision.decisionOptions } : null });
}
/** 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, decisionRecord = null }) {
const result = board.db
.prepare(
`INSERT INTO shout (shout_from, shout_to, shout_text, shout_at, shout_decision, shout_answers,
@@ -1721,7 +1722,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 });
- recordItemDecision(board, id, { decision, answers, detail });
+ recordItemDecision(board, id, { decision, answers, record: decisionRecord });
return id;
}
diff --git a/src/item-decision-queue.js b/src/item-decision-queue.js
index f161cda4..200e3b4f 100644
--- a/src/item-decision-queue.js
+++ b/src/item-decision-queue.js
@@ -17,10 +17,9 @@ export function itemDecisionDetail(board, message, engine) {
return { decisionOptions: options.map(option => option.trim()) };
}
-/** Save a query index alongside its authoritative event; passing up preserves the original options. */
-export function recordItemDecision(board, id, { decision, answers, detail }) {
+/** Index only the validated top-level option record, never opaque legacy detail; passing up retains that index. */
+export function recordItemDecision(board, id, { decision, answers, record }) {
if (!decision) return;
- let record = detail.decisionOptions ? { item: detail.item, options: detail.decisionOptions } : null;
if (!record && answers !== null) {
const original = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`item_decision:${answers}`);
if (original) record = JSON.parse(original.meta_value);
diff --git a/test/decision-queue.test.js b/test/decision-queue.test.js
index 2e009f50..10c6744b 100644
--- a/test/decision-queue.test.js
+++ b/test/decision-queue.test.js
@@ -123,4 +123,6 @@ test('item decision options replay exactly and never acquire legacy engine autho
assert.equal(legacyOpaque.options, undefined, 'old opaque detail must not acquire new option meaning or item authority');
assert.equal(replica.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`item_decision:${legacyOpaque.shout_id}`),
undefined, 'legacy engine data creates no new decision index');
+ assert.deepEqual(JSON.parse(store.events(replica).at(-1).event_detail).decisionOptions, ['Injected A', 'Injected B'],
+ 'the legacy opaque event data itself is retained without rewriting history');
});