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(needs): block audience comes from a code table [C6,N26]

Corey Olsondc23d5faa8bd
diff --git a/src/next-steps.js b/src/next-steps.js
index 6877369f..0bf5ec51 100644
--- a/src/next-steps.js
+++ b/src/next-steps.js
@@ -651,26 +651,47 @@ export function nextStepFor(error, message, options = {}) {
const NOT_BLOCKS = new Set(['USAGE', 'UNKNOWN_COMMAND']);
/**
- * Who can take a refusal's step: the person (a person-only move), the coordinator (a step that
- * asks the coordinator), or the agent that ran the command. Read from the code and the same step
- * this catalog gives, so the audience never disagrees with the step shown [P4].
+ * Who clears each refusal that is not the blocked agent's own to clear, by code, beside the steps
+ * above: the person (a person-only move) or the coordinator. Every other code is the agent's.
+ * test/blocks.test.js sends every person code here through to Needs you [C6,B26].
+ *
+ * @type {Readonly<Record<string, 'person'|'coordinator'|'either'>>}
+ */
+export const BLOCK_AUDIENCE = Object.freeze({
+ AGENT_APPROVAL_REQUIRED: 'person',
+ B26_PERSON_APPROVAL: 'person',
+ B26_PERSON_CHANNEL: 'person',
+ CHECK_ACCEPT_PERSON_ONLY: 'person',
+ HUMAN_REQUIRED: 'person',
+ LAND_PERSON_ONLY: 'person',
+ NOT_APPROVER: 'person',
+ PHONE_APPROVAL_PENDING: 'person',
+ RELAY_PERSON_ONLY: 'person',
+ RIGOR_PERSON_ONLY: 'person',
+ B26_PERSON_ANSWER: 'coordinator',
+ B26_PERSON_DECISION: 'coordinator',
+ COORDINATOR_CHECK: 'coordinator',
+ COORDINATOR_ONLY: 'coordinator',
+ COORDINATOR_VERIFIES: 'coordinator',
+ JOB_CADENCE_COORDINATOR_ONLY: 'coordinator',
+ SPEC_APPROVAL_BASELINE: 'coordinator',
+ TOKEN_REVOKED: 'coordinator',
+ // One code, two holders: the coordinator's own token is reissued by the person, a seat's by the coordinator.
+ TOKEN_EXPIRED: 'either',
+});
+
+/**
+ * Who can take a refusal's step, from its code alone. Only a code that serves both audiences
+ * reads its message, and only to tell which of the two raised it.
*
* @param {string} code
* @param {string} message
- * @param {string} step
* @returns {'person'|'coordinator'|'agent'}
*/
-export function blockAudience(code, message, step) {
- const person = /\blet the person act\b|\bbring it to the person\b|\bthe person (?:reissues|runs|sends|approves)\b|\bfrom the paired phone\b|\bthe person['’]s terminal\b/iu;
- const coordinator = /\bask (?:the|your) coordinator\b|^the coordinator\b/iu;
- if (/_PERSON_ONLY$|^B26_PERSON_CHANNEL$|^HUMAN_REQUIRED$/u.test(code)) return 'person';
- // The raise site's own words name who acts before the catalog's general step does: an expired
- // coordinator token says the person reissues it, while a seat's says to ask the coordinator.
- if (person.test(message)) return 'person';
- if (coordinator.test(message) || /(?:^|_)COORDINATOR_ONLY$/u.test(code)) return 'coordinator';
- if (person.test(step)) return 'person';
- if (/^(?:ask (?:the|your) coordinator|the coordinator)\b/iu.test(step)) return 'coordinator';
- return 'agent';
+export function blockAudience(code, message) {
+ const audience = BLOCK_AUDIENCE[code] ?? 'agent';
+ if (audience !== 'either') return audience;
+ return /\bthe coordinator relay token\b/iu.test(message) ? 'person' : 'coordinator';
}
/** Plain words: no bracketed rule code, no backticks, one line [P4]. */
@@ -693,7 +714,7 @@ export function blockNotice(error, { command, by, path, at, caller }) {
const first = plain(message);
const cut = first.indexOf(step.slice(0, 24));
const reason = (cut > 0 ? first.slice(0, cut) : first).replace(/[\s;:,.]+$/u, '') || first;
- const audience = blockAudience(code, message, step);
+ const audience = blockAudience(code, message);
// The person never needs to know how the relay works: a relay token is their sign-in [C6].
const said = audience === 'person' ? reason.replace(/\b(?:the )?coordinator relay token\b/giu, 'your sign-in for the coordinator').replace(/\brelay token\b/giu, 'sign-in') : reason;
return { at: at.toISOString(), code, command: `pullboard ${command}`.trim(), by, path, audience, reason: said, step };
diff --git a/test/blocks.test.js b/test/blocks.test.js
index b37f6680..afb004cc 100644
--- a/test/blocks.test.js
+++ b/test/blocks.test.js
@@ -5,6 +5,8 @@ import { serveApi } from '../src/api.js';
import { repoInfo } from '../src/git.js';
import { personNeedsState } from '../src/needs-state.js';
import {
+ BLOCK_AUDIENCE,
+ NEXT_STEPS,
blockAudience,
reportBlock,
} from '../src/next-steps.js';
@@ -55,9 +57,8 @@ test('a Pullboard block reaches whoever can clear it and repeats are counted [C6
assert.equal(raise(new Refused('TOKEN_EXPIRED', 'the coordinator relay token expired; the person reissues it: run pullboard relay on in the main checkout'), 'shout').audience, 'person');
assert.equal(raise(new Refused('TOKEN_EXPIRED', 'the relay token of web-1 expired, and only a seat\'s own current token or its creator renews it; ask the coordinator for a fresh worktree: pullboard worktree <lane> --model "<model name>"'), 'claim').audience, 'coordinator');
assert.equal(said.filter(line => /only the person can clear this/u.test(line)).length, 2);
- // A step the agent takes stays the agent's even when it mentions the person as an alternative.
- assert.equal(blockAudience('RATCHET_ROSE', 'C9 rose to 54, was 53; fix the new problems, commit, and submit again; only the person can sign an increased count',
- 'fix the new doctrine problems named in the report, commit, and submit again; only the person can sign an increased count'), 'agent');
+ // A refusal outside the table stays the agent's, whatever its wording says about the person.
+ assert.equal(blockAudience('RATCHET_ROSE', 'C9 rose to 54, was 53; fix the new problems, commit, and submit again; only the person can sign an increased count'), 'agent');
const personRows = personNeedsState(box.repo).needs.filter(row => row.kind === 'block');
assert.deepEqual(personRows.map(row => row.text).sort(), [
'Pullboard stopped a request that only you can clear: send this person action from the paired phone',
@@ -105,4 +106,19 @@ test('a Pullboard block reaches whoever can clear it and repeats are counted [C6
const added = box.run(box.repo, 'add', draft.lane, draft.title, '--brief', draft.brief, '--json');
assert.equal(added.code, 0, added.err);
assert.equal(JSON.parse(added.out).item.item_title, draft.title);
+
+ // Every person-only code in the catalog lands in Needs you, B26_PERSON_APPROVAL with its real words.
+ const personCodes = Object.keys(BLOCK_AUDIENCE).filter(code => BLOCK_AUDIENCE[code] === 'person');
+ assert.ok(personCodes.includes('B26_PERSON_APPROVAL'));
+ for (const code of Object.keys(NEXT_STEPS).filter(code => /PERSON_ONLY$/u.test(code))) assert.equal(BLOCK_AUDIENCE[code], 'person', code);
+ for (const code of personCodes) {
+ assert.ok(NEXT_STEPS[code], `${code} has a step in the catalog`);
+ const words = code === 'B26_PERSON_APPROVAL'
+ ? 'only the person from the main checkout approves or declines a spec row; use pullboard view for the person to decide'
+ : `the ${code.toLowerCase().replaceAll('_', ' ')} rule stops this`;
+ assert.equal(raise(new Refused(code, words), `sweep ${code.toLowerCase()}`).audience, 'person', code);
+ }
+ const swept = new Set(personNeedsState(box.repo).needs.filter(row => row.kind === 'block' && row.id.includes(' pullboard sweep ')).map(row => row.id.split(' ')[0].slice('block:'.length)));
+ assert.deepEqual([...swept].sort(), [...personCodes].sort());
+ assert.ok((await apiNeeds(api, box.repo)).needs.some(row => row.id.startsWith('block:B26_PERSON_APPROVAL ')));
});