Repository navigation
test: wake gateway loops only after run_gateway built its orchestrator - #34589
Conversation
The process-entry tests' fake sleep returned at once, so the hourly sweep could run while run_gateway still waited on its credentials thread. The session work-dir step then read an unbound orchestrator, swallowed the NameError and never called its stub: a race that failed Linux CI. The fake's first sleep now waits until the orchestrator is built, which is what the real hour-long sleep guarantees. Fixes #34528
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix is test-only and ties each fake first wake to the orchestrator being built, which is the condition the real hour-long sleep guarantees. [DESIGN-REVIEWED] ed432c1 Description read[DESCRIPTION-READ] d851bef8caab3e80f7ec12ce6eb31c9c2e8a0fb4f620f9b65eb36c7c14661bb3 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: |
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: |
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: the gateway process-entry test now wakes its loops only after run_gateway has built the orchestrator, removing a race in the test harness; test file only.
bolichen97
left a comment
There was a problem hiding this comment.
Approving ed432c1. Test-only change for the flaky test_gateway_process_entry (#34528). The fake asyncio.sleep now holds a task's first wake until booted is set, and booted is set when the test's GatewayOrchestrator is built. That stands for the hour a real first sleep lasts, so the hourly sweep can no longer read orchestrator before run_gateway has bound it after its credentials thread returns. The wait is bounded at 30 s, so a regression fails rather than hangs. No product code changes, and no regex. All 97 checks are green. Auto-merge is left to the author.
Problem / Motivation
Goal:
test_gateway_process_entry.pypasses the same way every run, whichever executor thread finishes first.The tests run
run_gatewaywith a fakeasynciowhose firstsleepreturns at once. That lets each hourly loop wake once. But the hourly sweep's session work-dir step readsorchestrator, andrun_gatewaybinds that only afterawait asyncio.to_thread(cfg.load_credentials). When the sweep task woke before the credentials thread returned, the step raisedNameError, its ownexcept Exceptionlogged and swallowed it, and the stub was never called.test_a_failing_step_is_logged_and_the_next_step_still_runsthen failed on Linux CI with "Called 0 times", as #34528 records.Why it matters
The flake fails Backend Tests (3.12, 3) on unrelated PRs (it hit #33713) and costs every hit a rerun. The issue author confirmed the race by making the credentials thread slow.
Not a goal
process_entry.py. In production, the first sleep is an hour, so the orchestrator is always bound by then.What changed (motivation → approach → change)
Symptom: the session work-dir stub is called 0 times. Root cause: the fake sleep did not model the real hour-long sleep, so a wake could beat boot. Change:
_OneWakeAsyncio.sleep's first wake now waits on abootedevent, with a 30s bound._seamssets that event whenGatewayOrchestratoris built, so every loop wakes after the orchestrator exists, as it does in production.Backwards compatibility
Compatible: test-only. Each loop still wakes exactly once, and every assertion is unchanged.
Removes nothing: no assertion or seam is removed.
Tests
test/test_gateway_process_entry.py: all three tests pass.cfg.load_credentialstake 0.5s on its thread fails the session-dir assertion on origin/main, and passes with this change.Proof: not provable -- test-only change
Manual verification
N/A — unit coverage sufficient: the forced-slow-credentials probe above exercises the race in both directions.
Related Issues
Fixes #34528
Sibling sweep
Swept: git grep -n "class _OneWakeAsyncio" -- test/
Siblings: none -- only this test module fakes the gateway's loop sleeps
Pattern harvest
Rule candidate: review-prompt
Pattern: a fake sleep that returns at once lets a "sleeps first" loop run before the state its real interval guaranteed
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.