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
fix(release): gate Memory retirement upgrades and config migration (#2157)
rkrkrkk11a89411f1cb
diff --git a/.github/workflows/memory-runtime-release-guard.yml b/.github/workflows/memory-runtime-release-guard.ymlindex 6f89b231b..7bad079c9 100644--- a/.github/workflows/memory-runtime-release-guard.yml+++ b/.github/workflows/memory-runtime-release-guard.yml@@ -156,6 +156,8 @@ jobs: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"] | @tsvelif any(.assets[]?; (.name | startswith("avibe_os-")) and (.name | endswith(".whl"))) thendiff --git a/.github/workflows/publish.yml b/.github/workflows/publish.ymlindex 4c540dd86..d29f19c70 100644--- a/.github/workflows/publish.yml+++ b/.github/workflows/publish.yml@@ -182,6 +182,11 @@ jobs:scripts/build_retired_companion.pyscripts/release_package_version.pytests/test_distribution_artifacts.py+ tests/__init__.py+ tests/e2e/test_retired_updater_bridge.py+ tests/e2e/test_install_command.py+ tests/e2e/retired_updater_probe.py+ tests/e2e/github_release_fixture.pysparse-checkout-cone-mode: false- name: Setup Node.js@@ -322,14 +327,43 @@ jobs:fi- name: Run release install and upgrade regressions+ env:+ GH_TOKEN: ${{ github.token }}+ RELEASE_TAG: ${{ needs.resolve-tag.outputs.tag }}run: |+ set -euo pipefaildocker infoexport VIBE_INSTALL_TEST_WHEEL="$(ls dist/avibe_os-*.whl)"+ export AVIBE_CORE_WHEEL="$(realpath "$VIBE_INSTALL_TEST_WHEEL")"+ export AVIBE_BRIDGE_WHEEL="$(realpath "$(ls dist/avibe_memory-*.whl)")"+ mkdir -p old-release+ for asset in avibe_os-3.1.0-py3-none-any.whl avibe_memory-3.1.0-py3-none-any.whl; do+ gh release download v3.1.0 --repo "$GITHUB_REPOSITORY" --pattern "$asset" --dir old-release+ done+ echo '7c2321ae32174c0fcf0b659c7d7a5b90ae53740c223ae41452702adbc393b924 old-release/avibe_os-3.1.0-py3-none-any.whl' | sha256sum -c -+ echo 'ce5cfb1473442642d7d19863b6f9131c0a17a1fb6e828d5e0aec04f2deea06b0 old-release/avibe_memory-3.1.0-py3-none-any.whl' | sha256sum -c -+ export AVIBE_OLD_CORE_WHEEL="$(realpath old-release/avibe_os-3.1.0-py3-none-any.whl)"+ export AVIBE_OLD_COMPANION_WHEEL="$(realpath old-release/avibe_memory-3.1.0-py3-none-any.whl)"+ export AVIBE_RELEASE_GATE=1pytest \tests/test_upgrade_flow.py \tests/test_install_script.py \tests/e2e/test_install_command.py \-v+ TARGET_VERSION="$(python release-automation/scripts/release_package_version.py "$RELEASE_TAG")"+ export TARGET_VERSION+ UPGRADE_DIRECTION="$(python - <<'PY'+ import os+ from packaging.version import Version++ print("forward" if Version(os.environ["TARGET_VERSION"]) > Version("3.1.0") else "historical")+ PY+ )"+ if [ "$UPGRADE_DIRECTION" = forward ]; then+ (cd release-automation && pytest tests/e2e/test_retired_updater_bridge.py -v)+ else+ echo "No forward Memory retirement upgrade from v3.1.0 to $RELEASE_TAG"+ fi- name: Upload GitHub release assetsenv:diff --git a/config/v2_config.py b/config/v2_config.pyindex fbe61c4fa..5a4768ece 100644--- a/config/v2_config.py+++ b/config/v2_config.py@@ -3261,12 +3261,14 @@ class V2Config:all_warnings = tuple(dict.fromkeys((*migration_warnings, *recovery_warnings)))if (persist_migrations- and migrated+ and (migrated or "memory" in payload)and not migration_warningsand not recovery_warnings):persisted_payload = copy.deepcopy(payload)- persisted_payload["model_hub"] = config.model_hub.to_payload()+ persisted_payload.pop("memory", None)+ if migrated:+ persisted_payload["model_hub"] = config.model_hub.to_payload()try:backup, persistence_warning = _persist_migrated_config_payload(path,diff --git a/docs/plans/memory-release-upgrade-gates.md b/docs/plans/memory-release-upgrade-gates.mdnew file mode 100644index 000000000..cd6badc2f--- /dev/null+++ b/docs/plans/memory-release-upgrade-gates.md@@ -0,0 +1,54 @@+# Memory retirement: official upgrade gates++## Background and goal++The 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+are separate gates: an explicit config save and an opt-in local E2E do not cover+either one by themselves.++## Delivery++- MUC-001/002/003: on successful startup migration, remove only the obsolete+ root `memory` key; preserve every other root key and all Memory user files.+ A memory-only write preserves even a minimal valid Model Hub payload exactly;+ a real Model Hub migration retains its existing serialization behavior.+ Recovery and losing a config compare-and-swap leave the old file intact.+- MUC-004: before GitHub asset upload and PyPI publication, download both+ published v3.1.0 wheels, verify their fixed SHA-256 identities, then run the+ released updater through real pip and uv in disposable Docker against the+ newly built core and inert bridge wheels. Missing inputs or Docker fail the+ release; the normal local opt-in test still skips without release inputs.+ Package wheels come from the target tag; the gate and all of its helpers come+ from the running workflow revision, including on older-tag dispatches. A+ target 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 checks++Unit/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/`,+with the real four-case updater test gated at official release build time.+Manually confirm a future official release's four Docker upgrade cases and+GitHub assets before accepting its PyPI publication. No host service restart,+Memory data deletion, or regression-state reset is part of this change.++## Known by design++- The compatibility bridge remains an inert GitHub Release wheel, not a Memory+ runtime or new PyPI companion. Legacy CLI argv and delivery metadata remain+ unchanged.+- Every target version strictly newer than v3.1.0, including newer prereleases+ and postreleases, must pass the real v3.1.0-to-target pip/uv upgrade gate.+ Earlier or equal versions have no forward upgrade from v3.1.0 and cannot+ exercise that scenario; their existing installer regressions still run.+- Published historical GitHub release assets are byte-immutable. A dispatch+ replay of an already published v3.1.0 cannot replace its real Memory wheel+ with 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 old user-owned Memory directories and their contents are left untouched.diff --git a/tests/e2e/test_retired_updater_bridge.py b/tests/e2e/test_retired_updater_bridge.pyindex 1d931f57c..c51ce03c5 100644--- a/tests/e2e/test_retired_updater_bridge.py+++ b/tests/e2e/test_retired_updater_bridge.py@@ -12,10 +12,15 @@ from tests.e2e.test_install_command import _docker_available@pytest.mark.integrationdef test_released_updater_replaces_companion_without_touching_user_data(tmp_path):+ """MUC-004: released updater crosses the removal boundary without rewriting data."""names = ("AVIBE_CORE_WHEEL", "AVIBE_BRIDGE_WHEEL", "AVIBE_OLD_CORE_WHEEL", "AVIBE_OLD_COMPANION_WHEEL")if not all(os.environ.get(name) for name in names):+ if os.environ.get("AVIBE_RELEASE_GATE") == "1":+ pytest.fail("Release gate requires all four pinned old and new wheels")pytest.skip("Explicit new and released v3.1.0 artifact paths required")if not _docker_available():+ if os.environ.get("AVIBE_RELEASE_GATE") == "1":+ pytest.fail("Release gate requires Docker for isolated real upgrades")pytest.skip("Docker is required for isolated github.com routing")for name in names:source = Path(os.environ[name]).resolve()diff --git a/tests/scenarios/INDEX.yaml b/tests/scenarios/INDEX.yamlindex 36ebf4dc8..a6764d6d7 100644--- a/tests/scenarios/INDEX.yaml+++ b/tests/scenarios/INDEX.yaml@@ -8,6 +8,18 @@ navigation:- Read that capability's observations.yaml.- Read the listed scenario test files before changing production code.capabilities:+ - id: memory_upgrade_compatibility+ name: Memory retirement and official release upgrade compatibility+ status: active+ catalog: tests/scenarios/memory_upgrade_compatibility/catalog.yaml+ observations: tests/scenarios/memory_upgrade_compatibility/observations.yaml+ scenario_tests:+ - 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.py+ unit_or_contract_tests:+ - tests/test_release_verification.py- id: model_hubname: Model Hub configured routes and turn outcomesstatus: activediff --git a/tests/scenarios/memory_upgrade_compatibility/catalog.yaml b/tests/scenarios/memory_upgrade_compatibility/catalog.yamlnew file mode 100644index 000000000..1b37f379b--- /dev/null+++ b/tests/scenarios/memory_upgrade_compatibility/catalog.yaml@@ -0,0 +1,44 @@+version: 1+capability:+ id: memory_upgrade_compatibility+ name: Memory retirement and official release upgrade compatibility+ canonical_tests:+ - 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.py+ shared_harness: []+status_legend:+ covered: deterministic test or release-gated end-to-end evidence exists+scenarios:+ - id: MUC-001+ name: startup migration removes obsolete config key only after successful write while preserving other configuration and user data+ status: covered+ kind: upgrade+ layer: contract+ test: tests/test_memory_removal.py::test_retired_memory_removed_only_after_successful_startup_migration+ - id: MUC-002+ name: concurrent config writer wins and next startup can complete migration+ status: covered+ kind: concurrency+ layer: contract+ test: tests/test_memory_removal.py::test_retired_memory_migration_does_not_overwrite_concurrent_writer+ - id: MUC-003+ name: malformed config remains intact during recovery+ status: covered+ kind: recovery+ layer: contract+ test: tests/test_memory_removal.py::test_retired_memory_malformed_config_keeps_original_for_recovery+ - id: MUC-004+ name: official publication gates real pip and uv upgrades from pinned v3.1.0 wheels to built core and inert bridge+ status: covered+ kind: release+ layer: scenario+ test: 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.yamlnew file mode 100644index 000000000..1e5be0c96--- /dev/null+++ b/tests/scenarios/memory_upgrade_compatibility/observations.yaml@@ -0,0 +1,12 @@+version: 1+capability: memory_upgrade_compatibility+observations:+ - id: MUC-OBS-001+ source: post-removal-official-upgrade-audit+ summary: Startup's Model Hub persistence copied the old root including memory; the existing bridge E2E was opt-in and absent from the official publish job, and the guard selected draft releases.+ affects:+ - MUC-001+ - MUC-004+ - MUC-005+ previous_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/scenarios/memory_upgrade_compatibility/test_catalog.py b/tests/scenarios/memory_upgrade_compatibility/test_catalog.pynew file mode 100644index 000000000..c6116094a--- /dev/null+++ b/tests/scenarios/memory_upgrade_compatibility/test_catalog.py@@ -0,0 +1,33 @@+"""Mechanical evidence binding for Memory retirement upgrade scenarios."""++import ast+from pathlib import Path++import yaml+++ROOT = Path(__file__).resolve().parents[3]+SCENARIO_ROOT = ROOT / "tests/scenarios/memory_upgrade_compatibility"+++def test_memory_upgrade_scenario_ids_resolve_to_executable_evidence():+ index = yaml.safe_load((ROOT / "tests/scenarios/INDEX.yaml").read_text())+ entry, = [item for item in index["capabilities"] if item["id"] == "memory_upgrade_compatibility"]+ catalog = yaml.safe_load((SCENARIO_ROOT / "catalog.yaml").read_text())+ observations = yaml.safe_load((SCENARIO_ROOT / "observations.yaml").read_text())+ assert {entry["catalog"], entry["observations"]} == {+ "tests/scenarios/memory_upgrade_compatibility/catalog.yaml",+ "tests/scenarios/memory_upgrade_compatibility/observations.yaml",+ }+ scenarios = catalog["scenarios"]+ ids = {item["id"] for item in scenarios}+ assert len(ids) == len(scenarios)+ for scenario in scenarios:+ path, name = scenario["test"].split("::")+ assert path in catalog["capability"]["canonical_tests"]+ assert path in entry["scenario_tests"] or path in entry["unit_or_contract_tests"]+ functions = [node for node in ast.parse((ROOT / path).read_text()).body if isinstance(node, ast.FunctionDef)]+ function, = [node for node in functions if node.name == name]+ assert scenario["id"] in (ast.get_docstring(function) or "")+ for observation in observations["observations"]:+ assert set(observation["affects"]) <= idsdiff --git a/tests/test_memory_removal.py b/tests/test_memory_removal.pyindex abeb5878e..c7a75fd4e 100644--- a/tests/test_memory_removal.py+++ b/tests/test_memory_removal.py@@ -3,6 +3,9 @@import jsonfrom pathlib import Path+import pytest++import config.v2_config as v2_configfrom config.v2_config import V2Config, config_write_transaction@@ -32,9 +35,6 @@ def test_config_write_transaction_loads_test_owned_snapshot(tmp_path: Path, monkwith config_write_transaction(path) as snapshot:assert snapshot.runtime.default_cwd == config.runtime.default_cwd-import pytest--@pytest.mark.parametrize("obsolete", [True, None, "legacy", [], {"enabled": True}])def test_json_obsolete_memory_shapes_are_ignored(obsolete, tmp_path):payload = {@@ -47,3 +47,70 @@ def test_json_obsolete_memory_shapes_are_ignored(obsolete, tmp_path):}config = V2Config.from_payload(json.loads(json.dumps(payload)))assert config.runtime.default_cwd == str(tmp_path / "work")+++def _old_config(tmp_path, monkeypatch):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path / "home"))+ path = tmp_path / "config.json"+ V2Config.default().save(path)+ payload = json.loads(path.read_text())+ payload["memory"] = {"enabled": True, "retained": {"legacy": 1}}+ payload["legacy_delivery"] = {"format": "old"}+ path.write_text(json.dumps(payload))+ return path, payload++[email protected]("minimal_hub", [False, True])+def test_retired_memory_removed_only_after_successful_startup_migration(tmp_path, monkeypatch, minimal_hub):+ """MUC-001: startup persistence removes the key without losing other keys or data."""+ path, payload = _old_config(tmp_path, monkeypatch)+ if minimal_hub:+ payload["model_hub"] = {"enabled": False, "runtime_default_applied": True}+ path.write_text(json.dumps(payload))+ data = tmp_path / "home/memory/sentinel.bin"+ data.parent.mkdir(parents=True)+ data.write_bytes(b"\x00legacy\xff")+ V2Config.load(config_path=path)+ assert json.loads(path.read_text()) == payload+ loaded = V2Config.load(config_path=path, persist_migrations=True)+ saved = json.loads(path.read_text())+ assert not loaded.load_warnings+ assert "memory" not in saved+ assert saved["legacy_delivery"] == payload["legacy_delivery"]+ assert saved["model_hub"] == payload["model_hub"]+ assert data.read_bytes() == b"\x00legacy\xff"+ assert any(path.parent.glob("config.json.bak-model-hub-migration-*"))+++def test_retired_memory_migration_does_not_overwrite_concurrent_writer(tmp_path, monkeypatch):+ """MUC-002: a competing write wins; the next startup may retry."""+ path, payload = _old_config(tmp_path, monkeypatch)+ original = v2_config._write_config_payload_if_unchanged++ def competing_write(target, replacement, expected):+ updated = json.loads(target.read_text())+ updated["legacy_delivery"]["format"] = "new"+ updated["legacy_delivery"]["revision"] = updated["legacy_delivery"].get("revision", 0) + 1+ target.write_text(json.dumps(updated))+ return original(target, replacement, expected)++ monkeypatch.setattr(v2_config, "_write_config_payload_if_unchanged", competing_write)+ V2Config.load(config_path=path, persist_migrations=True)+ saved = json.loads(path.read_text())+ assert saved["memory"] == payload["memory"]+ assert saved["legacy_delivery"]["format"] == "new"+ monkeypatch.setattr(v2_config, "_write_config_payload_if_unchanged", original)+ V2Config.load(config_path=path, persist_migrations=True)+ saved = json.loads(path.read_text())+ assert "memory" not in saved+ assert saved["legacy_delivery"]["format"] == "new"+++def test_retired_memory_malformed_config_keeps_original_for_recovery(tmp_path, monkeypatch):+ """MUC-003: recovery must not silently strip the old config."""+ path, payload = _old_config(tmp_path, monkeypatch)+ payload["model_hub"] = {"sources": 42}+ path.write_text(json.dumps(payload))+ loaded = V2Config.load(config_path=path, persist_migrations=True)+ assert loaded.load_warnings+ assert json.loads(path.read_text()) == payloaddiff --git a/tests/test_memory_runtime_release_guard.py b/tests/test_memory_runtime_release_guard.pyindex 903bd4741..aab18a1ab 100644--- a/tests/test_memory_runtime_release_guard.py+++ b/tests/test_memory_runtime_release_guard.py@@ -116,7 +116,7 @@ def test_failed_fetch_preserves_previous_verified_backup_output(monkeypatch, tmpdef test_resolve_manifests_shell_selects_history_and_excludes_new_or_invalid_wheels(tmp_path):- """Execute the workflow's resolver with a fake gh release API/download."""+ """MUC-005: execute the resolver against published stable/prerelease and draft fixtures."""import yamlworkflow = yaml.safe_load((Path(__file__).parents[1] / ".github/workflows/memory-runtime-release-guard.yml").read_text())@@ -138,6 +138,9 @@ def test_resolve_manifests_shell_selects_history_and_excludes_new_or_invalid_whearchive.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"),@@ -147,14 +150,28 @@ def test_resolve_manifests_shell_selects_history_and_excludes_new_or_invalid_wheshutil.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 pathlib, shutil, sys\n"+ "import json, pathlib, shutil, subprocess, sys\n""args=sys.argv[1:]\n""if args[:2] == ['api', '--paginate']:\n"- " print('v3.1.0\\tavibe-os\\tavibe_os-*.whl\\n' 'gh-v3.2.0rc1\\tavibe-memory\\tavibe_memory-*.whl\\n' 'v3.2.0\\tavibe-memory\\tavibe_memory-*.whl')\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"@@ -180,7 +197,8 @@ def test_resolve_manifests_shell_selects_history_and_excludes_new_or_invalid_wherecords = json.loads(values["manifests"])excluded = json.loads(values["excluded"])assert values["available"] == "true"- assert [item["release_tag"] for item in records] == ["v3.1.0"]+ 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"]diff --git a/tests/test_release_verification.py b/tests/test_release_verification.pyindex 20ae52310..353081692 100644--- a/tests/test_release_verification.py+++ b/tests/test_release_verification.py@@ -193,7 +193,10 @@ def test_workflow_owned_checkout_supplies_the_executed_contract(tmp_path, workflfor name in files:target = remote / nametarget.parent.mkdir(parents=True, exist_ok=True)- target.write_text("print('workflow-owned automation')\n")+ if workflow_name == "publish.yml" and (name.startswith("tests/e2e/") or name == "tests/__init__.py"):+ shutil.copy2(ROOT / name, target)+ else:+ target.write_text("print('workflow-owned automation')\n")_fixture_git(remote, "add", ".")_fixture_git(remote, "commit", "-m", "workflow automation")workflow = _fixture_git(remote, "rev-parse", "HEAD")@@ -211,6 +214,14 @@ def test_workflow_owned_checkout_supplies_the_executed_contract(tmp_path, workflresult = subprocess.run([sys.executable, str(tmp_path / script), "ensure-draft"],cwd=tmp_path, capture_output=True, text=True)assert result.returncode == 0 and "workflow-owned automation" in result.stdout+ assert not (tmp_path / "tests/e2e/test_retired_updater_bridge.py").exists()+ collected = subprocess.run(+ [sys.executable, "-m", "pytest", "--collect-only", "-q", "tests/e2e/test_retired_updater_bridge.py"],+ cwd=destination, env={**os.environ, "PYTHONPATH": ""},+ capture_output=True, text=True, timeout=15,+ )+ assert collected.returncode == 0, collected.stdout + collected.stderr+ assert "1 test collected" in collected.stdout@pytest.mark.parametrize("workflow", ["publish.yml", "release_ai.yml"])@@ -314,6 +325,116 @@ def test_release_installer_job_provisions_the_same_uv_as_its_ci_consumer():assert not consumer.get("if") and not consumer.get("continue-on-error")+def test_muc_004_official_publish_gates_real_retired_updater_before_assets_and_pypi():+ """MUC-004: released old wheels, built new wheels, Docker and pytest all gate publication."""+ job = _job("publish.yml", "build")+ bridge = _step(job, "Build and verify inert old-updater bridge")+ consumer = _step(job, "Run release install and upgrade regressions")+ upload = _step(job, "Upload GitHub release assets")+ assert job["steps"].index(bridge) < job["steps"].index(consumer) < job["steps"].index(upload)+ checkout = _step(job, "Checkout release automation")+ assert checkout["with"]["ref"] == "${{ needs.resolve-tag.outputs.workflow_sha }}"+ assert _step(job, "Checkout")["with"]["ref"] == "${{ needs.resolve-tag.outputs.tag }}"+ resolve = _step(_job("publish.yml", "resolve-tag"), "Resolve tag")["run"]+ assert 'if [ "${{ github.event_name }}" = "push" ]; then' in resolve+ assert 'WORKFLOW_SHA="$SOURCE_SHA"' in resolve+ assert set((+ "tests/__init__.py",+ "tests/e2e/test_retired_updater_bridge.py",+ "tests/e2e/test_install_command.py",+ "tests/e2e/retired_updater_probe.py",+ "tests/e2e/github_release_fixture.py",+ )) <= set(checkout["with"]["sparse-checkout"].splitlines())+ assert "build" in _job("publish.yml", "publish-avibe-os")["needs"]+ assert "finalize-github-release" in _job("publish.yml", "publish-avibe-os")["needs"]+ assert consumer["env"]["GH_TOKEN"] == "${{ github.token }}"+ commands = consumer["run"]+ for contract in (+ "tests/e2e/test_retired_updater_bridge.py",+ "AVIBE_RELEASE_GATE=1",+ "AVIBE_CORE_WHEEL=",+ "AVIBE_BRIDGE_WHEEL=",+ "AVIBE_OLD_CORE_WHEEL=",+ "AVIBE_OLD_COMPANION_WHEEL=",+ "gh release download v3.1.0",+ "7c2321ae32174c0fcf0b659c7d7a5b90ae53740c223ae41452702adbc393b924",+ "ce5cfb1473442642d7d19863b6f9131c0a17a1fb6e828d5e0aec04f2deea06b0",+ "sha256sum -c -",+ "docker info",+ ):+ assert contract in commands+ assert "dist/avibe_memory-*-py3-none-any.whl" in upload["run"]+ assert "cd release-automation && pytest tests/e2e/test_retired_updater_bridge.py -v" in commands+ assert "TARGET_VERSION=\"$(python release-automation/scripts/release_package_version.py \"$RELEASE_TAG\")\"" in commands+ assert 'realpath "$VIBE_INSTALL_TEST_WHEEL"' in commands+ assert "realpath old-release/avibe_memory-3.1.0-py3-none-any.whl" in commands+++ ("tag", "forward"),+ [+ ("v3.0.14", False),+ ("v3.1.0rc1", False),+ ("v3.1.0", False),+ ("v3.1.0.post1", True),+ ("v3.1.1rc1", True),+ ("v3.2.0", True),+ ("v4.0.0", True),+ ],+)+def test_muc_004_retirement_gate_replays_from_workflow_checkout(tmp_path, tag, forward):+ """MUC-004: old tag has no gate; forward tag executes the complete workflow checkout."""+ step = _step(_job("publish.yml", "build"), "Run release install and upgrade regressions")+ gate = "TARGET_VERSION=" + step["run"].split("TARGET_VERSION=", 1)[1]+ automation = tmp_path / "release-automation"+ script = automation / "scripts/release_package_version.py"+ script.parent.mkdir(parents=True)+ shutil.copy2(ROOT / "scripts/release_package_version.py", script)+ test = automation / "tests/e2e/test_retired_updater_bridge.py"+ test.parent.mkdir(parents=True)+ shutil.copy2(ROOT / "tests/e2e/test_retired_updater_bridge.py", test)+ binaries = tmp_path / "bin"+ binaries.mkdir()+ (binaries / "python").write_text(f"#!/bin/sh\nexec {shlex.quote(sys.executable)} \"$@\"\n")+ (binaries / "python").chmod(0o755)+ mock_pytest = binaries / "pytest"+ mock_pytest.write_text(+ "#!/usr/bin/env python3\n"+ "import os, pathlib, sys\n"+ "assert pathlib.Path(sys.argv[1]).is_file()\n"+ "pathlib.Path(os.environ['GATE_LOG']).write_text(str(pathlib.Path.cwd()))\n"+ )+ mock_pytest.chmod(0o755)+ log = tmp_path / "gate.log"+ result = subprocess.run(+ ["bash", "-e", "-o", "pipefail", "-c", gate], cwd=tmp_path,+ env={**os.environ, "RELEASE_TAG": tag, "GATE_LOG": str(log),+ "PATH": f"{binaries}{os.pathsep}{os.environ['PATH']}"},+ capture_output=True, text=True, timeout=15,+ )+ assert result.returncode == 0, result.stdout + result.stderr+ assert log.exists() is forward+ if forward:+ assert log.read_text() == str(automation)+ else:+ assert "No forward Memory retirement upgrade" in result.stdout+++def test_muc_004_release_gate_cannot_skip_missing_artifacts_or_docker(monkeypatch):+ from tests.e2e import test_retired_updater_bridge as upgrade_bridge++ monkeypatch.setenv("AVIBE_RELEASE_GATE", "1")+ for name in ("AVIBE_CORE_WHEEL", "AVIBE_BRIDGE_WHEEL", "AVIBE_OLD_CORE_WHEEL", "AVIBE_OLD_COMPANION_WHEEL"):+ monkeypatch.delenv(name, raising=False)+ with pytest.raises(pytest.fail.Exception, match="requires all four"):+ upgrade_bridge.test_released_updater_replaces_companion_without_touching_user_data(Path("/unused"))+ for name in ("AVIBE_CORE_WHEEL", "AVIBE_BRIDGE_WHEEL", "AVIBE_OLD_CORE_WHEEL", "AVIBE_OLD_COMPANION_WHEEL"):+ monkeypatch.setenv(name, "/unused")+ monkeypatch.setattr(upgrade_bridge, "_docker_available", lambda: False)+ with pytest.raises(pytest.fail.Exception, match="requires Docker"):+ upgrade_bridge.test_released_updater_replaces_companion_without_touching_user_data(Path("/unused"))++@pytest.mark.parametrize("workflow_name", ["publish.yml", "release_ai.yml"])@pytest.mark.parametrize("state",