Skip to content

test: bound held-side event waits by the lost-run bound and ratchet to_thread waits - #20418

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/20345-held-side-wait-bounds
Oct 16, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/20345-held-side-wait-bounds

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The tests #20346 touched no longer depend on runner speed on either side of their waits, and no new test adds the asyncio.to_thread(<event>.wait, N) shape.

#20346 fixed the waiting side of the spec-builder nudge-pause and auto-research settlement tests. That covered half of the class. The held side of the same tests still made the same D1 bet (docs/system-specs/common/testing-conventions.md): a patched write blocks on assert <release>.wait(5) while the test drives executor-backed I/O. In two of them that I/O is real durable work:

  • test_slow_settlement_cannot_remove_resumed_replacement holds the status write while the test awaits an AutoNudge store write;
  • test_duplicate_reserves_its_name_before_populating_the_destination holds a save while the test runs a full POST /specs create.

When that I/O takes longer than 5 s, the held thread gives up first, and the test fails with a bare assert False or a 500 from the handler: the #20345 symptom again. With a one-thread default executor, both fail in 30 of 30 runs on main.

Why it matters

These two tests can still red unrelated pull requests on a slow Windows shard. Nothing stops new tests from adding the parked-wait shape #20345 traced either, because no ratchet counts it.

Not a goal

  • Migrating the existing parked-wait sites. The new detector only stops a changed file's count from growing. Lowering them is the tracked burn-down.
  • Any production change. Only tests and kiro_crew.testing change.

What changed (motivation → approach → change)

Part Change
Held-side bounds Every held-side fixed bound in test_auto_research.py and the spec_builder/tests/test_routes*.py files waits on default_timeout(), the lost-run bound. A hold the test never releases fails by name at that bound, including a hold inside a request handler or on a plain thread, which records the failure for the test to assert.
Thread pin The duplicated one_pool_thread fixtures become one pytest fixture in src/kiro_crew/testing/fixtures.py, behind its existing pytest guard. test_auto_research.py and test_routes_nudge_loops.py import it.
Ratchet test/test_flake_pattern_ratchet.py gains detector K15, K15-parked-pool-wait, for a threading.Event wait a test parks on an executor.

The release is the test's own signal, so the larger bound loosens nothing. It turns "the test never released" into a named failure. The two load-bearing tests do not get the one-thread pin, because they hold a pool thread on purpose while the test needs a second one, so with one thread they would sit out the lost-run bound.

K15 counts to_thread(<obj>.wait, ...) and run_in_executor(<any>, <obj>.wait, ...) whatever the bound: a literal, a call such as default_timeout(), or none. The parked wait holds a pool thread the code under test may need to make the event fire, so a larger bound only changes how the starvation fails. The callee is matched by its last name, so an aliased module counts too, and a name bound by from asyncio import to_thread as tt resolves to to_thread. Known misses, listed in the docstring: functools.partial, a lambda, a rebound w = ev.wait, a rebound callee, executor.submit and getattr. Like every other detector it holds each file a change touches to its count at the change's merge-base, forgives a site that moved, and is excused by # flake-ok: <reason>. The module docstring lists it with the other shapes.

Why not a stored baseline: the flake ratchet's docstring records that judging against a stored count would red a change for sites that other, already merged changes added, which is the churn the earlier per-file baseline cost this PR on every rebase. test/test_wait_discipline_ratchet.py is back to main's shape and test/to_thread_wait_baseline.txt is gone.

Backwards compatibility

Compatible. The one_pool_thread fixture is an addition, and nothing is removed from kiro_crew.testing.

