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
fix(board): try every allowed subscription for the bio; pin the override's key billing
rubenluetke10-beepd9d4a1a93e87
diff --git a/docs/jarvis-board/ARCHITECTURE.md b/docs/jarvis-board/ARCHITECTURE.mdindex ffae0fb1b8..805539f350 100644--- a/docs/jarvis-board/ARCHITECTURE.md+++ b/docs/jarvis-board/ARCHITECTURE.md@@ -61,7 +61,7 @@| Phase | Code | Persistence | Responsibility ||---|---|---|---|| **A — Personal Dashboard** | `jarvis/board/aggregator.py`, `store.py` | `data/board/personal.db` (SQLite, sync) | FlightRecorder-JSONL → daily_stats / personal_records. Read-only API. |-| **B — Achievements + AI-Bio** | `jarvis/board/achievements.py`, `evaluator.py`, `profile.py`, `scheduler.py` | same `personal.db` (additive) | Live-EventBus subscriber unlocks achievements. Bio rewritten on achievement unlocks or on request, billed to a subscription once one is connected. |+| **B — Achievements + AI-Bio** | `jarvis/board/achievements.py`, `evaluator.py`, `profile.py`, `scheduler.py` | same `personal.db` (additive) | Live-EventBus subscriber unlocks achievements. Bio rewritten on achievement unlocks or on request, billed to a subscription once one is connected. `[board.bio].override_provider/override_model` is the user's deliberate pin and the only way the bio bills a per-token key while a subscription is connected. || **C — Federation Backend** | `board-backend/` (separate subproject) | `/data/board.db` (in the container) | Standalone service. Receives signed pushes from the local Jarvis. || **D — Friends** | extends `board-backend/` + `jarvis/ui/web/federation_proxy_routes.py` | same `board.db` (additive) | Pair, Activity, Reactions, Stories, Federation-Pull. |diff --git a/jarvis/board/bio_brain.py b/jarvis/board/bio_brain.pyindex 658940f152..d0450c2806 100644--- a/jarvis/board/bio_brain.py+++ b/jarvis/board/bio_brain.py@@ -6,19 +6,20 @@ it, never a voice or chat turn. It therefore followsauslegen"):* **Subscription mode** (a subscription is connected, or was within the- policy's memory window): the bio is written on a connected subscription with- the caller's contract forwarded (``resolve_subscription_brain``), else on a- free local model. When neither is usable the resolve raises+ policy's memory window): the bio is written on the first policy-allowed+ subscription that forwards the caller's contract, else on a free local+ model. When neither is usable the resolve raises:class:`~jarvis.brain.background_policy.BackgroundDeferred`; the generatorkeeps the old bio and the next board event tries again. It never slides ontoa per-token API key.* **Key-only install** (no subscription ever connected): today's frontierchain, unchanged, so a single-key download keeps a working bio (AGENTS.md"any single key must work").-* ``[board.bio].override_provider/override_model`` is a deliberate power-user- pin and is honoured as-is in both modes. In subscription mode an override- that cannot be instantiated falls through to the subscription path, never to- the keyed chain.+* ``[board.bio].override_provider/override_model`` is the user's deliberate+ pin and is honoured as-is in both modes, even when it names a keyed+ provider: it is the only way the bio bills a per-token key while a+ subscription is connected. An override that cannot be instantiated falls+ through to the subscription path, never to the keyed chain.Provider membership comes from the provider cards' billing mode (through thepolicy), never from a provider name (AP-21).@@ -63,23 +64,16 @@ def resolve_bio_brain(config: JarvisConfig, *, bus: EventBus | None = None) -> Boverride = _override_entry(config)if override is not None:+ # The user's deliberate pin (like an agent seat): the ONLY way the bio+ # bills a per-token key while a subscription is connected.brain = _instantiate(*override)if brain is not None:log.info("bio brain: power-user override %s", override[0])return brain- if any(background_policy.subscription_capable(name) for name in policy.allowed):- brain = brain_resolver.resolve_subscription_brain(- config, bus=bus, cli_timeout_s=BIO_TIMEOUT_S,- )- if brain is not None:- name = str(getattr(brain, "name", "") or "")- if policy.permits(name):- log.info("bio brain: subscription %s", name)- return brain- log.info(- "bio brain: %s is not allowed to bill background work right now", name,- )+ brain = _subscription_brain(config, policy)+ if brain is not None:+ return brainfor provider, model in _local_candidates(config, policy):brain = _instantiate(provider, model)@@ -92,6 +86,54 @@ def resolve_bio_brain(config: JarvisConfig, *, bus: EventBus | None = None) -> B)+def _subscription_brain(+ config: JarvisConfig, policy: background_policy.BackgroundProviders,+) -> Any | None:+ """The first policy-allowed subscription that takes the bio's contract.++ Same shape as ``resolve_subscription_brain`` — card order, a CLI with a+ real system channel first, ``structured_prompts`` required — but it walks+ EVERY subscription the policy allows. That resolver stops at its first+ connected candidate, which the policy may still refuse (a card with an+ API-key slot whose login is not confirmed), and a second subscription+ that could have written the bio would never be asked.+ """+ try:+ candidates = [+ name for name in brain_resolver._subscription_candidates(config)+ if policy.permits(name)+ ]+ except Exception: # noqa: BLE001 - a card problem means no subscription, not a crash+ log.info("bio brain: subscription candidates unavailable", exc_info=True)+ return None+ candidates.sort(key=lambda name: not brain_resolver._native_system_channel(name))++ for provider in candidates:+ kwargs: dict[str, Any] = {+ "structured_prompts": True,+ "cli_timeout_s": BIO_TIMEOUT_S,+ }+ model = brain_resolver._deep_model_for(config, provider)+ if model:+ kwargs["model"] = model+ try:+ brain = brain_resolver._get_registry().instantiate(provider, **kwargs)+ except TypeError:+ # No structured mode means the bio contract would be replaced by a+ # conversational wrapper; skip rather than write a chat answer.+ log.info("bio brain: %s cannot forward a system contract, skipped", provider)+ continue+ except Exception as exc: # noqa: BLE001 - an unusable candidate is skipped+ log.info(+ "bio brain: subscription %s not instantiable (%s)",+ provider, type(exc).__name__,+ )+ continue+ log.info("bio brain: subscription %s", provider)+ return brain+ return None++def _brain_provider_ids() -> list[str]:"""Every brain card id, in card order — the policy picks what may bill."""from jarvis.ui.web.provider_spec import PROVIDERSdiff --git a/tests/board/test_bio_brain.py b/tests/board/test_bio_brain.pyindex 6fb7d7f7ff..14eac5cac7 100644--- a/tests/board/test_bio_brain.py+++ b/tests/board/test_bio_brain.py@@ -29,11 +29,16 @@ class _FakeRegistry:"""Records every instantiation; a keyed one in subscription mode is the bug."""def __init__(- self, available: list[str], connected: tuple[str, ...] = (), fail: tuple[str, ...] = (),+ self,+ available: list[str],+ connected: tuple[str, ...] = (),+ fail: tuple[str, ...] = (),+ no_probe: tuple[str, ...] = (),) -> None:self._available = list(available)self._connected = set(connected)self._fail = set(fail)+ self._no_probe = set(no_probe)self.calls: list[tuple[str, dict[str, Any]]] = []def available(self) -> list[str]:@@ -41,14 +46,10 @@ class _FakeRegistry:def get_class(self, name: str) -> type:connected = name in self._connected- return type(- "FakeBrainClass",- (),- {- "native_system_prompt": True,- "subscription_connected": staticmethod(lambda: connected),- },- )+ attrs: dict[str, Any] = {"native_system_prompt": True}+ if name not in self._no_probe:+ attrs["subscription_connected"] = staticmethod(lambda: connected)+ return type("FakeBrainClass", (), attrs)def instantiate(self, name: str, **kwargs: Any) -> _Brain:self.calls.append((name, dict(kwargs)))@@ -76,10 +77,12 @@ def _world(available: list[str],connected: tuple[str, ...] = (),fail: tuple[str, ...] = (),+ no_probe: tuple[str, ...] = (),) -> _FakeRegistry:- registry = _FakeRegistry(available, connected, fail)+ """A provider in ``no_probe`` has no login probe: its login is unknown."""+ registry = _FakeRegistry(available, connected, fail, no_probe)monkeypatch.setattr(resolver, "_get_registry", lambda: registry)- policy._probe_override = lambda name: name in connected+ policy._probe_override = lambda name: None if name in no_probe else name in connectedreturn registry@@ -153,13 +156,59 @@ def test_no_usable_subscription_defers_without_touching_a_key(assert registry.calls == []-def test_override_is_honoured_as_is_in_subscription_mode(+def test_a_refused_subscription_does_not_hide_the_next_one(monkeypatch: pytest.MonkeyPatch,) -> None:+ """antigravity comes first by card order and has no login probe; with an+ API-key slot and an unknown login the policy refuses it. The bio must still+ reach the signed-in claude-cli instead of deferring."""+ registry = _world(+ monkeypatch,+ available=["openai", "antigravity", "claude-cli"],+ connected=("claude-cli",),+ no_probe=("antigravity",),+ )+ _frontier_must_not_run(monkeypatch)++ brain = bio_brain.resolve_bio_brain(JarvisConfig())++ assert brain.name == "claude-cli"+ assert registry.names() == ["claude-cli"]+++def test_every_allowed_subscription_is_tried_before_deferring(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ registry = _world(+ monkeypatch,+ available=["openai", "grok-build", "claude-cli"],+ connected=("claude-cli",),+ no_probe=("grok-build",),+ fail=("grok-build",),+ )+ _frontier_must_not_run(monkeypatch)++ brain = bio_brain.resolve_bio_brain(JarvisConfig())++ assert brain.name == "claude-cli"+ assert registry.names() == ["grok-build", "claude-cli"]+++def test_override_is_the_only_way_the_bio_bills_a_key_while_subscribed(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """The override is the user's deliberate pin and is honoured even when it+ names a keyed provider; without it the same install never touches a key."""registry = _world(monkeypatch, available=["openai", "claude-cli"], connected=("claude-cli",),)_frontier_must_not_run(monkeypatch)+ assert policy._billing("openai") == "api"++ assert bio_brain.resolve_bio_brain(JarvisConfig()).name == "claude-cli"+ assert _keyed(registry.names()) == []++ registry.calls.clear()cfg = JarvisConfig()cfg.board.bio.override_provider = "openai"cfg.board.bio.override_model = "picked-model"