The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(release): stable advance trusts receipts instead of downloading ~33 GB
ethernet4b050f6731e6
diff --git a/.github/workflows/stable-release-publication.yml b/.github/workflows/stable-release-publication.ymlindex 10288a0d7ca..8cc0298b23c 100644--- a/.github/workflows/stable-release-publication.yml+++ b/.github/workflows/stable-release-publication.yml@@ -53,7 +53,8 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- name: Reconcile stable drafts and protected heads- run: python -m scripts.releases.sequencer+ # The macOS feed merge parses YAML (hermes_yaml -> ruamel); the node toolchain has none.+ run: python -m scripts.ci.python_packages ruamel.yaml==0.18.17 -- -m scripts.releases.sequencerenv:GH_TOKEN: ${{ github.token }}REQUESTED_VERSION: ${{ inputs.version || '' }}diff --git a/.github/workflows/stable-release.yml b/.github/workflows/stable-release.ymlindex 195afd50d5c..7cdb7447be0 100644--- a/.github/workflows/stable-release.yml+++ b/.github/workflows/stable-release.yml@@ -662,7 +662,8 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- name: Reconcile ordered stable publication- run: python -m scripts.releases.sequencer+ # The macOS feed merge parses YAML (hermes_yaml -> ruamel); the node toolchain has none.+ run: python -m scripts.ci.python_packages ruamel.yaml==0.18.17 -- -m scripts.releases.sequencerenv:GH_TOKEN: ${{ github.token }}REQUESTED_VERSION: ''diff --git a/scripts/bundles/channel_artifacts.py b/scripts/bundles/channel_artifacts.pyindex 7858ad92cf4..78d660d39ce 100644--- a/scripts/bundles/channel_artifacts.py+++ b/scripts/bundles/channel_artifacts.py@@ -13,11 +13,33 @@ from scripts.bundles.release_artifacts import single, validate_windows_bundle, wALL_TARGETS = tuple((platform, arch) for platform in ("macos", "windows") for arch in ("arm64", "x64"))+def _leg_sha512(root: Path, files: dict, arch: str) -> dict[str, str]:+ """sha512 per artifact from the receipt-bound per-arch electron feed (``<arch>-*-mac.yml``)."""+ import hermes_yaml as yaml++ leg = single(name for name in files if name.startswith(f"{arch}-") and name.endswith("-mac.yml"))+ if not (root / leg).is_file():+ raise ChannelError(f"Missing receipt-bound macOS feed leg: {leg}")+ feed = yaml.safe_load((root / leg).read_text(encoding="utf-8-sig"))+ digests = {}+ for entry in feed.get("files", []):+ name = str(entry.get("url", ""))+ if name not in files or entry.get("size") != files[name]["size"]:+ raise ChannelError(f"macOS feed leg {leg} disagrees with its receipts: {name}")+ digests[name] = str(entry["sha512"])+ return digests++def assemble(request: dict, native: dict, root: Path, *, artifact_prefix: str,- targets=ALL_TARGETS) -> tuple[dict, list[Path]]:+ targets=ALL_TARGETS, local_bytes: bool = True) -> tuple[dict, list[Path]]:"""``targets`` defaults to every native target. A stable release that did notopt into macOS Intel passes the three it built; arm64 macOS and both Windows- arches are always required."""+ arches are always required.++ ``local_bytes=False`` trusts the receipts instead of downloaded packages:+ every artifact is bound by its receipt sha256 (and was validated when the+ candidate was accepted), the macOS sha512s come from the receipt-bound+ per-arch feed legs, and no multi-GB package needs to be on disk."""files = native["files"]rows = native["packages"]targets = sorted(targets)@@ -32,13 +54,14 @@ def assemble(request: dict, native: dict, root: Path, *, artifact_prefix: str,if windows[0]["applicationId"] != request["identity"]["appNamePascal"]:raise ChannelError("Windows application identity mismatch")bundle_name = single(name for name in files if name.endswith(".msixbundle") and not name.startswith("Store-"))- validate_windows_bundle(root / bundle_name, windows)+ if local_bytes:+ validate_windows_bundle(root / bundle_name, windows)packages, mac_files = [], []for row in rows:mac = row["platform"] == "macos"filename = row["filename"] if mac else bundle_namereceipt = files.get(filename)- if receipt is None or not (root / filename).is_file():+ if receipt is None or (local_bytes and not (root / filename).is_file()):raise ChannelError("Missing receipt-bound native artifact")signing = "teamId" if mac else "publisher"packages.append({"platform": "darwin" if mac else "win32", "arch": row["arch"], "variant": "bundled",@@ -47,11 +70,18 @@ def assemble(request: dict, native: dict, root: Path, *, artifact_prefix: str,"feed": {"key": prefix + ("darwin/stable-mac.yml" if mac else "win32/stable.appinstaller"),"channel": "stable"}})if mac:+ leg_digests = None if local_bytes else _leg_sha512(root, files, row["arch"])for name in (filename, filename.removesuffix(".zip") + ".dmg"):- if any(item not in files or not (root / item).is_file() for item in (name, name + ".blockmap")):+ if any(item not in files or (local_bytes and not (root / item).is_file())+ for item in (name, name + ".blockmap")):raise ChannelError("Missing receipt-bound macOS package or blockmap")- with (root / name).open("rb") as stream:- digest = base64.b64encode(hashlib.file_digest(stream, "sha512").digest()).decode("ascii")+ if leg_digests is not None:+ if name not in leg_digests:+ raise ChannelError(f"macOS feed leg has no sha512 for {name}")+ digest = leg_digests[name]+ else:+ with (root / name).open("rb") as stream:+ digest = base64.b64encode(hashlib.file_digest(stream, "sha512").digest()).decode("ascii")mac_files.append({"url": f"{base}/{artifact_prefix}{name}", "sha512": digest, "size": files[name]["size"]})manifest = {"schema": 1, "request": request, "packages": packages}if all(row.get("receiverProtocol") == 1 for row in rows):diff --git a/scripts/bundles/release_artifacts.py b/scripts/bundles/release_artifacts.pyindex 4ed14834cd1..7a89af69888 100644--- a/scripts/bundles/release_artifacts.py+++ b/scripts/bundles/release_artifacts.py@@ -231,7 +231,12 @@ def assemble(root: Path, tag: str, commit: str, public_base: str, out: Path,return result-def materialize(manifest: dict, root: Path, *, public_base: str, store_only: bool = False) -> None:+# Package payloads: receipt-bound by sha256, never needed on disk to write feeds.+PACKAGE_SUFFIXES = (".dmg", ".zip", ".blockmap", ".msix", ".msixbundle", ".deb")+++def materialize(manifest: dict, root: Path, *, public_base: str, store_only: bool = False,+ metadata_only: bool = False) -> None:validate_candidates(manifest, manifest["tag"], manifest["commit"], public_base,archive=manifest["archive"])files = manifest.get("files", [])@@ -241,6 +246,8 @@ def materialize(manifest: dict, root: Path, *, public_base: str, store_only: booif any(by_url.get(row["artifact"]["url"]) != row["artifact"]["sha256"] for row in manifest["packages"]):raise ValueError("Package receipts differ from candidate file receipts")selected = [item for item in files if item["path"].startswith("Store-") and item["path"].endswith(".msixbundle")] if store_only else files+ if metadata_only:+ selected = [item for item in selected if not item["path"].endswith(PACKAGE_SUFFIXES)]if store_only and len(selected) != 1:raise ValueError("Expected one Store candidate")from scripts.releases.progress import log@@ -330,7 +337,9 @@ def publish_canary_appinstaller(root: Path, *, tag: str, variant: str, bundle: Pdef promote(manifest: dict, root: Path, public_base: str) -> None:from scripts.releases.r2 import put, finalize- materialize(manifest, root, public_base=public_base)+ # Feeds need the per-arch feed legs and APT indexes, not the packages: those are+ # bound by the accepted candidate's sha256 receipts.+ materialize(manifest, root, public_base=public_base, metadata_only=True)windows = next(r for r in manifest["packages"] if r["platform"] == "windows")uri = f"{public_base.rstrip('/')}/releases/win32/stable/stable.appinstaller"appinstaller = root / "stable.appinstaller"@@ -351,7 +360,7 @@ def promote(manifest: dict, root: Path, public_base: str) -> None:# macOS Intel is opt-in: without it the feed carries the arm64 leg alone.arches = tuple(arch for arch in ("arm64", "x64")if any(row["platform"] == "macos" and row["arch"] == arch for row in manifest["packages"]))- finalize(tag=manifest["tag"], dir=root, archive=manifest["archive"], arches=arches)+ finalize(tag=manifest["tag"], dir=root, archive=manifest["archive"], arches=arches, verify_bytes=False)def publish_pointer(key, file):put(tag=manifest["tag"], key=key, file=file, key_is_full=True)digest = hashlib.sha256()diff --git a/scripts/releases/channel_releases.py b/scripts/releases/channel_releases.pyindex 89de95dac8a..e2e83a67536 100644--- a/scripts/releases/channel_releases.py+++ b/scripts/releases/channel_releases.py@@ -399,9 +399,14 @@ def publish_release(policy: str, env: dict, root: Path) -> dict:# Native handoffs were staged under the attempt ref for stable attempts# (identical for canary, where tag == payload_tag).legs = native_legs(accepted)- log(f"Fetching native handoffs for {', '.join(legs)} from releases/tag/{tag}/")- handoff.fetch(tag, commit, list(legs), root,- ["metadata-*.json", "*.zip", "*.dmg", "*.blockmap", "*.msixbundle"], public_base=publisher.public_base)+ # Stable trusts the receipt sha256s of an accepted candidate: only metadata and+ # the per-arch feed legs are downloaded, never the multi-GB packages.+ local_bytes = accepted is None+ includes = (["metadata-*.json", "*.zip", "*.dmg", "*.blockmap", "*.msixbundle"] if local_bytes+ else ["metadata-*.json", "*-mac.yml"])+ log(f"Fetching native handoffs for {', '.join(legs)} from releases/tag/{tag}/ "+ f"({'packages' if local_bytes else 'metadata and feed legs only'})")+ handoff.fetch(tag, commit, list(legs), root, includes, public_base=publisher.public_base)native = read_native_receipts(root, tag, commit, legs, payload_tag=payload_tag)log(f"Native receipts verified: {len(native['packages'])} packages, {len(native['files'])} files")windows = next(row for row in native["packages"] if row["platform"] == "windows")@@ -433,7 +438,7 @@ def publish_release(policy: str, env: dict, root: Path) -> dict:identity=identity, policy=policy, release_gate=release_gate,archive_ref=tag if parsed else None)manifest, feeds = assemble(request, native, root, artifact_prefix=f"releases/tag/{tag}/",- targets=_leg_targets(legs))+ targets=_leg_targets(legs), local_bytes=local_bytes)if accepted is not None:match_accepted_packages(manifest, accepted)prefix = build_prefix(request["buildId"])@@ -448,7 +453,8 @@ def publish_release(policy: str, env: dict, root: Path) -> dict:def qualified(pinned: dict, actual: dict) -> bool:# Rehash local receipt-bound bytes rather than trusting caller-supplied claims.expected, _ = assemble(pinned, read_native_receipts(root, tag, commit, legs, payload_tag=payload_tag), root,- artifact_prefix=f"releases/tag/{tag}/", targets=_leg_targets(legs))+ artifact_prefix=f"releases/tag/{tag}/", targets=_leg_targets(legs),+ local_bytes=local_bytes)if accepted is not None:match_accepted_packages(expected, accepted)diff --git a/scripts/releases/darwin.py b/scripts/releases/darwin.pyindex 375eccc77e0..75a3e4d18dd 100644--- a/scripts/releases/darwin.py+++ b/scripts/releases/darwin.py@@ -177,9 +177,13 @@ def publish_mac_feed(# ---------------------------------------------------------------------------def finalize(tag: str, dir: str, variant: str | None = None, archive: str | None = None,- arches: tuple[str, ...] | None = None) -> None:+ arches: tuple[str, ...] | None = None, verify_bytes: bool = True) -> None:"""Validate both native legs, verify their streamed bytes, then replace- the feed pointer (conditional write, then readback)."""+ the feed pointer (conditional write, then readback).++ ``verify_bytes=False`` (stable promotion of an accepted candidate, whose+ artifacts are already bound by receipt sha256) checks each artifact's+ remote size instead of streaming multi-GB packages back down."""if variant and variant != "light":raise ValueError("Unknown macOS variant")creds, base, bucket = r2_module.credentials()@@ -210,6 +214,12 @@ def finalize(tag: str, dir: str, variant: str | None = None, archive: str | Nonereturn {"text": response.text(), "etag": etag}def verify(key: str, file_entry: dict[str, Any]) -> None:+ if not verify_bytes:+ head = r2_module.signed_request(+ "HEAD", f"{base}/{bucket}/{r2_module.encode_key_path(key)}", creds=creds, now=now)+ if str(head.header("content-length")) != str(file_entry["size"]):+ raise ValueError(f"Artifact size mismatch: {key}")+ returnr2_module.verify_remote_artifact(f"{base}/{bucket}/{r2_module.encode_key_path(key)}",creds, now, file_entry["size"], file_entry["sha512"],diff --git a/scripts/releases/r2.py b/scripts/releases/r2.pyindex ba1d75c0016..a9c05940598 100644--- a/scripts/releases/r2.py+++ b/scripts/releases/r2.py@@ -702,12 +702,13 @@ def put_object(def finalize(tag: str, dir: str, variant: str | None = None, archive: str | None = None,- arches: tuple[str, ...] | None = None) -> None:+ arches: tuple[str, ...] | None = None, verify_bytes: bool = True) -> None:"""Lazy re-export of the Darwin finalize so callers can treatscripts.releases.r2 as the single transport surface."""from . import darwin as darwin_module- darwin_module.finalize(tag=tag, dir=dir, variant=variant, archive=archive, arches=arches)+ darwin_module.finalize(tag=tag, dir=dir, variant=variant, archive=archive, arches=arches,+ verify_bytes=verify_bytes)def put(