diff --git a/docs/mutation-cache.md b/docs/mutation-cache.md index 2d6d493..0180ee1 100644 --- a/docs/mutation-cache.md +++ b/docs/mutation-cache.md @@ -96,6 +96,7 @@ exact lockfile with `npm ci --ignore-scripts`; we do not recursively hash `node_modules`. The only noninputs are named root documentation files, Markdown under `docs/`, +the prose files `fuzz/README.md` and `scripts/schemas/cyclonedx-1.5/README.md`, governance files, the four named runtime architecture scanner/test scripts and `tests/runtime-architecture/` fixtures, the Copilot instructions, and the parent `ci.yml`. These SAST-only files are not @@ -169,8 +170,10 @@ parser or artifact authentication client is maintained. Admission diagnostics distinguish `native-baseline-missing`, `native-baseline-incompatible`, `native-baseline-corrupt-or-unauditable`, and -`native-baseline-unreadable`. All four mean no admitted report and require fresh -full execution through the applicable route; none bypasses the gate. A compatible +`native-baseline-unreadable`. A rejected own-PR envelope can still fall back to +the already downloaded authenticated main baseline. If neither report is admitted, +fresh full execution is required through the applicable route; no rejection +bypasses the gate. A compatible report is logged as `native-same-input-reuse`. Explicit full mode, an unavailable input fingerprint, or a supplied `NODE_OPTIONS` is logged as `native-full-required`. @@ -184,6 +187,12 @@ used. Admission requires a successful restore with an exact cache hit, matching `prIdentity` and input key, and the existing report audit. The ordinary suite and native discovery/coverage still run; changed declared inputs still run full. +The own-PR report is preferred when admitted. If it fails admission, the runner +tries the already downloaded main envelope through the same key, source identity +and current-policy audit before selecting a cold route. A missing or invalid +authenticated main SHA cannot authorize this fallback. `audit.json` records the +source actually admitted: the main commit or the own-PR identity. + This is an **own-PR optimization, not authenticated producer provenance**. `prIdentity`/`audit.execution.baselinePR` name its scope; they are not a producing commit or a successful whole-CI attestation. A selected main artifact's SHA is @@ -199,9 +208,10 @@ With hosted routing enabled, an own-PR cache can be saved after a successful nat run that admitted a compatible baseline; the matrix does not seed it. Restore/save failures, eviction, partial/corrupt files or incompatible reports -fall back to full execution. Native caches are immutable: an unusable exact-key -entry cannot be repaired in place and may remain cold until eviction or a -reviewed key-namespace change. No cache failure skips tests or weakens the gate. +require full execution only when no compatible baseline is admitted. Native +caches are immutable: an unusable exact-key entry cannot be repaired in place, +but it does not prevent reuse of an authenticated compatible main baseline. +No cache failure skips tests or weakens the gate. See GitHub's [cache-scope restrictions](https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache). The new envelope is not compatible with the old schema3 cache. The first hosted diff --git a/scripts/mutation-cache-inputs.mjs b/scripts/mutation-cache-inputs.mjs index b00f74d..91724e7 100644 --- a/scripts/mutation-cache-inputs.mjs +++ b/scripts/mutation-cache-inputs.mjs @@ -16,6 +16,8 @@ export function isMutationInput(path) { path === 'node_modules' || passive.test(path) || /^docs\/.*\.md$/.test(path) || + path === 'fuzz/README.md' || + path === 'scripts/schemas/cyclonedx-1.5/README.md' || path.startsWith('governance/') || path.startsWith('tests/runtime-architecture/') || architectureOnly.has(path) || diff --git a/scripts/mutation-cache.test.mjs b/scripts/mutation-cache.test.mjs index 9660b2f..7e51a28 100644 --- a/scripts/mutation-cache.test.mjs +++ b/scripts/mutation-cache.test.mjs @@ -56,6 +56,13 @@ function selectRunnerPolicy(source) { ts.isCallExpression(statement.expression.expression) && statement.expression.expression.expression.getText(parsed); const guards = statements.filter(ts.isIfStatement); + const callsReadCache = (node) => + (ts.isCallExpression(node) && node.expression.getText(parsed) === 'readCache') || + ts.forEachChild(node, callsReadCache); + const fallback = guards.filter(callsReadCache); + assert.equal(fallback.length, 1, 'Expected one main-baseline fallback guard'); + assert.ok(admission.at(-1).end < fallback[0].end); + admission.push(fallback[0]); const promotion = guards.filter( (statement) => callName(statement.thenStatement) === 'promoteCache', ); @@ -409,13 +416,13 @@ test('the runner admission policy fragment distinguishes full mode, PR hits and MUTATION_PR_CACHE_RESTORED: 'true', }; for (const [delta, args, expected] of [ - [{}, [], 'pr:42:7'], - [{ MUTATION_PR_CACHE_RESTORED: 'false' }, [], commit], - [{ MUTATION_PR_CACHE_RESTORED: '' }, [], commit], - [{ GITHUB_EVENT_NAME: 'push' }, [], commit], - [{ GITHUB_EVENT_NAME: 'pull_request_target' }, [], commit], - [{ GITHUB_REF: 'refs/heads/release' }, [], commit], - [{}, ['--full'], null], + [{}, [], ['pr:42:7', commit]], + [{ MUTATION_PR_CACHE_RESTORED: 'false' }, [], [commit]], + [{ MUTATION_PR_CACHE_RESTORED: '' }, [], [commit]], + [{ GITHUB_EVENT_NAME: 'push' }, [], [commit]], + [{ GITHUB_EVENT_NAME: 'pull_request_target' }, [], [commit]], + [{ GITHUB_REF: 'refs/heads/release' }, [], [commit]], + [{}, ['--full'], []], ]) { const calls = []; await runInNewContext( @@ -437,7 +444,7 @@ test('the runner admission policy fragment distinguishes full mode, PR hits and ); assert.deepEqual( calls.map((values) => values[2]), - expected ? [expected] : [], + expected, ); } }); diff --git a/scripts/mutation-editorial-inputs.test.mjs b/scripts/mutation-editorial-inputs.test.mjs new file mode 100644 index 0000000..44e6a9d --- /dev/null +++ b/scripts/mutation-editorial-inputs.test.mjs @@ -0,0 +1,43 @@ +import assert from 'node:assert/strict'; +import { execFileSync } from 'node:child_process'; +import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { dirname, join } from 'node:path'; +import { test } from 'node:test'; +import { fingerprint, mutationInputs } from './mutation-cache-inputs.mjs'; + +test('only the two proven editorial paths preserve the mutation input key', async (t) => { + const root = await mkdtemp(join(tmpdir(), 'mutation-editorial-')); + t.after(() => rm(root, { recursive: true, force: true })); + execFileSync('git', ['init', '-q', root]); + const cases = [ + ['fuzz/README.md', true], + ['scripts/schemas/cyclonedx-1.5/README.md', true], + ['fuzz/seeds/raw/example.bin', false], + ['fuzz/regressions/raw/example.bin', false], + ['scripts/schemas/cyclonedx-1.5/bom-1.5.schema.json', false], + ['scripts/schemas/cyclonedx-1.5/spdx.schema.json', false], + ['scripts/schemas/cyclonedx-1.5/jsf-0.82.schema.json', false], + ['fuzz/NOTES.md', false], + ['scripts/schemas/cyclonedx-1.5/NOTES.md', false], + ['src/README.md', false], + ]; + for (const [path] of cases) { + await mkdir(dirname(join(root, path)), { recursive: true }); + await writeFile(join(root, path), 'initial'); + } + const capture = async () => fingerprint(await mutationInputs(root, {}, {})); + const before = await capture(); + for (const [path, editorial] of cases) { + await t.test(path, async () => { + await writeFile(join(root, path), 'changed'); + try { + const after = await capture(); + if (editorial) assert.equal(after, before); + else assert.notEqual(after, before); + } finally { + await writeFile(join(root, path), 'initial'); + } + }); + } +}); diff --git a/scripts/mutation-routing.test.mjs b/scripts/mutation-routing.test.mjs index e0e787b..88e935f 100644 --- a/scripts/mutation-routing.test.mjs +++ b/scripts/mutation-routing.test.mjs @@ -33,6 +33,8 @@ const report = { files: { 'src/mp3/example.ts': { mutants: [{ status: 'Killed', duration: 0 }] } }, testFiles: {}, }; +const prReport = { ...report, cacheSource: 'own-pr' }; +const mainReport = { ...report, cacheSource: 'authenticated-main' }; const summary = { rawScore: 100, adjustedScore: 100, @@ -69,18 +71,27 @@ async function fixture(t, options = {}) { await writeFile(outputPath, ''); const env = { ...prEnv, GITHUB_OUTPUT: outputPath, ...options.env }; const identity = env.MUTATION_PR_CACHE_RESTORED === 'true' ? pullRequestIdentity(env) : commit; - const baselinePath = join(root, identity?.startsWith('pr:') ? PR_BASELINE : BASELINE); - if (options.cache) { - await promoteCache(root, report, key, identity); + for (const [cache, cacheIdentity, cachedReport] of [ + [options.cache, identity, options.cacheReport ?? report], + [options.mainCache, options.mainIdentity ?? commit, mainReport], + ]) { + if (!cache) continue; + const baselinePath = join(root, cacheIdentity?.startsWith('pr:') ? PR_BASELINE : BASELINE); + await promoteCache(root, cachedReport, key, cacheIdentity); const envelope = JSON.parse(await readFile(baselinePath, 'utf8')); - if (options.cache === 'incompatible') envelope.key = 'f'.repeat(64); - if (options.cache === 'unauditable') envelope.report = { valid: false }; - await writeFile( - baselinePath, - options.cache === 'corrupt' ? '{partial' : JSON.stringify(envelope), - ); + if (cache === 'incompatible') envelope.key = 'f'.repeat(64); + if (cache === 'unauditable') envelope.report = { valid: false }; + await writeFile(baselinePath, cache === 'corrupt' ? '{partial' : JSON.stringify(envelope)); } - const calls = { discovery: 0, processes: [], promotions: [], ended: 0 }; + const calls = { + discovery: 0, + processes: [], + promotions: [], + reads: [], + audits: [], + workingReports: [], + ended: 0, + }; const messages = []; const processState = { argv: ['node', 'run-mutations.mjs', ...(options.args ?? ['--parallel-fallback'])], @@ -128,10 +139,14 @@ async function fixture(t, options = {}) { fingerprint, sourceContext, pullRequestIdentity, - readCache, + readCache: async (...values) => { + calls.reads.push(values[2]); + return readCache(...values); + }, executionSummary, - auditMutations: (value) => { - if (!value?.valid) throw new Error('audit rejected report'); + auditMutations: (value, _policy, _sources, auditOptions) => { + calls.audits.push({ value, options: auditOptions }); + if (!value?.valid || options.auditFailure) throw new Error('audit rejected report'); return summary; }, verifyParserTestDiscovery: async () => { @@ -141,8 +156,15 @@ async function fixture(t, options = {}) { runMutationProcess: async (command, args) => { calls.processes.push({ command, args: Array.from(args) }); if (options.processFailure) throw new Error('native execution failed'); - if (command.endsWith('stryker.js')) - await writeFile(join(root, 'reports/mutation/mutation.json'), JSON.stringify(report)); + if (command.endsWith('stryker.js')) { + if (!args.includes('--force')) + calls.workingReports.push(JSON.parse(await readFile(join(root, WORKING_REPORT), 'utf8'))); + if (options.strykerFailure) throw new Error('native Stryker execution failed'); + await writeFile( + join(root, 'reports/mutation/mutation.json'), + JSON.stringify(options.executionReport ?? report), + ); + } }, promoteCache: async (...values) => { calls.promotions.push(values[3]); @@ -242,6 +264,200 @@ for (const restored of ['false', 'true']) assert.deepEqual(JSON.parse(await readFile(join(result.root, WORKING_REPORT), 'utf8')), report); }); +for (const cache of [undefined, 'incompatible', 'corrupt', 'unauditable']) + test(`rejected own-PR ${cache ?? 'missing'} cache falls back to authenticated main`, async (t) => { + const result = await fixture(t, { + cache, + cacheReport: prReport, + mainCache: 'valid', + env: { MUTATION_PR_CACHE_RESTORED: 'true' }, + }); + assert.equal(result.exitCode, 0); + assert.equal(result.route, 'route=native\n'); + assert.deepEqual(result.calls.reads, ['pr:42:7', commit]); + assert.equal(result.calls.discovery, 1); + assert.deepEqual( + result.calls.processes.map(({ args }) => args), + [['run', '--no-fsModuleCache'], ['run']], + ); + assert.deepEqual(result.calls.workingReports, [mainReport]); + assert.deepEqual( + JSON.parse(await readFile(join(result.root, WORKING_REPORT), 'utf8')), + mainReport, + ); + const audit = JSON.parse( + await readFile(join(result.root, 'reports/mutation/audit.json'), 'utf8'), + ); + assert.equal(audit.execution.mode, 'incremental'); + assert.equal(audit.execution.cacheReason, 'native-same-input-reuse'); + assert.equal(audit.execution.baselineCommit, commit); + assert.equal(audit.execution.baselinePR, null); + assert.deepEqual(result.calls.promotions, ['pr:42:7']); + const promoted = JSON.parse(await readFile(join(result.root, PR_BASELINE), 'utf8')); + assert.deepEqual(promoted.report, report); + assert.equal(promoted.prIdentity, 'pr:42:7'); + await assert.rejects(readFile(join(result.root, BASELINE)), { code: 'ENOENT' }); + }); + +test('admitted own-PR cache stays preferred without reading authenticated main', async (t) => { + const result = await fixture(t, { + cache: 'valid', + cacheReport: prReport, + mainCache: 'valid', + env: { MUTATION_PR_CACHE_RESTORED: 'true' }, + }); + assert.equal(result.exitCode, 0); + assert.equal(result.route, 'route=native\n'); + assert.deepEqual(result.calls.reads, ['pr:42:7']); + assert.deepEqual(result.calls.workingReports, [prReport]); + const audit = JSON.parse( + await readFile(join(result.root, 'reports/mutation/audit.json'), 'utf8'), + ); + assert.equal(audit.execution.baselineCommit, null); + assert.equal(audit.execution.baselinePR, 'pr:42:7'); +}); + +for (const mainCache of [undefined, 'incompatible', 'corrupt', 'unauditable']) + test(`rejected own-PR and ${mainCache ?? 'missing'} main caches stay cold`, async (t) => { + const result = await fixture(t, { + cache: 'corrupt', + mainCache, + env: { MUTATION_PR_CACHE_RESTORED: 'true' }, + }); + assert.equal(result.exitCode, 0); + assert.equal(result.route, 'route=full-sharded\n'); + assert.deepEqual(result.calls.reads, ['pr:42:7', commit]); + assert.equal(result.calls.discovery, 0); + assert.deepEqual(result.calls.processes, []); + assert.deepEqual(result.calls.promotions, []); + for (const path of [BASELINE, PR_BASELINE, WORKING_REPORT, 'reports/mutation/audit.json']) + await assert.rejects(readFile(join(result.root, path)), { code: 'ENOENT' }); + }); + +for (const sha of [undefined, '', 'unknown', 'A'.repeat(40), 'local', 'pr:42:7']) + test(`own-PR fallback never reads main without a trusted SHA: ${String(sha)}`, async (t) => { + const result = await fixture(t, { + cache: 'corrupt', + mainCache: 'valid', + mainIdentity: sha === 'local' ? 'local' : commit, + env: { MUTATION_PR_CACHE_RESTORED: 'true', MUTATION_BASELINE_SHA: sha }, + }); + assert.equal(result.exitCode, 0); + assert.equal(result.route, 'route=full-sharded\n'); + assert.deepEqual(result.calls.reads, ['pr:42:7']); + assert.deepEqual(result.calls.audits, []); + assert.deepEqual(result.calls.processes, []); + const routing = JSON.parse( + await readFile(join(result.root, 'reports/mutation/routing.json'), 'utf8'), + ); + assert.equal(routing.cacheReason, 'native-baseline-corrupt-or-unauditable'); + }); + +test('own-PR fallback rejects a main envelope from a different authenticated SHA', async (t) => { + const result = await fixture(t, { + cache: 'corrupt', + mainCache: 'valid', + env: { MUTATION_PR_CACHE_RESTORED: 'true', MUTATION_BASELINE_SHA: 'd'.repeat(40) }, + }); + assert.equal(result.exitCode, 0); + assert.equal(result.route, 'route=full-sharded\n'); + assert.deepEqual(result.calls.reads, ['pr:42:7', 'd'.repeat(40)]); + assert.deepEqual(result.calls.audits, []); + assert.deepEqual(result.calls.processes, []); + const routing = JSON.parse( + await readFile(join(result.root, 'reports/mutation/routing.json'), 'utf8'), + ); + assert.equal(routing.cacheReason, 'native-baseline-incompatible'); +}); + +test('own-PR fallback rechecks current audit and fails closed for both reports', async (t) => { + const result = await fixture(t, { + cache: 'valid', + cacheReport: prReport, + mainCache: 'valid', + auditFailure: true, + env: { MUTATION_PR_CACHE_RESTORED: 'true' }, + }); + assert.equal(result.exitCode, 0); + assert.equal(result.route, 'route=full-sharded\n'); + assert.deepEqual(result.calls.reads, ['pr:42:7', commit]); + assert.deepEqual( + result.calls.audits.map(({ value }) => value), + [prReport, mainReport], + ); + assert.ok(result.calls.audits.every(({ options }) => options.nativeReuse === true)); + assert.deepEqual(result.calls.processes, []); + assert.deepEqual(result.calls.promotions, []); + await assert.rejects(readFile(join(result.root, 'reports/mutation/audit.json')), { + code: 'ENOENT', + }); +}); + +for (const options of [{ args: ['--full'] }, { nodeOptions: true }, { inputFailure: true }]) + test(`forced paths never reuse own-PR or main fallback: ${JSON.stringify(options)}`, async (t) => { + const result = await fixture(t, { + cache: 'corrupt', + mainCache: 'valid', + env: { MUTATION_PR_CACHE_RESTORED: 'true' }, + ...options, + }); + assert.equal(result.exitCode, 0); + assert.deepEqual(result.calls.reads, []); + assert.deepEqual(result.calls.workingReports, []); + if (options.args) { + assert.equal(result.route, ''); + assert.deepEqual(result.calls.processes[1].args, ['run', '--force']); + const audit = JSON.parse( + await readFile(join(result.root, 'reports/mutation/audit.json'), 'utf8'), + ); + assert.equal(audit.execution.mode, 'full'); + assert.equal(audit.execution.baselineCommit, null); + assert.equal(audit.execution.baselinePR, null); + } else { + assert.equal(result.route, 'route=full-sharded\n'); + assert.deepEqual(result.calls.processes, []); + } + assert.deepEqual(result.calls.promotions, []); + }); + +test('native failure after own-PR fallback never launches a second campaign', async (t) => { + const result = await fixture(t, { + cache: 'corrupt', + mainCache: 'valid', + strykerFailure: true, + env: { MUTATION_PR_CACHE_RESTORED: 'true' }, + }); + assert.equal(result.exitCode, 1); + assert.equal(result.route, 'route=native\n'); + assert.deepEqual(result.calls.reads, ['pr:42:7', commit]); + assert.equal(result.calls.discovery, 1); + assert.deepEqual( + result.calls.processes.map(({ args }) => args), + [['run', '--no-fsModuleCache'], ['run']], + ); + assert.deepEqual(result.calls.workingReports, [mainReport]); + assert.deepEqual(result.calls.promotions, []); + for (const path of [BASELINE, PR_BASELINE, 'reports/mutation/audit.json']) + await assert.rejects(readFile(join(result.root, path)), { code: 'ENOENT' }); +}); + +test('current report audit rejection after own-PR fallback prevents promotion', async (t) => { + const result = await fixture(t, { + cache: 'corrupt', + mainCache: 'valid', + executionReport: { ...report, valid: false }, + env: { MUTATION_PR_CACHE_RESTORED: 'true' }, + }); + assert.equal(result.exitCode, 1); + assert.equal(result.route, 'route=native\n'); + assert.deepEqual(result.calls.workingReports, [mainReport]); + assert.equal(result.calls.processes.length, 2); + assert.deepEqual(result.calls.promotions, []); + assert.ok(result.messages.some((message) => message.includes('audit rejected report'))); + for (const path of [BASELINE, PR_BASELINE, 'reports/mutation/audit.json']) + await assert.rejects(readFile(join(result.root, path)), { code: 'ENOENT' }); +}); + test('cold main push runs native full and promotes the trusted sequential report', async (t) => { const result = await fixture(t, { env: { GITHUB_EVENT_NAME: 'push', GITHUB_REF: 'refs/heads/main', GITHUB_SHA: commit }, diff --git a/scripts/native-mutation.integration.mjs b/scripts/native-mutation.integration.mjs index 8129310..9adfc30 100644 --- a/scripts/native-mutation.integration.mjs +++ b/scripts/native-mutation.integration.mjs @@ -23,6 +23,11 @@ const files = { 'package.json': '{"type":"module"}', 'package-lock.json': '{"lockfileVersion":3}', 'docs/mutation-review.md': 'Editorial review notes\n', + 'fuzz/README.md': 'Fuzzing instructions\n', + 'scripts/schemas/cyclonedx-1.5/README.md': 'Schema provenance notes\n', + 'scripts/schemas/cyclonedx-1.5/bom-1.5.schema.json': '{"type":"object"}', + 'fuzz/seeds/raw/example.bin': Buffer.from([0, 1]), + 'fuzz/regressions/raw/example.bin': Buffer.from([1, 0]), 'mutation-equivalents.json': '{"approvals":[]}', 'source.js': 'export const positive = value => value > 0;\n', 'helper.js': 'export const select = values => values;\n', @@ -53,8 +58,10 @@ test('boundaries', () => { }; async function campaign(root, name, baseline, change = {}, force = false) { - for (const [path, value] of Object.entries({ ...files, ...change })) + for (const [path, value] of Object.entries({ ...files, ...change })) { + await mkdir(dirname(join(root, path)), { recursive: true }); await writeFile(join(root, path), value); + } const key = fingerprint(await mutationInputs(root, {}, {})); if (baseline) await promoteCache(root, baseline.report, baseline.key, 'local'); const cached = force ? { report: null } : await readCache(root, key, 'local', () => {}); @@ -98,13 +105,18 @@ test( execFileSync('git', ['init', '-q', root]); await symlink(join(repo, 'node_modules'), join(root, 'node_modules')); await mkdir(join(root, '.cache/mutation'), { recursive: true }); - await mkdir(join(root, 'docs'), { recursive: true }); const cold = await campaign(root, 'cold'); + assert.equal(cold.execution.total, 5); assert.ok(cold.execution.executed > 0); assert.equal(cold.execution.reused, 0); for (const [name, change] of [ ['unchanged', {}], ['review', { 'docs/mutation-review.md': 'Updated editorial review notes\n' }], + ['fuzz-readme', { 'fuzz/README.md': 'Updated fuzzing instructions\n' }], + [ + 'schema-readme', + { 'scripts/schemas/cyclonedx-1.5/README.md': 'Updated schema provenance notes\n' }, + ], ]) { const warm = await campaign(root, name, cold, change); assert.equal(warm.key, cold.key); @@ -117,6 +129,9 @@ test( assert.deepEqual(outcomes(forced.report), outcomes(cold.report)); const changes = { proof: { 'mutation-equivalents.json': '{"approvals":[{"changed":true}]}' }, + schema: { 'scripts/schemas/cyclonedx-1.5/bom-1.5.schema.json': '{"type":"array"}' }, + 'fuzz-seed': { 'fuzz/seeds/raw/example.bin': Buffer.from([0, 2]) }, + 'fuzz-regression': { 'fuzz/regressions/raw/example.bin': Buffer.from([2, 0]) }, source: { 'source.js': files['source.js'] + '// source changed\n' }, helper: { 'helper.js': 'export const select = values => values.filter(([n]) => n !== 0);' }, fixture: { 'values.json': '[[-1,false],[1,true]]' }, diff --git a/scripts/run-mutations.mjs b/scripts/run-mutations.mjs index c8abaf0..8b24f52 100644 --- a/scripts/run-mutations.mjs +++ b/scripts/run-mutations.mjs @@ -89,15 +89,25 @@ mutationRun: try { const force = args.includes('--full') || Boolean(env.NODE_OPTIONS) || !inputsHash; const routingIdentity = pullRequestIdentity(process.env); const prIdentity = force ? null : routingIdentity; - const sourceIdentity = + let sourceIdentity = prIdentity && process.env.MUTATION_PR_CACHE_RESTORED === 'true' ? prIdentity : process.env.GITHUB_ACTIONS === 'true' ? process.env.MUTATION_BASELINE_SHA : 'local'; - const cache = force + let cache = force ? { report: null, reason: 'native-full-required' } : await readCache(root, inputsHash, sourceIdentity, audit); + if ( + !force && + !cache.report && + prIdentity && + sourceIdentity === prIdentity && + /^[a-f0-9]{40}$/.test(process.env.MUTATION_BASELINE_SHA ?? '') + ) { + sourceIdentity = process.env.MUTATION_BASELINE_SHA; + cache = await readCache(root, inputsHash, sourceIdentity, audit); + } await mkdir(dirname(join(root, WORKING_REPORT)), { recursive: true }); if (cache.report) await writeFile(join(root, WORKING_REPORT), JSON.stringify(cache.report)); // CI transport files are not proof of successful promotion by this invocation.