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(core): keep touched registry guards in submit proof [C7,V4]

Corey Olsondb94176cda12
diff --git a/src/cli-main.js b/src/cli-main.js
index 5d960fad..44c0b135 100644
--- a/src/cli-main.js
+++ b/src/cli-main.js
@@ -93,6 +93,7 @@ const OPTIONS = {
diagnostics: { type: 'boolean' },
landing: { type: 'boolean' },
adopt: { type: 'boolean' },
+ affected: { type: 'boolean' },
waive: { type: 'string' },
until: { type: 'string' },
take: { type: 'string' },
diff --git a/src/commands/submit.js b/src/commands/submit.js
index 112325d9..ece472e0 100644
--- a/src/commands/submit.js
+++ b/src/commands/submit.js
@@ -192,8 +192,9 @@ export async function submitHere(ctx, id, infra) {
// Empty frozen gates adopt accepted main setup; only a full fallback may stamp its tree.
const submitConfig = { ...ctx.config, gate: ctx.config.gate.trim() ? ctx.config.gate : acceptedMain.config.gate, submitGate: acceptedMain.config.submitGate, staticChecks: acceptedMain.config.staticChecks,
submitInvariants: acceptedMain.config.submitInvariants, submitDeferAbove: acceptedMain.config.submitDeferAbove,
+ registryGuards: acceptedMain.config.registryGuards,
// The accepted project runner interprets its current invariant files; candidate config cannot replace it.
- ...(acceptedMain.config.submitInvariants.length ? { affectedTests: acceptedMain.config.affectedTests } : {}) };
+ ...(acceptedMain.config.submitInvariants.length || acceptedMain.config.registryGuards.length ? { affectedTests: acceptedMain.config.affectedTests } : {}) };
const gate = await runSubmitGate(root, submitConfig, { base: claimHead, trunk: acceptedMain.commit, check: frozenCheck(held), agent: me.id, item: String(id), onWait: queuedItemLease(ctx, held, me.id, 'build'), onBrowserFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson),
onFailure: nativeFlakes.observer(ctx, { kind: 'submit', main: acceptedMain.commit, config: submitConfig }, { ordered, withBoard, resourceAgent }) });
// Only the person's live waivers can pass a red proof, failure by failure; the item's own check is never waived [B3].
diff --git a/src/commands/test.js b/src/commands/test.js
index 0e968ca5..97550b55 100644
--- a/src/commands/test.js
+++ b/src/commands/test.js
@@ -10,7 +10,7 @@ import {
export async function run(io, { first, second, rest, values }) {
const ctx = context(io);
const files = [first, second, ...rest].filter((file) => file !== undefined && file !== '');
- const result = await runTestFiles(ctx.info.root, ctx.config, files, { agent: resourceAgent(ctx) ?? `pid-${process.pid}`, onWait: gateWaitReporter(io) });
+ const result = await runTestFiles(ctx.info.root, ctx.config, files, { affected: values.affected === true, agent: resourceAgent(ctx) ?? `pid-${process.pid}`, onWait: gateWaitReporter(io) });
io.result?.(result);
if (!values.json && result.output) io.say(result.output.trimEnd());
io.err(`pullboard test: ${result.green ? 'green' : 'red'} on ${result.runner} in ${result.seconds}s${result.local ? `: ${result.local}` : ''}`);
diff --git a/src/config.js b/src/config.js
index 76002641..c2ba4a5a 100644
--- a/src/config.js
+++ b/src/config.js
@@ -9,6 +9,7 @@ import {
import { join } from 'node:path';
import { Refused } from './refused.js';
import { environmentProblem } from './execution-environment.js';
+import { registryGuardsProblem } from './registry-guards.js';
export const CONFIG_FILE = 'pullboard.json';
export const COORDINATOR = 'coordinator';
@@ -48,6 +49,7 @@ export function defaults() {
submit: { requireInfraNote: false },
itemSizeBudget: 100,
submitInvariants: [],
+ registryGuards: [],
staticChecks: '',
lease: '2h',
reviewLease: '30m',
@@ -231,6 +233,9 @@ export function configProblems(config) {
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');
}
+ const registryProblem = registryGuardsProblem(config.registryGuards);
+ if (registryProblem) problems.push(registryProblem);
+ else if (config.registryGuards.length && (typeof config.affectedTests !== 'string' || !config.affectedTests.trim())) problems.push('"registryGuards" requires the project "affectedTests" runner');
if (!isStringList(config.submitInvariants) || config.submitInvariants.some(path =>
!path || path.trim() !== path || /[\u0000-\u001f\u007f-\u009f\\]/u.test(path)
|| path.startsWith('/') || /^[a-z]:/iu.test(path) || path.split('/').some(part => !part || part === '..' || part === '.'))) {
diff --git a/src/gate.js b/src/gate.js
index dcfb9be3..dca9be7c 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -81,6 +81,7 @@ import {
memoryFloorMB,
} from './settings.js';
import { selectAffectedTests } from './affected-tests.js';
+import { selectRegistryGuards } from './registry-guards.js';
import {
checkNeedsBrowser,
testsNeedBrowser,
@@ -615,15 +616,18 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
// A selection over submitDeferAbove files moves to the landing gate, which runs every recorded file before the item lands.
const deferSelection = deferred && !selection.full && Number.isSafeInteger(config.submitDeferAbove) && selection.files.length > config.submitDeferAbove;
const invariants = deferred ? [...new Set(config.submitInvariants ?? [])].sort() : [];
+ const registryGuards = selectRegistryGuards(root, config.registryGuards, { base, trunk, changed });
if (invariants.length && !config.affectedTests?.trim()) {
throw new Refused('BAD_CONFIG', 'submitInvariants requires the project affectedTests runner');
}
- for (const path of invariants) {
+ for (const path of [...invariants, ...registryGuards]) {
let file = false;
try { file = statSync(join(root, path)).isFile(); } catch { /* Missing or unreadable invariants refuse rather than silently disappearing. */ }
- if (!file) throw new Refused('BAD_CONFIG', `submitInvariants file ${path} is missing or unreadable; restore it or update the list on accepted main`);
+ if (!file) throw new Refused('BAD_CONFIG', `submit proof file ${path} is missing or unreadable; restore it or update the obligations on accepted main`);
}
- const proofFiles = [...new Set([...(deferFullFallback || deferSelection ? [] : selection.files), ...invariants])].sort();
+ const proofFiles = [...new Set([...(deferFullFallback || deferSelection ? [] : selection.files), ...invariants, ...registryGuards])].sort();
+ const guardCommand = registryGuards.length ? `${config.affectedTests.trimEnd()} ${registryGuards.map(path => commandWord('./' + path)).join(' ')}` : '';
+ const fullConfig = guardCommand ? { ...config, gate: `(${config.gate}) && ${guardCommand}` } : config;
const allowBrowserFreeChecks = browserFreeChecksEnabled();
const checkUsesBrowser = check ? (!allowBrowserFreeChecks || await checkNeedsBrowser(root, check, { onFallback: onBrowserFallback })) : false;
const proofUsesBrowser = deferFullFallback || deferSelection
@@ -657,7 +661,7 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
executionSource: profiles.find(value => value.executionSource)?.executionSource } : {}),
});
refuseSandboxBlocked(proof);
- return { ...proof, log, seconds: criterion.seconds + proof.seconds, ...selection, ...(deferred ? { files: proofFiles, submitInvariants: invariants } : {}),
+ return { ...proof, log, seconds: criterion.seconds + proof.seconds, ...selection, files: proofFiles, registryGuards, ...(deferred ? { submitInvariants: invariants } : {}),
...(deferSelection ? { deferredFiles: selection.files, deferAbove: config.submitDeferAbove } : {}), deferred, deferFullFallback, check: receipt,
profile, profilePath, proofProfilePath: proof.profilePath, proofLog: proof.log };
};
@@ -670,7 +674,7 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
const proofWait = check ? 0 : lease.waitMs;
let proof;
// The proof keeps each stage's status, so a person's waiver can only ever explain named test failures.
- if (!deferFullFallback && selection.full) proof = fullGateRun(root, config, false, { waitMs: proofWait, log: proofLog, gateLease: lease, stages: true, kind: 'submit' });
+ if (!deferFullFallback && selection.full) proof = fullGateRun(root, fullConfig, false, { waitMs: proofWait, log: proofLog, gateLease: lease, stages: true, kind: 'submit' });
else if (!proofFiles.length) proof = { isGreen: true, output: '', seconds: 0, isCached: false, log: '' };
else {
const command = `${config.affectedTests.trimEnd()} ${proofFiles.map(path => commandWord('./' + path)).join(' ')}`;
@@ -682,7 +686,7 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
: selection.full ? 'full gate' : 'affected tests';
writeFileSync(log, `item check:\n${criterion.output}\n${phase}:\n${proof.output}`);
if (!proof.isGreen && onFailure) await onFailure(proof, { root,
- command: !deferFullFallback && selection.full ? config.gate : `${config.affectedTests.trimEnd()} ${proofFiles.map(path => commandWord('./' + path)).join(' ')}`, lease });
+ command: !deferFullFallback && selection.full ? fullConfig.gate : `${config.affectedTests.trimEnd()} ${proofFiles.map(path => commandWord('./' + path)).join(' ')}`, lease });
await recordRun(onFailure, proof);
return finish(proof);
}, { browser, gui, agent, item, kind, itemCheck: true, onWait });
@@ -695,7 +699,8 @@ export function deferredSelectionNote(files) {
/** 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';
+ const registry = gate.registryGuards?.length ? `; registry guards: ${gate.registryGuards.join(', ')}` : '';
+ const check = (gate.check.checked ? `item check ${gate.check.green ? 'green' : 'red'} in ${gate.check.seconds}s` : 'no item check') + registry;
if (gate.deferred) {
const reason = gate.reason ? `: ${gate.reason}` : '';
const timings = timingDigest(gate.profile);
@@ -707,7 +712,7 @@ export function submitGateReport(gate) {
: gate.deferredFiles
? `${invariants}${deferredSelectionNote(gate.deferredFiles)} (over submitDeferAbove ${gate.deferAbove}): ${gate.deferredFiles.join(', ')}`
: `affected tests: ${gate.files.length ? gate.files.join(', ') : 'none'}; full suite deferred to the landing gate${gate.submitInvariants?.length ? '; submit invariants: ' + gate.submitInvariants.join(', ') : ''}`;
- const result = invariantsOnly && !gate.submitInvariants?.length ? '' : `; ${gate.isGreen ? `${invariantsOnly ? 'submit invariants' : 'affected tests'} green in ${gate.seconds}s` : gateReport(gate)}`;
+ const result = invariantsOnly && !gate.submitInvariants?.length && !gate.registryGuards?.length ? '' : `; ${gate.isGreen ? `${invariantsOnly ? 'submit invariants and registry guards' : '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'}`;
diff --git a/src/help.js b/src/help.js
index 95a987c9..ee210c3a 100644
--- a/src/help.js
+++ b/src/help.js
@@ -136,6 +136,7 @@ Work
the command and its author print first; the project gate is pullboard gate
pullboard test <files> run named test files on the runner pool with the per-file timeout, uncommitted
changes included; a red file is compared with main and named known or new
+ --affected selects the change and its accepted registry guards; no files needed
pullboard check accept <id> the person accepts an item's check that already passes on main, as it reads now;
with checks.provesNothing "hold", claim and submit refuse that item until then
pullboard bar ready [on|off] coordinator: opt in to ready bars; existing frozen work needs no backfill
diff --git a/src/registry-guards.js b/src/registry-guards.js
new file mode 100644
index 00000000..ce872792
--- /dev/null
+++ b/src/registry-guards.js
@@ -0,0 +1,43 @@
+/** Accepted project registry obligations survive import-selection deferral [C7,V4,V16]. */
+import { git } from './git.js';
+
+/** A literal repository path, or an input glob using only *, ** and ?. */
+function projectPath(value, glob = false) {
+ return typeof value === 'string' && value.trim() === value && value.length > 0
+ && !/[:\\\p{Cc}]/u.test(value) && !/[\[\]{}]/u.test(value)
+ && (glob || !/[*?]/u.test(value))
+ && value.split('/').every(part => part && part !== '.' && part !== '..');
+}
+
+/** Reject ambiguous configuration rather than silently dropping a registry obligation. */
+export function registryGuardsProblem(rules) {
+ if (!Array.isArray(rules) || rules.some(rule => !rule || typeof rule !== 'object' || Array.isArray(rule)
+ || Object.keys(rule).some(key => !['inputs', 'tests'].includes(key))
+ || !Array.isArray(rule.inputs) || !rule.inputs.length || rule.inputs.some(path => !projectPath(path, true))
+ || !Array.isArray(rule.tests) || !rule.tests.length || rule.tests.some(path => !projectPath(path)))) {
+ return '"registryGuards" is a list of {inputs: [repository globs using *, ** or ?], tests: [literal repository test paths]}';
+ }
+ return null;
+}
+
+/** Match the entire repository-relative path, allowing recursive globs to cover no directories. */
+function matches(path, glob) {
+ const source = glob.split(/(\*\*\/|\*\*|\*|\?)/u).map(part => part === '**/' ? '(?:.*/)?' : part === '**' ? '.*'
+ : part === '*' ? '[^/]*' : part === '?' ? '[^/]' : part.replace(/[.+^$()|[\]{}\\]/gu, '\\$&')).join('');
+ return new RegExp(`^${source}$`, 'u').test(path);
+}
+
+/** Select from the same merge base as affected tests, retaining deletions and both sides of renames. */
+export function selectRegistryGuards(root, rules = [], { base, trunk, commit = 'HEAD', changed } = {}) {
+ if (!rules.length) return [];
+ if (trunk) {
+ const mergeBase = git(root, ['merge-base', trunk, commit]).trim();
+ const submitted = git(root, ['rev-parse', '--verify', `${commit}^{commit}`]).trim();
+ if (mergeBase !== submitted) base = mergeBase;
+ changed = undefined;
+ }
+ // No base is uncertainty, never evidence that none of the registries changed.
+ if (base) changed ??= git(root, ['diff', '--no-renames', '--name-only', '-z', base, commit]).split('\0').filter(Boolean);
+ return [...new Set(rules.filter(rule => !base || changed.some(path => rule.inputs.some(glob => matches(path, glob))))
+ .flatMap(rule => rule.tests))].sort();
+}
diff --git a/src/test-run.js b/src/test-run.js
index a75ba288..09e9f070 100644
--- a/src/test-run.js
+++ b/src/test-run.js
@@ -14,6 +14,9 @@ import {
sep,
} from 'node:path';
import { testsNeedBrowser } from './browser-admission.js';
+import { selectAffectedTests } from './affected-tests.js';
+import { selectRegistryGuards } from './registry-guards.js';
+import { mainPolicy } from './trusted-policy-read.js';
import {
runProfiledShellAsync,
withGateSlot,
@@ -22,7 +25,7 @@ import {
cleanGitEnvironment,
headCommit,
} from './git.js';
-import { testsNeedGui } from './gui-admission.js';
+import { projectNeedsGui, testsNeedGui } from './gui-admission.js';
import {
compareMainFailures,
withMainCheckout,
@@ -100,17 +103,31 @@ function localReason() {
*
* @returns {Promise<{ green: boolean, output: string, runner: string, seconds: number, files: string[], known: Array<{file: string, result: string}>, main: string|null }>}
*/
-export async function runTestFiles(root, config, files, { agent, onWait } = {}) {
+export async function runTestFiles(root, config, files, { agent, onWait, affected = false } = {}) {
+ if (affected && files.length) throw new Refused('USAGE', 'use pullboard test --affected without file arguments, or name the files without --affected');
+ const policy = affected ? mainPolicy(root) : null;
+ if (policy) config = policy.config;
if (typeof config.affectedTests !== 'string' || !config.affectedTests.trim()) {
throw new Refused('NO_TEST_RUNNER', 'set "affectedTests" in pullboard.json to the command that runs named test files, like "node bin/run-tests.js"');
}
- const paths = testFiles(root, files);
- const command = `${config.affectedTests.trimEnd()} ${paths.map((path) => shellWord('./' + path)).join(' ')}`;
+ let paths = affected ? [] : testFiles(root, files);
const started = Date.now();
const run = await inCleanCheckout(root, async (checkout) => {
- const browser = !browserFreeChecksEnabled() || await testsNeedBrowser(checkout, paths);
+ let full = false;
+ if (policy) {
+ const options = { base: policy.commit, trunk: policy.commit };
+ const selection = selectAffectedTests(checkout, options);
+ const guards = selectRegistryGuards(checkout, config.registryGuards, options);
+ full = selection.full;
+ paths = [...new Set([...(full ? [] : selection.files), ...guards])].sort();
+ if (paths.length) paths = testFiles(checkout, paths);
+ }
+ const focused = paths.length ? `${config.affectedTests.trimEnd()} ${paths.map(path => shellWord('./' + path)).join(' ')}` : '';
+ if (full && !config.gate?.trim()) throw new Refused('NO_TEST_RUNNER', 'affected selection needs the full project gate; set gate in accepted pullboard.json');
+ const command = full ? `(${config.gate})${focused ? ' && ' + focused : ''}` : (focused || 'true');
+ const browser = full || !browserFreeChecksEnabled() || await testsNeedBrowser(checkout, paths);
return withGateSlot(checkout, (lease) => runProfiledShellAsync(checkout, command, { gateLease: lease, waitMs: lease.waitMs }),
- { browser, gui: testsNeedGui(checkout, paths), shortEligible: true, agent, kind: 'test', onWait });
+ { browser, gui: full ? projectNeedsGui(checkout) : testsNeedGui(checkout, paths), shortEligible: !full, agent, kind: 'test', onWait });
});
const result = { green: run.isGreen, output: run.output, runner: run.executionRunner || 'this machine', seconds: Math.round((Date.now() - started) / 1000), files: paths, known: [], main: null,
...(run.executionRunner ? {} : { local: localReason() }) };