Repository navigation
refactor(sandbox): name the Python-env-only strip policy - #21663
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that no test or the terminal facade mirror still patches [DESIGN-REVIEWED] f33dc55 Description read[DESCRIPTION-READ] 44e8a2c1accfe3baa6b91fa178d4fd330df20204d19ab1f384528ad61a39062f 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. Not justified as shipped
What this change shipsInventory (6 items) — 5 justifiedIntent: give one name to the rule that a non-agent child gets every environment variable except Kiro Crew's Python settings, so spawn sites stop copying the loop. This is a FIX (Closes #8054).
The grep for [FIRST-PRINCIPLES-REVIEWED] f33dc55 Description read[DESCRIPTION-READ] 6dcc4e38515827fa888f00fa5b247033ed486bc4fb8825399a5d05cfb9173733 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Sensitive change review
|
|
9010673 to
7db77df
Compare
Sensitive change review
|
7db77df to
9a790c2
Compare
Sensitive change review
|
|
9a790c2 to
cf3dc39
Compare
Sensitive change review
|
cf3dc39 to
f33dc55
Compare
Sensitive change review
|
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Every review lane on the head is clean (only runner notices and PR Scope size warnings); held by the triage cron on a path, category, checklist or P0-area rule, not a finding. Approved on the watch holder's request.
Problem / Motivation
Goal: The "drop only Kiro Crew's Python settings, keep the user's credentials" rule for a child process has one name in
sandbox, and every place that applies it calls that name.Three spawn sites hand-write the same prefix loop over
sandbox._PYTHON_ENV_PREFIXES: the dashboard terminal's shell (terminal_shell._pty_child_env), the voice list'saws polly describe-voicescall (chat_voice.api_voice_voices), and the third-party branch of the pooled MCP backend spawn (mcp_gateway/daemon/launch.env_target_resolver). None of them can usescrub_agent_subprocess_env, because that one also stripsSSH_AUTH_SOCK,AWS_*,GNUPGHOMEandGIT_ASKPASS, which these children need. So the rule is real, has three callers, and no name.Why it matters
The next caller copies the loop a fourth time, and copies drift: two of the three already compare case-sensitively while the third does not. With a name, a reader sees which policy a spawn uses, and a change to it happens in one place.
Not a goal
scrub_agent_subprocess_env,scrub_env, or any agent spawn site.launch.py, which strips the wider_SPEC_ENV_DENIED_PREFIXESset._PYTHON_ENV_PREFIXES.What changed (motivation → approach → change)
Three copies of one rule → give the rule a name beside
scrub_env→sandbox_spawn.without_python_env(env=None)returns a copy of the environment without any_PYTHON_ENV_PREFIXESkey and with every other key kept. The terminal shell, the voice list and the third-party MCP backend spawn now call it. Thesandboxfacade forwards the new name like its siblings.src/kiro_crew/sandbox_spawn.py: the new helper, besidescrub_env.src/kiro_crew/sandbox.py: the facade's type-checking import lists it.src/kiro_crew/dashboard/handlers/terminal_shell.py,src/kiro_crew/dashboard/chat_voice.py,src/kiro_crew/mcp_gateway/daemon/launch.py: call it instead of the loop.src/kiro_crew/dashboard/handlers/terminal.py: the facade's type-checking import follows its owner.The helper compares names case-insensitively, as
launch.pyalready did. For the terminal and the voice list this can only remove more: a lower-casepythonpaththe gateway inherited. Python itself ignores lower-case names on POSIX, and Windows upper-cases environment names.It is called
without_python_env, notstrip_python_env, becausestrip_python_envis already a keyword argument on the agent spawn path, and that path means the other policy.Backwards compatibility
Compatible: each child gets the same environment as before, except the terminal and the voice list also drop lower-case spellings of the four Python keys.
Removes nothing:
_PYTHON_ENV_PREFIXESstays exported fromsandbox, and no public function or key is removed. The terminal facade's type-checking import changes from_PYTHON_ENV_PREFIXEStowithout_python_envbecausetest_terminal_facaderequires it to match what its owner modules import.Tests
test/test_sandbox_no_isolation.py::test_without_python_env_drops_only_python_settings: all four Python keys (and a lower-case one) are dropped;PYTHONUNBUFFERED,SSH_AUTH_SOCK,AWS_*,GNUPGHOME,GIT_ASKPASSsurvive; the input is not mutated.test/test_sandbox_no_isolation.py::test_without_python_env_defaults_to_os_environ: with no argument it readsos.environ.test/test_sandbox_refactor_facade.py: thesandbox_spawnowner list names the new function.test_terminal_handler.pytests still assertPYTHONPATH/PYTHONHOMEare absent whileSSH_AUTH_SOCK,AWS_*,TERMandKIROCREW_TERMINALsurvive in the terminal child.Run locally before the first push: 9 related files, 1978 passed, 1 skipped (
test_sandbox_no_isolation,test_terminal_handler,test_terminal_facade,test_chat_voice,test_mcp_gatewayd_coverage,test_mcp_cron_security,test_sandbox_refactor_facade,test_sandbox_refactor_generated_programs,test_s29_spawn_env_regression).Run locally after the rebase onto main
2e50054d2e(same patch, no conflicts): 1263 passed, 1 skipped across 7 of those files plustest_session_allocation_bindings.py::test_every_name_patched_through_the_facade_reaches_every_owner_reading_it. That node timed out on the first head's CI shard; it is flake #21671, fixed on main by #21640, and it now passes here.Run locally after each rebase onto main (
2d378bf4b6, then9d088c85ad; same patch, no conflicts): the same 7 files, 1262 passed, 1 skipped.Rebased onto main
943a4e5c0e, which carries thetest_history_bindings.pyfix from #21792 (that file failed the Windows shard on the previous head): the same 7 files plustest_history_bindings.py, 1474 passed, 1 skipped.Determinism: the two new tests passed 30/30 repeated runs, and the whole
test_sandbox_no_isolation.pyfile passed in a shuffled order (13/13). Flake-pattern ratchet: 58 passed.Manual verification
N/A — unit coverage sufficient: the change only moves an existing loop behind a name, and each call site is covered by its existing environment tests.
Related Issues
Closes #8054
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)