The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui_gateway): vault.* RPCs bind the launch profile's secret scope once the process multiplexes
kshitijk4poorae7126353f9a
diff --git a/tests/tui_gateway/test_vault_methods.py b/tests/tui_gateway/test_vault_methods.pyindex dc8baebac4c..ccc745a3856 100644--- a/tests/tui_gateway/test_vault_methods.py+++ b/tests/tui_gateway/test_vault_methods.py@@ -151,3 +151,21 @@ def test_remove_is_idempotent(home):def test_remove_requires_id(home):err = _error(srv._methods["vault.remove"](1, {}))assert err["code"] == 5095+++def test_launch_profile_vault_rpcs_stay_scoped_once_the_process_multiplexes(home, monkeypatch):+ """Once a second profile has been served, ``get_secret`` fails closed for unscoped reads. The+ launch profile's vault.* calls (Desktop sends no ``profile`` for it) must still bind the launch+ secret scope — otherwise every enabled manager's token read raises UnscopedSecretError and the+ Passwords & Logins panel shows "Could not load vault items" until the gateway restarts."""+ from agent.secret_scope import is_multiplex_active, set_multiplex_active++ monkeypatch.setattr("agent.vault_backends.base.is_installed", lambda name: name == "onepassword")+ monkeypatch.setenv("OP_SERVICE_ACCOUNT_TOKEN", "ops_launch_profile_token")+ previous = is_multiplex_active()+ set_multiplex_active(True)+ try:+ rows = _sources_rows(home)+ finally:+ set_multiplex_active(previous)+ assert rows["onepassword"]["enabled"] is Truediff --git a/tui_gateway/methods_vault.py b/tui_gateway/methods_vault.pyindex 76fa7bd0d91..c5f97dbd1ae 100644--- a/tui_gateway/methods_vault.py+++ b/tui_gateway/methods_vault.py@@ -31,18 +31,11 @@ _registry = HandlerRegistry()def method(name: str):- """``@method(name)`` with ``params.profile`` bound (home + secret scope) around the handler."""+ """``@method(name)`` under server.py's ``@_profile_scoped`` — the one scoping path every RPC uses,+ so the launch profile (no ``params.profile``) gets its secret scope bound once the process+ multiplexes instead of its manager-token reads raising ``UnscopedSecretError``."""def deco(fn):- def scoped(rid, params: dict) -> dict:- try:- home = _profile_home(params.get("profile") if isinstance(params, dict) else None)- except FileNotFoundError as e:- return _err(rid, 5095, str(e))- if home is None:- return fn(rid, params)- with _session_profile_runtime_scope({"profile_home": str(home)}):- return fn(rid, params)- return _registry.method(name)(scoped)+ return _registry.method(name)(_registry.profile_scoped(fn))return deco# JSON-RPC error code 5095 = vault failure (validation + store errors).