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.

feat: reviewer bar checks for 1163 [R2,H16]

Corey Olsone83838f1c2b3
diff --git a/src/api-moves.js b/src/api-moves.js
index 6e924741..6b397f10 100644
--- a/src/api-moves.js
+++ b/src/api-moves.js
@@ -11,7 +11,7 @@ const MOVES = {
'check-accept': { prefix: ['check', 'accept'], item: true },
add: { positions: ['lane', 'title'], flags: ['criterion', 'specs', 'parent', 'after', 'brief', 'route', 'check'], booleans: ['wait'], booleans: ['wait'] },
edit: { item: true, flags: ['criterion', 'brief', 'route', 'check', 'reason'], booleans: ['wait'], booleans: ['wait'] },
- fact: { item: true, positions: ['kind', 'text'], flags: ['supersedes', 'ref', 'implies'] },
+ fact: { item: true, positions: ['kind', 'text'], flags: ['answers', 'supersedes', 'ref', 'implies'] },
claim: { item: true },
release: { item: true, flags: ['note'] },
submit: { item: true },
diff --git a/src/bar-check-engine.js b/src/bar-check-engine.js
new file mode 100644
index 00000000..3acf9f77
--- /dev/null
+++ b/src/bar-check-engine.js
@@ -0,0 +1,3 @@
+/** The first engine carrying claim-scoped builder checks and peer answers. */
+import { unassignedEngine } from './engine-next.js';
+export const BAR_CHECK_ENGINE = unassignedEngine();
diff --git a/src/bar-check.js b/src/bar-check.js
new file mode 100644
index 00000000..ad84341d
--- /dev/null
+++ b/src/bar-check.js
@@ -0,0 +1,88 @@
+/** Claim-scoped bar check notes and reviewer answers [B29,B30,B31,H16]. */
+import { validateKnownLineSetting } from './queue-settings.js';
+import { Refused } from './refused.js';
+
+const SETTING = 'bar.check';
+
+/** Read the board's default-off bar.check line setting. */
+export function barCheckEnabled(board) {
+ const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`line_setting:${SETTING}`);
+ if (!row) return false;
+ let value;
+ try { value = JSON.parse(row.meta_value); }
+ catch { throw new Refused('LINE_SETTING_RANGE', 'the stored bar.check setting is malformed; restore its recorded board value before changing policy'); }
+ validateKnownLineSetting(SETTING, value);
+ return value === true;
+}
+
+/** Return the latest active claim, preserving its identity through lease renewals. */
+function latestClaim(board, id) {
+ return board.db.prepare("SELECT event_id FROM event WHERE item_id=? AND event_kind='claim' ORDER BY event_id DESC LIMIT 1").get(id) ?? null;
+}
+
+/** Read facts only after the current claim and extract their typed payloads. */
+function claimFacts(board, id, claimId) {
+ if (!claimId) return [];
+ return board.db.prepare("SELECT event_id,event_detail FROM event WHERE item_id=? AND event_kind='fact' AND event_id>? ORDER BY event_id")
+ .all(id, claimId).map(event => ({ eventId: event.event_id, ...JSON.parse(event.event_detail) }));
+}
+
+/** Determine whether this item needs a bar check and whether its latest note has a peer answer. */
+export function barCheckState(board, item) {
+ const claim = latestClaim(board, item.item_id);
+ const facts = claimFacts(board, item.item_id, claim?.event_id ?? null);
+ const note = facts.filter(fact => fact.kind === 'bar-check' && fact.claimId === claim?.event_id).at(-1) ?? null;
+ const answer = note ? facts.find(fact => fact.kind === 'bar-answer' && fact.claimId === claim.event_id && fact.answers === note.id) ?? null : null;
+ const sentBack = Boolean(board.db.prepare("SELECT 1 FROM event WHERE item_id=? AND event_kind='reject' LIMIT 1").get(item.item_id));
+ const required = Boolean(claim) && barCheckEnabled(board) && (['mid', 'strong'].includes(item.item_route) || sentBack);
+ return { required, claimId: claim?.event_id ?? null, note, answer };
+}
+
+/** Describe the one-line submit warning when the current claim has no reviewer answer. */
+export function barCheckWarning(board, item) {
+ const state = barCheckState(board, item);
+ if (!state.required || state.answer) return null;
+ if (!state.note) return `bar.check for claim ${state.claimId ?? 'unknown'} has no builder note`;
+ return `bar.check note ${state.note.id} has no reviewer answer`;
+}
+
+/** Parse the three labeled parts required in a builder's bar-check note. */
+function validBarNote(text) {
+ const sections = new Set();
+ for (const line of String(text).split(/\r?\n/u)) {
+ const label = /^\s*(bar|edge cases|test):\s*(.*)$/iu.exec(line);
+ if (label && label[2].trim()) sections.add(label[1].toLowerCase());
+ }
+ return ['bar', 'edge cases', 'test'].every(section => sections.has(section));
+}
+
+/** Capture the current claim on builder notes and validate one cross-session answer to the latest note. */
+export function barCheckFactFields(board, item, { agentId, kind, text, answers, supersedes }) {
+ if (!['bar-check', 'bar-answer'].includes(kind)) {
+ if (answers !== null) throw new Refused('USAGE', '--answers is only for bar-answer facts', 'use --answers only with pullboard fact <id> bar-answer "yes or what was missed" --answers <bar-check-fact-id>');
+ return {};
+ }
+ if (supersedes !== null) throw new Refused('USAGE', 'bar-check notes and answers are append-only and do not supersede other facts', 'post a new bar-check note and answer that note with --answers <fact-id>');
+ const claim = latestClaim(board, item.item_id);
+ if (!claim || item.item_status !== 'claimed' || (item.item_lease_until ?? '') <= board.clock.now().toISOString()) {
+ throw new Refused('NOT_YOURS', `#${item.item_id} needs a live claim before a bar check note or answer can be posted`, `claim #${item.item_id}, then post the bar-check note or answer`);
+ }
+ const facts = claimFacts(board, item.item_id, claim.event_id);
+ const latestNote = facts.filter(fact => fact.kind === 'bar-check' && fact.claimId === claim.event_id).at(-1) ?? null;
+ if (kind === 'bar-check') {
+ if (item.item_owner !== agentId) throw new Refused('NOT_YOURS', `only the live builder ${item.item_owner} can post the bar-check note for #${item.item_id}`, `the live builder posts it with pullboard fact ${item.item_id} bar-check "bar: …\\nedge cases: …\\ntest: …"`);
+ if (!validBarNote(text)) throw new Refused('USAGE', 'a bar-check note needs labeled nonempty parts: bar:, edge cases:, and test:', `post pullboard fact ${item.item_id} bar-check "bar: …\\nedge cases: …\\ntest: …"`);
+ return { claimId: claim.event_id };
+ }
+ if (typeof answers !== 'string' || !/^[A-Za-z0-9_-]{1,80}$/u.test(answers) || !latestNote || latestNote.id !== answers) {
+ throw new Refused('NO_FACT', `answer the latest bar-check note for claim ${claim.event_id}; read pullboard show ${item.item_id} --history`, `read the latest bar-check note with pullboard show ${item.item_id} --history, then name its id with --answers <fact-id>`);
+ }
+ const existing = facts.find(fact => fact.kind === 'bar-answer' && fact.claimId === claim.event_id && fact.answers === answers);
+ if (existing) throw new Refused('FACT_JUDGEMENT', `bar-check note ${answers} already has its one reviewer answer`, `the builder can post a new bar-check note if the bar changed`);
+ if (typeof text !== 'string' || !text.trim()) throw new Refused('EMPTY_FACT', 'a bar-check answer needs “yes” or what the bar check missed');
+ const builderSession = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`agent_session:${item.item_owner}`)?.meta_value;
+ const reviewerSession = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`agent_session:${agentId}`)?.meta_value;
+ if (!builderSession || !reviewerSession) throw new Refused('BAR_PARENT_UNKNOWN', 'bar-check authors need registered runtime session identities; join from each real session before posting', 'join from each real runtime session, then retry the bar-check answer');
+ if (builderSession === reviewerSession) throw new Refused('BAR_SELF_SIGN', 'the builder and reviewer must be different runtime sessions', 'ask a reviewer from another runtime session to answer the bar-check note');
+ return { claimId: claim.event_id, answers };
+}
diff --git a/src/board-query.js b/src/board-query.js
index 60202e5c..689ffddd 100644
--- a/src/board-query.js
+++ b/src/board-query.js
@@ -303,6 +303,7 @@ export function factFromEvent(event) {
const detail = JSON.parse(event.event_detail);
return { id: detail.id, eventId: event.event_id, kind: detail.kind, text: detail.text,
by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null, ...decisionFields(detail),
+ ...(detail.claimId === undefined ? {} : { claimId: detail.claimId }), ...(detail.answers === undefined ? {} : { answers: detail.answers }),
...(detail.neverAgain ? { cause: detail.cause, neverAgain: true } : {}) };
}
diff --git a/src/board.js b/src/board.js
index 79f49d64..dabcc1e4 100644
--- a/src/board.js
+++ b/src/board.js
@@ -45,6 +45,7 @@ import {
import { FILE_GROWTH_NOTICE_ENGINE } from './file-growth-notice-engine.js';
import { recordBarRevision } from './bar-readiness.js';
import { barReadyProblem } from './bar-readiness.js';
+import { barCheckFactFields } from './bar-check.js';
export { setBarReady, signBar } from './bar-readiness.js';
import { coordinatorCheck } from './item-check-baseline.js';
import { normalizeCheckBaseline } from './item-check-baseline.js';
@@ -1860,7 +1861,7 @@ export { unreadCount } from './board-query.js';
export { events } from './board-query.js';
/** Fact labels distinguish observations from judgements reserved to an item's live holder [B29,B30]. */
-export const FACT_KINDS = Object.freeze(['capture', 'measurement', 'note', 'diff', 'decision', 'rejection', 'supersession', 'root-cause']);
+export const FACT_KINDS = Object.freeze(['capture', 'measurement', 'note', 'diff', 'decision', 'rejection', 'supersession', 'root-cause', 'bar-check', 'bar-answer']);
const FACT_JUDGEMENTS = new Set(['decision', 'rejection', 'supersession', 'root-cause']);
export { factReference };
@@ -1870,12 +1871,13 @@ export { itemThread } from './board-query.js';
/** Append a typed fact atomically; a correction never edits the original event [B29,B30,B31,B32].
* The internal factId is set from a sealed move's identity during replay, rather than replica-local sequence ids; a never-again with its cause is the person's alone, and rigor lists it at once (#713) [D1].
*/
-export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID(), implies, cause = null, neverAgain = false, asPerson = false, channel = 'terminal' }) {
+export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, answers = null, factId = randomUUID(), implies, cause = null, neverAgain = false, asPerson = false, channel = 'terminal' }) {
return atomic(board, () => {
const item = current(board, itemById(board, id));
if (!board.db.prepare('SELECT 1 FROM agent WHERE agent_id = ?').get(agentId)) throw new Refused('NO_AGENT', `no registered agent ${agentId}; join a worktree before appending a fact`);
if (!FACT_KINDS.includes(kind)) throw new Refused('BAD_FACT_KIND', `unknown fact kind ${String(kind)}; use ${FACT_KINDS.join(', ')}`);
if (typeof text !== 'string' || !text.trim()) throw new Refused('EMPTY_FACT', 'a fact needs nonempty text; supply the observation or judgement');
+ const barFields = barCheckFactFields(board, item, { agentId, kind, text, answers, supersedes });
if ((FACT_JUDGEMENTS.has(kind) || supersedes !== null) && agentId !== COORDINATOR && (!isHeld(board, item) || item.item_owner !== agentId)) {
throw new Refused('FACT_JUDGEMENT', `only the item's live holder${isHeld(board, item) ? ' (' + item.item_owner + ')' : ''} or the coordinator may append a judgement or supersede a fact; append an observation or ask the coordinator`);
}
@@ -1886,7 +1888,7 @@ export function appendFact(board, id, { agentId, kind, text, ref = null, superse
}
const binding = factReference(ref);
if (neverAgain || asPerson || cause !== null) requireNeverAgain(id, { agentId, cause, neverAgain, asPerson, channel });
- logEvent(board, neverAgain ? PERSON : agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes, ...(neverAgain ? { cause, neverAgain: true, channel } : {}), ...(implies?.length ? { implies } : {}) });
+ logEvent(board, neverAgain ? PERSON : agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes, ...barFields, ...(neverAgain ? { cause, neverAgain: true, channel } : {}), ...(implies?.length ? { implies } : {}) });
const trigger = board.lastEvent;
const result = tellFactImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), factFromEvent(trigger), { id, implies, supersedes });
if (neverAgain) postRigorNotices(board, trigger);
diff --git a/src/cli-main.js b/src/cli-main.js
index 0bad3f05..9ece9ff2 100644
--- a/src/cli-main.js
+++ b/src/cli-main.js
@@ -130,6 +130,7 @@ const OPTIONS = {
commit: { type: 'string' },
ref: { type: 'string' },
supersedes: { type: 'string' },
+ answers: { type: 'string' },
conflict: { type: 'string', multiple: true },
'withdraw-verdict': { type: 'boolean' },
cause: { type: 'string' },
diff --git a/src/commands/fact.js b/src/commands/fact.js
index a0c8e462..eb8e67e6 100644
--- a/src/commands/fact.js
+++ b/src/commands/fact.js
@@ -19,7 +19,7 @@ import {
export async function run(io, { first, second, rest, values }) {
const act = (work) => actOn(io, work);
return act(async (ctx, board, me) => {
- if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>] [--cause <key> --never-again --as person]');
+ if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--answers <bar-check-fact-id>] [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>] [--cause <key> --never-again --as person]');
const id = idArg(first);
const implies = parseImplies(values.implies);
const asPerson = values.as === 'person' && personMode(ctx, me, values);
@@ -27,7 +27,8 @@ export async function run(io, { first, second, rest, values }) {
const marked = asPerson || values['never-again'] || values.cause !== undefined
? { cause: values.cause ?? null, neverAgain: Boolean(values['never-again']), asPerson, channel: ctx.io.personChannel ?? 'terminal' } : {};
const fact = await ordered(ctx, board, 'appendFact', [id, { agentId: me.id, kind: second,
- text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null, ...(implies ? { implies } : {}), ...marked }]);
+ text: rest[0], supersedes: values.supersedes ?? null, answers: values.answers ?? null,
+ ref: values.ref ?? null, ...(implies ? { implies } : {}), ...marked }]);
io.result?.({ item: id, fact });
io.say(`fact ${fact.id} appended to #${id} as ${fact.kind}`);
return 0;
diff --git a/src/commands/show.js b/src/commands/show.js
index 034fa2c1..2a6ca8f8 100644
--- a/src/commands/show.js
+++ b/src/commands/show.js
@@ -104,7 +104,7 @@ export async function run(io, { first, values }) {
for (const entry of thread) {
const stamp = ` ${entry.at} ${agentDisplayName(agents, ctx.config, entry.by)} `;
if (entry.type === 'fact') {
- io.say(`${stamp}fact ${entry.kind} ${entry.id}${entry.supersedes ? ' (supersedes ' + entry.supersedes + ')' : ''}: ${entry.text}`);
+ io.say(`${stamp}fact ${entry.kind} ${entry.id}${entry.answers ? ' (answers ' + entry.answers + ')' : entry.supersedes ? ' (supersedes ' + entry.supersedes + ')' : ''}: ${entry.text}`);
if (entry.ref) io.say(` ref: ${entry.ref.path}:${entry.ref.start}${entry.ref.end === entry.ref.start ? '' : '-' + entry.ref.end}@${entry.ref.commit}`);
} else {
const detail = entry.detail;
diff --git a/src/commands/submit.js b/src/commands/submit.js
index ac0c7683..2ad508ee 100644
--- a/src/commands/submit.js
+++ b/src/commands/submit.js
@@ -2,6 +2,7 @@ import {
barReadySetting,
barReadyProblem,
} from '../bar-readiness.js';
+import { barCheckWarning } from '../bar-check.js';
import { requireSubmitComposition } from '../submit-composition.js';
/** The pullboard submit command, in its own module so an item adding another command never edits these lines. */
import * as store from '../board.js';
@@ -124,6 +125,15 @@ export async function submitHere(ctx, id, infra) {
if (correction) throw correction;
return item;
});
+ const barWarning = await withBoard(ctx, async board => {
+ const warning = barCheckWarning(board, held);
+ if (!warning) return null;
+ await ordered(ctx, board, 'appendFact', [id, { agentId: held.item_owner, kind: 'note', text: `bar.check warning: ${warning}` }]);
+ return warning;
+ });
+ if (barWarning) {
+ ctx.io.say(`bar.check warning: ${barWarning}`);
+ }
const policy = itemPolicy(root, held);
const acceptedMain = mainPolicy(root);
const requireComposition = withBoard(ctx, board => barReadySetting(board).enabled);
diff --git a/src/help.js b/src/help.js
index 0bf71342..90ad5c16 100644
--- a/src/help.js
+++ b/src/help.js
@@ -32,7 +32,7 @@ Set up
pullboard resources local resource holders and their FIFO queues
pullboard settings line [<name> <value> --reason "why" --window <json>] read or record board controller inputs; all off by default
value is on, off, or a number within the setting range
- names: order, reviewsFirst, wipPerReviewer (1.5-3), barReady, takeoverMinutes (15-60), collisionFreeBatch, landingBatchSize (1-8), landingCadenceMinutes (5-30)
+ names: order, reviewsFirst, wipPerReviewer (1.5-3), barReady, bar.check, takeoverMinutes (15-60), collisionFreeBatch, landingBatchSize (1-8), landingCadenceMinutes (5-30)
pullboard settings [gateSlots <n> | browserSlots <n>] view or set machine capacity (gate default 2; browser default 1)
browser-free check slots are opt-in: gate.browserFreeChecks in ~/.pullboard/settings.json (default false)
a test file takes a browser slot only if it launches Chrome: gate.browserByLaunch (default false)
@@ -117,8 +117,9 @@ Work
pullboard skills --update refresh unchanged Claude Code skills from shipped versions
pullboard show <id> [--history] an item, the criterion frozen at claim, its verdicts: the latest in full,
earlier ones as one line; --history prints every note in full
- pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>]
- append an observation or a holder/coordinator judgement to its thread
+ pullboard fact <id> <kind> <text> [--answers <bar-check-fact-id>] [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>]
+ append observations, bar-check notes and peer answers, or holder/coordinator judgements
+ a bar-answer uses --answers to name the bar-check fact it reviewed
--implies 12,13: each named item gets a fact citing this decision,
and is told again when the decision is superseded
the person adds --cause <key> --never-again --as person: rigor lists it at once
diff --git a/src/moves/appendFact.js b/src/moves/appendFact.js
index 3a0bce6e..005c2733 100644
--- a/src/moves/appendFact.js
+++ b/src/moves/appendFact.js
@@ -5,15 +5,17 @@ import { LANDING_LEASE_ENGINE } from '../landing-lease-engine.js';
import { IMPLIES_ENGINE } from '../move-engine-constants.js';
import { carriesImplies } from '../move-implies.js';
import { BOARD_SENTINEL_ENGINE } from '../sentinel-engine.js';
+import { BAR_CHECK_ENGINE } from '../bar-check-engine.js';
/** Preserve this operation's historical first-matching engine conditions [H16]. */
function minimumEngine(args, board, at) {
- if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('conflict:')) return RIGOR_AUTO_ENGINE;
- if (args[0]?.landingFence !== undefined) return LANDING_LEASE_ENGINE;
- if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('sentinel:')) return BOARD_SENTINEL_ENGINE;
- if (['cause', 'neverAgain', 'asPerson'].some(name => Boolean(args[1] && typeof args[1] === 'object' && Object.hasOwn(args[1], name) && args[1][name] !== undefined && args[1][name] !== null && args[1][name] !== false))) return CAUSE_ENGINE;
- if (carriesImplies('appendFact', args)) return IMPLIES_ENGINE;
- return 1;
+ const barCheck = ['bar-check', 'bar-answer'].includes(args[1]?.kind) ? BAR_CHECK_ENGINE : 1;
+ if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('conflict:')) return Math.max(barCheck, RIGOR_AUTO_ENGINE);
+ if (args[0]?.landingFence !== undefined) return Math.max(barCheck, LANDING_LEASE_ENGINE);
+ if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('sentinel:')) return Math.max(barCheck, BOARD_SENTINEL_ENGINE);
+ if (['cause', 'neverAgain', 'asPerson'].some(name => Boolean(args[1] && typeof args[1] === 'object' && Object.hasOwn(args[1], name) && args[1][name] !== undefined && args[1][name] !== null && args[1][name] !== false))) return Math.max(barCheck, CAUSE_ENGINE);
+ if (carriesImplies('appendFact', args)) return Math.max(barCheck, IMPLIES_ENGINE);
+ return barCheck;
}
/** Read precisely the actor argument used by this operation [H2,H16]. */
diff --git a/src/moves/setLineSetting.js b/src/moves/setLineSetting.js
index 7fd79e72..72bace03 100644
--- a/src/moves/setLineSetting.js
+++ b/src/moves/setLineSetting.js
@@ -5,15 +5,17 @@ import { LANDING_LEASE_ENGINE } from '../landing-lease-engine.js';
import { LINE_ORDER_ENGINE } from '../line-order-engine.js';
import { LINE_SETTINGS_ENGINE } from '../line-settings-engine.js';
import { BOARD_SENTINEL_ENGINE } from '../sentinel-engine.js';
+import { BAR_CHECK_ENGINE } from '../bar-check-engine.js';
/** Preserve this operation's historical first-matching engine conditions [H16]. */
function minimumEngine(args, board, at) {
- if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('conflict:')) return RIGOR_AUTO_ENGINE;
- if (args[0]?.key === 'collisionFreeBatch') return LAND_COLLISION_ENGINE;
- if (args[0]?.key === 'order') return LINE_ORDER_ENGINE;
- if (args[0]?.landingFence !== undefined) return LANDING_LEASE_ENGINE;
- if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('sentinel:')) return BOARD_SENTINEL_ENGINE;
- return LINE_SETTINGS_ENGINE;
+ const barCheck = args[0]?.key === 'bar.check' ? BAR_CHECK_ENGINE : 1;
+ if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('conflict:')) return Math.max(barCheck, RIGOR_AUTO_ENGINE);
+ if (args[0]?.key === 'collisionFreeBatch') return Math.max(barCheck, LAND_COLLISION_ENGINE);
+ if (args[0]?.key === 'order') return Math.max(barCheck, LINE_ORDER_ENGINE);
+ if (args[0]?.landingFence !== undefined) return Math.max(barCheck, LANDING_LEASE_ENGINE);
+ if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('sentinel:')) return Math.max(barCheck, BOARD_SENTINEL_ENGINE);
+ return Math.max(barCheck, LINE_SETTINGS_ENGINE);
}
/** Read precisely the actor argument used by this operation [H2,H16]. */
diff --git a/src/moves/submit.js b/src/moves/submit.js
index cef18ca0..3600579d 100644
--- a/src/moves/submit.js
+++ b/src/moves/submit.js
@@ -6,6 +6,8 @@ import { LANDING_LEASE_ENGINE } from '../landing-lease-engine.js';
import { OUTSIDE_INTAKE_ENGINE } from '../outside-intake-engine.js';
import { outsideSource } from '../outside-source.js';
import { BOARD_SENTINEL_ENGINE } from '../sentinel-engine.js';
+import { BAR_CHECK_ENGINE } from '../bar-check-engine.js';
+import { barCheckEnabled } from '../bar-check.js';
import {
SUBMISSION_PROOF_ENGINE,
submissionProof,
@@ -13,12 +15,13 @@ import {
/** Preserve this operation's historical first-matching engine conditions [H16]. */
function existingEngine(args, board, at) {
- if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('conflict:')) return RIGOR_AUTO_ENGINE;
- if (board && barReadySetting(board).enabled) return BAR_READY_ENGINE;
- if (args[0]?.landingFence !== undefined) return LANDING_LEASE_ENGINE;
- if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('sentinel:')) return BOARD_SENTINEL_ENGINE;
- if (args[1]?.submissionProof !== undefined) return SUBMISSION_PROOF_ENGINE;
- return 1;
+ const barCheck = board && barCheckEnabled(board) ? BAR_CHECK_ENGINE : 1;
+ if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('conflict:')) return Math.max(barCheck, RIGOR_AUTO_ENGINE);
+ if (board && barReadySetting(board).enabled) return Math.max(barCheck, BAR_READY_ENGINE);
+ if (args[0]?.landingFence !== undefined) return Math.max(barCheck, LANDING_LEASE_ENGINE);
+ if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('sentinel:')) return Math.max(barCheck, BOARD_SENTINEL_ENGINE);
+ if (args[1]?.submissionProof !== undefined) return Math.max(barCheck, SUBMISSION_PROOF_ENGINE);
+ return barCheck;
}
/** Keep outside-source isolation as the original maximum over the older engine rule. */
function minimumEngine(args, board, at) {
diff --git a/src/queue-settings.js b/src/queue-settings.js
index 535a8370..48bdce4b 100644
--- a/src/queue-settings.js
+++ b/src/queue-settings.js
@@ -92,6 +92,7 @@ export const LINE_SETTING_DEFINITIONS = Object.freeze({
reviewsFirst: Object.freeze({ type: 'boolean' }),
wipPerReviewer: Object.freeze({ type: 'number', min: 1.5, max: 3, integer: false }),
barReady: Object.freeze({ type: 'boolean' }),
+ 'bar.check': Object.freeze({ type: 'boolean' }),
takeoverMinutes: Object.freeze({ type: 'number', min: 15, max: 60, integer: true }),
collisionFreeBatch: Object.freeze({ type: 'boolean' }),
landingBatchSize: Object.freeze({ type: 'number', min: 1, max: 8, integer: true }),
diff --git a/test/bar-check.test.js b/test/bar-check.test.js
new file mode 100644
index 00000000..b94bb99c
--- /dev/null
+++ b/test/bar-check.test.js
@@ -0,0 +1,149 @@
+/** Prove the opt-in bar check's claim-scoped typed note and one-session answer [B29,B30,B31,H16]. */
+import assert from 'node:assert/strict';
+import { join } from 'node:path';
+import { after, test } from 'node:test';
+import * as store from '../src/board.js';
+import { barCheckState, barCheckWarning } from '../src/bar-check.js';
+import { parentSessionDigest } from '../src/parent-session.js';
+import { saveAgentSession } from '../src/seats.js';
+import { applyRelayMove, prepareEngineMove } from '../src/engine.js';
+import { BAR_CHECK_ENGINE } from '../src/bar-check-engine.js';
+import { createE2eHelpers } from './e2e-helpers.js';
+
+const HOUR = 3_600_000;
+const e2e = createE2eHelpers();
+after(e2e.cleanup);
+
+/** Open a private board and enroll two agents with distinct recorded runtime sessions. */
+function fixture(t, route = 'mid') {
+ const board = store.openBoard(':memory:');
+ store.register(board, { lane: 'coordinator', path: '/fixture/main' });
+ store.register(board, { lane: 'core', path: '/fixture/builder' });
+ store.register(board, { lane: 'core', path: '/fixture/reviewer' });
+ saveAgentSession(board, 'core-1', parentSessionDigest('bar-check-builder-session'));
+ saveAgentSession(board, 'core-2', parentSessionDigest('bar-check-reviewer-session'));
+ const id = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Bar check fixture', criterion: 'the bar is understood', route,
+ brief: 'Files: src/page.js\nTest: the check proves the criterion', check: 'true' });
+ t.after(() => store.closeBoard(board));
+ return { board, id };
+}
+
+/** Record an opt-in setting with the required measured window. */
+function enable(board) {
+ store.setLineSetting(board, { agentId: 'coordinator', key: 'bar.check', value: true,
+ reason: 'The review window needs a pre-build bar check', window: { windowMinutes: 60, activeReviewers: 2 } });
+}
+
+/** Claim an item with a stable fixture criterion digest. */
+function claim(board, id) {
+ return store.claim(board, id, { agentId: 'core-1', lane: 'core', leaseMs: 2 * HOUR,
+ freeze: item => ({ text: item.item_criterion, digest: 'fixture-bar-check' }) });
+}
+
+const BUILDER_NOTE = 'bar: the criterion is met by the changed behavior\nedge cases: empty and repeated inputs\ntest: add one named case for each';
+
+test('[B29,B30,B31,H16] a bar check note on a claimed item is answered by a reviewer in one round', t => {
+ const { board, id } = fixture(t);
+ assert.equal(store.lineSettings(board)['bar.check'], false, 'the board setting is off by default');
+ assert.equal(barCheckWarning(board, store.getItem(board, id)), null, 'unclaimed work has no current bar-check cycle');
+ enable(board);
+ claim(board, id);
+ const item = store.getItem(board, id);
+ const note = store.appendFact(board, id, { agentId: 'core-1', kind: 'bar-check', text: BUILDER_NOTE, factId: 'builder-bar-check' });
+ assert.equal(note.claimId, store.events(board, { itemId: id }).findLast(event => event.event_kind === 'claim').event_id);
+ assert.match(barCheckWarning(board, store.getItem(board, id)), /has no reviewer answer/u);
+ assert.throws(() => store.appendFact(board, id, { agentId: 'core-1', kind: 'bar-answer', text: 'yes', answers: note.id }), { code: 'BAR_SELF_SIGN' });
+ const answer = store.appendFact(board, id, { agentId: 'core-2', kind: 'bar-answer', text: 'The repeated input also needs to preserve order.', answers: note.id, factId: 'reviewer-bar-answer' });
+ assert.equal(answer.answers, note.id, 'the answer names the note it reviewed');
+ assert.equal(barCheckState(board, item).answer.id, answer.id);
+ assert.equal(barCheckWarning(board, store.getItem(board, id)), null);
+ assert.throws(() => store.appendFact(board, id, { agentId: 'core-2', kind: 'bar-answer', text: 'yes', answers: note.id }), { code: 'FACT_JUDGEMENT' });
+
+ store.appendFact(board, id, { agentId: 'core-1', kind: 'bar-check', text: BUILDER_NOTE + '\nbar: correction for this claim', factId: 'builder-bar-check-correction' });
+ assert.equal(barCheckState(board, store.getItem(board, id)).answer, null, 'a later note needs its own answer');
+ assert.throws(() => store.appendFact(board, id, { agentId: 'core-2', kind: 'bar-answer', text: 'yes', answers: note.id }), { code: 'NO_FACT' });
+});
+
+test('[R2,H16] the bar.check setting refuses old engine moves and applies at its current engine floor', t => {
+ const { board } = fixture(t);
+ const options = { agentId: 'coordinator', key: 'bar.check', value: true, reason: 'the check is being introduced',
+ window: { windowMinutes: 60, activeReviewers: 2 } };
+ const move = prepareEngineMove(board, 'setLineSetting', [options], { id: 'bar-check-setting-engine', actor: 'coordinator' });
+ assert.equal(move.engine, BAR_CHECK_ENGINE);
+ const envelope = { sequence: 1, at: '2026-10-24T00:00:00Z', kind: 'move',
+ sender: { kind: 'agent', agent: 'coordinator', userId: 'fixture' } };
+ assert.throws(() => applyRelayMove(board, { ...move, engine: BAR_CHECK_ENGINE - 1 }, envelope),
+ /RELAY_MOVE.*introduced in engine/u, 'an old engine cannot reinterpret the new setting');
+ assert.equal(store.lineSettings(board)['bar.check'], false);
+ assert.equal(applyRelayMove(board, move, envelope).error, undefined);
+ assert.equal(store.lineSettings(board)['bar.check'], true);
+});
+
+test('[B29,B30,B31,H16] renewals keep the current note and a new claim starts a fresh bar-check round', t => {
+ const { board, id } = fixture(t);
+ enable(board);
+ claim(board, id);
+ const note = store.appendFact(board, id, { agentId: 'core-1', kind: 'bar-check', text: BUILDER_NOTE, factId: 'renew-note' });
+ store.claim(board, id, { agentId: 'core-1', lane: 'core', leaseMs: 2 * HOUR, freeze: () => ({ text: '', digest: '' }) });
+ assert.equal(barCheckState(board, store.getItem(board, id)).note.id, note.id);
+ store.release(board, id, 'core-1');
+ claim(board, id);
+ assert.equal(barCheckState(board, store.getItem(board, id)).note, null);
+ assert.match(barCheckWarning(board, store.getItem(board, id)), /has no builder note/u);
+});
+
+test('[B29,B30,B31,V4,H16] submit succeeds despite a missing answer, warns once and records the warning', () => {
+ const box = e2e.project();
+ const added = box.run(box.repo, 'add', 'web', 'Bar check submit', '--route', 'mid', '--criterion', 'the page renders', '--check', 'true',
+ '--brief', 'Files:\n- web/page.html\nTest:\n- the page renders');
+ assert.equal(added.code, 0, added.err);
+ const enabled = box.run(box.repo, 'settings', 'line', 'bar.check', 'on', '--reason', 'check the criterion before building',
+ '--window', '{"windowMinutes":60,"activeReviewers":2}');
+ assert.equal(enabled.code, 0, enabled.err);
+ assert.equal(box.run(box.web, 'claim', '1').code, 0);
+ assert.equal(e2e.commitFile(box, box.web, 'web/page.html', '<h1>Page</h1>\n', 'feat(web): add page [G1]').status, 0);
+
+ const submitted = box.run(box.web, 'submit', '1');
+ assert.equal(submitted.code, 0, submitted.err);
+ assert.match(submitted.out, /^bar\.check warning: bar\.check for claim \d+ has no builder note$/mu);
+ assert.equal((submitted.out.match(/^bar\.check warning:/gmu) ?? []).length, 1, 'submit emits one warning line');
+ assert.match(submitted.out, /submitted #1/u, 'the warning does not refuse submit');
+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));
+ try {
+ const warning = store.events(board, { itemId: 1 })
+ .filter(event => event.event_kind === 'fact')
+ .map(event => JSON.parse(event.event_detail))
+ .find(fact => fact.kind === 'note' && fact.text.startsWith('bar.check warning:'));
+ assert.ok(warning, 'the warning is recorded as an item fact');
+ assert.match(warning.text, /^bar\.check warning: bar\.check for claim \d+ has no builder note$/u);
+ } finally { store.closeBoard(board); }
+});
+
+test('[B29,B30,B31,V4,H16] a sent-back light item starts a required check when it is reclaimed', () => {
+ const box = e2e.project();
+ const added = box.run(box.repo, 'add', 'web', 'Light bar check', '--route', 'light', '--criterion', 'the page renders', '--check', 'true',
+ '--brief', 'Files:\n- web/page.html\nTest:\n- the page renders');
+ assert.equal(added.code, 0, added.err);
+ const enabled = box.run(box.repo, 'settings', 'line', 'bar.check', 'on', '--reason', 'check the criterion before building',
+ '--window', '{"windowMinutes":60,"activeReviewers":2}');
+ assert.equal(enabled.code, 0, enabled.err);
+ assert.equal(box.run(box.web, 'claim', '1').code, 0);
+ assert.equal(e2e.commitFile(box, box.web, 'web/page.html', '<h1>Page</h1>\n', 'feat(web): add page [G1]').status, 0);
+ const firstSubmit = box.run(box.web, 'submit', '1');
+ assert.equal(firstSubmit.code, 0, firstSubmit.err);
+ assert.doesNotMatch(firstSubmit.out, /^bar\.check warning:/mu, 'a first light claim is optional');
+ const reviewer = join(box.dir, 'web-reviewer');
+ const submittedCommit = box.git(box.web, 'rev-parse', 'HEAD');
+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', reviewer, submittedCommit);
+ const reviewerJoin = box.run(reviewer, 'join', 'web');
+ assert.equal(reviewerJoin.code, 0, reviewerJoin.err);
+ const rejected = box.run(reviewer, 'verify', '1', 'reject', '--reason', 'BEHAVIOR_MISMATCH', '--note', 'the heading is not specified');
+ assert.equal(rejected.code, 0, rejected.err);
+ assert.equal(box.run(box.web, 'claim', '1').code, 0);
+
+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));
+ try {
+ assert.equal(barCheckState(board, store.getItem(board, 1)).required, true,
+ 'the real reject and reclaim starts a fresh required check');
+ } finally { store.closeBoard(board); }
+});
diff --git a/test/line-settings.test.js b/test/line-settings.test.js
index 5b52454e..769eefe4 100644
--- a/test/line-settings.test.js
+++ b/test/line-settings.test.js
@@ -9,6 +9,7 @@ import { applyRelayMove, prepareEngineMove } from '../src/engine.js';
import { settingsInventory } from '../src/settings-inventory.js';
import { createE2eHelpers } from './e2e-helpers.js';
import { LAND_COLLISION_ENGINE } from '../src/landing-collision-engine.js';
+import { BAR_CHECK_ENGINE } from '../src/bar-check-engine.js';
/** A private SQLite board with coordinator and builder identities. */
function fixture(t) {
@@ -67,11 +68,12 @@ test('the settings inventory exposes board line values and defaults without audi
} finally {
for (const [key, value] of Object.entries(previous)) { if (value === undefined) delete process.env[key]; else process.env[key] = value; }
}
- assert.equal(rows.length, 8);
+ assert.equal(rows.length, 9);
assert.deepEqual(rows.find(row => row.key === 'line.wipPerReviewer'), { key: 'line.wipPerReviewer', scope: 'board',
board: store.boardId(board), root: box.repo, value: 2, default: false,
source: join(box.repo, '.git', 'pullboard', 'board.sqlite'), origin: 'configured' });
assert.equal(rows.find(row => row.key === 'line.reviewsFirst').value, false);
+ assert.equal(rows.find(row => row.key === 'line.bar.check').value, false);
assert.equal(rows.find(row => row.key === 'line.reviewsFirst').origin, 'default');
assert.doesNotMatch(JSON.stringify(rows), /PRIVATE_REASON_CANARY|activeReviewers|reviewMedianMinutes/u);
assert.equal(store.events(board).length, before, 'inventory is a read, not a line-setting change');
@@ -92,3 +94,17 @@ test('collision-free batch policy stays off until a current authenticated coordi
store.setLineSetting(board, change({ key: 'collisionFreeBatch', value: false }));
assert.equal(store.lineSettings(board).collisionFreeBatch, false);
});
+
+test('[R2,H16] bar.check setting moves require the new engine and current clients still apply them', t => {
+ const board = fixture(t);
+ const options = change({ key: 'bar.check' });
+ const move = prepareEngineMove(board, 'setLineSetting', [options], { id: 'bar-check-policy', actor: 'coordinator' });
+ assert.equal(move.engine, BAR_CHECK_ENGINE, 'the new line-setting key carries its own engine floor');
+ const envelope = { sequence: 1, at: '2026-10-24T00:00:00Z', kind: 'move',
+ sender: { kind: 'agent', agent: 'coordinator', userId: 'fixture' } };
+ assert.throws(() => applyRelayMove(board, { ...move, engine: BAR_CHECK_ENGINE - 1 }, envelope), /RELAY_MOVE.*introduced in engine/u);
+ assert.equal(store.lineSettings(board)['bar.check'], false, 'an old-engine move cannot enable the setting');
+ const applied = applyRelayMove(board, move, envelope);
+ assert.equal(applied.error, undefined);
+ assert.equal(store.lineSettings(board)['bar.check'], true, 'the current engine applies the same recorded move');
+});
diff --git a/test/settings.test.js b/test/settings.test.js
index b7cab7d7..31e3472d 100644
--- a/test/settings.test.js
+++ b/test/settings.test.js
@@ -85,7 +85,7 @@ test('a line setting change is a recorded move with its reason and its range [R1
'--window', JSON.stringify(numbers), '--json');
assert.equal(changed.code, 0, `a board setting change succeeds: ${changed.err}${changed.out}`);
assert.equal(initial.code, 0, initial.err);
- const defaults = { order: false, reviewsFirst: false, wipPerReviewer: false, barReady: false, takeoverMinutes: false,
+ const defaults = { order: false, reviewsFirst: false, wipPerReviewer: false, barReady: false, 'bar.check': false, takeoverMinutes: false, collisionFreeBatch: false,
landingBatchSize: false, landingCadenceMinutes: false };
assert.deepEqual(JSON.parse(initial.out).lineSettings, defaults, 'all line controls start off, not silently enabled by a machine file');
assert.equal(JSON.parse(changed.out).lineSettings.reviewsFirst, true);
@@ -97,7 +97,7 @@ test('a line setting change is a recorded move with its reason and its range [R1
assert.deepEqual(JSON.parse(first.event_detail), { key: 'reviewsFirst', value: true,
reason: 'Review waiting exceeds the target', window: numbers, model: 'unknown' });
assert.equal(first.event_by, 'coordinator');
- const values = [['order', true], ['order', false], ['reviewsFirst', false], ['wipPerReviewer', 1.5], ['wipPerReviewer', 3], ['barReady', true],
+ const values = [['order', true], ['order', false], ['reviewsFirst', false], ['wipPerReviewer', 1.5], ['wipPerReviewer', 3], ['barReady', true], ['bar.check', true], ['collisionFreeBatch', true], ['collisionFreeBatch', false],
['takeoverMinutes', 15], ['takeoverMinutes', 60], ['landingBatchSize', 1], ['landingBatchSize', 8],
['landingCadenceMinutes', 5], ['landingCadenceMinutes', 30]];
let sequence = appliedSequence(board);