Skip to content

ui-server: close-grace fixture times out waiting for stats during the package suite #2866

Closed as duplicate

Description

@schlessera

Context

During #2752's required bun run test packages/ui-server on head 4b07b9ae2be0e6cf9018217a6cce15384fd2f7fe (base 650caaf7447c7508fd234e7d6a2aae52fff55cf9), a read that finishes within the grace period is answered failed after 15,518.64 ms with timed out waiting for stats started at packages/ui-server/tests/close-cancels-shared-runs.test.ts:70, called from line 98. The preceding never-exiting-read case passed, as did the following writer case.

The file is byte-identical between that head and origin/main. The new app-isolation test file had not run when this failure occurred. A separate clean checkout of origin/main 650caaf7447c7508fd234e7d6a2aae52fff55cf9, with its own installed dependencies and Bun 1.4.2, passed all seven cases in this file in 27.88 seconds. This is an unresolved failure in the larger suite; the isolated main pass is a comparison, not a correction or a reproduction of the failure. No product shutdown regression or root cause is established.

The fixture detects launch by scanning /proc/*/cmdline (running, packages/ui-server/tests/close-cancels-shared-runs.test.ts:51-56). The affected stats fixture exits 500 ms after launch (function brainWithCli, packages/ui-server/tests/close-cancels-shared-runs.test.ts:38-57; affected test, same file:98-106; the start wait throws in until at line 72). Whether the larger run missed that interval or the command never reached execution remains unknown. Full local logs are retained outside the repository; no credentials or deployment details are involved.

Scope

Reproduce this failure in a bounded file-alone run under recorded load or the complete package ordering, as necessary; distinguish a missed start observation from admission/execution refusal, then correct only the evidenced cause with a failing-first receipt.

Out of scope

Acceptance criteria

  • Record a reproduction naming the actual failed assertion, source identity, execution/admission outcome and preceding test context.
  • Preserve SHARED_RUN_WITHIN_GRACE_IS_UNAFFECTED, the real process runtime, the grace-period timing check, and writer completion across close.
  • The corrected file and complete packages/ui-server suite pass offline without silently retrying the original failed observation away.
  • Demonstrate a targeted mutation or negative control that fails on the guard repaired by the implementation.

Verification

bun run test packages/ui-server/tests/close-cancels-shared-runs.test.ts, bun run test packages/ui-server, the failing-first/mutation control, and bun run check:pr --base origin/main.

Contract impact

No machine-surface change is selected. Reassess contract/changeset requirements if diagnosis requires a consumer-visible production correction.

Found while validating #2752. Needs reproduction in the larger suite; do not infer readiness from the isolated main pass.

2026-10-25 triage at main 827861e1fa71cd4a26b52f1ef0f96b849381acdf: Sorted the complete larger-suite reproduction brief as wanted unscheduled p2 work. The passing isolated comparison does not resolve needs: repro. Keep standalone at #736’s 100-child capacity.

Current-main complete release-proof recurrence — 2026-10-27

The complete pre-version bun run check:pr --all for #3030 on reviewed main 5eebfc6289f07f11106de5c6aec9b5abd9355358 now fails all three app-close cases in this file, before their close behavior assertions:

  • Never-exiting read: timed out waiting for stats started, line 70 called from line 87, 15262.11 ms.
  • Read finishing within grace: the same stats-start error, called from line 98, 15220.99 ms.
  • Writer outlasting grace: timed out waiting for add started, called from line 109, 15210.32 ms.

The complete invocation is still collecting its final counts and full log. This records actual named wait failures, not a demonstrated shutdown regression. Subsequent fixture/qualification logs in the same process report brain CLI version probe failed; continuing and worker_host_unavailable with EINVAL: invalid argument, fchown. No per-case failing-request trace yet correlates those diagnostics to these three waits, so no cause is selected. The supplied direct-client shutdown cases in the same file continue running.

Environment: Bun 1.4.2, independent frozen copyfile dependencies, SDK 0.3.293 and unchanged lock SHA-256 5bbd5f6651f111db3fcfabeda512d44a21163cba54c58993f8878012d548cc14. The only tracked edit is the Claude pricing check date. A private user/mount namespace isolates only the default maintenance ledger, with caller UID/GID preserved and capabilities dropped. That ledger was mistakenly created with mode 0755, independently causing eight default-ledger guard failures; native API controls establish rejection at 0755 and admission at 0700. The run also reproduces #3010 and separately records #3038. None of those observations establishes these waits' cause. The active run's source/environment is unchanged and retained.

Retain needs: repro. Raise priority to p1 under the blocker-priority rule because the actual complete gate blocks p1 #3030. Preserve milestone 0.45.0 pending parent release scheduling reconciliation; no silent retarget, deadline widening, skipped assertion, unchanged full retry or completion is claimed. Parent coordination owns bounded attribution, any separately reviewed correction and integration before new complete release proof.

2026-10-27 correction: added current-main complete-discovery wait failures and the exact setup/qualification caveats; existing release milestone and historical comparisons remain intact.

Final retained round-5 invocation — 2026-10-27

The complete pre-version bun run check:pr --all finished with exit 1: 16,368 pass / 28 expected skip / 27 fail, two snapshots, 607,298 assertions, 16,423 tests across 1,265 files in 3,918.90 seconds. Head and fetched main both remain 5eebfc6289f07f11106de5c6aec9b5abd9355358; only the Claude pricing check date is edited. Bun 1.4.2, SDK 0.3.293, independently copied frozen dependencies and lock SHA-256 5bbd5f6651f111db3fcfabeda512d44a21163cba54c58993f8878012d548cc14 are unchanged. Complete log SHA-256: b894c1b32b57d47530eb2cdc1d2d6cc84d671679ffbdd2dc10ce0406708a0d59.

The 28 skips are 24 opt-in paid image cases and four inverse sqlite-vec placeholders; real vector cases passed. Two planned failed diagnostic workers passed their parent evidence-handoff test and are not additional outer failures. No paid inference call or registry mutation was made. Setup/lint/leakage, metadata, pinned fonts and the first real Chrome launch/render passed. The standalone pinned browser/layout/endurance, editorial reproducibility, native probes and packed consumer stages did not execute after the failed unit tier. No versioning, post-version proof, experiment receipt or release PR exists.

The isolated ledger's original mode 0755 is retained as a preparation error. Native controls establish its exact guard refusal at 0755 and successful admission/release at 0700; they do not constitute a passing release gate or attribute unrelated symptoms. Full failure contexts and source/environment identities are retained. No unchanged full retry, assertion/deadline change or waiver replaced the failure. Parent coordination must reconcile the setup error and actual failures, preserve current scheduling rulings, and select any supported separately reviewed correction before authorizing new complete proof. Historical attribution remains open.

Final explicit bun run typecheck on the unchanged failed-proof source also exits 0 (strict tsc --noEmit); this focused result does not replace the failed complete gate. Log SHA-256: 8366207267355d3e3d5bf3bf6e8c94c5f93f6078c34f08973fa2b38cdda6cc92.

2026-11-02 source/evidence review at main a84d9bfbcb4e608b504aa0a9feb1144ad9a0b77e: Reverified the real process-liveness predicate and refreshed its moved current-source pointer. Retained the original complete-suite timeout and later passing controls without converting them into causal proof. This host lacks the native runtime required for the full app fixture; no new invocation or cleanup cause is claimed. Preserve needs: repro, p1 and milestone 0.45.0; dated release-round dispositions remain historical.

Package-suite recurrences and an isolated-file rate — 2026-10-26 (recorded 2026-11-03)

Two merged PRs recorded this failure in their proof tables. Neither PR changed this file or its fixture.

  • PR #3022 on d37185754, which contains main b99489b3c: bun run test packages/ui-server gave 4118 pass / 2 fail. Both failures were close-cancels-shared-runs timing out while waiting for the fixture's stats read to start. Run alone, the file failed once in 7 runs on that branch and 0 times in 6 runs on main, all under host load. The reporter notes that this app uses an in-memory database (DB_PATH: ":memory:" in appFor, packages/ui-server/tests/close-cancels-shared-runs.test.ts:59-67).
  • PR #3026, head 153f9ccd07c6810216b5f25b68f1917f35c7b4cc: bun run test packages/ui-server gave 4151 pass / 2 fail, including the same stats-start timeout. The other failure was a separate worker_state_busy refusal (ui-server: reference-transport tests refuse as maintenance-busy when run after other ui-server test files #2859).

So the failure can occur with the file alone under host load. It does not need the complete package discovery context. These receipts still do not separate a missed /proc start observation (the fixture CLI exits 500 ms after launch, and running polls every 25 ms) from a command that never reached execution. That correlation is still the missing evidence. To get it, repeat the file alone under recorded host load until it fails, and capture app-side admission/spawn timing for the stats request together with the poll's view of /proc.

Priority note. The p1 above was raised under the blocker-priority rule because the complete gate blocked p1 #3030. #3030 closed on 2026-11-01, and its record says this investigation was not scheduled 0.44.0 work. The milestone remains 0.45.0, and this pass leaves the priority unchanged.

Triage 2026-11-03 at main 3d3516a0247702560c09c5a0889bdec39b8313fb: added the 2026-10-26 package-suite recurrences and the isolated-file rate from #3022/#3026, refreshed moved fixture citations, and recorded that #3030 is closed. needs: repro remains; the remaining gap is the same failure correlated with spawn/admission timing.

Latest bounded investigation and remaining evidence — reconciled 2026-11-05

The 2026-11-04 investigator receipt records the following; this triage did not rerun it.

At 53b862123d7b8e4c9d039859fabdc9fc6ad4cd36, the investigator observed the stats-start timeout only after native output staging had already refused the unsupported nested-namespace environment. The correlated request returned HTTP 500 before the fixture CLI could execute. This is not the historical qualified-host/load failure or evidence of a missed 500 ms process. Later #3022/#3026 evidence permits bounded file-alone investigation under recorded load; complete package context is required only if necessary to reach the same failure. Capture request settlement, admission/spawn/exit and /proc samples in one naturally failing qualified invocation. Current labels rank this unscheduled remainder p2; milestone 0.45.0 and needs: repro remain.

Historical failures and controls retain their original identities. Keep needs: repro and no agent-ready; no new causal repair, full-suite qualification or provider/device result is claimed.

Activity

  1. added
    type: test
    area: ui-server
    needs: repro
    priority: p2
    on Oct 25, 2026
  2. schlessera commented on Oct 25, 2026

    @schlessera
    OwnerAuthor

    2026-10-25 triage at main 827861e1fa71cd4a26b52f1ef0f96b849381acdf: Sorted the complete larger-suite reproduction brief as wanted unscheduled p2 work. The passing isolated comparison does not resolve needs: repro. Keep standalone at #736’s 100-child capacity.

  3. added this to the 0.45.0 milestone on Oct 25, 2026
  4. added
    priority: p1
    and removed
    priority: p2
    on Oct 27, 2026
  5. schlessera commented on Nov 3, 2026

    @schlessera
    OwnerAuthor

    2026-11-03 triage at main 3d3516a0247702560c09c5a0889bdec39b8313fb: added the 2026-10-26 package-suite recurrences from #3022/#3026 to the body. #3022 also failed this file alone once in 7 runs under host load, which makes a bounded isolated-file repro feasible. The gap is still the same failure correlated with spawn/admission timing, so needs: repro stays.

    Priority question: p1 was raised only under the blocker-priority rule, because the gate blocked p1 #3030. #3030 is now closed, and its record calls this investigation unscheduled for 0.44.0. Nothing open is blocked by this issue. Recommendation: return it to p2 and keep milestone 0.45.0, unless 0.45.0 should commit to fixing it. I left p1 unchanged pending that ruling.

  6. added
    priority: p2
    and removed
    priority: p1
    on Nov 3, 2026
  7. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    Reproduction research — 2026-11-04 (UTC)

    Verdict: inconclusive for the reported suite/load defect; retain needs: repro. The unchanged current file produces the exact stats-start timeout here, but the correlated observation is an unsupported native worker environment, before the fixture CLI can execute. This is not evidence of a shutdown regression, a missed 500 ms /proc window, or the cause of the historical failures. No fault or load was deliberately injected.

    Inspected source and environment. HEAD and freshly fetched origin/main were both 53b862123d7b8e4c9d039859fabdc9fc6ad4cd36. Ubuntu 26.04.1, Linux x86_64 7.0.0-42-generic, 16 available CPUs, Bun 1.4.4 (38afee6c8), Node 26.13.0, bubblewrap 0.11.1, installed Claude SDK 0.3.293 (not invoked). Checkout filesystem Btrfs; /tmp tmpfs. Frozen independent copyfile install under umask 022 completed: 922 packages. Lock SHA-256 ecf6986227406c1fd9d835ae3c119d561e012df5a1bedcae599907332fc20a3e; test-file SHA-256 f01cc2b128dda389be9b311a0841bb3d54c194024c9f690a09dd7ab14104b637.

    Tests used a cleared environment, disposable HOME, existing fictional fixtures, the repository network preload, and an outer bubblewrap user/network namespace with an empty IPv4 route table. Simple outer bubblewrap execution works, but native staging's required unshare does not. Outside that wrapper, the following prerequisite also exits 1 with unshare: write failed /proc/self/uid_map: Operation not permitted:

    unshare --user --map-root-user --mount --net --ipc --uts \
      --fork --kill-child=SIGKILL /bin/true

    Observed runtime evidence. One unchanged invocation of bun run test packages/ui-server/tests/close-cancels-shared-runs.test.ts exited 1: 0 pass / 7 fail / 1 error, 91.23 s. In original file order:

    • Never-exiting read: timed out waiting for stats started, until line 72, caller line 89, 15,470.46 ms.
    • Read finishing within grace: the same exception, caller line 102, 15,258.83 ms. It follows the failed never-exiting-read case; it never reaches SHARED_RUN_WITHIN_GRACE_IS_UNAFFECTED at line 104.
    • Writer: timed out waiting for add started, caller line 113, 15,220.15 ms.
    • Direct-client cases also fail; the runtime reports WorkerHostError, errorClass: worker_host_unsupported, requirement unshare: unshare failed: Operation not permitted, at createOutputStagingStorage line 1311. No successful shutdown/cancellation/writer-completion assertion is claimed.

    One subsequent observation-only temporary copy, selecting just the grace-read case, preserves the generated CLI and existing waits/assertions and wraps the real app fetch to read a cloned response and recorded logs. It exits 1: 0 pass / 1 fail / 6 filtered out, 15.54 s; target case 15,409.63 ms. Its request returns HTTP 500 after 22.292 ms, with:

    {"error":"Agent worker boundary unavailable: unshare: unshare failed: Operation not permitted. Use a verified Linux or qualifying WSL2 host with bubblewrap and unprivileged user namespaces."}
    brain CLI version probe failed; continuing
    GET /api/brain/stats -> 500 (recorded HTTP duration: 18 ms)
    ... then: timed out waiting for stats started
    

    Expected on a qualified host: observe the 500 ms stats fixture process, close the app, receive 200 under SHARED_RUN_WITHIN_GRACE_IS_UNAFFECTED, and finish close. Observed here: output staging rejects before CLI execution, the request has already failed, and the process-start poll still waits until its original 15-second deadline. The recorded request/log error plus the real direct-client stack locate this attempt before execution: const run (packages/ui-server/src/brain/host-boundary.ts:626-648) awaits output preparation at line 634 before reaching runMaintenanceWorker at line 639; createOutputStagingStorage (packages/ui-sdk/src/server/worker-launcher.ts:1242-1312) launches the refused namespace helper. This correlation is specific to this environment; it does not attribute the historical fchown diagnostics or loaded failures.

    Repeatable commands and observer. Run from the inspected checkout after a frozen install. All authored repository files stay untouched; the observer copy is outside the tree. Resolve the actual Bun executable before replacing HOME (the first setup attempt hit a HOME-dependent runtime shim and ran no tests; that was corrected, not counted as reproduction).

    export REPRO_DIR=$(mktemp -d /tmp/odysseus-close-repro.XXXXXX)
    mkdir "$REPRO_DIR/home"
    repro_bun=$(bun -p 'process.execPath')
    repro_path="$(dirname "$repro_bun"):$PATH"
    offline_repro() {
      bwrap --bind / / --unshare-user --unshare-net --proc /proc \
        --dev-bind /dev /dev --chdir "$PWD" -- env -i \
        HOME="$REPRO_DIR/home" PATH="$repro_path" TMPDIR=/tmp LANG=C.UTF-8 \
        /bin/sh -c 'readlink /proc/self/ns/net; cat /proc/net/route; exec "$@"' repro "$@"
    }
    offline_repro bun run test \
      packages/ui-server/tests/close-cancels-shared-runs.test.ts \
      > "$REPRO_DIR/unchanged.log" 2>&1
    printf 'unchanged exit: %s\n' "$?"
    
    python3 - <<'PY'
    from pathlib import Path
    import os, re
    root = Path.cwd()
    src = root / 'packages/ui-server/tests/close-cancels-shared-runs.test.ts'
    s = re.sub(r'from "(\.[^"]+)"',
        lambda m: 'from "' + str((src.parent / m[1]).resolve()) + '"',
        src.read_text())
    s = s.replace('import { afterEach, expect, test }',
                  'import { afterAll, afterEach, expect, test, spyOn }')
    s = s.replace('const roots: string[] = [];', f'''
    import {{ hostExecution }} from "{root}/packages/ui-server/src/brain/host-boundary.ts";
    const probe = hostExecution.probe;
    const probeSpy = spyOn(hostExecution, "probe").mockImplementation((...args) => {{
      const value = probe(...args);
      console.error("REPRO_HOST_PROBE", JSON.stringify(value));
      return value;
    }});
    afterAll(() => probeSpy.mockRestore());
    const roots: string[] = [];''')
    s = s.replace('  const app = await createApp({',
        '  const observability = createRecordingObservability();\n  const app = await createApp({')
    s = s.replace('    observability: createRecordingObservability(),',
                  '    observability,')
    s = s.replace('  apps.push(app);', '''
      const fetch = app.fetch;
      app.fetch = async (...args) => {
        const at = performance.now();
        const result = await fetch(...args);
        console.error("REPRO_RESPONSE", JSON.stringify({
          elapsedMs: performance.now() - at, status: result.status,
          body: await result.clone().text(), logs: observability.logs.records()
        }));
        return result;
      };
      apps.push(app);''')
    (Path(os.environ['REPRO_DIR']) / 'observed-close.test.ts').write_text(s)
    PY
    offline_repro bun run test "$REPRO_DIR/observed-close.test.ts" \
      -t '^a read that finishes within the grace period is answered$' \
      > "$REPRO_DIR/observed.log" 2>&1
    printf 'observed exit: %s\n' "$?"
    git status --short

    The probe wrapper only forwards and observes the real probe; no REPRO_HOST_PROBE event was emitted in this selected run. The response wrapper supplies the correlation above. Filter logs before sharing; the published excerpt omits incidental generated principal IDs and local paths. Raw unchanged-run log SHA-256: 8359ee2807966c27c0586b52cc221a141e5804febd781884f9f6ecc925846dd5.

    Source/history review and limits. Read the full issue and all comment pages, the relevant #2752/#3022/#3026 receipts and #2473/#2457 lifetime rulings, and the separate #2474/#3010/#3038/#3030 records. The REST parent endpoint confirms no parent; #736 remains a reference with 100 native children, not an implied parent/blocker. Reverified function brainWithCli (lines 38–57), const running (51–56), async function until (69–74), async function appFor (59–67), and the affected test (98–106). Current source is not byte-identical to the original baseline: it has the per-suite client-fixture installation, the current CLI-version constant, and extra close-outcome assertions; the 500 ms lifetime, /proc predicate and 15-second start wait remain.

    The native prerequisite refusal prevents a meaningful complete-package or loaded admission/spawn comparison, so neither was launched. No provider call is needed for this CLI-fixture defect, and none was made. No artificial failure, production change, mutation receipt, fix, full-suite success, historical cause or readiness is claimed.

    Next step / labels. Obtain a host where both real app-worker qualification and native output staging succeed with the offline fixtures. Run a bounded original-order/file-alone investigation under recorded host load, preserving the unchanged assertion and deadline. Capture request settlement, admission/onExecute and actual CLI spawn/exit timestamps alongside the /proc poll samples on a naturally failing attempt; extend to package context if that is necessary to trigger it. That is the missing evidence separating a missed start observation from a genuinely unexecuted command on a qualified runtime. No paid/live-provider evidence is required.

    Before this comment: type: test, area: ui-server, priority: p2, needs: repro; milestone 0.45.0 (open), issue open and unassigned. Retain those labels and milestone, keep agent-ready absent. No additional product/design/human prerequisite is established by this host limitation. Checkout remains clean (git status --short empty; tracked diff empty) at the inspected SHA; temporary observer/logs and install cache are outside authored source. No assignment, closure, commit, push or PR action was taken.

  8. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    2026-11-10 triage at main 3aadc8df5: Recurrence check only; the body is unchanged. I searched the failed-job logs (gh run view <id> --log-failed) of every failed main CI run from 2026-11-01 to 2026-11-10: 28 runs, 27 with failed-job logs. None contains timed out waiting for stats. a read that finishes within the grace period is answered appears in six of them, as passes only. close-cancels-shared-runs.test.ts has not changed since the last triage, and the cited anchors (brainWithCli 38, until 69-72, the case at 98) still hold. needs: repro and p2 remain.

  9. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Test-health run th-20261110163814-571eb3 (cluster 0), at main 0129244ad: not reproduced. bun scripts/test-health.ts measure ran packages/ui-server/tests/close-cancels-shared-runs.test.ts 10 times, shuffled and together with four other ui-server files, on a local host at load average of about 37-41. All 10 runs passed, with a file median of 31.6 s; a read that finishes within the grace period is answered had a median of 2.45 s. A clean result does not show the timeout cannot happen. needs: repro stays.

  10. removed this from the 0.45.0 milestone on Nov 11, 2026
  11. schlessera commented on Nov 13, 2026

    @schlessera
    OwnerAuthor

    Closing as a duplicate of #3019. Reproduced on demand (2026-11-13); receipt, commands and the full table are in #3019.

    On main 631bbae2c, with one foreign 256 MiB reservation live in the default maintenance ledger and nothing else running, close-cancels-shared-runs.test.ts fails three cases with this issue's exact signatures: timed out waiting for stats started twice and timed out waiting for add started once, each after about 15.7 s. With no holder it passes 7 of 7.

    That points to the "command never executed" hypothesis: with the budget held, admission refuses the command, no stats or add process exists, and the fixture polls /proc for its full 15 s before reporting a timeout. The run's output does not print the refusal itself, so that step rests on the 2026-11-04 observation here (HTTP 500 in 22 ms, then the full 15 s wait). The misleading timeout is worth fixing in the fixture: it should report the response it already has.

    It also accounts for the pattern here: failures alone and in the package suite, tied to a busy shared host, never on hosted CI, where each unit worker binds a private ledger.

    The close-grace fixture is now listed in #3019's body.

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

    area: ui-serverneeds: repropriority: p2type: test

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions