Repository navigation
test: keep the launch capture's default-home pin over its cleared env - #20673
Conversation
…ed environment The ACP launch capture installs a fixed parent environment with no KIROCREW_HOME and pins the default data-home resolver so nothing it drives resolves the operator's real home. The pin was entered AFTER the environment patch and exited BEFORE it, so at both edges the cleared environment was live with the real resolver behind it. A thread an earlier test on the same xdist worker left running reads the home at call time; landing in that window it resolved the real ~/.kiro/crew, and the conftest teardown check failed whichever capture test happened to be running. Enter the two default-home pins ahead of the environment patch in both the client and the runtime capture, so they unwind after it, and pin the ordering with a test that probes both edges of the environment patch. Closes #20324
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify before merge: the CI flake was never reproduced, so "Closes #20324" stands on an inferred race window. Reopen the issue if the guard fires again. [DESIGN-REVIEWED] 96b76e7 Description read[DESCRIPTION-READ] 1b064f961939cd81542efd53eef0dccd4e60e2e564291c9b7adf542fc2855329 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 |
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: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only: moves the default-home and breadcrumb pins in the ACP launch capture so they stay in force while the cleared environment is installed, and adds a test that probes both edges.
Problem / Motivation
Goal: The ACP launch capture can no longer let another thread resolve the real data home, so
test_both_physical_spawn_expressions_obey_admissionstops failing at random.Seen on #18015 (Backend Tests (3.12, 3), gw3):
test/test_windows_cleanup_capacity.py::test_both_physical_spawn_expressions_obey_admission[False-client]errors at teardown withthis test resolved the operator's REAL default data home (/home/runner/.kiro/crew). It passes locally, alone and with its whole file.Why it matters
Any PR whose shard happens to schedule this test after one that leaves a thread behind goes red on a check unrelated to its diff. The capture is shared by 17 test files, so every capture test can hit the same failure, and a real home-resolution guard firing for an unrelated reason teaches people to re-run it.
Not a goal
config_dir(),data_home()or the conftest guard.KIROCREW_HOMEinto the capture's fixed parent environment: the delta-from-parent goldens depend on it staying absent.config_dir()reads the variable and the resolver at two moments; that gap is inside production code, much narrower than the window closed here, and left as is.What changed (motivation → approach → change)
_refuse_a_resolved_real_default_homefires on a capture test, meaningpaths._resolved_homeheld the real~/.kiro/crew. That global is written only by_resolve_default_home(), i.e. a lookup with no validKIROCREW_HOME.capture()and_capture_runtime_served()intest/acp_launch_capture.pybuild their patch stack as[patch.dict(os.environ, parent_env, clear=True), <stubs...>, <default-home pin>, <breadcrumb stub>]. Entered in order and exited in reverse, the cleared environment (noKIROCREW_HOME) is live both BEFORE the pin is entered and AFTER it is exited, with the real resolver behind it. During the test the floor pin keeps every other moment safe, so these two edges are the only instants in this test where a lookup can reach the real default; a thread an earlier test on the same worker left running that callsconfig_dir()there resolves the real home. Under xdist that is ordering-dependent, which matches "passes locally"._default_home_pins(tmp_path), and both capture paths enter it ahead of the environment patch, so they unwind after it. The resolver is now pinned for every instantKIROCREW_HOMEis absent. The stubs themselves, and so every golden answer, are unchanged.Backwards compatibility
Compatible: test-only change; the same two stubs are applied, only earlier and for longer.
Removes nothing: no stub, key, file or behaviour is dropped; the pins now span a strictly larger interval.
Tests
test/test_acp_launch_goldens.py::test_the_default_home_stays_pinned_while_the_capture_environment_is_installed[client|runtime](new): wrapsunittest.mock's dict patcher and, at both edges of theos.environpatch (just after it is installed, just before it is restored), records whetherKIROCREW_HOMEis absent whilepaths._resolve_default_homeis still the real resolver. It probes rather than calls the resolver, so it never creates a home. Both arms are red onorigin/main'sacp_launch_capture.py(2 failed) and green with this change (2 passed).-n0, all green:test_acp_launch_goldens.py(44),test_windows_cleanup_capacity.py(33),test_acp_deepseek_backend.py(154),test_browser_cli_launch.py(44),test_acp_pod_home_remap.py(41).Manual verification
Traced every
_resolve_default_home()call that found the cache empty, and every home lookup made withKIROCREW_HOMEabsent, acrosstest_windows_cleanup_capacity.py. Locally, every unpinned lookup happens inside the capture on threads the capture owns, and none resolves the real home. The CI flake itself was not reproduced on this host: it needs another test's surviving thread to land in the window, so it is stated here as the mechanism the source allows, not as a reproduced run.Related Issues
Closes #20324
Pattern harvest
Rule candidate: review-prompt
Pattern: a
patch.dict(os.environ, ..., clear=True)that removes a pin variable must be entered after, and exited before, every stub that stands in for that variable; otherwise a concurrent reader sees neither.Decision for the owner
The decision is whether this flake is fixed by closing the launch capture's own unpinned window, without naming the CI thread that landed in it. This draft closes the window in the shared capture, because it is the only point in this test where a real-home lookup is possible, and it leaves hunting the stray thread to the conftest guard's next stack-recording change.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.