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(api): a sent-back summary keeps its note's first line [A2,N26]

Corey Olson3c7e947b1888
diff --git a/docs/api.md b/docs/api.md
index 1354fa94..57eca2ba 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -209,7 +209,7 @@ The server checks any Origin against its own address and grants no CORS permissi
The boards response keeps `boards` and may include `warnings` for registered entries that could not be opened. State `seen` must be a nonnegative safe integer; omitting it retains the `unseen: null` result. State continues to include only the newest 40 shouts. Use `GET /api/v1/boards/:board/shouts/:id` to resolve an older address; its `{ shout }` result contains the complete stored shout row, including sender, recipient, text, timestamp, decision flag and reply relationship. Decision shouts also include `decision_state` (`open` or `answered`) and `decision_answer` (the reply row or `null`); other shouts use `null` for both fields. A missing id returns `NO_SHOUT` with HTTP 404; malformed ids are refused with HTTP 400. Code previews read only a registered repo's committed tree, use a plain commit SHA and at most 60 lines, and never read the working tree. The shared router lets adapters omit the optional code capability; such adapters return the versioned `CODE_NOT_AVAILABLE` refusal.
-The state from `pullboard serve` lists every item as a summary of what the lists and the roadmap read: `id`, `title`, `lane`, `status`, `route`, `milestone`, `specs`, `claim`, `builtBy`, `blockedBy`, `updatedAt`, `stage`, `since`, `counts` and `verdict`. `milestone` names the first roadmap milestone that lists the item, or is `null`. `claim` is the live lease on the item, `{by, until}`: its builder's while it is claimed, or its reviewer's while a submitted item is reserved for review; otherwise it is `null`. `stage` is the item's status, except `accepted` for a verified item and `merged` once a merge is recorded. `since` is when the item entered that stage: edits, review reservations and renewals do not restart it, and a lapsed claim's stage starts at its recorded lease deadline. `counts` has the item's number of `verdicts` and `facts`. `verdict` keeps only the latest verdict's `decision` and `reason`, or is `null`. The state also has `moveCounts`, the board's lifecycle moves keyed `from>to:verb`, as the view's lifecycle drawing counts them.
+The state from `pullboard serve` lists every item as a summary of what the lists and the roadmap read: `id`, `title`, `lane`, `status`, `route`, `milestone`, `specs`, `claim`, `builtBy`, `blockedBy`, `updatedAt`, `stage`, `since`, `counts` and `verdict`. `milestone` names the first roadmap milestone that lists the item, or is `null`. `claim` is the live lease on the item, `{by, until}`: its builder's while it is claimed, or its reviewer's while a submitted item is reserved for review; otherwise it is `null`. `stage` is the item's status, except `accepted` for a verified item and `merged` once a merge is recorded. `since` is when the item entered that stage: edits, review reservations and renewals do not restart it, and a lapsed claim's stage starts at its recorded lease deadline. `counts` has the item's number of `verdicts` and `facts`. `verdict` keeps only the latest verdict's `decision` and `reason`, or is `null`; for an item sent back and not verified, it also keeps `note`, the first nonblank line of that reject's note. The state also has `moveCounts`, the board's lifecycle moves keyed `from>to:verb`, as the view's lifecycle drawing counts them.
`GET /api/v1/boards/:board/items/:id` returns `{item}`: the item's `id` and every field its summary leaves out, which are `owner`, `reviewer`, `reviewUntil`, `verifiedBy`, `criterion`, `brief`, `commit`, `merged`, `history`, `check`, `checkBaseline` when recorded, `verdicts`, `thread`, and the latest `verdict` in full. Laid over its summary, the detail is the item exactly as the full state carries it. An unknown id returns `NO_ITEM` with HTTP 404; a malformed id is refused with HTTP 400. `state?detail=full` returns every item in full, summary fields included, and `detail=summary` returns summaries; any other value is refused with `BAD_REQUEST`. Without `detail`, a server answers with its own default, `stateDetail: "summary"` or `"full"`: `serveApi`, which `pullboard serve` runs, defaults to summaries, and `createLocalApiHandler`, which a page's own server builds, defaults to full items until that page reads summaries. `GET /api/v1/boards/:board/items?q=text` returns `{ids}`, in state order, for the items whose `#id`, title, lane, spec ids or criterion contain the trimmed text, ignoring case, as the view's search matches; empty text matches every item. An adapter without these reads, such as the relay, whose state carries every item in full, returns `ITEM_NOT_AVAILABLE`.
diff --git a/src/api.js b/src/api.js
index 1a311490..4406655d 100644
--- a/src/api.js
+++ b/src/api.js
@@ -187,10 +187,15 @@ function withListFields(state, leases) {
return { ...state, items, moveCounts };
}
-/** Keep the summary fields; the latest verdict keeps only its decision and reason. */
+/**
+ * Keep the summary fields. The latest verdict keeps its decision and reason, and, for an item sent
+ * back and not verified, the first line of its note, which the Items list shows beside the reason.
+ */
function itemSummary(item) {
const summary = Object.fromEntries(SUMMARY_FIELDS.map((key) => [key, item[key]]));
- summary.verdict = item.verdict && { decision: item.verdict.decision, reason: item.verdict.reason };
+ const sentBack = item.verdict?.decision === 'REJECT' && item.status !== 'verified';
+ summary.verdict = item.verdict && { decision: item.verdict.decision, reason: item.verdict.reason,
+ ...(sentBack ? { note: String(item.verdict.note ?? '').split('\n').map((line) => line.trim()).find(Boolean) ?? '' } : {}) };
return summary;
}
diff --git a/test/api-http.test.js b/test/api-http.test.js
index f3f600ec..917f6248 100644
--- a/test/api-http.test.js
+++ b/test/api-http.test.js
@@ -357,6 +357,43 @@ test("[A2, N26] the board state sends summaries and an item's detail comes from
assert.deepEqual((await pageSummary.json()).state.items, summaryState.document.state.items, 'and sends summaries when asked');
});
+test("[A2, N26] a sent-back item's summary carries its reject note's first line", async (t) => {
+ const box = await httpBox(t);
+ const builder = box.cli(box.root, 'worktree', 'app', '--model', 'fixture-builder');
+ const verifier = box.cli(box.root, 'worktree', 'app', '--model', 'fixture-verifier');
+ /** Make one real board move through HTTP and return its result. */
+ async function move(body) {
+ const moved = await box.call(box.path + '/moves', body);
+ assert.equal(moved.status, 200, JSON.stringify(moved.document));
+ return moved.document.result;
+ }
+ /** Build an item to submission and reserve its review for the verifier. */
+ async function submitted(title) {
+ const id = (await move({ verb: 'add', args: { lane: 'app', title, criterion: 'shows a greeting', specs: 'G1' } })).item.item_id;
+ await move({ verb: 'claim', item: id, agent: builder.agent });
+ await move({ verb: 'submit', item: id, agent: builder.agent });
+ await move({ verb: 'next', agent: verifier.agent, args: { verify: true } });
+ return id;
+ }
+ const note = 'The page shows no greeting.\nThe second line stays in the detail.';
+ const rejected = await submitted('Rejected item');
+ await move({ verb: 'verify', item: rejected, agent: verifier.agent, args: { decision: 'reject', reason: 'BEHAVIOR_MISMATCH', note } });
+ const accepted = await submitted('Accepted item');
+ await move({ verb: 'verify', item: accepted, agent: verifier.agent, args: { decision: 'accept', reason: 'CRITERION_MET', note: 'The page greets by name.\nChecked twice.' } });
+
+ const summaries = new Map((await box.call(box.path + '/state')).document.state.items.map((item) => [item.id, item]));
+ assert.deepEqual(summaries.get(rejected).verdict, { decision: 'REJECT', reason: 'BEHAVIOR_MISMATCH', note: 'The page shows no greeting.' },
+ 'a sent-back row keeps its reason and the first line of the note');
+ assert.deepEqual(summaries.get(accepted).verdict, { decision: 'ACCEPT', reason: 'CRITERION_MET' }, 'an accepted item carries no note');
+ assert.equal((await box.call(box.path + '/items/' + rejected)).document.item.verdict.note, note, 'the whole note stays in the detail');
+
+ await move({ verb: 'claim', item: rejected, agent: builder.agent });
+ const reworked = (await box.call(box.path + '/state')).document.state.items.find((item) => item.id === rejected);
+ assert.equal(reworked.verdict.note, 'The page shows no greeting.', 'a row being reworked still says why');
+ const full = (await box.call(box.path + '/state?detail=full')).document.state.items.find((item) => item.id === rejected);
+ assert.deepEqual({ ...reworked, ...(await box.call(box.path + '/items/' + rejected)).document.item }, full, 'the detail still completes the summary');
+});
+
test('[A2, N26] local milestone item status refreshes after an item event', async (t) => {
let builds = 0;
const box = await httpBox(t, { onStateBuild: () => { builds += 1; } });