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(realtime): close round-6 findings — stale-teardown capture, cold plan path, block-aware readiness
Ruben Lütke39696dcd7c12
diff --git a/docs/os-parity.md b/docs/os-parity.mdindex 7e249cfd7f..9f51404cb6 100644--- a/docs/os-parity.md+++ b/docs/os-parity.md@@ -53,6 +53,7 @@ experiences today.| # | Impact | Area | Gap | Evidence | Behavior off-Windows ||---|---|---|---|---|---|+| P-29 | Low | Subscription voice | The dedicated ChatGPT-subscription voice login is an interactive browser flow, so a headless Linux host can never CONNECT the profile there (an existing login still reports ready and calls work through the browser voice bridge) | `jarvis/codex_app_server.py::_login_required_state`, `start_codex_subscription_login` | Headless Linux without a login: every surface (card, activation, voice-mode, Test) reports the same `lifecycle_unavailable` truth with the "run Jarvis on a desktop to connect" reason — no enabled Connect button that can only produce an error toast || P-24 | Medium | Dictation shortcut | The global dictation/call shortcut needs `pynput` on Linux/X11, and `pynput` hard-requires `evdev` — which is published **source-only** (verified on PyPI 2026-07-28: evdev 1.9.3 ships an sdist and no wheels) and compiles against the kernel headers. Putting it in `[full]` would break the one advertised install path on a stock `python:3.11-slim`, so it is the opt-in `[desktop-linux]` extra instead. Wayland is a separate, unfixable-by-install case: the compositor owns global shortcuts by design (the XDG `GlobalShortcuts` portal lets the *compositor* assign the keys, and no wlroots compositor implements it at all) | `pyproject.toml` (`desktop-linux`), `jarvis/platform/probes.py::has_hotkey`, `jarvis/trigger/backends/noop.py::explain_unavailable` | X11 without the extra: no global shortcut, and the log/UI now names the actual cause and the exact `pip install` that fixes it (it used to blame Wayland unconditionally). Wayland: no global shortcut at all — bind a compositor shortcut to `jarvis api dictation start`. On both, dictation still works from the Jarvis Bar, the Dictation view and the CLI, and voice still works via the wake word || P-25 | Medium | Dictation insertion | Pasting the transcript into another application is blocked, silently, in three OS-specific situations: Windows UIPI when the foreground window is elevated and Jarvis is not (`SendInput` reports success and the input is discarded), macOS Secure Input while a password field is focused, and Wayland outright (no synthetic input). Detection exists for the first two; Wayland is refused up front | `jarvis/dictation/insert.py::describe_target`, `jarvis/platform/input_isolation.py::windows_foreground_window_is_elevated`, `macos_secure_input_enabled` | All three degrade to the SAME honest outcome instead of silence: the transcript is left on the clipboard, the result is reported as `clipboard_only`, and the bar plus the Dictation view say why and that Ctrl+V will paste it. macOS Secure Input detection is implemented but has not been verified on real hardware from this machine || P-02 | Low | Awareness | Idle detection has no Wayland backend (Windows GetLastInputInfo, macOS Quartz, Linux X11 `xprintidle` all exist since 2026-07-16); Wayland exposes no global idle time without portal support | `jarvis/awareness/watchers/idle.py` | Wayland: one honest log line, watcher does not start |diff --git a/jarvis/codex_app_server.py b/jarvis/codex_app_server.pyindex f3b6e0e355..e9f9e8dbbc 100644--- a/jarvis/codex_app_server.py+++ b/jarvis/codex_app_server.py@@ -1042,6 +1042,12 @@ _CLI_VERSION_RE: Final = re.compile()+_HEADLESS_LOGIN_REASON: Final = (+ "Interactive subscription-voice login is unavailable on headless Linux. "+ "Run Jarvis on a desktop to connect this dedicated profile."+)++def _login_required_reason_code() -> CodexSubscriptionReasonCode:"""The honest "please log in" state for THIS host.@@ -1059,6 +1065,19 @@ def _login_required_reason_code() -> CodexSubscriptionReasonCode:return "login_required"+def _login_required_state(reason: str) -> tuple[str, CodexSubscriptionReasonCode]:+ """Reason text and code for a missing login, coherent on every surface.++ When the code degrades to ``lifecycle_unavailable`` (headless host), the+ text degrades WITH it: otherwise the 409/400 details and the Test verdict+ would keep asking for the exact login the card refuses to offer.+ """+ code = _login_required_reason_code()+ if code == "lifecycle_unavailable":+ reason = _HEADLESS_LOGIN_REASON+ return reason, code++def _displayable_cli_version(raw: str | None) -> str | None:"""Return the probe output only when it is an actual version string.@@ -1144,13 +1163,14 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:trusted_binary_path=resolved_binary,)except CodexSubscriptionProfileMissing as exc: # Missing login becomes an actionable snapshot.+ reason, reason_code = _login_required_state(str(exc))return CodexAppServerCapability(available=False,chatgpt_authenticated=False,binary_path=resolved_binary,version=version,- reason=str(exc),- reason_code=_login_required_reason_code(),+ reason=reason,+ reason_code=reason_code,)except CodexSubscriptionInspectionFailed as exc:# An OS read hiccup is transiently unknown, never a proven-broken@@ -1194,13 +1214,14 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:)except CodexSubscriptionProfileMissing as exc:# Missing login remains a normal not-ready state.+ reason, reason_code = _login_required_state(str(exc))return CodexAppServerCapability(available=False,chatgpt_authenticated=False,binary_path=resolved_binary,version=version,- reason=str(exc),- reason_code=_login_required_reason_code(),+ reason=reason,+ reason_code=reason_code,)except CodexSubscriptionInspectionFailed as exc:# Transiently unreadable, not proven-broken (see the first block).@@ -1234,19 +1255,27 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:reason_code="busy",)chatgpt_login = logged_in and login_mode == "chatgpt"+ if chatgpt_login:+ return CodexAppServerCapability(+ available=True,+ # Advisory only: the CLI emits a fixed PII-free mode string. The+ # live account/read RPC below proves ChatGPT mode and the plan.+ chatgpt_authenticated=True,+ binary_path=resolved_binary,+ version=version,+ reason="Dedicated ChatGPT login is available.",+ reason_code="ready",+ )+ reason, reason_code = _login_required_state(+ "Use Jarvis's subscription-voice login to connect ChatGPT."+ )return CodexAppServerCapability(available=True,- # Advisory only: the CLI emits a fixed PII-free mode string. The live- # account/read RPC below proves ChatGPT mode and the plan.- chatgpt_authenticated=chatgpt_login,+ chatgpt_authenticated=False,binary_path=resolved_binary,version=version,- reason=(- "Dedicated ChatGPT login is available."- if chatgpt_login- else "Use Jarvis's subscription-voice login to connect ChatGPT."- ),- reason_code="ready" if chatgpt_login else _login_required_reason_code(),+ reason=reason,+ reason_code=reason_code,)@@ -1849,7 +1878,17 @@ class CodexAppServerClient:_subscription_state_changed.notify_all()await asyncio.shield(asyncio.to_thread(_announce_ready))- except BaseException:+ except BaseException as exc:+ if isinstance(exc, CodexSubscriptionPlanUnsupported):+ # The COLD activation path discovers the refused plan+ # here, inside startup — record the sticky diagnosis where+ # the truth appears, or every surface keeps claiming ready+ # after the one honest toast fades.+ await asyncio.shield(+ asyncio.to_thread(+ set_codex_subscription_activation_block, str(exc)+ )+ )await self._close_process(CodexAppServerDisconnected("Codex app-server initialization failed."),expected=False,@@ -3018,6 +3057,17 @@ class CodexAppServerClient:stderr_task = self._stderr_taskself._reader_task = Noneself._stderr_task = None+ # Captured SYNCHRONOUSLY with self._process = None: the reaping below+ # awaits for seconds without _start_lock, and a parallel ensure_started+ # may re-reserve (new epoch) and re-spawn (new lifeline FD) meanwhile.+ # Reading these fields late in the finally would tear down the NEW+ # life's state — closing the fresh child's lifeline kills its process+ # group on POSIX, and releasing the fresh epoch strips a live call's+ # profile reservation.+ lifeline_fd = self._lifeline_write_fd+ self._lifeline_write_fd = None+ release_epoch = self._profile_transport_epoch+ self._profile_transport_epoch = Nonefor _method, future in tuple(self._pending.values()):if not future.done():@@ -3070,17 +3120,18 @@ class CodexAppServerClient:finally:# Sync resource cleanup first (safe under any cancellation), the# awaited release last: its shield keeps the queued job alive even- # if this await is interrupted again.+ # if this await is interrupted again. ONLY the entry-time local+ # copies are used here — never re-read from self (see above).if tree is not None:tree.close()- self._close_lifeline()- if self._profile_transport_epoch is not None:- # Epoch first, release off-loop and shielded (see the- # early-return branch above for why both matter).- epoch = self._profile_transport_epoch- self._profile_transport_epoch = None+ if lifeline_fd is not None:+ with suppress(OSError):+ os.close(lifeline_fd)+ if release_epoch is not None:await asyncio.shield(- asyncio.to_thread(_release_subscription_transport, self, epoch)+ asyncio.to_thread(+ _release_subscription_transport, self, release_epoch+ ))if not expected:log.warning("Codex app-server connection reset")@@ -3178,9 +3229,11 @@ def _cached_subscription_snapshot_locked(``allow_stale`` serves the last known status while the profile is brieflyowned elsewhere, bounded by ``_SUBSCRIPTION_SNAPSHOT_STALE_MAX_S``.- In-process mutations invalidate the cache, so a stale entry cannot outlive- a login, logout, or disconnect performed by this process; an entry only- ages past the TTL while another process owns the profile.+ In-process mutations invalidate the cache when they BEGIN and again when+ they finish; a probe that was already mid-flight when a mutation started+ may still store its (pre-mutation) result during the mutation window, so+ a stale read can briefly reflect the pre-mutation truth until the+ mutation's closing invalidation lands."""if _subscription_snapshot_cache is None:return None@@ -3228,9 +3281,11 @@ def _invalidate_subscription_snapshot_locked() -> None:_subscription_snapshot_cache_key = ""_subscription_snapshot_cache_at = 0.0_subscription_snapshot_cache_is_failure = False- # A login/logout may change the account, so the sticky "this plan can- # never activate" diagnosis must be re-earned by the next activation.- _subscription_activation_block = None+ # The sticky activation block is deliberately NOT cleared here: cache+ # invalidation happens on every mutation attempt, including an ABORTED+ # re-login, and a closed browser window is no evidence the refused plan+ # changed. The block clears only on explicit new evidence — a VERIFIED+ # fresh login, a logout, or a passed activation.# Sticky reason the connected login cannot activate (for example a@@ -3240,12 +3295,17 @@ def _invalidate_subscription_snapshot_locked() -> None:_subscription_activation_block: str | None = None-def set_codex_subscription_activation_block(message: str | None) -> None:- """Record (or clear with ``None``) why activation is impossible."""+def _set_subscription_activation_block_locked(message: str | None) -> None:+ """Caller holds ``_subscription_login_lock``."""global _subscription_activation_block+ _subscription_activation_block = (message or "").strip() or None+++def set_codex_subscription_activation_block(message: str | None) -> None:+ """Record (or clear with ``None``) why activation is impossible."""with _subscription_login_lock:- _subscription_activation_block = (message or "").strip() or None+ _set_subscription_activation_block_locked(message)def codex_subscription_activation_block() -> str | None:@@ -3683,15 +3743,17 @@ def start_codex_subscription_login(global _subscription_login_in_flight, _subscription_login_processglobal _subscription_profile_mutating+ login_verified = Falsetry:process.wait()try:post_login = _read_codex_capability(capability.binary_path)- if not (+ login_verified = bool(post_login.availableand post_login.chatgpt_authenticatedand post_login.reason_code == "ready"- ):+ )+ if not login_verified:log.warning("Dedicated subscription login did not produce a verified ""ChatGPT login (%s)",@@ -3721,6 +3783,11 @@ def start_codex_subscription_login(_subscription_profile_mutating = False_release_subscription_mutation_process_lock_locked()_invalidate_subscription_snapshot_locked()+ if login_verified:+ # A VERIFIED fresh login is new evidence — the next+ # activation re-judges the plan. An aborted login+ # window keeps the recorded verdict.+ _set_subscription_activation_block_locked(None)_subscription_state_changed.notify_all()try:@@ -3812,6 +3879,8 @@ def logout_codex_subscription(_release_subscription_mutation_process_lock_locked()_subscription_profile_mutating = False_invalidate_subscription_snapshot_locked()+ # The judged login is gone; the plan verdict goes with it.+ _set_subscription_activation_block_locked(None)_subscription_state_changed.notify_all()@@ -3863,6 +3932,8 @@ def _finish_subscription_disconnect_mutation() -> None:_release_subscription_mutation_process_lock_locked()_subscription_profile_mutating = False_invalidate_subscription_snapshot_locked()+ # The judged login is gone; the plan verdict goes with it.+ _set_subscription_activation_block_locked(None)_subscription_state_changed.notify_all()@@ -3929,6 +4000,10 @@ async def codex_subscription_login_ready(binary_path: str | None = None) -> boolturns a healthy install into "connect this provider first" for the busywindow."""+ if await asyncio.to_thread(codex_subscription_activation_block):+ # The live account gate refused this login permanently; readiness+ # surfaces must stop advertising a provider that can never start.+ return Falsetry:snapshot = await asyncio.to_thread(codex_subscription_auth_snapshot,@@ -3967,8 +4042,13 @@ async def close_shared_codex_app_servers() -> None:epoch = client._profile_transport_epochclient._profile_transport_epoch = Noneif epoch is not None:- await asyncio.to_thread(- _release_subscription_transport, client, epoch+ # Shielded like every other epoch release: a cancellation+ # after the attribute was nulled must not strand the+ # reservation.+ await asyncio.shield(+ asyncio.to_thread(+ _release_subscription_transport, client, epoch+ ))else:raise CodexSubscriptionUnavailable(diff --git a/jarvis/plugins/realtime/codex_subscription.py b/jarvis/plugins/realtime/codex_subscription.pyindex 2360e95ca6..20adff8e40 100644--- a/jarvis/plugins/realtime/codex_subscription.py+++ b/jarvis/plugins/realtime/codex_subscription.py@@ -713,29 +713,32 @@ class CodexSubscriptionRealtimeProvider:credential_family = "openai-chatgpt-subscription"supports_realtime = Trueimplicit_usage_fallback_allowed = False+ requires_webrtc_offer = True+ input_sample_rate = _INPUT_RATE+ output_sample_rate = _OUTPUT_RATE+ credential_candidates: tuple[tuple[str, str | None], ...] = ()@classmethodasync def verify_activation(cls, cfg: Any) -> None:"""Run the provider's authoritative account/config activation gate.- The gate starts app-server just to judge the account, so it must also- clean up after itself: leaving the transport reservation and an idle- Codex child running would make the card's reconnect button answer- "disconnect active subscription voice" after every activation. A call- that starts later simply re-runs ``ensure_started``.+ When the gate itself started app-server just to judge the account, it+ also cleans up: leaving the transport reservation and an idle Codex+ child running would make the card's reconnect button answer+ "disconnect active subscription voice" after every activation. A+ client that was ALREADY ready is carrying a live call — verifying is+ harmless, closing it would cut the call mid-sentence."""app_server_module = importlib.import_module("jarvis.codex_app_server")codex_cfg = getattr(cfg, "codex", None)binary_path = str(getattr(codex_cfg, "binary_path", "") or "").strip() or Noneclient = app_server_module.get_shared_codex_app_server(binary_path)+ was_ready = bool(getattr(client, "ready", False))try:await client.require_chatgpt_login()finally:- await client.close()- requires_webrtc_offer = True- input_sample_rate = _INPUT_RATE- output_sample_rate = _OUTPUT_RATE- credential_candidates: tuple[tuple[str, str | None], ...] = ()+ if not was_ready:+ await client.close()def __init__(self,@@ -765,6 +768,11 @@ class CodexSubscriptionRealtimeProvider:binary_path = str(getattr(getattr(cfg, "codex", None), "binary_path", "") or "").strip()+ if app_server_module.codex_subscription_activation_block():+ # The live account gate refused this login permanently;+ # advertising the provider as available would build sessions+ # that can never start (and mislead GET /voice-mode).+ return Falsestatus = app_server_module.codex_subscription_auth_snapshot(binary_path or None)diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsxindex 7ab8ae0a7a..42c1150aff 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx@@ -620,6 +620,40 @@ describe("ProviderCard: ChatGPT subscription Realtime", () => {);});+ it("lets a plan-blocked card retry activation through the backend", async () => {+ const calls = installFetchMock();+ // The experimental-provider acknowledgement dialog (jsdom cannot show it).+ vi.spyOn(window, "confirm").mockReturnValue(true);+ renderCard(+ codexRealtimeCard({+ configured: false,+ codex_status: {+ installed: true,+ connected: false,+ mode: "not_connected",+ message:+ "Subscription voice permits only personal ChatGPT accounts; workspace, enterprise, education, and unknown plans are refused.",+ reason_code: "plan_unsupported",+ },+ }),+ );++ // The backend's live account gate is the ONLY judge that can clear the+ // sticky block — the click must reach it instead of dead-ending in a+ // local toast.+ fireEvent.click(screen.getByText("ChatGPT subscription (Codex)"));++ await waitFor(() =>+ expect(+ calls.some(+ (candidate) =>+ candidate.method === "POST" &&+ candidate.url.includes("/realtime/switch"),+ ),+ ).toBe(true),+ );+ });+it("shows the pinned install path for a wrong codex release", () => {installFetchMock();renderCard(diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsxindex 2beff53036..ce89cb80b0 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx@@ -767,7 +767,15 @@ export function ProviderCard({pushToast("warning", t("apikeys_codex.brain_needs_openai_key"));return;}- if (!assumeConfigured && !descriptor.configured) {+ if (+ !assumeConfigured &&+ !descriptor.configured &&+ // plan_unsupported deliberately proceeds to the backend switch: its+ // live account gate is the ONLY judge that can clear the sticky block+ // when the plan changed back; a re-refusal answers with the precise+ // 409 detail as an error toast.+ descriptor.codex_status?.reason_code !== "plan_unsupported"+ ) {const codexReason = descriptor.codex_status?.reason_code;// Transient/in-flight states are notes, not faults — and telling the// user to redo a working ChatGPT login would contradict the card's own@@ -1625,7 +1633,7 @@ export function AuthWidget({// Exhaustive by construction: adding a value to CodexStatus["reason_code"]// without a card mapping fails the TypeScript build here instead of silently// falling through to a wrong status line (the BUG-008 multi-layer enum class).-const CODEX_STATUS_KEY_BY_REASON: Record<+export const CODEX_STATUS_KEY_BY_REASON: Record<NonNullable<NonNullable<ProviderDescriptor["codex_status"]>["reason_code"]>,string> = {@@ -1799,7 +1807,8 @@ function CodexAuthWidget({{subscriptionOnly &&(status?.reason_code === "setup_invalid" ||status?.reason_code === "not_installed" ||- status?.reason_code === "plan_unsupported") &&+ status?.reason_code === "plan_unsupported" ||+ status?.reason_code === "lifecycle_unavailable") &&status.message && (<divdata-testid="codex-setup-detail"@@ -2033,6 +2042,9 @@ export function StatusBadge({ descriptor }: { descriptor: ProviderDescriptor })// Nothing is "missing" on an OS the feature does not support at all.if (status?.reason_code === "lifecycle_unavailable")return <StateChip tone="neutral">unavailable</StateChip>;+ // Terminal until the account changes — "not connected" would undersell it.+ if (status?.reason_code === "plan_unsupported")+ return <StateChip tone="missing">blocked</StateChip>;if (!status?.installed) return <StateChip tone="missing">missing</StateChip>;if (descriptor.configured) return <StateChip tone="ready">ready</StateChip>;return <StateChip tone="neutral">not connected</StateChip>;diff --git a/jarvis/ui/web/frontend/src/i18n/voice-i18n-parity.test.ts b/jarvis/ui/web/frontend/src/i18n/voice-i18n-parity.test.tsindex adedac404c..ec209838bc 100644--- a/jarvis/ui/web/frontend/src/i18n/voice-i18n-parity.test.ts+++ b/jarvis/ui/web/frontend/src/i18n/voice-i18n-parity.test.ts@@ -9,6 +9,7 @@* values.*/import { describe, expect, it } from "vitest";+import { CODEX_STATUS_KEY_BY_REASON } from "@/components/providers/ProviderTierSection";import en from "./locales/en.json";import de from "./locales/de.json";import es from "./locales/es.json";@@ -127,14 +128,9 @@ describe("subscription Realtime voice copy", () => {"settings_view.realtime_voice.title","settings_view.realtime_voice.description","settings_view.realtime_voice.unavailable",- "apikeys_codex.status_ready",- "apikeys_codex.status_login_required",- "apikeys_codex.status_not_installed",- "apikeys_codex.status_lifecycle_unavailable",- "apikeys_codex.status_setup_invalid",- "apikeys_codex.status_busy",- "apikeys_codex.status_login_in_progress",- "apikeys_codex.status_plan_unsupported",+ // Derived from the card's exhaustive reason-code mapping so a ninth code+ // cannot ship with an i18n key no locale knows.+ ...Object.values(CODEX_STATUS_KEY_BY_REASON),"apikeys_codex.setup_detail_label","apikeys_codex.install_command_copied","apikeys_codex.connected_chatgpt",diff --git a/tests/unit/codex_app_server/test_transport.py b/tests/unit/codex_app_server/test_transport.pyindex 5ab0223b7c..2a1e34e9c4 100644--- a/tests/unit/codex_app_server/test_transport.py+++ b/tests/unit/codex_app_server/test_transport.py@@ -2446,19 +2446,118 @@ def test_unreadable_profile_reports_busy_not_setup_invalid(assert "could not be inspected" in capability.reason-def test_activation_block_sticks_until_invalidated() -> None:+def test_activation_block_survives_cache_invalidation_until_logout(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Cache invalidation happens on every mutation attempt — including an+ ABORTED re-login — which is no evidence the refused plan changed. Only+ explicit new evidence (here: logout) clears the verdict."""transport.set_codex_subscription_activation_block("Subscription voice permits only personal ChatGPT accounts.")+ with transport._subscription_login_lock:+ transport._invalidate_subscription_snapshot_locked()assert (transport.codex_subscription_activation_block()== "Subscription voice permits only personal ChatGPT accounts.")- with transport._subscription_login_lock:- transport._invalidate_subscription_snapshot_locked()++ monkeypatch.setattr(+ transport,+ "_delete_codex_subscription_auth_locked",+ lambda: (True, None),+ )+ assert transport.logout_codex_subscription() == (True, None)assert transport.codex_subscription_activation_block() is None+async def test_cold_start_plan_refusal_is_recorded(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """The FIRST activation (app-server not yet running) discovers the plan+ refusal inside ensure_started — the sticky diagnosis must be recorded on+ that cold path too, not only on the warm re-verification."""+ client = CodexAppServerClient("codex-test")+ monkeypatch.setattr(+ transport,+ "_read_codex_capability",+ lambda _binary: _ready_capability(binary_path="codex-test"),+ )++ def refuse(**_kwargs: object) -> Path:+ raise transport.CodexSubscriptionPlanUnsupported(+ "Subscription voice permits only personal ChatGPT accounts."+ )++ monkeypatch.setattr(transport, "_validated_subscription_home", refuse)++ with pytest.raises(transport.CodexSubscriptionPlanUnsupported):+ await client.ensure_started()++ assert "personal ChatGPT accounts" in (+ transport.codex_subscription_activation_block() or ""+ )+++async def test_login_ready_respects_the_activation_block(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Readiness surfaces must not advertise a provider whose account the+ live gate refused permanently."""+ monkeypatch.setattr(+ transport,+ "_read_codex_capability",+ lambda _binary: _ready_capability(),+ )+ assert await transport.codex_subscription_login_ready("codex-test") is True++ transport.set_codex_subscription_activation_block(+ "Subscription voice permits only personal ChatGPT accounts."+ )+ assert await transport.codex_subscription_login_ready("codex-test") is False+++def test_headless_linux_reports_lifecycle_with_a_coherent_reason(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """The reason TEXT degrades with the code: every surface renders one of+ the two, and they must tell the same story."""+ import jarvis.codex_auth as auth_module++ class FakeAuthService:+ def __init__(self, *_args: object, **_kwargs: object) -> None:+ pass++ def _resolve_binary(self) -> str:+ return "codex-test"++ def _probe_version(self, _binary: str) -> str:+ return "codex-cli 0.146.0"++ monkeypatch.setattr(auth_module, "CodexAuthService", FakeAuthService)+ monkeypatch.setattr(+ transport,+ "_trusted_native_codex_binary",+ lambda binary, _version: binary,+ )++ def missing_profile(**_kwargs: object) -> Path:+ raise transport.CodexSubscriptionProfileMissing("profile missing")++ monkeypatch.setattr(transport, "_validated_subscription_home", missing_profile)+ monkeypatch.setattr(transport.sys, "platform", "linux")+ monkeypatch.delenv("DISPLAY", raising=False)+ monkeypatch.delenv("WAYLAND_DISPLAY", raising=False)++ capability = transport._read_codex_capability(None)++ assert capability.reason_code == "lifecycle_unavailable"+ assert "headless Linux" in capability.reason+ assert "desktop" in capability.reason++def test_profile_allowlist_accepts_codex_own_runtime_markers() -> None:"""Codex 0.146 writes these into CODEX_HOME on a normal run; rejectingthem bricked the profile right after the CLI's first use."""diff --git a/tests/unit/realtime/test_codex_subscription.py b/tests/unit/realtime/test_codex_subscription.pyindex 988ca2273f..5c0eafc571 100644--- a/tests/unit/realtime/test_codex_subscription.py+++ b/tests/unit/realtime/test_codex_subscription.py@@ -318,6 +318,26 @@ async def test_orchestrator_capability_check_does_not_repeat_cli_auth_probe(assert await provider.can_open_duplex_session() is True+def test_external_login_ready_respects_the_activation_block(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """A permanently refused account must not be advertised as available."""+ from jarvis import codex_app_server++ monkeypatch.setattr(+ codex_app_server,+ "codex_subscription_activation_block",+ lambda: "Subscription voice permits only personal ChatGPT accounts.",+ )+ monkeypatch.setattr(+ codex_app_server,+ "codex_subscription_auth_snapshot",+ lambda _binary: pytest.fail("a blocked account needs no CLI probe"),+ )++ assert CodexSubscriptionRealtimeProvider.external_login_ready(None) is False++@pytest.mark.asyncioasync def test_verify_activation_cleans_up_its_own_transport(monkeypatch: pytest.MonkeyPatch,@@ -347,6 +367,36 @@ async def test_verify_activation_cleans_up_its_own_transport(assert events == ["verified", "closed"]+async def test_verify_activation_never_closes_a_client_carrying_a_call(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """A client that was ALREADY ready is carrying a live session — verifying+ is harmless, closing it would cut the call mid-sentence."""+ from jarvis import codex_app_server++ events: list[str] = []++ class _Client:+ ready = True++ async def require_chatgpt_login(self) -> None:+ events.append("verified")++ async def close(self) -> None:+ events.append("closed")++ monkeypatch.setattr(+ codex_app_server,+ "get_shared_codex_app_server",+ lambda _binary: _Client(),+ )++ await CodexSubscriptionRealtimeProvider.verify_activation(SimpleNamespace())++ assert events == ["verified"]++@pytest.mark.parametrize(("reason_code", "available", "authenticated", "expected"),[