Repository navigation
fix(config): stop the edition-agent lookup re-entering config load - #23782
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS The guard only changes the nested same-thread lookup, and that call already answered "none" once it hit the recursion limit. Nothing blocks. Notes
[DESIGN-REVIEWED] 9d6ffac Description read[DESCRIPTION-READ] 1f1695327ba163ce87cd77b16097b009b69db206d3b7c12bcf9594c561afb379 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix closes the config-load loop where it forms, and a new test pins it. The repository already has a peek mechanism for this same re-entry. Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: stop shard-7 config tests failing at random from runaway recursion during config load. FIX.
[FIRST-PRINCIPLES-REVIEWED] 9d6ffac Description read[DESCRIPTION-READ] 81080a3ef01d5f346aa18faf7cdf0bc338b5a1177546002ecd3cc1577186c456 That sha256 names the PR description this verdict read. 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: |
8eec2e8 to
d60673b
Compare
d60673b to
9d6ffac
Compare
|
Review-ready at 🤖 AI-assisted comment 🤖 |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (3 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: a thread-local re-entry guard in _edition_agent_names() stops the config-load recursion that made shard 7 tests fail at random, with a regression test that asserts the lookup nests only once.
Problem / Motivation
Goal: Stop
TestDanglingDefaultAgentResettests from failing at random on CI withExceptionGroup: multiple unraisable exception warnings.Backend Tests shard 7 keeps failing on PRs that touch no config code. The failing test changes from run to run (
test_a_relative_workspace_is_placed_under_the_data_home,test_the_removal_evidence_is_bounded_and_evicts_the_oldest_removals_first, and others in the same class). The log showsRecursionErrorinside pytest's unraisable hook and a half-builtPosixPath('_str','_drv').Why it matters
Every contributor whose PR lands on shard 7 can get a red run they did not cause. It has been reported on nine unrelated heads in #23427 alone, once on both attempts of one run, and reruns cost CI time and reviewer trust.
Not a goal
default_templateor the default-agent healer decides when the edition does supply an agent.gc.collect()drain that test(unraisable-leak): drain asyncio transport and PosixPath GC leaks #23466 added to the test classsetUp.test_remote_session_client.pyor the residual ontest_side_readonly_spec_reap.pynoted in Flaky: test_a_relative_workspace_is_placed_under_the_data_home (unraisable exception warnings from a sibling teardown) #23427.What changed (motivation → approach → change)
Symptom → cause. With no platform context installed,
_edition_agent_names()inconfig/loader_snapshots.pyaskscurrent_context()for the edition's agents. That call builds a context, which loads config, which reaches_edition_agent_names()again. The loop only stops at Python's recursion limit, andsafe_context_callswallows theRecursionError. On main, 13 of the 27 tests inTestDanglingDefaultAgentResetrun about 988 frames deep this way. Any GC finalizer that fires down there has no stack left, so pytest fails whichever test is running. This is the cycle #21089 describes.Change.
_edition_agent_names()now notes, per thread, that a lookup is in progress. A second lookup on the same thread answers "no edition agents". That is the same answer it already gives on an adapter error, and the answer the innermost call reached at the recursion limit before. The outer lookup still asks the real context. With the guard, the same tests peak at 48 frames and raise nothing. Theconfig/loader.pyfacade forwards the new_EDITION_LOOKUPstate like the module's other globals.Why this spot: it is the one place the loop closes, and it changes no answer the outer call gives. A guard inside
current_context()would also refuse other nested callers that work today.Backwards compatibility
Compatible: only a lookup nested inside the same lookup on the same thread changes. It answered "none" before too, after about 95 levels of recursion.
Removes nothing: no key, path, record or function is removed or narrowed.
Tests
test_the_edition_lookup_with_no_context_does_not_re_enter_itselfruns the dangling-default reset with no context installed and counts how deepcurrent_context()nests. It asserts depth 1 and that the default is still reset todefault. Without the guard it nests 95 deep.Proof: PROVEN test/test_config_loader_default_agent.py::TestDanglingDefaultAgentReset::test_the_edition_lookup_with_no_context_does_not_re_enter_itself (head 9d6ffac)
Determinism: the whole file passed 10 of 10 runs in 10 shuffled orders with
-W error::pytest.PytestUnraisableExceptionWarning. The 11 test files that usedefault_template,_edition_agent_names,_with_edition_agentsorbuiltin_agentspassed 3 of 3 runs under-n 4with the same flag (563 tests each run).Manual verification
N/A — this is test infrastructure behaviour; a per-test stack-depth probe showed 988 frames and 1–2 swallowed
RecursionErrors per affected test on main, and 48 frames and none with the fix.Related Issues
Closes #23427
Closes #23221
Part of #21089
Sibling sweep
Swept: git grep -nE "current_context()" -- src/kiro_crew/config/ src/kiro_crew/agent_discovery_parts/ src/kiro_crew/agent_discovery.py
Sibling: src/kiro_crew/agent_discovery_parts/agent_roster.py -- not affected -- reached only through _edition_agent_names when inside config load
Sibling: src/kiro_crew/config/loader.py -- not affected -- build_provider_factory takes a loaded config and is not called from load
Pattern harvest
Rule candidate: review-prompt
Pattern: a lazy-default context lookup (
current_context()) reachable from insideKiroCrewConfig.load()re-enters load; peekinstalled_context()or guard re-entry.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)