From a11b65182731ac5ce83d067b69db49407d8a14eb Mon Sep 17 00:00:00 2001 From: garrytan Date: Tue, 29 Sep 2026 14:44:17 +0000 Subject: [PATCH] fix(test): pin the package.json change kind in shared-input selection tests computePaidCaseSelection read the version-only exemption from git even when changed files were injected, so the shared-input test failed on main and on version-only branches. The exemption is now an optional input; the test pins a real package.json change and covers the version-only case. --- scripts/test-paid-shards.ts | 5 ++++- test/pr-shared-input-selection.test.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/test-paid-shards.ts b/scripts/test-paid-shards.ts index 2f6750a3e..d156651d5 100644 --- a/scripts/test-paid-shards.ts +++ b/scripts/test-paid-shards.ts @@ -298,13 +298,16 @@ export function computePaidCaseSelection(options: { env?: NodeJS.ProcessEnv; rootDir?: string; changedFiles?: string[]; + /** Whether package.json differs from the base only in `version`; computed from git when omitted. */ + packageVersionOnly?: boolean; }): { selection: PaidCaseSelection; reason: string; coverage?: PrProfileSelection } { const env = options.env ?? process.env; const rootDir = options.rootDir ?? ROOT; const baseRef = env.EVALS_BASE || detectBaseBranch(rootDir) || 'main'; const files = options.changedFiles ?? (env.EVALS_ALL ? [] : getChangedFiles(baseRef, rootDir)); const all = !!env.EVALS_ALL || files.length === 0; - const effectiveFiles = files.filter(file => options.profile !== 'pr' || file !== 'package.json' || !packageVersionOnlySinceBase(rootDir, baseRef)); + const effectiveFiles = files.filter(file => options.profile !== 'pr' || file !== 'package.json' || + !(options.packageVersionOnly ?? packageVersionOnlySinceBase(rootDir, baseRef))); const sourceAliases = options.profile === 'pr' ? existingPromptSourceAliases(effectiveFiles, rootDir) : {}; const selectionFiles = [...new Set([...effectiveFiles, ...Object.values(sourceAliases)])]; const select = (table: Record) => all ? null diff --git a/test/pr-shared-input-selection.test.ts b/test/pr-shared-input-selection.test.ts index fd7dc2d8b..72929da8c 100644 --- a/test/pr-shared-input-selection.test.ts +++ b/test/pr-shared-input-selection.test.ts @@ -13,7 +13,9 @@ const periodicIds = Object.keys(E2E_TOUCHFILES).filter(id => E2E_TIERS[id] === ' const judgeIds = Object.keys(LLM_JUDGE_TOUCHFILES).sort(); test.each(sharedInputs)('%s retains the full gate after native dependency registration', file => { - const result = computePaidCaseSelection({ profile: 'pr', env: {}, changedFiles: [file] }); + // A package.json change beyond its version; the version-only exemption is + // decided from git history and would otherwise depend on the checkout. + const result = computePaidCaseSelection({ profile: 'pr', env: {}, changedFiles: [file], packageVersionOnly: false }); expect(result.coverage?.mode).toBe('full-fallback'); expect(result.selection.e2e).toEqual(gateIds); expect(result.selection.judges).toEqual(judgeIds); @@ -22,6 +24,12 @@ test.each(sharedInputs)('%s retains the full gate after native dependency regist expect(result.coverage?.needsFullValidation).toBe(false); }); +test('a version-only package.json change does not restore the full gate', () => { + const result = computePaidCaseSelection({ profile: 'pr', env: {}, changedFiles: ['package.json'], packageVersionOnly: true }); + expect(result.coverage?.mode).not.toBe('full-fallback'); + expect(result.coverage?.reasons.join('\n')).not.toContain('Shared runtime/build inputs restore every gate case and judge: package.json'); +}); + test.each(sharedInputs)('%s broad policy is independent of native, judge and global maps', file => { for (const registration of ['none', 'broad', 'fast', 'judge', 'global']) { const maps: PrProfileMaps = {