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(core): use detached spec baseline [D4,A5]

Corey Olson8d07a3dbd908
diff --git a/src/cli.js b/src/cli.js
index 1956dbb1..37b56879 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -78,12 +78,12 @@ export const VERSION = PACKAGE.version;
const CHECKOUT_LEASES = new WeakMap();
/**
- * Read the collision baseline from the primary branch, or its retained trunk when detached.
+ * Read the collision baseline from the primary branch, retained trunk, or detached HEAD default.
*
* @param {string} root
* @param {string} path
* @param {string} [revision]
- * @returns {{ status: number, stdout: string }}
+ * @returns {{ status: number, stdout: string, baseline?: string }}
*/
function coordinatorFile(root, path, revision) {
const commonDir = git(root, ['rev-parse', '--path-format=absolute', '--git-common-dir']);
@@ -91,7 +91,9 @@ function coordinatorFile(root, path, revision) {
const env = { ...gitChildEnv(root), GIT_NO_REPLACE_OBJECTS: '1' };
const primary = mainCheckout(coordinatorRoot);
let ref = primary?.branch ?? trunkRef(coordinatorRoot);
- if (!ref?.startsWith('refs/heads/')) {
+ const detachedHeadDefault = !primary && !ref;
+ if (detachedHeadDefault) ref = 'HEAD';
+ if (ref !== 'HEAD' && !ref?.startsWith('refs/heads/')) {
throw new Refused('NO_TRUNK', 'no trunk branch was recorded; check out the trunk branch in the main checkout once and run pullboard inbox');
}
if (!primary) {
@@ -106,7 +108,11 @@ function coordinatorFile(root, path, revision) {
const result = spawnSync('git', ['--no-replace-objects', 'show', `${revision ?? ref}:${path}`], {
cwd: coordinatorRoot, env, encoding: 'utf8',
});
- return { status: result.status ?? 1, stdout: result.stdout ?? '' };
+ return {
+ status: result.status ?? 1,
+ stdout: result.stdout ?? '',
+ ...(detachedHeadDefault ? { baseline: 'collision baseline default: detached HEAD' } : {}),
+ };
}
const ALL_HELP = `pullboard ${VERSION}: the local-first work board for teams of coding agents.
@@ -2403,11 +2409,13 @@ async function specCommand(io, { first, second, rest, values }) {
const renameBase = collisionFiles.some(([name]) => name === DOCTRINE_FILE)
? legacyDoctrineRenameBase(ctx.info.root, DOCTRINE_FILE)
: null;
+ const baselineNotes = new Set();
const previousCounts = new Map(collisionFiles.map(([name]) => {
const baselineName = renameBase && name === DOCTRINE_FILE ? LEGACY_DOCTRINE_FILE : name;
const previous = name === DOCTRINE_FILE && !renameBase
? { status: 1, stdout: '' }
: coordinatorFile(ctx.info.root, baselineName, renameBase ?? undefined);
+ if (previous.baseline) baselineNotes.add(previous.baseline);
const rows = previous.status === 0 ? parseSpec(previous.stdout, { strictGrammarVersion: false }).rows : [];
const counts = new Map();
for (const row of rows) counts.set(row.id, (counts.get(row.id) ?? 0) + 1);
@@ -2437,7 +2445,7 @@ async function specCommand(io, { first, second, rest, values }) {
}
}
let errors = 0;
- const messages = [];
+ const messages = [...baselineNotes];
for (const [name, parsed] of files) {
const findings = [
...lintSpec(parsed).filter((finding) => !finding.message.startsWith('duplicate id;')),
diff --git a/test/doctrine-name.test.js b/test/doctrine-name.test.js
index 70994a90..34ff16f4 100644
--- a/test/doctrine-name.test.js
+++ b/test/doctrine-name.test.js
@@ -272,7 +272,42 @@ test('[D4,A5] a staged rename keeps known duplicates before its rename commit',
assert.match(check.stdout, /DOCTRINE\.md:4 G1 warning: known duplicate id; also appears at SPEC\.md:4/u);
});
-test('[D4,A5] detached checkout reads the trunk baseline through the verifier clone', function verifierCloneRetainsTrunkBaseline() {
+test('[D4,A5] spec check in a fresh detached CI clone reads its own commit', function detachedCiCloneUsesCheckedCommit() {
+ const box = sandbox();
+ for (const scenario of [
+ { name: 'ci-known', laterCollision: false },
+ { name: 'ci-later', laterCollision: true },
+ ]) {
+ const source = renamedDoctrineFixture(box, `${scenario.name}-source`, { laterCollision: scenario.laterCollision });
+ const initialized = box.run(source, 'init');
+ assert.equal(initialized.status, 0, `${initialized.stdout}${initialized.stderr}`);
+ box.git(source, 'add', '-A');
+ box.git(source, 'commit', '-q', '-m', 'chore: commit detached CI fixture configuration');
+ box.git(source, 'tag', scenario.name);
+
+ const clone = join(box.dir, `${scenario.name}-clone`);
+ box.git(box.dir, 'clone', '--quiet', '--no-local', '--no-checkout', '--', source, clone);
+ box.git(clone, 'checkout', '--quiet', '--detach', scenario.name);
+ const localTrunk = spawnSync('git', ['config', '--local', '--get', 'pullboard.trunk'], { cwd: clone, env: box.env, encoding: 'utf8' });
+ assert.equal(localTrunk.status, 1, 'the detached CI clone has no recorded trunk configuration');
+
+ const checked = box.run(clone, 'spec', 'check');
+ assert.match(checked.stdout, /^collision baseline default: detached HEAD$/mu, 'the check announces the detached default ref');
+ assert.match(checked.stdout, /SPEC\.md:4 G1 warning: known duplicate id; also appears at DOCTRINE\.md:4/u);
+ assert.match(checked.stdout, /DOCTRINE\.md:4 G1 warning: known duplicate id; also appears at SPEC\.md:4/u);
+ if (scenario.laterCollision) {
+ assert.equal(checked.status, 1, checked.stdout);
+ assert.match(checked.stdout, /SPEC\.md:5 G2 error: duplicate id; also appears at DOCTRINE\.md:5/u);
+ assert.match(checked.stdout, /DOCTRINE\.md:5 G2 error: duplicate id; also appears at SPEC\.md:5/u);
+ } else {
+ assert.equal(checked.status, 0, `${checked.stdout}${checked.stderr}`);
+ assert.match(checked.stdout, /SPEC\.md: \d+ rows, 0 errors/u);
+ assert.match(checked.stdout, /DOCTRINE\.md: \d+ rows, 0 errors/u);
+ }
+ }
+});
+
+test('[D4,A5] detached verifier clones use a recorded trunk or their checked commit', function verifierCloneRetainsTrunkBaseline() {
const box = sandbox();
const source = renamedDoctrineFixture(box, 'detached-source');
const initialized = box.run(source, 'init');
@@ -312,11 +347,19 @@ test('[D4,A5] detached checkout reads the trunk baseline through the verifier cl
box.git(withoutTrunk, 'config', '--local', '--unset-all', 'pullboard.trunk');
assert.equal(spawnSync('git', ['config', '--local', '--get', 'pullboard.trunk'], {
cwd: withoutTrunk, env: box.env,
- }).status, 1, 'the negative source actually has no retained trunk');
- const refused = checkAtCommit(withoutTrunk, { ...item, item_claim_head: noTrunkCommit, item_commit: noTrunkCommit });
- assert.equal(refused.state, 'red');
- assert.match(`${refused.output}\n${refused.outputTail}`, /NO_TRUNK/u);
- assert.match(`${refused.output}\n${refused.outputTail}`, /check out the trunk branch in the main checkout once/u);
+ }).status, 1, 'the source actually has no retained trunk');
+ const attachedWithoutTrunk = box.run(withoutTrunk, 'spec', 'check');
+ assert.equal(attachedWithoutTrunk.status, 0, `${attachedWithoutTrunk.stdout}${attachedWithoutTrunk.stderr}`);
+ assert.doesNotMatch(attachedWithoutTrunk.stdout, /collision baseline default: detached HEAD/u, 'an attached checkout keeps using its own branch');
+ box.git(withoutTrunk, 'config', '--local', '--unset-all', 'pullboard.trunk');
+ assert.equal(spawnSync('git', ['config', '--local', '--get', 'pullboard.trunk'], {
+ cwd: withoutTrunk, env: box.env,
+ }).status, 1, 'the source remains without a retained trunk for the detached verifier');
+ const detachedWithoutTrunk = checkAtCommit(withoutTrunk, { ...item, item_claim_head: noTrunkCommit, item_commit: noTrunkCommit });
+ assert.equal(detachedWithoutTrunk.state, 'pass', `${detachedWithoutTrunk.stage}\n${detachedWithoutTrunk.output}`);
+ assert.match(detachedWithoutTrunk.output, /^collision baseline default: detached HEAD$/mu);
+ assert.match(detachedWithoutTrunk.output, /SPEC\.md:4 G1 warning: known duplicate id; also appears at DOCTRINE\.md:4/u);
+ assert.match(detachedWithoutTrunk.output, /DOCTRINE\.md:4 G1 warning: known duplicate id; also appears at SPEC\.md:4/u);
});
test('[D4,A5] verify in a detached checkout reads the trunk baseline for a doctrine frozen check', function verifyDoctrineFrozenCheck() {