Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
chore(release): retire the Memory Runtime release guard (#2188)
Call White4049065ceab6
diff --git a/.github/workflows/memory-runtime-release-guard.yml b/.github/workflows/memory-runtime-release-guard.ymldeleted file mode 100644index 7bad079c9..000000000--- a/.github/workflows/memory-runtime-release-guard.yml+++ /dev/null@@ -1,392 +0,0 @@-name: Guard Memory Runtime releases--on:- push:- branches: [master]- paths:- - "scripts/memory_runtime_release_guard.py"- - ".github/workflows/memory-runtime-release-guard.yml"- schedule:- - cron: "29 */6 * * *"- - cron: "53 4 * * 0"- workflow_dispatch:--permissions:- actions: read- contents: write--concurrency:- group: memory-runtime-release-guard- cancel-in-progress: false--jobs:- resolve_manifests:- name: Resolve published Memory Runtime manifests- runs-on: ubuntu-latest- timeout-minutes: 30- outputs:- available: ${{ steps.manifests.outputs.available }}- manifests: ${{ steps.manifests.outputs.manifests }}- excluded: ${{ steps.manifests.outputs.excluded }}- steps:- - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5-- - name: Resolve every published Memory Runtime manifest- id: manifests- env:- GH_TOKEN: ${{ github.token }}- shell: bash- run: |- set -euo pipefail- candidate_dir="$RUNNER_TEMP/memory-runtime-candidate"- records_file="$RUNNER_TEMP/memory-runtime-manifests.jsonl"- excluded_file="$RUNNER_TEMP/memory-runtime-excluded.jsonl"- mkdir -p "$candidate_dir"- : > "$records_file"- : > "$excluded_file"- while IFS=$'\t' read -r candidate_tag manifest_owner wheel_pattern; do- rm -rf "$candidate_dir"- mkdir -p "$candidate_dir"- if ! gh release download "$candidate_tag" --repo "$GITHUB_REPOSITORY" \- --pattern "$wheel_pattern" --dir "$candidate_dir" >/dev/null 2>&1; then- jq -nc --arg release_tag "$candidate_tag" \- --arg reason "published $manifest_owner wheel could not be downloaded" \- '{release_tag: $release_tag, reason: $reason}' >> "$excluded_file"- continue- fi- set +e- CANDIDATE_TAG="$candidate_tag" CANDIDATE_DIR="$candidate_dir" WHEEL_PATTERN="$wheel_pattern" \- python3 - <<'PY'- import json- import os- import zipfile- from pathlib import Path-- wheels = sorted(Path(os.environ["CANDIDATE_DIR"]).glob(os.environ["WHEEL_PATTERN"]))- if len(wheels) != 1:- raise SystemExit(1)- with zipfile.ZipFile(wheels[0]) as wheel:- try:- manifest = wheel.read("vibe/memory_runtime_manifest.json")- except KeyError:- raise SystemExit(4) from None- payload = json.loads(manifest)- if payload.get("release_state") != "published" or payload.get("release_tag") != os.environ["CANDIDATE_TAG"]:- raise SystemExit(1)- (Path(os.environ["CANDIDATE_DIR"]) / "memory-runtime-manifest.json").write_bytes(manifest)- PY- manifest_status=$?- set -e- # Only legacy core wheels may predate Memory Runtime. Once the- # Memory wheel exists, it is authoritative and must not fall back.- if [ "$manifest_status" -eq 4 ]; then- if [ "$manifest_owner" = "avibe-os" ]; then- jq -nc --arg release_tag "$candidate_tag" \- --arg reason "$manifest_owner wheel has no self-pinned historical Runtime manifest" \- '{release_tag: $release_tag, reason: $reason}' >> "$excluded_file"- continue- fi- # New releases carry an inert three-file compatibility wheel so- # old updaters can cross the removal boundary. Verify that exact- # shape before excluding it; a malformed companion remains a- # visible policy exclusion and can never mask a broken legacy- # Runtime manifest.- if ! CANDIDATE_DIR="$candidate_dir" CANDIDATE_TAG="$candidate_tag" \- WHEEL_PATTERN="$wheel_pattern" python3 - <<'PY'- import email- import os- import zipfile- from pathlib import Path-- wheels = sorted(Path(os.environ["CANDIDATE_DIR"]).glob(os.environ["WHEEL_PATTERN"]))- if len(wheels) != 1:- raise SystemExit(1)- expected_version = os.environ["CANDIDATE_TAG"].removeprefix("gh-").removeprefix("v")- with zipfile.ZipFile(wheels[0]) as wheel:- names = {entry.filename for entry in wheel.infolist() if not entry.is_dir()}- directory = f"avibe_memory-{expected_version}.dist-info"- expected = {f"{directory}/METADATA", f"{directory}/WHEEL", f"{directory}/RECORD"}- if names != expected:- raise SystemExit(1)- metadata = email.message_from_bytes(wheel.read(f"{directory}/METADATA"))- if metadata.get("Name") != "avibe-memory" or metadata.get("Version") != expected_version:- raise SystemExit(1)- if metadata.get_all("Requires-Dist") or metadata.get_all("Provides-Extra"):- raise SystemExit(1)- PY- then- jq -nc --arg release_tag "$candidate_tag" \- --arg reason "$manifest_owner wheel has no manifest and is not a verified inert bridge" \- '{release_tag: $release_tag, reason: $reason}' >> "$excluded_file"- continue- fi- jq -nc --arg release_tag "$candidate_tag" \- --arg reason "$manifest_owner wheel is a verified inert compatibility bridge; no historical Runtime assets" \- '{release_tag: $release_tag, reason: $reason}' >> "$excluded_file"- continue- elif [ "$manifest_status" -ne 0 ]; then- jq -nc --arg release_tag "$candidate_tag" \- --arg reason "$manifest_owner wheel does not contain a valid self-pinned published manifest" \- '{release_tag: $release_tag, reason: $reason}' >> "$excluded_file"- continue- fi- manifest="$candidate_dir/memory-runtime-manifest.json"- manifest_sha="$(sha256sum "$manifest" | cut -d' ' -f1)"- set +e- policy_output="$(- python3 scripts/memory_runtime_release_guard.py \- --manifest "$manifest" check-policy 2>&1- )"- policy_status=$?- set -e- if [ "$policy_status" -eq 0 ]; then- jq -nc --arg release_tag "$candidate_tag" --arg sha256 "$manifest_sha" \- --arg manifest_owner "$manifest_owner" --arg wheel_pattern "$wheel_pattern" \- '{release_tag: $release_tag, sha256: $sha256, manifest_owner: $manifest_owner,- wheel_pattern: $wheel_pattern}' >> "$records_file"- elif [ "$policy_status" -eq 2 ]; then- policy_reason="$(jq -r '.error // "manifest excluded by policy"' <<<"$policy_output")"- jq -nc --arg release_tag "$candidate_tag" --arg reason "$policy_reason" \- '{release_tag: $release_tag, reason: $reason}' >> "$excluded_file"- else- echo "$policy_output" >&2- exit "$policy_status"- fi- done < <(- gh api --paginate "repos/$GITHUB_REPOSITORY/releases?per_page=100" \- --jq '- .[] |- select(.draft == false) |- # Published prereleases are historical releases too; drafts are not.- if any(.assets[]?; (.name | startswith("avibe_memory-")) and (.name | endswith(".whl"))) then- [.tag_name, "avibe-memory", "avibe_memory-*.whl"] | @tsv- elif any(.assets[]?; (.name | startswith("avibe_os-")) and (.name | endswith(".whl"))) then- [.tag_name, "avibe-os", "avibe_os-*.whl"] | @tsv- else- empty- end'- )- RECORDS_FILE="$records_file" EXCLUDED_FILE="$excluded_file" python3 - <<'PY'- import json- import os- from pathlib import Path-- def load_records(name: str) -> list[dict[str, str]]:- return [- json.loads(line)- for line in Path(os.environ[name]).read_text().splitlines()- if line.strip()- ]-- records = load_records("RECORDS_FILE")- excluded = load_records("EXCLUDED_FILE")- with Path(os.environ["GITHUB_OUTPUT"]).open("a", encoding="utf-8") as output:- output.write(f"available={'true' if records else 'false'}\n")- output.write(f"manifests={json.dumps(records, separators=(',', ':'))}\n")- output.write(f"excluded={json.dumps(excluded, separators=(',', ':'))}\n")-- guarded_tags = [record["release_tag"] for record in records]- print(f"Guarded Memory Runtime manifests ({len(records)}): {', '.join(guarded_tags) or 'none'}")- print(f"Excluded Memory Runtime manifests ({len(excluded)}):")- for record in excluded:- print(f"- {record['release_tag']}: {record['reason']}")- if not excluded:- print("- none")-- summary = [- "## Memory Runtime release guard coverage",- "",- f"Guarded Memory Runtime manifests ({len(records)}): "- f"{', '.join(guarded_tags) or 'none'}",- "",- f"Excluded Memory Runtime manifests ({len(excluded)}):",- ]- summary.extend(- f"- `{record['release_tag']}`: {record['reason']}" for record in excluded- )- if not excluded:- summary.append("- none")- with Path(os.environ["GITHUB_STEP_SUMMARY"]).open("a", encoding="utf-8") as output:- output.write("\n".join(summary) + "\n")- PY-- guard:- name: Verify and recover ${{ matrix.manifest.release_tag }}- needs: resolve_manifests- if: needs.resolve_manifests.outputs.available == 'true'- runs-on: ubuntu-latest- timeout-minutes: 30- strategy:- fail-fast: false- matrix:- manifest: ${{ fromJSON(needs.resolve_manifests.outputs.manifests) }}- steps:- - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5-- - name: Resolve selected published Memory Runtime manifest- env:- GH_TOKEN: ${{ github.token }}- RELEASE_TAG: ${{ matrix.manifest.release_tag }}- EXPECTED_SHA256: ${{ matrix.manifest.sha256 }}- MANIFEST_OWNER: ${{ matrix.manifest.manifest_owner }}- WHEEL_PATTERN: ${{ matrix.manifest.wheel_pattern }}- shell: bash- run: |- set -euo pipefail- manifest_dir="$RUNNER_TEMP/memory-runtime-manifest"- rm -rf "$manifest_dir"- mkdir -p "$manifest_dir"- gh release download "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" \- --pattern "$WHEEL_PATTERN" --dir "$manifest_dir" >/dev/null- CANDIDATE_TAG="$RELEASE_TAG" CANDIDATE_DIR="$manifest_dir" \- MANIFEST_OWNER="$MANIFEST_OWNER" WHEEL_PATTERN="$WHEEL_PATTERN" \- python3 - <<'PY'- import json- import os- import zipfile- from pathlib import Path-- wheels = sorted(Path(os.environ["CANDIDATE_DIR"]).glob(os.environ["WHEEL_PATTERN"]))- if len(wheels) != 1:- raise SystemExit(f"expected exactly one {os.environ['MANIFEST_OWNER']} wheel")- with zipfile.ZipFile(wheels[0]) as wheel:- manifest = wheel.read("vibe/memory_runtime_manifest.json")- payload = json.loads(manifest)- if payload.get("release_state") != "published" or payload.get("release_tag") != os.environ["CANDIDATE_TAG"]:- raise SystemExit("wheel does not contain the selected published manifest")- (Path(os.environ["CANDIDATE_DIR"]) / "memory-runtime-manifest.json").write_bytes(manifest)- PY- manifest="$manifest_dir/memory-runtime-manifest.json"- test "$(sha256sum "$manifest" | cut -d' ' -f1)" = "$EXPECTED_SHA256"-- - name: Fetch and verify published assets- id: probe- env:- RELEASE_TAG: ${{ matrix.manifest.release_tag }}- shell: bash- run: |- set -euo pipefail- set +e- probe_output="$(- python3 scripts/memory_runtime_release_guard.py \- --manifest "$RUNNER_TEMP/memory-runtime-manifest/memory-runtime-manifest.json" \- fetch --output-dir "$RUNNER_TEMP/memory-runtime-release" 2>&1- )"- probe_status=$?- set -e- echo "$probe_output"- failure_kind="$(jq -r '.failure_kind // empty' <<<"$probe_output" 2>/dev/null || true)"- if [ "$probe_status" -eq 0 ]; then- echo "result=verified" >> "$GITHUB_OUTPUT"- elif [ "$probe_status" -eq 1 ] && [ "$failure_kind" = "bytes" ]; then- echo "result=bytes_failure" >> "$GITHUB_OUTPUT"- elif [ "$probe_status" -eq 2 ] && [ "$failure_kind" = "policy" ]; then- echo "result=policy_excluded" >> "$GITHUB_OUTPUT"- echo "::notice title=Memory Runtime manifest excluded by policy::$RELEASE_TAG: $probe_output"- echo "- Guard-time exclusion for \`$RELEASE_TAG\`: $probe_output" >> "$GITHUB_STEP_SUMMARY"- else- exit "$probe_status"- fi-- - name: Recover missing assets from latest verified backup- if: steps.probe.outputs.result == 'bytes_failure'- env:- GH_TOKEN: ${{ github.token }}- MANIFEST_SHA: ${{ matrix.manifest.sha256 }}- RELEASE_TAG: ${{ matrix.manifest.release_tag }}- shell: bash- run: |- set -euo pipefail- artifact_name="memory-runtime-release-backup-$MANIFEST_SHA"- restore_dir="$RUNNER_TEMP/memory-runtime-restore"- backup_run=""- # Resolve the run from the artifact itself rather than scanning recent- # runs: backups are retained for 90 days, but a fixed window of the- # last 50 successful runs covers only about 12 days at the six-hourly- # schedule, so a live backup outside it was unreachable.- while IFS= read -r run_id; do- [ -n "$run_id" ] || continue- rm -rf "$restore_dir"- mkdir -p "$restore_dir"- if gh run download "$run_id" --repo "$GITHUB_REPOSITORY" \- --name "$artifact_name" --dir "$restore_dir"; then- backup_run="$run_id"- break- fi- done < <(- gh api "repos/$GITHUB_REPOSITORY/actions/artifacts?name=$artifact_name&per_page=100" \- --jq '[.artifacts[]? | select(.expired == false)]- | sort_by(.created_at) | reverse | .[].workflow_run.id'- )- if [ -z "$backup_run" ]; then- echo "::error::No verified Memory Runtime backup is available for manifest $MANIFEST_SHA."- exit 1- fi- python3 scripts/memory_runtime_release_guard.py \- --manifest "$RUNNER_TEMP/memory-runtime-manifest/memory-runtime-manifest.json" \- verify --asset-dir "$restore_dir"-- existing="$(gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name')"- missing=()- for asset in "$restore_dir"/*; do- name="$(basename "$asset")"- if ! grep -qxF "$name" <<<"$existing"; then- missing+=("$asset")- fi- done- if [ "${#missing[@]}" -eq 0 ]; then- echo "::error::All asset names exist but integrity failed; refusing to overwrite immutable runtime bytes."- exit 1- fi- gh release upload "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" "${missing[@]}"-- - name: Verify recovered release- if: steps.probe.outputs.result == 'bytes_failure'- run: |- python3 scripts/memory_runtime_release_guard.py \- --manifest "$RUNNER_TEMP/memory-runtime-manifest/memory-runtime-manifest.json" \- fetch --output-dir "$RUNNER_TEMP/memory-runtime-release"-- - name: Check whether this manifest already has a backup- id: backup- if: >-- steps.probe.outputs.result == 'verified' ||- steps.probe.outputs.result == 'bytes_failure'- env:- GH_TOKEN: ${{ github.token }}- MANIFEST_SHA: ${{ matrix.manifest.sha256 }}- shell: bash- run: |- set -euo pipefail- # Backups are keyed by manifest hash, so a newly published manifest has- # no artifact to recover from until its first upload. Without this- # check the six-hourly run skips the upload whenever the probe passes,- # leaving a window of up to a week -- until the Sunday cron -- in which- # an asset that disappears cannot be restored at all.- artifact_name="memory-runtime-release-backup-$MANIFEST_SHA"- existing="$(gh api \- "repos/$GITHUB_REPOSITORY/actions/artifacts?name=$artifact_name&per_page=100" \- --jq '[.artifacts[]? | select(.expired == false)] | length')"- if [ "${existing:-0}" -gt 0 ]; then- echo "Manifest $MANIFEST_SHA already has $existing live backup artifact(s)."- echo "missing=false" >> "$GITHUB_OUTPUT"- else- echo "Manifest $MANIFEST_SHA has no live backup artifact yet."- echo "missing=true" >> "$GITHUB_OUTPUT"- fi-- - name: Preserve verified release backup- if: >-- (steps.probe.outputs.result == 'verified' ||- steps.probe.outputs.result == 'bytes_failure') &&- (github.event_name != 'schedule' ||- github.event.schedule == '53 4 * * 0' ||- steps.probe.outputs.result == 'bytes_failure' ||- steps.backup.outputs.missing == 'true')- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6- with:- name: memory-runtime-release-backup-${{ matrix.manifest.sha256 }}- path: ${{ runner.temp }}/memory-runtime-release- if-no-files-found: error- retention-days: 90- compression-level: 0diff --git a/docs/plans/memory-release-upgrade-gates.md b/docs/plans/memory-release-upgrade-gates.mdindex cd6badc2f..b508cdc1a 100644--- a/docs/plans/memory-release-upgrade-gates.md+++ b/docs/plans/memory-release-upgrade-gates.md@@ -3,8 +3,7 @@## Background and goalThe removed Memory implementation must not reappear in persisted configuration,-but historical user data, released updater compatibility, and published Runtime-recovery assets remain supported. A normal startup and the official release path+but historical user data and released updater compatibility remain supported. A normal startup and the official release pathare separate gates: an explicit config save and an opt-in local E2E do not covereither one by themselves.@@ -23,15 +22,11 @@ either one by themselves.Package wheels come from the target tag; the gate and all of its helpers comefrom the running workflow revision, including on older-tag dispatches. Atarget at or before v3.1.0 has no forward retirement upgrade to exercise.-- MUC-005: the historical Runtime backup guard selects only non-draft GitHub- releases. Published prereleases with self-pinned manifests are included; the- existing inert bridge policy and invalid-manifest exclusions still apply.## Evidence and residual checksUnit/contract: config migration, concurrent writer/retry, recovery, workflow-ordering and fail-closed prerequisites, and published/draft/prerelease guard-selection. Scenario: stable IDs in `tests/scenarios/memory_upgrade_compatibility/`,+ordering and fail-closed prerequisites. Scenario: stable IDs in `tests/scenarios/memory_upgrade_compatibility/`,with the real four-case updater test gated at official release build time.Manually confirm a future official release's four Docker upgrade cases andGitHub assets before accepting its PyPI publication. No host service restart,@@ -49,6 +44,8 @@ Memory data deletion, or regression-state reset is part of this change.- Published historical GitHub release assets are byte-immutable. A dispatchreplay of an already published v3.1.0 cannot replace its real Memory wheelwith an inert bridge: the existing asset comparison must reject that attempt.-- The release-only historical Runtime guard continues backing up published- manifests; it does not install, upgrade, or roll back a Memory package.+- The historical Memory Runtime release guard was retired (owner decision,+ 2026-09-25). Published Runtime assets stay on their GitHub Releases but are no+ longer re-verified or restored from backup; only already installed pre-removal+ versions fetch them, and current releases never do.- The old user-owned Memory directories and their contents are left untouched.diff --git a/scripts/memory_runtime_release_guard.py b/scripts/memory_runtime_release_guard.pydeleted file mode 100644index a91c112f2..000000000--- a/scripts/memory_runtime_release_guard.py+++ /dev/null@@ -1,351 +0,0 @@-#!/usr/bin/env python3-"""Verify and materialize manifest-pinned Memory Runtime release assets."""--from __future__ import annotations--import argparse-import hashlib-import json-import shutil-import sys-import tarfile-import tempfile-import time-import urllib.error-import urllib.request-from dataclasses import dataclass-from pathlib import Path--RELEASE_DOWNLOAD_ROOT = "https://github.com/avibe-bot/avibe/releases/download"-EXPECTED_EVEROS_VERSION = "1.2.3"-EXPECTED_PYTHON_VERSION = "3.12.12"-EXPECTED_LOCK_SHA256 = "e6acc17e4c0969563d380326e90134965af0822259bb4a9adb4d54433e9737fe"-EXPECTED_UV_VERSION = "0.9.18"-EXPECTED_PLATFORMS = frozenset({"darwin-arm64", "linux-arm64", "linux-x64"})-EXPECTED_SYNC_BOOTSTRAP_REVISION = 1-EXPECTED_SYNC_ARGV = ["-I", "-m", "everos.entrypoints.cli.main", "cascade", "sync"]-MAX_ARCHIVE_BYTES = 1024 * 1024 * 1024-ASSET_FAILURE_EXIT = 1-POLICY_EXCLUSION_EXIT = 2-INTERNAL_GUARD_FAILURE_EXIT = 3---class ReleaseGuardError(RuntimeError):- """Base error for Memory Runtime release guard failures."""---class ManifestPolicyError(ReleaseGuardError):- """Raised when a manifest is outside the guard's verifiable policy scope."""---class ReleaseAssetError(ReleaseGuardError):- """Raised when guarded release bytes are unavailable or fail verification."""---@dataclass(frozen=True)-class RuntimeProvenance:- python_version: str- lock_sha256: str- uv_version: str---# Existing published manifests remain verifiable after the current pin moves.-PUBLISHED_RUNTIME_PROVENANCE = {- "1.1.3": RuntimeProvenance(- python_version=EXPECTED_PYTHON_VERSION,- lock_sha256="62b00f1a9ca04cc4ea4c5af51f389ba49acdea8786e5f7044d52823244502c57",- uv_version=EXPECTED_UV_VERSION,- ),- "1.2.1": RuntimeProvenance(- python_version=EXPECTED_PYTHON_VERSION,- lock_sha256="e7b59ee874e5cb2bfcbcb87cbd1e9c2d6ca2df752cd8a1059ddd3badb8c0246f",- uv_version=EXPECTED_UV_VERSION,- ),- EXPECTED_EVEROS_VERSION: RuntimeProvenance(- python_version=EXPECTED_PYTHON_VERSION,- lock_sha256=EXPECTED_LOCK_SHA256,- uv_version=EXPECTED_UV_VERSION,- ),-}---@dataclass(frozen=True)-class ArchiveSpec:- platform: str- name: str- url: str- sha256: str- binary_sha256: str- size: int- bin_path: str---@dataclass(frozen=True)-class ReleaseSpec:- manifest_bytes: bytes- release_tag: str- archives: tuple[ArchiveSpec, ...]- sync_bootstrap_sha256: str | None = None- sync_scrubbers_sha256: str | None = None-- @property- def expected_asset_names(self) -> set[str]:- return {"memory-runtime-manifest.json", *(archive.name for archive in self.archives)}---def _sha256(path: Path) -> str:- digest = hashlib.sha256()- with path.open("rb") as stream:- for chunk in iter(lambda: stream.read(1024 * 1024), b""):- digest.update(chunk)- return digest.hexdigest()---def _required_string(payload: dict, key: str, context: str) -> str:- value = payload.get(key)- if not isinstance(value, str) or not value:- raise ManifestPolicyError(f"{context}.{key} must be a non-empty string")- return value---def load_release_spec(manifest_path: Path) -> ReleaseSpec:- try:- manifest_bytes = manifest_path.read_bytes()- payload = json.loads(manifest_bytes)- except (OSError, json.JSONDecodeError) as exc:- raise ManifestPolicyError(f"cannot read Memory Runtime manifest: {exc}") from exc- if not isinstance(payload, dict) or type(payload.get("schema_version")) is not int or payload["schema_version"] != 1:- raise ManifestPolicyError("Memory Runtime manifest schema_version must be 1")- everos_version = payload.get("everos_version")- provenance = (- PUBLISHED_RUNTIME_PROVENANCE.get(everos_version)- if isinstance(everos_version, str)- else None- )- if payload.get("release_state") != "published" or provenance is None:- raise ManifestPolicyError("Memory Runtime manifest must describe a published supported EverOS version")- if (- payload.get("python_version") != provenance.python_version- or payload.get("lock_sha256") != provenance.lock_sha256- or payload.get("lock_id") != f"uv-lock-sha256:{provenance.lock_sha256}"- or payload.get("uv_version") != provenance.uv_version- ):- raise ManifestPolicyError("Memory Runtime manifest provenance is invalid")- sync_revision = payload.get("sync_bootstrap_revision")- sync_argv = payload.get("sync_argv")- sync_digest = payload.get("sync_bootstrap_sha256")- sync_scrubbers_digest = payload.get("sync_scrubbers_sha256")- if (- sync_revision is not None- or sync_argv is not None- or sync_digest is not None- or sync_scrubbers_digest is not None- ):- if (- sync_revision != EXPECTED_SYNC_BOOTSTRAP_REVISION- or sync_argv != EXPECTED_SYNC_ARGV- or not isinstance(sync_digest, str)- or len(sync_digest) != 64- or any(character not in "0123456789abcdef" for character in sync_digest)- or not isinstance(sync_scrubbers_digest, str)- or len(sync_scrubbers_digest) != 64- or any(character not in "0123456789abcdef" for character in sync_scrubbers_digest)- ):- raise ManifestPolicyError("Memory Runtime sync bootstrap contract is invalid")-- release_tag = _required_string(payload, "release_tag", "manifest")- release_root = f"{RELEASE_DOWNLOAD_ROOT}/{release_tag}"- raw_archives = payload.get("archives")- if not isinstance(raw_archives, dict) or set(raw_archives) != EXPECTED_PLATFORMS:- raise ManifestPolicyError("Memory Runtime manifest platform set is invalid")- archives: list[ArchiveSpec] = []- for platform, raw in sorted(raw_archives.items()):- if not isinstance(raw, dict):- raise ManifestPolicyError(f"archives.{platform} must be an object")- context = f"archives.{platform}"- name = _required_string(raw, "name", context)- url = _required_string(raw, "url", context)- sha256 = _required_string(raw, "sha256", context)- binary_sha256 = _required_string(raw, "binary_sha256", context)- bin_path = _required_string(raw, "bin_path", context)- size = raw.get("size")- if Path(name).name != name or url != f"{release_root}/{name}":- raise ManifestPolicyError(f"{context} is outside the pinned release")- if (- len(sha256) != 64- or len(binary_sha256) != 64- or any(character not in "0123456789abcdef" for character in sha256 + binary_sha256)- ):- raise ManifestPolicyError(f"{context} has an invalid digest")- if not isinstance(size, int) or isinstance(size, bool) or not 0 < size <= MAX_ARCHIVE_BYTES:- raise ManifestPolicyError(f"{context}.size is invalid")- if Path(bin_path).is_absolute() or ".." in Path(bin_path).parts:- raise ManifestPolicyError(f"{context}.bin_path is unsafe")- archives.append(ArchiveSpec(platform, name, url, sha256, binary_sha256, size, bin_path))- return ReleaseSpec(- manifest_bytes=manifest_bytes,- release_tag=release_tag,- archives=tuple(archives),- sync_bootstrap_sha256=sync_digest,- sync_scrubbers_sha256=sync_scrubbers_digest,- )---def verify_release_assets(manifest_path: Path, asset_dir: Path) -> ReleaseSpec:- spec = load_release_spec(manifest_path)- if not asset_dir.is_dir():- raise ReleaseAssetError("Memory Runtime asset directory is missing")- entries = list(asset_dir.iterdir())- if any(path.is_symlink() or not path.is_file() for path in entries):- raise ReleaseAssetError("Memory Runtime asset directory contains unsafe entries")- actual = {path.name for path in entries}- if actual != spec.expected_asset_names:- raise ReleaseAssetError(- f"Memory Runtime asset set mismatch: missing={sorted(spec.expected_asset_names - actual)}, "- f"unexpected={sorted(actual - spec.expected_asset_names)}"- )- if (asset_dir / "memory-runtime-manifest.json").read_bytes() != spec.manifest_bytes:- raise ReleaseAssetError("published Memory Runtime manifest differs from the pinned manifest")- for archive in spec.archives:- path = asset_dir / archive.name- if path.stat().st_size != archive.size or _sha256(path) != archive.sha256:- raise ReleaseAssetError(f"Memory Runtime archive integrity mismatch: {archive.name}")- try:- with tarfile.open(path, "r:gz") as bundle:- member = bundle.getmember(archive.bin_path)- binary = bundle.extractfile(member)- digest = hashlib.sha256(binary.read()).hexdigest() if binary is not None and member.isfile() else ""- if spec.sync_bootstrap_sha256 is not None:- bootstrap_digest = _archive_member_sha256(- bundle,- "lib/python3.12/site-packages/avibe_memory_sync_bootstrap.py",- )- scrubbers_digest = _archive_member_sha256(- bundle,- "lib/python3.12/site-packages/avibe_memory_sync_scrubbers.py",- )- marker = bundle.extractfile(- bundle.getmember(- "lib/python3.12/site-packages/avibe_memory_sync_bootstrap.pth"- )- )- if (- bootstrap_digest != spec.sync_bootstrap_sha256- or scrubbers_digest != spec.sync_scrubbers_sha256- or marker is None- or marker.read() != b"import avibe_memory_sync_bootstrap\n"- ):- raise ReleaseAssetError(- f"Memory Runtime sync contract mismatch: {archive.name}"- )- except (KeyError, OSError, tarfile.TarError) as exc:- raise ReleaseAssetError(f"invalid Memory Runtime archive: {archive.name}") from exc- if digest != archive.binary_sha256:- raise ReleaseAssetError(f"Memory Runtime binary integrity mismatch: {archive.name}")- return spec---def _archive_member_sha256(bundle: tarfile.TarFile, name: str) -> str:- member = bundle.getmember(name)- stream = bundle.extractfile(member)- if stream is None or not member.isfile():- return ""- return hashlib.sha256(stream.read()).hexdigest()---def _download(url: str, destination: Path, expected_size: int, attempts: int = 3) -> None:- request = urllib.request.Request(url, headers={"User-Agent": "avibe-memory-runtime-release-guard/1"})- for attempt in range(1, attempts + 1):- try:- with urllib.request.urlopen(request, timeout=60) as response, destination.open("wb") as output:- content_length = response.headers.get("Content-Length")- try:- declared_size = int(content_length) if content_length is not None else None- except (TypeError, ValueError):- declared_size = None- if declared_size is not None and declared_size > expected_size:- raise ReleaseAssetError(f"release asset exceeds manifest size: {url}")- downloaded = 0- while chunk := response.read(1024 * 1024):- downloaded += len(chunk)- if downloaded > expected_size:- raise ReleaseAssetError(f"release asset exceeds manifest size: {url}")- output.write(chunk)- return- except ReleaseAssetError:- destination.unlink(missing_ok=True)- raise- except (OSError, urllib.error.URLError) as exc:- destination.unlink(missing_ok=True)- if attempt == attempts:- raise ReleaseAssetError(f"release asset download failed: {url}: {exc}") from exc- time.sleep(float(attempt))---def fetch_release_assets(manifest_path: Path, output_dir: Path) -> ReleaseSpec:- spec = load_release_spec(manifest_path)- output_dir.parent.mkdir(parents=True, exist_ok=True)- temporary = Path(tempfile.mkdtemp(prefix=f".{output_dir.name}-", dir=output_dir.parent))- try:- manifest_url = f"{RELEASE_DOWNLOAD_ROOT}/{spec.release_tag}/memory-runtime-manifest.json"- _download(- manifest_url,- temporary / "memory-runtime-manifest.json",- len(spec.manifest_bytes),- )- for archive in spec.archives:- _download(archive.url, temporary / archive.name, archive.size)- verify_release_assets(manifest_path, temporary)- if output_dir.exists():- if output_dir.is_dir():- shutil.rmtree(output_dir)- else:- output_dir.unlink()- temporary.replace(output_dir)- finally:- if temporary.exists():- shutil.rmtree(temporary)- return spec---def main(argv: list[str] | None = None) -> int:- parser = argparse.ArgumentParser(description=__doc__)- parser.add_argument("--manifest", type=Path, required=True)- subparsers = parser.add_subparsers(dest="command", required=True)- fetch = subparsers.add_parser("fetch")- fetch.add_argument("--output-dir", type=Path, required=True)- verify = subparsers.add_parser("verify")- verify.add_argument("--asset-dir", type=Path, required=True)- subparsers.add_parser("check-policy")- args = parser.parse_args(argv)- try:- if args.command == "fetch":- spec = fetch_release_assets(args.manifest, args.output_dir)- elif args.command == "verify":- spec = verify_release_assets(args.manifest, args.asset_dir)- else:- spec = load_release_spec(args.manifest)- except ManifestPolicyError as exc:- print(- json.dumps({"ok": False, "failure_kind": "policy", "error": str(exc)}),- file=sys.stderr,- )- return POLICY_EXCLUSION_EXIT- except ReleaseAssetError as exc:- print(- json.dumps({"ok": False, "failure_kind": "bytes", "error": str(exc)}),- file=sys.stderr,- )- return ASSET_FAILURE_EXIT- except ReleaseGuardError as exc:- print(- json.dumps({"ok": False, "failure_kind": "internal", "error": str(exc)}),- file=sys.stderr,- )- return INTERNAL_GUARD_FAILURE_EXIT- print(json.dumps({"ok": True, "release_tag": spec.release_tag, "asset_count": len(spec.expected_asset_names)}))- return 0---if __name__ == "__main__":- raise SystemExit(main())diff --git a/tests/scenarios/INDEX.yaml b/tests/scenarios/INDEX.yamlindex e848d2941..1a23f6ca8 100644--- a/tests/scenarios/INDEX.yaml+++ b/tests/scenarios/INDEX.yaml@@ -17,7 +17,6 @@ capabilities:- tests/scenarios/memory_upgrade_compatibility/test_catalog.py- tests/e2e/test_retired_updater_bridge.py- tests/test_memory_removal.py- - tests/test_memory_runtime_release_guard.pyunit_or_contract_tests:- tests/test_release_verification.py- id: model_hubdiff --git a/tests/scenarios/memory_upgrade_compatibility/catalog.yaml b/tests/scenarios/memory_upgrade_compatibility/catalog.yamlindex 1b37f379b..acfc5b944 100644--- a/tests/scenarios/memory_upgrade_compatibility/catalog.yaml+++ b/tests/scenarios/memory_upgrade_compatibility/catalog.yaml@@ -6,7 +6,6 @@ capability:- tests/scenarios/memory_upgrade_compatibility/test_catalog.py- tests/test_memory_removal.py- tests/e2e/test_retired_updater_bridge.py- - tests/test_memory_runtime_release_guard.py- tests/test_release_verification.pyshared_harness: []status_legend:@@ -36,9 +35,3 @@ scenarios:kind: releaselayer: scenariotest: tests/e2e/test_retired_updater_bridge.py::test_released_updater_replaces_companion_without_touching_user_data- - id: MUC-005- name: historical Runtime guard excludes drafts while retaining published stable and prerelease manifests- status: covered- kind: release- layer: contract- test: tests/test_memory_runtime_release_guard.py::test_resolve_manifests_shell_selects_history_and_excludes_new_or_invalid_wheelsdiff --git a/tests/scenarios/memory_upgrade_compatibility/observations.yaml b/tests/scenarios/memory_upgrade_compatibility/observations.yamlindex 1e5be0c96..4075d9e38 100644--- a/tests/scenarios/memory_upgrade_compatibility/observations.yaml+++ b/tests/scenarios/memory_upgrade_compatibility/observations.yaml@@ -7,6 +7,5 @@ observations:affects:- MUC-001- MUC-004- - MUC-005previous_assumption: Explicit saves and a local opt-in E2E covered the official upgrade path.observed_behavior: Startup migration and official publication have distinct write and test gates.diff --git a/tests/test_memory_runtime_release_guard.py b/tests/test_memory_runtime_release_guard.pydeleted file mode 100644index aab18a1ab..000000000--- a/tests/test_memory_runtime_release_guard.py+++ /dev/null@@ -1,205 +0,0 @@-"""Hermetic coverage for the release-only historical Runtime guard."""--import hashlib-import json-import os-from pathlib import Path-import shutil-import subprocess-import sys-import tarfile-import zipfile--import pytest--from scripts import memory_runtime_release_guard as guard---def _fixture(tmp_path: Path, *, tag="v3.1.0", malformed=False):- tmp_path.mkdir(parents=True, exist_ok=True)- payload = {- "schema_version": 1, "release_state": "published", "release_tag": tag,- "everos_version": "1.2.3", "python_version": guard.EXPECTED_PYTHON_VERSION,- "lock_sha256": guard.EXPECTED_LOCK_SHA256,- "lock_id": f"uv-lock-sha256:{guard.EXPECTED_LOCK_SHA256}",- "uv_version": guard.EXPECTED_UV_VERSION,- "archives": {},- }- archive = tmp_path / "runtime-linux-x64.tgz"- binary = b"historical runtime binary"- member = tarfile.TarInfo("bin/runtime")- member.size = len(binary)- with tarfile.open(archive, "w:gz") as bundle:- stream = __import__("io").BytesIO(binary)- bundle.addfile(member, stream)- digest = hashlib.sha256(archive.read_bytes()).hexdigest()- payload["archives"] = {- platform: {"name": name, "url": f"https://github.com/avibe-bot/avibe/releases/download/{tag}/{name}",- "sha256": digest, "binary_sha256": hashlib.sha256(binary).hexdigest(),- "size": archive.stat().st_size, "bin_path": "bin/runtime"}- for platform, name in (("darwin-arm64", "runtime-darwin-arm64.tgz"),- ("linux-arm64", "runtime-linux-arm64.tgz"),- ("linux-x64", "runtime-linux-x64.tgz"))- }- manifest = tmp_path / "memory-runtime-manifest.json"- manifest.write_text(json.dumps(payload))- if malformed:- manifest.write_text("{}")- return manifest, payload, archive---def test_pinned_manifest_and_asset_hash_are_strict(tmp_path):- manifest, payload, archive = _fixture(tmp_path)- spec = guard.load_release_spec(manifest)- asset_dir = tmp_path / "assets"- asset_dir.mkdir()- (asset_dir / manifest.name).write_bytes(manifest.read_bytes())- for item in spec.archives:- (asset_dir / item.name).write_bytes(archive.read_bytes())- assert guard.verify_release_assets(manifest, asset_dir).release_tag == "v3.1.0"- (asset_dir / "runtime-linux-x64.tgz").write_bytes(b"tampered")- with pytest.raises(guard.ReleaseAssetError):- guard.verify_release_assets(manifest, asset_dir)- payload["release_tag"] = "v9.9.9"- manifest.write_text(json.dumps(payload))- with pytest.raises(guard.ManifestPolicyError):- guard.load_release_spec(manifest)---def test_malformed_historical_manifest_is_excluded_not_reconstructed(tmp_path):- manifest, _, _ = _fixture(tmp_path, malformed=True)- with pytest.raises(guard.ManifestPolicyError):- guard.load_release_spec(manifest)---def test_fetch_uses_pinned_urls_and_refuses_existing_output(monkeypatch, tmp_path):- manifest, _, archive = _fixture(tmp_path)- calls = []-- def download(url, destination, expected_size, attempts=3):- calls.append(url)- if url.endswith("manifest.json"):- destination.write_bytes(manifest.read_bytes())- else:- destination.write_bytes(archive.read_bytes())-- monkeypatch.setattr(guard, "_download", download)- output = tmp_path / "out"- guard.fetch_release_assets(manifest, output)- assert calls == [- "https://github.com/avibe-bot/avibe/releases/download/v3.1.0/memory-runtime-manifest.json",- "https://github.com/avibe-bot/avibe/releases/download/v3.1.0/runtime-darwin-arm64.tgz",- "https://github.com/avibe-bot/avibe/releases/download/v3.1.0/runtime-linux-arm64.tgz",- "https://github.com/avibe-bot/avibe/releases/download/v3.1.0/runtime-linux-x64.tgz",- ]- before = {path.name: path.read_bytes() for path in output.iterdir()}- guard.fetch_release_assets(manifest, output)- assert {path.name: path.read_bytes() for path in output.iterdir()} == before---def test_failed_fetch_preserves_previous_verified_backup_output(monkeypatch, tmp_path):- manifest, _, archive = _fixture(tmp_path)- output = tmp_path / "out"- output.mkdir()- (output / "verified.bin").write_bytes(b"verified backup")-- def fail_download(url, destination, expected_size, attempts=3):- if url.endswith("manifest.json"):- destination.write_bytes(manifest.read_bytes())- return- raise guard.ReleaseAssetError("fixture network failure")-- monkeypatch.setattr(guard, "_download", fail_download)- with pytest.raises(guard.ReleaseAssetError):- guard.fetch_release_assets(manifest, output)- assert (output / "verified.bin").read_bytes() == b"verified backup"---def test_resolve_manifests_shell_selects_history_and_excludes_new_or_invalid_wheels(tmp_path):- """MUC-005: execute the resolver against published stable/prerelease and draft fixtures."""- import yaml-- workflow = yaml.safe_load((Path(__file__).parents[1] / ".github/workflows/memory-runtime-release-guard.yml").read_text())- step = next(- step for step in workflow["jobs"]["resolve_manifests"]["steps"]- if step.get("id") == "manifests"- )- root = tmp_path / "releases"- root.mkdir()- old_manifest, _, _ = _fixture(tmp_path / "old")-- def wheel(path: Path, name: str, manifest: bytes | None = None):- path.parent.mkdir(parents=True, exist_ok=True)- with zipfile.ZipFile(path, "w") as archive:- if manifest is not None:- archive.writestr("vibe/memory_runtime_manifest.json", manifest)- archive.writestr(f"{name}.dist-info/METADATA", f"Name: {name}\nVersion: 3.2.0\n")- archive.writestr(f"{name}.dist-info/WHEEL", "Wheel-Version: 1.0\n")- archive.writestr(f"{name}.dist-info/RECORD", "")-- wheel(root / "v3.1.0" / "avibe_os-3.1.0-py3-none-any.whl", "avibe_os", old_manifest.read_bytes())- prerelease_manifest, _, _ = _fixture(tmp_path / "prerelease", tag="v3.0.9rc1")- wheel(root / "v3.0.9rc1" / "avibe_os-3.0.9rc1-py3-none-any.whl", "avibe_os", prerelease_manifest.read_bytes())- wheel(root / "v3.0.8" / "avibe_os-3.0.8-py3-none-any.whl", "avibe_os", old_manifest.read_bytes())- inert = tmp_path / "inert"- subprocess.run([- sys.executable, str(Path(__file__).parents[1] / "scripts/build_retired_companion.py"),- "--tag", "gh-v3.2.0rc1", "--output-dir", str(inert),- ], check=True, capture_output=True)- (root / "gh-v3.2.0rc1").mkdir()- shutil.copy2(next(inert.glob("*.whl")), root / "gh-v3.2.0rc1/avibe_memory-3.2.0rc1-py3-none-any.whl")- wheel(root / "v3.2.0" / "avibe_memory-3.2.0-py3-none-any.whl", "avibe_memory")-- releases = [- {"tag_name": tag, "draft": draft, "prerelease": prerelease,- "assets": [{"name": path.name} for path in (root / tag).glob("*.whl")]}- for tag, draft, prerelease in (- ("v3.0.8", True, False),- ("v3.0.9rc1", False, True),- ("v3.1.0", False, False),- ("gh-v3.2.0rc1", False, True),- ("v3.2.0", False, False),- )- ]-- fake_bin = tmp_path / "bin"- fake_bin.mkdir()- fake_bin.joinpath("gh").write_text(- "#!/usr/bin/env python3\n"- "import json, pathlib, shutil, subprocess, sys\n"- "args=sys.argv[1:]\n"- "if args[:2] == ['api', '--paginate']:\n"- f" releases={releases!r}\n"- " result=subprocess.run(['jq', '-r', args[args.index('--jq')+1]], input=json.dumps(releases), text=True, capture_output=True, check=True)\n"- " print(result.stdout, end='')\n"- "elif args[:2] == ['release', 'download']:\n"- " tag=args[2]; pattern=args[args.index('--pattern')+1]; destination=pathlib.Path(args[args.index('--dir')+1]); destination.mkdir(parents=True, exist_ok=True)\n"- f" source=pathlib.Path({str(root)!r})/tag\n"- " matches=list(source.glob(pattern)); assert len(matches)==1, (tag,pattern)\n"- " shutil.copy2(matches[0], destination/matches[0].name)\n"- "else: raise SystemExit(args)\n",- encoding="utf-8",- )- fake_bin.joinpath("gh").chmod(0o755)- output = tmp_path / "github-output"- summary = tmp_path / "summary"- runner_temp = tmp_path / "runner"- runner_temp.mkdir()- env = {- **os.environ, "PATH": f"{fake_bin}:{os.environ['PATH']}", "GITHUB_REPOSITORY": "fixture/repo",- "GITHUB_OUTPUT": str(output), "GITHUB_STEP_SUMMARY": str(summary), "RUNNER_TEMP": str(runner_temp),- }- release_bytes_before = {path: path.read_bytes() for path in root.rglob("*") if path.is_file()}- result = subprocess.run(["bash", "--noprofile", "--norc", "-e", "-o", "pipefail", "-c", step["run"]],- cwd=Path(__file__).parents[1], env=env, capture_output=True, text=True, timeout=30)- assert result.returncode == 0, result.stdout + result.stderr- values = dict(line.split("=", 1) for line in output.read_text().splitlines())- records = json.loads(values["manifests"])- excluded = json.loads(values["excluded"])- assert values["available"] == "true"- assert [item["release_tag"] for item in records] == ["v3.0.9rc1", "v3.1.0"]- assert "v3.0.8" not in {item["release_tag"] for item in records + excluded}- reasons = {item["release_tag"]: item["reason"] for item in excluded}- assert "verified inert compatibility bridge" in reasons["gh-v3.2.0rc1"]- assert "not a verified inert bridge" in reasons["v3.2.0"]- assert {path: path.read_bytes() for path in root.rglob("*") if path.is_file()} == release_bytes_beforediff --git a/tests/test_release_verification.py b/tests/test_release_verification.pyindex 09999e5f5..7d785d38d 100644--- a/tests/test_release_verification.py+++ b/tests/test_release_verification.py@@ -26,17 +26,6 @@ WORKFLOWS = ()-def test_historical_guard_is_release_only_and_verifies_inert_bridge_shape():- workflow = yaml.safe_load((ROOT / ".github/workflows/memory-runtime-release-guard.yml").read_text())- assert workflow.get("on", workflow.get(True))["schedule"]- assert workflow["permissions"]["contents"] == "write"- text = (ROOT / ".github/workflows/memory-runtime-release-guard.yml").read_text()- assert "verified inert compatibility bridge" in text- assert "has no self-pinned historical Runtime manifest" in text- assert "gh release upload" in text and "All asset names exist" in text- assert "memory-runtime-release-backup-" in text--@pytest.mark.parametrize(("annotation", "existing_body", "silent"),[