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
feat(checks): a check that is not valid shell is refused [C7,V4]
Corey Olson28c9f8271222
diff --git a/src/check-baseline.js b/src/check-baseline.jsindex a7c83070..5a2e89dc 100644--- a/src/check-baseline.js+++ b/src/check-baseline.js@@ -7,6 +7,7 @@ import { join } from 'node:path';import { gitChildEnv, mainCheckout, tryGit } from './git.js';import { runShell } from './gate.js';import { CONFIG_FILE } from './config.js';+import { Refused } from './refused.js';/*** Capture the command and coordinator commit once on the sender; replay only receives this observation.@@ -36,6 +37,21 @@ export function checkBaseline(root, command, { main = undefined } = {}) {}}+/**+ * Refuse a check the shell cannot parse, quoting the shell's own message. sh -n reads the command+ * without running it, so a stray quote is caught when the check is set instead of surfacing later+ * as a baseline red that looks like a test failing before the work [C7,V4].+ *+ * @param {string} command+ */+export function refuseCheckSyntax(command) {+ // /bin/sh is the shell checks run in (spawn's shell: true); a parse that cannot start is no verdict.+ const parsed = spawnSync('/bin/sh', ['-n', '-c', command], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 5000 });+ if (parsed.status === 0 || parsed.error || parsed.status === null) return;+ const said = `${parsed.stderr ?? ''}`.trim().split('\n').map((line) => line.trim()).filter(Boolean).join('; ') || `sh -n exited ${parsed.status}`;+ throw new Refused('CHECK_SYNTAX', `the check is not valid shell, so it would only ever run red: ${said}`);+}+/** Capture the authorized check's immutable base without running its shell command [V2,H16]. */export function prepareCheckBaseline(root, command) {const primary = mainCheckout(root);diff --git a/src/cli.js b/src/cli.jsindex cbebab1c..d249cb38 100644--- a/src/cli.js+++ b/src/cli.js@@ -61,7 +61,7 @@ import {} from './spec.js';import { bundledBlueprints, planBlueprint, readBlueprint, saveBlueprint } from './blueprints.js';import { briefFiles } from './brief.js';-import { checkBaseline, prepareCheckBaseline, sayCheckBaseline } from './check-baseline.js';+import { checkBaseline, prepareCheckBaseline, refuseCheckSyntax, sayCheckBaseline } from './check-baseline.js';import { retryCheckBaselines, startCheckBaseline } from './check-baseline-worker.js';import { compareMainFailures, mainRedMessage, mainRedReworkItems } from './main-red.js';import { runItems } from './run.js';@@ -2873,6 +2873,7 @@ function workCommands(io, args) {};buildInFilelessLane(ctx.config, first, after);const { command } = store.validateItemAddition(board, item);+ if (command) refuseCheckSyntax(command);if (command) item.checkBaseline = values.wait ? checkBaseline(ctx.info.root, command) : prepareCheckBaseline(ctx.info.root, command);const id = await ordered(ctx, board, 'addItem', [item]);if (item.checkBaseline?.result === 'pending') await launchBaseline(ctx, board, id, item.checkBaseline);@@ -2902,6 +2903,7 @@ function workCommands(io, args) {after: editAfter(values.after),};const { item, command } = store.validateItemEdit(board, id, change);+ if (command && command !== item.item_check) refuseCheckSyntax(command);if (command && command !== item.item_check) change.checkBaseline = values.wait ? checkBaseline(ctx.info.root, command) : prepareCheckBaseline(ctx.info.root, command);await ordered(ctx, board, 'editItem', [id, change]);if (change.checkBaseline?.result === 'pending') await launchBaseline(ctx, board, id, change.checkBaseline);diff --git a/src/next-steps.js b/src/next-steps.jsindex d8afe8fe..60b90046 100644--- a/src/next-steps.js+++ b/src/next-steps.js@@ -76,6 +76,7 @@ export const NEXT_STEPS = Object.freeze({BROWSER_SLOT_REQUIRED: 'release the gate lease and take it again with browser: true',CANNOT_SIGN: 'sign only approved rows: pullboard spec signoff <approved ids>',CHECKOUT_SESSION: 'run pullboard takeover from the agent session that owns this checkout',+ CHECK_SYNTAX: 'close the quote the shell names, then set the check again: inside single quotes write an apostrophe as \'\\\'\' or match it with ., and test with sh -n -c "<command>"',CHECK_CANNOT_FAIL: 'write a check that exits nonzero on the problem, then add the item again',CHECK_CONFIRM: 'read the check command, then run pullboard check <id> --yes',CHECK_RED: 'reject with what failed: pullboard verify <id> reject --reason TEST_FAILURE --note "<what failed>"',diff --git a/test/check-baseline.test.js b/test/check-baseline.test.jsindex ae3012f5..a95a0eb1 100644--- a/test/check-baseline.test.js+++ b/test/check-baseline.test.js@@ -430,3 +430,41 @@ test('[H3,H16] captured add and edit baselines replay identically without runninassert.deepEqual(snapshotFile(fileA), snapshotFile(fileB), 'replayed edits preserve equal baseline and event metadata');assert.deepEqual(snapshotFile(senderFile), snapshotFile(fileA), 'sender and both receiving databases share the same add/edit history');});++/** Read the shell's own parse message for a command, as the refusal must quote it. */+function shellParseMessage(command) {+ const parsed = spawnSync('/bin/sh', ['-n', '-c', command], { encoding: 'utf8' });+ assert.notEqual(parsed.status, 0, 'the fixture command is a real syntax error');+ return parsed.stderr.trim().split('\n')[0].trim();+}++test('[C7,V4] a check that is not valid shell is refused when set', () => {+ const box = project();+ const unbalanced = "grep -q 'it's done' web/result.txt";+ const said = shellParseMessage(unbalanced);+ const before = box.run(box.repo, ['list', '--json']).stdout;++ const added = box.run(box.repo, ['add', 'web', 'Unbalanced add', '--specs', 'G1', '--check', unbalanced, '--json']);+ assert.notEqual(added.status, 0, 'an unbalanced quote on add is refused');+ const addError = JSON.parse(added.stdout).error;+ assert.equal(addError.code, 'CHECK_SYNTAX', 'add refuses with CHECK_SYNTAX');+ assert.ok(addError.message.includes(said), `add quotes the shell's message: ${addError.message}`);+ assert.match(addError.next, /sh -n/u, 'the refusal names its specific next step');+ assert.equal(box.run(box.repo, ['list', '--json']).stdout, before, 'a refused add files no item');++ const valid = "grep -q 'green' web/result.txt";+ const { item } = addChecked(box, 'Valid check', valid);+ assert.equal(item.item_check, valid, 'a valid check is accepted on add');++ const edited = box.run(box.repo, ['edit', String(item.item_id), '--check', unbalanced, '--json']);+ assert.notEqual(edited.status, 0, 'an unbalanced quote on edit is refused');+ const editError = JSON.parse(edited.stdout).error;+ assert.equal(editError.code, 'CHECK_SYNTAX', 'edit refuses with CHECK_SYNTAX');+ assert.ok(editError.message.includes(said), `edit quotes the shell's message: ${editError.message}`);+ assert.equal(showItem(box, item.item_id).item.item_check, valid, 'a refused edit keeps the old check');++ const revised = "grep -q 'gr''een' web/result.txt";+ const accepted = box.run(box.repo, ['edit', String(item.item_id), '--check', revised, '--wait', '--json']);+ assert.equal(accepted.status, 0, `a valid check is accepted on edit: ${accepted.stdout}${accepted.stderr}`);+ assert.equal(showItem(box, item.item_id).item.item_check, revised);+});