Files
roboco/tests/unit/runtime/test_provider_routing.py
T
21d6730400 feat(providers): Gemini CLI provider — ModelProvider.GEMINI (#660)
* feat(providers): Gemini CLI provider — ModelProvider.GEMINI

Mirrors the grok blueprint with source-verified divergences (all facts
pinned against google-gemini/gemini-cli @ 9681621c): no refresher
daemon — Google's refresh tokens are reusable, so the RO host mount is
COPIED to a writable container-local ~/.gemini and each container
refreshes in-process independently (the write-back crash risk on RO
never triggers); settings.json renders security.auth.selectedType
'oauth-personal', experimental.enableAgents=false (subagent ban),
autoConfigureMemory=false with a bounded heap; tool scoping rides the
tiered TOML Policy Engine (deny-only rules that yolo mode structurally
cannot beat); gemini -p with --output-format stream-json; usage parsed
from the run's own stdout stats — the adversarial pass caught the
parser reading the json-mode nested shape while the entrypoint runs
stream-json's FLAT shape (every real run would have priced $0 forever,
hidden by fixtures sharing the assumption) — now flat-primary with the
nested shape as cited fallback; rate-limit classified from structured
error.type only (model-echo immune), native exit 41 auth passthrough;
per-model pricing for the three GA models; migrations 084 (enum) + 085
(seed) complete the 082-085 finale chain. V1 excludes interactive
intake/secretary. Stack-merge required two behavior-preserving
complexity refactors in the shared park/usage plumbing (a park-pair
loop; a usage-reader dispatch dict).

* fix(providers): route gemini usage read through the containment barrier

Mirrors the codex/grok fix — _gemini_usage_json now delegates to
_read_usage_json_contained, so CodeQL's path-injection alert on the
gemini read is resolved by the same resolve-and-contain guard.

---------

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
2026-07-23 03:53:21 +02:00

47 lines
1.5 KiB
Python

"""The orchestrator routes only dedicated-backend providers through the registry.
GROK gets the GrokCliProvider, GEMINI gets the GeminiCliProvider; Anthropic /
Ollama Cloud / self-hosted (and any unknown value) return None so
``_spawn_container`` runs its built-in Claude Code path unchanged. This keeps
the GROK / GEMINI additions purely additive.
"""
from __future__ import annotations
from unittest.mock import patch
from roboco.llm.providers import GeminiCliProvider, GrokCliProvider
from roboco.runtime.orchestrator import AgentOrchestrator
def _make_orch() -> AgentOrchestrator:
with patch.object(AgentOrchestrator, "__init__", return_value=None):
orch = AgentOrchestrator.__new__(AgentOrchestrator)
orch._provider_registry = None
return orch
def test_provider_for_grok_returns_grok_provider() -> None:
assert isinstance(_make_orch()._provider_for("grok"), GrokCliProvider)
def test_provider_for_gemini_returns_gemini_provider() -> None:
assert isinstance(_make_orch()._provider_for("gemini"), GeminiCliProvider)
def test_provider_for_anthropic_returns_none() -> None:
assert _make_orch()._provider_for("anthropic") is None
def test_provider_for_ollama_cloud_returns_none() -> None:
assert _make_orch()._provider_for("ollama_cloud") is None
def test_provider_for_unknown_value_returns_none() -> None:
assert _make_orch()._provider_for("bogus") is None
def test_provider_registry_built_once() -> None:
orch = _make_orch()
assert orch._ensure_provider_registry() is orch._ensure_provider_registry()