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(gate): explain uncommitted init policy [I1,C7]

Corey Olson4b2fa8f8d1ad
diff --git a/src/cli.js b/src/cli.js
index 6da76760..46a3f818 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1719,6 +1719,21 @@ function uncommittedSetup(mainRoot, config) {
};
}
+/** Find initialized setup that is on disk but absent from the primary checkout's committed policy. */
+function uncommittedPolicySetup(info) {
+ const primary = mainCheckout(info.root);
+ if (!primary?.commit) return null;
+ const committedConfig = tryGit(info.root, ['ls-tree', '-z', primary.commit, '--', `:(literal)${CONFIG_FILE}`]);
+ if (committedConfig.status !== 0 || committedConfig.stdout) return null;
+
+ const mainRoot = resolve(info.commonDir, '..');
+ let config;
+ try { config = loadConfig(mainRoot); }
+ catch { return null; }
+ const setup = uncommittedSetup(mainRoot, config);
+ return setup?.files.includes(CONFIG_FILE) ? setup : null;
+}
+
/**
* Refuse a worktree whose agent would start without pullboard's files as the main checkout has
* them: no config, rules or hooks, or older ones (I4). Name each file and how it differs, and the
@@ -3341,6 +3356,14 @@ async function runCommand(argv, io) {
&& 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}`);
}
+ if (error instanceof Refused && error.code === 'NO_POLICY'
+ && error.message === 'the committed coordinator policy or claim base is missing; restore its Git objects or ask the coordinator to refreeze the item') {
+ const setup = uncommittedPolicySetup(ctx.info);
+ if (setup) {
+ const files = setup.files.map(shellWord).join(' ');
+ throw new Refused('NO_POLICY', `${CONFIG_FILE} and Pullboard's initialized setup files are uncommitted; commit them before running the gate: ${setup.stage} && git commit -q -m "chore: set up pullboard" -- ${files}`);
+ }
+ }
throw error;
}
const gate = await runGate(ctx.info.root, config, { landing: values.landing, agent: resourceAgent(ctx), onWait: gateWaitReporter(io) });
diff --git a/test/gate.test.js b/test/gate.test.js
index f3088bd0..970d6bb2 100644
--- a/test/gate.test.js
+++ b/test/gate.test.js
@@ -101,6 +101,42 @@ test('gate before the first commit names the uncommitted config [I1,C7]', () =>
'other genuine NO_POLICY failures keep their specific message');
});
+test('gate after init in an existing repo says to commit the init files [I1,C7]', () => {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-init-history-')));
+ 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');
+ writeFileSync(join(repo, 'README.md'), '# Existing repository\n');
+ git('add', 'README.md');
+ git('commit', '-q', '-m', 'chore: create existing repository');
+ assert.equal(run('init', '--model', 'Test Coordinator').status, 0);
+
+ const refused = run('gate', '--json');
+ assert.equal(refused.status, 1, 'the gate cannot read the policy until init files are committed');
+ const refusal = JSON.parse(refused.stdout).error;
+ assert.equal(refusal.code, 'NO_POLICY');
+ const message = refusal.message;
+ assert.match(message, /pullboard\.json and Pullboard's initialized setup files are uncommitted/u);
+ assert.match(message, /git add(?: -f)? -- .*pullboard\.json/u, 'the refusal gives a scoped staging command');
+ assert.match(message, /&& git commit -q -m "chore: set up pullboard"/u, 'the refusal explains the needed commit');
+ for (const path of ['SPEC.md', 'DOCTRINE.md']) assert.ok(message.includes(path), message);
+ assert.ok(!message.includes('README.md'), 'unrelated existing files are not included in the staging command');
+});
+
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`);