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(why): bind origin and landed history [N29,H16,B29,P6,A1]

Corey Olson21b4148e1558
diff --git a/docs/api.md b/docs/api.md
index 34edf335..6507d62b 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -123,6 +123,7 @@ For example: `flow: review wait average 61 min (1 measured; > 60 min); bottlenec
| `edit` | `version:number`, `item:object` |
| `fact` | `version:number`, `item:number`, `fact:object` |
| `why` | `version:number`, `id:number`, `decisions:array` |
+| `why file` | `version:number`, `file:string`, `line:number|null`, `items:array`, `rows:array`, `decisions:array` |
| `escalate` | `version:number`, `id:number`, `from:string`, `to:string` |
| `run` | `version:number`, `messages:array` |
| `sweep` | `version:number`, `messages:array` |
@@ -673,3 +674,5 @@ When `publish.pullRequest` is enabled, `pullboard publish` reconciles the GitHub
A board-recorded item merge covers its introduced commits only when its exact submitted commit has that receipt and is an ancestor of the recorded merge. `Pullboard-Companion: #N` is covered only on a board-recorded trunk containing item N's landing. Unreceipted commits, including release bumps and synthetic publication commits, remain unverified. An outside PR is allowed and initially reads `not verified`; the JSON result's `verification[].intake` names the existing `pullboard intake` command that files it for review. Outside intake can cover only its exact accepted head, never its earlier commits by inference.
The JSON result includes `verification` entries with PR number, exact head, state, assurance, receipt identities, and any unverified commit IDs. GitHub statuses are shared by PRs with the same head: if an outside or unproven PR shares a commit with a proven proposal, the shared status stays red rather than lending the proposal's green status to it. Publishing observes and posts statuses; it never merges a PR or requires outside authors to use Pullboard.
+
+`pullboard why <file>[:<line>] --json` uses the `why file` catalog shape; this names the file form, not a literal `file` argument. It traces commits on the repository's actual primary branch, then resolves their item trailers, served row IDs and answered decisions in one board query. The legacy `why <id>` shape is unchanged. Answered decisions carry their recorded origin, statement, rationale, decider and relayer; absent historical provenance remains `unknown`. Row and item origins are also `unknown` unless recorded, rather than inferred from a related decision. An agent may label a relayed or inherited answer but cannot use that label to mint a person-origin record. Unproven original decider identities remain unknown, with the answering relay seat recorded separately.
diff --git a/src/commands/why.js b/src/commands/why.js
index c77d07a3..e218b6bb 100644
--- a/src/commands/why.js
+++ b/src/commands/why.js
@@ -33,8 +33,8 @@ function runFile(io, ctx, target) {
io.result?.(found);
const where = found.line === null ? found.file : `${found.file}:${found.line}`;
if (!found.items.length) io.say(`no landed commit that names an item touched ${where}`);
- for (const item of found.items) io.say(`item #${item.id} (${item.status}): ${item.title}`);
- for (const row of found.rows) io.say(`row ${row.id}, served by ${row.items.map((id) => `#${id}`).join(', ')}`);
+ for (const item of found.items) io.say(`item #${item.id} (${item.status}) [${item.origin}]: ${item.title}`);
+ for (const row of found.rows) io.say(`row ${row.id} [${row.origin}], served by ${row.items.map((id) => `#${id}`).join(', ')}`);
for (const entry of found.decisions) {
const relay = entry.relayedBy ? `, relayed by ${entry.relayedBy}` : '';
io.say(`decision #${entry.id} [${entry.origin}] by ${entry.decidedBy}${relay}: ${entry.statement.split('\n')[0]}${entry.rationale ? ` (because ${entry.rationale})` : ''}`);
diff --git a/src/decision-origin.js b/src/decision-origin.js
index 8c0d182d..9fb10829 100644
--- a/src/decision-origin.js
+++ b/src/decision-origin.js
@@ -42,9 +42,9 @@ export function answerProvenance(board, { agentId, asPerson, text, origin, ratio
throw new Refused('BAD_ORIGIN', `an origin is ${NAMEABLE_ORIGINS.join(', ')}, not "${origin}"; only a real person answer is the person's origin: pullboard answer <id> <text> --origin person-relayed`);
}
if (asPerson && named) throw new Refused('BAD_ORIGIN', 'a person answer is its own origin; leave out --origin');
- const decidedBy = asPerson ? 'person' : agentId;
const chosen = asPerson ? 'person' : (origin ?? 'agent');
- return { statement: String(text).trim(), rationale: reason, decidedBy, relayedBy: chosen === 'person-relayed' ? agentId : null, origin: chosen };
+ const decidedBy = asPerson ? 'person' : chosen === 'agent' ? agentId : 'unknown';
+ return { statement: String(text).trim(), rationale: reason, decidedBy, relayedBy: ['person-relayed', 'inherited'].includes(chosen) ? agentId : null, origin: chosen };
}
/**
@@ -57,31 +57,3 @@ export function originOf(detail) {
const origin = detail?.provenance?.origin;
return typeof origin === 'string' && origin ? origin : 'unknown';
}
-
-/**
- * The answered decisions behind some items: answers that imply an item, or were addressed to it.
- *
- * @param {any} board
- * @param {number[]} itemIds
- * @returns {{ id: number, items: number[], statement: string, rationale: string, decidedBy: string, relayedBy: string | null, origin: string, at: string }[]}
- */
-export function decisionsBehind(board, itemIds) {
- if (!itemIds.length) return [];
- const marks = itemIds.map(() => '?').join(',');
- const byShout = new Map();
- const note = (shout, item) => byShout.set(shout, [...new Set([...(byShout.get(shout) ?? []), item])].sort((a, b) => a - b));
- for (const row of board.db.prepare(`SELECT item_id, event_detail FROM event WHERE event_kind = 'fact' AND item_id IN (${marks}) AND json_extract(event_detail, '$.decision.source') = 'answer' AND json_extract(event_detail, '$.supersededBy') IS NULL`).all(...itemIds)) {
- note(JSON.parse(row.event_detail).decision.id, row.item_id);
- }
- for (const row of board.db.prepare(`SELECT item_id, event_detail FROM event WHERE event_kind = 'answer' AND item_id IN (${marks})`).all(...itemIds)) {
- note(JSON.parse(row.event_detail).shout, row.item_id);
- }
- return [...byShout].sort(([left], [right]) => left - right).map(([id, items]) => {
- const shout = board.db.prepare('SELECT shout_from, shout_text, shout_at FROM shout WHERE shout_id = ?').get(id);
- const event = board.db.prepare("SELECT event_detail FROM event WHERE event_kind = 'answer' AND json_extract(event_detail, '$.shout') = ?").get(id);
- const recorded = event ? JSON.parse(event.event_detail).provenance : undefined;
- return { id, items, statement: recorded?.statement ?? shout.shout_text, rationale: recorded?.rationale ?? '',
- decidedBy: recorded?.decidedBy ?? shout.shout_from, relayedBy: recorded?.relayedBy ?? null,
- origin: originOf({ provenance: recorded }), at: shout.shout_at };
- });
-}
diff --git a/src/json.js b/src/json.js
index 046272e0..aaa2227f 100644
--- a/src/json.js
+++ b/src/json.js
@@ -67,6 +67,7 @@ export const JSON_SHAPES = {
edit: shape({ item: 'object' }),
fact: shape({ item: 'number', fact: 'object' }),
why: shape({ id: 'number', decisions: 'array' }),
+ 'why file': shape({ file: 'string', line: 'number|null', items: 'array', rows: 'array', decisions: 'array' }),
escalate: shape({ id: 'number', from: 'string', to: 'string' }),
run: shape({ messages: 'array' }),
sweep: shape({ messages: 'array' }),
diff --git a/src/moves/answerDecision.js b/src/moves/answerDecision.js
index fa135a85..3a7fb0e7 100644
--- a/src/moves/answerDecision.js
+++ b/src/moves/answerDecision.js
@@ -8,15 +8,19 @@ import { carriesImplies } from '../move-implies.js';
import { BOARD_SENTINEL_ENGINE } from '../sentinel-engine.js';
/** Preserve this operation's historical first-matching engine conditions [H16]. */
-function minimumEngine(args, board, at) {
+function historicalMinimumEngine(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 (carriesImplies('answerDecision', args)) return IMPLIES_ENGINE;
- if (carriesOrigin(args)) return DECISION_ORIGIN_ENGINE;
return 1;
}
+/** New provenance composes with every older option; clause-free recorded moves keep their selection [H16]. */
+function minimumEngine(args, board, at) {
+ return Math.max(historicalMinimumEngine(args, board, at), carriesOrigin(args) ? DECISION_ORIGIN_ENGINE : 1);
+}
+
/** Read precisely the actor argument used by this operation [H2,H16]. */
function actor(move) { return move.args[1]?.agentId ?? null; }
diff --git a/src/why-file.js b/src/why-file.js
index ceafb7ca..aeb63b50 100644
--- a/src/why-file.js
+++ b/src/why-file.js
@@ -5,8 +5,9 @@
* serve and the answered decisions that imply them. One query over Git history and the board.
*/
import { tryGit } from './git.js';
+import { mainCheckout } from './git.js';
import { Refused } from './refused.js';
-import { decisionsBehind } from './decision-origin.js';
+import { originOf } from './decision-origin.js';
/**
* Split `path` or `path:line` into the file and an optional line.
@@ -27,8 +28,10 @@ export function parseFileTarget(target) {
* @returns {number[]}
*/
export function itemsTouching(root, { file, line }) {
- const range = line === null ? ['--', file] : [`-L${line},${line}:${file}`, '-s'];
- const log = tryGit(root, ['log', '--reverse', '--format=%x01%B', ...range]);
+ const trunk = mainCheckout(root);
+ if (!trunk?.commit) return [];
+ const range = line === null ? ['--', `:(literal)${file}`] : [`-L${line},${line}:${file}`, '-s'];
+ const log = tryGit(root, ['log', '--first-parent', '--diff-merges=first-parent', '--reverse', '--format=%x01%B', trunk.commit, ...range]);
if (log.status !== 0) {
if (line !== null && /no such path|file .* has only|there is no path/iu.test(log.stderr)) return [];
if (/does not have any commits|unknown revision|bad revision|ambiguous argument/iu.test(log.stderr)) return [];
@@ -52,9 +55,47 @@ export function itemsTouching(root, { file, line }) {
export function whyFile(board, root, target) {
const parsed = parseFileTarget(target);
const ids = itemsTouching(root, parsed);
- const found = ids.map((id) => board.db.prepare('SELECT item_id, item_title, item_status, item_spec_ids FROM item WHERE item_id = ?').get(id)).filter(Boolean);
- const items = found.map((item) => ({ id: item.item_id, title: item.item_title, status: item.item_status }));
- const rows = [...new Set(found.flatMap((item) => item.item_spec_ids.split(',').filter(Boolean)))]
- .map((id) => ({ id, items: found.filter((item) => item.item_spec_ids.split(',').includes(id)).map((item) => item.item_id) }));
- return { file: parsed.file, line: parsed.line, items, rows, decisions: decisionsBehind(board, items.map((item) => item.id)) };
+ const found = board.db.prepare(`
+ WITH selected AS (
+ SELECT item.* FROM item JOIN json_each(?) requested ON item.item_id = requested.value
+ ), links AS (
+ SELECT event.item_id, json_extract(event_detail, '$.decision.id') AS answer
+ FROM event JOIN selected ON selected.item_id = event.item_id
+ WHERE event_kind = 'fact' AND json_extract(event_detail, '$.decision.source') = 'answer'
+ UNION
+ SELECT event.item_id, json_extract(event_detail, '$.shout') AS answer
+ FROM event JOIN selected ON selected.item_id = event.item_id WHERE event_kind = 'answer'
+ )
+ SELECT selected.item_id, item_title, item_status, item_spec_ids,
+ answer.shout_id, answer.shout_text, answer.shout_at, recorded.event_detail
+ FROM selected LEFT JOIN links ON links.item_id = selected.item_id
+ LEFT JOIN shout answer ON answer.shout_id = links.answer
+ LEFT JOIN event recorded ON recorded.event_kind = 'answer'
+ AND json_extract(recorded.event_detail, '$.shout') = answer.shout_id
+ ORDER BY selected.item_id, answer.shout_id`).all(JSON.stringify(ids));
+ const itemMap = new Map();
+ const rowMap = new Map();
+ const decisionMap = new Map();
+ for (const record of found) {
+ const item = record.item_id;
+ itemMap.set(item, { id: item, title: record.item_title, status: record.item_status, origin: 'unknown' });
+ for (const id of record.item_spec_ids.split(',').filter(Boolean)) {
+ if (!rowMap.has(id)) rowMap.set(id, { id, items: [], origin: 'unknown' });
+ const row = rowMap.get(id);
+ if (!row.items.includes(item)) row.items.push(item);
+ }
+ if (record.shout_id === null) continue;
+ if (!decisionMap.has(record.shout_id)) {
+ const detail = record.event_detail ? JSON.parse(record.event_detail) : {};
+ const recorded = detail.provenance;
+ decisionMap.set(record.shout_id, { id: record.shout_id, items: [],
+ statement: recorded?.statement ?? record.shout_text, rationale: recorded?.rationale ?? '',
+ decidedBy: recorded?.decidedBy ?? 'unknown', relayedBy: recorded?.relayedBy ?? null,
+ origin: originOf(detail), at: record.shout_at });
+ }
+ const decision = decisionMap.get(record.shout_id);
+ if (!decision.items.includes(item)) decision.items.push(item);
+ }
+ return { file: parsed.file, line: parsed.line, items: [...itemMap.values()], rows: [...rowMap.values()],
+ decisions: [...decisionMap.values()].sort((left, right) => left.id - right.id) };
}
diff --git a/test/api-catalog.test.js b/test/api-catalog.test.js
index b8e338bd..a4ecfd3b 100644
--- a/test/api-catalog.test.js
+++ b/test/api-catalog.test.js
@@ -347,6 +347,7 @@ catalogCase('[A1] command results match the catalog across roots and subcommands
await json(box, repo, 'fact', ['1', 'note', 'API fact']);
await json(box, repo, 'fact', ['1', 'decision', 'API decision', '--implies', '1']);
assert.equal((await json(box, repo, 'why', ['1'])).decisions[0].line, 'API decision', 'why lists the decision that implies the item [N29]');
+ assert.equal((await json(box, repo, 'why', ['SPEC.md'], 'file')).file, 'SPEC.md', 'file provenance has its own additive JSON shape [A1,N29]');
await json(box, repo, 'edit', ['1', '--criterion', 'the edited API item is verified', '--check', 'true']);
await json(box, repo, 'show', ['1']);
await json(box, repo, 'list', ['--all']);
diff --git a/test/why.test.js b/test/why.test.js
index 1444136c..805abc65 100644
--- a/test/why.test.js
+++ b/test/why.test.js
@@ -1,81 +1,59 @@
/** A decision records where it came from, and pullboard why <file> names the decisions behind a file [N29,B29,P6]. */
import assert from 'node:assert/strict';
-import { runFixtureChild, runFixtureGit } from './fixture-child.js';
-import { chmodSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
-import { tmpdir } from 'node:os';
-import { join, resolve } from 'node:path';
+import { readFileSync, writeFileSync } from 'node:fs';
+import { join } from 'node:path';
import { after, test } from 'node:test';
+import * as store from '../src/board.js';
+import { createE2eHelpers } from './e2e-helpers.js';
import { minimumMoveEngine } from '../src/move-registry.js';
import { DECISION_ORIGIN_ENGINE } from '../src/decision-origin-engine.js';
import { originOf } from '../src/decision-origin.js';
+import { whyFile } from '../src/why-file.js';
-const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
-const sandboxes = [];
-const SPEC = '# Why fixture\n\n## G · Goals\n- G1 [approved, must] The feature works. | gate: test\n';
+const e2e = createE2eHelpers();
+after(e2e.cleanup);
-after(() => {
- for (const dir of sandboxes) rmSync(dir, { recursive: true, force: true });
-});
-
-/** Make an isolated real-Git repo with a board, a coordinator, one web builder and two web items. */
+/** Real Git/SQLite items use public submit, verdict and native landing before file history is queried. */
function fixture() {
- const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-why-')));
- sandboxes.push(dir);
- const shims = join(dir, 'bin');
- mkdirSync(shims);
- writeFileSync(join(shims, 'pullboard'), `#!/bin/sh\nexec "${process.execPath}" "${BIN}" "$@"\n`, { mode: 0o755 });
- chmodSync(join(shims, 'pullboard'), 0o755);
- const env = {
- ...process.env,
- PATH: `${shims}:${process.env.PATH}`,
- GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',
- GIT_AUTHOR_NAME: 'Test Agent', GIT_AUTHOR_EMAIL: '[email protected]',
- GIT_COMMITTER_NAME: 'Test Agent', GIT_COMMITTER_EMAIL: '[email protected]',
- PULLBOARD_HOME: join(dir, 'home'), PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),
- };
- for (const name of Object.keys(env)) if (name.startsWith('GIT_') && !name.startsWith('GIT_CONFIG') && !name.startsWith('GIT_AUTHOR') && !name.startsWith('GIT_COMMITTER')) delete env[name];
- delete env.PULLBOARD_RELAY_TOKEN;
- const repo = join(dir, 'repo');
- mkdirSync(repo);
- /** Run Git in this private fixture with its isolated identity. */
- const git = (cwd, ...args) => runFixtureGit(args, { cwd, env });
- /** Run the actual CLI in a fixture checkout and keep both output streams. */
- const run = (cwd, ...args) => {
- const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });
- return { code: result.status, out: result.stdout ?? '', err: result.failure ?? result.stderr ?? '' };
- };
- /** Run a command that must succeed with --json and return its one document. */
- const json = (cwd, ...args) => {
- const result = run(cwd, ...args, '--json');
+ const box = e2e.project('true');
+ const config = JSON.parse(readFileSync(join(box.repo, 'pullboard.json'), 'utf8'));
+ config.landing = { publish: 'separate' };
+ writeFileSync(join(box.repo, 'pullboard.json'), JSON.stringify(config, null, 2));
+ const seed = e2e.commitFile(box, box.repo, 'web/shared.txt', 'one\ntwo\nthree\n', 'chore: configure private why landing');
+ assert.equal(seed.status, 0, seed.stderr);
+ const other = e2e.commitFile(box, box.repo, 'web/other.txt', 'other\n', 'chore: seed other why history');
+ assert.equal(other.status, 0, other.stderr);
+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');
+ /** Return one public JSON result only after its native command succeeds. */
+ function json(cwd, ...args) {
+ const result = box.run(cwd, ...args, '--json');
assert.equal(result.code, 0, `${args.join(' ')}: ${result.err}${result.out}`);
return JSON.parse(result.out);
- };
- git(repo, 'init', '-q', '-b', 'main');
- assert.equal(run(repo, 'init').code, 0);
- writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({
- gate: 'true', spec: 'SPEC.md', verify: 'any', lease: '2h',
- lanes: { web: { owns: ['web/'], specs: ['G1'] } },
- }, null, 2));
- writeFileSync(join(repo, 'SPEC.md'), SPEC);
- mkdirSync(join(repo, 'web'));
- writeFileSync(join(repo, 'web', 'shared.txt'), 'one\ntwo\nthree\n');
- writeFileSync(join(repo, 'web', 'other.txt'), 'other\n');
- git(repo, 'add', '-A');
- git(repo, 'commit', '-q', '-m', 'chore: create why fixture');
- for (const title of ['First item', 'Second item']) {
- json(repo, 'add', 'web', title, '--specs', 'G1', '--criterion', `${title} works`, '--check', 'true');
}
- return { git, repo, run, json };
+ for (const [index, title] of ['First item', 'Second item'].entries()) {
+ json(box.repo, 'add', 'web', title, '--specs', 'G1', '--criterion', `${title} exists`,
+ '--check', `test -f web/built-${index + 1}`);
+ }
+ /** Land an actual submitted item, preserving its item trailer and durable merge receipt. */
+ function landItem(id, file, text) {
+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');
+ json(box.web, 'claim', String(id));
+ const result = e2e.commitFile(box, box.web, file, text, `feat(web): build why item ${id} [G1]`);
+ assert.equal(result.status, 0, result.stderr);
+ const flag = e2e.commitFile(box, box.web, `web/built-${id}`, 'built\n', `feat(web): complete why item ${id} [G1]`);
+ assert.equal(flag.status, 0, flag.stderr);
+ const submitted = json(box.web, 'submit', String(id));
+ box.git(box.repo, 'switch', '-q', '--detach', submitted.commit);
+ try { json(box.repo, 'verify', String(id), 'accept', '--as', 'coordinator', '--note', 'The committed result exists.'); }
+ finally { box.git(box.repo, 'switch', '-q', 'main'); }
+ assert.deepEqual(json(box.repo, 'land').landed, [id]);
+ }
+ return { ...box, json, landItem };
}
test('a decision records its origin and pullboard why names the decisions behind a file [N29,B29,P6]', () => {
const box = fixture();
- const web = box.json(box.repo, 'worktree', 'web', '--route', 'strong', '--model', 'fixture-model').path;
-
- writeFileSync(join(box.repo, 'web', 'shared.txt'), 'one\nTWO\nthree\n');
- box.git(box.repo, 'commit', '-q', '-am', 'feat(web): change line two [G1]\n\nPullboard-Item: #1');
- writeFileSync(join(box.repo, 'web', 'other.txt'), 'other, changed\n');
- box.git(box.repo, 'commit', '-q', '-am', 'feat(web): change the other file [G1]\n\nPullboard-Item: #2');
+ const web = box.web;
const ask = box.json(web, 'shout', 'coordinator', 'Keep line two upper case?', '--decision').id;
const answer = box.json(box.repo, 'answer', String(ask), 'Keep it upper case', '--implies', '1',
@@ -83,11 +61,20 @@ test('a decision records its origin and pullboard why names the decisions behind
const askOther = box.json(web, 'shout', 'coordinator', 'Change the other file?', '--decision').id;
const answerOther = box.json(box.repo, 'answer', String(askOther), 'Change it', '--implies', '2').id;
+ const inheritedAsk = box.json(web, 'shout', 'coordinator', 'Keep the inherited convention?', '--decision').id;
+ const inherited = box.json(box.repo, 'answer', String(inheritedAsk), 'Keep the convention', '--implies', '2',
+ '--origin', 'inherited', '--rationale', 'the earlier design supplies no named decider').id;
+ const personAsk = box.json(web, 'shout', 'person', 'Approve the other change?', '--decision').id;
+ const person = box.json(box.repo, 'answer', String(personAsk), 'I approve this change', '--as', 'person', '--implies', '2').id;
+
const third = box.json(web, 'shout', 'coordinator', 'One more?', '--decision').id;
const forged = box.run(box.repo, 'answer', String(third), 'x', '--origin', 'person');
assert.notEqual(forged.code, 0, 'an agent cannot name the person as the origin');
assert.match(forged.err, /BAD_ORIGIN/u);
+ box.landItem(1, 'web/shared.txt', 'one\nTWO\nthree\n');
+ box.landItem(2, 'web/other.txt', 'other, changed\n');
+
const file = box.json(box.repo, 'why', 'web/shared.txt');
assert.equal(file.file, 'web/shared.txt');
assert.deepEqual(file.items.map((item) => item.id), [1], 'only the item whose landed commit touched the file');
@@ -96,7 +83,7 @@ test('a decision records its origin and pullboard why names the decisions behind
assert.deepEqual({ id: file.decisions[0].id, statement: file.decisions[0].statement, rationale: file.decisions[0].rationale,
decidedBy: file.decisions[0].decidedBy, relayedBy: file.decisions[0].relayedBy, origin: file.decisions[0].origin },
{ id: answer, statement: 'Keep it upper case', rationale: 'the person wants it to read as a heading',
- decidedBy: 'coordinator', relayedBy: 'coordinator', origin: 'person-relayed' });
+ decidedBy: 'unknown', relayedBy: 'coordinator', origin: 'person-relayed' });
const text = box.run(box.repo, 'why', 'web/shared.txt');
assert.equal(text.code, 0, text.err);
@@ -106,11 +93,30 @@ test('a decision records its origin and pullboard why names the decisions behind
assert.deepEqual(box.json(box.repo, 'why', 'web/shared.txt:2').items.map((item) => item.id), [1], 'the changed line');
assert.deepEqual(box.json(box.repo, 'why', 'web/shared.txt:1').items, [], 'a line no landed commit touched');
const other = box.json(box.repo, 'why', 'web/other.txt');
- assert.deepEqual(other.decisions.map((entry) => [entry.id, entry.origin]), [[answerOther, 'agent']], 'an answer that names no origin is an agent decision');
+ assert.deepEqual(other.decisions.map((entry) => [entry.id, entry.origin, entry.decidedBy]),
+ [[answerOther, 'agent', 'coordinator'], [inherited, 'inherited', 'unknown'], [person, 'person', 'person']],
+ 'actual person answers and agent answers retain their authority; an inherited decider stays unknown');
+
+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));
+ try {
+ let queries = 0;
+ const db = { prepare(sql) { queries += 1; return board.db.prepare(sql); } };
+ assert.deepEqual(whyFile({ ...board, db }, box.repo, 'web/shared.txt').items.map(item => item.id), [1]);
+ assert.equal(queries, 1, 'items, rows and answers resolve in one board query');
+ } finally { store.closeBoard(board); }
assert.equal(originOf({}), 'unknown', 'a decision with no recorded origin is unknown');
assert.equal(originOf({ provenance: { origin: 'inherited' } }), 'inherited');
assert.equal(box.json(box.repo, 'why', 'web/missing.txt').items.length, 0, 'a file no commit touched has nothing behind it');
+ const pending = box.json(box.repo, 'add', 'web', 'Not landed', '--specs', 'G1', '--criterion', 'Pending exists', '--check', 'test -f web/not-landed').id;
+ box.git(web, 'merge', '-q', '--ff-only', 'main');
+ box.json(web, 'claim', String(pending));
+ const unlanded = e2e.commitFile(box, web, 'web/shared.txt', 'one\nUNLANDED\nthree\n',
+ `feat(web): pending change [G1]\n\nPullboard-Item: #${pending}`);
+ assert.equal(unlanded.status, 0, unlanded.stderr);
+ assert.deepEqual(box.json(web, 'why', 'web/shared.txt').items.map(item => item.id), [1],
+ 'a builder checkout cannot present its unlanded history as the primary branch');
+
});