fix(kas): keep remote MCP sign-ins by default, strict on governed hosts

Draft
DO
18d ago
+515-54

Problem / Motivation

Goal: A remote OAuth MCP server such as Atlassian stays signed in across KAS chats, subagents and crons on a regular install, while a registry-governed install keeps sign-ins in memory unless its admin's security policy opts in.

On the KAS backend a remote MCP server's OAuth sign-in lives only in the engine's process memory unless agent.kas_persist_mcp_sign_in is on, and it is off by default. Installs that never chose a backend now run KAS, so a user who signs in to Atlassian (#26182) or Notion/Figma (#23135) is asked to sign in again by every new KAS process, and the gateway log says nothing about it.

Why it matters

Every KAS user with a remote OAuth MCP server hits a repeated Authorize card that reads as a broken sign-in, and a dropped sign-in leaves no trace in the gateway log to diagnose it.

Not a goal

  • Changing how the KAS engine itself refreshes or reuses its tokens; that lives in the engine shipped with kiro-cli.
  • Carrying a Settings > Connections sign-in (kiro-cli's own OAuth cache) into KAS.
  • Relaxing anything on a registry-governed install by default.

What changed (motivation → approach → change)

Grants were lost because the vault that keeps them was opt-in, so the fix is to make it the default and keep the governed path strict:

  • agent.kas_persist_mcp_sign_in defaults to true (config/sections_agent.py, config-baseline.json regenerated); an explicit false still turns it off.
  • runtime_spawn_launch._mcp_sign_in_storage_decision decides per spawn from one effective-config read (kas_secret_storage.sign_in_settings); a read that raised or came back degraded (an unparseable config.json/config.local.json loads as defaults that would say "keep" and "not governed") keeps sign-ins in memory. On a governed host -- one with a security policy installed (current_context().governance, read as installed when the ceiling cannot be read), or one declaring agent.mcp_registry_mode -- sign-ins are kept only when the admin's security policy sets the new policy-only, authority-only field mcp_persist_sign_in (kas_secret_storage.policy_permit). config.json alone never widens that host, a false there still wins, and a governed spawn left in memory logs one INFO line naming the field. The field lives on GovernanceCeiling (platform/governance_parts/carriers.py, parsed in parsing.py, listed authority-only in tiers.py) and follows the shape of mcp_registry_local_control_plane (#28444): a JSON boolean, any other value fails the load, a profile cannot carry it, a lower tier cannot supply it.
  • The session sign-in tracker logs a completed sign-in at INFO and a WARNING when a server that connected on the session is reported failedAuthorization again, with the sanitized server name and session id only.
  • Config baseline, configuration.md, and the acp-client, governance and security specs describe the new default and the governed opt-in; the config help says that turning the key off leaves already kept sign-ins in the vault, unused.

No RFC records this default change; the maintainer ruling for it is on #26182 / #23135.

Backwards compatibility

Breaking: on a governed install (a security policy installed, or agent.mcp_registry_mode) that had set agent.kas_persist_mcp_sign_in: true, KAS sign-ins now stay in memory until the admin's policy sets mcp_persist_sign_in: true. This is the lockdown-by-default rule for governed hosts, applied on purpose. Every other install is compatible: an explicit value keeps its meaning, an unset key now keeps sign-ins, and a policy file without the new field parses as before. Writer sweep on origin/main @ 7da2cbbeec (git grep kas_persist_mcp_sign_in): the only reader is kas_secret_storage (changed here); loader_builders.py and sections_agent.py declare the key; website/src/api/acpBackend.ts and its tests pass the key in fixtures but never decide anything from it.

Reader: src/kiro_crew/acp/runtime_spawn_launch.py:_with_mcp_sign_in_storage -- chat -- the one reader of the removed kas_secret_storage.persistence_enabled, on every KAS spawn (chats, crons, subagents alike); it now calls _mcp_sign_in_storage_decision, which reads sign_in_settings and policy_permit (test_a_regular_kas_handshake_declares_secret_storage_by_default)

Tests

  • test/test_kas_mcp_sign_in_default.py: the policy field (absent off, booleans, bad values fail, profile refused, authority-only); the spawn decision on a regular install (default on, explicit false off), a registry-mode host (default off with the INFO line, config true alone off, policy opt-in on, explicit false wins), a host with a security policy and no registry mode (default off, policy opt-in on, explicit false wins), an unparseable or non-object config and a config read that raises all off, unreadable policy off); the KAS handshake declaring secretStorage by default and not on a governed host; both tracker log lines, with no URL or token in the log.
  • test/test_kas_mcp_secret_storage.py: the config key now reads on by default and off when set false.
  • test/test_governance_tier_ladder.py: the new ceiling field is classified authority-only.

Proof: PROVEN test/test_governance_tier_ladder.py::TestEveryCeilingFieldHasAComposeClass::test_every_field_is_classified_exactly_once, test/test_kas_mcp_secret_storage.py::test_the_key_is_on_by_default_and_read_from_config, test/test_kas_mcp_sign_in_default.py::test_a_regular_kas_handshake_declares_secret_storage_by_default, test/test_kas_mcp_sign_in_default.py::test_a_completed_sign_in_is_logged_at_info, test/test_kas_mcp_sign_in_default.py::test_a_sign_in_the_engine_drops_is_logged_once_as_a_warning (head 36c617aa12aa)

Manual verification

Not run end to end: it needs an Atlassian account and a browser consent. The reporter is asked on #26182 to confirm on a build with this change.

Screenshots / video

N/A — no frontend file changes; the Settings field's default and help text come from the config schema.

Related Issues

Fixes #26182
Fixes #23135

Sibling sweep

Swept: git grep -n "kas_persist_mcp_sign_in|persistence_enabled" -- src/ website/src/
Sibling: src/kiro_crew/acp/kas_secret_storage.py -- changed here
Sibling: website/src/api/acpBackend.ts -- not affected -- reads only the backend, never this key

Pattern harvest

Not generalizable: a per-feature default choice, not a code defect with a repeatable shape.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff