ui-server: the host-token-fallback budget tests race a 200 ms adapter window against the worker commit
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- bun, sqlite, typescript
- Domain
- testing
Research direction
Start with packages/ui-server/tests/ws-turn-budgets.test.ts around lines 58 and 66, then read packages/ui-server/src/brain/turn-budgets.ts to understand when the budget report settles and the host aborts. Replace the fixed 200 ms wait with a wait for the abort decision that has a long deadline. Run the test repeatedly; it should pass under load and fail if the host abort is removed.
Written by the indexing model from the issue text.
Description
Context
ws-turn-budgets.test.ts's "actual claude/pi completed response crosses the host token fallback and stops with budget_exceeded, preserving partial work" cases fail intermittently with BUDGET_HOST_ABORTS_ACTUAL_ADAPTER (expected true, received false).
The fixture adapter waits for the host's abort for at most 200 ms after emitting usage that crosses the budget: Bun.sleep(200) in the Promise.race after each fixture adapter emits its usage, packages/ui-server/tests/ws-turn-budgets.test.ts:58 (Claude) and :66 (Pi). Since #2896 the blocking budget report commits on the SQLite write worker (observe, packages/ui-server/src/brain/turn-budgets.ts), and the host aborts only once that commit settles. On a loaded host the commit plus the abort can take longer than 200 ms, so the adapter returns first and the test reads it as "not aborted".
Observed on 2026-10-26, running the file alone on a loaded shared host:
- main
c47483196: 2 failures in 22 runs; - an unmerged #2850 slice branch: 6 failures in 33 runs.
The full ui-server suite also failed both cases once.
Scope
Make the test wait for the host's abort decision rather than a fixed 200 ms. For example, the adapter could hold until the budget report has committed (budgets.settled() or an equivalent hook) or the turn's abort signal fires, with a long deadline. The test must still prove that the host aborts the adapter, and fails if it never does.
Out of scope
Changing how or when the host aborts a turn over budget.
Acceptance criteria
- The file passes 20 consecutive runs on a host under three
dd … conv=fsyncwriters. - A mutation that removes the host's budget abort still fails
BUDGET_HOST_ABORTS_ACTUAL_ADAPTER.
Verification
bun run test packages/ui-server/tests/ws-turn-budgets.test.ts, repeated.
Contract impact
None.
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 0
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 946
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from schlessera/brain-kit
-
agent-ready area: backends area: ui-sdk priority: p1 type: fix
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
schlessera/brain-kit#3519 · 1 comment ·
Maintainers usually reply within 1 day
-
agent-ready area: docs priority: p3 type: docs
Difficulty 1/5 Under an hour Newbie friendliness 78/100
schlessera/brain-kit#3479 ·
Maintainers usually reply within 1 day
-
agent-ready area: ci priority: p2 type: fix
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
schlessera/brain-kit#3318 ·
Maintainers usually reply within 1 day
-
agent-ready area: ui-server priority: p2 type: fix
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
schlessera/brain-kit#3259 ·
Maintainers usually reply within 1 day
-
agent-ready area: ui-kit priority: p2 type: docs
Difficulty 1/5 Under an hour Newbie friendliness 90/100
schlessera/brain-kit#3188 ·
Maintainers usually reply within 1 day
All issues in schlessera/brain-kit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vercel-labs/durable-harness#53 ·
Maintainers usually reply within 1 day
-
[Bug]: Redesign tab bars ignore clicks on Linux: hidden chat layers keep window drag regionsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
experiência: a doc manda subir para o Micro do Supabase, mas não diz que exige plano pago nem quanto custaPossibly taken A pull request linked to this issue is open or already merged. Openarea/docs area/ui enhancement
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
melgarafael/DeskcommCRM#4098 ·
Maintainers usually reply within 1 day
-
bug ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kerti/balances-v2#801 ·
Maintainers usually reply within 1 day
-
lesson-submission pending-review
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Ikalus1988/MisakaNet#4510 ·
Maintainers usually reply within 1 day