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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(flakes): a paired or main remote receipt needs both facts [C7]
Corey Olson9ecd5806a30d
diff --git a/src/native-flakes.js b/src/native-flakes.jsindex cf142d40..754bd6c2 100644--- a/src/native-flakes.js+++ b/src/native-flakes.js@@ -175,9 +175,9 @@ function privateProbe(root, commit, command, lease, policyCommit) {* execution host's load, and the pinned main this run used (#925). A missing fact is never guessed or replaced by a* local measurement.*/-function remoteGap(run, pin) {- if (!run.executionLoad) return 'The remote receipt does not carry the execution host\'s load; the red remains unclassified, never guessed.';- if (!pin.main || run.executionMain !== pin.main) return 'The remote receipt does not name the pinned main this run used; the red remains unclassified, never guessed.';+function remoteGap(run, pin, receipt = 'remote') {+ if (!run.executionLoad) return `The ${receipt} receipt does not carry the execution host's load; the red remains unclassified, never guessed.`;+ if (!pin.main || run.executionMain !== pin.main) return `The ${receipt} receipt does not name the pinned main this run used; the red remains unclassified, never guessed.`;return null;}@@ -236,17 +236,24 @@ async function observeFailure({ root, config, pin, run, command, lease, kind, reconst pairRun = pin.privateCheck ? privateProbe(root, pin.head, selected, lease, pin.main ?? pin.head): runProfiledShell(root, selected, { gateLease: lease });paired = saveReceipt(directory, id, 'paired', pairRun);- const pairResult = pairRun.unverified ? null : targetResult(pairRun, root, failure.name);+ // Every remote receipt a classification rests on carries both facts, the paired rerun's and main's included; a+ // probe that ran in a local private copy has no remote receipt to check.+ const gaps = [];+ const pairGap = pairRun.executionRunner ? remoteGap(pairRun, pin, 'paired remote') : null;+ if (pairGap) gaps.push(pairGap);+ const pairResult = pairRun.unverified || pairGap ? null : targetResult(pairRun, root, failure.name);let mainResult = pin.main === pin.head ? false : null;if (pin.main && pin.main !== pin.head && committedTest(root, pin.main, failure.file)) {const mainRun = privateProbe(root, pin.main, selected, lease, pin.main);mainReceipt = saveReceipt(directory, id, 'main', mainRun);- mainResult = mainRun.unverified ? null : targetResult(mainRun, root, failure.name);+ const mainGap = mainRun.executionRunner ? remoteGap(mainRun, pin, 'main remote') : null;+ if (mainGap) gaps.push(mainGap);+ mainResult = mainRun.unverified || mainGap ? null : targetResult(mainRun, root, failure.name);}if (mainResult === true) { classification = 'possible-regression'; reason = 'The exact target passes on pinned main; this candidate failure is not a flake observation.'; }else if (pairResult === true && mainResult === false) { classification = 'flake'; reason = 'The red target passed its one paired rerun at the same pinned head; original red retained.'; }else if (pairResult === false) { classification = 'stable-red'; reason = 'The target remains red in its one paired rerun; original red retained.'; }- else reason = 'A probe did not establish the exact target at its pinned source; it remains unclassified.';+ else reason = gaps[0] ?? 'A probe did not establish the exact target at its pinned source; it remains unclassified.';invalidateGitFacts();if (!pin.privateCheck && (headCommit(root) !== pin.head || headTree(root) !== pin.tree || !isClean(root) || untracked(root).length > 0)) {classification = 'unclassified'; reason = 'The source changed during diagnostics; no unchanged-head classification is claimed.';diff --git a/test/runners.test.js b/test/runners.test.jsindex c290b47c..57cd1b86 100644--- a/test/runners.test.js+++ b/test/runners.test.js@@ -1916,7 +1916,7 @@ test('a refused runner checkout names its failed Git step and stderr [C6,C7]', a});test('a red on a registered runner gets its paired rerun and ledger entry, or stays unclassified without the host load [C7]', { timeout: 300_000 }, async (t) => {- for (const mode of ['remote-load', 'no-load']) await t.test(mode, async () => {+ for (const mode of ['remote-load', 'no-load', 'paired-no-load']) await t.test(mode, async () => {const helper = createE2eHelpers();t.after(helper.cleanup);const box = helper.project('true');@@ -1935,11 +1935,14 @@ test('remote flaky case', () => { const n = existsSync(${JSON.stringify(runs)})writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ ...config, gate: 'node bin/run-tests.js test/flaky.test.js', flakes: { rerun: true } }) + '\n');box.git(repo, 'add', '-A');box.git(repo, 'commit', '-q', '-m', 'test: a remote flaky fixture');- // The worker either reports a known load, or (as an older worker would) a receipt without one.+ // The worker reports a known load, or (as an older worker would) a receipt without one: on every run, or only on+ // the paired rerun, whose receipt the classification rests on too (#925). A marker file spans worker processes.const preload = join(box.dir, 'worker-preload.mjs');+ const firstReceipt = join(box.dir, 'first-receipt-seen');+ const strip = mode === 'no-load' ? 'true' : `existsSync(${JSON.stringify(firstReceipt)}) || (writeFileSync(${JSON.stringify(firstReceipt)}, ''), false)`;writeFileSync(preload, mode === 'remote-load'? "import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const os = require('node:os'); os.loadavg = () => [7.25, 7.25, 7.25]; require('node:module').syncBuiltinESMExports();\n"- : "const write = process.stderr.write.bind(process.stderr); process.stderr.write = (chunk, ...rest) => { const text = String(chunk); const match = /^(PULLBOARD_RUNNER_RESULT \\S+ )(\\S+)\\n$/u.exec(text); if (!match) return write(chunk, ...rest); const body = JSON.parse(Buffer.from(match[2], 'base64').toString('utf8')); delete body.load; return write(match[1] + Buffer.from(JSON.stringify(body)).toString('base64') + '\\n', ...rest); };\n");+ : "import { existsSync, writeFileSync } from 'node:fs'; const write = process.stderr.write.bind(process.stderr); process.stderr.write = (chunk, ...rest) => { const text = String(chunk); const match = /^(PULLBOARD_RUNNER_RESULT \\S+ )(\\S+)\\n$/u.exec(text); if (!match) return write(chunk, ...rest); const body = JSON.parse(Buffer.from(match[2], 'base64').toString('utf8')); if (" + strip + ") delete body.load; return write(match[1] + Buffer.from(JSON.stringify(body)).toString('base64') + '\\n', ...rest); };\n");installSshStandIn({ bin: fixtureBin, worker, home: remoteHome, machineHome: remoteMachineHome, requests: join(box.dir, 'requests.jsonl'), nodeOptions: '--import=' + pathToFileURL(preload).href });assert.equal(cli(repo, env, 'settings', 'gateSlots', '1', '--json').status, 0);const registered = cli(repo, env, 'runner', 'add', HOST, '--slots', '1', '--browser', '1', '--json');@@ -1962,10 +1965,14 @@ test('remote flaky case', () => { const n = existsSync(${JSON.stringify(runs)})assert.equal(observation.classification, 'flake', observation.reason);assert.deepEqual(observation.load.average, [7.25, 7.25, 7.25], 'the execution host\'s load is recorded, not the controller\'s');assert.equal(observation.paired?.green, true, 'the one paired rerun ran and passed');- } else {+ } else if (mode === 'no-load') {assert.equal(observation.classification, 'unclassified');assert.match(observation.reason, /does not carry the execution host's load/u);assert.equal(observation.paired, null, 'no rerun is guessed without the host load');+ } else {+ assert.equal(observation.paired?.green, true, 'the paired rerun ran and passed, but its receipt lacks the host load');+ assert.equal(observation.classification, 'unclassified', 'a green pair without its host load never makes a flake: ' + observation.reason);+ assert.match(observation.reason, /paired remote receipt does not carry the execution host's load/u);}});});