A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
release: bundle the live catalog instead of the fixture snapshot (#3763)
ktb800e2ef6de7
diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.ymlindex e398187dd6..ce872525bb 100644--- a/.github/workflows/continuous.yml+++ b/.github/workflows/continuous.yml@@ -64,6 +64,30 @@ jobs:echo "superseded=false" >> "${GITHUB_OUTPUT}"fi+ # The prime-agent-catalog commit every build job bundles, resolved once+ # per run so all targets ship the same catalog revision.+ catalog-ref:+ name: Resolve the bundled catalog commit+ runs-on: ubuntu-latest+ permissions:+ contents: read+ outputs:+ sha: ${{ steps.resolve.outputs.sha }}+ steps:+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2+ with:+ persist-credentials: false+ - name: Resolve prime-agent-catalog main+ id: resolve+ env:+ # Authenticated lookups avoid the shared-runner anonymous API limit.+ GITHUB_TOKEN: ${{ github.token }}+ run: |+ set -euo pipefail+ sha="$(python3 scripts/release/bundle_catalog.py resolve-ref)"+ echo "sha=${sha}" >> "${GITHUB_OUTPUT}"+ echo "bundling prime-agent-catalog ${sha}"+# The dependency audit gate (RELEASE_SECURITY pragmatic baseline): the# same advisories + licenses check as `make deny` (deny.toml), on every# tree the branch channel builds binaries from. Advisories that are@@ -85,7 +109,7 @@ jobs:# The audit gates every build: an unaudited tree must not produce# downloadable branch-channel binaries.build-gnu:- needs: [deny, staleness]+ needs: [deny, staleness, catalog-ref]if: needs.staleness.outputs.superseded != 'true'name: build-${{ matrix.target }}runs-on: ${{ matrix.runs-on }}@@ -180,11 +204,16 @@ jobs:echo "::error::binary requires ${max_glibc}, above the GLIBC_2.35 (Ubuntu 22.04) release baseline"exit 1fi- - name: Generate bundled catalog assets (fixture, offline-safe)+ # The live catalog from prime-agent-catalog (public; no token needed)+ # at the commit the catalog-ref job resolved: a fresh install's first+ # model list comes from this snapshot, identical across targets.+ - name: Generate bundled catalog assets (live catalog)+ env:+ CATALOG_REF: ${{ needs.catalog-ref.outputs.sha }}run: |set -euo pipefail- python3 scripts/release/bundle_catalog.py generate --fixture \- --out "target/${{ matrix.target }}/catalog-assets"+ python3 scripts/release/bundle_catalog.py generate --network \+ --catalog-ref "${CATALOG_REF}" --out "target/${{ matrix.target }}/catalog-assets"- name: Assemble tarball + checksums + manifest (commit-stamped)run: |set -euo pipefail@@ -221,7 +250,7 @@ jobs:if-no-files-found: errorbuild-darwin:- needs: [deny, staleness]+ needs: [deny, staleness, catalog-ref]if: needs.staleness.outputs.superseded != 'true'name: build-${{ matrix.target }}runs-on: ${{ matrix.runs-on }}@@ -267,11 +296,16 @@ jobs:# no consumer (~26% of the build step, measured).- name: Build (release, locked)run: cargo build --release --locked --target ${{ matrix.target }} -j 4 -p pa-cli --bin prime-agent- - name: Generate bundled catalog assets (fixture, offline-safe)+ # The live catalog from prime-agent-catalog (public; no token needed)+ # at the commit the catalog-ref job resolved: a fresh install's first+ # model list comes from this snapshot, identical across targets.+ - name: Generate bundled catalog assets (live catalog)+ env:+ CATALOG_REF: ${{ needs.catalog-ref.outputs.sha }}run: |set -euo pipefail- python3 scripts/release/bundle_catalog.py generate --fixture \- --out "target/${{ matrix.target }}/catalog-assets"+ python3 scripts/release/bundle_catalog.py generate --network \+ --catalog-ref "${CATALOG_REF}" --out "target/${{ matrix.target }}/catalog-assets"- name: Assemble tarball + checksums + manifest (commit-stamped)run: |set -euo pipefaildiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex e04c2a0b23..5fee6ce1ac 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -80,8 +80,32 @@ jobs:*) echo "stable channel: the release publishes latest.json" ;;esac+ # The prime-agent-catalog commit every build job bundles, resolved once+ # per run so all targets ship the same catalog revision.+ catalog-ref:+ name: Resolve the bundled catalog commit+ runs-on: ubuntu-latest+ permissions:+ contents: read+ outputs:+ sha: ${{ steps.resolve.outputs.sha }}+ steps:+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2+ with:+ persist-credentials: false+ - name: Resolve prime-agent-catalog main+ id: resolve+ env:+ # Authenticated lookups avoid the shared-runner anonymous API limit.+ GITHUB_TOKEN: ${{ github.token }}+ run: |+ set -euo pipefail+ sha="$(python3 scripts/release/bundle_catalog.py resolve-ref)"+ echo "sha=${sha}" >> "${GITHUB_OUTPUT}"+ echo "bundling prime-agent-catalog ${sha}"+build-gnu:- needs: tag-check+ needs: [tag-check, catalog-ref]# Stable-only: a -beta* tag consumes the continuous build instead (the# reuse-continuous job); exactly one of the two routes runs per tag.if: ${{ !contains(github.ref_name, '-') }}@@ -202,11 +226,16 @@ jobs:echo "::error::binary requires ${max_glibc}, above the GLIBC_2.35 (Ubuntu 22.04) release baseline"exit 1fi- - name: Generate bundled catalog assets (fixture, offline-safe)+ # The live catalog from prime-agent-catalog (public; no token needed)+ # at the commit the catalog-ref job resolved: a fresh install's first+ # model list comes from this snapshot, identical across targets.+ - name: Generate bundled catalog assets (live catalog)+ env:+ CATALOG_REF: ${{ needs.catalog-ref.outputs.sha }}run: |set -euo pipefail- python3 scripts/release/bundle_catalog.py generate --fixture \- --out "target/${{ matrix.target }}/catalog-assets"+ python3 scripts/release/bundle_catalog.py generate --network \+ --catalog-ref "${CATALOG_REF}" --out "target/${{ matrix.target }}/catalog-assets"- name: Assemble tarball + checksums + manifest# Assemble from the separate SHIPPED image; the Cargo binary stays# unstripped. The decoder remains a separate release asset.@@ -285,7 +314,7 @@ jobs:if-no-files-found: errorbuild-darwin:- needs: tag-check+ needs: [tag-check, catalog-ref]# Stable-only: a -beta* tag consumes the continuous build instead (the# reuse-continuous job); exactly one of the two routes runs per tag.if: ${{ !contains(github.ref_name, '-') }}@@ -343,11 +372,16 @@ jobs:bin="target/${{ matrix.target }}/release/prime-agent"out="$("${bin}" --version)"[[ "${out}" == "${RELEASE_VERSION#v}" ]] || { echo "binary reports '${out}', expected '${RELEASE_VERSION#v}'"; exit 1; }- - name: Generate bundled catalog assets (fixture, offline-safe)+ # The live catalog from prime-agent-catalog (public; no token needed)+ # at the commit the catalog-ref job resolved: a fresh install's first+ # model list comes from this snapshot, identical across targets.+ - name: Generate bundled catalog assets (live catalog)+ env:+ CATALOG_REF: ${{ needs.catalog-ref.outputs.sha }}run: |set -euo pipefail- python3 scripts/release/bundle_catalog.py generate --fixture \- --out "target/${{ matrix.target }}/catalog-assets"+ python3 scripts/release/bundle_catalog.py generate --network \+ --catalog-ref "${CATALOG_REF}" --out "target/${{ matrix.target }}/catalog-assets"- name: Assemble tarball + checksums + manifestrun: |set -euo pipefail@@ -404,7 +438,7 @@ jobs:# builds the tag commit itself on either route and uploads the same# artifacts-<target> shape into this run.build-windows:- needs: tag-check+ needs: [tag-check, catalog-ref]name: build-${{ matrix.target }}runs-on: ${{ matrix.runs-on }}permissions:@@ -458,12 +492,17 @@ jobs:bin="target/${{ matrix.target }}/release/prime-agent.exe"out="$("${bin}" --version)"[[ "${out}" == "${RELEASE_VERSION#v}" ]] || { echo "binary reports '${out}', expected '${RELEASE_VERSION#v}'"; exit 1; }- - name: Generate bundled catalog assets (fixture, offline-safe)+ # The live catalog from prime-agent-catalog (public; no token needed)+ # at the commit the catalog-ref job resolved: a fresh install's first+ # model list comes from this snapshot, identical across targets.+ - name: Generate bundled catalog assets (live catalog)shell: bash+ env:+ CATALOG_REF: ${{ needs.catalog-ref.outputs.sha }}run: |set -euo pipefail- "${PY}" scripts/release/bundle_catalog.py generate --fixture \- --out "target/${{ matrix.target }}/catalog-assets"+ "${PY}" scripts/release/bundle_catalog.py generate --network \+ --catalog-ref "${CATALOG_REF}" --out "target/${{ matrix.target }}/catalog-assets"- name: Assemble tarball + checksums + manifestshell: bashrun: |diff --git a/Makefile b/Makefileindex c178551f47..509bf5b2e7 100644--- a/Makefile+++ b/Makefile@@ -77,10 +77,11 @@ RUNTIME_DIR ?=RUNTIME_FLAG = $(if $(RUNTIME_DIR),--runtime-dir $(RUNTIME_DIR),)# Bundled catalog assets (catalog spec §3.2 layer 2): generated at build-# time, never committed. CI generates the offline fixture snapshot (it passes-# the full packer gates: >= 42 transport tuples, >= 68 services) so builds-# never depend on the catalog repo being reachable; CATALOG_ASSETS_MODE=network-# switches the dry-runs to the live fetch for packaging parity.+# time, never committed. Release and continuous CI ship the live catalog+# (--network) at one prime-agent-catalog commit per run (`bundle_catalog.py+# resolve-ref`). The local dry-runs default to the offline fixture snapshot+# (it passes the full packer gates); CATALOG_ASSETS_MODE=network switches+# them to the live fetch of the catalog's main.CATALOG_ASSETS_DIR = target/catalog-assetsCATALOG_ASSETS_MODE ?= fixtureCATALOG_ASSETS_FLAG = --catalog-assets $(CATALOG_ASSETS_DIR)@@ -104,8 +105,7 @@ RELEASE_PACKAGE_BUILD = :RELEASE_PACKAGE_FLAGS =endif-# Live-catalog asset generation (network fetch; packaging parity with the-# TS release flow — CI itself uses the fixture snapshot for reliability).+# Live-catalog asset generation (network fetch; what release CI ships).catalog-assets:python3 scripts/release/bundle_catalog.py generate --network --out $(CATALOG_ASSETS_DIR)diff --git a/crates/pa-models/tests/parity.rs b/crates/pa-models/tests/parity.rsindex f88ef42c5f..52bfda32b8 100644--- a/crates/pa-models/tests/parity.rs+++ b/crates/pa-models/tests/parity.rs@@ -44,14 +44,15 @@ fn every_real_entry_survives_transport_pinning() {#[test]fn passes_the_packer_gates() {- // The build lane's gate: >= 42 distinct (provider, api, baseUrl) tuples.+ // The build lane's gate: >= 30 distinct (provider, api, baseUrl) tuples+ // (scripts/release/bundle_catalog.py MIN_MODEL_TRANSPORT_TUPLES).let parsed = parse_model_catalog(&fixture(), InvalidEntries::Reject).unwrap();let tuples: std::collections::HashSet<(&str, &str, &str)> = parsed.models.iter().map(|m| (m.provider.as_str(), m.api.as_str(), m.base_url.as_str())).collect();- assert!(tuples.len() >= 42, "packer gate: >=42 transport tuples");+ assert!(tuples.len() >= 30, "packer gate: >=30 transport tuples");let compiled: std::collections::HashSet<(String, String, String)> =transports::compiled_models().iter()diff --git a/scripts/package_release.py b/scripts/package_release.pyindex f60a1ad4d3..461973a279 100644--- a/scripts/package_release.py+++ b/scripts/package_release.py@@ -30,8 +30,8 @@ the tarball and binaries.json. No network publishing happens here.`--catalog-assets <dir>` supplies the generated bundled catalog assets(scripts/release/bundle_catalog.py generates them); the packer hard-fails-without VALIDATED assets (version gates + >= 42 transport tuples + >= 68-services).+without VALIDATED assets (version gates + the transport-tuple and service+minimums in bundle_catalog.py)."""import argparsediff --git a/scripts/release/assemble_artifacts.py b/scripts/release/assemble_artifacts.pyindex afdc6b3291..f718c2fb3e 100755--- a/scripts/release/assemble_artifacts.py+++ b/scripts/release/assemble_artifacts.py@@ -16,10 +16,11 @@ Usage:`--catalog-assets` is the directory holding the generated bundled catalogassets (`models.bundled.json` + `mcp-services.bundled.json`); the packer-hard-fails without VALIDATED assets (version gates + >= 42 transport tuples +->= 68 services — see scripts/release/bundle_catalog.py, the catalog spec §3.2-no-cold-start layer 2). CI generates them from the live catalog repo; offline-builds use `bundle_catalog.py generate --fixture`.+hard-fails without VALIDATED assets (version gates + the transport-tuple and+service minimums — see scripts/release/bundle_catalog.py, the catalog spec+§3.2 no-cold-start layer 2). CI generates them from the live catalog repo at+one resolved commit per run; offline builds use+`bundle_catalog.py generate --fixture`.`--binary` defaults to `<repo>/target/<target>/release/<binary-name>` (crossbuilds) and falls back to `<repo>/target/release/<binary-name>` (host builds),diff --git a/scripts/release/assemble_source.py b/scripts/release/assemble_source.pyindex b4cc5faf2b..a0a77860e4 100644--- a/scripts/release/assemble_source.py+++ b/scripts/release/assemble_source.py@@ -18,10 +18,11 @@ Usage:`--catalog-assets` is the directory holding the generated bundled catalogassets (models.bundled.json + mcp-services.bundled.json); the packer-hard-fails without VALIDATED assets (version gates + >= 42 transport-tuples + >= 68 services — see scripts/release/bundle_catalog.py, the-catalog spec §3.2 no-cold-start layer 2), exactly like assemble_artifacts.-CI generates them from the fixture snapshot per build job; offline runs use+hard-fails without VALIDATED assets (version gates + the transport-tuple+and service minimums — see scripts/release/bundle_catalog.py, the catalog+spec §3.2 no-cold-start layer 2), exactly like assemble_artifacts. The+release workflow passes the build-gnu job's assets: the live catalog at the+one prime-agent-catalog commit the run resolved. Offline runs use`bundle_catalog.py generate --fixture`.`--version` must be a BARE semver (no prerelease/continuous suffix). Thediff --git a/scripts/release/bundle_catalog.py b/scripts/release/bundle_catalog.pyindex 6db8a522cb..e7948d7442 100644--- a/scripts/release/bundle_catalog.py+++ b/scripts/release/bundle_catalog.py@@ -23,12 +23,17 @@ Validation (the release packer runs the same functions before packing):Usage:python3 scripts/release/bundle_catalog.py generate \[--catalog-dir DIR | --network | --fixture] [--out DIR] \- [--models-url URL] [--mcp-services-url URL] [--allow-small-fixture]+ [--catalog-ref REF] [--models-url URL] [--mcp-services-url URL] \+ [--allow-small-fixture]python3 scripts/release/bundle_catalog.py verify [--out DIR] [--allow-small-fixture]+ python3 scripts/release/bundle_catalog.py resolve-refNetwork mode reads GITHUB_TOKEN / PRIME_CATALOG_REPO_TOKEN (optional Bearer;-the catalog repo is public), aborts after 5 s, refuses redirects, and caps-responses at MAX_REMOTE_CATALOG_BYTES.+the catalog repo is public), aborts each attempt after 5 s, retries transient+failures twice, refuses redirects, and caps responses at+MAX_REMOTE_CATALOG_BYTES. Release CI runs `resolve-ref` once per workflow run+and passes the commit to every build job's `--catalog-ref`, so all targets+bundle one catalog revision."""from __future__ import annotations@@ -50,25 +55,42 @@ ROOT = Path(__file__).resolve().parent.parent.parent# The two bundled asset names (spec §3.2; TS bundledCatalogFiles).BUNDLED_CATALOG_FILES = ("models.bundled.json", "mcp-services.bundled.json")-# Release-gate minimums (spec §3.2/§3.9). The shipped TS tool still carries-# MIN_BUNDLED_MCP_SERVICES = 20 from before the service count grew; this port-# uses the verified current contract: >= 42 transport tuples, >= 68 services.-MIN_MODEL_TRANSPORT_TUPLES = 42-MIN_MCP_SERVICES = 68+# Release-gate minimums (spec §3.2/§3.9): sanity floors that catch a+# truncated, emptied or wrong catalog file. They gate the live catalog, and+# prime-agent-catalog's own validator has no minimums, so they sit below the+# live counts (42 transport tuples and 69 services on 2026-10-23): removing a+# provider endpoint or a few services there must not block every build. The+# shipped TS tool carries MIN_BUNDLED_MCP_SERVICES = 20.+MIN_MODEL_TRANSPORT_TUPLES = 30+MIN_MCP_SERVICES = 50+# The offline fixture's generated service count (plus the special entries).+FIXTURE_MCP_SERVICES = 68-DEFAULT_MODEL_CATALOG_URL = (- "https://raw.githubusercontent.com/PrimeIntellect-ai/prime-agent-catalog"- "/main/models/catalog.v1.json"-)-DEFAULT_MCP_SERVICE_CATALOG_URL = (- "https://raw.githubusercontent.com/PrimeIntellect-ai/prime-agent-catalog"- "/main/plugins/catalog.v2.json"-)+CATALOG_REPO = "PrimeIntellect-ai/prime-agent-catalog"+MODEL_CATALOG_PATH = "models/catalog.v1.json"+MCP_SERVICE_CATALOG_PATH = "plugins/catalog.v2.json"+++def catalog_url(ref: str, path: str) -> str:+ """The raw URL of one catalog file at a branch or commit of the repo."""+ return f"https://raw.githubusercontent.com/{CATALOG_REPO}/{ref}/{path}"+++DEFAULT_MODEL_CATALOG_URL = catalog_url("main", MODEL_CATALOG_PATH)+DEFAULT_MCP_SERVICE_CATALOG_URL = catalog_url("main", MCP_SERVICE_CATALOG_PATH)+# The commit lookup `resolve-ref` uses; the sha media type answers with the+# bare 40-hex commit id.+CATALOG_COMMIT_URL = f"https://api.github.com/repos/{CATALOG_REPO}/commits/main"+COMMIT_SHA_PATTERN = re.compile(r"[0-9a-f]{40}")# Build-time fetch limits (TS parity: 20 MiB cap, 5 s hard timeout, no# redirects — a moved catalog must be a client change).MAX_REMOTE_CATALOG_BYTES = 20 * 1024 * 1024FETCH_TIMEOUT_SECONDS = 5+# Transient failures (connection errors, timeouts, HTTP 429/5xx) retry with+# these backoffs between attempts; a 4xx, a redirect or an oversized body+# fails at once, and so does validation, which runs after the fetch.+FETCH_RETRY_BACKOFF_SECONDS = (2, 5)# The 14 derived count keys of the plugins v2 envelope (spec §1.2).COUNTS_KEYS = (@@ -639,7 +661,7 @@ def fixture_special_services() -> list:def fixture_mcp_services() -> list:- """68 services covering every transport kind, auth strategy, setup+ """FIXTURE_MCP_SERVICES services covering every transport kind, auth strategy, setupstatus, readiness value, and verification status, plus the specialpaste-flow/builtin-shadow entries the runtime lane consumes."""entries = []@@ -651,7 +673,7 @@ def fixture_mcp_services() -> list:("sse", "none", "requires-setup", "unknown", False),("stdio", "unknown", "requires-setup", "prime-restricted", False),]- for index in range(MIN_MCP_SERVICES):+ for index in range(FIXTURE_MCP_SERVICES):transport_kind, auth_strategy, setup_status, readiness, verified = \matrix[index % len(matrix)]entries.append(fixture_service(@@ -718,10 +740,14 @@ class _NoRedirect(urllib.request.HTTPRedirectHandler):headers, fp)-def fetch_catalog(url: str, label: str) -> str:+class _TransientFetchError(Exception):+ """A fetch failure a retry can fix: connection errors, timeouts, 429/5xx."""+++def _fetch_once(url: str, label: str, accept: str) -> str:token = os.environ.get("GITHUB_TOKEN") or os.environ.get("PRIME_CATALOG_REPO_TOKEN")request = urllib.request.Request(url, headers={- "accept": "application/json",+ "accept": accept,"cache-control": "no-cache",**({"authorization": f"Bearer {token}"} if token else {}),})@@ -729,15 +755,19 @@ def fetch_catalog(url: str, label: str) -> str:try:response = opener.open(request, timeout=FETCH_TIMEOUT_SECONDS)except urllib.error.HTTPError as error:+ message = f"Failed to fetch {label} catalog from {url}: HTTP {error.code}."+ if error.code == 429 or error.code >= 500:+ raise _TransientFetchError(message) from errorhint = ""if error.code in (401, 404):hint = (" The catalog repo is private or absent; set GITHUB_TOKEN ""or PRIME_CATALOG_REPO_TOKEN.")elif 300 <= error.code < 400:hint = f" ({error.reason})"- fail(f"Failed to fetch {label} catalog from {url}: HTTP {error.code}.{hint}")+ fail(f"{message}{hint}")except (urllib.error.URLError, OSError, TimeoutError) as error:- fail(f"Failed to fetch {label} catalog from {url}: {error}")+ raise _TransientFetchError(+ f"Failed to fetch {label} catalog from {url}: {error}") from errorwith response:content_length = response.headers.get("content-length")if content_length is not None:@@ -758,11 +788,15 @@ def fetch_catalog(url: str, label: str) -> str:deadline = time.monotonic() + FETCH_TIMEOUT_SECONDSwhile True:if time.monotonic() >= deadline:- fail(+ raise _TransientFetchError(f"{label} catalog fetch exceeded the "f"{FETCH_TIMEOUT_SECONDS}s hard timeout")- chunk = response.read1(64 * 1024)+ try:+ chunk = response.read1(64 * 1024)+ except (OSError, TimeoutError) as error:+ raise _TransientFetchError(+ f"Failed to read {label} catalog from {url}: {error}") from errorif not chunk:breakbody.extend(chunk)@@ -775,6 +809,30 @@ def fetch_catalog(url: str, label: str) -> str:return text if text.endswith("\n") else f"{text}\n"+def fetch_catalog(url: str, label: str, accept: str = "application/json") -> str:+ """Fetch one catalog body, retrying transient failures; any other+ failure (and the last transient one) is a hard failure."""+ for backoff in (*FETCH_RETRY_BACKOFF_SECONDS, None):+ try:+ return _fetch_once(url, label, accept)+ except _TransientFetchError as error:+ if backoff is None:+ fail(str(error))+ print(f"warning: {error}; retrying in {backoff}s", file=sys.stderr)+ time.sleep(backoff)+ raise AssertionError("unreachable")+++def resolve_catalog_ref(url: str = CATALOG_COMMIT_URL) -> str:+ """The commit id the catalog repo's main points at now. A release run+ resolves it once and every build job fetches that commit, so all+ targets bundle the same catalog revision."""+ sha = fetch_catalog(url, "catalog commit", accept="application/vnd.github.sha").strip()+ if not COMMIT_SHA_PATTERN.fullmatch(sha):+ fail(f"catalog commit lookup at {url} returned {sha[:80]!r}, not a commit id")+ return sha++def generate_bundled_catalog_assets(options) -> dict:out_dir = Path(options.out_dir).resolve() if options.out_dir \else (ROOT / "target" / "catalog-assets")@@ -803,9 +861,11 @@ def generate_bundled_catalog_assets(options) -> dict:# a mixed snapshot (a fresh models file beside the previous services# file would pack together).model_body = fetch_catalog(- options.models_url or DEFAULT_MODEL_CATALOG_URL, "model")+ options.models_url or catalog_url(options.catalog_ref, MODEL_CATALOG_PATH),+ "model")mcp_body = fetch_catalog(- options.mcp_services_url or DEFAULT_MCP_SERVICE_CATALOG_URL,+ options.mcp_services_url+ or catalog_url(options.catalog_ref, MCP_SERVICE_CATALOG_PATH),"MCP service")targets["models.bundled.json"].write_text(model_body)targets["mcp-services.bundled.json"].write_text(mcp_body)@@ -818,8 +878,9 @@ def generate_bundled_catalog_assets(options) -> dict:def parse_args(argv=None) -> argparse.Namespace:parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])parser.add_argument("command", nargs="?", default="generate",- choices=("generate", "verify"),- help="generate (default) or verify an existing --out dir")+ choices=("generate", "verify", "resolve-ref"),+ help="generate (default), verify an existing --out dir, or "+ "resolve-ref: print the catalog repo's current main commit")parser.add_argument("--out", dest="out_dir", default=None,help="asset output directory (default: target/catalog-assets)")parser.add_argument("--catalog-dir", default=None,@@ -828,6 +889,9 @@ def parse_args(argv=None) -> argparse.Namespace:help="fetch the live catalog repo (CI/packaging default)")parser.add_argument("--fixture", action="store_true",help="emit the synthetic full-gate snapshot (offline builds)")+ parser.add_argument("--catalog-ref", default="main",+ help="network mode: the catalog branch or commit to fetch "+ "(release CI passes the commit resolve-ref printed)")parser.add_argument("--models-url", default=None,help="override the model catalog URL")parser.add_argument("--mcp-services-url", default=None,@@ -839,6 +903,9 @@ def parse_args(argv=None) -> argparse.Namespace:def main(argv=None) -> int:args = parse_args(argv)+ if args.command == "resolve-ref":+ print(resolve_catalog_ref())+ return 0out_dir = args.out_dir or (ROOT / "target" / "catalog-assets")if args.command == "verify":result = validate_bundled_catalog_dir(diff --git a/scripts/release/test_catalog_assets.py b/scripts/release/test_catalog_assets.pyindex e83baa9830..de98d4753f 100644--- a/scripts/release/test_catalog_assets.py+++ b/scripts/release/test_catalog_assets.py@@ -28,6 +28,7 @@ import threadingimport timeimport unittestfrom pathlib import Path+from unittest import mockSCRIPTS_DIR = Path(__file__).resolve().parentREPO = SCRIPTS_DIR.parent.parent@@ -201,7 +202,8 @@ class ValidationGates(unittest.TestCase):def test_fixture_passes_the_full_gates(self):"""Offline build verifier: --fixture produces a VALIDATED snapshot- (>= 42 transport tuples, >= 68 services) without any network."""+ (it clears the transport-tuple and service minimums) without any+ network."""with tempfile.TemporaryDirectory() as tmp:out = Path(tmp) / "assets"result = run_cli(BUNDLER, ["generate", "--fixture", "--out", str(out)])@@ -283,7 +285,7 @@ class ValidationGates(unittest.TestCase):(out / "mcp-services.bundled.json").write_text(json.dumps(good))with self.assertRaises(SystemExit):bundle_catalog.validate_bundled_model_catalog(- out / "models.bundled.json") # 0 tuples < 42+ out / "models.bundled.json") # 0 tuples < the minimumsmall = {"schemaVersion": 1, "models": [json.loads(bundle_catalog.fixture_catalog_bodies()["models.bundled.json"])["models"][0]]}@@ -328,7 +330,7 @@ class ValidationGates(unittest.TestCase):self.assertEqual(plugins["counts"]["total"], len(plugins["entries"]))self.assertEqual(plugins["counts"]["total"],- bundle_catalog.MIN_MCP_SERVICES + 5)+ bundle_catalog.FIXTURE_MCP_SERVICES + 5)def test_small_fixture_verify_waiver(self):with tempfile.TemporaryDirectory() as tmp:@@ -555,6 +557,61 @@ class NetworkMode(unittest.TestCase):self.assertEqual((out / "mcp-services.bundled.json").read_text(),services_before)+ def test_transient_fetch_failures_retry_and_hard_failures_do_not(self):+ """A 503 is retried inside fetch_catalog; a 404 fails on the first+ request. Validation never retries: it runs after the fetch."""+ body = bundle_catalog.fixture_catalog_bodies()["models.bundled.json"]+ attempts = []++ class Handler(http.server.BaseHTTPRequestHandler):+ def do_GET(self):+ attempts.append(self.path)+ flaky = self.path == "/flaky" and attempts.count("/flaky") == 1+ status = 503 if flaky else (200 if self.path == "/flaky" else 404)+ payload = body.encode() if status == 200 else b""+ self.send_response(status)+ self.send_header("content-length", str(len(payload)))+ self.end_headers()+ self.wfile.write(payload)++ def log_message(self, *args):+ pass++ server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler)+ thread = threading.Thread(target=server.serve_forever, daemon=True)+ thread.start()+ base = f"http://127.0.0.1:{server.server_address[1]}"+ try:+ with contextlib.redirect_stderr(io.StringIO()) as captured, \+ mock.patch.object(bundle_catalog, "FETCH_RETRY_BACKOFF_SECONDS", (0, 0)):+ self.assertEqual(bundle_catalog.fetch_catalog(f"{base}/flaky", "model"), body)+ self.assertIn("HTTP 503", captured.getvalue())+ self.assertEqual(attempts, ["/flaky", "/flaky"])+ attempts.clear()+ with contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit):+ bundle_catalog.fetch_catalog(f"{base}/missing", "model")+ self.assertEqual(attempts, ["/missing"])+ finally:+ server.shutdown()+ server.server_close()+ thread.join(timeout=5)++ def test_resolve_ref_returns_the_catalog_commit(self):+ sha = "01f4d46dd5157ec73f8faf440214088237c81d59"+ server = RecordingServer({+ "/commit": (sha.encode(), {}, 200),+ "/garbage": (b"<html>rate limited</html>", {}, 200),+ })+ try:+ self.assertEqual(bundle_catalog.resolve_catalog_ref(f"{server.base}/commit"), sha)+ self.assertEqual(server.seen_headers[-1]["Accept"], "application/vnd.github.sha")+ with contextlib.redirect_stderr(io.StringIO()) as captured, \+ self.assertRaises(SystemExit):+ bundle_catalog.resolve_catalog_ref(f"{server.base}/garbage")+ self.assertIn("not a commit id", captured.getvalue())+ finally:+ server.stop()+def test_network_fetch_enforces_a_total_deadline(self):"""The 5 s timeout is the TOTAL fetch budget, not per blocking op: aslow-drip server that always delivers another chunk keeps every