import { verifyCompatibilityTuple } from "../application/policies/compatibility.ts"; export const RELEASE_TOKEN_REGISTRY = Object.freeze({ appVersion: token("appVersion", "manifest", "human release label"), buildId: token("buildId", "CI build", "asset and HTML coherence"), commitSha: token("commitSha", "VCS", "source traceability"), configSchemaVersion: token( "configSchemaVersion", "runtime config schema", "boot compatibility", ), apiContractVersion: token( "apiContractVersion", "frontend/backend agreement", "legacy V1 scalar; superseded by contractSetDigest", ), contractSetDigest: token( "contractSetDigest", "compiled external contract package set", "release coherence for multi-package contracts", ), assetManifestHash: token( "assetManifestHash", "build output", "chunk integrity and mismatch detection", ), releaseId: token("releaseId", "deploy system", "rollback target"), builtAt: token("builtAt", "CI", "diagnostics only; never cache identity"), }); function token(name: string, source: string, compatibilityRole: string) { return Object.freeze({ token: name, source, compatibilityRole }); } /** * Compare a release manifest and runtime configuration structurally. Version * fields are delegated to the numeric compatibility policy, never compared * lexically. * */ export function compareReleaseToRuntime( release: Readonly<{ buildId: string; configSchemaVersion: string; apiContractVersion: string; assetManifestHash: string; releaseId: string; }>, runtimeConfig: Readonly<{ BUILD_ID: string; CONFIG_SCHEMA_VERSION: string; API_CONTRACT_VERSION: string; RELEASE_ID: string; }>, ) { return verifyCompatibilityTuple({ frontend: release, runtime: { buildId: runtimeConfig.BUILD_ID, configSchemaVersion: runtimeConfig.CONFIG_SCHEMA_VERSION, apiContractVersion: runtimeConfig.API_CONTRACT_VERSION, assetManifestHash: release.assetManifestHash, releaseId: runtimeConfig.RELEASE_ID, }, }); }