Tests

  • 1-thread proof. On this head, both load-bearing tests run under an autouse one-thread executor fail at the lost-run bound, each by name: the test never released the status write and the test never released the held save. With two threads they pass. With the release removed, the duplicate test fails at 63 s with AssertionError: the test never released the held save, where it used to fail with a 500.
  • Determinism. The 17 changed or pinned tests passed 30 of 30 runs with -n 8, and 30 of 30 under 32 CPU burners.
  • Detector. K15's positive cases (positional and keyword bounds, no bound, default_timeout(), a from-import, an aliased from-import, a module alias, run_in_executor with and without a bound) each count once; its near miss (another callable, is_set, polling from the loop, a held-side wait, a docstring mention) counts nothing. The suite's mutation proof turns a blind K15 into a failed positive case. Ignoring the from-import aliases fails the aliased case (0 == 1), as does the detector at c546711.
  • Planted site. Adding await asyncio.to_thread(ev.wait, default_timeout()) to test/test_auto_research.py fails test_no_changed_file_gains_a_flaky_shape with K15-parked-pool-wait 1 > 0; removing it passes.
  • Full files. test_auto_research.py, the spec_builder/tests/test_routes*.py files, test_flake_pattern_ratchet.py, test_wait_discipline_ratchet.py and the kiro_crew.testing tests (test_testing_determinism_helpers.py, test_fixtures_helper.py) pass at -n 8 (636 passed). A bare import kiro_crew.testing with pytest blocked loads no wait helper and no fixture.
  • Local gates. isort, flake8, mypy (src/kiro_crew), the black gate and the comment-history gate pass. Semgrep 1.78.0 with the repository rules plus p/python, p/security-audit, p/secrets and p/owasp-top-ten reports 0 findings on changed lines (7 pre-existing elsewhere in those files).

Manual verification

N/A: unit coverage is enough for a test and test-helper change, proven by the one-thread runs and the mutations above.

Related Issues

Part of #20345

Follow-up to #20346 (merged): the held-side remainder, and the ratchet shape #20345 recorded as a burn-down candidate.

Pattern harvest

Rule candidate: lint
Pattern: a test parking a threading.Event wait on an executor under a fixed bound (asyncio.to_thread(<event>.wait, N), run_in_executor(<any>, <event>.wait, N)). This PR counts it as detector K15 in test/test_flake_pattern_ratchet.py, whatever the bound.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners October 14, 2026 18:26
@jeeshofone
jeeshofone requested a review from mbriones98 October 14, 2026 18:26
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 8943e2f7629ef3af21b8410e0efa2611a6df108b touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 8943e2f7629ef3af21b8410e0efa2611a6df108b via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (7 items) — 6 justified

Intent: stop the #20346-touched tests from failing on slow runners on the held side, and stop new tests from adding the parked to_thread(<event>.wait, N) shape. FIX (plus a ratchet).

  1. The held save and held status write in the two load-bearing tests now wait up to the lost-run bound and fail by name instead of assert False or a 500. — justified
  2. The other held-side bounds in test_auto_research.py and spec_builder/tests/test_routes*.py move from 5/10 s to default_timeout(), with named messages. — justified
  3. The two duplicated one_pool_thread fixtures become one pytest-only fixture in kiro_crew.testing.fixtures, with 2 consumers. — rides along: it deduplicates and is outside the frozen Goal, but it is declared and carries no harm.
  4. A new flake-ratchet class, K15-parked-pool-wait. I grepped to_thread|run_in_executor across semgrep/ and test_wait_discipline_ratchet.py on base and got 0 hits, so nothing already counts this shape. — justified
  5. The ratchet module now resolves from asyncio import … as aliases for K15. — justified
  6. A test proves the fixture really gives the loop one pool thread. — justified
  7. A test checks that a pytest-absent import of kiro_crew.testing.fixtures exposes no one_pool_thread. — justified

[FIRST-PRINCIPLES-REVIEWED] 8943e2f

Description read

[DESCRIPTION-READ] b5c49ba7e506b571c847c6b021d35a064c4afdc0390eb81cedebd683f4235b83

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 8943e2f7629ef3af21b8410e0efa2611a6df108b via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that the duplicate test fails by its own message when the hold times out: with a lost-run-sized bound, the job timeout could fire first and give no name.

[DESIGN-REVIEWED] 8943e2f

Description read

