From 9e61adb2d5fdd32b17f0a7dc8e709e241bfab7ea Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Tue, 27 Oct 2026 11:27:30 +0000 Subject: [PATCH] fix: exclude retry tests from scenario traces --- gitnexus/test/unit/scenario-map/cli.test.ts | 25 +++++++++++++++++++ .../scenario-map/coverage-records.test.ts | 14 +++++++++++ .../path-coverage/run-coverage.ts | 5 ++++ gitnexus/tools/scenario-map/scenario-map.ts | 22 ++++++++++------ 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/gitnexus/test/unit/scenario-map/cli.test.ts b/gitnexus/test/unit/scenario-map/cli.test.ts index c7c925c1f..727f9904d 100644 --- a/gitnexus/test/unit/scenario-map/cli.test.ts +++ b/gitnexus/test/unit/scenario-map/cli.test.ts @@ -89,6 +89,31 @@ import { const temps: string[] = []; describe('trace selection', () => { + it.each(['none', 'possible-duplicates', 'all'] as const)( + 'excludes configured retries from %s traces even when coverage passed', + (mutation) => { + const pairs = [ + { a: 'a', b: 'b' }, + { a: 'a', b: 'retry' }, + { a: 'a', b: 'failed' }, + { a: 'a', b: 'failed-retry' }, + ]; + expect( + passingTracePairs( + [ + { id: 'a', state: 'passed', retry: 0 }, + { id: 'b', state: 'passed' }, + { id: 'retry', state: 'passed', retry: 1 }, + { id: 'failed', state: 'failed' }, + { id: 'failed-retry', state: 'failed', retry: 2 }, + ], + pairs, + mutation, + ), + ).toEqual(mutation === 'all' ? [pairs[0], pairs[2]] : [pairs[0]]); + }, + ); + it('keeps non-passing coverage tests out of the shared trace without losing valid pairs', () => { const pairs = [ { a: 'a', b: 'b' }, diff --git a/gitnexus/test/unit/scenario-map/coverage-records.test.ts b/gitnexus/test/unit/scenario-map/coverage-records.test.ts index bdd7e4629..40d6a01ee 100644 --- a/gitnexus/test/unit/scenario-map/coverage-records.test.ts +++ b/gitnexus/test/unit/scenario-map/coverage-records.test.ts @@ -351,6 +351,20 @@ describe('isNativeEntry', () => { }); describe('buildWorkFile: concurrent and unrun tests', () => { + it.each([ + { retry: undefined, expected: 0 }, + { retry: 0, expected: 0 }, + { retry: 1, expected: 1 }, + { retry: { count: 2 }, expected: 2 }, + { retry: {}, expected: 0 }, + ])( + 'records configured retries ($retry) independently of observed attempts', + ({ retry, expected }) => { + const file = work([], [rt('t', 't', 3, { retry })]); + expect(file.tests[0]).toMatchObject({ state: 'passed', retry: expected, attempts: 0 }); + }, + ); + const record = new FileRun() .load() .start('c1', ['f'], [], true) diff --git a/gitnexus/tools/scenario-map/path-coverage/run-coverage.ts b/gitnexus/tools/scenario-map/path-coverage/run-coverage.ts index 429a7ea51..1c4842632 100644 --- a/gitnexus/tools/scenario-map/path-coverage/run-coverage.ts +++ b/gitnexus/tools/scenario-map/path-coverage/run-coverage.ts @@ -141,6 +141,8 @@ export interface CoverageTest { location: TestLocation | null; state: TestState; concurrent: boolean; + /** Configured retries, even if no retry ran; absent in older version 1 work files. */ + retry?: number; attempts: number; blocks: number[]; suiteBlocks: number[]; @@ -173,6 +175,7 @@ export interface RuntimeTest { location: TestLocation | undefined; state: TestState; concurrent: boolean; + retry?: number | { count?: number }; } /** One test file's collected tests, in collection order. */ @@ -367,6 +370,7 @@ export function buildWorkFile(input: WorkFileInput): CoverageWorkFile { location: test.location ?? null, state: test.state, concurrent, + retry: typeof test.retry === 'number' ? test.retry : (test.retry?.count ?? 0), attempts, }; if (raw === undefined || rawTest === undefined || attempts === 0) { @@ -691,6 +695,7 @@ export async function runCoverage(options: CoverageOptions): Promise( - tests: readonly Pick[], + tests: readonly Pick[], pairs: readonly T[], + mutation: MutationScope = 'none', ): T[] { - const passed = new Set(tests.filter((test) => test.state === 'passed').map((test) => test.id)); - return pairs.filter((pair) => passed.has(pair.a) && passed.has(pair.b)); + const eligible = new Set( + tests + .filter((test) => (mutation === 'all' || test.state === 'passed') && (test.retry ?? 0) === 0) + .map((test) => test.id), + ); + return pairs.filter((pair) => eligible.has(pair.a) && eligible.has(pair.b)); } /** The value-flow stage; see the module comment. */ @@ -3129,11 +3137,9 @@ export async function runValueFlowStage( } const traceStarted = ctx.now(); - // Full mutation runs still investigate order-dependent tests that fail Layer 1's repeats. - // Fingerprint runs cannot promote those pairs; do not let them invalidate every other trace. - const tracePairs = plan.mutation === 'all' ? equal : passingTracePairs(work.tests, equal); + const tracePairs = passingTracePairs(work.tests, equal, plan.mutation); log( - `value-flow: tracing ${tracePairs.length} pairs (${equal.length - tracePairs.length} non-passing pairs left inconclusive)`, + `value-flow: tracing ${tracePairs.length} pairs (${equal.length - tracePairs.length} ineligible pairs left inconclusive)`, ); const trace = await runTrace({ repoRoot,