Repository navigation
Description
Context
packages/ui-server/tests/ws-ask-turn-timeout.test.ts "a pending question when the host's turn limit runs out > ask_user_form > expires at the original elapsed deadline, counting the wait, and says the host's limit ended it" failed once in hosted CI with waitFor timed out at packages/ui-server/tests/ws-ask-turn-timeout.test.ts:163 (await waitFor(() => terminal() !== undefined)). The case took 3640 ms. The sibling ask_user, ask_user_list and ask_user_rank cases passed in about 350 to 430 ms each in the same run.
- Run 41780062866, job
unit (2), for test(ui-server): join the journal's startup release before counting native sockets #3552 (a test-only change tohttp-supported-mounts.test.ts) at head35313bdfa26b84c4509e5e96a5f4a51a20f0cf88, merge checkout5ba62aa6897766bf1fcc801ebb619e457212da65(base main2fa67923d). It was the only failure among 1740 tests on that worker. - Not reproduced locally: 40 isolated runs of the file and 36 runs at 12-way parallel load all passed.
The case's turn limit is a real 300 ms timer (TIMEOUT = 300, ask after 200 ms). waitFor (packages/ui-server/tests/ws-ask-turn-timeout.test.ts:117-123) polls 600 times at 5 ms, a wall-clock budget of about 3 s. So either the terminal result frame for ask_user_form was never sent after the turn limit fired, or it took more than about 3 s on a loaded runner. Which of the two is not established.
Scope
Determine which. Capture the ordering of the turn-limit abort, the form drain and the terminal result frame in a failing invocation (forced delay or instrumentation). Then either fix the product ordering, or make the case wait on the observable completion condition under docs/process/test-waits.md instead of a wall-clock poll budget.
Out of scope
- Retries, raised poll counts or longer real-time budgets as the fix.
- Changing the 300 ms production-shaped turn limit semantics the case asserts.
Acceptance criteria
- The cause is named with a
file:linecitation from a failing invocation captured on purpose. - The case passes 30 consecutive isolated runs and the ui-server suite.
- A mutation receipt shows the case still fails if the turn limit's terminal frame is not sent for
ask_user_form.
Verification
bun test --timeout 30000 packages/ui-server/tests/ws-ask-turn-timeout.test.ts repeated, then bun run test in packages/ui-server.
Contract impact
None expected.
Activity
schlessera commentedon Nov 4, 2026
Claiming (token
c3553-d742). Branchfix/3553-ask-form-turn-limit. I'll capture the failing ordering on purpose before choosing a product or test-wait fix.fix(ui-server): refuse interactive requests raised after their turn's…
fix(ui-server): refuse interactive requests raised after their turn's…
fix(ui-server): refuse interactive requests raised after their turn's…
fix(ui-server): refuse interactive requests raised after their turn's…
schlessera commentedon Nov 4, 2026
Delivered by #3557 (squash
5d461c516, on main).Cause. The turn limit is armed at
packages/ui-server/src/ws/session-run/turn.ts:34, several awaits beforebackend.startTurn. On a loaded runner the 300 ms limit fired before the backend's question (asked 200 ms intostartTurn). The drain (packages/ui-server/src/ws/session-run/admission.ts:57) then found nothing, and the question opened afterwards was never settled. So the terminal frame was never sent; it was not merely late. Captured on purpose by adding a 150 ms delay beforestartTurnon unchanged main: abort at 167 ms, question at 367 ms, the question still pending a second later, andwaitFor timed outat the terminal wait. That is the hosted signature.Fix. Product: every interactive opener (four ask kinds, approval, location, mask) refuses a request raised after its aborted turn was drained, using the drain's reason. Test: the turn-limit case holds the host's registered limit timer on a test clock, asserts the exact boundary (299 ms no, 300 ms yes, not restarted by the question), and gains a case per ask kind for a question raised after the limit ran out.
Receipts (failing-first, mutations including AC3's form-drain mutation, 30 of 30 isolated runs, 24 concurrent single-CPU runs) are in the PR. Hosted confirmation passed in run 41815841868 at head
92f9cb2caon base86dff9e41.