Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

keep individual github releases stable-only (#3469)

kte317c3b91500
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a80a43b3b4..03beea0e1f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -219,6 +219,7 @@ jobs:
run: |
python3 scripts/release/test_native_compat.py
python3 scripts/release/test_npm_bridge.py
+ python3 scripts/release/test_release_publication.py
python3 scripts/release/test_restamp.py
python3 scripts/release/test_channel_version.py
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index e3eca687a4..6b544f56f9 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -44,9 +44,9 @@
# load-bearing: a GITHUB_TOKEN-created tag fires NO downstream push
# event, so release.yml would never run. The App's ref creation is the
# push event that triggers release.yml's -beta* channel: build ->
-# promote (beta.json, a PRERELEASE - never takes GitHub's Latest
-# pointer; beta tags publish automatically from the release-beta
-# environment, no approval) -> nightly-refresh rolls the rolling
+# promote (beta.json and versioned R2 artifacts; beta tags publish
+# automatically from the release-beta environment, no approval) ->
+# nightly-refresh rolls the rolling
# `nightly` release.
#
# Idempotency/counter safety: if the computed tag already exists, the cut
@@ -445,4 +445,4 @@ jobs:
tag="$(jq -r .tag "${out}/meta.json")"
gh api -X POST "${repo}/git/refs" --input "${out}/ref.json"
echo "annotated tag ${tag} cut at the tag-only commit ${commit_sha} (parent $(jq -r .parent "${out}/meta.json"))"
- echo "release.yml (tag-triggered, -beta* channel) takes over: build -> promote (beta.json + prerelease; publishes automatically, no approval) -> nightly-refresh rolls the nightly release"
+ echo "release.yml (tag-triggered, -beta* channel) takes over: build -> promote (beta.json + versioned R2 artifacts; publishes automatically, no approval) -> nightly-refresh rolls the nightly release"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 71f0dc7462..bb3fff8fd4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -39,7 +39,7 @@ permissions: {}
concurrency:
# Every tag promotes under its own group: a queued promotion is never
# canceled by another tag (single-pending groups would drop a queued
- # run), so every published tag gets its release. The rolling nightly
+ # run), so every published tag gets its versioned artifacts. The rolling nightly
# refresh - the one piece of shared state - serializes in its own
# nightly-refresh job group instead.
group: release-${{ github.ref }}
@@ -880,6 +880,16 @@ jobs:
out.write_text(json.dumps(document, indent=2) + "\n")
print(f"channel manifest {out.name}: {document['version']}, {len(rows)} artifacts")
PY
+ - name: Install syft
+ uses: anchore/sbom-action/download-syft@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2
+ - name: Generate SPDX SBOM per target (unpacked artifact tree)
+ run: |
+ set -euo pipefail
+ for dir in release-unpacked/*/; do
+ target="$(basename "${dir}")"
+ syft "dir:${dir}" -o "spdx-json=release-out/sbom-spdx-${RELEASE_VERSION#v}-${target}.json"
+ done
+ ls -la release-out/sbom-spdx-*
# THE R2 PUBLISH PHASE (the operator's distribution-model ruling: the
# channel — pointers, manifests, payloads, checksums — lives on the
# R2-backed base alone. The sh one-liner's route carries no GitHub
@@ -913,8 +923,8 @@ jobs:
# cut is coming — this publish keeps its versioned artifacts but
# skips the beta channel pointers (beta.json/beta/install-beta.sh),
# so the channel only ever advances forward.
- # - AUDIT SURFACE: the GitHub release below still attaches every
- # artifact (the TS order: the R2 publish first, GitHub second).
+ # - AUDIT SURFACE: beta archives retain every release asset on R2;
+ # stable releases and the rolling nightly attach them on GitHub.
- name: Publish the R2 channel (the channel serves no GitHub URL)
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
@@ -953,6 +963,20 @@ jobs:
--content-type text/plain \
--cache-control 'public, max-age=31536000, immutable'
+ # Beta tags no longer have individual GitHub release objects. Archive
+ # their audit assets before advancing any pointer, including superseded
+ # builds. The existing versioned tarballs + sums complete this payload.
+ if [[ "$RELEASE_VERSION" == *-beta* ]]; then
+ for artifact in release-out/*.debug.gz release-out/*.json; do
+ content_type=application/json
+ case "$artifact" in *.gz) content_type=application/gzip ;; esac
+ aws s3 cp "$artifact" "s3://${R2_BUCKET}/${RELEASE_PREFIX}/$(basename "$artifact")" \
+ --endpoint-url "$R2_ENDPOINT_URL" \
+ --content-type "$content_type" \
+ --cache-control 'public, max-age=31536000, immutable'
+ done
+ fi
+
# The rendered installer pairs: the repo files' defaults ARE the
# official domain, so the publish render only stamps the build's
# R2 base + channel default into the served copies. Production
@@ -1141,16 +1165,6 @@ jobs:
echo "stable channel advanced to ${RELEASE_VERSION} at ${INSTALL_BASE_URL}"
fi
fi
- - name: Install syft
- uses: anchore/sbom-action/download-syft@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2
- - name: Generate SPDX SBOM per target (unpacked artifact tree)
- run: |
- set -euo pipefail
- for dir in release-unpacked/*/; do
- target="$(basename "${dir}")"
- syft "dir:${dir}" -o "spdx-json=release-out/sbom-spdx-${RELEASE_VERSION#v}-${target}.json"
- done
- ls -la release-out/sbom-spdx-*
# [reserved] Apple notarization step goes here once certificates land:
# sign + notarize each darwin tarball's inner binary before attach.
- name: Attest build provenance (SLSA)
@@ -1161,16 +1175,12 @@ jobs:
release-out/prime-agent-*.tgz
release-out/*.debug.gz
- name: Attach to GitHub release
+ if: ${{ !contains(github.ref_name, '-') }}
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
- # A -beta* tag publishes the nightly channel as a GitHub PRE-RELEASE:
- # prereleases never take the Latest pointer, so the stable channel's
- # download base (.../releases/latest/download/) keeps serving the
- # latest stable release's latest.json (Bugbot: beta tags steal
- # GitHub Latest).
- prerelease: ${{ contains(github.ref_name, '-') }}
+ prerelease: false
fail_on_unmatched_files: true
files: |
release-out/prime-agent-*.tar.gz
@@ -1185,15 +1195,17 @@ jobs:
name: nightly-refresh-payload
path: |
release-out/prime-agent-*.tar.gz
+ release-out/prime-agent-*.tgz
+ release-out/*.debug.gz
release-out/SHA256SUMS
- release-out/beta.json
+ release-out/*.json
if-no-files-found: error
# The rolling `nightly` release is the nightly channel's discoverable base:
# GitHub's latest/download/ alias serves only the latest NON-prerelease
# release, so beta.json has no address there. Every -beta* tag refreshes
# the fixed `nightly` release's assets (.../releases/download/nightly/),
- # the base a nightly install records (.install-source). This job carries
+ # for direct GitHub downloads; installers use the R2 base. This job carries
# the workflow's only shared mutable state, so it - and it alone -
# serializes: the group lets one refresh run at a time (a queued refresh
# superseded by a newer tag is harmless: the newest beta's refresh wins,
@@ -1241,28 +1253,36 @@ jobs:
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
- # The rolling update channel distributes tarballs only. Per-tag
- # releases retain the separately attested decoder and full sums;
- # rolling SHA256SUMS must name only assets carried in this refresh.
- python3 - <<'PY'
- from pathlib import Path
- sums = Path("release-out/SHA256SUMS")
- rows = sums.read_text().splitlines()
- tar_rows = [row for row in rows if row.split()[-1].endswith(".tar.gz")]
- if not tar_rows:
- raise SystemExit("nightly refresh: missing tarball checksums")
- sums.write_text("\n".join(tar_rows) + "\n")
- PY
- if gh release view nightly >/dev/null 2>&1; then
+ (cd release-out && sha256sum --check SHA256SUMS)
+ # RELEASE_VERSION feeds every refresh path (guarded clobber, heal,
+ # bootstrap), so it is validated up front: a tag the strict nightly
+ # regex rejects fails closed here instead of publishing a nightly
+ # that later refreshes refuse to parse.
+ python3 <<'PY_RELEASE'
+ import os, re
+ version = os.environ["RELEASE_VERSION"]
+ if not re.fullmatch(r"v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+", version):
+ raise SystemExit(f"invalid nightly version: {version!r}")
+ PY_RELEASE
+ # Only an explicit API 404 permits bootstrap. Authentication, network,
+ # rate-limit, and malformed-response errors must not bypass the guard.
+ state="$(mktemp -d)"
+ trap 'rm -rf "$state"' EXIT
+ if gh release view nightly --json assets > "$state/release.json"; then
+ jq -e '.assets | type == "array" and all(.[]; .name | type == "string")' "$state/release.json" >/dev/null
+ jq -r '.assets[].name' "$state/release.json" > "$state/assets"
# The newest-wins guard protects the CURRENT beta.json, and it
# fails CLOSED: a release that carries a beta.json we cannot read
# is never clobbered (Bugbot: a discarded download failure fell
# through to --clobber, so a re-run of an older tag could replace
# a newer nightly). A release with NO beta.json asset (a partial
- # earlier refresh) has nothing to protect - the clobber heals it.
- if gh release view nightly --json assets --jq '.[].name' \
- 2>/dev/null | grep -qx "beta.json"; then
- guard="$(mktemp -d)"
+ # earlier refresh) lost its version witness, but its tarball names
+ # still name versions: the heal clobbers only when this refresh is
+ # the newest version the release serves, fails closed when a
+ # tarball's name cannot be read, and an empty release (a bootstrap
+ # interrupted before any upload) heals unconditionally.
+ if grep -qx "beta.json" "$state/assets"; then
+ guard="$state"
ok=0
for attempt in 1 2 3; do
if gh release download nightly --pattern beta.json \
@@ -1278,24 +1298,64 @@ jobs:
echo "could not read the rolling nightly's beta.json; refusing to clobber it (re-run this refresh once the release is readable)" >&2
exit 1
fi
- current="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' "$guard/beta.json")"
+ current="$(python3 - "$guard/beta.json" <<'PY_VERSION'
+ import json, os, re, sys
+ current = json.load(open(sys.argv[1]))["version"]
+ for version in (current, os.environ["RELEASE_VERSION"]):
+ if not isinstance(version, str) or not re.fullmatch(r"v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+", version):
+ raise SystemExit(f"invalid nightly version: {version!r}")
+ print(current)
+ PY_VERSION
+ )"
newest="$(printf '%s\n%s\n' "$current" "$RELEASE_VERSION" | sort -V | tail -1)"
if [ "$newest" != "$RELEASE_VERSION" ]; then
echo "the rolling nightly release already serves $current >= $RELEASE_VERSION; skipping the refresh"
exit 0
fi
+ else
+ served="$(python3 - "$state/assets" <<'PY_ASSETS'
+ import re, sys
+ versions = []
+ for name in open(sys.argv[1]).read().split():
+ if not name.endswith(('.tar.gz', '.tgz')):
+ continue
+ body = name[: -len('.tar.gz')] if name.endswith('.tar.gz') else name[: -len('.tgz')]
+ match = re.fullmatch(r'prime-agent-([0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+)(?:-.+)?', body)
+ if match is None:
+ raise SystemExit(f"cannot read a version from the nightly asset name: {name!r}")
+ versions.append('v' + match.group(1))
+ print('\n'.join(versions))
+ PY_ASSETS
+ )"
+ newest="$(printf '%s\n%s\n' "$served" "$RELEASE_VERSION" | sort -V | tail -1)"
+ if [ "$newest" != "$RELEASE_VERSION" ]; then
+ echo "the rolling nightly release already serves $newest >= $RELEASE_VERSION; skipping the refresh"
+ exit 0
+ fi
fi
gh release upload nightly \
release-out/prime-agent-*.tar.gz \
+ release-out/prime-agent-*.tgz \
+ release-out/*.debug.gz \
release-out/SHA256SUMS \
- release-out/beta.json \
+ release-out/*.json \
--clobber
else
+ if gh api --include "repos/${GH_REPO}/releases/tags/nightly" > "$state/response"; then
+ echo "nightly exists but could not be inspected; refusing to overwrite" >&2
+ exit 1
+ fi
+ if ! grep -Eq '^HTTP/[0-9.]+ 404([[:space:]]|$)' "$state/response"; then
+ echo "could not establish that nightly is absent; refusing to publish" >&2
+ exit 1
+ fi
gh release create nightly \
--title "nightly" \
--notes "The rolling nightly channel (beta builds). Assets are overwritten per -beta* tag; beta.json names the current build." \
--prerelease \
release-out/prime-agent-*.tar.gz \
+ release-out/prime-agent-*.tgz \
+ release-out/*.debug.gz \
release-out/SHA256SUMS \
- release-out/beta.json
+ release-out/*.json
fi
diff --git a/crates/pa-core/tests/release_channel_manifest.rs b/crates/pa-core/tests/release_channel_manifest.rs
index 69501ed5a3..d6d3450c07 100644
--- a/crates/pa-core/tests/release_channel_manifest.rs
+++ b/crates/pa-core/tests/release_channel_manifest.rs
@@ -250,17 +250,21 @@ fn the_workflow_wires_the_channel_manifest_producer() {
files.contains("release-out/*.json"),
"the attach list must carry the channel manifest via a json glob"
);
- // A -beta* tag attaches as a GitHub PRE-RELEASE so the nightly can never take the Latest
- // pointer; the stable channel's download base (.../releases/latest/download/) keeps serving the
- // last stable release's latest.json (Bugbot: beta tags steal GitHub Latest).
+ // Only stable tags attach individual GitHub releases. Beta assets use the
+ // rolling nightly release and versioned R2 archive instead.
+ assert_eq!(
+ attach_step.r#if.as_deref(),
+ Some("${{ !contains(github.ref_name, '-') }}"),
+ "individual GitHub releases are stable-only"
+ );
let prerelease = attach_step
.with
.as_ref()
.and_then(|with| with.prerelease.as_deref())
.expect("the attach step must decide prerelease-ness");
assert_eq!(
- prerelease, "${{ contains(github.ref_name, '-') }}",
- "the attach step must mark prerelease-tag releases as prereleases"
+ prerelease, "false",
+ "the stable attachment remains a non-prerelease"
);
// Every tag promotes under its own group: a queued promotion is never
// canceled by another tag's push, so every published tag gets its
@@ -334,16 +338,16 @@ fn the_rolling_nightly_refresh_is_a_serialized_job() {
.as_deref()
.expect("the refresh step runs a script");
assert!(run.contains("gh release upload nightly"), "{run}");
- assert!(run.contains("release-out/beta.json"), "{run}");
+ assert!(run.contains("release-out/*.json"), "{run}");
assert!(run.contains("--clobber"), "{run}");
assert!(run.contains("--prerelease"), "{run}");
assert!(run.contains("release-out/prime-agent-*.tar.gz"), "{run}");
// The newest-wins guard: re-runs of an older tag must never clobber a newer rolling beta.json;
// gh release download's destination flag is --dir (Bugbot: --output-dir was discarded and never
// wrote the guard file). The guard FAILS CLOSED: a release carrying an unreadable beta.json is
- // never clobbered (Bugbot: a discarded download failure fell through to --clobber), while a
- // release with NO beta.json asset (a partial earlier refresh) has nothing to protect - the
- // clobber heals it.
+ // never clobbered (Bugbot: a discarded download failure fell through to --clobber), and a
+ // witnessless release clobbers only when its own tarball asset names carry no newer version -
+ // an empty release (no versioned assets at all) heals unconditionally.
assert!(run.contains("sort -V"), "{run}");
assert!(run.contains("skipping the refresh"), "{run}");
assert!(run.contains(r#"--dir "$guard""#), "{run}");
diff --git a/scripts/release/README.md b/scripts/release/README.md
new file mode 100644
index 0000000000..12c6481aaa
--- /dev/null
+++ b/scripts/release/README.md
@@ -0,0 +1,30 @@
+# Release publication
+
+Eligible main commits still produce unique beta versions and tags through
+`nightly.yml`. `release.yml` retains the five-platform build/reuse routes and
+publishes versioned installer payloads to R2. Only stable tags create individual
+GitHub releases; beta tags refresh the single prerelease named `nightly`.
+
+For future beta versions, the public R2 prefix
+`releases/v<version>/` retains the entire published payload: platform tarballs,
+Linux debug decoders, the npm migration bridge, SHA256SUMS, merged manifest,
+beta.json, and per-target SPDX SBOMs. Audit files upload before channel pointers
+advance, even when a newer main commit has superseded the build. The existing
+provenance attestation step continues to cover tarballs and decoders. The rolling
+nightly release also carries the full current payload and checksums.
+
+Installers and native/npm updaters keep using the R2 channel manifests and
+versioned payload paths anonymously; they do not require per-beta GitHub release
+objects. Consumers of `/releases/download/v<beta>/...` must use the public R2
+versioned prefix for future beta builds, or `nightly` for its current payload.
+Stable GitHub asset URLs retain their existing behavior.
+
+No historical releases or assets are removed. Versioned nightly asset names
+continue to accumulate; retention and historical cleanup require a separate
+decision. The R2 channel comparator repair remains in PR #3452; this change only
+hardens the independent rolling GitHub newest-wins guard.
+
+`python3 scripts/release/test_release_publication.py` executes the workflow shell
+against local GitHub/R2 fakes, including stale reruns, failed reads, complete
+payloads, interrupted bootstrap, and superseded beta archival. It performs no
+network requests or real publication.
diff --git a/scripts/release/test_release_publication.py b/scripts/release/test_release_publication.py
new file mode 100644
index 0000000000..a6bb3a1ac1
--- /dev/null
+++ b/scripts/release/test_release_publication.py
@@ -0,0 +1,210 @@
+#!/usr/bin/env python3
+"""Execute release workflow shell with local gh/aws fakes; never publish anything."""
+import hashlib
+import json
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+import unittest
+
+REPO = Path(__file__).resolve().parents[2]
+WORKFLOW = REPO / '.github/workflows/release.yml'
+
+
+def step_script(name):
+ step = WORKFLOW.read_text().split(f' - name: {name}\n', 1)[1]
+ step = step.split(' - name:', 1)[0].split(' run: |\n', 1)[1]
+ lines = []
+ for line in step.splitlines():
+ if line.strip() and not line.startswith(' '):
+ break
+ lines.append(line[10:])
+ return '\n'.join(lines)
+
+
+FAKE_GH = r'''#!/usr/bin/env python3
+import json, os, pathlib, sys
+args = sys.argv[1:]
+mode = os.environ.get('MODE', 'existing')
+with open('calls.jsonl', 'a') as f:
+ f.write(json.dumps(args) + '\n')
+if args[:2] == ['release', 'view']:
+ if mode in ('absent', 'api-error', 'view-error'):
+ sys.exit(1)
+ response = {'assets': [{'name': 'beta.json'}]}
+ if mode == 'empty': response = {'assets': []}
+ if mode == 'malformed': response = {'assets': [{'other': 'beta.json'}]}
+ if mode == 'wrong-shape': response = []
+ if mode in ('no-beta-newer', 'no-beta-older', 'no-beta-unparsable'):
+ served = '0.10.1-beta.11' if mode == 'no-beta-newer' else '0.10.1-beta.9'
+ names = [f'prime-agent-{served}-linux-x64.tar.gz', 'prime-agent-0.9.9-beta.999.tgz',
+ 'prime-agent-linux.debug.gz', 'SHA256SUMS', 'manifest.json']
+ if mode == 'no-beta-unparsable': names = ['prime-agent-unversioned.tar.gz', 'SHA256SUMS']
+ response = {'assets': [{'name': name} for name in names]}
+ print(json.dumps(response))
+elif args[:2] == ['release', 'download']:
+ if mode == 'download-error': sys.exit(1)
+ path = pathlib.Path(args[args.index('--dir') + 1]) / 'beta.json'
+ path.write_text(json.dumps({'version': os.environ['CURRENT']}))
+elif args[:2] in (['release', 'upload'], ['release', 'create']):
+ for arg in args:
+ if arg.startswith('release-out/'):
+ assert pathlib.Path(arg).is_file(), arg
+elif args[0] == 'api':
+ if '--include' in args:
+ status = '404 Not Found' if mode == 'absent' else '503 Service Unavailable'
+ if mode == 'view-error': status = '200 OK'
+ print('HTTP/2.0 ' + status + '\n\n{}')
+ sys.exit(0 if mode == 'view-error' else 1)
+ if '/git/ref/' in args[1]: print(json.dumps({'object': {'type': 'commit', 'sha': 'tag'}}))
+ elif '/git/commits/' in args[1]: print('built')
+ elif '/commits/main' in args[1]: print('newer')
+ else: sys.exit(2)
+else: sys.exit(2)
+'''
+
+FAKE_AWS = r'''#!/usr/bin/env python3
+import json, os, pathlib, sys
+args = sys.argv[1:]
+assert args[:2] == ['s3', 'cp'], args
+assert pathlib.Path(args[2]).is_file(), args
+with open('uploads.jsonl', 'a') as f: f.write(json.dumps(args) + '\n')
+if os.environ.get('FAIL_ARCHIVE') == '1' and args[2].endswith('.debug.gz'): sys.exit(1)
+'''
+
+
+class PublicationTests(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.root = Path(self.temp.name)
+ self.bin = self.root / 'bin'
+ self.bin.mkdir()
+ for name, script in [('gh', FAKE_GH), ('aws', FAKE_AWS), ('sleep', '#!/bin/sh\nexit 0\n')]:
+ path = self.bin / name
+ path.write_text(script)
+ path.chmod(0o755)
+ self.version = 'v0.10.1-beta.10'
+ self.env = dict(os.environ, PATH=f'{self.bin}:{os.environ["PATH"]}',
+ RELEASE_VERSION=self.version, CURRENT='v0.10.1-beta.9',
+ GH_REPO='owner/repo', GITHUB_REPOSITORY='owner/repo',
+ GITHUB_REF_NAME=self.version, R2_BUCKET='bucket',
+ R2_ENDPOINT_URL='https://invalid.example',
+ R2_PUBLIC_BASE_URL='https://invalid.example')
+ self.out = self.root / 'release-out'
+ self.out.mkdir()
+ names = [f'prime-agent-{self.version[1:]}-{p}.tar.gz' for p in
+ ('darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64')]
+ names += [f'prime-agent-{self.version[1:]}.tgz', 'prime-agent-linux.debug.gz',
+ 'manifest.json', 'beta.json', 'sbom-spdx-linux.json']
+ for name in names:
+ (self.out / name).write_text('{}')
+ self.sums = ''.join(f'{hashlib.sha256(b"{}").hexdigest()} {name}\n'
+ for name in names if name.endswith(('.gz', '.tgz')))
+ (self.out / 'SHA256SUMS').write_text(self.sums)
+
+ def run_step(self, name, **env):
+ return subprocess.run(['bash', '-c', step_script(name)], cwd=self.root,
+ env=dict(self.env, **env), capture_output=True, text=True)
+
+ def mutations(self):
+ calls = self.root / 'calls.jsonl'
+ return [a for a in map(json.loads, calls.read_text().splitlines())
+ if a[:2] in (['release', 'upload'], ['release', 'create'])] if calls.exists() else []
+
+ def refresh(self, **env):
+ return self.run_step('Refresh the rolling nightly release', **env)
+
+ def test_existing_release_preserves_complete_payload_and_checksums(self):
+ result = self.refresh()
+ self.assertEqual(result.returncode, 0, result.stderr)
+ mutations = self.mutations()
+ self.assertEqual(len(mutations), 1)
+ self.assertEqual(mutations[0][:3], ['release', 'upload', 'nightly'])
+ self.assertEqual({a for a in mutations[0] if a.startswith('release-out/')},
+ {f'release-out/{p.name}' for p in self.out.iterdir()})
+ self.assertEqual((self.out / 'SHA256SUMS').read_text(), self.sums)
+
+ def test_corrupt_payload_never_publishes(self):
+ (self.out / "prime-agent-linux.debug.gz").write_text("corrupt")
+ result = self.refresh()
+ self.assertNotEqual(result.returncode, 0)
+ self.assertEqual(self.mutations(), [])
+
+ def test_newer_release_blocks_stale_rerun(self):
+ for current in ('v0.10.1-beta.11', 'v0.11.0-beta.1', 'v1.0.0-beta.1'):
+ with self.subTest(current=current):
+ result = self.refresh(CURRENT=current)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(self.mutations(), [])
+
+ def test_same_version_rerun_and_new_numeric_base_can_publish(self):
+ for current in (self.version, 'v0.9.9-beta.999'):
+ with self.subTest(current=current):
+ (self.root / 'calls.jsonl').write_text('')
+ result = self.refresh(CURRENT=current)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(len(self.mutations()), 1)
+
+ def test_unreadable_state_fails_closed(self):
+ for mode in ('api-error', 'view-error', 'malformed', 'wrong-shape', 'download-error'):
+ with self.subTest(mode=mode):
+ result = self.refresh(MODE=mode)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertEqual(self.mutations(), [])
+
+ def test_invalid_version_fails_closed(self):
+ for current in ('', 'not-a-version', 'v0.10.1', 'v0.10.1-beta.9\nv9.0.0-beta.1'):
+ with self.subTest(current=current):
+ result = self.refresh(CURRENT=current)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertEqual(self.mutations(), [])
+
+ def test_confirmed_absence_bootstraps_and_empty_release_heals(self):
+ for mode, operation in (('absent', 'create'), ('empty', 'upload')):
+ with self.subTest(mode=mode):
+ (self.root / 'calls.jsonl').write_text('')
+ result = self.refresh(MODE=mode)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(self.mutations()[0][:3], ['release', operation, 'nightly'])
+
+ def test_witnessless_release_blocks_stale_rerun(self):
+ result = self.refresh(MODE='no-beta-newer')
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertIn('already serves v0.10.1-beta.11', result.stdout)
+ self.assertEqual(self.mutations(), [])
+
+ def test_witnessless_release_heals_when_this_refresh_is_newest(self):
+ result = self.refresh(MODE='no-beta-older')
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(self.mutations()[0][:3], ['release', 'upload', 'nightly'])
+
+ def test_witnessless_release_with_unreadable_asset_names_fails_closed(self):
+ result = self.refresh(MODE='no-beta-unparsable')
+ self.assertNotEqual(result.returncode, 0)
+ self.assertEqual(self.mutations(), [])
+
+ def test_malformed_release_version_fails_closed_on_bootstrap_and_heal(self):
+ for mode in ('absent', 'empty'):
+ with self.subTest(mode=mode):
+ result = self.refresh(MODE=mode, RELEASE_VERSION='v0.10.1-beta2')
+ self.assertNotEqual(result.returncode, 0)
+ self.assertEqual(self.mutations(), [])
+
+ def test_superseded_beta_archives_every_file_without_advancing_pointers(self):
+ result = self.run_step('Publish the R2 channel (the channel serves no GitHub URL)')
+ self.assertEqual(result.returncode, 0, result.stderr)
+ uploads = list(map(json.loads, (self.root / 'uploads.jsonl').read_text().splitlines()))
+ self.assertEqual({a[3] for a in uploads},
+ {f's3://bucket/releases/{self.version}/{p.name}' for p in self.out.iterdir()})
+ self.assertTrue(all(a[-1] == 'public, max-age=31536000, immutable' for a in uploads))
+
+ def test_archive_failure_stops_promotion(self):
+ result = self.run_step('Publish the R2 channel (the channel serves no GitHub URL)', FAIL_ARCHIVE='1')
+ self.assertNotEqual(result.returncode, 0)
+ self.assertFalse((self.root / 'calls.jsonl').exists())
+
+
+if __name__ == '__main__':
+ unittest.main()