From 554390da387d97c8b93dc2337c2ab41d4271e9f4 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 11 Nov 2026 06:37:58 -0800 Subject: [PATCH] Stop the doctor floor test failing on every release that adds no policy key (GST-2441) (#4293) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- changelog.d/fix-policy-floor-test-on-release-stamps.md | 1 + test/policy-floor-stable.test.ts | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelog.d/fix-policy-floor-test-on-release-stamps.md diff --git a/changelog.d/fix-policy-floor-test-on-release-stamps.md b/changelog.d/fix-policy-floor-test-on-release-stamps.md new file mode 100644 index 000000000..2ac5773d5 --- /dev/null +++ b/changelog.d/fix-policy-floor-test-on-release-stamps.md @@ -0,0 +1 @@ +- **The doctor floor-row test no longer fails every release that adds no policy key (GST-2441).** test/policy-floor-stable.test.ts now expects a lagging checkout to read policies as the newest policy key gstack knows, computed from the same key table validatePolicy reads, instead of the repo's own VERSION. Before this, any release stamp past the newest key (v1.99.1.0 in #4291) turned free-tests red. Test-only change; no product code moved. diff --git a/test/policy-floor-stable.test.ts b/test/policy-floor-stable.test.ts index b840f7c0f..b90af5d29 100644 --- a/test/policy-floor-stable.test.ts +++ b/test/policy-floor-stable.test.ts @@ -10,7 +10,8 @@ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { EXIT } from '../lib/headless-artifacts'; -import { runningGstackVersion, validatePolicy } from '../lib/ship-policy'; +import { BUMP_NEVER_KEY_VERSION, POLICY_KEY_INTRODUCED, runningGstackVersion, TRAIN_GATES_KEY_VERSION, validatePolicy } from '../lib/ship-policy'; +import { cmpVersion, parseVersion } from '../lib/version-source'; import { useDoctorCleanup, REPO, makeFixture, doctor, write as writeFile } from './helpers/doctor-fixture'; import { cleanup as cleanupPregate, commit, makeFixtureRepo as makePregateRepo, runBin as runPregateBin, type FixtureRepo as PregateRepo } from './helpers/pregate-fixture'; import { cleanup, makeFixtureRepo, runBin, type FixtureRepo } from './helpers/restamp-fixture'; @@ -187,12 +188,13 @@ describe('gstack-doctor --check floor row', () => { test('an unstamped main checkout gets the verdict validatePolicy gives: the newest policy key it knows counts', () => { const f = makeFixture(); fs.copyFileSync(path.join(REPO, 'lib/ship-policy-keys.ts'), path.join(f.root, 'lib/ship-policy-keys.ts')); - const known = runningGstackVersion(); + const newer = (a: string, b: string) => cmpVersion(parseVersion(a)!, parseVersion(b)!) > 0; + const known = [...Object.values(POLICY_KEY_INTRODUCED), BUMP_NEVER_KEY_VERSION, TRAIN_GATES_KEY_VERSION].reduce((a, b) => (newer(b, a) ? b : a)); const dir = project(f, known); const at = floorRow(f, dir); expect(validatePolicy({ min_gstack_version: known })).toEqual([]); expect(at.status, at.line).toBe('PASS'); - expect(at.line).toBe(known === VERSION ? `PASS floor ${known} declared by ${dir}/.gstack/ship-policy.json (installed ${VERSION})` : `PASS floor ${known} declared by ${dir}/.gstack/ship-policy.json (installed ${VERSION}, reads policies as ${known})`); + expect(at.line).toBe(!newer(known, VERSION) ? `PASS floor ${known} declared by ${dir}/.gstack/ship-policy.json (installed ${VERSION})` : `PASS floor ${known} declared by ${dir}/.gstack/ship-policy.json (installed ${VERSION}, reads policies as ${known})`); // A checkout whose VERSION lags a key it carries reads the key's floor (validatePolicy agrees), so the row passes. writeFile(path.join(f.root, 'VERSION'), '1.0.0.0\n'); const lagging = floorRow(f, project(f, known));