Require complete same-SHA evidence for Linux RC and stable releases

This commit is contained in:
cflmy committed 2026-11-22 22:10:34 +08:00
1 parent 6e9b5af88d
commit e4c4a852d0
3 files changed
+138 -111

No files matched your search

+39 -49
View File
@@ -5,16 +5,11 @@ Schema: `marqdo.release-gates.v1`. A missing, skipped, timed-out, failed or
SHA-mismatched gate is never PASS. The tool only records supplied facts; it
does not query CI and cannot turn an UNVERIFIED gate into a release.
Two profiles exist and both are explicit in the output:
* `stable` — every required platform gate must PASS on the target SHA.
* `beta` — the supported platform set is the one declared in
`COMPATIBILITY.md` (Linux x86_64 for `3.0.0-beta.1`). `windows`/`macos` must
be explicitly `UNSUPPORTED` (not silently omitted). `strict_vm` may be PASS
with same-SHA disposable-VM evidence, or `UNSUPPORTED` when the tested policy
is an explicit fail-closed refusal; `extension`, `clean_install` and
`version_compat` must PASS. `performance` may be `WARN` only in beta and is
recorded with its reason.
The `rc` profile requires every gate on the target SHA. For a Linux-only RC,
Windows and macOS must be explicitly UNSUPPORTED; the stable profile requires
both to PASS. Strict VM, extension, clean install, version compatibility and
performance all require PASS in both profiles. The historical beta profile
retains its scoped exceptions, including a documented performance WARN.
Gate spec: `name=STATE:tested_sha:run_url` (url may contain colons).
@@ -29,7 +24,7 @@ Usage:
--gate windows=UNSUPPORTED:$SHA:supported-platforms-exclude \
--gate macos=UNSUPPORTED:$SHA:supported-platforms-exclude \
--gate performance=WARN:$SHA:docs/evidence/... \
--out/docs/evidence/ci/$SHA/manifest.json
--out docs/evidence/ci/$SHA/manifest.json
"""
import argparse
@@ -40,22 +35,6 @@ import sys
from pathlib import Path
SCHEMA = "marqdo.release-gates.v1"
PROFILES = {
"stable": {
"required": ("linux", "windows", "macos", "strict_vm"),
"optional": ("performance",),
"windows_macos_unsupported_allowed": False,
"strict_unsupported_allowed": False,
"decision": "RELEASE_CANDIDATE",
},
"beta": {
"required": ("linux", "strict_vm", "extension", "clean_install", "version_compat"),
"optional": ("windows", "macos", "performance"),
"windows_macos_unsupported_allowed": True,
"strict_unsupported_allowed": True,
"decision": "BETA_RELEASE_CANDIDATE",
},
}
GATES = (
"linux",
"windows",
@@ -66,6 +45,22 @@ GATES = (
"version_compat",
"performance",
)
RC_PLATFORM_STATES = {"windows": {"UNSUPPORTED"}, "macos": {"UNSUPPORTED"}}
BETA_OPTIONAL = ("windows", "macos", "performance")
PROFILES = {
"stable": ("RELEASE_CANDIDATE", {}, ()),
"rc": ("RC_RELEASE_CANDIDATE", RC_PLATFORM_STATES, ()),
"beta": (
"BETA_RELEASE_CANDIDATE",
{
"windows": {"PASS", "UNSUPPORTED"},
"macos": {"PASS", "UNSUPPORTED"},
"strict_vm": {"PASS", "UNSUPPORTED"},
"performance": {"PASS", "WARN"},
},
BETA_OPTIONAL,
),
}
STATES = {
"linux": {"PASS", "FAIL", "UNVERIFIED"},
"windows": {"PASS", "FAIL", "UNVERIFIED", "UNSUPPORTED"},
@@ -109,7 +104,7 @@ def build_manifest(target_sha: str, gates: list[str], profile: str = "stable") -
if not SHA_RE.fullmatch(target_sha):
raise ValueError(f"target SHA must be 40 lowercase hex characters: {target_sha!r}")
try:
rules = PROFILES[profile]
release_decision, accepted_states, optional = PROFILES[profile]
except KeyError:
raise ValueError(f"unknown profile {profile!r}; expected {sorted(PROFILES)}") from None
parsed = {}
@@ -120,11 +115,11 @@ def build_manifest(target_sha: str, gates: list[str], profile: str = "stable") -
parsed[name] = gate
reasons = []
for name in rules["required"] + rules["optional"]:
for name in GATES:
gate = parsed.get(name)
if gate is None:
parsed[name] = {"state": "UNVERIFIED", "tested_sha": "", "run_url": ""}
if name in rules["required"]:
if name not in optional:
reasons.append(f"{name}: missing gate")
continue
if gate["tested_sha"] != target_sha:
@@ -132,25 +127,15 @@ def build_manifest(target_sha: str, gates: list[str], profile: str = "stable") -
f"{name}: tested_sha {gate['tested_sha'] or '(missing)'} != target_sha {target_sha}"
)
continue
if gate["state"] == "FAIL":
reasons.append(f"{name}: FAIL")
elif gate["state"] == "UNVERIFIED":
reasons.append(f"{name}: UNVERIFIED")
elif gate["state"] == "UNSUPPORTED":
allowed = False
if name in {"windows", "macos"}:
allowed = rules["windows_macos_unsupported_allowed"]
elif name == "strict_vm":
allowed = rules["strict_unsupported_allowed"]
if not allowed:
reasons.append(f"{name}: UNSUPPORTED is not allowed in the {profile} profile")
elif name == "performance":
if gate["state"] not in {"PASS", "WARN"}:
reasons.append(f"{name}: {gate['state']} is not PASS/WARN")
elif gate["state"] != "PASS":
reasons.append(f"{name}: {gate['state']} is not PASS")
allowed = accepted_states.get(name, {"PASS"})
if gate["state"] not in allowed:
reasons.append(
f"{name}: {gate['state']} is not accepted; expected {' or '.join(sorted(allowed))}"
)
elif not gate["run_url"].strip():
reasons.append(f"{name}: missing evidence reference")
decision = rules["decision"] if not reasons else "DO_NOT_RELEASE"
decision = release_decision if not reasons else "DO_NOT_RELEASE"
recorded = utc_now()
return {
"schema": SCHEMA,
@@ -175,6 +160,11 @@ def main(argv: list[str]) -> int:
parser.add_argument("--profile", choices=sorted(PROFILES), default="stable")
parser.add_argument("--gate", action="append", default=[])
parser.add_argument("--out", default="")
parser.add_argument(
"--require-release",
action="store_true",
help="exit 1 when the recorded decision blocks publication",
)
args = parser.parse_args(argv)
try:
manifest = build_manifest(args.target_sha, args.gate, args.profile)
@@ -187,7 +177,7 @@ def main(argv: list[str]) -> int:
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(text)
sys.stdout.write(text)
return 0
return int(args.require_release and manifest["release_decision"] == "DO_NOT_RELEASE")
if __name__ == "__main__":
+69 -57
View File
@@ -1,5 +1,8 @@
import importlib.util
import io
import json
import unittest
from contextlib import redirect_stdout
from pathlib import Path
MODULE = Path(__file__).with_name("release_evidence.py")
@@ -18,70 +21,79 @@ def gate(name: str, state: str, sha: str = SHA, url: str = "https://example.test
class ReleaseEvidenceTests(unittest.TestCase):
def test_all_required_pass_is_candidate(self) -> None:
manifest = release_evidence.build_manifest(
SHA,
[
gate("linux", "PASS"),
gate("windows", "PASS"),
gate("macos", "PASS"),
gate("strict_vm", "PASS"),
gate("performance", "WARN"),
],
SHA, [gate(name, "PASS") for name in release_evidence.GATES]
)
self.assertEqual(manifest["release_decision"], "RELEASE_CANDIDATE")
self.assertEqual(manifest["reasons"], [])
def test_missing_strict_vm_is_not_release(self) -> None:
manifest = release_evidence.build_manifest(
SHA,
[
gate("linux", "PASS"),
gate("windows", "PASS"),
gate("macos", "PASS"),
gate("performance", "PASS"),
],
)
self.assertEqual(manifest["release_decision"], "DO_NOT_RELEASE")
self.assertTrue(any("strict_vm" in reason for reason in manifest["reasons"]))
def test_complete_linux_rc_is_candidate(self) -> None:
manifest = release_evidence.build_manifest(SHA, self.rc_gates(), profile="rc")
self.assertEqual(manifest["release_decision"], "RC_RELEASE_CANDIDATE")
self.assertEqual(manifest["reasons"], [])
def test_sha_mismatch_is_not_release(self) -> None:
manifest = release_evidence.build_manifest(
SHA,
[
gate("linux", "PASS"),
gate("windows", "PASS", OTHER),
gate("macos", "PASS"),
gate("strict_vm", "PASS"),
gate("performance", "PASS"),
],
)
self.assertEqual(manifest["release_decision"], "DO_NOT_RELEASE")
self.assertTrue(any("windows" in reason for reason in manifest["reasons"]))
@staticmethod
def rc_gates() -> list[str]:
return [
gate(name, "UNSUPPORTED" if name in {"windows", "macos"} else "PASS")
for name in release_evidence.GATES
]
def test_failure_is_not_release(self) -> None:
manifest = release_evidence.build_manifest(
SHA,
[
gate("linux", "FAIL"),
gate("windows", "PASS"),
gate("macos", "PASS"),
gate("strict_vm", "PASS"),
gate("performance", "PASS"),
],
)
self.assertEqual(manifest["release_decision"], "DO_NOT_RELEASE")
def test_rc_requires_same_sha_evidence_for_every_gate(self) -> None:
for original in self.rc_gates():
name, details = original.split("=", 1)
state = details.split(":", 1)[0]
for replacement, reason in [
([], "missing gate"),
([gate(name, state, OTHER)], "!= target_sha"),
([gate(name, state, url="")], "missing evidence reference"),
([gate(name, "FAIL")], "FAIL"),
([gate(name, "UNVERIFIED")], "UNVERIFIED"),
]:
with self.subTest(gate=name, reason=reason):
inputs = [spec for spec in self.rc_gates() if spec != original]
manifest = release_evidence.build_manifest(
SHA, inputs + replacement, profile="rc"
)
self.assertEqual(manifest["release_decision"], "DO_NOT_RELEASE")
self.assertEqual(len(manifest["reasons"]), 1)
self.assertIn(reason, manifest["reasons"][0])
def test_unverified_performance_is_not_release(self) -> None:
manifest = release_evidence.build_manifest(
SHA,
[
gate("linux", "PASS"),
gate("windows", "PASS"),
gate("macos", "PASS"),
gate("strict_vm", "PASS"),
gate("performance", "UNVERIFIED"),
],
)
def test_rc_rejects_beta_exceptions_and_platform_scope_changes(self) -> None:
for name, state in [
("strict_vm", "UNSUPPORTED"),
("performance", "WARN"),
("windows", "PASS"),
("macos", "PASS"),
]:
with self.subTest(gate=name, state=state):
inputs = [spec for spec in self.rc_gates() if not spec.startswith(f"{name}=")]
manifest = release_evidence.build_manifest(
SHA, inputs + [gate(name, state)], profile="rc"
)
self.assertEqual(manifest["release_decision"], "DO_NOT_RELEASE")
self.assertTrue(manifest["reasons"][0].startswith(f"{name}:"))
def test_stable_requires_extension_install_version_and_performance(self) -> None:
names = ("extension", "clean_install", "version_compat", "performance")
for name in names:
with self.subTest(gate=name):
inputs = [gate(key, "PASS") for key in release_evidence.GATES if key != name]
manifest = release_evidence.build_manifest(SHA, inputs)
self.assertEqual(manifest["release_decision"], "DO_NOT_RELEASE")
self.assertEqual(manifest["reasons"], [f"{name}: missing gate"])
inputs = [gate(key, "WARN" if key == "performance" else "PASS") for key in release_evidence.GATES]
manifest = release_evidence.build_manifest(SHA, inputs)
self.assertEqual(manifest["release_decision"], "DO_NOT_RELEASE")
self.assertIn("performance: WARN", manifest["reasons"][0])
def test_require_release_returns_failure_and_preserves_manifest(self) -> None:
output = io.StringIO()
with redirect_stdout(output):
status = release_evidence.main(
["--target-sha", SHA, "--profile", "rc", "--require-release"]
)
self.assertEqual(status, 1)
self.assertEqual(json.loads(output.getvalue())["release_decision"], "DO_NOT_RELEASE")
def test_beta_profile_accepts_declared_linux_scope_with_warn_performance(self) -> None:
manifest = release_evidence.build_manifest(
@@ -119,7 +131,7 @@ class ReleaseEvidenceTests(unittest.TestCase):
)
self.assertEqual(manifest["release_decision"], "BETA_RELEASE_CANDIDATE")
def test_beta_profile_requires_explicit_platform_and_extension_gates(self) -> None:
def test_beta_profile_requires_extension_but_retains_optional_platforms(self) -> None:
manifest = release_evidence.build_manifest(
SHA,
[