fix: normalize package version in golden-install-parity hashes (#1837)

The rc release step runs `npm version X.Y.Z-rc.N` before tests, which
rebakes the current version string into hook files and `gsd-core/VERSION`.
Without normalization, every golden parity hash differed post-bump and the
entire test suite failed with 16 golden failures — even though no files
actually changed in a semantically meaningful way.

Add `PKG_VERSION` normalization (`.split(PKG_VERSION).join('<VERSION>')`)
alongside the existing `<HOME>` root normalization so the goldens are
stable across version bumps. Regenerate all 16 fixtures with the new
normalization to establish the new baseline.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-30 00:11:34 -04:00
committed by GitHub
parent 4f07e9f8de
commit 4bdf0fd1cd
17 changed files with 275 additions and 271 deletions

View File

@@ -50,6 +50,11 @@ const FIXTURE_DIR = path.join(__dirname, 'fixtures', 'golden-install-parity');
// Volatile metadata files always excluded from the parity manifest.
const VOLATILE_FILES = new Set(['gsd-file-manifest.json', 'gsd-install-state.json']);
// The installed package version, normalized to '<VERSION>' in hash computation so
// the golden is stable across version bumps (the rc step runs `npm version X.Y.Z-rc.N`
// before tests, which rebakes the version into hook files and gsd-core/VERSION).
const PKG_VERSION = require('../package.json').version;
// Hook-registration config files excluded from the parity manifest. These are
// written by the hook/permission install path (applySettingsJsonHooks /
// finishInstall) — NOT by installRuntimeArtifacts, so they are outside the scope
@@ -102,10 +107,9 @@ function buildParityManifest(configDir, root) {
const content = fs.readFileSync(full);
// Normalize every occurrence of the temp root so hashes are stable across runs.
// The only other platform-varying content (the node-runner command form) lives
// exclusively in the excluded HOOK_CONFIG_FILES, so no further normalization is
// needed — a scan of all 16 installs confirmed no other file embeds it.
const normalized = content.toString('utf8').split(root).join('<HOME>');
// Also normalize the package version so the golden survives `npm version` bumps
// (the rc release step bakes the new version into hook files before running tests).
const normalized = content.toString('utf8').split(root).join('<HOME>').split(PKG_VERSION).join('<VERSION>');
const hash = crypto.createHash('sha256').update(normalized).digest('hex').slice(0, 16);
unsorted[rel] = hash;
}