Repository navigation
Conversation
A desktop app launched from a development shell inherits PYTHONPATH and PYTHONHOME, so a packaged backend imports checkout code instead of the bundle it shipped, and an app update then runs a gateway that no longer matches its backend (kirodotdev#17850). buildGatewayEnvironment now takes app.isPackaged and drops both names, case-folded for Windows, on the one spawn boundary every launch and respawn passes through. Source-tree launches keep the variables: there they are how the checkout under test is found at all.
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] c3df04e Description read[DESCRIPTION-READ] 51f6b640034601d6a05c98baba3a4b828bfeb4d70cce1a0ae9f7dd2714c080e9 That sha256 names everything this verdict read: the PR description, plus the 3 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 |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] c3df04e Description read[DESCRIPTION-READ] 898d4b347da886cbd40a9a21bf5a6e1fb8938ab47e28ef1f35a3faf06aff7310 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check What this change shipsInventory (4 items) — 4 justifiedIntent: a packaged desktop app started from a dev shell runs the backend it shipped, not the checkout the shell points at. This is a FIX for #17850.
[FIRST-PRINCIPLES-REVIEWED] c3df04e Description read[DESCRIPTION-READ] 8ba2ccae0641a97711833fa783932e1bd933400edccefd2e754db652d1640927 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
|
On the First Principles note about Impact analysis for leaving it as-is in this PR: the child is Same class, worth closing: a follow-up PR that routes this child (and sweeps the other short-lived CLI children for the same inherited-env shape) through the same strip. Happy to pick that up once this lands. |
|
This stops a packaged desktop app from inheriting |
|
Closing as superseded: #17852 ("fix: isolate bundled desktop gateway from Python overrides") landed on main at 19:20 UTC — minutes before the review above — and covers the same ground: |
Problem / Motivation
Goal: A packaged desktop app launched from a development shell runs the backend it shipped, never the checkout that shell happens to point at.
Bug fix (#17850): a desktop app launched from a development shell inherits
PYTHONPATHandPYTHONHOME. When the shell spawns the bundled backend, those inherited import roots make Python load checkout code instead of the packaged backend, so after an app update the running gateway no longer matches the shipped backend and the saved-prompt URI fails essential document admission.Why it matters
Anyone who develops Kiro Crew (or any Python project) and launches the packaged desktop app from the same shell is hit: the app silently runs different code than the version it reports and signed, and the failure only surfaces later, as admission refusals that read like backend bugs. The bundled backend's value is being a known, shipped, updated artifact — inherited import roots void that.
Not a goal
PYTHONSTARTUP, user site-packages): the issue namesPYTHONPATH/PYTHONHOME, and the Windows.cmd-shim spawn already passes-s.What changed (motivation → approach → change)
Observed symptom: a packaged app launched from a dev shell imports the checkout; an update then fails saved-prompt document admission. Root cause:
buildGatewayEnvironment()pinned the encoding variables but passedPYTHONPATH/PYTHONHOMEstraight through from the parent shell. Change:buildGatewayEnvironmenttakes anisPackagedflag (defaultfalse, the pre-flag contract) and, for a packaged spawn, drops both names case-folded, because Windows honors any casing; the one owned spawn boundary ingateway-supervisor.jspassesapp.isPackaged, covering the first launch and every liveness respawn. The source-reading pin on that boundary moves with it and now requires the flag.Backwards compatibility
Compatible: the new parameter defaults to the pre-flag behavior, and the only caller (the owned gateway spawn) opts in for packaged builds; source-tree launches are byte-identical.
Removes nothing: a packaged backend never documented or supported operator-supplied import roots — inheriting them was the defect, not a capability.
Tests
node:testcases inwebsite/electron/test/gateway-env.test.js: a packaged spawn dropsPYTHONPATH/PYTHONHOMEwhile a source-tree spawn and the omitted-flag shape keep them, without mutating Electron'sprocess.env; the strip folds case, so Windows spellings (PythonPath,pYtHoNhOmE) go too.app.isPackagedas the second argument.Manual verification
End-to-end on this branch (
PYTHONPATH=/tmp/fake-checkout PYTHONHOME=/tmp/fake-homein the parent):The packaged child boots a clean interpreter with no import roots; the source-tree child still resolves the checkout, which is the development contract the issue asks to keep.
Related Issues
Fixes #17850
Pattern harvest
Rule candidate: review-prompt
Pattern: a spawned runtime inherits environment variables that redirect its module resolution (
PYTHONPATH/PYTHONHOMEhere; the same shape exists forNODE_PATH,RUBYLIB,PERL5LIB) — a packaged spawn should not inherit them.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement