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(spec): draft requirements in the requested section [S1,C7]

Corey Olsona4acc8ea84bf
diff --git a/src/cli.js b/src/cli.js
index 1ec82219..c695a4b3 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -176,7 +176,7 @@ function commandHelp(name) {
' pullboard spec view — agent or person: write the offline spec page',
' pullboard spec show <id> — agent or person: inspect one row and its sign-offs',
' pullboard spec unmet — agent or person: list approved rows without current sign-off',
- ' pullboard spec draft <text> [--aim] [--gate "<gate>"] — any agent: append a draft row; never approve it',
+ ' pullboard spec draft <text> [--section <letter>] [--aim] [--gate "<gate>"] — any agent: append a draft row; never approve it',
' pullboard spec signoff <ids> — person: sign rows with evidence',
' pullboard spec signers add — person: register an SSH signing key',
' pullboard spec approve <ids> — person: decide from their own terminal or Pullboard View',
@@ -241,6 +241,7 @@ const OPTIONS = {
text: { type: 'string' },
gate: { type: 'string' },
aim: { type: 'boolean' },
+ section: { type: 'string' },
route: { type: 'string' },
family: { type: 'string' },
model: { type: 'string' },
@@ -2795,7 +2796,7 @@ async function specCommand(io, { first, second, rest, values }) {
unmet: ['must'],
signoff: ['by', 'note', 'note-file'],
signers: ['key', 'by'],
- draft: ['aim', 'gate'],
+ draft: ['aim', 'gate', 'section'],
approve: ['by', 'text'],
decline: ['reason'],
apply: [],
@@ -2819,10 +2820,15 @@ async function specCommand(io, { first, second, rest, values }) {
if (values.gate !== undefined && (!values.gate.trim() || /[\r\n|]/u.test(values.gate))) {
throw new Refused('USAGE', 'give one nonempty, single-line gate without a field separator, or omit --gate to use review');
}
- const section = spec.sections[0];
- if (!section) throw new Refused('NO_SECTION', `no section in ${ctx.config.spec}; add a section heading, then draft the requirement`);
- const prefix = /^([A-Z][A-Z0-9]*)\s*[·.:-]/u.exec(section.name)?.[1];
- if (!prefix) throw new Refused('SPEC_SECTION', `the first section "${section.name}" needs an id prefix such as G · Goals before drafting`);
+ if (!spec.sections.length) throw new Refused('NO_SECTION', `no section in ${ctx.config.spec}; add a section heading, then draft the requirement`);
+ const sections = spec.sections.map(section => ({ ...section,
+ prefix: /^([A-Z][A-Z0-9]*)\s*[·.:-]/u.exec(section.name)?.[1] })).filter(section => section.prefix);
+ const requested = values.section ?? 'G';
+ const section = sections.find(section => section.prefix === requested);
+ if (!section) throw new Refused('SPEC_SECTION', `unknown section "${requested}" in ${ctx.config.spec}; ${sections.length
+ ? `choose one of: ${sections.map(section => section.prefix).join(', ')}`
+ : 'add a section heading with an id prefix such as G · Goals'}`);
+ const { prefix } = section;
const numbered = spec.rows.map((row) => new RegExp(`^${prefix}(\\d+)$`, 'u').exec(row.id)?.[1]).filter(Boolean).map(Number);
let next = Math.max(0, ...numbered) + 1;
while (spec.rows.some((row) => row.id === `${prefix}${next}`)) next += 1;
diff --git a/src/help.js b/src/help.js
index 977ccd16..a55c892e 100644
--- a/src/help.js
+++ b/src/help.js
@@ -145,7 +145,8 @@ Spec
pullboard spec view [--out file] the spec, open questions, sign-offs and doctrine as one page
pullboard spec show <id> | unmet [--must] | signoff <ids> [--by <principal>]
signoff: --note "what was checked" stays with the receipt
- pullboard spec draft <text> [--aim] [--gate "<gate>"] any agent appends a draft row; never approves it
+ pullboard spec draft <text> [--section <letter>] [--aim] [--gate "<gate>"] any agent appends a draft row; never approves it
+ --section chooses the section prefix; defaults to G
Defaults to must and gate review.
pullboard spec signers add [--key <path>] [--by <principal>] opt into SSH-signed sign-offs
principal defaults to Git user.email; --by overrides it
diff --git a/test/spec.test.js b/test/spec.test.js
index 2fb546f6..53945d88 100644
--- a/test/spec.test.js
+++ b/test/spec.test.js
@@ -391,6 +391,50 @@ function specBox(t, { specName = 'SPEC.md', practiceName = 'PRACTICE.md', practi
return { root, run, command, env, git, specName, practiceName };
}
+test('spec draft files a row in the named section [S1,C7]', (t) => {
+ const specSource = `# Demo
+
+## K · Constraints
+- K1 [draft, must] Works locally. | gate: review
+
+## G · Goals
+- G1 [draft, must] The first goal. | gate: review
+- G2 [retired] An old goal.
+
+## Q · Questions
+- Q4 [pending, aim] A question. | gate: review
+`;
+ const box = specBox(t, { specSource });
+ const rows = () => parseSpec(readFileSync(join(box.root, box.specName), 'utf8')).rows;
+ const constraint = box.run('draft', 'Uses the local disk', '--section', 'K');
+ assert.equal(constraint.status, 0, constraint.stderr);
+ assert.equal(constraint.stdout.trim(), 'K2');
+ assert.equal(rows().find(row => row.id === 'K2').section, 'K · Constraints');
+
+ const goal = box.run('draft', 'A new goal');
+ assert.equal(goal.status, 0, goal.stderr);
+ assert.equal(goal.stdout.trim(), 'G3', 'G stays the default even when another section comes first');
+ assert.equal(rows().find(row => row.id === 'G3').section, 'G · Goals');
+
+ const question = box.run('draft', 'Another question', '--section', 'Q', '--aim', '--gate', 'question test', '--json');
+ assert.equal(question.status, 0, question.stderr);
+ const result = JSON.parse(question.stdout);
+ assert.equal(result.id, 'Q5');
+ assert.equal(result.row.section, 'Q · Questions');
+ assert.equal(result.row.tier, 'aim');
+ assert.equal(result.row.gate, 'question test');
+ assert.equal(rows().find(row => row.id === 'Q5').section, 'Q · Questions');
+
+ const before = readFileSync(join(box.root, box.specName), 'utf8');
+ const unknown = box.run('draft', 'Must not be written', '--section', 'Z');
+ assert.equal(unknown.status, 1);
+ assert.match(unknown.stderr, /SPEC_SECTION.*Z.*K.*G.*Q/u);
+ assert.equal(readFileSync(join(box.root, box.specName), 'utf8'), before);
+ const misplaced = box.run('check', '--section', 'K');
+ assert.equal(misplaced.status, 1);
+ assert.match(misplaced.stderr, /FLAG_NOT_ALLOWED.*section/u);
+});
+
test('a drafted row reads as draft [S1,C7]', (t) => {
const specSource = SPEC.replace(
'- G2 [retired] Old idea.',