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(land): a waiver covers only its own kind, file or test name [B3,R3]

Corey Olson88160b49777b
diff --git a/src/board.js b/src/board.js
index defa39b6..e247f747 100644
--- a/src/board.js
+++ b/src/board.js
@@ -2707,7 +2707,7 @@ export function recordLandingWaiver(board, { agentId, channel, id, test, until,
throw new Refused('LAND_WAIVER', 'name a test, a future --until date and a nonempty --reason; run pullboard land --waive <test> --until <date> --reason "why"');
}
return atomic(board, () => {
- const waiver = { id, test, until: new Date(until).toISOString(), reason: reason.trim(), by: PERSON, channel };
+ const waiver = { id, test, kind: landingWaiverKind(test), until: new Date(until).toISOString(), reason: reason.trim(), by: PERSON, channel };
logEvent(board, PERSON, 'landing_waiver', null, { waiver });
return waiver;
});
@@ -2720,10 +2720,26 @@ export function landingWaivers(board) {
.map((row) => JSON.parse(row.event_detail).waiver);
}
+/**
+ * Name what a waiver argument is: a test file path, or a test's name. A path has no spaces and a
+ * source extension; anything else is a name. Earlier waivers carry no kind and are read the same way.
+ */
+export function landingWaiverKind(test) {
+ return /^[^\s]+\.(?:[cm]?[jt]sx?|py)$/u.test(test) ? 'file' : 'name';
+}
+
+/**
+ * True when a waiver covers one failure: a file waiver only its file, a name waiver only its name.
+ * Keeping the kinds apart stops a new test named like a waived file from riding that waiver [B3,R3].
+ */
+export function landingWaiverCovers(waiver, failure) {
+ return (waiver.kind ?? landingWaiverKind(waiver.test)) === 'file' ? waiver.test === failure.file : waiver.test === failure.name;
+}
+
/** Find a live person's waiver covering the exact failing file or test name [B3,R3]. */
export function landingWaiverFor(board, failure) {
return landingWaivers(board).findLast((waiver) => Date.parse(waiver.until) > board.clock.now().getTime()
- && (waiver.test === failure.file || waiver.test === failure.name)) ?? null;
+ && landingWaiverCovers(waiver, failure)) ?? null;
}
/** File one durable defect per flaky test and retain its source digest [B3,R3]. */
@@ -2760,7 +2776,7 @@ export function waivedLandingProof(board, tree) {
&& batch.proof.failures.every((failure) => {
const waiver = landingWaivers(board).find((entry) => entry.id === failure.waiver);
return waiver && Date.parse(waiver.until) > board.clock.now().getTime()
- && (waiver.test === failure.file || waiver.test === failure.name);
+ && landingWaiverCovers(waiver, failure);
})) ?? null;
}
diff --git a/src/cli.js b/src/cli.js
index b0f2b7d3..c98db6ed 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -2712,7 +2712,7 @@ function workCommands(io, args) {
const waiver = await ordered(ctx, board, 'recordLandingWaiver', [{ agentId: store.PERSON, channel: io.personChannel ?? 'terminal',
id: randomUUID(), test: values.waive, until: values.until, reason: values.reason }]);
io.result?.({ batch: null, landed: [], conflicts: [], blocked: [], culprits: [], flakes: [], waiver });
- io.say(`waived ${waiver.test} until ${waiver.until}: ${waiver.reason}`);
+ io.say(`waived ${waiver.kind} ${waiver.test} until ${waiver.until}: ${waiver.reason}`);
return 0;
}
if (values.until !== undefined || values.reason !== undefined || values.max !== undefined && (!/^[1-9][0-9]*$/u.test(values.max) || !Number.isSafeInteger(Number(values.max)))) throw new Refused('USAGE', 'use --max with a positive item count, or --waive with --until and --reason');
diff --git a/src/land.js b/src/land.js
index 42750a84..20476ec7 100644
--- a/src/land.js
+++ b/src/land.js
@@ -168,7 +168,7 @@ export function waivedFailures(board, failures) {
/** Name one waived failure with the person's waiver, its reason and its expiry [B3]. */
export function waiverLine(failure) {
const { waiver } = failure;
- return `waived: ${failure.name} (${failure.file}) by person waiver ${waiver.id} for ${waiver.test}: ${waiver.reason}; expires ${waiver.until}`;
+ return `waived: ${failure.name} (${failure.file}) by person waiver ${waiver.id} for ${waiver.kind ?? store.landingWaiverKind(waiver.test)} ${waiver.test}: ${waiver.reason}; expires ${waiver.until}`;
}
/** Record every failure's exact live waiver rather than changing which tests the gate runs. */
diff --git a/test/land.test.js b/test/land.test.js
index cab32ea9..f1d17ee3 100644
--- a/test/land.test.js
+++ b/test/land.test.js
@@ -104,7 +104,7 @@ function gateFixture(box) {
"fs.appendFileSync(trace, JSON.stringify({ alone, files }) + '\\n'); const fullRuns = fs.readFileSync(trace, 'utf8').trim().split('\\n').map(line => JSON.parse(line)).filter(row => !row.alone).length;",
"if (!alone && fs.existsSync(hold) && (fs.readFileSync(hold, 'utf8') === 'armed' || Number(fs.readFileSync(hold, 'utf8')) === fullRuns)) { fs.writeFileSync(entered, root); const end = Date.now() + 20000; while (!fs.existsSync(release) && Date.now() < end) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20); if (!fs.existsSync(release)) process.exit(24); }",
"console.log('TAP version 13'); let failed = 0;",
- "files.forEach((file, i) => { const text = fs.readFileSync(path.resolve(root, file), 'utf8'); const red = process.env.LAND_SUPPRESS_RED !== '1' && (text.includes('RED') || !alone && text.includes('FLAKE')); console.log('# Subtest: ' + file + ' keeps the landed behavior'); console.log((red ? 'not ok ' : 'ok ') + (i + 1) + ' - ' + file + ' keeps the landed behavior'); if (red) { failed++; console.log(' ---'); console.log(' location: ' + path.resolve(root, file) + ':1:1'); console.log(' failureType: testCodeFailure'); console.log(' error: fixture behavior is red'); console.log(' ...'); } });",
+ "files.forEach((file, i) => { const text = fs.readFileSync(path.resolve(root, file), 'utf8'); const red = process.env.LAND_SUPPRESS_RED !== '1' && (text.includes('RED') || !alone && text.includes('FLAKE')); const name = (/NAME:(\\S+)/.exec(text) || [])[1] || file + ' keeps the landed behavior'; console.log('# Subtest: ' + name); console.log((red ? 'not ok ' : 'ok ') + (i + 1) + ' - ' + name); if (red) { failed++; console.log(' ---'); console.log(' location: ' + path.resolve(root, file) + ':1:1'); console.log(' failureType: testCodeFailure'); console.log(' error: fixture behavior is red'); console.log(' ...'); } });",
"console.log('1..' + files.length); console.log('# tests ' + files.length); console.log('# pass ' + (files.length - failed)); console.log('# fail ' + failed); process.exitCode = failed ? 1 : 0;",
].join('\n'));
writeFileSync(checks, "const fs = require('node:fs'); const file = process.argv[2]; if (!fs.existsSync(file) || !fs.readFileSync(file, 'utf8').trim()) process.exit(1);\n");
@@ -690,7 +690,7 @@ test("a person's waiver lets a submit and a landing gate through only the waived
assert.equal(store.landingWaiverFor(board, { file: FILES[0], name: FILES[0] }), null, 'no attempt recorded a live waiver');
});
const waiver = json(box, box.repo, 'land', '--waive', FILES[0], '--until', '2099-01-01', '--reason', 'private flaky fixture tracked elsewhere').waiver;
- const line = new RegExp(`waived: .*\\(${FILES[0].replaceAll('.', '\\.')}\\) by person waiver ${waiver.id} for ${FILES[0].replaceAll('.', '\\.')}: private flaky fixture tracked elsewhere; expires 2099-01-01T00:00:00\\.000Z`, 'u');
+ const line = new RegExp(`waived: .*\\(${FILES[0].replaceAll('.', '\\.')}\\) by person waiver ${waiver.id} for file ${FILES[0].replaceAll('.', '\\.')}: private flaky fixture tracked elsewhere; expires 2099-01-01T00:00:00\\.000Z`, 'u');
const mixed = itemWorktree(box, 2);
assert.equal(commitFile(box, mixed.path, FILES[0], 'RED\n', `feat(web): build land fixture ${mixed.item} [G1]`).status, 0);
@@ -717,6 +717,17 @@ test("a person's waiver lets a submit and a landing gate through only the waived
assert.equal(landingJson.green, false, 'a waived landing gate is never reported green');
assert.deepEqual(landingJson.waived.map((entry) => [entry.file, entry.waiver]), [[FILES[0], waiver.id]]);
assert.notEqual(stampOf(box.repo), box.git(box.repo, 'rev-parse', 'HEAD^{tree}'), 'a waived landing gate writes no green stamp');
+ onBoard(box, (board) => {
+ assert.equal(store.landingWaiverFor(board, { file: FILES[2], name: FILES[0] }), null, 'a file waiver never covers a test merely named like that file');
+ store.recordLandingWaiver(board, { agentId: 'person', channel: 'terminal', id: 'name-waiver', test: 'keeps a named behavior', until: '2099-01-01', reason: 'named fixture' });
+ assert.equal(store.landingWaiverFor(board, { file: FILES[3], name: 'keeps a named behavior' })?.kind, 'name');
+ assert.equal(store.landingWaiverFor(board, { file: 'keeps a named behavior', name: 'another behavior' }), null, 'a name waiver covers only that name');
+ });
+ assert.equal(commitFile(box, box.repo, FILES[2], `RED NAME:${FILES[0]}\n`, 'chore: install a test named like the waived file').status, 0);
+ const spoofed = box.run(box.repo, 'gate', '--landing');
+ assert.equal(spoofed.code, 1, 'a failing test named like a waived file path still refuses');
+ assert.doesNotMatch(spoofed.out, /waived, not green/u);
+ assert.equal(commitFile(box, box.repo, FILES[2], 'PASS\n', 'chore: correct the spoofed fixture test').status, 0);
assert.equal(commitFile(box, box.repo, FILES[1], 'RED\n', 'chore: install a second failing fixture test').status, 0);
const refused = box.run(box.repo, 'gate', '--landing');
assert.equal(refused.code, 1, 'a failure with only an expired waiver refuses the landing gate');