Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

test(model-hub): accept exactly the engine version the selected manifest names (#2784)

Call Whiteb21d43736bcf
diff --git a/docs/maintenance/upstream-dependency-maintenance.md b/docs/maintenance/upstream-dependency-maintenance.md
index 2a9545b41..e3c79e3ae 100644
--- a/docs/maintenance/upstream-dependency-maintenance.md
+++ b/docs/maintenance/upstream-dependency-maintenance.md
@@ -243,9 +243,15 @@ Preparation:
6. Run the focused builder/guard tests, then run the existing installed-service
acceptance once with
`VIBE_MODEL_HUB_ENGINE_MANIFEST_PATH=/tmp/avibe-candidate-assets/model-hub-engine-offline-manifest.json`
- (and the candidate normal wheel) against synthetic loopback upstreams. Record
- the real result and prepare the PR with the candidate manifest/patch
- metadata. The existing release workflow remains the publication/recovery
+ (and the candidate normal wheel) against synthetic loopback upstreams. That
+ variable is the acceptance's only engine input: the service installs from the
+ manifest it names (else the packaged one), and the acceptance asserts that the
+ engine it installed and verified is that manifest's build: its `version`,
+ `source_sha`, and the host platform asset's `sha256` and `size_bytes`. So an
+ ignored override, or a packaged engine installed by accident, fails the run
+ instead of passing as candidate acceptance, even when both name the same
+ upstream version. Record the real result and prepare the PR
+ with the candidate manifest/patch metadata. The existing release workflow remains the publication/recovery
authority; do not change the packaged pin or publish from candidate mode.
Strict pinned mode remains the recovery and publication path: it must verify
diff --git a/tests/e2e/test_model_hub_service_acceptance.py b/tests/e2e/test_model_hub_service_acceptance.py
index 70c1540ec..8475be1ca 100644
--- a/tests/e2e/test_model_hub_service_acceptance.py
+++ b/tests/e2e/test_model_hub_service_acceptance.py
@@ -6,7 +6,8 @@ the same way on Linux and macOS. It drives ``vibe`` exactly as a user's install
does -- the CLI starts the background service, the Web UI API configures it --
against two loopback upstreams, and proves:
-- the engine installs from the packaged manifest and becomes healthy;
+- the engine installs from the selected manifest (``VIBE_MODEL_HUB_ENGINE_MANIFEST_PATH``,
+ else the packaged one), as that manifest's verified build, and becomes healthy;
- an API-key Source saves through the real credential check;
- a Vibey turn and a Claude Code hub-mode turn each get the upstream's reply;
- after the service is killed outright, the next start reaps the engine it
@@ -28,7 +29,7 @@ import urllib.error
import urllib.request
from http.cookiejar import CookieJar
from pathlib import Path
-from typing import Any, Iterator
+from typing import Any, Iterator, Mapping
import psutil
import pytest
@@ -44,6 +45,8 @@ _CLAUDE_MODEL = "claude-sonnet-4-6"
_VIBEY_MODEL = "acceptance-chat"
_REPLY = "mock response"
_ENGINE_START_SECONDS = 600
+_ENGINE_MANIFEST_ENV = "VIBE_MODEL_HUB_ENGINE_MANIFEST_PATH"
+_ENGINE_MANIFEST_URL_ENV = "VIBE_MODEL_HUB_ENGINE_MANIFEST_URL"
_TURN_SECONDS = 300
@@ -145,6 +148,14 @@ class _Service:
"VIBE_TMUX_OFFLINE": "1",
"VIBE_GIT_OFFLINE": "1",
}
+ # The manifest path is the acceptance's one engine control, as in the Model
+ # Hub E2E harness: an inherited manifest URL would outrank the packaged
+ # manifest the acceptance falls back to.
+ self.env.pop(_ENGINE_MANIFEST_URL_ENV, None)
+ if self.env.get(_ENGINE_MANIFEST_ENV):
+ # The service resolves a relative path from its own working directory,
+ # which is not this one; give it, and the acceptance, the same file.
+ self.env[_ENGINE_MANIFEST_ENV] = str(Path(self.env[_ENGINE_MANIFEST_ENV]).expanduser().resolve())
self._socket_dir: str | None = None
if os.name != "nt":
# A Unix socket path is capped near 104 bytes; a test home is deeper.
@@ -176,6 +187,15 @@ class _Service:
assert result.returncode == 0, (args, result.returncode, result.stdout[-4000:], result.stderr[-4000:])
return result
+ def packaged_engine_manifest(self) -> Path:
+ """The engine manifest the installed package ships, which the service selects without an override."""
+
+ result = self.python("-c", (
+ "from importlib import resources; "
+ "print(resources.files('vibe').joinpath('model_hub_runtime/cliproxyapi_manifest.json'))"
+ ))
+ return Path(result.stdout.strip())
+
def vibe(self, *args: str, timeout: float = 300, check: bool = True) -> subprocess.CompletedProcess[str]:
return self.python("-m", "vibe", *args, timeout=timeout, check=check)
@@ -344,6 +364,58 @@ def _process_is(entry: dict[str, Any]) -> bool:
return False
+def _selected_engine_manifest(env: Mapping[str, str], packaged_manifest: Path) -> dict[str, Any]:
+ """The manifest the service selects: the one ``VIBE_MODEL_HUB_ENGINE_MANIFEST_PATH`` names, else the packaged one.
+
+ ``_Service`` makes the override absolute before the service starts, so both
+ read the same file, and leaves the service no other selector. One that is missing, unreadable or names no version
+ fails the run: an acceptance must never pass without knowing what it accepted.
+ """
+
+ override = env.get(_ENGINE_MANIFEST_ENV)
+ path = Path(override) if override else packaged_manifest
+ try:
+ payload = json.loads(path.read_text(encoding="utf-8"))
+ except (OSError, ValueError) as exc:
+ pytest.fail(f"the selected engine manifest {path} is unreadable: {exc}")
+ version = payload.get("version") if isinstance(payload, dict) else None
+ if not isinstance(version, str) or not version.strip():
+ pytest.fail(f"the selected engine manifest {path} names no version")
+ return payload
+
+
+def _asset(manifest: dict[str, Any], platform: str) -> dict[str, Any] | None:
+ assets = manifest.get("assets")
+ return next(
+ (asset for asset in assets if isinstance(asset, dict) and asset.get("platform") == platform),
+ None,
+ ) if isinstance(assets, list) else None
+
+
+def _assert_installed_engine(runtime: dict[str, Any], selected: dict[str, Any]) -> None:
+ """The running engine is the selected manifest's build, not merely its upstream version.
+
+ The service reports the manifest it loaded and verifies the installed
+ binary against that manifest's asset, so the loaded asset must be the
+ selected one, byte identity included. An ignored override installs the
+ packaged engine and fails here even when both name the same upstream version.
+ """
+
+ platform = runtime["host_platform"]
+ wanted = _asset(selected, platform)
+ if wanted is None or not isinstance(wanted.get("sha256"), str):
+ pytest.fail(f"the selected engine manifest has no asset for {platform}")
+ loaded = runtime["manifest"]
+ identity = ("version", "source_sha")
+ assert {key: loaded.get(key) for key in identity} == {key: selected.get(key) for key in identity}, runtime
+ got = _asset(loaded, platform) or {}
+ assert (got.get("sha256"), got.get("size_bytes")) == (wanted["sha256"], wanted.get("size_bytes")), runtime
+ status = runtime["status"]
+ assert status["verified"] is True and status["installed_version"] == selected["version"], (
+ f"installed engine {status['installed_version']}, selected manifest {selected['version']}: {runtime}"
+ )
+
+
def _add_model(service: _Service, backend: str, model_id: str) -> None:
baseline = service.ok("GET", f"/api/models/agents/{backend}/models")["agent"].get("catalog_models") or []
if any(model.get("id") == model_id for model in baseline):
@@ -387,10 +459,16 @@ def test_fresh_install_serves_vibey_and_claude_through_the_hub_and_reaps_an_orph
service.vibe("start", "--no-open-browser", timeout=300)
service.wait_ready()
- # The engine installs from the packaged manifest and becomes healthy.
+ # The engine installs from the selected manifest (a candidate's, else the
+ # packaged one) and becomes healthy.
runtime = service.ok("POST", "/api/models/runtime/start", timeout=_ENGINE_START_SECONDS)["runtime"]
first = service.healthy_engine()
started.append(first)
+ # Read once healthy: while it installs, no version is reported yet.
+ _assert_installed_engine(
+ service.ok("GET", "/api/models/runtime/status")["runtime"],
+ _selected_engine_manifest(service.env, service.packaged_engine_manifest()),
+ )
# CI names the asset each runner must get, which is not always
# Python's architecture: Windows on Arm runs x64 Python.
expected_platform = os.environ.get("AVIBE_EXPECT_ENGINE_PLATFORM")
diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yaml
index 886afaf58..2b1e46c39 100644
--- a/tests/scenarios/model_hub/catalog.yaml
+++ b/tests/scenarios/model_hub/catalog.yaml
@@ -2533,13 +2533,17 @@ scenarios:
- id: MH-SERVICE-001
name: >-
A fresh install of the installed service, on Windows x64 and Arm64 as on Linux and macOS: the engine installs
- from the packaged manifest and turns healthy, API-key Sources save through the real credential check, a Vibey
+ from the selected manifest (a candidate's, else the packaged one) as that manifest's verified build and turns healthy,
+ API-key Sources save through the real credential check, a Vibey
turn and a Claude Code hub-mode turn get the upstream's reply, a hard-killed service's engine is reaped by the
next start, and vibe stop leaves no engine
status: assert
kind: runtime_lifecycle
layer: e2e-auto
test: tests/e2e/test_model_hub_service_acceptance.py::test_fresh_install_serves_vibey_and_claude_through_the_hub_and_reaps_an_orphaned_engine
+ related_tests:
+ - tests/test_model_hub_service_acceptance_helpers.py::test_an_ignored_override_that_installs_the_packaged_engine_fails_the_run
+ - tests/test_model_hub_service_acceptance_helpers.py::test_a_selected_manifest_without_a_usable_version_fails_the_run
- id: MH-HOSTED-GATEWAY-004
name: A proxied search runs one native request on the turn's first admitted executor, without an effort, and answers its canonical record and execution with the pricing module's cost and the same positive evidence a native call writes
status: covered
diff --git a/tests/test_model_hub_service_acceptance_helpers.py b/tests/test_model_hub_service_acceptance_helpers.py
new file mode 100644
index 000000000..6a4896c80
--- /dev/null
+++ b/tests/test_model_hub_service_acceptance_helpers.py
@@ -0,0 +1,148 @@
+"""MH-SERVICE-001 accepts exactly the engine build its selected manifest names (#2780)."""
+
+from __future__ import annotations
+
+import json
+import os
+from pathlib import Path
+
+import pytest
+
+from tests.e2e import test_model_hub_service_acceptance as acceptance
+
+_ENV = "VIBE_MODEL_HUB_ENGINE_MANIFEST_PATH"
+_PLATFORM = "linux-arm64"
+
+
+def _payload(version: object = "v8.0.30", sha: str = "a" * 64, source_sha: str = "c" * 40) -> dict:
+ return {
+ "schema_version": 1,
+ "version": version,
+ "source_sha": source_sha,
+ "assets": [{"platform": _PLATFORM, "url": "file:///x.tar.gz", "size_bytes": 10, "sha256": sha}],
+ }
+
+
+def _manifest(path: Path, **fields: object) -> Path:
+ path.write_text(json.dumps(_payload(**fields)), encoding="utf-8")
+ return path
+
+
+def _runtime(loaded: dict, installed: str | None = None, *, verified: bool = True) -> dict:
+ """The runtime status as the service reports it: the manifest it loaded and its install."""
+
+ return {
+ "host_platform": _PLATFORM,
+ "manifest": {"name": "cliproxyapi", "resolution": "resolved", "version": loaded["version"],
+ "source_sha": loaded["source_sha"], "assets": loaded["assets"]},
+ "status": {"installed_version": installed or loaded["version"], "verified": verified},
+ }
+
+
+def test_a_candidate_run_selects_the_candidate_with_no_other_input(tmp_path):
+ packaged = _manifest(tmp_path / "packaged.json", version="v8.0.23")
+ candidate = _manifest(tmp_path / "candidate.json", version="v8.0.30")
+
+ selected = acceptance._selected_engine_manifest({_ENV: str(candidate)}, packaged)
+
+ assert selected["version"] == "v8.0.30"
+ acceptance._assert_installed_engine(_runtime(selected), selected)
+
+
+def test_without_an_override_the_packaged_manifest_is_selected(tmp_path):
+ packaged = _manifest(tmp_path / "packaged.json", version="v8.0.23")
+
+ for env in ({}, {_ENV: ""}):
+ selected = acceptance._selected_engine_manifest(env, packaged)
+ assert selected["version"] == "v8.0.23"
+ acceptance._assert_installed_engine(_runtime(selected), selected)
+
+
+ "packaged_fields",
+ [
+ pytest.param({"version": "v8.0.23", "sha": "b" * 64}, id="another-version"),
+ # A rebuild with other patches keeps the upstream version but not the bytes.
+ pytest.param({"version": "v8.0.30", "sha": "b" * 64}, id="same-version-other-build"),
+ pytest.param({"version": "v8.0.30", "source_sha": "d" * 40}, id="same-version-other-source"),
+ ],
+)
+def test_an_ignored_override_that_installs_the_packaged_engine_fails_the_run(tmp_path, packaged_fields):
+ selected = acceptance._selected_engine_manifest(
+ {_ENV: str(_manifest(tmp_path / "candidate.json"))}, _manifest(tmp_path / "packaged.json")
+ )
+ packaged = _payload(**packaged_fields)
+
+ with pytest.raises(AssertionError):
+ acceptance._assert_installed_engine(_runtime(packaged), selected)
+
+
+def test_an_engine_not_verified_against_the_selected_build_fails_the_run(tmp_path):
+ selected = acceptance._selected_engine_manifest({}, _manifest(tmp_path / "packaged.json"))
+
+ with pytest.raises(AssertionError):
+ acceptance._assert_installed_engine(_runtime(selected, verified=False), selected)
+ with pytest.raises(AssertionError, match="installed engine v8.0.23"):
+ acceptance._assert_installed_engine(_runtime(selected, installed="v8.0.23"), selected)
+
+
+def test_a_selected_manifest_without_an_asset_for_the_host_fails_the_run(tmp_path):
+ selected = acceptance._selected_engine_manifest({}, _manifest(tmp_path / "packaged.json"))
+ selected["assets"] = []
+
+ with pytest.raises(pytest.fail.Exception, match="selected engine manifest has no asset"):
+ acceptance._assert_installed_engine(_runtime(_payload()), selected)
+
+
+ "selected",
+ [
+ pytest.param(lambda tmp: tmp / "absent.json", id="missing"),
+ pytest.param(lambda tmp: _write(tmp / "bad.json", "{not json"), id="malformed"),
+ pytest.param(lambda tmp: _write(tmp / "list.json", "[]"), id="not-an-object"),
+ pytest.param(lambda tmp: _manifest(tmp / "none.json", version=None), id="no-version"),
+ pytest.param(lambda tmp: _manifest(tmp / "blank.json", version=" "), id="blank-version"),
+ pytest.param(lambda tmp: _manifest(tmp / "number.json", version=8), id="non-string-version"),
+ ],
+)
[email protected]("which", ["candidate", "packaged"])
+def test_a_selected_manifest_without_a_usable_version_fails_the_run(tmp_path, selected, which):
+ path = selected(tmp_path)
+ good = _manifest(tmp_path / "good.json")
+ env, packaged = ({_ENV: str(path)}, good) if which == "candidate" else ({}, path)
+
+ with pytest.raises(pytest.fail.Exception, match="selected engine manifest"):
+ acceptance._selected_engine_manifest(env, packaged)
+
+
+def test_a_relative_override_reaches_the_service_and_the_acceptance_as_one_absolute_file(tmp_path, monkeypatch):
+ """The service resolves a relative path from its own working directory, so the acceptance hands it an absolute one."""
+
+ candidate = _manifest(tmp_path / "candidate.json")
+ monkeypatch.chdir(tmp_path)
+ monkeypatch.setenv(_ENV, "candidate.json")
+
+ service = acceptance._Service(tmp_path / "home", 0)
+ try:
+ assert service.env[_ENV] == str(candidate.resolve())
+ assert os.path.isabs(service.env[_ENV])
+ finally:
+ service.close()
+
+
+def test_an_inherited_manifest_url_never_selects_the_engine_the_acceptance_checks(tmp_path, monkeypatch):
+ """The service's only other selector, a manifest URL, would outrank the packaged fallback; it never reaches it."""
+
+ monkeypatch.delenv(_ENV, raising=False)
+ monkeypatch.setenv("VIBE_MODEL_HUB_ENGINE_MANIFEST_URL", "https://inherited.example/manifest.json")
+
+ service = acceptance._Service(tmp_path / "home", 0)
+ try:
+ assert not [name for name in service.env if name.startswith("VIBE_MODEL_HUB_ENGINE_MANIFEST")]
+ finally:
+ service.close()
+
+
+def _write(path: Path, text: str) -> Path:
+ path.write_text(text, encoding="utf-8")
+ return path