[DESCRIPTION-READ] fdb8805aa5d74ada38db556dde8b8c5c502f5346b112fe272245c2ab633814bd

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 8943e2f7629ef3af21b8410e0efa2611a6df108b via the fork AI-review pipeline; updated in place on each push.

Review details

No findings blocking merge.

FINDING — src/kiro_crew/apps/builtins/spec_builder/tests/test_routes_delete.py:47 — the joins run one after another and each t.join(timeout=default_timeout()) gets half of the 120 s --timeout. If both tombstone writers deadlock (the regression this test exists to catch), the joins add up to the whole budget, so pytest-timeout kills the test before assert not t.is_alive(), "a tombstone write deadlocked" can fail by name. On Windows that kill takes down the xdist worker and loses the run → Fix: set one deadline = time.monotonic() + default_timeout() before the loop and call t.join(max(0, deadline - time.monotonic())) for each thread.

[OPUS-REVIEWED] 8943e2f

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 8943e2f7629ef3af21b8410e0efa2611a6df108b via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8943e2f

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 14, 2026
@jeeshofone jeeshofone changed the title test: bound held-side event waits and ratchet to_thread event waits test: bound held-side event waits by the lost-run bound and ratchet parked event waits Oct 14, 2026
@jeeshofone jeeshofone changed the title test: bound held-side event waits by the lost-run bound and ratchet parked event waits test: bound held-side event waits by the lost-run bound and ratchet to_thread waits Oct 14, 2026
@jeeshofone
jeeshofone force-pushed the fix/20345-held-side-wait-bounds branch from cda3ae8 to 559d707 Compare October 14, 2026 22:02
@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Global pin: clean-merge red main and swaps (fixed)

fixed in 559d707: the single TO_THREAD_EVENT_WAIT_PIN and its must-equal check are deleted. The count is held per file in test/to_thread_wait_baseline.txt, keyed by repo-relative path, through the existing read_baseline / lowered_baseline / --write-baseline / --move.
Swap: removing a site in test/test_cli.py and planting one in test/test_chat_threads.py now fails both the rise and the stale check (it passed on cda3ae8). test_moving_a_parked_wait_to_another_file_is_caught pins it.
Merge race: two branches that each burn down a different file and lower their own line merge with exit 0, and the merged baseline passes the rise, stale and well-formed checks on the merged tree. Adjacent lines stop on a visible conflict. Two burn-downs of the same file can still leave its line one high; the stale check names that file on main, and it is the same property the existing per-file gate has.

