Skip to content

ui-server: the host-token-fallback budget tests race a 200 ms adapter window against the worker commit #3009

Closed

Description

@schlessera

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:

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=fsync writers.
  • 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.

2026-11-10 triage at main d79eeed0a: the fixed 200 ms window this issue names is gone. #3459 (squash dacee8e7e, commit "wait for the host's budget abort instead of a fixed 200 ms") made the fake adapters race the abort signal against a 2.5 s failure maximum, and #3719 (5de219acf) removed the last 200 ms case for late (abortWindowMs, packages/ui-server/tests/ws-turn-budgets.test.ts:34; the two races at :71 and :79; the assertion at :114). The Context's :58/:66 citations are historical. What remains is the acceptance evidence: 20 consecutive runs under three fsync writers and the abort-removal mutation. If both hold, close this with those receipts; no source change is expected.

Activity

  1. added
    type: test
    area: ui-server
    agent-ready
    on Oct 26, 2026
  2. added this to the 0.45.0 milestone on Oct 26, 2026
  3. schlessera commented on Oct 26, 2026

    @schlessera
    OwnerAuthor

    Additional completed full-suite recurrence while validating #3002, with Bun 1.4.2 and frozen dependencies through the shared heavy-command wrapper:

    • Head: 21f820efc6ebac1fad92082db8cd8a636ebd2c6b; base: fd51cadf42918202fe3a68e0333ffdcecbdbcb8d.
    • bun run test packages/ui-server: 4,144 passes, four failures, 28,460 assertions, 3,585.36 seconds.
    • The actual Claude host-token-fallback case failed BUDGET_HOST_ABORTS_ACTUAL_ADAPTER at packages/ui-server/tests/ws-turn-budgets.test.ts:101, expected true / received false. The other budget cases in that run passed.
    • The other three failures are retained separately under ui-server: attribute the full-suite boot-prune timeout and mount timer residue #3020 and ui-server: attribute the recovery fixture cleanup completion failure #3021; a shared cause is not claimed.
    • Full base and unchanged-head comparisons are running. No budget source, fixture, deadline, assertion, durability level or offline guard was changed for them.
  4. added
    priority: p1
    on Nov 10, 2026
  5. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    2026-11-10 triage at main d79eeed0a: priority: p1. The issue is on the open 0.45.0 release milestone, which is the current milestone commitment. It blocks nothing.

    Delta: the fixed 200 ms window is gone. #3459 (squash dacee8e7e) made the fake adapters wait for the abort signal with a 2.5 s failure maximum, and #3719 (5de219acf) removed the last 200 ms late case (abortWindowMs, packages/ui-server/tests/ws-turn-budgets.test.ts:34). The body now records this in a dated note. What remains is the evidence the acceptance criteria ask for: 20 consecutive runs under three fsync writers, and the abort-removal mutation failing BUDGET_HOST_ABORTS_ACTUAL_ADAPTER. If both hold, this should close with those receipts and no source change. agent-ready stays for that verification.

  6. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Acceptance evidence, test-health push (epic #3855), batch e3855-ui-server-04, run th-20261110174252-07efe9#14, at the epic base 0129244ad0781c426f7d3f2363c92d8993aefaee with packages/ui-server/tests/ws-turn-budgets.test.ts unchanged, Linux 6.18 WSL2.

    1. 20 consecutive runs under three fsync writers. Three loops of dd if=/dev/zero of=<scratch>/wN bs=1M count=256 conv=fsync ran on the same filesystem as TMPDIR for the whole measurement, on a shared host whose load average was 25–45 from other workers. bun scripts/test-health.ts measure packages/ui-server/tests/ws-turn-budgets.test.ts --runs 20: 20 runs, 0 failures, verdict stable, median 53.7 s per file run. The writers were stopped afterwards.
    2. Abort-removal mutation. Removing abortController.abort(stops.budget); from the budget block in packages/ui-server/src/ws/session-run/budget.ts:91 makes bun scripts/test-health.ts mutate --test packages/ui-server/tests/ws-turn-budgets.test.ts --name "actual " --expect BUDGET_HOST_ABORTS_ACTUAL_ADAPTER report killed: the cases pass before, fail on BUDGET_HOST_ABORTS_ACTUAL_ADAPTER with the abort removed, and pass again once it is restored.

    Both acceptance criteria hold with no source or test change, as the 2026-11-10 triage note predicted. The batch PR into the epic branch says Closes #3009.

  7. schlessera commented on Nov 11, 2026

    @schlessera
    OwnerAuthor

    Delivered by #3925, which merged into epic/3855-test-health as 9c8309639 (the push in #3855). It landed in the combined merge without proof of its own; the gate, typecheck and check:pr passed on the combined branch. The epic's two exhaustive runs on dc2439551, 42996974186 and 42997012467, then passed. GitHub does not apply Closes for a pull request into a non-default branch, so I'm closing this by hand. The change reaches main with the epic's single landing pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-serverpriority: p1type: test

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions