Skip to content

fix(kas): say which MCP servers start without their env on KAS - #26786

Merged
bolichen97 merged 1 commit into
mainfrom
fix/24555-kas-declared-env
Nov 4, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/24555-kas-declared-env

Conversation

@JLargent42

@JLargent42 JLargent42 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A KAS session tells the user which MCP servers start without part of their declared env or headers, by server and key name, and how to start them with their full config.

On the default KAS backend, the agent's MCP servers travel over the ACP connection (_meta.kiro.customAgents), so kas_agents._project_mcp_servers withholds every env value it cannot prove is not a credential, and every headers block. The gateway rewriter leaves a credentialed server unwrapped when a shared backend would withhold its env, expecting the session to apply it. On KAS the session does not, so the server starts with none of its settings. The reporter's gitlab-mcp started against the default GitLab host, got 401 on every call, and exposed a tool its GITLAB_DENIED_TOOLS_REGEX should have hidden. The only trace was an INFO log line.

Why it matters

KAS is the default backend, so anyone with a credentialed or settings-driven MCP server sees it fail with no visible cause. Two working routes exist (the kiro backend, or a secret:// value routed through the gateway, which #24918 made reachable from MCP Management), but nothing tells the user to take one.

Not a goal

What changed (motivation → approach → change)

Symptom: a server that needs a withheld setting fails on KAS with no visible cause. Cause: the projection's withhold was logged at INFO and nowhere else. Fix: the projection records what it withheld, and the new chat shows it.

Part Change
Projection (acp/kas_agents.py) _project_mcp_servers, to_client_custom_agent and build_kas_custom_agents take an optional withheld_out. For each declared server Crew did not author that lost something, it records (withheld env key names, fields, stdio). Names only, never a value. Crew's own servers and gateway-stubbed servers are not recorded (a stubbed server gets its env through the gateway). It records after the local launcher step from #26785: a key the launcher started the server with is dropped from the record, and a server the launcher fully covered is not recorded at all, so the notice never claims a server lost env it actually has.
Notice text (acp/kas_withheld_notice.py, new) withheld_credentials_notice names each server and its key names through the existing _loggable_key_names, so a credential-shaped name is counted, not printed. For a local (command) server that lost env, it gives the route that keeps the values off the wire: a secret:// value with the server routed through the gateway in Developer → MCP Management. For a remote (url) server the header bridge does not carry, such as an sse one, it says plainly that the gateway cannot route it either and nothing on Crew's side supplies its headers (the gateway launches only stdio servers, and secret:// resolves only in a stdio server's env). The collector records whether each server is stdio for that split. It does not suggest agent.acp_backend kiro: a stored kiro pick loads as KAS once kiro-cli serves its v3 engine (kiro_cli_pick_backend). A new module because kas_agents.py is at the 2,000-line cap.
Carriage KasHarness.session_extras builds the notice from the same projection it sends, into the new SessionExtras.withheld_credentials_notice. create_session copies it onto the handle (kas_withheld_credentials_notice), threaded like request_identity so the late-adoption path carries it too. AcpSessionProvider (acp/session_provider.py) and AcpProvider (providers/acp.py) expose it like kas_agent_prompt_notice.
Chat (dashboard/chat_turn/turn_spec_hooks.py) _notice_steer_upgrade shows it as one notice row on a new session, the same row the steer and prompt-floor notices use, through the display redactor.
Docs (docs/agent-spec-fields.md) The env-withholding paragraph says a new chat names the servers, the gateway route for a local server, and that a remote server whose headers stay withheld (an sse entry) has none.
Line-cap split (acp/kas_env_literals.py, new) After the rebase onto #26785, kas_agents.py would be 2,014 lines. The env-literal helpers (_relayable_literal, _credential_shaped_env_key, _loggable_key_names and their patterns) move unchanged into kas_env_literals.py; kas_agents.py imports the two it calls and is 1,945 lines. security_posture.py's redactor allowlist entry moves from acp/kas_agents.py to the new file (the scan follows the redact_external_text call), and docs/system-specs/modules/acp-client.md names the new module.
Inventories test_runtime_bindings.py signature digests for _collect_late_start and _finish_create_session, which gain withheld_notice.

The fifth item in the issue (tell the operator a stub_servers entry is unapproved) is already surfaced on main. /api/mcp-gateway/status reports launch_refused with reason added_outside_dashboard, MCP Management renders it ("Declared in a config file, and never approved here."), and kirocrew doctor reports "not approved yet". The issue's loop step 2, where the row read direct (env) and offered no approval, was fixed by #24918.

Backwards compatibility

Compatible: the new parameters and fields are optional with empty defaults, and the projection sends exactly what it sent before.

Removes nothing: the diff only adds a parameter, a dataclass field, a handle field, two properties and a notice row.

Tests

  • test/test_kas_withheld_credentials_notice.py (new):
    • TestTheProjectionRecordsWhatItWithheld: the reported server's withheld keys are recorded by name. The relayed boolean and a variable set only in the gateway's environment are not. headers is recorded. A server that lost nothing, Crew's own server and a stubbed server are not recorded. A stdio server the local launcher starts with its env (projection with a session key) is not recorded; this test fails with the record taken before the launcher step. A streamable-HTTP server the header bridge carries (projection with a session key) is not recorded, and fails when the bridge step's result is ignored; an sse server, which the bridge does not carry, still is. The projection with a collector equals the one without, and neither carries the undeclared variable. build_kas_custom_agents passes the collector through.
    • TestTheNotice: names the server, keys and the gateway route, and does not suggest acp_backend. A remote server is not offered the gateway route and is told nothing supplies its headers; a stdio server alone gets only the gateway route. No value and no undeclared variable reaches it. A credential-shaped key or server name is counted, not printed. A malformed env is named whole. An env key literally named headers reads as an env key.
    • test_the_session_payload_carries_the_notice / ..._withholds_nothing_has_no_notice: the real KasHarness.session_extras over a spec on disk.
    • Provider and chat-row tests: the notice reaches AcpProvider.withheld_credentials_notice and renders as one notice row in a new dashboard chat; empty or non-string renders none. Other surfaces (CLI, Slack, Discord) keep the INFO log line only.
  • test/test_acp_runtime.py::test_create_session_records_the_withheld_credentials_notice: the real create_session wire path puts the notice on the handle.
  • test/test_acp_bindings.py: inventory row for the new AcpProvider property. Test doubles of build_kas_custom_agents in test_kas_agents_mcp_servers.py and test_member_dispatch_mount.py accept the new keyword.

Proof: not provable -- other: prove.py was not run on this host; reverted by hand instead (below)

Manual revert-and-retest: with only the withheld_out[name] = ... line in _project_mcp_servers reverted, 8 tests in test_kas_withheld_credentials_notice.py fail (every projection, session-payload and value-absence test). With only the handle assignment in _finish_create_session reverted, test_create_session_records_the_withheld_credentials_notice fails. Locally run green at -n 2: the new file, test_acp_runtime.py, test_kas_agent_prompt_floor.py, test_acp_bindings.py, test_kas_agents_mcp_env_relay.py, test_kas_agents_mcp_servers.py, test_acp_harness_contract.py, test_kas_agents.py, test_acp_harness_wire_parity.py, test_member_dispatch_mount.py, test_worker_agent_spawn_gate.py, test_agent_spec_fields_doc.py, test_security_posture.py (1,100+ tests). The full suite was not run locally. After the rebase onto #26785: the new file, test_kas_agents_mcp_servers.py, test_acp_bindings.py, test_acp_runtime.py, test_member_dispatch_mount.py, test_runtime_bindings.py, test_kas_env_launch.py and test_kas_env_launch_resume.py pass at -n 2 (931 tests).

Manual verification

Not run against a live KAS session on this host. The tests drive the real harness projection over a spec on disk and the real create_session wire path, and render the row through the same function a new chat calls.

Related Issues

Closes #24555

Sibling sweep

Swept: git grep -n "_withhold_credential_fields(" -- src/
Sibling: src/kiro_crew/acp/kas_agents.py -- changed here

Pattern harvest

Rule candidate: review-prompt
Pattern: a safety filter that strips part of a user's configuration and reports it only in a debug or INFO log, so the user sees a failure with no cause.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@JLargent42 JLargent42 self-assigned this Oct 31, 2026
@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners October 31, 2026 17:26
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 80d520c99c304239b2d5c6541c3f1176908552a7 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 80d520c99c304239b2d5c6541c3f1176908552a7 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the projection already decides what to withhold, so recording that decision there and showing it as a notice row fixes the silent failure where it starts.

Notes

  • The notice only appears in the dashboard chat (_notice_steer_upgrade). A KAS session opened from Slack or Discord, or a cron session, still fails with no visible cause. Showing it on those surfaces would be a follow-up, not part of this PR.
  • kas_withheld_notice.py imports WithheldOut from kas_agents. Keeping that type next to its only consumer, or in kas_env_literals, would stop the new module from depending on a file that is at the 2,000-line cap.

[DESIGN-REVIEWED] 80d520c

Description read

[DESCRIPTION-READ] d65873fb9a426251b3bd09ab600f5e39d790d6611ea7b469d9e96867fbe55445

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 80d520c99c304239b2d5c6541c3f1176908552a7 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Each item has a reported defect behind it, and the existing INFO log line is the only other place this shows up.

What this change ships

Inventory (7 items) — 7 justified

Intent: a user on KAS whose MCP server starts without part of its declared env or headers learns which server, which keys, and the route that fixes it. FIX.

  1. A new KAS chat shows one notice row naming each server and the env key names or headers it lost — justified
  2. The notice offers a local (command) server the secret:// plus gateway-routing route — justified
  3. The notice tells a remote server the local bridge cannot carry, such as an sse entry, that nothing on Crew's side can supply its headers — justified
  4. The projection records what it withheld after the launcher and bridge steps, so a server those steps fully cover is not named — justified
  5. New optional withheld_out parameter on _project_mcp_servers, to_client_custom_agent and build_kas_custom_agents — justified
  6. New SessionExtras field, handle field and two provider properties carrying the notice to the chat — justified
  7. The env-literal helpers move unchanged into kas_env_literals.py, and the redactor allowlist entry follows them — justified

[FIRST-PRINCIPLES-REVIEWED] 80d520c

Description read

[DESCRIPTION-READ] 6b602366085309077d6b745ff121534a575b466b3ef66d86876a00740368511e

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 80d520c99c304239b2d5c6541c3f1176908552a7 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 80d520c

Verdict parsed from the review's SHA-scoped output markers for commit 80d520c99c304239b2d5c6541c3f1176908552a7.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 80d520c99c304239b2d5c6541c3f1176908552a7 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 80d520c99c304239b2d5c6541c3f1176908552a7 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 80d520c

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 80d520c99c304239b2d5c6541c3f1176908552a7 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 31, 2026
@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from 857a326 to b20f18b Compare October 31, 2026 18:12
@JLargent42

JLargent42 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

AI review disposition

  • GPT 6.1 F1, src/kiro_crew/acp/kas_withheld_notice.py:49: the kiro backend suggestion still selects KAS on v3: fixed in b20f18b. Confirmed: _read_backend_choice moves a stored kiro pick onto KAS through kiro_cli_pick_backend once kiro-cli serves its v3 engine. The notice and docs/agent-spec-fields.md now give only the gateway route (secret:// value, routing on in MCP Management), which keeps the values off the wire and starts the server with its whole declared env. TestTheNotice::test_it_names_the_server_and_keys_and_the_way_out asserts the notice no longer mentions acp_backend. The frozen "Why it matters" paragraph still names the kiro backend as a route; it is left as written because that section is frozen, and the sections below it now say why it is not offered.

@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from b20f18b to 86c1439 Compare October 31, 2026 19:17
@JLargent42

Copy link
Copy Markdown
Contributor Author

AI review disposition

  • Opus 5.5 F1, src/kiro_crew/acp/kas_withheld_notice.py:49: the gateway remedy cannot help a remote server that lost its headers: fixed in 86c1439. Confirmed: the rewriter wraps only entries with a command, and secret:// resolves only in a stdio server's env. The collector now records whether each server is stdio. The gateway route is shown only when a stdio server lost env; a remote server gets a plain line that the gateway cannot route it and nothing on Crew's side supplies its headers. Pinned by TestTheNotice::test_a_remote_server_is_not_offered_the_gateway_route and test_a_stdio_server_alone_gets_only_the_gateway_route.

@JLargent42

JLargent42 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

AI review disposition

  • GPT 6.1 F1, src/kiro_crew/acp/kas_withheld_notice.py:49: the gateway remedy cannot restore a remote server's withheld headers: fixed in 86c1439. Same defect as the Opus finding on this head. The gateway route is now qualified to local (command) servers that lost env, and a remote server is told that it cannot be routed and nothing on Crew's side supplies its headers. Pinned by TestTheNotice::test_a_remote_server_is_not_offered_the_gateway_route.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 1, 2026
@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from 86c1439 to e528431 Compare November 2, 2026 17:19
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e528431
  • What rule changed: No rule changed. One allowlist row in src/kiro_crew/security_posture.py moves from acp/kas_agents.py to acp/kas_env_literals.py, because the env-literal helpers that call redact_external_text moved there unchanged (a line-cap split after the rebase onto fix(kas): start env-bearing MCP servers through a local launcher #26785).
  • Before -> after (what was allowed/blocked, now): Same values allowed and withheld before and after. The KAS projection still relays only a boolean env literal under a non-credential key that the redactor leaves unchanged, and still withholds every other value and every headers block. The moved functions are byte-identical; only their module changed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A stale allowlist row would hide a new redactor call site in kas_agents.py from the posture scan. The scan's own stale-entry test fails on a row that no longer calls a redactor, and it passes on this head, so the row points at the file that holds the call.
  • Evidence checked (which sandbox result proves it): No sandbox path is touched. test/test_security_posture.py (both omission-detection tests) and test/test_kas_agents_mcp_env_relay.py pass on this head; before the row moved, both omission tests failed, naming acp/kas_agents.py as stale and the new module as unregistered.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest -n 2 over the KAS projection, launcher, notice, bindings and posture files: 1,401 passed. check_file_line_cap.py: 0 failures (kas_agents.py 1,945 lines). black, isort and flake8 clean on the changed files.
    • Backward compatible (old config / old data / old callers still work, how checked): kas_agents still imports _relayable_literal and _loggable_key_names, so its callers and the env-relay tests resolve unchanged. The wire payload is unchanged; the projection tests pin it.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_kas_agents_mcp_env_relay.py, test_kas_agents_mcp_servers.py, test_kas_agents.py, test_kas_env_launch.py, test_kas_env_launch_resume.py, test_kas_withheld_credentials_notice.py, test_acp_bindings.py, test_acp_runtime.py, test_runtime_bindings.py, test_member_dispatch_mount.py, test_acp_harness_contract.py, test_acp_harness_wire_parity.py, test_agent_spec_fields_doc.py, test_kas_agent_prompt_floor.py.
  • How to undo: Revert the commit; the row and the helpers move back together.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture.py

  • @JLargent42 posted a complete reasoning template for 80d520c.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 2, 2026
@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from e528431 to 954e895 Compare November 3, 2026 07:08
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 954e895
  • What rule changed: No rule changed. One allowlist row in src/kiro_crew/security_posture.py moves from acp/kas_agents.py to acp/kas_env_literals.py, because the env-literal helpers that call redact_external_text moved there unchanged (a line-cap split). This head is a rebase onto current main, which added the local header bridge for streamable-HTTP servers; the notice is recorded after that step, so a server whose headers the bridge carries is not named.
  • Before -> after (what was allowed/blocked, now): Same values allowed and withheld as on main. The KAS projection still relays only a boolean env literal under a non-credential key that the redactor leaves unchanged, and withholds every other value; headers are withheld from the wire and, as on main, reach a streamable-HTTP server only through the local bridge. The moved functions are byte-identical; only their module changed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A stale allowlist row would hide a new redactor call site in kas_agents.py from the posture scan. The scan's own stale-entry test fails on a row that no longer calls a redactor, and it passes on this head. A wrong notice would only misname which servers lack settings; it never carries a value.
  • Evidence checked (which sandbox result proves it): No sandbox path is touched. test/test_security_posture.py and test/test_kas_agents_mcp_env_relay.py pass on this head. The new test that a bridged remote server is not named fails when the header step's result is ignored, and passes with it.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest -n 2 over the KAS projection, launcher, header bridge, app identity, notice, bindings and posture files: 1,431 passed. check_file_line_cap.py: 0 failures (kas_agents.py 1,964 lines). black, isort and flake8 clean on the changed files; scripts/docs-lint.sh passed.
    • Backward compatible (old config / old data / old callers still work, how checked): kas_agents still imports _relayable_literal and _loggable_key_names, so its callers and the env-relay tests resolve unchanged. The wire payload is unchanged; the projection and header-bridge tests pin it. Main's app_launches extra is kept beside the new notice field.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_kas_agents_mcp_env_relay.py, test_kas_agents_mcp_servers.py, test_kas_agents.py, test_kas_env_launch.py, test_kas_env_launch_resume.py, test_kas_withheld_credentials_notice.py, test_kas_header_bridge.py, test_kas_app_mcp_session_identity.py, test_acp_bindings.py, test_acp_runtime.py, test_runtime_bindings.py, test_member_dispatch_mount.py, test_acp_harness_contract.py, test_acp_harness_wire_parity.py, test_agent_spec_fields_doc.py, test_kas_agent_prompt_floor.py.
  • How to undo: Revert the commit; the row and the helpers move back together.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 3, 2026
@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from 954e895 to b0c64df Compare November 3, 2026 07:26
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: b0c64df
  • What rule changed: No rule changed. One allowlist row in src/kiro_crew/security_posture.py moves from acp/kas_agents.py to acp/kas_env_literals.py, because the env-literal helpers that call redact_external_text moved there unchanged (a line-cap split). This head is a rebase onto current main, which added the local header bridge for streamable-HTTP servers; the notice is recorded after that step, so a server whose headers the bridge carries is not named. Since 954e895 only the new test file was black-formatted (two signatures joined onto one line).
  • Before -> after (what was allowed/blocked, now): Same values allowed and withheld as on main. The KAS projection still relays only a boolean env literal under a non-credential key that the redactor leaves unchanged, and withholds every other value; headers are withheld from the wire and, as on main, reach a streamable-HTTP server only through the local bridge. The moved functions are byte-identical; only their module changed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A stale allowlist row would hide a new redactor call site in kas_agents.py from the posture scan. The scan's own stale-entry test fails on a row that no longer calls a redactor, and it passes on this head. A wrong notice would only misname which servers lack settings; it never carries a value.
  • Evidence checked (which sandbox result proves it): No sandbox path is touched. test/test_security_posture.py and test/test_kas_agents_mcp_env_relay.py pass on this head. The new test that a bridged remote server is not named fails when the header step's result is ignored, and passes with it.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest -n 2 over the KAS projection, launcher, header bridge, app identity, notice, bindings and posture files: 1,431 passed; the reformatted notice file passes again (25 passed). check_file_line_cap.py: 0 failures (kas_agents.py 1,964 lines). scripts/check_black_formatting.py passed, and isort and flake8 are clean on the changed files; scripts/docs-lint.sh passed.
    • Backward compatible (old config / old data / old callers still work, how checked): kas_agents still imports _relayable_literal and _loggable_key_names, so its callers and the env-relay tests resolve unchanged. The wire payload is unchanged; the projection and header-bridge tests pin it. Main's app_launches extra is kept beside the new notice field.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_kas_agents_mcp_env_relay.py, test_kas_agents_mcp_servers.py, test_kas_agents.py, test_kas_env_launch.py, test_kas_env_launch_resume.py, test_kas_withheld_credentials_notice.py, test_kas_header_bridge.py, test_kas_app_mcp_session_identity.py, test_acp_bindings.py, test_acp_runtime.py, test_runtime_bindings.py, test_member_dispatch_mount.py, test_acp_harness_contract.py, test_acp_harness_wire_parity.py, test_agent_spec_fields_doc.py, test_kas_agent_prompt_floor.py.
  • How to undo: Revert the commit; the row and the helpers move back together.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Notes moved out of two AI review disposition comments, so each disposition record covers exactly one finding. Neither note is an AI-lane finding.

  • Design Review note on 857a326: the row reaches dashboard chats only. Acknowledged. The Tests section says so: CLI, Slack and Discord sessions keep the existing INFO log line. Extending the row to those surfaces is new scope.
  • CI on b20f18b: Backend Tests (3.12, 8) and (Windows) (8) were fixed in 86c1439. test_runtime_bindings.py pins signature digests, and _collect_late_start / _finish_create_session gained withheld_notice. The inventory rows were updated.
  • Rebase onto main (head b0c64df): main added the local header bridge for streamable-HTTP servers. The notice is now recorded after that step, so a server whose headers the bridge carries is not named; an sse server, which the bridge does not carry, still is. Pinned by test_a_remote_server_the_local_bridge_carries_is_not_recorded and test_an_sse_server_the_bridge_cannot_carry_is_still_recorded.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 3, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 3, 2026
@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from b0c64df to 8369e6f Compare November 3, 2026 13:16
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8369e6f
  • What rule changed: No rule changed. One allowlist row in src/kiro_crew/security_posture.py moves from acp/kas_agents.py to acp/kas_env_literals.py, because the env-literal helpers that call redact_external_text moved there unchanged (a line-cap split). This head is a rebase onto current main, which added launch_snapshots to the session-create path; the PR's withheld_notice argument now sits beside it, and the two test_runtime_bindings.py signature digests are recomputed for both arguments.
  • Before -> after (what was allowed/blocked, now): Same values allowed and withheld as on main. The KAS projection still relays only a boolean env literal under a non-credential key that the redactor leaves unchanged, and withholds every other value; headers are withheld from the wire and, as on main, reach a streamable-HTTP server only through the local bridge. The moved functions are byte-identical; only their module changed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A stale allowlist row would hide a new redactor call site in kas_agents.py from the posture scan. The scan's own stale-entry test fails on a row that no longer calls a redactor, and it passes on this head. A wrong notice would only misname which servers lack settings; it never carries a value. A wrong merge of launch_snapshots would leave snapshot files after shutdown; main's launch-snapshot tests pass on this head.
  • Evidence checked (which sandbox result proves it): No sandbox path is touched. test/test_security_posture.py and test/test_kas_agents_mcp_env_relay.py pass on this head. The test that a bridged remote server is not named fails when the header step's result is ignored, and passes with it.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest -n 2 over the KAS projection, launcher, header bridge, app identity, notice, bindings and posture files: 1,432 passed; test_kas_env_launch.py, test_kas_env_launch_resume.py and test_worker_agent_load_bracket.py: 70 passed. check_file_line_cap.py: 0 failures. scripts/check_black_formatting.py passed, and isort and flake8 are clean on the changed files.
    • Backward compatible (old config / old data / old callers still work, how checked): kas_agents still imports _relayable_literal and _loggable_key_names, so its callers resolve unchanged. Both new session-create arguments are keyword-only with defaults, so a caller that passes neither behaves as on main. The wire payload is unchanged; the projection and header-bridge tests pin it.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_kas_agents_mcp_env_relay.py, test_kas_agents_mcp_servers.py, test_kas_agents.py, test_kas_env_launch.py, test_kas_env_launch_resume.py, test_worker_agent_load_bracket.py, test_kas_withheld_credentials_notice.py, test_kas_header_bridge.py, test_kas_app_mcp_session_identity.py, test_acp_bindings.py, test_acp_runtime.py, test_runtime_bindings.py, test_member_dispatch_mount.py, test_acp_harness_contract.py, test_acp_harness_wire_parity.py, test_agent_spec_fields_doc.py, test_kas_agent_prompt_floor.py.
  • How to undo: Revert the commit; the row and the helpers move back together.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 3, 2026
@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from 8369e6f to 4befe37 Compare November 4, 2026 03:36
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 4befe37
  • What rule changed: No rule changed. One allowlist row in src/kiro_crew/security_posture.py moves from acp/kas_agents.py to acp/kas_env_literals.py, because the env-literal helpers that call redact_external_text moved there unchanged (a line-cap split). This head is a rebase onto current main, which added the session-label relay env (session_label.take_kas_marker) and withdrawn_stub_names on SessionExtras. The PR's env relay now reads main's relay_env for both the launcher and the notice's relayable set, and SessionExtras carries both withdrawn_stub_names and withheld_credentials_notice.
  • Before -> after (what was allowed/blocked, now): Same values allowed and withheld as on main. The KAS projection still relays only a boolean env literal under a non-credential key that the redactor leaves unchanged, and withholds every other value; headers are withheld from the wire and, as on main, reach a streamable-HTTP server only through the local bridge. The moved functions are byte-identical; only their module changed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A stale allowlist row would hide a new redactor call site in kas_agents.py from the posture scan. The scan's own stale-entry test fails on a row that no longer calls a redactor, and it passes on this head. A wrong notice would only misname which servers lack settings; it never carries a value. A wrong merge of main's withdrawn stubs would leave a muted worker stub mounted; main's mate-overlay and runtime tests pass on this head.
  • Evidence checked (which sandbox result proves it): No sandbox path is touched. test/test_security_posture.py, test/test_kas_agents_mcp_env_relay.py and test/test_app_mcp_session_label.py pass on this head. The test that a bridged remote server is not named fails when the header step's result is ignored, and passes with it.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest -n 2 over the KAS projection, launcher, header bridge, app identity, session label, mate overlays, notice, bindings and posture files: 1,510 passed; the harness contract, wire parity, spec-fields doc, prompt floor and load-bracket files: 353 passed. check_file_line_cap.py: 0 failures. scripts/check_black_formatting.py passed, and isort and flake8 are clean on the changed files.
    • Backward compatible (old config / old data / old callers still work, how checked): kas_agents still imports _relayable_literal and _loggable_key_names, so its callers resolve unchanged. The new session-create argument is keyword-only with a default, so a caller that omits it behaves as on main. The wire payload is unchanged; the projection and header-bridge tests pin it.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_kas_agents_mcp_env_relay.py, test_kas_agents_mcp_servers.py, test_kas_agents.py, test_kas_env_launch.py, test_kas_env_launch_resume.py, test_worker_agent_load_bracket.py, test_kas_withheld_credentials_notice.py, test_kas_header_bridge.py, test_kas_app_mcp_session_identity.py, test_app_mcp_session_label.py, test_mcp_gateway_mate_overlays.py, test_acp_bindings.py, test_acp_runtime.py, test_runtime_bindings.py, test_member_dispatch_mount.py, test_acp_harness_contract.py, test_acp_harness_wire_parity.py, test_agent_spec_fields_doc.py, test_kas_agent_prompt_floor.py.
  • How to undo: Revert the commit; the row and the helpers move back together.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 4, 2026
A KAS session receives the agent's MCP servers over the ACP connection, so
the projection withholds every env value it cannot prove is not a
credential, and every headers block. The server still starts, so a
credentialed server the gateway left unwrapped started without its
settings and failed with only an INFO log line as a trace.

The projection now records, per declared server, the env key names and
fields it withheld (names only). The KAS harness turns that into a
session-start notice, and a new chat shows it in the same row as the
other upgrade notices, with the two ways to start the server with its
full config.
@JLargent42
JLargent42 force-pushed the fix/24555-kas-declared-env branch from 4befe37 to 80d520c Compare November 4, 2026 06:35
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 80d520c
  • What rule changed: No rule changed. One allowlist row in src/kiro_crew/security_posture.py moves from acp/kas_agents.py to acp/kas_env_literals.py, because the env-literal helpers that call redact_external_text moved there unchanged (a line-cap split). This head is a clean rebase of 4befe37 onto current main to pick up the main-side Electron xattr test fix (test(linux): skip lease-held publish checks where the kernel refuses write leases #29444); the PR's own diff is unchanged. The env relay reads main's relay_env for both the launcher and the notice's relayable set, and SessionExtras carries both withdrawn_stub_names and withheld_credentials_notice.
  • Before -> after (what was allowed/blocked, now): Same values allowed and withheld as on main. The KAS projection still relays only a boolean env literal under a non-credential key that the redactor leaves unchanged, and withholds every other value; headers are withheld from the wire and, as on main, reach a streamable-HTTP server only through the local bridge. The moved functions are byte-identical; only their module changed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A stale allowlist row would hide a new redactor call site in kas_agents.py from the posture scan. The scan's own stale-entry test fails on a row that no longer calls a redactor, and it passes on this head. A wrong notice would only misname which servers lack settings; it never carries a value. A wrong merge of main's withdrawn stubs would leave a muted worker stub mounted; main's mate-overlay and runtime tests pass on this head.
  • Evidence checked (which sandbox result proves it): No sandbox path is touched. test/test_security_posture.py, test/test_kas_agents_mcp_env_relay.py and test/test_app_mcp_session_label.py pass on this head. The test that a bridged remote server is not named fails when the header step's result is ignored, and passes with it.
  • No regression:
    • Tools still work (which tools/commands were run, result): pytest -n 2 over 25 files covering the KAS projection, launcher, header bridge, app identity, session label, mate overlays, notice, bindings, harness contract, wire parity and posture: 1,708 passed. check_file_line_cap.py: 0 failures. scripts/check_black_formatting.py passed, and isort and flake8 are clean on the changed files.
    • Backward compatible (old config / old data / old callers still work, how checked): kas_agents still imports _relayable_literal and _loggable_key_names, so its callers resolve unchanged. The new session-create argument is keyword-only with a default, so a caller that omits it behaves as on main. The wire payload is unchanged; the projection and header-bridge tests pin it.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_kas_agents_mcp_env_relay.py, test_kas_agents_mcp_servers.py, test_kas_agents.py, test_kas_env_launch.py, test_kas_env_launch_resume.py, test_worker_agent_load_bracket.py, test_kas_withheld_credentials_notice.py, test_kas_header_bridge.py, test_kas_app_mcp_session_identity.py, test_app_mcp_session_label.py, test_mcp_gateway_mate_overlays.py, test_acp_bindings.py, test_acp_runtime.py, test_runtime_bindings.py, test_member_dispatch_mount.py, test_acp_harness_contract.py, test_acp_harness_wire_parity.py, test_agent_spec_fields_doc.py, test_kas_agent_prompt_floor.py.
  • How to undo: Revert the commit; the row and the helpers move back together.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 4, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving head 80d520c.

What I checked:

  • Read every non-test hunk (19 files). The projection now records, per server Crew did not author, the env key names and fields it withheld, and the KAS harness turns that into one notice row on a new chat. The notice passes key and server names through _loggable_key_names, so a credential-shaped name is counted, not printed, and no value is read.
  • The wire payload is unchanged: withheld_out is only an out parameter, and test_the_wire_is_unchanged pins the projection with and without the collector.
  • The launcher path is handled: when relay_withheld_env launched the server, keys in withheld_env(...) are dropped from the notice, so it names only what is still missing. The headers bridge clears headers the same way.
  • kas_env_literals.py is a verbatim move of _relayable_literal, _loggable_key_names and their helpers out of kas_agents.py; no matching rule was added or widened. The security_posture.py entry moves with the code.
  • No change to approvals, permissions or what crosses the wire.

Gates at this head: 95 checks ok, 0 red, 0 pending; readiness passed; mergeable; no open change requests. Design, First Principles, Opus and GPT lanes pass; UX skipped (no user-facing surface).

Non-blocking note: when the launcher snapshot cannot be written, the server refuses to start rather than starting without its env, so the notice wording "start without the settings" is slightly loose for that case. Fine to leave as is.

@bolichen97
bolichen97 merged commit dd41cf8 into main Nov 4, 2026
96 checks passed
@bolichen97
bolichen97 deleted the fix/24555-kas-declared-env branch November 4, 2026 09:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAS sessions start credentialed MCP servers with no env when the gateway leaves them unwrapped

2 participants