Independent review of cda3ae8, all items on 559d707:

  • SF-1 (fixed): the two remaining held-side bounds in spec_builder/tests/test_routes.py, in test_cancelled_persistence_cannot_be_overtaken and the _remember_deleted two-writer test, wait on default_timeout(). So do the waiting side and the joins next to the second one. The plain-thread hold records its failure, and the test asserts it by name. A grep of both files for a fixed .wait(N), .wait(timeout=N) or join(timeout=N) finds none.
  • SF-2 (fixed): see above.
  • N1 (fixed): the detector also counts run_in_executor(<any>, <obj>.wait, N) and resolves plain module aliases (real_asyncio = asyncio), for this gate only, so the short-wait counts are unchanged. The re-baseline is 184 sites in 97 files: 175 to_thread (including the 2 aliased sites in test_md_notebook.py) and 9 run_in_executor (one more than the review's 8, because test_external_registry.py binds its bound to a module constant). The docstring lists the remaining known misses. Planted sites of each new shape fail.
  • N2 (fixed): the duplicate test records the hold's timeout and asserts it before duplicate.json(). With the release removed it fails at 63 s with AssertionError: the test never released the held save, where it used to fail with a 500.
  • N3: see the first-principles disposition.
  • N4 (fixed): the scan parses only the 306 of 4,286 files whose text holds .wait and one callee name. Folding the alias pass into the existing walk keeps it to one AST traversal per file. The scan measured 13.6-17 s cold at -n0. source_corpus.parsed_candidates streams only the kiro_crew package and does not reach test/, where 183 of the 184 sites are, so the four tests that read the scan carry an explicit measured pytest.mark.timeout(TREE_SCAN_TIMEOUT_SECS) (90 s), with its measurement recorded beside the constant. That is one of the two forms test: keep the whole-tree scans inside the per-test timeout #20459's tree-scan guard is set to accept.
  • N5: title left as is.

Rules matched on the changed files:

  • tests-are-deterministic and a-stopwatch-is-not-a-barrier: no new wall-clock upper bound or sleep. Every new or raised bound is the lost-run ceiling on the test's own release signal.
  • a-ratchet-may-only-tighten: the per-file stale and rise checks replace the global pin, and are strictly stronger because a cross-file swap now fails. The held-side bounds are raised only to the lost-run ceiling the rule allows, and each hold is released by its event.
  • no-test-side-effects: the scratch-repository tests write only under tmp_path.
  • prefer-subtracting-a-duplicate-mechanism: the new baseline reuses the existing reader, lowering and move code, and the duplicate pool-thread helper is deleted.
  • an-invariant-line-needs-a-mutation-pin: the swap, planted-site, alias, run_in_executor and N2 release mutations each go red.

First-pass check: R1-R8 OK

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • use_one_pool_thread: public helper with one caller (fixed, subtracted)

fixed in 559d707: kiro_crew.testing.wait.use_one_pool_thread and its direct test are deleted, so kiro_crew/testing/wait.py is unchanged from main. The two lines are inlined into the one_pool_thread fixture, which carries the guidance in its docstring and imports ThreadPoolExecutor lazily.
A bare import kiro_crew.testing with pytest blocked still loads no wait helper and exposes no one_pool_thread (test_seeded_home_importable_without_pytest). test_the_pytest_fixture_installs_it still fails if the fixture becomes a no-op.

First-pass check: R1-R8 OK

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Oct 14, 2026
@jeeshofone
jeeshofone force-pushed the fix/20345-held-side-wait-bounds branch from 559d707 to 8e5bc1e Compare October 14, 2026 23:43
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (fbca1a1) as 8e5bc1e, still one commit.

Conflict: main split the tail of spec_builder/tests/test_routes.py into test_routes_<topic>.py files (#20327), so the held-side conversions followed their tests into test_routes.py, test_routes_duplicate.py, test_routes_identity_pinning.py and test_routes_nudge_loops.py. No fixed .wait/join bound came back, and test_routes_nudge_loops.py now imports the shared one_pool_thread fixture instead of its own copy.

Baseline: total unchanged at 184 sites, now 98 files instead of 97. Main's meetings route split (#20460) moved three sites out of test/test_meetings_routes.py, so its line goes 6 to 3 and test/test_meetings_routes_lifecycle.py gains 3. Nothing else moved, and --write-baseline on the rebased tree changes no line.

git range-diff shows only the test_routes split relocation, the baseline split and the two body-visible counts. The PR body now says 98 files and names the test_routes*.py files.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 15, 2026
@jeeshofone
jeeshofone force-pushed the fix/20345-held-side-wait-bounds branch from 8e5bc1e to 6515a1c Compare October 15, 2026 03:26
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for head 6515a1c (rebased onto main 9a77e12, one commit, test-only). It answers the independent review of 8e5bc1e.

SF-1, two tree-scan timeout constants (fixed by deletion). TREE_SCAN_TIMEOUT_SECS and its four pytest.mark.timeout markers are gone from test/test_wait_discipline_ratchet.py. The module already sits in main's tree_scan_wait_discipline_ratchet xdist group, so the scan tests get the suite default today and #20459's group default once it lands. #20459 owns tree-scan budgets. Evidence:

SF-2, positive control needed a live src/ site (fixed). test_the_to_thread_scan_reads_both_trees now checks three things: the real scan finds sites, the real scanned file set covers test/ and src/**/tests, and a site planted at the first real src/**/tests path in a scratch tree is found.

  • In a scratch tree I removed the last src/ site and ran --write-baseline. The ratchet passes 66/66. The previous head's test fails that same tree with AssertionError: {'test'}.
  • A site planted in a src/**/tests file still fails test_no_file_gains_a_parked_event_wait.
  • Mutating to_thread_scanned_files so it skips src/ fails the control.

NIT, missed shapes (done). The module docstring now lists three more misses: a function alias of to_thread, a bound-method alias of run_in_executor, and executor.submit(ev.wait, N) / wrap_future(pool.submit(...)). It notes that the submit sites in the tree are pool-filling blockers, a different class. The "306 of 4,286" figure is gone.

NIT, the two-burn-down test never merges (declined). It stays as a baseline-composition test. The review ran a real git merge of two burn-downs and proved the property, and the scenario table below re-checks the baseline behaviour on this head.

Also fixed: mypy reported two errors in _Module.__init__ because alias was reused as a loop variable over renames. The variable is renamed. This only affects type checking.

Per-file baseline scenarios on this head (scratch tree, each reverted):

  • Moving a site from test_acp_frame_record.py to test_acp_seed_provenance.py fails both the rise check and the stale check.
  • --write-baseline lowers only the first file, so the rise still fails.
  • git mv plus --move of test_apple_speech.py gives 66/66.

Gates:

  • Ratchet file 30/30 normal runs at -n 4: 30 of 30 (1980 tests), with the host at load ~200 from other processes.
  • Loaded runs: one extra run with 16 burners of my own on top of that load passed 66/66, and the slowest scan took 47 s. The 32-burner pass was not run because about 64-164 foreign burners were already active; mine were killed and confirmed dead.
  • The touched files plus test_file_line_cap.py and test_source_pin_budget.py: 933 passed at -n 8.
  • isort, flake8, black and mypy pass on the changed file, and the comment-history gate passes against origin/main.
  • Semgrep 1.78.0 with semgrep/ on the 9 changed .py files: 4 results, 0 on lines this PR adds (all four blame to main).

The lanes on 8e5bc1e had two reds:

First-pass check: R1-R8 OK. AUTOSDE rules that apply to the changed test file:

  • tests-are-deterministic: no wall-clock bound was added, and a per-test timeout was removed.
  • a-ratchet-may-only-tighten: the baseline is unchanged.
  • an-invariant-line-needs-a-mutation-pin: the control is pinned by the skip-src mutation and by the old-head failure.
  • no-test-side-effects: the planted site is written under tmp_path.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Item 3: duplicate of the flake-pattern ratchet (fixed)

fixed in c546711. The parked-wait shape is now detector K15, K15-parked-pool-wait, in test/test_flake_pattern_ratchet.py (_k15_parked_pool_wait), listed in the module docstring with the other shapes. It uses that ratchet's merge-base model through scripts/ratchet_scope.py, forgives moved sites, and keeps no committed count.
Deleted: test/to_thread_wait_baseline.txt, _TO_THREAD_BASELINE_HEADER, TO_THREAD_BASELINE_FILE, risen_files / stale_files, the two-baseline --write-baseline / --move additions, the module-alias pass and their tests. git diff origin/main -- test/test_wait_discipline_ratchet.py is empty.
Kept: every held-side default_timeout() fix from #20345 and the shared one_pool_thread fixture.
Proof: K15's positive cases each count once and its near miss counts nothing; the suite's mutation proof fails a blind K15 on its positive case. Planting await asyncio.to_thread(ev.wait, default_timeout()) in test/test_auto_research.py fails test_no_changed_file_gains_a_flaky_shape with K15-parked-pool-wait 1 > 0. The PR body now describes the detector and says why there is no stored baseline.

First-pass check: R1-R8 OK. Local gates on this head: both ratchet files plus every changed test file at -n 8 (636 passed), the black gate, isort, flake8, mypy src/kiro_crew, the comment-history gate, and both PR body gates.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Watch: a call bound escapes the detector (fixed)

fixed in c546711. K15 counts to_thread(<obj>.wait, ...) and run_in_executor(<any>, <obj>.wait, ...) whatever the bound: a literal, a call such as default_timeout(), or none. Swapping 5 for default_timeout() no longer silences it, because the pool-thread grab is the counted harm. Its positive cases pin the call bound and the unbounded forms, and the planted asyncio.to_thread(ev.wait, default_timeout()) site turns the flake ratchet red. No baseline needs regenerating: the flake ratchet compares each changed file against the merge-base. A site that must stay carries # flake-ok: <reason>.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 15, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for the delta review of c546711, now at head 2063959.

  • S1 (aliased from-import of to_thread): fixed. _Module records names bound by from asyncio import ... (asyncio_names), and _k15_parked_pool_wait resolves a Name callee through that map before matching. Added from asyncio import to_thread as tt / await tt(ev.wait, 5) to K15's positives. Proof: with the detector from c546711 that case fails (0 == 1), and it also fails under a mutation that ignores the alias map (callee = func.id). At this head it passes. Rebound callees (f = asyncio.to_thread) remain a listed miss, the same as the old gate.
  • N1 (known-miss list): done. The K15 docstring names its misses: functools.partial, a lambda, a rebound w = ev.wait, a rebound callee, executor.submit and getattr. The body says the same.
  • N2 (over-count): no change. The comparison is against the merge-base with the same detector on both sides, so an over-count cannot fail an unchanged site.

Gates on this head: test/test_flake_pattern_ratchet.py, test/test_wait_discipline_ratchet.py and every changed test file passed at -n 8 (636 passed). The black gate, isort, flake8 and comment-history all report no findings. mypy reports the same pre-existing errors as before, none on the changed lines.

First-pass check: R1-R8 OK.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@jeeshofone
jeeshofone force-pushed the fix/20345-held-side-wait-bounds branch from 2063959 to 1798880 Compare October 15, 2026 20:08
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 15, 2026
…o_thread waits

The settlement tests in test_auto_research.py and the spec_builder route
tests were moved off `asyncio.to_thread(<event>.wait, N)` earlier. Their
held side still bet on the runner's speed: a patched write blocked on
`assert <release>.wait(5)` while the test drove executor-backed I/O. In
test_slow_settlement_cannot_remove_resumed_replacement and
test_duplicate_reserves_its_name_before_populating_the_destination that
I/O is a store write or a full create, so a slow runner made the held
thread give up first and the test failed with a bare assert or a 500.
With a one-thread default executor both fail every time at those lines.

Every held-side fixed bound in test_auto_research.py and the
spec_builder route tests now waits on default_timeout(), the lost-run
bound, and a hold the test never releases fails by name at that bound,
including one raised inside a request handler or a plain thread.

The one-thread executor pin moves into kiro_crew.testing as the pytest
fixture one_pool_thread (kiro_crew.testing.fixtures). Both test files
import it, so the duplicated fixtures are deleted.

test_flake_pattern_ratchet.py gains the K15 detector for the parked-wait
shape: `asyncio.to_thread(<obj>.wait, ...)` and
`loop.run_in_executor(<any>, <obj>.wait, ...)`, counted at any bound,
whether a literal, a call such as default_timeout(), or none. Callees
are matched by their last name, so an aliased asyncio module counts, and
a name bound by `from asyncio import to_thread as tt` resolves to
to_thread. Like the other detectors it holds each touched file to its
count at the change's merge-base, forgives a site that moved, and is
excused by `# flake-ok: <reason>`. No baseline is stored, so merged
changes that add sites elsewhere cannot red this one.
@jeeshofone
jeeshofone force-pushed the fix/20345-held-side-wait-bounds branch from 1798880 to 8943e2f Compare October 16, 2026 00:29
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 16, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 16, 2026 03:04

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: test (9 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: bounds test waits and adds a pytest-only one_pool_thread fixture plus a ratchet test; test helpers only.

@KiroCrewCaptain
KiroCrewCaptain merged commit 2c3a227 into kirodotdev:main Oct 16, 2026
105 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants