From d696816c01a1c57742155ca87eeba4ba5f98813c Mon Sep 17 00:00:00 2001 From: Javen Cinocca <129346815+javenciu@users.noreply.github.com> Date: Wed, 14 Oct 2026 02:32:11 +0000 Subject: [PATCH] test(integration): pin the scratch-root override before the boot diff 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. --- test/integration/test_boot_smoke.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/integration/test_boot_smoke.py b/test/integration/test_boot_smoke.py index d1964939a85..42e31351054 100644 --- a/test/integration/test_boot_smoke.py +++ b/test/integration/test_boot_smoke.py @@ -533,12 +533,21 @@ def _module_globals() -> dict[tuple[str, str], tuple[int, str]]: @pytest.mark.asyncio -async def test_a_second_boot_touches_only_known_module_globals(gateway_boot) -> None: +async def test_a_second_boot_touches_only_known_module_globals(gateway_boot, monkeypatch) -> None: """The generic witness behind the reset list: diff every loaded ``kiro_crew`` module's globals across a SECOND boot (the first warms the imports) and require each changed name to be either restored by the harness or listed in ``_KNOWN_SECOND_BOOT_CHANGES`` with its reason. A home-derived global that startup grows fails here by name.""" + from kiro_crew.config import paths as config_paths + + # The scratch-root override is validated once and pinned for the process by the first + # ``scratch_root()`` call, which a session spawn makes on an executor thread. Whether + # that call lands before the baseline or between the two snapshots depends on timing, + # not on what a boot does to the home. Settle the pin first so both snapshots hold the + # same value; the monkeypatch puts the old one back. + monkeypatch.setattr(config_paths, "_scratch_root_override_pin", config_paths._UNSET) + config_paths.valid_scratch_root_override() async with gateway_boot() as gw: await gw.get_json("/api/health", auth=False) before = _module_globals()