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(cli): name the uncommitted config before gate [I1,C7]

Corey Olson3f259e5ed3de
diff --git a/src/cli.js b/src/cli.js
index 1ec82219..7f5b4b48 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -3248,7 +3248,17 @@ async function runCommand(argv, io) {
}
if (command === 'gate') {
const ctx = context(io);
- const gate = await runGate(ctx.info.root, mainPolicy(ctx.info.root).config, { landing: values.landing, agent: resourceAgent(ctx), onWait: gateWaitReporter(io) });
+ let config;
+ try { config = mainPolicy(ctx.info.root).config; }
+ catch (error) {
+ if (error instanceof Refused && error.code === 'NO_POLICY'
+ && error.message.includes('the coordinator checkout has no commit on ')
+ && existsSync(join(ctx.info.root, CONFIG_FILE))) {
+ throw new Refused('NO_POLICY', `${CONFIG_FILE} is not committed; add and commit the initialized project before running the gate: git add ${CONFIG_FILE}`);
+ }
+ throw error;
+ }
+ const gate = await runGate(ctx.info.root, config, { landing: values.landing, agent: resourceAgent(ctx), onWait: gateWaitReporter(io) });
io.result?.({ green: gate.isGreen, report: gateReport(gate) });
io.say(gateReport(gate));
return gate.isGreen ? 0 : 1;
diff --git a/test/gate.test.js b/test/gate.test.js
index 479a089e..f3088bd0 100644
--- a/test/gate.test.js
+++ b/test/gate.test.js
@@ -4,7 +4,7 @@
*/
import assert from 'node:assert/strict';
import { runFixtureExecFile as execFileSync, runFixtureChild as spawnSync, runFixtureChild, runFixtureGit } from './fixture-child.js';
-import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { after, test } from 'node:test';
@@ -61,6 +61,46 @@ function repoWithGate(gate, check = '') {
return { dir, repo, env, git, run, runs };
}
+test('gate before the first commit names the uncommitted config [I1,C7]', () => {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-first-commit-')));
+ dirs.push(dir);
+ const repo = join(dir, 'repo');
+ mkdirSync(repo);
+ const env = {
+ ...process.env,
+ 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(dir, 'home'),
+ PULLBOARD_MACHINE_HOME: join(dir, 'home'),
+ };
+ const git = (...args) => runFixtureGit(args, { cwd: repo, env });
+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });
+ git('init', '-q', '-b', 'main');
+ const initialized = run('init', '--model', 'Test Coordinator');
+ assert.equal(initialized.status, 0, `${initialized.stdout}${initialized.stderr}`);
+ assert.equal(existsSync(join(repo, 'pullboard.json')), true, 'init wrote the coordinator config');
+
+ const firstGate = run('gate', '--json');
+ assert.equal(firstGate.status, 1, 'the gate cannot read a policy before the initial commit');
+ const firstRefusal = JSON.parse(firstGate.stdout).error;
+ assert.equal(firstRefusal.code, 'NO_POLICY');
+ assert.match(firstRefusal.message, /pullboard\.json is not committed/u);
+ assert.match(firstRefusal.message, /git add pullboard\.json/u, 'the refusal gives the concrete staging command');
+
+ const committed = repoWithGate('true');
+ committed.git('switch', '--detach', 'HEAD');
+ const missingCoordinator = committed.run('gate', '--json');
+ assert.equal(missingCoordinator.status, 1);
+ const missingRefusal = JSON.parse(missingCoordinator.stdout).error;
+ assert.equal(missingRefusal.code, 'NO_POLICY');
+ assert.match(missingRefusal.message, /coordinator checkout is detached for review/u,
+ 'other genuine NO_POLICY failures keep their specific message');
+});
+
test('a digest keeps the failures and the end within its cap, however long one line is [V10]', () => {
const digest = digestOf(`not ok 1 - ${'x'.repeat(3500)}\n${'ok\n'.repeat(50)}# fail 1\nsummary: 1 failed`);
assert.ok(digest.length <= 3000, `${digest.length} characters`);