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.

feat: defer landing gate suite on submit [V4,C7]

Corey Olsona8ee945a0a3e
diff --git a/src/board.js b/src/board.js
index defa39b6..0cefd895 100644
--- a/src/board.js
+++ b/src/board.js
@@ -1179,10 +1179,13 @@ export function release(board, id, agentId, note = '') {
*
* @param {any} board
* @param {number} id
- * @param {{ agentId: string, commit: string, tree: string, files?: string[], policyCommit?: string }} at - `files`: what the
+ * @param {{ agentId: string, commit: string, tree: string, files?: string[], policyCommit?: string, note?: string }} at - `files`: what the
* item's own commits changed since its claim; a rework adds to what the first attempt changed.
*/
-export function submit(board, id, { agentId, commit, tree, files = [], policyCommit = null }) {
+export function submit(board, id, { agentId, commit, tree, files = [], policyCommit = null, note }) {
+ if (note !== undefined && (typeof note !== 'string' || !note.trim() || /[\r\n\u2028\u2029]/u.test(note))) {
+ throw new Refused('USAGE', 'a submission note, when present, is one nonempty line');
+ }
atomic(board, () => {
const notYours = () => new Refused('NOT_YOURS', `item #${id} is not claimed by you; claim it first`);
moveItem(board, id, 'submit', {
@@ -1237,6 +1240,7 @@ export function submit(board, id, { agentId, commit, tree, files = [], policyCom
tree,
...(policyCommit ? { policyCommit } : {}),
...(criterionDigest ? { criterionDigest } : {}),
+ ...(note === undefined ? {} : { note: note.trim() }),
});
});
}
diff --git a/src/cli.js b/src/cli.js
index d421104b..e78e56a6 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1929,7 +1929,7 @@ function readCommands(io, { first, second, rest, values }) {
if (entry.ref) io.say(` ref: ${entry.ref.path}:${entry.ref.start}${entry.ref.end === entry.ref.start ? '' : '-' + entry.ref.end}@${entry.ref.commit}`);
} else {
const detail = entry.detail;
- io.say(`${stamp}${entry.kind}${detail.commit ? ' at ' + detail.commit : ''}${detail.reason ? ': ' + detail.reason : ''}`);
+ io.say(`${stamp}${entry.kind}${detail.commit ? ' at ' + detail.commit : ''}${detail.reason ? ': ' + detail.reason : ''}${detail.note ? `: ${detail.note}` : ''}`);
}
}
return 0;
@@ -2133,7 +2133,8 @@ async function submitHere(ctx, id) {
withBoard(ctx, (board) => refuseUnverifiedStack(root, board, held, commit, trunk));
// Every submit proves its frozen check and reachable tests anew on this exact commit (V4,V16).
// A full-gate stamp never substitutes for either proof; only an actual full fallback may stamp.
- const gate = await runSubmitGate(root, ctx.config, { base: claimHead, trunk: acceptedMain.commit, check: frozenCheck(held), agent: me.id, item: String(id), onWait: gateWaitReporter(ctx.io) });
+ const submitConfig = { ...ctx.config, submitGate: acceptedMain.config.submitGate };
+ const gate = await runSubmitGate(root, submitConfig, { base: claimHead, trunk: acceptedMain.commit, check: frozenCheck(held), agent: me.id, item: String(id), onWait: gateWaitReporter(ctx.io) });
if (!gate.isGreen) {
const message = `the submission proof is red at ${commit.slice(0, 12)}; fix it, commit, submit again. ${submitGateReport(gate)}`;
// No submission can follow this verdict. Read-only main comparisons must not retain the seat's write lease.
@@ -2153,9 +2154,10 @@ async function submitHere(ctx, id) {
const currentTrunk = requireTrunkMerge(root, commit); // The trunk may have moved while the gate ran.
await withBoard(ctx, async (board) => {
refuseUnverifiedStack(root, board, store.getItem(board, id), commit, currentTrunk);
- return await ordered(ctx, board, 'submit', [id, { agentId: me.id, commit, tree: headTree(root) ?? '', files: filesSince(root, id, claimHead, commit), policyCommit: acceptedMain.commit }]);
+ return await ordered(ctx, board, 'submit', [id, { agentId: me.id, commit, tree: headTree(root) ?? '', files: filesSince(root, id, claimHead, commit), policyCommit: acceptedMain.commit,
+ ...(gate.deferred ? { note: 'full suite deferred to the landing gate' } : {}) }]);
});
- return reportSubmission(ctx, id, commit, { green: gate.isGreen, report: submitGateReport(gate), files: gate.files, full: gate.full, reason: gate.reason, check: gate.check,
+ return reportSubmission(ctx, id, commit, { green: gate.isGreen, report: submitGateReport(gate), files: gate.files, full: gate.full, deferred: gate.deferred, deferFullFallback: gate.deferFullFallback, reason: gate.reason, check: gate.check,
log: gate.log, profile: gate.profile, profilePath: gate.profilePath, proofLog: gate.proofLog, proofProfilePath: gate.proofProfilePath });
}
diff --git a/src/config.js b/src/config.js
index 8f1927b6..f06fe763 100644
--- a/src/config.js
+++ b/src/config.js
@@ -158,6 +158,9 @@ export function configProblems(config) {
if (typeof config.spec !== 'string' || !config.spec) problems.push('"spec" names a file');
if (typeof config.practice !== 'string' || !config.practice) problems.push('"practice" names the doctrine file');
if (typeof config.gate !== 'string') problems.push('"gate" is a shell command, like "npm test"');
+ if (config.submitGate !== undefined && config.submitGate !== 'landing') {
+ problems.push('"submitGate" is "landing" when the full suite should be deferred until landing');
+ }
if (config.affectedTests !== undefined && (typeof config.affectedTests !== 'string' || !config.affectedTests.trim())) {
problems.push('"affectedTests" is a nonempty command prefix used to run selected test files');
}
diff --git a/src/gate.js b/src/gate.js
index 7a0f2ccd..9f502e41 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -351,7 +351,9 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
const selection = config.affectedTests
? selectAffectedTests(root, { base, trunk, changed })
: { full: true, reason: 'affected-test selection is not enabled for this project', files: [] };
- const browser = Boolean(check) || selection.full || await testsNeedBrowser(root, selection.files);
+ const deferred = config.submitGate === 'landing';
+ const deferFullFallback = deferred && selection.full;
+ const browser = Boolean(check) || (!deferFullFallback && (selection.full || await testsNeedBrowser(root, selection.files)));
return await withGateSlot(root, (lease) => {
const startedAt = Date.now();
const log = gitPath(root, 'pullboard-submit.log');
@@ -374,7 +376,7 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
format: [...new Set(profiles.map(value => value.format))].join('+'),
unavailable: profiles.some(value => value.unavailable) ? 'per-test timing unavailable: output was not TAP or JUnit (one or more phases)' : null,
});
- return { ...proof, log, seconds: criterion.seconds + proof.seconds, ...selection, check: receipt,
+ return { ...proof, log, seconds: criterion.seconds + proof.seconds, ...selection, deferred, deferFullFallback, check: receipt,
profile, profilePath, proofProfilePath: proof.profilePath, proofLog: proof.log };
};
if (!criterion.isGreen) {
@@ -384,14 +386,16 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
// The proof already owns this lease: its phase profile has no additional queue wait.
const proofWait = check ? 0 : lease.waitMs;
let proof;
- if (selection.full) proof = fullGateRun(root, config, false, { waitMs: proofWait, log: proofLog, gateLease: lease });
+ if (deferFullFallback) proof = { isGreen: true, isCached: false, output: '', seconds: 0, log: '' };
+ else if (selection.full) proof = fullGateRun(root, config, false, { waitMs: proofWait, log: proofLog, gateLease: lease });
else if (!selection.files.length) proof = { isGreen: true, output: '', seconds: 0, isCached: false, log: '' };
else {
const command = `${config.affectedTests.trimEnd()} ${selection.files.map(path => commandWord('./' + path)).join(' ')}`;
proof = { ...runProfiledShell(root, command, { waitMs: proofWait, profileFile: `${proofLog}.profile.json`, gateLease: lease }), isCached: false, log: proofLog };
writeFileSync(proofLog, proof.output);
}
- writeFileSync(log, `item check:\n${criterion.output}\n${selection.full ? 'full gate' : 'affected tests'}:\n${proof.output}`);
+ const phase = deferFullFallback ? 'full suite deferred to the landing gate' : selection.full ? 'full gate' : 'affected tests';
+ writeFileSync(log, `item check:\n${criterion.output}\n${phase}:\n${proof.output}`);
return finish(proof);
}, { browser, agent, item, kind, itemCheck: true, onWait });
}
@@ -399,6 +403,16 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
/** Describe precisely which submission proof ran, including absent checks and full fallbacks. */
export function submitGateReport(gate) {
const check = gate.check.checked ? `item check ${gate.check.green ? 'green' : 'red'} in ${gate.check.seconds}s` : 'no item check';
+ if (gate.deferred) {
+ const reason = gate.reason ? `: ${gate.reason}` : '';
+ const timings = timingDigest(gate.profile);
+ const detail = timings ? `\n${timings}\ntiming profile: ${gate.profilePath}` : '';
+ const proof = gate.deferFullFallback
+ ? `full suite deferred to the landing gate${reason}`
+ : `affected tests: ${gate.files.length ? gate.files.join(', ') : 'none'}; full suite deferred to the landing gate`;
+ const result = gate.deferFullFallback ? '' : `; ${gate.isGreen ? `affected tests green in ${gate.seconds}s` : gateReport(gate)}`;
+ return `${check}; ${proof}${result}${detail}`;
+ }
const selection = gate.full ? `full gate: ${gate.reason}` : `affected tests: ${gate.files.length ? gate.files.join(', ') : 'none'}`;
const timings = timingDigest(gate.profile);
const detail = timings ? `\n${timings}\ntiming profile: ${gate.profilePath}` : '';
diff --git a/test/submit-gate.test.js b/test/submit-gate.test.js
index 2334b29e..2d50e072 100644
--- a/test/submit-gate.test.js
+++ b/test/submit-gate.test.js
@@ -224,6 +224,102 @@ test('submit runs the frozen check and affected test only; landing and explicit
assert.equal(existsSync(stamp), false, 'neither subset nor red full gate leaves a green full-gate stamp');
});
+test('a landing-gated project defers the full suite from submit to landing [V4,C7]', (t) => {
+ /** Build a small project whose global-source edit selects the full gate.
+ * @param {string} [initialSubmitGate]
+ * @returns {{box: any, fullMarker: string, checkMarker: string}}
+ */
+ function project(initialSubmitGate) {
+ let box = privateRepo(t);
+ put(box.root, 'pullboard.json', JSON.stringify({
+ gate: 'node --test', affectedTests: 'node --test', shared: ['pullboard.json'],
+ ...(initialSubmitGate ? { submitGate: initialSubmitGate } : {}),
+ }));
+ seedGraph(box);
+ const fullMarker = join(box.dir, 'full-suite.log');
+ const checkMarker = join(box.dir, 'item-check.log');
+ box.env.FULL_SUITE_MARKER = fullMarker;
+ box.env.ITEM_CHECK_MARKER = checkMarker;
+ for (const [file, name] of [['a', 'first'], ['b', 'second'], ['c', 'third']]) {
+ put(box.root, `test/${file}.test.js`, [
+ "import { appendFileSync } from 'node:fs';",
+ ...(file === 'a' ? ["import '../src/entry.js';"] : []),
+ `appendFileSync(process.env.FULL_SUITE_MARKER, '${name}\\n');`,
+ ].join('\n') + '\n');
+ }
+ put(box.root, 'src/cli.js', 'export const version = 1;\n');
+ commitAll(box, 'chore(core): prepare landing-gate fixture');
+ box = builderRepo(box);
+ const check = `node -e "require('node:fs').appendFileSync(process.env.ITEM_CHECK_MARKER, 'check\\n')"`;
+ assert.equal(box.coordinator('add', 'build', 'Landing gate fixture', '--check', check).code, 0);
+ assert.equal(box.run('claim', '1').code, 0);
+ rmSync(fullMarker, { force: true });
+ rmSync(checkMarker, { force: true });
+ return { box, fullMarker, checkMarker };
+ }
+
+ const optedIn = project();
+ const mainRoot = join(optedIn.box.dir, 'repo');
+ const mainConfig = JSON.parse(readFileSync(join(mainRoot, 'pullboard.json'), 'utf8'));
+ mainConfig.submitGate = 'landing';
+ put(mainRoot, 'pullboard.json', JSON.stringify(mainConfig));
+ runFixtureGit(['add', 'pullboard.json'], { cwd: mainRoot, env: optedIn.box.env });
+ runFixtureGit(['commit', '-q', '-m', 'feat(config): defer full suite to landing [G1]'], { cwd: mainRoot, env: optedIn.box.env });
+ optedIn.box.git('merge', '--no-edit', 'main');
+ put(optedIn.box.root, 'src/cli.js', 'export const version = 2;\n');
+ commitAll(optedIn.box, 'feat(core): change global source [G1]');
+
+ const deferred = optedIn.box.run('submit', '1', '--json');
+ assert.equal(deferred.code, 0, deferred.err);
+ const receipt = JSON.parse(deferred.out);
+ assert.equal(receipt.gate.full, true, 'the selector still reports that it fell back to the whole suite');
+ assert.equal(receipt.gate.deferred, true);
+ assert.match(receipt.gate.report, /full suite deferred to the landing gate/u);
+ assert.ok(existsSync(optedIn.checkMarker), 'the item check still runs');
+ assert.equal(existsSync(optedIn.fullMarker), false, 'the submit did not run the deferred suite');
+ const shown = optedIn.box.run('show', '1', '--json');
+ assert.equal(shown.code, 0, shown.err);
+ const submitEvent = JSON.parse(shown.out).thread.findLast((event) => event.kind === 'submit');
+ assert.equal(submitEvent.detail.note, 'full suite deferred to the landing gate', 'the reviewer can see the durable submission note');
+ const stamp = resolve(optedIn.box.root, optedIn.box.git('rev-parse', '--git-path', 'pullboard-gate-green'));
+ assert.equal(existsSync(stamp), false, 'deferral never creates a full-gate stamp');
+
+ const landing = optedIn.box.run('gate', '--landing');
+ assert.equal(landing.code, 0, landing.err);
+ assert.deepEqual(readFileSync(optedIn.fullMarker, 'utf8').trim().split('\n').sort(), ['first', 'second', 'third'],
+ 'the landing gate runs the full configured suite');
+ assert.ok(existsSync(stamp), 'only the actual full-suite pass stamps the tree');
+
+ const candidateOnly = project();
+ const candidateConfig = JSON.parse(readFileSync(join(candidateOnly.box.root, 'pullboard.json'), 'utf8'));
+ candidateConfig.submitGate = 'landing';
+ put(candidateOnly.box.root, 'pullboard.json', JSON.stringify(candidateConfig));
+ put(candidateOnly.box.root, 'src/cli.js', 'export const version = 2;\n');
+ commitAll(candidateOnly.box, 'feat(core): try candidate-only deferral [G1]');
+ const ordinary = candidateOnly.box.run('submit', '1', '--json');
+ assert.equal(ordinary.code, 0, ordinary.err);
+ const ordinaryReceipt = JSON.parse(ordinary.out);
+ assert.equal(ordinaryReceipt.gate.deferred, false, 'a candidate-only setting is not trusted');
+ assert.ok(existsSync(candidateOnly.fullMarker), 'without current-main opt-in the full suite still runs at submit');
+ const ordinaryEvent = JSON.parse(candidateOnly.box.run('show', '1', '--json').out).thread.findLast((event) => event.kind === 'submit');
+ assert.equal(ordinaryEvent.detail.note, undefined, 'ordinary submissions do not claim the suite was deferred');
+
+ const named = project('landing');
+ put(named.box.root, 'src/a.js', 'export const value = 2;\n');
+ commitAll(named.box, 'feat(core): change one selected source [G1]');
+ const selected = named.box.run('submit', '1', '--json');
+ assert.equal(selected.code, 0, selected.err);
+ const selectedReceipt = JSON.parse(selected.out);
+ assert.equal(selectedReceipt.gate.full, false);
+ assert.equal(selectedReceipt.gate.deferred, true);
+ assert.deepEqual(selectedReceipt.gate.files, ['test/a.test.js']);
+ assert.match(selectedReceipt.gate.report, /affected tests: test\/a\.test\.js; full suite deferred to the landing gate/u);
+ assert.ok(existsSync(named.checkMarker), 'the item check runs for a named selection');
+ assert.equal(readFileSync(named.fullMarker, 'utf8'), 'first\n', 'the named affected test runs without unrelated tests');
+ const namedEvent = JSON.parse(named.box.run('show', '1', '--json').out).thread.findLast((event) => event.kind === 'submit');
+ assert.equal(namedEvent.detail.note, 'full suite deferred to the landing gate', 'the reviewer sees deferral for named affected tests too');
+});
+
test('a jest project submits with its own gate [V4,C7]', (t) => {
for (const optedIn of [false, true]) {
let box = privateRepo(t);
@@ -305,6 +401,10 @@ test('affectedTests accepts only a nonempty command prefix [V4,C7]', () => {
});
}
assert.equal(configFromSource(JSON.stringify({ affectedTests: 'node test/runner.js' })).affectedTests, 'node test/runner.js');
+ assert.equal(configFromSource(JSON.stringify({ submitGate: 'landing' })).submitGate, 'landing');
+ assert.throws(() => configFromSource(JSON.stringify({ submitGate: 'submit' })), {
+ code: 'BAD_CONFIG', message: /submitGate.*landing/u,
+ });
});
test('submit without a frozen check reports no item check and still runs affected tests [V4,C7,V16]', (t) => {