Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(vertex): a credential family of its own, and a real Cloud project path
Haraldc1d9cc14e4ca
diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex db6bdb5b55..79400f896a 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -157,6 +157,21 @@ PROVIDER_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {("google_api_key", "GOOGLE_API_KEY"),("realtime_gemini_api_key", "JARVIS_REALTIME_GEMINI_API_KEY"),),+ # Google Cloud Vertex AI — the SAME Gemini models on Google's enterprise+ # endpoint, billed against a Cloud project instead of an AI Studio account.+ # It is a family of its OWN rather than a fourth Gemini slot on purpose:+ # the two accounts bill separately (the 2026-06-22 forensic), so a user who+ # holds both must be able to store both and point each tier at the one they+ # mean. There is deliberately NO cross-read to the ``gemini`` slots in+ # either direction — an AI Studio key forced onto the Vertex endpoint dies+ # with an auth error on every call, which is worse than an honest "no key".+ # A project-path install authenticates via a service account and stores no+ # key at all; ``vertex_credential_configured`` is what answers for those.+ "vertex": (+ ("vertex_api_key", "VERTEX_API_KEY"),+ ("google_vertex_api_key", "GOOGLE_VERTEX_API_KEY"),+ ("realtime_vertex_api_key", "JARVIS_REALTIME_VERTEX_API_KEY"),+ ),"grok": (("grok_api_key", "GROK_API_KEY"),("xai_api_key", "XAI_API_KEY"),@@ -182,6 +197,13 @@ PROVIDER_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {("google_aistudio_api_key", "GOOGLE_AIStudio_API_KEY"),("google_api_key", "GOOGLE_API_KEY"),),+ # Vertex Live — same dedicated-slot-first precedence as its siblings, but+ # the trailing fallbacks stay INSIDE the Vertex family (see "vertex" above).+ "vertex-live": (+ ("realtime_vertex_api_key", "JARVIS_REALTIME_VERTEX_API_KEY"),+ ("vertex_api_key", "VERTEX_API_KEY"),+ ("google_vertex_api_key", "GOOGLE_VERTEX_API_KEY"),+ ),# "grok-realtime" was removed 2026-07-16 (BUG-064 deaf-session wedge);# any stored realtime_grok_api_key simply stays unused in its backend.}@@ -218,6 +240,10 @@ JARVIS_AGENT_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {("jarvis_agent_nvidia_api_key", "JARVIS_AGENT_NVIDIA_API_KEY"),*PROVIDER_SECRET_CANDIDATES["nvidia"],),+ "vertex": (+ ("jarvis_agent_vertex_api_key", "JARVIS_AGENT_VERTEX_API_KEY"),+ *PROVIDER_SECRET_CANDIDATES["vertex"],+ ),}_PROVIDER_SECRET_OVERRIDES: ContextVar[Mapping[str, str | None] | None] = ContextVar(@@ -3489,11 +3515,34 @@ class GoogleAuthConfig(BaseModel):answer; ``always``/``never`` force the route for installs where the probeguesses wrong or the network blocks it. Read exclusively by``jarvis.core.google_genai`` (AP-31: no unread switch).++ The ``vertex_*`` fields below describe the FULL Vertex AI path — a real+ Google Cloud project rather than express mode — and are what the dedicated+ ``vertex`` provider family (brain, tool model, realtime, STT, TTS,+ subagents) resolves against. Express mode and the full path are mutually+ exclusive at the SDK boundary (``genai.Client`` refuses an ``api_key``+ together with ``project``/``location``), so exactly one of the two is ever+ sent: a configured ``vertex_project`` selects the project path and+ authenticates via Application Default Credentials (optionally the service+ account named here), an empty one keeps the express-key path. Both are read+ by ``jarvis.core.google_genai``."""model_config = ConfigDict(extra="allow")vertex_mode: Literal["auto", "always", "never"] = "auto"+ #: Google Cloud project that owns the Vertex AI quota. Empty = express+ #: mode (the key itself carries the trial/billing project).+ vertex_project: str | None = None+ #: Vertex region. ``global`` is Google's cross-region endpoint and the one+ #: with the broadest Gemini availability; a single region (``us-central1``,+ #: ``europe-west4``, …) is what a data-residency requirement needs.+ vertex_location: str = "global"+ #: Service-account JSON for the project path. Exported as+ #: ``GOOGLE_APPLICATION_CREDENTIALS`` so the Cloud SDK auth chain finds it.+ #: ``None`` = use whatever Application Default Credentials already resolve+ #: (gcloud login, workload identity, an ambient env var).+ service_account_path: str | None = Noneclass JarvisConfig(BaseModel):@@ -3745,6 +3794,14 @@ _PERSISTED_PROVIDER_ENV_KEYS: tuple[str, ...] = ("JARVIS__TTS__USE_VERTEX","JARVIS__TTS__VOICE_DE","JARVIS__TTS__VOICE_EN",+ # Google endpoint routing, same class of bug one section over: these decide+ # WHICH Google account every tier bills (AI Studio vs a Cloud project). A+ # stale inherited value sends the whole stack at an endpoint the user's key+ # cannot open, and the failure reads as "the key is broken".+ "JARVIS__GOOGLE__VERTEX_MODE",+ "JARVIS__GOOGLE__VERTEX_PROJECT",+ "JARVIS__GOOGLE__VERTEX_LOCATION",+ "JARVIS__GOOGLE__SERVICE_ACCOUNT_PATH",)@@ -4568,6 +4625,36 @@ def get_provider_secret(provider: str) -> str | None:return get_secret_any(PROVIDER_SECRET_CANDIDATES.get(provider, ()))+def vertex_credential_configured(config: JarvisConfig | None = None) -> bool:+ """Whether Vertex AI can authenticate on this host at all.++ Vertex is the one family whose credential is not always a key: the Google+ Cloud project path signs requests with Application Default Credentials (a+ service account, a ``gcloud`` login, workload identity), so a perfectly+ configured install can hold no ``vertex_api_key`` whatsoever. Every+ reachability probe that asks "is this provider set up" has to ask THIS+ instead of ``get_provider_secret`` alone, or the whole family is dead-listed+ on exactly the setup Google documents for production.++ A configured ``[google].vertex_project`` is the signal, not the presence of+ a credentials file: ADC resolves through several sources we deliberately do+ not enumerate here, and the honest answer to "can it authenticate" is the+ first real call. ``config`` is a test seam; production passes ``None``.+ """+ if get_provider_secret("vertex"):+ return True+ try:+ cfg = config if config is not None else load_config()+ return bool(str(getattr(cfg.google, "vertex_project", "") or "").strip())+ except Exception as exc: # noqa: BLE001 — an unreadable config is an unset one+ logging.getLogger(__name__).debug(+ "Vertex project lookup failed (%s: %s) — treating Vertex as unconfigured.",+ type(exc).__name__,+ exc,+ )+ return False++def get_jarvis_agent_secret(provider: str) -> str | None:"""Return the effective API key for one Jarvis-Agent provider.diff --git a/jarvis/core/google_genai.py b/jarvis/core/google_genai.pyindex 6eadbd914b..675b2ba2b5 100644--- a/jarvis/core/google_genai.py+++ b/jarvis/core/google_genai.py@@ -31,13 +31,26 @@ dictation polish, computer use, ack brain):An explicitly configured ``base_url`` (team proxy, W2) must bypass routingentirely — the proxy speaks the AI Studio wire format — which callers get bypassing ``route="aistudio"`` to :func:`build_genai_client`.++Everything above is about a key stored in the GEMINI slots, where the endpoint+has to be inferred. The dedicated ``vertex`` provider family is the other case:+there the user picked Vertex explicitly, so :func:`build_vertex_client` pins the+route with no probe at all and additionally serves the FULL Google Cloud path —+``[google].vertex_project``/``vertex_location`` with Application Default+Credentials instead of a key. That path is what a production Cloud project+actually uses, and it is the one an ``AIza`` key restricted to+``aiplatform.googleapis.com`` needs, since its shape is indistinguishable from+an AI Studio key."""from __future__ import annotationsimport hashlibimport logging+import osimport threading+from dataclasses import dataclass+from pathlib import Pathfrom typing import Any, Literallog = logging.getLogger("jarvis.google_genai")@@ -107,6 +120,74 @@ def classify_google_key(api_key: str) -> KeyRoute | None:return "aistudio"+@dataclass(frozen=True, slots=True)+class VertexProject:+ """The full-Vertex (Google Cloud project) half of ``[google]``.++ ``project`` empty means express mode — the API key carries the billing+ project itself and no project/location may be sent. Anything else selects+ the enterprise path: Application Default Credentials against+ ``project``/``location``, optionally from ``service_account_path``.+ """++ project: str | None+ location: str+ service_account_path: str | None++ @property+ def configured(self) -> bool:+ return bool(self.project)+++def vertex_project_settings() -> VertexProject:+ """Read the Vertex project path from ``[google]``; never raises.++ Same lazy-import + broad-fallback discipline as :func:`_configured_mode`:+ an unreadable or older config yields express mode, which is exactly the+ behaviour every install had before this path existed.+ """+ try:+ from jarvis.core.config import load_config++ google = load_config().google+ project = str(getattr(google, "vertex_project", "") or "").strip() or None+ location = str(getattr(google, "vertex_location", "") or "").strip() or "global"+ sa_path = str(getattr(google, "service_account_path", "") or "").strip() or None+ except Exception as exc: # noqa: BLE001 — config trouble must never break clients+ log.debug(+ "Vertex project settings unreadable (%s: %s) — using express mode.",+ type(exc).__name__,+ exc,+ )+ return VertexProject(project=None, location="global", service_account_path=None)+ return VertexProject(project=project, location=location, service_account_path=sa_path)+++def _export_service_account(path: str | None) -> None:+ """Point the Cloud SDK auth chain at *path* for this process.++ Only ever ADDS the pointer, and only when the file is really there: a+ ``GOOGLE_APPLICATION_CREDENTIALS`` aimed at a missing file makes google-auth+ fail outright, which is strictly worse than letting the ambient ADC chain+ (gcloud login, workload identity, an env var the user already set) answer.+ An env var the user set themselves is left untouched.+ """+ if not path:+ return+ if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"):+ return+ resolved = Path(path).expanduser()+ if not resolved.is_file():+ log.warning(+ "Vertex service account %s does not exist — falling back to the "+ "ambient Application Default Credentials.",+ resolved,+ )+ return+ os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(resolved)+ log.info("Vertex AI: authenticating via the service account at %s.", resolved)++def _configured_mode() -> str:"""``[google].vertex_mode`` with a hard fallback to ``auto``.@@ -296,16 +377,37 @@ async def resolve_google_key_route_async(api_key: str, *, transport: Any | Nonereturn _remember_route(fp, route, source=detail)-def _client_kwargs(api_key: str, route: KeyRoute, http_options: Any | None) -> dict[str, Any]:+def _client_kwargs(+ api_key: str,+ route: KeyRoute,+ http_options: Any | None,+ project: VertexProject | None = None,+) -> dict[str, Any]:"""Pure kwargs assembly for ``genai.Client`` — unit-testable sans SDK.- Express mode is exactly ``vertexai=True`` plus the key; no project or- location — the express endpoint infers the trial/billing project from the- key itself. The explicit ``api_key`` argument outranks any ambient- ``GOOGLE_API_KEY``/``GEMINI_API_KEY`` env, so no env-stripping is needed- here (unlike the TTS service-account path, which authenticates via env).+ Two shapes, never mixed. Express mode is exactly ``vertexai=True`` plus the+ key; no project or location — the express endpoint infers the trial/billing+ project from the key itself. The Google Cloud project path is+ ``vertexai=True`` plus ``project``/``location`` and NO key at all: the SDK+ enforces that mutual exclusion, and sending both is a hard construction+ error rather than a preference.++ The explicit ``api_key`` argument outranks any ambient+ ``GOOGLE_API_KEY``/``GEMINI_API_KEY`` env, so no env-stripping is needed on+ the key paths. The project path authenticates through Application Default+ Credentials instead, so it drops the key argument entirely — an ambient+ ``GOOGLE_API_KEY`` next to it makes the SDK warn and pick one."""- kwargs: dict[str, Any] = {"api_key": api_key}+ if route == "vertex" and project is not None and project.configured:+ kwargs: dict[str, Any] = {+ "vertexai": True,+ "project": project.project,+ "location": project.location,+ }+ if http_options is not None:+ kwargs["http_options"] = http_options+ return kwargs+ kwargs = {"api_key": api_key}if route == "vertex":kwargs["vertexai"] = Trueif http_options is not None:@@ -313,6 +415,58 @@ def _client_kwargs(api_key: str, route: KeyRoute, http_options: Any | None) -> dreturn kwargs+def _project_for(route: KeyRoute) -> VertexProject | None:+ """Project settings for a resolved route, plus the ADC side effect.++ ``None`` for AI Studio: that path has no notion of a Cloud project, and+ returning anything else would put a config read on every client build for+ the endpoint the vast majority of installs use. On the Vertex route the+ settings are read AND the service account is exported here, because the+ Cloud SDK reads that env at client construction — after this returns is+ already too late.+ """+ if route != "vertex":+ return None+ settings = vertex_project_settings()+ if settings.configured:+ _export_service_account(settings.service_account_path)+ return settings+++def build_vertex_client(api_key: str = "", *, http_options: Any | None = None) -> Any:+ """Build a client PINNED to Vertex AI — no probe, no AI Studio fallback.++ The dedicated ``vertex`` provider family calls this instead of+ :func:`build_genai_client` because its endpoint is a user decision, not a+ guess: a Google Cloud API key restricted to ``aiplatform.googleapis.com``+ carries the ordinary ``AIza`` shape, so the shape classifier would send it+ to AI Studio and it would fail on every call with an auth error that names+ nothing useful. Pinning also skips the probe round-trip entirely.++ ``api_key`` may be empty on the Cloud project path, where Application+ Default Credentials do the authenticating.+ """+ from google import genai++ settings = _project_for("vertex")+ if not api_key and not (settings and settings.configured):+ raise RuntimeError(+ "Vertex AI is not configured: store a Vertex AI API key (or set "+ "[google].vertex_project for the Google Cloud project path)."+ )+ return genai.Client(**_client_kwargs(api_key, "vertex", http_options, settings))+++async def build_vertex_client_async(api_key: str = "", *, http_options: Any | None = None) -> Any:+ """Async twin of :func:`build_vertex_client`.++ Pinning means there is no probe to keep off the event loop, so this is a+ thin wrapper — it exists so realtime callers reach the Vertex path through+ the same await-shaped door as :func:`build_genai_client_async`.+ """+ return build_vertex_client(api_key, http_options=http_options)++def build_genai_client(api_key: str,*,@@ -331,7 +485,7 @@ def build_genai_client(from google import genairesolved = route or resolve_google_key_route(api_key)- return genai.Client(**_client_kwargs(api_key, resolved, http_options))+ return genai.Client(**_client_kwargs(api_key, resolved, http_options, _project_for(resolved)))async def build_genai_client_async(@@ -349,7 +503,7 @@ async def build_genai_client_async(from google import genairesolved = route or await resolve_google_key_route_async(api_key)- return genai.Client(**_client_kwargs(api_key, resolved, http_options))+ return genai.Client(**_client_kwargs(api_key, resolved, http_options, _project_for(resolved)))def reset_route_cache() -> None:diff --git a/tests/unit/core/test_google_vertex_project_path.py b/tests/unit/core/test_google_vertex_project_path.pynew file mode 100644index 0000000000..b08d364629--- /dev/null+++ b/tests/unit/core/test_google_vertex_project_path.py@@ -0,0 +1,266 @@+"""The dedicated Vertex AI path: pinned route, project mode, ADC.++Sibling of ``test_google_genai.py``, which covers the INFERRED route for a key+stored in a Gemini slot. Everything here is about the case where the user picked+Vertex explicitly, and the three facts that makes true:++1. The route is PINNED — no probe, no AI Studio fallback. Without this a Google+ Cloud API key restricted to ``aiplatform.googleapis.com`` (ordinary ``AIza``+ shape, so indistinguishable from an AI Studio key) would be sent to the wrong+ host and fail every call with an auth error that names nothing useful.+2. The express key and the Cloud project are MUTUALLY EXCLUSIVE at the SDK+ boundary. ``genai.Client`` refuses both together, so exactly one shape may+ ever be assembled.+3. A configured project counts as a credential even with no key stored anywhere,+ because Application Default Credentials do the signing on that path.++No network and no SDK: the kwargs assembly is pure, and the client build is+driven through a stub module so these run on a base install.+"""++from __future__ import annotations++import sys+from types import SimpleNamespace++import pytest++from jarvis.core import config as cfg+from jarvis.core import google_genai as gg++[email protected](autouse=True)+def _fresh_cache():+ gg.reset_route_cache()+ yield+ gg.reset_route_cache()+++def _no_ambient_adc(monkeypatch: pytest.MonkeyPatch):+ """Start from a host with no ``GOOGLE_APPLICATION_CREDENTIALS`` set."""+ monkeypatch.delenv("GOOGLE_APPLICATION_CREDENTIALS", raising=False)+++def _project(project: str | None, location: str = "global", sa: str | None = None):+ return gg.VertexProject(project=project, location=location, service_account_path=sa)+++# ── kwargs assembly: the two shapes never mix ────────────────────────────────+++def test_express_mode_sends_the_key_and_no_project() -> None:+ kwargs = gg._client_kwargs("AQ.express", "vertex", None, _project(None))+ assert kwargs == {"api_key": "AQ.express", "vertexai": True}+++def test_project_mode_sends_project_and_location_and_no_key() -> None:+ """The SDK rejects api_key together with project/location — so must we.++ Leaking the key into this shape is not a cosmetic issue: it is a hard+ construction error, i.e. every Vertex call on a correctly configured Cloud+ project would die before it left the process.+ """+ kwargs = gg._client_kwargs("AQ.ignored", "vertex", None, _project("my-proj", "europe-west4"))+ assert kwargs == {+ "vertexai": True,+ "project": "my-proj",+ "location": "europe-west4",+ }+ assert "api_key" not in kwargs+++def test_aistudio_route_is_untouched_by_the_project_settings() -> None:+ """Configuring a Cloud project must not change the AI Studio path at all."""+ kwargs = gg._client_kwargs("AIza-studio", "aistudio", None, _project("my-proj"))+ assert kwargs == {"api_key": "AIza-studio"}+++def test_http_options_survive_both_shapes() -> None:+ opts = object()+ express = gg._client_kwargs("AQ.k", "vertex", opts, _project(None))+ project = gg._client_kwargs("", "vertex", opts, _project("p"))+ assert express["http_options"] is opts+ assert project["http_options"] is opts+++# ── project settings are read defensively ────────────────────────────────────+++def test_settings_fall_back_to_express_mode_when_config_is_unreadable(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ def _boom():+ raise RuntimeError("config mid-boot")++ monkeypatch.setattr(cfg, "load_config", _boom)+ settings = gg.vertex_project_settings()+ assert settings.configured is False+ assert settings.location == "global"+++def test_blank_project_and_location_normalise(monkeypatch: pytest.MonkeyPatch) -> None:+ """Whitespace in a hand-edited TOML must not become a real project id."""+ monkeypatch.setattr(+ cfg,+ "load_config",+ lambda: SimpleNamespace(+ google=SimpleNamespace(+ vertex_project=" ", vertex_location="", service_account_path=" "+ )+ ),+ )+ settings = gg.vertex_project_settings()+ assert settings.project is None+ assert settings.configured is False+ assert settings.location == "global"+ assert settings.service_account_path is None+++# ── service account export: only when the file is really there ───────────────+++def test_service_account_is_exported_when_the_file_exists(tmp_path, _no_ambient_adc) -> None:+ sa = tmp_path / "vertex-sa.json"+ sa.write_text("{}", encoding="utf-8")+ gg._export_service_account(str(sa))+ import os++ assert os.environ["GOOGLE_APPLICATION_CREDENTIALS"] == str(sa)+++def test_missing_service_account_file_leaves_adc_alone(tmp_path, _no_ambient_adc) -> None:+ """A pointer at a missing file makes google-auth fail outright.++ Leaving the ambient chain (gcloud login, workload identity) to answer is+ strictly better than breaking it with a dead path.+ """+ gg._export_service_account(str(tmp_path / "absent.json"))+ import os++ assert "GOOGLE_APPLICATION_CREDENTIALS" not in os.environ+++def test_an_env_the_user_set_is_never_overwritten(+ tmp_path, monkeypatch: pytest.MonkeyPatch+) -> None:+ monkeypatch.setenv("GOOGLE_APPLICATION_CREDENTIALS", "/user/choice.json")+ sa = tmp_path / "ours.json"+ sa.write_text("{}", encoding="utf-8")+ gg._export_service_account(str(sa))+ import os++ assert os.environ["GOOGLE_APPLICATION_CREDENTIALS"] == "/user/choice.json"+++# ── the pinned client build ──────────────────────────────────────────────────+++class _StubGenaiModule:+ """Stands in for ``google.genai``, recording the kwargs it was built with."""++ def __init__(self) -> None:+ self.calls: list[dict] = []+ outer = self++ class Client:+ def __init__(self, **kwargs):+ outer.calls.append(kwargs)++ self.Client = Client+++def stub_genai(monkeypatch: pytest.MonkeyPatch) -> _StubGenaiModule:+ stub = _StubGenaiModule()+ google_pkg = SimpleNamespace(genai=stub)+ monkeypatch.setitem(sys.modules, "google", google_pkg)+ monkeypatch.setitem(sys.modules, "google.genai", stub)+ return stub+++def test_build_vertex_client_never_probes(+ monkeypatch: pytest.MonkeyPatch, stub_genai: _StubGenaiModule+) -> None:+ """An ``AIza`` key would classify as AI Studio — pinning must ignore that.++ This is the whole reason the dedicated family exists: a Cloud API key+ restricted to aiplatform wears the AI Studio shape, so any shape- or+ probe-based decision sends it to the wrong host.+ """++ def _must_not_run(*_args, **_kwargs): # pragma: no cover - guard+ raise AssertionError("build_vertex_client must not resolve a route")++ monkeypatch.setattr(gg, "resolve_google_key_route", _must_not_run)+ monkeypatch.setattr(gg, "vertex_project_settings", lambda: _project(None))++ gg.build_vertex_client("AIza-cloud-restricted")++ assert stub_genai.calls == [{"api_key": "AIza-cloud-restricted", "vertexai": True}]+++def test_build_vertex_client_uses_the_project_when_configured(+ monkeypatch: pytest.MonkeyPatch, stub_genai: _StubGenaiModule+) -> None:+ monkeypatch.setattr(gg, "vertex_project_settings", lambda: _project("prod-proj", "us-central1"))+ gg.build_vertex_client("")+ assert stub_genai.calls == [+ {"vertexai": True, "project": "prod-proj", "location": "us-central1"}+ ]+++def test_build_vertex_client_without_any_credential_says_so(+ monkeypatch: pytest.MonkeyPatch, stub_genai: _StubGenaiModule+) -> None:+ """No key and no project is a setup problem, and the error must name both fixes."""+ monkeypatch.setattr(gg, "vertex_project_settings", lambda: _project(None))+ with pytest.raises(RuntimeError) as exc:+ gg.build_vertex_client("")+ message = str(exc.value)+ assert "Vertex AI API key" in message+ assert "vertex_project" in message+ assert stub_genai.calls == []+++async def test_async_twin_builds_the_same_client(+ monkeypatch: pytest.MonkeyPatch, stub_genai: _StubGenaiModule+) -> None:+ monkeypatch.setattr(gg, "vertex_project_settings", lambda: _project(None))+ await gg.build_vertex_client_async("AQ.key")+ assert stub_genai.calls == [{"api_key": "AQ.key", "vertexai": True}]+++def test_aistudio_build_does_not_read_the_project_config(+ monkeypatch: pytest.MonkeyPatch, stub_genai: _StubGenaiModule+) -> None:+ """The overwhelmingly common path must not gain a config read per client."""++ def _must_not_run(): # pragma: no cover - guard+ raise AssertionError("the AI Studio path must not read Vertex settings")++ monkeypatch.setattr(gg, "vertex_project_settings", _must_not_run)+ gg.build_genai_client("AIza-studio", route="aistudio")+ assert stub_genai.calls == [{"api_key": "AIza-studio"}]+++# ── "is Vertex configured" is one question with one answer ───────────────────+++def test_a_stored_key_alone_counts_as_configured(monkeypatch: pytest.MonkeyPatch) -> None:+ with cfg.override_provider_secrets({"vertex": "AQ.stored"}):+ assert cfg.vertex_credential_configured() is True+++def test_a_project_alone_counts_as_configured() -> None:+ """The documented production setup stores no key at all."""+ config = SimpleNamespace(google=SimpleNamespace(vertex_project="prod-proj"))+ with cfg.override_provider_secrets({"vertex": None}):+ assert cfg.vertex_credential_configured(config) is True+++def test_neither_key_nor_project_is_unconfigured() -> None:+ config = SimpleNamespace(google=SimpleNamespace(vertex_project=""))+ with cfg.override_provider_secrets({"vertex": None}):+ assert cfg.vertex_credential_configured(config) is False