Repository navigation
fix(spawn): isolate the bundled interpreter from user site - #11846
Conversation
|
Intent: Make every Kiro Crew-owned child launched by the bundled interpreter use one user-site isolation policy, so ambient |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify on a Suggestions
[DESIGN-REVIEWED] 6476ae4 |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS One owned bundled-interpreter boundary is left raw: Not justified as shipped
What this change shipsInventory (10 items) — 9 justifiedIntent: stop user-site packages from shadowing the desktop bundle's shipped dependencies in Kiro Crew-owned child processes — a FIX (issue #11587).
[FIRST-PRINCIPLES-REVIEWED] 6476ae4 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
Opus 4.8 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: |
23fc35d to
dfffd74
Compare
|
CI note: |
3a76838 to
7f37bdf
Compare
7f37bdf to
bbc92e6
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
bbc92e6 to
d13bac1
Compare
d13bac1 to
7cb49ee
Compare
7cb49ee to
6476ae4
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approved after verification: PR Readiness success on this head, no active change requests or unresolved threads, mergeable against current main.
Problem / Motivation
Kiro Crew-owned children launched directly with the bundled Python interpreter could load packages from the user's site directory. A package under
~/.localcould therefore override a bundled dependency and break gateway startup or another internal service after an update.Why it matters
The desktop bundle is expected to run against its shipped dependency set. Ambient user packages make startup and repair behavior depend on machine-local state that Kiro Crew does not control.
What changed (motivation → approach → change)
Added
platform_compat.isolated_python_argv, which inserts CPython's-sflag for the bundled interpreter and parents whose user site is already unavailable. It preserves existing-s, stronger-I, attached-m…/-c…targets, interpreter option values, executable selection,PYTHONPATH, and current-directory import semantics. A non-bundled parent that allows user site keeps that policy because Kiro Crew itself may be installed there. Only callers whose launcher supplies the child's import path, or whose target is a script or entry path that does not importkiro_crewfrom the user site, setforce_isolation=True. The path-based dependency shim is one such launcher-owned path. APYTHONPATHinherited from the operator or declared by an app manifest is not, so neither case forces isolation. A module-style-m kiro_crew...child does not force isolation; the bundled interpreter still receives-sautomatically. Existing sandbox launchers keep-I -S; user scripts and project tools remain outside this contract.Routed the inventoried internal service, installer, re-exec, app backend, MCP gateway/stub, overlay, pod fallback, test harness, app-registry build, resident Piper worker, and dependency-repair boundaries through that helper. Generated MCP stubs use the isolated prefix while legacy overlays remain readable. The MCP overlay fingerprint includes the helper's effective isolation prefix, so a changed bundle or user-site policy regenerates cached argv instead of serving the previous
-sdecision. The platform compatibility system spec records the cross-cutting rule.Ownership map:
src/kiro_crew/platform_compat.pyowns argv construction and re-exec;src/kiro_crew/agent.pyandsrc/kiro_crew/mcp_discovery.pykeep managed MCP fallback and probe classification aligned.src/kiro_crew/apps/covers app backends, app MCP commands, registry builds, Dev Fleet, and app installers;src/kiro_crew/mcp_gateway/covers daemon and generated-stub launch paths.src/kiro_crew/cli.py,src/kiro_crew/cli_server.py,src/kiro_crew/computer_use/, andsrc/kiro_crew/dashboard/cover CLI fallbacks, overlay launch, and runtime installers.src/kiro_crew/piper_runtime.py,src/kiro_crew/pod/,src/kiro_crew/slack/, andsrc/kiro_crew/testing/cover the resident Piper worker, pod fallback, dependency repair, and harness children.Observed argv evidence from the isolated verification pod:
Tests
test_effective_user_site_policy_change_invalidates,test_worker_argv_follows_shared_user_site_policy, the Piper inventory case,test_ambient_pythonpath_keeps_user_site_for_uvicorn, andtest_manifest_pythonpath_keeps_user_site_for_gateway_module; the old implementation failed these cases.test_preflight_runs_after_seed_and_preserves_its_fileslocates the embedded source after-c, so an optional-sprefix cannot disable itsreplaceguard.test_a_python_backend_with_deps_launches_through_the_shimandtest_the_deps_dir_is_prepended_to_a_stdio_server_pythonpathpin the launcher-owned dependency transports.test_dash_x_falls_back_to_the_pythonpath_transportpins the unshimmable launcher-injectedPYTHONPATHcase.test_bundled_interpreter_disables_user_site_for_python_backendspins automatic-sinsertion for both ASGI and plain Python backends.scripts/local-gate.pywas not run because its stale-base selector is not authoritative for this work order. The explicit backend gate and spawn/security audits stand in for it.Manual verification
Used the disposable
kirocrew-wt-11587pod to capture the before/after process argv above and verify the gateway, gateway daemon, Dev Fleet backend, generated MCP stub, and existing-I -Ssandbox launchers.The pod's
mcp-coreandmcp-cronconsole-script processes do not display-s; they already run inside a virtual environment where Python disables the user site. The pod evidence is therefore for consistency of direct bundled-interpreter argv, not a suggestion that virtual-environment console scripts need another flag.Related Issues
Fixes #11587
Pattern harvest
Rule candidate: lint
Pattern: Kiro Crew-owned bundled-interpreter children must use the shared user-site isolation argv builder.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)