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(model-hub): close the two edges left in the OAuth grant wait (#2828)
Call Whiteb79aa59622eb
diff --git a/docs/plans/model-hub.md b/docs/plans/model-hub.mdindex a063a0b6a..a72b84b47 100644--- a/docs/plans/model-hub.md+++ b/docs/plans/model-hub.md@@ -2001,11 +2001,11 @@ OAuth grants, and until then lists each grant with no model and routes none ofthem (#2756). So after the health check a start also waits, for at most thefull 5-second config reload bound, until every grant the engine loaded (except adisabled one) lists a model. The wait has two outcomes. A listing the engine-refuses as a credential or route it does not hold (401/403/404), or an engine-that exited, fails the start. Anything else is ready once every grant lists a-model or the bound expires; grants still unlisted and failed or malformed-listings are logged as a degraded listing. API-key Sources are registered before-the engine answers.+refuses as a credential or route it does not hold (401/403/404), an engine that+stops listening after its health check answered, or one that exited, fails the+start. Anything else is ready once every grant lists a model or the bound+expires; grants still unlisted and failed or malformed listings are logged as a+degraded listing. API-key Sources are registered before the engine answers.CLIProxyAPI stdout and stderr are directed to the operating system's null sinkwhen the process is created. Child bytes therefore never enter Avibe's Pythonmemory or service logs and cannot create pipe backpressure. Startup diagnosticsdiff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.pyindex ee8623a4a..d804a5bbf 100644--- a/tests/test_model_hub_runtime.py+++ b/tests/test_model_hub_runtime.py@@ -3059,7 +3059,8 @@ def _write_mock_engine(grant_listing_delay: float = 0.0,auth_files_status: int = 200,auth_files_malformed: bool = False,- grant_models_malformed: bool = False,+ grant_models: object = "listed",+ drop_listener_on_auth_files: bool = False,) -> None:script = f"""#!{sys.executable}import json@@ -3139,6 +3140,11 @@ class Handler(BaseHTTPRequestHandler):mark_health_surface('management')self._json(200, {{'host': config['host']}})return+ if self.path == '/v0/management/auth-files' and {drop_listener_on_auth_files!r}:+ # The process lives on, but its listener is gone: nothing answers where Avibe connects.+ self.close_connection = True+ threading.Thread(target=server.shutdown, daemon=True).start()+ returnif self.path == '/v0/management/auth-files' and self.headers.get('X-Management-Key') == management:grants = sorted(os.listdir(config['auth-dir'])) if os.path.isdir(config['auth-dir']) else []files = [{{'name': name}} for name in grants if name.endswith('.json')]@@ -3148,7 +3154,8 @@ class Handler(BaseHTTPRequestHandler):time.sleep({grant_listing_delay!r})# CPA answers before its watcher loads the auth directory, listing each grant with no model until then.loaded = time.monotonic() - answering_since >= {grants_load_after!r}- models = ([{{}}] if {grant_models_malformed!r} else [{{'id': 'model-a'}}]) if loaded else []+ override = {grant_models!r}+ models = ([{{'id': 'model-a'}}] if override == 'listed' else override) if loaded else []self._json(200, {{'models': models}})returnself._json(401, {{'error': {{'type': 'unauthorized'}}}})@@ -3331,7 +3338,8 @@ def _fixture_supervisor(grant_listing_delay: float = 0.0,auth_files_status: int = 200,auth_files_malformed: bool = False,- grant_models_malformed: bool = False,+ grant_models: object = "listed",+ drop_listener_on_auth_files: bool = False,) -> tuple[EngineSupervisor, EngineStateStore]:tmp_path.mkdir(parents=True, exist_ok=True)binary = tmp_path / "mock-engine"@@ -3349,7 +3357,8 @@ def _fixture_supervisor(grant_listing_delay=grant_listing_delay,auth_files_status=auth_files_status,auth_files_malformed=auth_files_malformed,- grant_models_malformed=grant_models_malformed,+ grant_models=grant_models,+ drop_listener_on_auth_files=drop_listener_on_auth_files,)installer = _FixtureInstaller(binary, tmp_path / "versions" / "install-1")store = EngineStateStore(tmp_path / "state")@@ -4728,18 +4737,23 @@ def test_the_wait_for_oauth_grants_is_bounded_as_a_whole_however_many_grants_ans[({"auth_files_status": 404}, None),({"auth_files_status": 401}, None),+ ({"drop_listener_on_auth_files": True}, None),({"auth_files_status": 503}, "failure=503"),({"auth_files_malformed": True}, "failure=malformed_inventory"),- ({"grant_models_malformed": True}, "failure=malformed_listing"),+ ({"grant_models": [{}]}, "failure=malformed_listing"),+ ({"grant_models": None}, "failure=malformed_listing"),+ ],+ ids=[+ "disowned-404", "disowned-401", "disowned-listener-lost", "degraded-503", "degraded-malformed-inventory",+ "degraded-malformed-models", "degraded-null-models",],- ids=["disowned-404", "disowned-401", "degraded-503", "degraded-malformed-inventory", "degraded-malformed-models"],)def test_a_failed_grant_listing_fails_the_start_only_when_the_engine_disowns_its_config(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture,listing: dict, degraded: str | None,) -> None:- """MH-RUNTIME-005 (#2756): an engine that answers its health check but refuses the grant listing as a credential- or route it does not hold never starts as ready, and is stopped. Any other failure, a malformed inventory or+ """MH-RUNTIME-005 (#2756, #2826): an engine that answers its health check but refuses the grant listing as a+ credential or route it does not hold, or then stops listening, never starts as ready, and is stopped. Any other failure, a malformed inventory ormodel listing included, is a degraded listing, not a failed engine: the start polls it through the bound, sayswhy, and is ready."""diff --git a/vibe/model_hub_runtime/supervisor.py b/vibe/model_hub_runtime/supervisor.pyindex 570161edc..1033ba1d3 100644--- a/vibe/model_hub_runtime/supervisor.py+++ b/vibe/model_hub_runtime/supervisor.py@@ -598,12 +598,13 @@ class EngineSupervisor:except Exception as exc:self._stop_locked()raise EngineUnavailableError("models.engine.unsafe_permissions") from exc+ # It has answered: a refusal from here on, the grant wait's included, is a lost listener (#2826).+ self._engine_answered = Trueif not self._oauth_grants_listed_locked(connection) or process.poll() is not None:time.sleep(min(_STARTUP_POLL_INTERVAL_SECONDS, max(0.0, deadline - time.monotonic())))continueself._last_check = _utc_now()self._verified_at = time.monotonic()- self._engine_answered = Truelogger.info("Model Hub engine startup outcome=ready managed_version=%s ""elapsed_seconds=%.3f child_output_retained=false",@@ -637,7 +638,8 @@ class EngineSupervisor:The wait has exactly two outcomes:* Not ready (False): the engine refused a listing as a credential or- route it does not hold (``_disowns_config_locked``). The caller also+ route it does not hold, or stopped listening after it answered its+ health check (``_disowns_config_locked``). The caller alsotreats an engine that exited as not ready. Either way the start failslike any start that never becomes ready.* Ready (True): every loaded grant lists a model the discovery reader@@ -687,7 +689,8 @@ class EngineSupervisor:models = listing("/auth-files/models", {"name": name})if models is not None and _lists_a_model(models):listed.add(name)- elif models is not None and models.get("models"):+ elif models is not None and models.get("models") != []:+ # An empty list is a grant with no model yet; anything else is not a listing.failure = "malformed_listing"if pending is not None:pending = [name for name in pending if name not in listed]