Skip to content

Flaky: test_a_second_boot_touches_only_known_module_globals: governance._CONFIRM_PATTERNS_MEMO (from #22511) is not reset between boots #22676

Closed

Description

@amadsalmon

test/integration/test_boot_smoke.py::test_a_second_boot_touches_only_known_module_globals failed on #9750 (head 1f7dbad2c4, CI merge ref including #22511):

AssertionError: a boot changed module globals the harness neither restores nor documents; add each to conftest._reset_home_bound_globals or, with its reason, to _KNOWN_SECOND_BOOT_CHANGES: [('kiro_crew.platform.governance', '_CONFIRM_PATTERNS_MEMO')]

Run: https://github.com/kirodotdev/KiroCrew/actions/runs/39546719458/job/119048406182 (62 other integration tests passed).

#22511 (merged 2026-10-21 04:53 UTC) added governance._CONFIRM_PATTERNS_MEMO, a process-wide memo of the confirm_tools patterns keyed on the config files' fingerprint and the loader cache generation. That is home-derived data, so a second boot on a new home can replace it. It is in neither conftest._reset_home_bound_globals nor _KNOWN_SECOND_BOOT_CHANGES.

It depends on test order: on main 41987ae89b the test passes alone (2 of 2 runs) and in a full local -n 2 --dist loadgroup run of test/integration, so it fails only when an earlier test in the same worker has already filled the memo.

Likely fix: reset it to None in conftest._reset_home_bound_globals, beside the other config-derived caches. Same class as #19150 (atomic_write._default_mode).

Sent by an AI agent on behalf of Amad

Activity

  1. amadsalmon commented on Oct 21, 2026

    @amadsalmon
    ContributorAuthor

    Again on #9750 head b768d68 (same _CONFIRM_PATTERNS_MEMO line): https://github.com/kirodotdev/KiroCrew/actions/runs/39552568866/job/119066769570

    The test is timing-dependent on main itself, not only through this memo. Running it alone with KIROCREW_INTEGRATION=1, 3 times each on fresh worktrees: main 41987ae89b passed 2 of 3, and the third run failed on a different global, [('kiro_crew._facade_mirror', '_INSTALLED')]. #9750 b768d68d53 gave the same pattern (2 of 3, the same _facade_mirror._INSTALLED failure). Both globals look like work a boot's background tasks may or may not finish before the second snapshot is taken.

    Sent by an AI agent on behalf of Amad

  2. added
    tier:T1Bug: behaviour does not match intent; fix keeps the design
    on Oct 21, 2026
  3. KiroCrewCaptain commented on Oct 21, 2026

    @KiroCrewCaptain
    Collaborator

    Thanks for the report. This issue has been triaged by Crew Captain and will be assigned to a maintainer, who will follow up here.

  4. amadsalmon commented on Oct 21, 2026

    @amadsalmon
    ContributorAuthor

    This hits fork PRs, not #9750's code. Fork PRs run CI on GitHub-hosted ubuntu-latest: ci.yml (the runner step's ELIGIBLE expression) sends only same-repo PRs, pushes and merge groups to CodeBuild. Since #22511 merged at 04:53 UTC:

    How it happens: before the config watcher holds a snapshot, governance._confirm_tool_patterns() rewrites the memo on every read. At boot those reads come from rebuild_agent_config, through auto_approve to may_skip_gate_now and _operator_requires_confirmation. The memo key carries config.json's stat (dev, ino, ctime, mtime, size). conftest._reset_home_bound_globals never clears it, so whenever that stat moves between the two boots' last reads, the witness flags it. Locally the change hides behind _module_globals()'s repr(value)[:200] cut when the tmp path is long. With a CI-length --basetemp, a scratch repro that bumps config.json's mtime inside boot 2 failed 3 of 3 runs. It passed 3 of 3 with this in test/integration/conftest.py:

    +from kiro_crew.platform import governance as platform_governance
    @@ def _reset_home_bound_globals
         config_live.reset_for_tests()
    +    platform_governance._CONFIRM_PATTERNS_MEMO = None

    Sent by an AI agent on behalf of Amad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

tier:T1Bug: behaviour does not match intent; fix keeps the design

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions