Repository navigation
test(integration): pin the scratch-root override before the boot diff - #20078
Conversation
test_a_second_boot_touches_only_known_module_globals diffs every kiro_crew module global between a baseline taken after the first boot and a snapshot taken after the second. config.paths. _scratch_root_override_pin is _UNSET until the first scratch_root() call, which allocate_scratch makes on an executor thread when a session spawns. When that first call lands between the two snapshots the pin changes and the test fails by name, so the verdict depends on timing, not on what a boot does to the home. Resolve the override at the start of the test, with the test's own monkeypatch recording the previous value, so both snapshots hold the same pin whichever boot would have resolved it first.
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] d696816 Description read[DESCRIPTION-READ] 0dd01c3596c5d3350fbb7d8f8e76b95489d0addbcdabf86faf59d4f23cedc1f6 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: |
|
Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 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: one integration test pins the scratch-root override before the boot diff, so the two snapshots compare like with like.
Problem / Motivation
Goal:
test_a_second_boot_touches_only_known_module_globalsgives the same verdict whichever test ran before it and whichever boot first resolves the scratch-root override.The test diffs every loaded module global of the package between a baseline taken after the first boot (
before = _module_globals()attest/integration/test_boot_smoke.py:553) and a snapshot taken after the second (after = _module_globals()attest/integration/test_boot_smoke.py:556).config.paths._scratch_root_override_pin(src/kiro_crew/config/paths.py:372) is_UNSETuntil the firstscratch_root()call.scratch_rootis defined atsrc/kiro_crew/agent_scratch.py:185and reads the pin throughvalid_scratch_root_override(src/kiro_crew/config/paths.py:375). The first caller isallocate_scratch(src/kiro_crew/agent_scratch.py:399), which a session spawn runs on an executor thread (src/kiro_crew/acp/launch.py:936). When the first resolve lands between the two snapshots,_UNSETbecomes('', None)and the test fails naming('kiro_crew.config.paths', '_scratch_root_override_pin'). The boots in this test only request/api/healthand nothing in the test body starts a session. I did not see a resolve land inside the window in local runs (the whole file in file order, and the file aftertest_streaming.py, which does spawn sessions), so the reproduction below forces one. The rootdirconftest.pyresets the pin to_UNSETat the start of every test (conftest.py:4088), so an earlier test does not hand this one a set pin.Why it matters
The test is the witness that keeps the integration harness's reset list honest. A failure that depends on timing makes a red Integration run look like a real home-bound global and sends the author hunting for a global no boot touched.
Not a goal
config/paths.py: the pin is a deliberate process-lifetime value (its docstring explains the time-of-use reason) and stays lazy._KNOWN_SECOND_BOOT_CHANGESfor the pin: the witness keeps comparing it, so a boot that re-pins it to a different value still fails here.test/integration/conftest.pyor the rootdirconftest.py.What changed (motivation → approach → change)
Symptom: the witness is red only when the pin's first resolve falls between its two snapshots. Cause: the pin is resolved lazily and the test does not control when. Change: the test resolves the override itself before the first boot, so both snapshots hold
('', None)and a later resolve hits the pinned value without changing it. The test's ownmonkeypatchrecords the previous value and restores it, so the test leaves the pin as it found it.The edit is inside the test body only (
test/integration/test_boot_smoke.py, one hunk, +10/-1): a local import ofkiro_crew.config.paths, amonkeypatch.setattrof the pin to_UNSET, and one call tovalid_scratch_root_override().Rejected: a row for the pin in
_KNOWN_SECOND_BOOT_CHANGES, the way #19168 listed the umask cache. The pin is the value the scratch-root symlink defence freezes (src/kiro_crew/config/paths.py:362onward), so a row would let the witness ignore a boot that repoints it. Pinning it in the test keeps the comparison; the mutant run below shows the pinned form still catches a repoint.Overlap with open PRs, read with
gh pr view: #17666 changes only the fivekiro_crew.security.argv_floorrows of_KNOWN_SECOND_BOOT_CHANGESin this file (hunk@@ -436,11 +436,11 @@); #15546 adds a test after line 150 of this file (@@ -150,6 +150,31 @@) and editstest/integration/conftest.py. This hunk (@@ -533,12 +533,21 @@) shares no line with either.Backwards compatibility
Compatible: test-only change; no production code, fixture or other test changes.
Removes nothing: the witness still compares the pin across the two boots.
Tests
In short: the changed test is green on the reproductions where the unmodified test is red.
The first resolve was forced to land inside a chosen boot with a throwaway pytest plugin (an executor-thread call to
valid_scratch_root_override()while that boot is live, asallocate_scratchmakes it). Commands run from the repo root withKIROCREW_INTEGRATION=1,-n0,-p no:randomly. The red runs are on unmodifiedorigin/mainat3665e4772f; the green runs are on that commit plus this change, then repeated on the rebased head overorigin/mainat2f5c7d58b9where noted.AssertionError: a boot changed module globals the harness neither restores nor documents ... [('kiro_crew.config.paths', '_scratch_root_override_pin')].2f5c7d58b9), first resolve inside the second boot: green 3 of 3, wholetest_boot_smoke.py: 15 passed.('kiro_crew.config.paths', '_scratch_root_override_pin'), so the pinned form still compares the pin._UNSETagain.-n0,test_boot_smoke.pyfirst, thentest_taskrunner_atomic_persistence.py,test_taskrunner_execution_capture_async.py,test_unattended_slot_guardrails.py,test_wheel_apply.py: 127 passed.test/integrationdirectory in one process at-n0: 63 passed.test_wait_discipline_ratchet.py,test_flake_pattern_ratchet.py,test_pid_reader_ratchet.py,test_tmpdir_helpers.py,test_dir_fd_create_race_ratchet.py): 127 passed.black --check,isort --check-only,flake8,mypyon the file,scripts/check_agent_sdk_boundary.py,scripts/check_comment_history.py: exit 0.Not shown red by test order alone: the rootdir
conftest.pyresets the pin to_UNSETat the start of every test, so a previous test does not leave it set at the start of this one. The red needs the first resolve to land between the two snapshots.Manual verification
N/A — the change is a test and the reproductions above are the verification.
Related Issues
None.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)