Repository navigation
test(acp): keep the resume lifecycle off the sensitive-path resolver pool - #20564
Conversation
…pool The [load] cases of test_runtime_cleanup_regression.py expired their 5 s wait on Windows shard 2 while the [new] cases passed beside them. load_session reads the agent spec where create_session, handed an explicit array, does not; the spec read's project-checkout scan runs the work dir through the sensitive-path fence, whose symlink resolution spawns the process-wide resolver child pool on first use. On a loaded Windows worker that cold spawn alone outlasts the bound, and whether a case pays it depends on test order, so it flaked instead of failing. The lifecycle fixture now seals the spec read at its one entry (session_mcp._agent_spec_for -> None), replacing the narrower ensure_agent_materialized seal, and asserts that nothing on this lifecycle reaches security.paths._run_resolution_bounded, so a reintroduced fence hop fails by name on every host. Bounds and assertions are unchanged. Part of #19498
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
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: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Confirm the [DESIGN-REVIEWED] f59b946 Description read[DESCRIPTION-READ] 5875a5ab095879306543e53765dfeaa3631baabcf9c101c7fa0b845ca8564b85 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: |
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: test-only change to one regression test, which stubs the agent-spec read and makes any reach into the path resolver pool fail by name.
Problem / Motivation
Goal: The two
[load]cases intest/test_runtime_cleanup_regression.pystop timing out on the Windows backend shard, on every pull request, for good.Backend Tests (Windows) (2)keeps going red on pull requests that touch nothing near this file:test_session_start_persists_new_descendants[load]test_cancelled_descendant_scan_terminates_only_failed_session[load]Both expire the 5 s
asyncio.wait_foraround the resume (rt.load_session) and fail asTimeoutError(GitHub's annotation quotes the innerCancelledErrorframe fromasyncio/locks.py:212, which is the same expiry). The[new]cases of the same tests pass in the same job. A seven-day mine over CI found the pair on 26 and 24 distinct PR branches, Windows only.Why it matters
Every author whose PR lands on that shard pays a rerun for a test about a runtime they did not touch, and the Windows job is the slow one to rerun. The red also hides real Windows regressions in this file behind "known flaky".
Not a goal
What changed (motivation → approach → change)
Symptom: only the
[load]cases expire, and only on a loaded Windows shard.Root cause:
load_sessionresolves its MCP array from the agent spec, wherecreate_sessionis handed an explicitmcp_servers=[]by this test and never reads one. #19093 sealed one half of that read, the managed-spec self-heal (ensure_agent_materialized). The other half was still live: the spec read's project-checkout scan (session_mcp._project_spec_path_for→agent_discovery.project_agent_files→security.is_sensitive_path(work_dir)) runs the test's work dir through the sensitive-path fence, whose symlink resolution is served by the process-wide resolver child pool (executors.path_resolve_executor()), spawned on first use. The resume path reaches it twice per start (the_ref_spec_snapshotpassenger andkiro_control_plane_servers). Profiled locally that first resolution is 36 ms of a 0.5 s start; on a Windows runner with four xdist workers, two freshpythonchildren plus the ~130-path anchor rebuild is seconds, and the product's own budgets for it (_PATH_RESOLVE_TIMEOUT_SECS = 2.0,_PATH_RESOLVE_REBUILD_TIMEOUT_SECS = 8.0) are already wider than the test's 5 s. Whether a given[load]case pays it depends on whether an earlier test in the same worker already warmed the pool, which is why it flakes rather than fails.Change, all in the
lifecyclefixture:session_mcp._agent_spec_for→None, in place of the narrowerensure_agent_materializedseal. The resume path is then answered "no spec" before either cost (self-heal or fence) is reached, the same shape the create path already takes with its explicit array. The unresolved-ref guard goes silent (its documentedNonecase) and the control-plane mount yields nothing, which is what the test's empty pooled array already asserted.security.paths._run_resolution_boundedraisesAssertionErrornaming the path, so a future change that reintroduces a fence hop on this lifecycle fails by name on every host, instead of only on the shard slow enough to expose it. All five tests pass under it, which is the proof that nothing else in the file reaches the pool.The bounds, the simulated kernel and every assertion are unchanged.
Backwards compatibility
Compatible: test-only change; no production code is touched.
Removes nothing: the fixture replaces one monkeypatch seal with a wider one on the same read path and adds one assertion seal; no production path, key or function changes.
Tests
Changed:
test/test_runtime_cleanup_regression.py::lifecycle(fixture). Locks in: the resume path under this lifecycle never reads an agent spec and never reaches the sensitive-path resolver pool (theAssertionErrorseal), so the[load]and[new]cases do the same amount of work inside their 5 s lost-run bounds.Determinism proof (testing-conventions § Proving a determinism fix), Linux worktree, Python 3.12.14, uv venv:
Repeats, 20 ×
-n0:Repeats, 10 ×
-n 4 --dist loadgroup --max-worker-restart=2with two sibling files as co-tenants (test/test_acp_runtime_session_start.py,test/test_runtime_cleanup_windows.py):Shuffled order (ids of the same three files,
@file):Forced condition: a throwaway
-pplugin (not committed) holds the firstsecurity.paths._resolve_on_calling_threadcall for 6 s, which is the cold resolver pool on a loaded shard.Parent (
10e53cc1, origin/main):Same shape as CI:
TimeoutErrorout of the 5 swait_for,CancelledErrorin the inner frame.Fix:
The
[force]line never prints: the resolver is not reached.Where the time went before the fix (
cProfileon the two off-loop hops only the resume path takes, cold worker):_pooled_session_servers_and_ref_spec36 ms, of which 35 ms isis_sensitive_path→_run_resolution_bounded→subprocess_pool.executor.call_op(select.selecton the child pipe); the second hop,kiro_control_plane_servers, 2 ms once the pool is warm.Gates:
python -m pytest -n0 test/test_flake_pattern_ratchet.py53 passed;test/test_wait_discipline_ratchet.py39 passed;python3 scripts/check_comment_history.pyclean;check_brand_name.py,check_black_formatting.py,isort,flake8clean;python3 scripts/local-gate.pyall selected gates passed.Manual verification
N/A — unit coverage sufficient: the fixture seal is exercised by the five tests in the file, and the forced-condition run above is the manual reproduction.
Related Issues
Part of #19498
Pattern harvest
Rule candidate: review-prompt
Pattern: a test's lost-run bound wraps a product path whose first call lazily spawns a process-wide pool (the sensitive-path resolver children); the cost lands on whichever test in the worker goes first, so it flakes by test order and host load rather than failing. Seal the pool-reaching seam in the fixture, and make the seal assert, so the next hop that reaches it fails by name.
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.