Repository navigation
test(design-tweak): order the WS relay feeders by the request bytes, not a sleep - #25544
Conversation
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 Test-only change. It replaces the sleep-ordered close with a read of the relay's request followed by a half-close. That fixes the race at its root, and it takes nothing away from [DESIGN-REVIEWED] 4c29eb1 Description read[DESCRIPTION-READ] aa12c035595e9abc8a44308c6a6433f7d8f9cebd80fe54148269199e4632cb0b 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 |
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: |
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: |
…not a sleep The handshake-sanitization test's feeder answered and closed its end of the socketpair after a 50 ms sleep, without reading the relay's upgrade request. On a loaded runner the relay wrote that request into a closed peer, returned early, and the downstream read was empty. The feeder now reads the request first, answers, and half-closes. The two pump-error tests get the same read so they reach the pump they cover. The dead first feeder is removed. Fixes #14146
98b5912 to
4c29eb1
Compare
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: orders the design-tweak WS relay feeders by request bytes instead of a sleep.
Problem / Motivation
Goal:
test_set_cookie_stripped_from_101stops failing on loaded CI runners withassert '101 Switching Protocols' in ''.The test's feeder thread plays the dev server on one end of a socketpair. It sends the 101 handshake, sleeps 50 ms and closes, and never reads the relay's upgrade request. The relay writes that request first (
dev_preview.py:684). On a loaded runner the relay reaches that write after the feeder has closed, getsEPIPE, returns early, and sends nothing downstream.Why it matters
It fails PRs that never touch design-tweak (#13375 on Linux, #18150 on macOS), and each one costs a rerun.
Not a goal
Intended? / Repro
Intended? No. The 50 ms sleep is the test's only ordering, and it is not a guarantee.
Repro (read on current main
2f620d8a7c):test/test_design_tweak_relay_paths.py:664-667: the feeder sends,time.sleep(0.05),up_c.close(), with no read of the request.src/kiro_crew/apps/builtins/design_tweak/backend/dev_preview.py:684: the relay'supstream.sendall(...)of the request; itsexcept OSErrorreturns.Backend Tests (3.12, 4)for fix(acp): spell a Crew agent's tools in KAS ids so the kas backend can read files #13375 head847b476d1, and onmacOS Tests / Backend Tests (macOS) (4)for feat(subagents): let spawn_run pick the backend a sub-agent runs on #18150 head92eee63640, both at:692.What changed (motivation → approach → change)
Symptom: an empty downstream read. Cause: the feeder can close before the relay writes its request. Change: order the feeder by the bytes.
_read_relay_request(sock): reads the relay's request through\r\n\r\nwith the file's existing_recv_untillost-run bound.test_set_cookie_stripped_from_101: the feeder reads the request, sends the handshake, thenshutdown(SHUT_WR), so the pump reads handshake-then-EOF. The test closes the feeder socket after the relay returns. The dead first feeder (up_a/up_b, never handed to the relay) is removed.test_pump_sendall_oserror,test_pump_recv_oserrorandtest_trailing_frames_forwardedcopy the same send-before-read idiom.test_trailing_frames_forwardedasserts on the downstream bytes, so it can fail the same way; it now reads the request, answers, and half-closes. The two pump-error tests asserted onlyerrors == [], which held either way, but under the race they ended at the request write and never reached the pump they test. Their feeders now read the request first.Backwards compatibility
Test-only. Removes nothing in
src/.Tests
The three tests above are the change. On main the first can fail under load; after this change its ordering no longer depends on scheduling.
Proof: not provable -- other: a scheduling race; this host runs no local tests, CI runs them.
Manual verification
N/A: static gates only on this host (isort, flake8).
black --checkalready fails on this file on main in untouched lines; the new lines are black-clean.Screenshots
Why no screenshot: No visual change: test-only.
Related Issues
Fixes #14146
Sibling sweep
Swept: grep -n "time.sleep(0.05)" test/test_design_tweak_relay_paths.py
Sibling: test/test_design_tweak_relay_paths.py
test_pump_sendall_oserror-- changed hereSibling: test/test_design_tweak_relay_paths.py
test_pump_recv_oserror-- changed hereSibling: test/test_design_tweak_relay_paths.py
test_trailing_frames_forwarded(:1043) -- changed hereSibling: test/test_design_tweak_relay_paths.py
TestRelayWsPump-- not affected (already reads the request with_recv_untilbefore answering)Sibling: test/test_design_tweak_relay_paths.py
TestRelayWsIdleCap-- not affected (its feeder never closes, so the request write cannot hit a closed peer)Pattern harvest
Not generalizable: one test file's feeder idiom.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.