Skip to content

Commit db05877

Browse files
fix(evidence): evaluate release proofs against the release line (#90)
REL-014 required package.json#version to equal "1.0.0" and REL-012 required it to be in an enumerated set, so an isolated bump to 1.0.1 failed both proofs. Each release had to edit the proofs it was meant to satisfy. Add scripts/release-line.mjs with pure predicates for final MAJOR.MINOR.PATCH versions and use them in both proofs: - REL-014 accepts any final release on the 1.x line, still requires the 16 stable entrypoints and the 1.0.0 changelog entry, and requires a published 1.x compatibility baseline no newer than the package. - REL-012 accepts any final release from 0.6.1 on, with a baseline between 0.6.0 and the package version. Move the previous-release compatibility baseline from 0.6.1 to 1.0.0 and add the frozen 1.0.0 consumer fixture. The 1.0.0 export names and declarations are identical to 0.6.1, so the gate result is unchanged. Prerelease versions, other major lines, a baseline newer than the package and a pre-freeze baseline are still rejected. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 4eb7e99 commit db05877

7 files changed

Lines changed: 233 additions & 16 deletions

File tree

‎packages/core/evidence/claims.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@
573573
"status": "proven",
574574
"proof": "tests/evidence/release/hardening-contracts.mjs",
575575
"command": "npm run test:evidence",
576-
"expectedInvariant": "declarations and 0.6.0 compatibility are locked, Node 20.11/22/24 are exercised, two builds pack identically, public benchmark thresholds drive their gates, and 1,000 runs per property are scheduled nightly with rotating reproducible seeds",
576+
"expectedInvariant": "declarations and previous-release compatibility are locked, Node 20.11/22/24 are exercised, two builds pack identically, public benchmark thresholds drive their gates, and 1,000 runs per property are scheduled nightly with rotating reproducible seeds",
577577
"limitations": "The declaration snapshot intentionally freezes the complete generated type graph. The Node matrix and deep property profile execute in CI; local release verification covers the active Node version and bounded property profile unless explicitly overridden.",
578578
"verifiedFor": "0.6.1"
579579
},
@@ -597,8 +597,8 @@
597597
"status": "proven",
598598
"proof": "tests/evidence/release/one-zero-contracts.mjs",
599599
"command": "npm run test:evidence",
600-
"expectedInvariant": "the 1.0 package declares all 16 entrypoints stable and checks runtime exports and declarations against 0.6.1",
601-
"limitations": "The compatibility gate proves the published JavaScript exports and generated declarations are unchanged from 0.6.1. Behavioral compatibility remains bounded by the documented contracts and executable consumer fixtures.",
600+
"expectedInvariant": "every 1.x package declares all 16 entrypoints stable and checks runtime exports and declarations against a published 1.x baseline no newer than itself",
601+
"limitations": "The compatibility gate proves the JavaScript export names and generated declarations are unchanged from the 1.0.0 release, which was itself verified unchanged from 0.6.1 when it was published. Behavioral compatibility remains bounded by the documented contracts and executable consumer fixtures.",
602602
"verifiedFor": "1.0.0"
603603
},
604604
{

‎packages/core/scripts/check-previous-compatibility.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { fileURLToPath } from "node:url";
1515
import { promisify } from "node:util";
1616
import { parseSingleNpmPackResult } from "./npm-pack-result.mjs";
1717

18-
const BASELINE_VERSION = "0.6.1";
18+
const BASELINE_VERSION = "1.0.0";
1919
const OPENTELEMETRY_VERSION = "1.9.1";
2020
const PACKAGE_ROOT = fileURLToPath(new URL("../", import.meta.url));
2121
const FIXTURE_PATH = fileURLToPath(
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Frozen strict-TypeScript consumer for the 1.0.0 compatibility baseline.
3+
*
4+
* @author Admilson B. F. Cossa
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
import {
9+
ContextBagImpl,
10+
createContextKey,
11+
group,
12+
run,
13+
type ContextBag,
14+
type TaskContext,
15+
} from "@workit/core";
16+
import * as activity from "@workit/core/activity";
17+
import * as ai from "@workit/core/ai";
18+
import * as analysis from "@workit/core/analysis";
19+
import * as candidates from "@workit/core/candidates";
20+
import * as channel from "@workit/core/channel";
21+
import * as contracts from "@workit/core/contracts";
22+
import * as diagnostics from "@workit/core/diagnostics";
23+
import * as fault from "@workit/core/fault";
24+
import * as ledger from "@workit/core/ledger";
25+
import * as observability from "@workit/core/observability";
26+
import * as otel from "@workit/core/otel";
27+
import * as replay from "@workit/core/replay";
28+
import * as resources from "@workit/core/resources";
29+
import * as timePolicy from "@workit/core/time-policy";
30+
import * as worker from "@workit/core/worker";
31+
32+
const RequestId = createContextKey<string>("request-id");
33+
const initialContext: ContextBag = new ContextBagImpl().with(RequestId, "compatibility-check");
34+
35+
export const execute = () => group(
36+
async (task) => task(async (ctx: TaskContext) =>
37+
ctx.context.getOrThrow(RequestId), { name: "compatibility" }),
38+
{ context: initialContext },
39+
);
40+
41+
export const timeout = run.timeout;
42+
43+
export type PublishedModules = readonly [
44+
typeof activity,
45+
typeof ai,
46+
typeof analysis,
47+
typeof candidates,
48+
typeof channel,
49+
typeof contracts,
50+
typeof diagnostics,
51+
typeof fault,
52+
typeof ledger,
53+
typeof observability,
54+
typeof otel,
55+
typeof replay,
56+
typeof resources,
57+
typeof timePolicy,
58+
typeof worker,
59+
];
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Release-line predicates shared by the release evidence proofs.
3+
*
4+
* Release proofs must hold for every release on a line, not for one
5+
* enumerated version. These predicates let a proof state "a final release on
6+
* the 1.x line" or "a baseline no newer than the package" without being
7+
* edited on each version bump.
8+
*
9+
* Only final `MAJOR.MINOR.PATCH` versions are release versions. Prerelease
10+
* and build-metadata versions, including the ephemeral dry-run version used by
11+
* the release workflow, are rejected.
12+
*
13+
* @author Admilson B. F. Cossa
14+
* SPDX-License-Identifier: Apache-2.0
15+
*/
16+
17+
const RELEASE_VERSION =
18+
/^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)$/u;
19+
const COMPONENTS = Object.freeze(["major", "minor", "patch"]);
20+
21+
/**
22+
* Parses a final release version.
23+
*
24+
* @param {unknown} version Candidate version, normally `package.json#version`.
25+
* @returns {{ major: number, minor: number, patch: number } | null} Numeric
26+
* components, or `null` when the value is not a final release version.
27+
*/
28+
export function parseReleaseVersion(version) {
29+
const match = typeof version === "string" ? RELEASE_VERSION.exec(version) : null;
30+
if (match === null) return null;
31+
return {
32+
major: Number(match.groups.major),
33+
minor: Number(match.groups.minor),
34+
patch: Number(match.groups.patch),
35+
};
36+
}
37+
38+
/**
39+
* Reports whether a version is a final release on one major line.
40+
*
41+
* @param {unknown} version Candidate version.
42+
* @param {number} major Major line, for example `1` for every 1.x release.
43+
* @returns {boolean} `false` for other lines and for non-release versions.
44+
*/
45+
export function isReleaseOnMajorLine(version, major) {
46+
return parseReleaseVersion(version)?.major === major;
47+
}
48+
49+
/**
50+
* Reports whether a release is the same as, or newer than, a floor release.
51+
*
52+
* @param {unknown} version Candidate version.
53+
* @param {unknown} floor Oldest accepted release.
54+
* @returns {boolean} `false` when either side is not a final release version.
55+
*/
56+
export function isReleaseAtOrAfter(version, floor) {
57+
const candidate = parseReleaseVersion(version);
58+
const minimum = parseReleaseVersion(floor);
59+
if (candidate === null || minimum === null) return false;
60+
for (const component of COMPONENTS) {
61+
if (candidate[component] !== minimum[component]) {
62+
return candidate[component] > minimum[component];
63+
}
64+
}
65+
return true;
66+
}

‎packages/core/tests/evidence/release/hardening-contracts.mjs‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66
*/
77

88
import { readFile } from "node:fs/promises";
9+
import { isReleaseAtOrAfter } from "../../../scripts/release-line.mjs";
910
import { createSuite } from "../harness.mjs";
1011

1112
const suite = createSuite("release");
1213
const root = new URL("../../../", import.meta.url);
13-
const HARDENED_RELEASE_VERSIONS = new Set(["0.6.1", "1.0.0"]);
14-
const COMPATIBILITY_BASELINES = new Set(["0.6.0", "0.6.1"]);
14+
/** Release that introduced the hardening gates; every later release keeps them. */
15+
const HARDENING_VERSION = "0.6.1";
16+
/** Oldest baseline the previous-release compatibility gate has ever locked. */
17+
const OLDEST_COMPATIBILITY_BASELINE = "0.6.0";
1518

1619
await suite.proof(
1720
"REL-012",
1821
"0.6.1 locks declarations compatibility and reproducible packaging",
19-
"declarations and 0.6.0 compatibility are locked, Node 20.11/22/24 are exercised, two builds pack identically, public benchmark thresholds drive their gates, and deep property exploration is scheduled",
22+
"declarations and previous-release compatibility are locked, Node 20.11/22/24 are exercised, two builds pack identically, public benchmark thresholds drive their gates, and deep property exploration is scheduled",
2023
async () => {
2124
const packageJson = JSON.parse(await readFile(new URL("package.json", root), "utf8"));
2225
const snapshot = JSON.parse(await readFile(
@@ -46,10 +49,11 @@ await suite.proof(
4649
)?.groups?.version;
4750

4851
return {
49-
ok: HARDENED_RELEASE_VERSIONS.has(packageJson.version)
52+
ok: isReleaseAtOrAfter(packageJson.version, HARDENING_VERSION)
5053
&& snapshot.files?.length === 31
5154
&& declarationGate.includes("public-declarations.snapshot.json")
52-
&& COMPATIBILITY_BASELINES.has(compatibilityBaseline)
55+
&& isReleaseAtOrAfter(compatibilityBaseline, OLDEST_COMPATIBILITY_BASELINE)
56+
&& isReleaseAtOrAfter(packageJson.version, compatibilityBaseline)
5357
&& reproducibilityGate.includes("two clean builds produced different package bytes")
5458
&& ci.includes('node-version: ["20.11.1", "22.x", "24.x"]')
5559
&& logicalFixture?.minimumLogicalItemsPerSecond === 50_000_000

‎packages/core/tests/evidence/release/one-zero-contracts.mjs‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66
*/
77

88
import { readFile } from "node:fs/promises";
9+
import { isReleaseAtOrAfter, isReleaseOnMajorLine } from "../../../scripts/release-line.mjs";
910
import { createSuite } from "../harness.mjs";
1011

11-
const RELEASE_VERSION = "1.0.0";
12-
const COMPATIBILITY_BASELINE = "0.6.1";
12+
/** Release that froze the surface. Its changelog entry must stay published. */
13+
const FREEZE_VERSION = "1.0.0";
14+
/** Major line the freeze covers: every 1.x release keeps the frozen surface. */
15+
const FROZEN_MAJOR = 1;
1316
const STABLE_ENTRYPOINT_COUNT = 16;
1417
const suite = createSuite("release");
1518
const root = new URL("../../../", import.meta.url);
1619

1720
await suite.proof(
1821
"REL-014",
1922
"1.0 freezes the documented package surface",
20-
"the 1.0 package declares all 16 entrypoints stable and checks runtime exports and declarations against 0.6.1",
23+
"every 1.x package declares all 16 entrypoints stable and checks runtime exports and declarations against a published 1.x baseline no newer than itself",
2124
async () => {
2225
const packageJson = JSON.parse(await readFile(new URL("package.json", root), "utf8"));
2326
const readme = await readFile(new URL("README.md", root), "utf8");
@@ -34,14 +37,19 @@ await suite.proof(
3437
return readme.includes(`| \`${publishedPath}\` | stable |`);
3538
});
3639

40+
const compatibilityBaseline = compatibilityGate.match(
41+
/BASELINE_VERSION = "(?<version>[^"]+)"/u,
42+
)?.groups?.version;
43+
3744
return {
38-
ok: packageJson.version === RELEASE_VERSION
45+
ok: isReleaseOnMajorLine(packageJson.version, FROZEN_MAJOR)
3946
&& entrypoints.length === STABLE_ENTRYPOINT_COUNT
4047
&& stableRows.length === STABLE_ENTRYPOINT_COUNT
41-
&& changelog.includes(`## ${RELEASE_VERSION}`)
42-
&& compatibilityGate.includes(`BASELINE_VERSION = "${COMPATIBILITY_BASELINE}"`),
48+
&& changelog.includes(`## ${FREEZE_VERSION}`)
49+
&& isReleaseAtOrAfter(compatibilityBaseline, FREEZE_VERSION)
50+
&& isReleaseAtOrAfter(packageJson.version, compatibilityBaseline),
4351
version: packageJson.version,
44-
compatibilityBaseline: COMPATIBILITY_BASELINE,
52+
compatibilityBaseline,
4553
entrypoints,
4654
stableEntrypoints: stableRows.length,
4755
};
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* Release-line predicate tests for the release evidence proofs.
3+
*
4+
* @author Admilson B. F. Cossa
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
import { describe, expect, it } from "vitest";
9+
import {
10+
isReleaseAtOrAfter,
11+
isReleaseOnMajorLine,
12+
parseReleaseVersion,
13+
} from "../../scripts/release-line.mjs";
14+
15+
describe("release version parsing", () => {
16+
it("parses final MAJOR.MINOR.PATCH versions numerically", () => {
17+
expect(parseReleaseVersion("1.0.0")).toEqual({ major: 1, minor: 0, patch: 0 });
18+
expect(parseReleaseVersion("10.20.30")).toEqual({ major: 10, minor: 20, patch: 30 });
19+
});
20+
21+
it.each([
22+
"1.0",
23+
"1.0.0.0",
24+
"v1.0.0",
25+
"01.0.0",
26+
"1.0.0-rc.1",
27+
"0.0.0-dry-run.42.1",
28+
"1.0.0+build.7",
29+
"",
30+
" 1.0.0",
31+
])("rejects %j because it is not a final release version", (version) => {
32+
expect(parseReleaseVersion(version)).toBeNull();
33+
});
34+
35+
it.each([undefined, null, 1, { major: 1 }])("rejects the non-string value %j", (version) => {
36+
expect(parseReleaseVersion(version)).toBeNull();
37+
});
38+
});
39+
40+
describe("release major line", () => {
41+
it("accepts every final release on the requested major line", () => {
42+
expect(isReleaseOnMajorLine("1.0.0", 1)).toBe(true);
43+
expect(isReleaseOnMajorLine("1.0.1", 1)).toBe(true);
44+
expect(isReleaseOnMajorLine("1.7.12", 1)).toBe(true);
45+
});
46+
47+
it("rejects other major lines and non-release versions", () => {
48+
expect(isReleaseOnMajorLine("0.6.1", 1)).toBe(false);
49+
expect(isReleaseOnMajorLine("2.0.0", 1)).toBe(false);
50+
expect(isReleaseOnMajorLine("1.0.1-rc.1", 1)).toBe(false);
51+
expect(isReleaseOnMajorLine(undefined, 1)).toBe(false);
52+
});
53+
});
54+
55+
describe("release ordering", () => {
56+
it("treats a release as at or after itself", () => {
57+
expect(isReleaseAtOrAfter("1.0.0", "1.0.0")).toBe(true);
58+
});
59+
60+
it("orders by major, then minor, then patch", () => {
61+
expect(isReleaseAtOrAfter("1.0.1", "1.0.0")).toBe(true);
62+
expect(isReleaseAtOrAfter("1.1.0", "1.0.9")).toBe(true);
63+
expect(isReleaseAtOrAfter("2.0.0", "1.9.9")).toBe(true);
64+
expect(isReleaseAtOrAfter("1.0.0", "1.0.1")).toBe(false);
65+
expect(isReleaseAtOrAfter("1.0.9", "1.1.0")).toBe(false);
66+
expect(isReleaseAtOrAfter("0.6.1", "1.0.0")).toBe(false);
67+
});
68+
69+
it("compares components as numbers, not strings", () => {
70+
expect(isReleaseAtOrAfter("1.0.10", "1.0.9")).toBe(true);
71+
expect(isReleaseAtOrAfter("1.10.0", "1.9.0")).toBe(true);
72+
expect(isReleaseAtOrAfter("1.0.9", "1.0.10")).toBe(false);
73+
});
74+
75+
it("is false when either side is not a final release version", () => {
76+
expect(isReleaseAtOrAfter("1.0.1-rc.1", "1.0.0")).toBe(false);
77+
expect(isReleaseAtOrAfter("1.0.1", "1.0")).toBe(false);
78+
expect(isReleaseAtOrAfter(undefined, "1.0.0")).toBe(false);
79+
});
80+
});

0 commit comments

Comments
 (0)