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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(merge): integrate #129 grammar version onto main [A5]
Corey Olsona987fa8bba3c
diff --cc docs/lifecycle.mdindex 3b4206f4,63d3ccfe..118a9425--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@@ -47,11 -47,11 +47,11 @@@ Each move checks its guards in this ord| release | claimed | open | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS) || lapse | claimed | open | clock, when its lease runs out | none || submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT), gateConfigured (NO_GATE), gateGreen (GATE_RED), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |-| reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), reviewFree (REVIEW_HELD) |-| accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), proofNoted (PROOF_REQUIRED) |-| reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED) |+| reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) |+| accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), proofNoted (PROOF_REQUIRED) |+| reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED) || escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) |- | refreeze | open, claimed, submitted | open | coordinator | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC) |+ | refreeze | open, claimed, submitted | open | coordinator | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION) || withdraw | open, claimed, submitted | withdrawn | coordinator | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), inState (CLOSED) |## Exit guardsdiff --cc src/json.jsindex cbc82d1d,06a7785c..afc67cce--- a/src/json.js+++ b/src/json.js@@@ -85,12 -73,6 +85,12 @@@ function nextStep(message)return match?.[1] ?? 'Run pullboard help, correct the reported problem, and retry the command.';}+/** A refusal shared by the CLI and API, retaining its rule and repair guidance (A1, A2). */+export function refusalDocument(error) {- const message = String(error.message).replace(/^\[[A-Z_]+\] /, '');++ const message = String(error.message).replace(/^\[[A-Z][A-Z0-9_]*\] /, '');+ return { version: JSON_SHAPES.version, error: { code: error.code ?? 'INTERNAL', message, next: nextStep(message) } };+}+/*** Collect one command's output; text mode writes immediately and JSON mode writes one document.* Long-running view explicitly flushes its address before waiting for a shutdown signal.@@@ -112,9 -94,9 +112,9 @@@ export function commandOutput(argv, strlet document;if (refusal || (code && result === undefined)) {const text = refusal?.message ?? [...diagnostics, ...messages].join('\n');- const match = /\[([A-Z_]+)\]\s*([\s\S]*)/.exec(text);- const message = refusal ? text.replace(/^\[[A-Z_]+\] /, '') : match?.[2] ?? text;+ const match = /\[([A-Z][A-Z0-9_]*)\]\s*([\s\S]*)/.exec(text);+ const message = refusal ? text.replace(/^\[[A-Z][A-Z0-9_]*\] /, '') : match?.[2] ?? text;- document = { version: JSON_SHAPES.version, error: { code: refusal?.code ?? match?.[1] ?? (code === 2 ? 'USAGE' : 'COMMAND_FAILED'), message, next: nextStep(message) } };+ document = refusalDocument({ code: refusal?.code ?? match?.[1] ?? (code === 2 ? 'USAGE' : 'COMMAND_FAILED'), message });} else if (result !== undefined) {document = { version: JSON_SHAPES.version, ...result };} else {diff --cc test/spec.test.jsindex a71c6499,123fc673..fa7c9394--- a/test/spec.test.js+++ b/test/spec.test.js@@@ -52,15 -52,91 +53,100 @@@ test('rows parse with id, status, tierassert.deepEqual(lintSpec(spec), []);});+test('rows parse signer requirements and lint their names and duplicates [S18]', () => {+ const spec = parseSpec('## G\n- G1 [approved, must] Two people sign. | gate: proof | signers: [email protected], AB\n');+ assert.deepEqual(spec.rows[0].signers, ['[email protected]', 'AB']);+ assert.deepEqual(lintSpec(spec), []);+ const invalid = lintSpec(parseSpec('## G\n- G1 [approved, must] Bad names. | gate: proof | signers: bad name,CO,CO\n'));+ assert.ok(invalid.some((finding) => /signer "bad name" must be one SSH principal/u.test(finding.message)));+ assert.ok(invalid.some((finding) => /signers are unique/u.test(finding.message)));+});++ test('SPEC and PRACTICE grammar defaults to version 1 and accepts its declaration [A5]', () => {+ assert.equal(SPEC_GRAMMAR_VERSION, 1);+ const legacy = parseSpec(SPEC);+ const declared = parseSpec(`<!-- pullboard-grammar ${SPEC_GRAMMAR_VERSION} -->\n${SPEC}`);+ assert.equal(legacy.grammarVersion, SPEC_GRAMMAR_VERSION);+ assert.equal(declared.grammarVersion, SPEC_GRAMMAR_VERSION);+ assert.deepEqual(declared.intro, legacy.intro);+ assert.deepEqual(declared.rows.map(({ line, ...row }) => row), legacy.rows.map(({ line, ...row }) => row));+ assert.deepEqual(lintSpec(declared), []);+ });++ test('a newer SPEC grammar is refused with its version and an upgrade step [A5]', () => {+ for (const version of ['2', '9007199254740993', '0', '2.5', '']) {+ assert.throws(() => parseSpec(`<!-- pullboard-grammar ${version} -->\n${SPEC}`), {+ code: 'A5_GRAMMAR_VERSION',+ message: new RegExp(`grammar .*not supported.*reads grammar ${SPEC_GRAMMAR_VERSION}.*upgrade Pullboard`),+ });+ }+ const fence = String.fromCharCode(96).repeat(3);+ assert.equal(parseSpec(`${fence}\n<!-- pullboard-grammar 2 -->\n${fence}\n${SPEC}`).grammarVersion, SPEC_GRAMMAR_VERSION);+ assert.throws(() => parseSpec(`<!-- pullboard-grammar 1 -->\n<!-- pullboard-grammar 2 -->\n${SPEC}`), { code: 'A5_GRAMMAR_VERSION' });+ });++ test('real spec check refuses future grammar in either configured file [A5]', (t) => {+ const practice = '# Practice\n\n## P\n- P1 [draft] A local rule.\n';+ const box = specBox(t, { specName: 'requirements.md', practiceName: 'ways.md', practice });+ for (const [name, source] of [[box.specName, SPEC], [box.practiceName, practice]]) {+ writeFileSync(join(box.root, name), `<!-- pullboard-grammar ${SPEC_GRAMMAR_VERSION} -->\n${source}`);+ }+ assert.equal(box.run('check').status, 0);+ for (const [name, source] of [[box.specName, SPEC], [box.practiceName, practice]]) {+ writeFileSync(join(box.root, name), '<!-- pullboard-grammar 2 -->\n' + source);+ const text = box.run('check');+ assert.equal(text.status, 1);+ assert.match(text.stderr, /A5_GRAMMAR_VERSION.*grammar 2.*grammar 1.*upgrade Pullboard/);+ const json = box.run('check', '--json');+ assert.equal(json.status, 1);+ const error = JSON.parse(json.stdout).error;+ assert.equal(error.code, 'A5_GRAMMAR_VERSION');+ assert.ok(!error.message.includes('[A5_GRAMMAR_VERSION]'));+ assert.match(error.message, /grammar 2.*grammar 1.*upgrade Pullboard/);+ assert.match(error.next, /upgrade Pullboard/);+ writeFileSync(join(box.root, name), source);+ }+ assert.equal(box.run('check').status, 0);+ });++ test('a grammar-1 repair can commit after grammar 2 was already recorded [A5,S8]', (t) => {+ const root = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-grammar-history-')));+ t.after(() => rmSync(root, { recursive: true, force: true }));+ const bin = join(root, '.bin');+ mkdirSync(bin);+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec "${process.execPath}" "${resolve(import.meta.dirname, '../bin/pullboard.js')}" "$@"\n`);+ chmodSync(join(bin, 'pullboard'), 0o755);+ const env = {+ ...process.env,+ PATH: `${bin}:${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(root, '.home'),+ };+ const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' });+ const command = (...args) => spawnSync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });+ git('init', '-q', '-b', 'main');+ git('config', 'user.name', 'Test Agent');+ git('config', 'user.email', '[email protected]');+ writeFileSync(join(root, 'SPEC.md'), `<!-- pullboard-grammar 2 -->\n${SPEC}`);+ writeFileSync(join(root, 'PRACTICE.md'), '<!-- pullboard-grammar 2 -->\n# Practice\n');+ git('add', '-A');+ git('commit', '-q', '-m', 'docs: preserve pre-upgrade grammar');+ const initialized = command('init');+ assert.equal(initialized.status, 0, `${initialized.stdout}${initialized.stderr}`);+ writeFileSync(join(root, 'SPEC.md'), `<!-- pullboard-grammar 1 -->\n${SPEC}`);+ writeFileSync(join(root, 'PRACTICE.md'), '<!-- pullboard-grammar 1 -->\n# Practice\n');+ git('add', '-A');+ const repaired = spawnSync('git', ['commit', '-q', '-m', 'docs: restore supported grammar'], { cwd: root, env, encoding: 'utf8' });+ assert.equal(repaired.status, 0, `${repaired.stdout}${repaired.stderr}`);+ const checked = command('spec', 'check');+ assert.equal(checked.status, 0, `${checked.stdout}${checked.stderr}`);+ });+test('a row-like line that does not parse is an error, never dropped [S1]', () => {const spec = parseSpec('## G\n- G1 [approved, must]\n- just a bullet note\n');const findings = lintSpec(spec);