diff --git a/DECISIONS.md b/DECISIONS.md index 8082c305..51f48cd8 100644 --- a/DECISIONS.md +++ b/DECISIONS.md @@ -20467,3 +20467,39 @@ at capacity instead of queueing (a small model handles "it starts when a slot frees" better than "try again"); starting a writer from the latest checkpoint instead of `HEAD` (it would need the checkpoint code reviewed; the spawn note says uncommitted edits are not in the child's worktree). + +## 2026-11-24 — TD-5301: what no phone permission opens (Class B) + +**Decision:** four acts are refused from a paired phone (or the legacy +token) whatever it was granted, with `loopback_only` and no switch: +releasing the computer-use stop (TD-5297), `shutdown`, sending a saved key +to a server it does not already go to, and pointing the mail server +elsewhere without typing the password. The two read off the message stay +in `phone_verbs.never_from_a_phone`. The two that depend on what is saved +live in `core/tstd/phone_never.py`, which `Hub.intercept` asks before the +permission check, through a callable the daemon passes with its live +config, so `peer_policy.check` stays a pure table. + +"Another server" reuses TD-5182's rule (`key_hosts.key_refusal`): a key's +own host, or, for a key saved without one, the URLs of the models it is +bound to, with a server on this computer allowed. `set_credential` is +refused when it changes or clears an existing key's host so the key would +reach a new origin; `set_tier_credential` when it binds a host-less key to +a model elsewhere. A new key (no id yet) and `set_api_key` (the phone types +the key) are not a move. For mail, any SMTP host other than the saved one, +compared case-blind, needs `password` in the same message. + +**Found at runtime before the change** (a live test daemon, a paired phone): +`set_email_notify` with a new host and no password was accepted with no +grant; `set_credential` moved the saved OpenRouter key's host once +`models_and_keys` was on; `shutdown` stopped the daemon. `add_model` reusing +a saved key at another URL was already refused for every client (TD-5182). + +**Rationale:** each sends something the person saved at the computer (a +key, a password) somewhere they never chose, or leaves the computer out of +reach; none is undone by revoking the phone. Asking before the grant check +gives the same answer with or without a grant. + +**Rejected:** a sixth capability for these (the owner chose "never"); and +refusing every `set_credential` with a `base_url`, which would also block +saving a new key with its own host. diff --git a/core/tests/test_phone_never.py b/core/tests/test_phone_never.py new file mode 100644 index 00000000..7307d7dd --- /dev/null +++ b/core/tests/test_phone_never.py @@ -0,0 +1,204 @@ +"""What no phone permission opens (owner decision #5, TD-5301). + +Checked against a running daemon before the change: a paired phone could +point the mail server elsewhere with no grant and no password, so the +saved password went to the new server on the next send; with "Adding +models and keys" on it could move a saved key's host; and it could shut +the daemon down. Each is now refused from a phone with any grant, and +stays the computer's own. +""" + +from __future__ import annotations + +import asyncio +import json +from pathlib import Path +from typing import Any + +import pytest + +from tests.test_add_model import _stop +from tests.test_mcp_peer import _drain, _fresh, _pair +from tests.test_models_on_phone import _seeded +from tests.test_peer_policy import ( + LOOPBACK_PLAIN, + PHONE_PLAIN, + PHONE_VIEWER, + PLAIN_REMOTE, + _code, + _msg, +) +from tests.test_preset_engine import _config +from tstd.config import CredentialConfig, ModelConfig +from tstd.peer_policy import check +from tstd.phone_never import COMPUTER_ONLY, KEY_ELSEWHERE, MAIL_PASSWORD, never_refusal + +EVERY_GRANT = frozenset( + {"mcp_servers", "approval_switches", "models_and_keys", "computer_use", "unattended_runs"} +) +GRANT_KEYS = {"type": "set_phone_permission", "capability": "models_and_keys", "enabled": True} + + +def _with_mail(config: ModelConfig, host: str = "smtp.first.example") -> ModelConfig: + config.notify.email.host = host + config.notify.email.username = "me" + return config + + +class TestTheRules: + def test_shutdown_is_the_computers(self) -> None: + msg = _msg("shutdown") + for phone in (PHONE_VIEWER, PHONE_PLAIN, PLAIN_REMOTE): + assert _code(check(msg, phone, bridged=False, grants=EVERY_GRANT)) == "loopback_only" + assert check(msg, LOOPBACK_PLAIN, bridged=False) is None + + def test_releasing_the_stop_stays_refused(self, tmp_path: Path) -> None: + config = _config(tmp_path) + assert never_refusal(_msg("set_cu_kill", killed=False), config) == COMPUTER_ONLY + assert never_refusal(_msg("set_cu_kill", killed=True), config) is None + + @pytest.mark.parametrize( + ("fields", "refused"), + [ + ({"host": "smtp.elsewhere.example"}, True), + ({"host": "SMTP.First.Example "}, False), + ({"host": "smtp.first.example", "port": 465, "security": "tls"}, False), + ({"host": "smtp.elsewhere.example", "password": "typed"}, False), + ({"host": "smtp.elsewhere.example", "method": "microsoft"}, False), + ({"host": "", "username": "someone-else"}, True), + ], + ) + def test_a_new_mail_server_needs_the_password( + self, tmp_path: Path, fields: dict[str, Any], refused: bool + ) -> None: + config = _with_mail(_config(tmp_path)) + msg = _msg("set_email_notify", **{"enabled": True, "username": "me", **fields}) + assert never_refusal(msg, config) == (MAIL_PASSWORD if refused else None) + + @pytest.mark.parametrize( + ("base_url", "refused"), + [ + ("https://elsewhere.example/v1", True), + ("", True), # cleared: the key would go to each bound model's own URL + ("https://openrouter.ai/api/v1/", False), + ("https://OPENROUTER.ai/other/path", False), + (None, False), # a rename + ], + ) + def test_a_saved_keys_host(self, tmp_path: Path, base_url: str | None, refused: bool) -> None: + config = _config(tmp_path) + # A model bound to the key whose own URL is another server. + config.presets["budget"].brain.base_url = "https://models.example.com/v1" + fields: dict[str, Any] = {"name": "OpenRouter", "credential": "openrouter"} + if base_url is not None: + fields["base_url"] = base_url + assert never_refusal(_msg("set_credential", **fields), config) == ( + KEY_ELSEWHERE if refused else None + ) + + def test_a_new_key_has_nothing_to_move(self, tmp_path: Path) -> None: + config = _config(tmp_path) + msg = _msg("set_credential", name="Fresh", base_url="https://elsewhere.example/v1") + assert never_refusal(msg, config) is None + + def test_binding_a_key_without_a_host(self, tmp_path: Path) -> None: + config = _config(tmp_path) + config.credentials["lab"] = CredentialConfig(name="Lab") + config.presets["local"].brain.credential = "lab" + config.presets["budget"].brain.credential = None + + def bind(preset: str) -> str | None: + msg = _msg("set_tier_credential", preset=preset, tier="brain", credential="lab") + return never_refusal(msg, config) + + assert bind("local") is None # where it already goes + assert bind("vllm") is None # another server on this computer + assert bind("budget") == KEY_ELSEWHERE # a hosted server it never went to + unbind = _msg("set_tier_credential", preset="budget", tier="brain", credential="") + assert never_refusal(unbind, config) is None + + def test_a_key_with_a_host_goes_there_whatever_it_is_bound_to(self, tmp_path: Path) -> None: + config = _config(tmp_path) + msg = _msg("set_tier_credential", preset="local", tier="brain", credential="openrouter") + assert never_refusal(msg, config) is None + + +async def _ask_phone(phone: Any, msg: dict[str, Any]) -> dict[str, Any]: + await _drain(phone) + await phone.send(json.dumps(msg)) + return dict(json.loads(await asyncio.wait_for(phone.recv(), 5))) + + +class TestOverTheWire: + async def test_the_mail_server_and_a_keys_host_stay_put(self, tmp_path: Path) -> None: + daemon, task, ws = await _seeded(tmp_path) + phone, _ = await _pair(daemon) + first = {"type": "set_email_notify", "enabled": True, "host": "smtp.first.example"} + moved = {**first, "host": "smtp.elsewhere.example"} + key = {"type": "set_credential", "name": "OpenRouter", "credential": "openrouter"} + try: + await _fresh(ws, {**first, "username": "me"}) + reply = await _ask_phone(phone, {**moved, "username": "me"}) + assert (reply["type"], reply["code"]) == ("error", "loopback_only"), reply + assert reply["message"] == MAIL_PASSWORD + assert daemon.config.notify.email.host == "smtp.first.example" + + await _fresh(ws, GRANT_KEYS) + reply = await _ask_phone(phone, {**key, "base_url": "https://elsewhere.example/v1"}) + assert (reply["type"], reply["message"]) == ("error", KEY_ELSEWHERE), reply + assert ( + daemon.config.credentials["openrouter"].base_url == "https://openrouter.ai/api/v1" + ) + # A rename with the grant still works. + done = await _fresh(phone, {**key, "name": "Router"}) + assert done["type"] == "setup_state", done + assert daemon.config.credentials["openrouter"].name == "Router" + # The computer itself does both. + await _fresh(ws, {**key, "base_url": "https://elsewhere.example/v1"}) + assert ( + daemon.config.credentials["openrouter"].base_url == "https://elsewhere.example/v1" + ) + await _fresh(ws, {**moved, "username": "me"}) + assert daemon.config.notify.email.host == "smtp.elsewhere.example" + finally: + await phone.close() + await _stop(task, ws) + + async def test_typing_the_password_moves_the_mail_server( + self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + stored: list[str] = [] + + async def store(password: str) -> None: + stored.append(password) + + monkeypatch.setattr("tstd.keychain.store_smtp_password", store) + daemon, task, ws = await _seeded(tmp_path) + phone, _ = await _pair(daemon) + try: + change = { + "type": "set_email_notify", + "enabled": True, + "host": "smtp.elsewhere.example", + "username": "me", + "password": "typed-on-the-phone", + } + done = await _fresh(phone, change) + assert done["type"] == "setup_state", done + assert daemon.config.notify.email.host == "smtp.elsewhere.example" + assert stored == ["typed-on-the-phone"] + finally: + await phone.close() + await _stop(task, ws) + + async def test_a_phone_cannot_shut_the_daemon_down(self, tmp_path: Path) -> None: + daemon, task, ws = await _seeded(tmp_path) + phone, _ = await _pair(daemon) + try: + reply = await _ask_phone(phone, {"type": "shutdown"}) + assert (reply["type"], reply["code"]) == ("error", "loopback_only"), reply + await asyncio.sleep(0.2) + assert not task.done() + finally: + await phone.close() + await _stop(task, ws) diff --git a/core/tstd/daemon.py b/core/tstd/daemon.py index f6928b30..7117724f 100644 --- a/core/tstd/daemon.py +++ b/core/tstd/daemon.py @@ -213,6 +213,7 @@ from .notify.slack import send as send_slack_notify from .notify.telegram import schedule as schedule_telegram_notify from .peer_policy import outbound_event, service_hosts +from .phone_never import never_refusal from .phone_permissions import ( APPROVAL_SWITCHES, COMPUTER_USE, @@ -1330,6 +1331,7 @@ def __init__( self._handle_list_sessions, policy=dial_policy, phone_grants=self.phone_store.live, + phone_never=lambda msg: never_refusal(msg, self.config), ) self._cu_server: Any = None # TD-4835: keychain presence cache — see _credential_is_stored. diff --git a/core/tstd/hub.py b/core/tstd/hub.py index 43f93247..14a30025 100644 --- a/core/tstd/hub.py +++ b/core/tstd/hub.py @@ -38,6 +38,7 @@ ListMachines, ReconnectMachine, RemoveMachine, + build_error, scrub_wire_json, ) from .ws import WebSocketServer @@ -89,11 +90,15 @@ def __init__( policy: DialPolicy | None = None, timings: Timings = DEFAULT_TIMINGS, phone_grants: Callable[[], Collection[str]] | None = None, + phone_never: Callable[[ClientMessage], str | None] | None = None, ) -> None: self._ws = ws_server # TD-5279: the phone permissions switched on right now. Without a # source there are none, so every opt-in verb is refused. self._phone_grants = phone_grants + # TD-5301: what no grant opens to a phone, read against the live + # config. Asked first, so the answer does not depend on a grant. + self._phone_never = phone_never self._own_session_list = own_session_list self.registry = MachineRegistry(data_dir) self.registry.load() @@ -131,6 +136,10 @@ async def intercept(self, msg: ClientMessage, connection: Any) -> object: peer = self._ws.peer_view(connection) sid = message_session_id(msg) bridged = sid is not None and is_bridged(sid) + if peer.remote and not peer.machine and self._phone_never is not None: + never = self._phone_never(msg) + if never is not None: + return build_error("loopback_only", never, session_id=sid, in_reply_to=msg.type) grants = self._phone_grants() if self._phone_grants is not None else () refusal = check(msg, peer, bridged=bridged, grants=grants) if refusal is not None: diff --git a/core/tstd/phone_never.py b/core/tstd/phone_never.py new file mode 100644 index 00000000..826c4ebf --- /dev/null +++ b/core/tstd/phone_never.py @@ -0,0 +1,84 @@ +"""What no phone permission opens (owner decision #5, TD-5301). + +A paired phone acts as the person, but some acts are the computer's +whatever a phone was granted. They are hard refusals with no switch: + +- releasing the computer-use stop (TD-5297) and ``shutdown``: both + pure, read off the message (``phone_verbs.never_from_a_phone``); +- sending a saved key to a server it does not already go to; +- changing the mail server without typing the mail password again, which + would send the saved password to the new server. + +The last two depend on what is saved, so they are read against the live +config here, before the permission check: a phone that has the grant +gets the same answer as one that does not. ``add_model`` and the model +list already keep a saved key on its own server for every client +(TD-5182); this covers the two verbs that change where a key goes. +""" + +from __future__ import annotations + +from .config import ModelConfig, credential_base_url +from .key_hosts import key_hosts, key_refusal, origin +from .phone_verbs import never_from_a_phone +from .protocol import ClientMessage, SetCredential, SetEmailNotify, SetTierCredential + +COMPUTER_ONLY = "Only the computer itself can do that." +KEY_ELSEWHERE = ( + "A phone cannot send a saved key to another server. Type the key for that " + "server instead, or make this change at the computer." +) +MAIL_PASSWORD = ( + "To change the mail server from a phone, type the mail password again. " + "The saved one is not sent to a new server." +) + + +def never_refusal(msg: ClientMessage, config: ModelConfig) -> str | None: + """Why a phone may never send *msg*, or None. The same with any grant.""" + if never_from_a_phone(msg): + return COMPUTER_ONLY + if isinstance(msg, SetCredential): + return KEY_ELSEWHERE if _moves_key(msg, config) else None + if isinstance(msg, SetTierCredential): + return KEY_ELSEWHERE if _binds_elsewhere(msg, config) else None + if isinstance(msg, SetEmailNotify): + return MAIL_PASSWORD if _new_mail_host(msg, config) else None + return None + + +def _moves_key(msg: SetCredential, config: ModelConfig) -> bool: + """A saved key's own host changed or cleared. A new key has no secret yet.""" + if msg.base_url is None or not msg.credential or msg.credential not in config.credentials: + return False + hosts = {origin(url) for url in key_hosts(config, msg.credential)} + after = msg.base_url.strip() + if not after: + # Cleared: the key goes to the URL of each model it is bound to. + cleared = config.model_copy(deep=True) + cleared.credentials[msg.credential].base_url = None + return any(origin(url) not in hosts for url in key_hosts(cleared, msg.credential)) + return origin(after) not in hosts + + +def _binds_elsewhere(msg: SetTierCredential, config: ModelConfig) -> bool: + """A key saved without a host, bound to a model on a server it is not sent to. + + A key saved with a host goes there whatever it is bound to. + """ + credential = msg.credential.strip() + if not credential or credential_base_url(config, credential) is not None: + return False + preset = config.presets.get(msg.preset) + tiers = preset.tier_map() if preset is not None else {} + tier = next((t for name, t in tiers.items() if name == msg.tier), None) + if tier is None: + return False # the handler refuses an unknown model itself + return key_refusal(config, credential, tier.base_url) is not None + + +def _new_mail_host(msg: SetEmailNotify, config: ModelConfig) -> bool: + """SMTP to a different server with the saved password, not a typed one.""" + if msg.method != "smtp" or msg.password: + return False + return msg.host.strip().lower() != config.notify.email.host.strip().lower() diff --git a/core/tstd/phone_verbs.py b/core/tstd/phone_verbs.py index 35f4bb91..f4726c97 100644 --- a/core/tstd/phone_verbs.py +++ b/core/tstd/phone_verbs.py @@ -76,10 +76,11 @@ # This list is what a phone could already send the day it was written; it # changed nothing by itself. Entries move to ``PHONE_OPT_IN`` one capability # at a time: the model and key verbs (TD-5296), computer-use control -# (TD-5297) and starting an unattended run (TD-5298) have; releasing the -# computer-use stop is refused outright (``never_from_a_phone``). Still -# here and waiting: the connector sign-ins, ``shutdown``, changing a saved -# key's host and changing the mail server. Some are refused or narrowed +# (TD-5297) and starting an unattended run (TD-5298) have. Some acts are +# refused outright whatever a phone was granted (TD-5301, ``phone_never``): +# releasing the computer-use stop, ``shutdown``, sending a saved key to +# another server and changing the mail server without the password. Still +# here and waiting: the connector sign-ins. Some are refused or narrowed # for a remote peer by their own handler (``start_pairing``, # ``remove_remote_device``); being here only means the policy passes them on. PHONE_OPEN: frozenset[str] = frozenset( @@ -236,12 +237,17 @@ def _only_tightens(msg: ClientMessage) -> bool: def never_from_a_phone(msg: ClientMessage) -> bool: - """What no grant opens to a phone (owner decision, 2026-11). + """What no grant opens to a phone, read off the message alone. Releasing the computer-use stop: whoever engaged it may have had a reason, and a phone that released it could set the pointer moving - again with nobody at the computer. Engaging it stays open. + again with nobody at the computer. Engaging it stays open. Shutting the + daemon down (TD-5301): nothing on a phone can start it again, so the + computer would be out of reach until someone sat down at it. The + rules that depend on what is saved are in ``phone_never``. """ + if msg.type == "shutdown": + return True return msg.type == "set_cu_kill" and getattr(msg, "killed", True) is False diff --git a/docs/architecture.md b/docs/architecture.md index ed7e7e1a..eb6f92dc 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -501,6 +501,17 @@ never to a machine peer; it may carry an expiry; and it lives in `{user_data_dir}/phone-permissions.yaml`, which no config file sets. `Hub.intercept` passes the live grants to `peer_policy.check`, whose default is none. +Some acts no grant opens (owner decision #5, TD-5301). They are refused with `loopback_only` +from any phone or the legacy token, granted or not, and `Hub.intercept` asks before the +permission check so the answer is the same either way: releasing the computer-use stop; +`shutdown`; sending a saved key to a server it does not already go to (`set_credential` +changing or clearing an existing key's host, or `set_tier_credential` binding a key saved +without a host to a model on another server); and `set_email_notify` naming another SMTP +server without a typed password, since the saved one would go there. The first two are read +off the message (`phone_verbs.never_from_a_phone`); the rest are read against the live config +(`core/tstd/phone_never.py`). A phone can still save a new key with its own host, or move the +mail server by typing the password. + `MACHINE_PEER_VERBS` is the session verbs a hub needs (list, attach, detach, send, stop, the approval answers, verify, new and fork, branch, tier, plan, effort, Fast and Ultracode (`set_effort`, `set_fast`, `set_ultracode`), preset, rename, star, archive, @@ -595,7 +606,7 @@ Every message in `ClientMessageT`. "Session" says whether the message carries a | `set_coworker` | — | Turn coworker mode on or off. Machine-wide; persists `{user_data_dir}/coworker.yaml`. Acked with `setup_state` (TD-2905). | | `set_voice` | — | Turn hold-to-talk dictation on or off. Machine-wide; persists `{user_data_dir}/voice.yaml`. Default off. Acked with `setup_state` (TD-4701). | | `transcribe` | — | Hold-to-talk audio. POSTs a clip to `voice.base_url` or `speech.base_url`. Refused when dictation is off or no endpoint is configured. Acked with `transcript`. Not a tool (TD-4701). | -| `set_email_notify` | — | Save email settings for scheduled-job email (TD-3820, TD-4853, TD-4854). `method` is `smtp`, `microsoft`, or `google`. `password` is written to the keychain account `tst-smtp-password` and is not stored in config. `google_client_secret` is written to `tst-google-client-secret`. Empty or omitted leaves the stored secret alone. Acked with `setup_state`. | +| `set_email_notify` | — | Save email settings for scheduled-job email (TD-3820, TD-4853, TD-4854). `method` is `smtp`, `microsoft`, or `google`. `password` is written to the keychain account `tst-smtp-password` and is not stored in config. `google_client_secret` is written to `tst-google-client-secret`. Empty or omitted leaves the stored secret alone. Acked with `setup_state`. From a phone, an SMTP `host` other than the saved one needs `password` typed with it, or it is `loopback_only` (TD-5301). | | `test_email` | — | Send one short sample report to `to` using the saved method, SMTP, Microsoft Graph, or Gmail (TD-3820, TD-3821, TD-4853, TD-4854). The sample uses the same newsletter renderer as a scheduled report. Acked with `email_test_result`. | | `github_connect` | — | Start GitHub device-flow sign-in (TD-4852). Acked with `github_status`. The device code stays in the daemon; the reply carries the user code and verification URL only. | | `github_disconnect` | — | Delete the GitHub keychain item (TD-4852). Acked with `github_status`. | @@ -641,7 +652,7 @@ Every message in `ClientMessageT`. "Session" says whether the message carries a | `steering_edit` | yes | Write an agent-proposed steering edit with the user's own `content` (Edit, then Save). Same checks as `steering_accept`; empty content is refused (`steering_edit_empty`), and so is content the session log's secret scrub would change (`steering_secret_shaped`), since the logged diff must show what was written. Loopback only (TD-5140). | | `steering_reject` | yes | Reject an agent-proposed steering edit. Writes nothing; logged as a `steering_decision` (TD-5140). Not a machine-peer verb. | | `end_session` | yes | Run distill for this session (TD-2302). Not a kill. | -| `shutdown` | — | Ask the daemon to shut down cleanly. Sent by the supervising host. | +| `shutdown` | — | Ask the daemon to shut down cleanly. Sent by the supervising host. `loopback_only` from any phone, granted or not (TD-5301). | | `drain` | — | Before a restart: wait up to `timeout_s` for open turns, then refuse every verb that starts a turn (`user_message`, `send_queued`, `submit_line_comments`, `fork_from`, `run_grok_command`, `approve_grok_plan`, `start_autonomy`, `run_job`) with `daemon_draining` (and `in_reply_to`, the refused verb) for `hold_s` more. Due jobs wait too; approve, deny, stop and resume still pass. `0`/`0` releases, and a release, a later drain or shutdown ends a drain's wait early. Loopback only (`loopback_only` for a phone or a paired computer). Answered with `drain_result`. Sent by `tst drain` (TD-5023). | | `list_sessions` | — | Ask for the current session list. A viewer's list also carries every paired computer's cached rows, answered from the cache without dialing (TD-5015). | | `search_sessions` | — | Search what this computer's sessions said: `query` (up to 500 characters) and `limit` (1–200, default 50). Answered with `session_search_results` from the local full-text index, `session_index.db` in the data dir (TD-5129). Nothing leaves the computer. | @@ -678,9 +689,9 @@ Every message in `ClientMessageT`. "Session" says whether the message carries a | `set_tier_slug` | — | Set the model slug for one tier of one preset, then refresh that tier's prices and limits from its model card (TD-5185). | | `refresh_model_cards` | — | Settings' Refresh from servers: re-read each tier's (and backup's) model card from the server it calls, with the key it sends, and write the matched prices and limits to config.yaml (TD-5185). A served window (vLLM `max_model_len`, llama.cpp `meta.n_ctx`, LiteLLM `/model/info` `max_input_tokens`) is taken on loopback too (TD-5189). Acked with `setup_state`. | | `set_tier_context_window` | — | Settings' Context field: write one tier's `context_window` (more than twice its `max_output_tokens`, else `bad_request`) to config.yaml (TD-5189). Acked with `setup_state`. | -| `set_credential` | — | Create or rename a named API key without touching the secret (TD-1717). Optional `base_url` sets or clears the host that key talks to (TD-1722). From a paired phone this is the phone permission `models_and_keys` (`phone_permission_off` without it, TD-5296). | +| `set_credential` | — | Create or rename a named API key without touching the secret (TD-1717). Optional `base_url` sets or clears the host that key talks to (TD-1722). From a paired phone this is the phone permission `models_and_keys` (`phone_permission_off` without it, TD-5296); changing or clearing an existing key's host so it would go to another server is `loopback_only` from a phone even with it (TD-5301). | | `delete_credential` | — | Remove a named key, its secret, and tier bindings (TD-1717). | -| `set_tier_credential` | — | Bind a named API key to one tier of one preset (TD-1717). That key's `base_url` is the host the tier calls when set (TD-1718). From a paired phone this is the phone permission `models_and_keys` (`phone_permission_off` without it, TD-5296). | +| `set_tier_credential` | — | Bind a named API key to one tier of one preset (TD-1717). That key's `base_url` is the host the tier calls when set (TD-1718). From a paired phone this is the phone permission `models_and_keys` (`phone_permission_off` without it, TD-5296); binding a key saved without a host to a model on a server it does not already go to is `loopback_only` from a phone even with it (TD-5301). | | `set_mcp_server` | — | Create or replace one listed MCP server (id, transport, command argv and/or url, enabled). No `env` or `headers` field; the server's existing ones are kept, unless the transport changes, which drops them and deletes their keychain items (TD-5110). A hand-set `allow_remote` is kept the same way, and dropped with a transport change (TD-5136). A url on another host or port drops the headers (deleting their items) and `allow_remote` too (TD-5161). Acked with `setup_state` (TD-4403). A stdio server is a command the computer runs from then on, so this and the three verbs below are a phone permission (TD-5279): a paired phone is refused with `phone_permission_off` unless the computer switched `mcp_servers` on with `set_phone_permission`, the legacy `remote-token` is always refused that way, and another computer gets `not_allowed`. A phone still sees the list in `setup_state`. When a phone does change a server, the computer's windows get `phone_change` and the server's `origin_device` / `origin_at` say which phone and when. | | `delete_mcp_server` | — | Remove one listed MCP server by id, and delete the keychain items its `env` / `headers` named (TD-5110). Unknown id is a typed error. Acked with `setup_state` (TD-4403). | | `set_mcp_secret` | — | Store one env var (stdio) or header (http) of a listed MCP server (`server_id`, `target`, `name`, `value`) in the keychain item `tst-mcp..`; `config.yaml` gets only `keychain:`. The value never appears in any event, log or audit record. Acked with `setup_state` (TD-5110). | diff --git a/docs/tst-desk-backlog.md b/docs/tst-desk-backlog.md index 7d48da38..ff984253 100644 --- a/docs/tst-desk-backlog.md +++ b/docs/tst-desk-backlog.md @@ -14737,3 +14737,26 @@ teams). Design: section 4.3 of the 2026-11-20 sub-tasks note. **Notes:** the optional per-worker `check` from the design note and steering a running child (4.4) are not in this story. A child's card is tagged by TD-5268 and its worker shows `awaiting_approval` while it waits. + +### TD-5301 — What no phone permission opens + +A paired phone acts as the person, but some acts belong to the computer +whatever the phone was granted (owner decision #5). Checked against a +running daemon first: a phone could point the mail server elsewhere with no +grant, so the saved password went there on the next send; with "Adding +models and keys" on it could move a saved key's host; and it could shut the +daemon down. + +- [x] A phone cannot release a computer-use stop or send `shutdown`, with + any grant (`test_phone_never.py`). +- [x] A phone cannot change or clear a saved key's host so the key reaches + another server, nor bind a key saved without a host to a model + elsewhere, with any grant; renaming a key, saving a new one with its + own host, and binding within the servers it already reaches stay open. +- [x] A phone cannot change the SMTP server without typing the password in + the same message; with it, the change goes through. +- [x] The computer itself does each of these as before. +- [x] The refusal is the same with or without a grant, and the phone sees + why. + +**Size:** 3 · **Depends on:** TD-5182, TD-5279, TD-5296, TD-5297 · **Status:** Done diff --git a/ui/src/lib/phone-permissions.ts b/ui/src/lib/phone-permissions.ts index a774de7d..f00756c8 100644 --- a/ui/src/lib/phone-permissions.ts +++ b/ui/src/lib/phone-permissions.ts @@ -69,6 +69,7 @@ export const PHONE_PERMISSIONS: PhonePermissionCopy[] = [ "What a phone adds stays on this computer after the phone is removed.", "A phone can always switch between the models already here; that needs no permission.", "The key a phone saves goes to the system keychain, never to a file.", + "No phone can send a key already saved here to another server, even with this on. It has to type the key for that server.", ], advice: "Leave this off unless you set up new models while away from the computer.", offOnPhone: