Skip to content

ui-server: root turn fixtures observe refusals through shared maintenance admission #3019

Open

Description

@schlessera

Context

Tests whose fixture uses an in-memory database admit their maintenance commands through the per-user default ledger in /tmp, shared with every other process of the same user. When another process holds that 256 MiB budget, the fixture's command is refused and the test fails on whatever depended on it.

Cause, reproduced on demand on main 631bbae2c: receipt and commands.

  • An in-memory dbPath selects no admission domain (const tempDomain, packages/ui-server/src/brain/host-boundary.ts:370), so admission uses the per-UID fallback (const directory, packages/ui-sdk/src/server/maintenance-temp-budget.ts:32).
  • createFixtureTurnHost passes dbPath: ":memory:" (const execution, tests/fixtures/turn-host-fixture.ts:15).
  • A foreign holder, sleep 86400 | bun packages/ui-server/tests/helpers/private-maintenance-test.ts --reserve, makes the unchanged tests/claude-worker.test.ts fail at its indexed-row assertion (r.indexed, :35) with Maintenance temporary storage is busy. With no holder it passes. CPU load is not needed.
  • test(root): test-health batch e3855-root-02 #3881 fixed one fixture this way: the policy-boundary probe's outer bubblewrap now has a private /tmp (tests/policy-write-boundary.test.ts:26-29). Before it, the same holder failed eight of that file's cases; after it, none.

Exposed files. A run of 1,277 of the repository's 1,587 bun test files under the same live holder found seven (table and method):

File Cases that fail under the holder
tests/claude-worker.test.ts indexed-row assertion
packages/ui-server/tests/native-worker-startup-order.test.ts 1 (scratch writable false), from #3010
packages/ui-server/tests/close-cancels-shared-runs.test.ts 3 (timed out waiting for … started), from #2866
packages/ui-server/tests/cron-scratch-prune.test.ts 3
packages/ui-server/tests/admission-sub-phases.test.ts 1
packages/ui-sdk/tests/mask-scratch.test.ts 1
packages/ui-backend-claude/tests/sdk-options-snapshot.test.ts 1, seen once; probable

packages/core and about 100 other files were not in that run.

Scope

  • Give each of the seven files admission state the test owns, so a foreign holder of the default ledger cannot refuse its commands. Two existing means: privateMaintenanceTest (packages/ui-server/tests/helpers/private-maintenance-test.ts:34), and a private /tmp for an outer bubblewrap as in test(root): test-health batch e3855-root-02 #3881.
  • For sdk-options-snapshot.test.ts, first confirm the exposure with the holder. If it does not fail in 10 runs, say so in the PR and leave the file alone.
  • In close-cancels-shared-runs.test.ts, make the wait's failure report the response the request already returned (until, :69-74), so a refusal at admission is named and the test does not burn its full 15 s poll.

Out of scope

  • Production admission and reservation lifetime, budget sizes, and the per-UID fallback.
  • Deleting or releasing a foreign reservation; retries or sleeps to get green.
  • Replacing the literal in-memory database in createFixtureTurnHost, or adding a public or configuration seam for tests.
  • The indexed-document, policy, publication and cleanup assertions in these files.
  • Files outside the seven. A new exposed file found later is a new issue.

Acceptance criteria

  • Each listed file passes with the foreign holder live and unchanged for the whole run, and with no holder. The PR records both runs per file.
  • For each isolation mechanism used, removing it from one file fails that file's named runtime assertion under the holder, and restoring it passes. The PR records the assertion.
  • Two fixture processes cannot collide through a reused test identity. An intentional same-domain over-admission still refuses, with production defaults unchanged.
  • Owned workers are joined and only owned reservations released, on success and on failure. The holder's reservation is still present after each run.
  • close-cancels-shared-runs.test.ts prints the request's response when its wait fails; shown once in the PR by running it under the holder before its isolation is added.
  • No file under packages/*/src changes.

Verification

sleep 86400 | bun packages/ui-server/tests/helpers/private-maintenance-test.ts --reserve &
bun run test tests/claude-worker.test.ts
bun run test packages/ui-server/tests/native-worker-startup-order.test.ts packages/ui-server/tests/close-cancels-shared-runs.test.ts packages/ui-server/tests/cron-scratch-prune.test.ts packages/ui-server/tests/admission-sub-phases.test.ts
bun run test packages/ui-sdk/tests/mask-scratch.test.ts packages/ui-backend-claude/tests/sdk-options-snapshot.test.ts

Stop the holder by its PID afterwards. Several of these files need unprivileged user namespaces; a host that refuses them stops the case before its assertion, which is not a pass. Run bun run check:pr --base origin/main before marking the PR ready.

Contract impact

None. Test isolation through existing boundaries.

Triage 2026-11-14 at main c82e30ae4: rewrote the brief around the demonstrated cause and the seven exposed files, with per-file criteria. Added agent-ready. type: test, priority: p2 and no milestone are unchanged. #3010 and #2866 remain closed into this issue.

Earlier brief, receipts and triage history. The sections above replace it where they differ.

Context

During the complete unfiltered root suite for #2984 / draft #3008 at ab564787211ea88b095364326b7868b752709a2e (merged main b99489b3cbe27fa739fd4d19117cab2cc78f72f3), the ordinary real-Claude integration case failed at tests/claude-worker.test.ts:35: r.indexed was [], expected [{ path: "notes/worker-raft.md" }]. Policy bytes, the authoritative Markdown application and PNG mask application had already passed their preceding assertions.

The retained application event reports:

Maintenance temporary storage is busy: this command needs 256 MiB, 1 maintenance reservations hold 256 MiB of the separate 256 MiB budget. Nothing ran. Retry after a maintenance command finishes; no agent runtime state was lost.

This is a real runtime/index-admission failure, not a test-load failure. The original reservation owner was not captured; do not attribute it to another process, a lifetime leak, host load or the HOME change. Exact command/head/base/exit and the complete failure are retained with #3008's R2 receipts. The completed full root result and the subsequent once-per-source matched complete-file controls are retained below; none replaces the original failure or establishes its reservation owner.

The source exposes a shared-state susceptibility: createFixtureTurnHost passes literal dbPath: ":memory:" to createHostExecution (const execution, tests/fixtures/turn-host-fixture.ts:15). The boundary consequently selects no maintenance tempDomain (const tempDomain, packages/ui-server/src/brain/host-boundary.ts:370), and admission uses the production per-UID fallback (const directory, packages/ui-sdk/src/server/maintenance-temp-budget.ts:32). The probe's outer bubblewrap shares the host /tmp (probe, tests/claude-worker.test.ts:6); its later query observes the missing indexed row (const indexed, tests/fixtures/claude-worker-probe.ts:146). These source facts do not establish the original holder or prove cross-process contention caused this occurrence.

Related closed #1890 and #2651 isolated other concrete maintenance fixtures; neither scope names this root Claude fixture/shared turn-host helper. Preserve those completed deliveries. This finding is separate from #2769's ambient-provider-variable note assertions and #2701's invalid mount-record guard signature.

Additional observations in the same root run

The policy-boundary fixture also calls the same in-memory helper (tests/fixtures/policy-boundary-probe.ts:434). The run reports AREAS_WRITABLE failures in Claude interactive/voice and Pi interactive, a Claude governed typed-turn refusal, missing Pi Git serialization, an explicit maintenance-busy authoritative voice-capture refusal, and a Pi internal-alias write refusal. Some symptoms directly include the same busy diagnostic; the other failures' original admission owner/complete receipt was not captured, so their cause remains unproven. Both complete files are included in the matched main/head diagnostic controls. Their tests, fixture probes, shared helper, boundary domain selection and maintenance ledger implementation are byte-unchanged from the merged main.

The scope remains the shared createFixtureTurnHost admission environment, with an inventory of its root fixture consumers. Do not treat every policy symptom as proven to share the original cause, or the deliberately failing nested unit-worker self-tests in root stdout as root-suite failures.

Out of scope

Production admission/lifetime changes, larger budgets, deleting or releasing foreign reservations, retries/sleeps to obtain green, weakening the indexed-document/policy/publication assertions, changing Claude startup policy, and adding a public/configuration seam solely for a test.

Scope

Establish the exact admission conflict for the root real-Claude fixture, then isolate independent fixture admission through test-owned process/namespace state or an existing internal fixture boundary. Preserve literal in-memory/no-operational-state behavior and the actual Claude/worker/application/index routes. Audit other consumers of createFixtureTurnHost for the same omission and scope any additional work explicitly.

Acceptance criteria

  • Retain the reported failure and one matched main/head control with source identity; distinguish an isolated pass from a causal correction.
  • In an owned private outer test environment, a separate process holds the unchanged default maintenance allowance. Gate it after fixture bootstrap so the unchanged test reaches the intended queued-index assertion and reproduces the maintenance-busy outcome, with the holder's live ownership established. If that cannot reproduce this occurrence, record the remaining factual question before choosing a repair.
  • With isolation present, the original indexed-row, protected-policy, authoritative Markdown, PNG mask, resume and descendant-cleanup assertions pass while the foreign holder remains live and unchanged. Removing only the isolation fails on the expected runtime assertion; restoration passes.
  • Distinct fixture processes cannot collide through a reused test identity. Intentional same-domain cross-process over-admission still refuses, with production defaults, budgets and ownership checks unchanged.
  • Join/drain owned workers and release only owned reservations before deleting fixture state, including failure paths. Unknown ownership remains held.

Verification

Use the repository's keyless network preload and an explicitly offline private outer harness for native CLI processes. Record failing-first/mutation/restored exact commands, source/conditions and named assertions. Run the complete Claude worker file, relevant shared-helper consumers and maintenance budget controls, the complete root ./tests suite and bun run check:pr --base origin/main via the shared heavy wrapper. A setup failure or plain retry is not isolation proof.

Contract impact

None expected: test isolation through existing boundaries. The original in-memory host and production admission contract must remain intact.

Needs reproducible ownership/timing evidence before agent-ready; no production change is requested by this report.

Completed diagnostic comparison — 2026-10-26

The complete unfiltered root run finished 1,956 pass / 10 fail across 1,966 tests. Two failures are the separately tracked #2769 note assertions; the remaining eight are the index/policy observations above. Deliberately failing nested unit-worker self-tests printed in stdout are excluded from that root failure count.

One subsequent complete-file comparison ran bun run test ./tests/claude-worker.test.ts ./tests/policy-write-boundary.test.ts once on merged main b99489b3cbe27fa739fd4d19117cab2cc78f72f3 and once on head ab564787211ea88b095364326b7868b752709a2e, serially within the existing heavy slot and with the same frozen dependencies/offline guards. Main reports 22 pass / 1 fail at the Pi interactive AREAS_WRITABLE assertion; head reports 23 pass / 0 fail. These complete-file results are retained beside the failed whole root run. They establish that one refusal signature also occurs on main, and that the head cases later pass; they do not prove the original holder/cause or that a correction was made. No guard, budget, assertion or fixture source was changed, and no full-root retry was used to replace the failed result.

The deterministic live-holder/timing control remains required before assigning a cause or selecting a fixture repair. This report does not claim the other seven original symptoms were reproduced on main.

2026-10-26 triage at main 2f10e0407769b685083c17a1c90bb43a060b94a0: Corrected the current outer-probe anchor and folded the completed-comparison status into Context. Preserve the live-holder/timing reproduction gap and p2 classification. General verification epic #736 is at its direct-child limit; remain standalone by reference.

Distinct setup-refusal observation — release round 5, 2026-10-27

The complete pre-version bun run check:pr --all on reviewed main 5eebfc6289f07f11106de5c6aec9b5abd9355358 finishes exit 1, 16,368 pass / 28 expected skip / 27 fail, 607,298 assertions, 16,423 tests in 1,265 files, 3,918.90 seconds. Complete log SHA-256: b894c1b32b57d47530eb2cdc1d2d6cc84d671679ffbdd2dc10ce0406708a0d59.

The ordinary Claude worker again fails the indexed-row assertion at tests/claude-worker.test.ts:35 (2379.29 ms), but the retained application-index event reports a different known setup refusal: maintenance admission requires an owned private directory outside the brain. The owned isolated default ledger was mistakenly created mode 0755 rather than 0700. Separate same-source native API controls reject 0755 with that exact message and admit/release at 0700, with UID/GID preserved and all capabilities zero. No foreign reservation was changed or removed. This is not reproduction or attribution of the original maintenance-busy holder.

Eight policy-boundary cases also fail in this invocation:

  • Claude interactive and Pi interactive: AREAS_WRITABLE, expected [true, true], received [false, true], at line 80. These scratch symptoms are also recorded on tests: full suites intermittently lose writable scratch #3010.
  • Claude voice: r.added has zero entries, expected one, at line 216.
  • Claude governed native write: Native writes require a governed typed turn, at line 285.
  • Pi governed: SHELL_WRITE_VISIBLE_OUTSIDE_WORKER, missing notes/shell.md, at line 287.
  • Pi governed lock: serialization is null, at line 297.
  • Governed voice capture: explicit application_failed with the same ledger-directory guard, at line 311.
  • Pi internal-alias write: PI_INTERNAL_ALIAS_LOCK, result is an error, at line 322.

Only the ordinary-Claude index and governed-voice application receipts above directly print the setup guard. The other symptoms are not assigned a common cause. The complete run also has the independently retained #3020, #3038, #2866 and #3010 observations. It is preserved, not replaced by a filtered replay. No setup/source/deadline/assertion was changed during it.

Bun 1.4.2, frozen copyfile dependencies, SDK 0.3.293 and unchanged lock SHA-256 5bbd5f6651f111db3fcfabeda512d44a21163cba54c58993f8878012d548cc14 are retained. No passing release proof, source correction, versioning, release PR or publication occurred. Preserve this issue's existing p2, needs: repro and milestone 0.45.0: this setup-error receipt does not establish a new commitment or resolve the original ownership investigation. Parent release coordination must reconcile the retained failures and correct preparation prerequisites before selecting further proof.

Main CI recurrence check (2026-11-03): in the window 2026-10-26 18:00 UTC to 2026-11-03 08:00 UTC, main CI ran 116 times; 97 runs were green and the failed-job logs of the other 19 contain no failure of the indexed-row assertion at tests/claude-worker.test.ts:35. Main CI selects affected suites, so this loosely bounds hosted recurrence; it is not a flake rate, a reproduction or a repair. The cited test, fixture helper and boundary lines are unchanged since 2026-10-26. The missing evidence is still the deterministic live-holder/timing control described in the acceptance criteria.

Triage 2026-11-03: added main-CI recurrence check; needs: repro, p2 and milestone unchanged.

Current reproduction evidence — 2026-11-04

The new bounded investigation at inspected main 53b862123d7b8e4c9d039859fabdc9fc6ad4cd36 established real two-process default-domain maintenance contention and independent state-domain admission with the live holder unchanged. Its existing budget/requeue controls passed 14 tests. Those are attributed investigator receipts, not a new execution by this body update.

The actual Claude case stopped at nested-namespace qualification before Markdown application or the indexed-row assertion. It therefore did not reproduce the reported fixture/application/index ordering. Preserve literal :memory: and the existing scope: the remaining evidence must gate an acknowledged holder after fixture bootstrap and correlate the real index admission and assertion while that holder is live. The independently demonstrated ledger conflict is not authority to choose a fixture or production correction. Keep needs: repro, no readiness, all original policy/publication/cleanup assertions and owned-only teardown. Refreshed the two current source-owner pointers; historical receipts retain their original identities.

Hosted observation, 2026-11-10 triage: the same held by: command refusal text appears in passing ui-server cases on main CI. Job 128983721784 at 4d376943c logged it twice in ws tests (scratch qualification refused, so the turn ran with scratch read-only). Job 128614069929 at 1619741f2 logged the governed profile is unavailable (worker_host_unavailable): Maintenance temporary storage is busy. So default-domain maintenance contention recurs in hosted unit shards. The log does not name the inner holder, so this is not the missing owner witness.

Triage 2026-11-10 at main 3aadc8df5: repaired three current-source pointers (const execution at turn-host-fixture.ts:15, const tempDomain at host-boundary.ts:370 after #3458, const indexed at claude-worker-probe.ts:146). The indexed-row assertion (claude-worker.test.ts:35) is unchanged. No failed main CI job from 2026-11-08 to 2026-11-10 shows it. needs: repro, p2 and 0.45.0 kept.

Test-health push evidence — 2026-11-10

Push #3855 shard e3855-root-02 at base 0129244ad, shared host at load average 30-38: tests/policy-write-boundary.test.ts failed in 5 of 10 baseline runs, one of them with the held by: command maintenance-busy refusal. Giving that probe's outer bubblewrap a private /tmp (so its in-memory turn host no longer shares the host-wide per-UID ledger) gave 20 of 20 passing runs. Open PR #3881 carries that probe-level change and says Refs #3019.

Effect on this issue: cross-process contention through the shared per-UID ledger is now a demonstrated cause for the policy-boundary probe's maintenance-busy refusal. It is not yet attributed for the ordinary-Claude indexed-row assertion (claude-worker.test.ts:35): a 20-run cluster audit at the same base failed that case once without retaining which assertion failed. tests/claude-worker.test.ts and tests/fixtures/turn-host-fixture.ts are unchanged, so the remaining scope is the shared createFixtureTurnHost consumers outside the policy-boundary probe.

Triage 2026-11-10 at main 91e54be37: folded the push receipts above. needs: repro stays for the indexed-row attribution; labels unchanged.

Deterministic reproduction — 2026-11-13

A live foreign reservation in the per-UID default ledger reproduces the indexed-row failure on demand on main 631bbae2c, with nothing else running: receipt and commands. The holder is bun packages/ui-server/tests/helpers/private-maintenance-test.ts --reserve, kept alive on its stdin. The unchanged tests/claude-worker.test.ts reaches line 35 with the holder live and fails there (r.indexed is [], application event Maintenance temporary storage is busy). It passes with no holder. The cause is cross-process contention on the shared ledger by any process of the same user, not CPU load. The same holder reproduces the eight policy-boundary failures on the tree before #3881 and none of them after it.

Folded in — 2026-11-13

Two issues are closed into this one, because the same holder reproduces their signatures on main and their fixtures are not covered by #3881:

  • tests: full suites intermittently lose writable scratch #3010, startup-order case. packages/ui-server/tests/native-worker-startup-order.test.ts, a first strict admission refreshes sealed inputs only after trusted scratch creation: scratch writable expected true, received false, in about 8 ms.
  • ui-server: close-grace fixture times out waiting for stats during the package suite #2866, close-grace cases. packages/ui-server/tests/close-cancels-shared-runs.test.ts: timed out waiting for stats started and timed out waiting for add started after about 15.7 s. The fitting reading is that the command is refused at admission, so no process appears in /proc and the fixture waits out its full 15 s poll; the run's output does not print the refusal. A fix should make that failure report the response the request already returned.

Scope and acceptance criteria above apply to these fixtures as well: isolate their admission through test-owned state, keep the foreign holder live and unchanged while they pass, and keep a removal mutation that fails on the named runtime assertion.

Triage 2026-11-13 at main 631bbae2c: added the deterministic reproduction, folded in #3010 and #2866, closed #2899, #2923, #2987 and #2988 as fixed by #3881, removed needs: repro. No milestone; priority unchanged.

Census of exposed fixtures — 2026-11-13

A run of 1,277 of the repository's 1,587 bun test files under the same live holder found seven exposed files: table and method. Beside the three already named above (tests/claude-worker.test.ts, native-worker-startup-order.test.ts, close-cancels-shared-runs.test.ts), they are:

  • packages/ui-server/tests/cron-scratch-prune.test.ts (3 cases)
  • packages/ui-server/tests/admission-sub-phases.test.ts (1 case)
  • packages/ui-sdk/tests/mask-scratch.test.ts (1 case)
  • packages/ui-backend-claude/tests/sdk-options-snapshot.test.ts (1 case, seen once; probable)

This is the audit of other consumers the scope asks for. packages/core and 100 other files were not run.

Triage 2026-11-13: added the census; scope now covers these seven files.

Activity

  1. added
    type: test
    area: ui-server
    priority: p2
    needs: repro
    on Oct 26, 2026
  2. changed the title [-]ui-server: root Claude worker fixture observes maintenance-busy during queued indexing[/-] [+]ui-server: root turn fixtures observe refusals through shared maintenance admission[/+] on Oct 26, 2026
  3. added this to the 0.45.0 milestone on Oct 26, 2026
  4. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    Reproduction triage — 2026-11-04

    Verdict: partial admission control established; the reported Claude/application/index failure is not conclusively reproduced. Retain needs: repro; do not add agent-ready.

    Inspected and tested the requested snapshot 53b862123d7b8e4c9d039859fabdc9fc6ad4cd36, without changing source. Environment: Linux 7.0.0-42-generic x86_64, UID/GID 1001/1001, Bun 1.4.2 (744846f84) selected explicitly, bubblewrap 0.11.1, installed Claude SDK 0.3.293. Dependencies were installed from the existing local cache with bun install --offline --frozen-lockfile --ignore-scripts --backend=copyfile under outer network isolation (exit 0). Lockfile SHA-256 remained ecf6986227406c1fd9d835ae3c119d561e012df5a1bedcae599907332fc20a3e. The shell's default Bun is 1.4.4; the receipts below use 1.4.2.

    Read the full issue and all comment pages (zero existing comments), confirmed the native parent endpoint returns 404 No parent issue found, and reviewed the relevant #3008, #1890, #2651 and later #3461 evidence. #736 is a reference, not this issue's native parent. No assignment, milestone or relationship change is proposed.

    Attempts and observations

    All commands below ran with the repository's network preload, empty inherited environment except the fixed PATH/LANG/TMPDIR, and an outer bwrap --unshare-net with private /tmp. No host default maintenance ledger was inspected, released or deleted. No external provider, account or deployment was used.

    1. Unchanged ordinary Claude case: bun run test ./tests/claude-worker.test.ts -t '^ordinary Claude worker' returned exit 1; 0 pass / 1 fail / 3 filtered out. Expected child exit 0; observed exit 1 at probe (tests/claude-worker.test.ts:14) with bwrap: No permissions to create a new namespace, likely because the kernel does not allow non-privileged user namespaces. Outer bubblewrap succeeds with UID/GID preserved and all five capability sets zero; a nested bubblewrap smoke command produces that same refusal. A separate unshare --user --map-current-user --net --mount smoke also refuses writing uid_map with Operation not permitted. These are setup limitations: this run never reached the probe, Markdown application or r.indexed at line 35. It is not reproduction of the reported bug, and no policy failure is attributed to maintenance contention.

    2. Independent real two-process admission control (script below): exit 0. A separate Bun process acknowledged a full unchanged 256 MiB default-domain reservation. Read-only inspection verified its acknowledged row, unreleased bytes, live PID/start/boot/PID-namespace identity and non-zombie state. A second default-domain reservation refused with exactly:

      Maintenance temporary storage is busy: this command needs 256 MiB, 1 maintenance reservations hold 256 MiB of the separate 256 MiB budget (held by: command). Nothing ran. Retry after a maintenance command finishes; no agent runtime state was lost.
      

      The existing explicit outside-brain state domain admitted at the same limits while the default holder remained live and its row byte-identical. The holder then released itself and was joined with exit 0; its row disappeared and fresh default admission/release succeeded. This proves real shared-ledger contention and existing-domain independence, not ownership/timing at the Claude fixture's application-index step. It does not select changing the fixture's literal :memory: contract as a repair.

    3. Existing controls: bun run test ./packages/ui-sdk/tests/maintenance-temp-budget.test.ts ./packages/ui-server/tests/automatic-index-requeue.test.ts returned exit 0; 14 pass / 0 fail / 85 assertions. These are admission/client controls, not launched-worker or complete-root proof. In particular ui-server: the automatic index refuses as maintenance-busy when a turn's scratch-mask query admits first #3461's later correction, delivered in 1ea260971e3f058c396ad9601be925fd279de1ea, keeps a marked automatic BrainClient.index pending on busy admission. This is not proof that ui-server: root turn fixtures observe refusals through shared maintenance admission #3019 is repaired: its fixture supplies boundaryPlanner, whose application index still directly calls boundary.run (boundaryPlanner, packages/ui-server/src/brain/application.ts:196-220).

    Source/caller audit at the inspected SHA

    The susceptibility still has source support, with drifted pointers: literal dbPath: ":memory:" is now on line 15 of tests/fixtures/turn-host-fixture.ts; const tempDomain is packages/ui-server/src/brain/host-boundary.ts:366; const directory is packages/ui-sdk/src/server/maintenance-temp-budget.ts:32. The probe's indexed-row query is now line 146, and the policy probe calls the helper at line 466. Direct helper consumers are claude-worker-probe.ts, pi-worker-probe.ts, policy-boundary-probe.ts, provider-history-host.ts, autonomous-dispatch-probe.ts, autonomous-containment-probe.ts and autonomous-runtime-probe.ts, all under tests/fixtures/. This is a source inventory; their runtime outcomes were not inferred from the admission control.

    Repeatable bounded control

    From the inspected checkout outside /tmp, with Bun 1.4.2 selected and frozen dependencies installed, save the following script as $proof/admission-control.ts. The script is an admission-only control and deliberately starts no Claude/maintenance worker. Run it and the two test commands with this outer harness; artifacts are outside authored source, and its private /tmp disappears on exit:

    proof=$(mktemp -d /tmp/odysseus-3019-XXXXXX)
    BUN=$(bun -p 'process.execPath')
    "$BUN" --version # receipt: 1.4.2
    # Save the TypeScript block below as "$proof/admission-control.ts".
    offline() {
      timeout 45s bwrap --unshare-net --bind / / --tmpfs /tmp \
        --bind "$proof" "$proof" --proc /proc --dev /dev \
        /usr/bin/env -i PATH="$(dirname "$BUN"):/usr/local/bin:/usr/bin:/bin" \
        LANG=C.UTF-8 TMPDIR=/tmp "$BUN" "$@"
    }
    offline --preload ./scripts/test-network-child-preload.ts "$proof/admission-control.ts" "$PWD"
    offline run test ./tests/claude-worker.test.ts -t '^ordinary Claude worker'
    offline run test ./packages/ui-sdk/tests/maintenance-temp-budget.test.ts ./packages/ui-server/tests/automatic-index-requeue.test.ts
    import assert from 'node:assert/strict';
    import { Database } from 'bun:sqlite';
    import { lstatSync, mkdtempSync, readFileSync, readlinkSync, rmSync } from 'node:fs';
    import { join, resolve } from 'node:path';
    const [repoArg, role] = process.argv.slice(2);
    const repo = resolve(repoArg!);
    const { reserveMaintenanceTemp, MaintenanceTempBusyError } = await import(join(repo, 'packages/ui-sdk/src/server/maintenance-temp-budget.ts'));
    const limits = { allowanceBytes: 268435456, budgetBytes: 268435456 };
    if (role === 'holder') {
      const held = reserveMaintenanceTemp(limits);
      try {
        console.log(JSON.stringify({ id: held.id, directory: held.directory }));
        await Bun.stdin.text();
      } finally { held.release(); }
      process.exit(0);
    }
    const state = mkdtempSync('/tmp/odysseus-3019-state-');
    const child = Bun.spawn([process.execPath, '--preload', join(repo, 'scripts/test-network-child-preload.ts'), import.meta.filename, repo, 'holder'], {
      cwd: repo, env: { PATH: '/usr/local/bin:/usr/bin:/bin', LANG: 'C.UTF-8' }, stdin: 'pipe', stdout: 'pipe', stderr: 'pipe',
    });
    const stderr = new Response(child.stderr).text();
    const reader = child.stdout.getReader();
    let db: Database | undefined;
    try {
      let ack = '';
      while (!ack.includes('\n')) {
        const next = await reader.read();
        assert(!next.done, 'HOLDER_ACK_BEFORE_EOF');
        ack += new TextDecoder().decode(next.value);
      }
      const reservation = JSON.parse(ack.split('\n')[0]!);
      assert.equal(lstatSync(reservation.directory).mode & 0o777, 0o700, 'PRIVATE_LEDGER_MODE');
      assert.equal(lstatSync(reservation.directory).uid, process.getuid!(), 'PRIVATE_LEDGER_UID');
      db = new Database(join(reservation.directory, 'reservations.db'), { readonly: true });
      const row = () => db!.query('SELECT id, bytes, owner, worker, released FROM reservations').all() as any[];
      const before = row();
      assert.equal(before.length, 1, 'ONE_OWNED_HOLDER');
      assert.equal(before[0].id, reservation.id, 'ACK_MATCHES_LEDGER');
      assert.equal(before[0].bytes, limits.allowanceBytes, 'UNCHANGED_ALLOWANCE');
      assert.equal(before[0].released, 0, 'HOLDER_NOT_RELEASED');
      const owner = JSON.parse(before[0].owner);
      assert.equal(owner.pid, child.pid, 'LIVE_OWNER_PID');
      const stat = readFileSync(`/proc/${child.pid}/stat`, 'utf8');
      const fields = stat.slice(stat.lastIndexOf(')') + 2).split(' ');
      assert.equal(owner.start, fields[19], 'LIVE_OWNER_START');
      assert(!['Z', 'X'].includes(fields[0]!), 'OWNER_NOT_ZOMBIE');
      assert.equal(owner.namespace, readlinkSync(`/proc/${child.pid}/ns/pid`), 'LIVE_OWNER_NAMESPACE');
      assert.equal(owner.boot, readFileSync('/proc/sys/kernel/random/boot_id', 'utf8').trim(), 'LIVE_OWNER_BOOT');
      let refusal: unknown;
      try {
        const unexpected = reserveMaintenanceTemp(limits);
        unexpected.release();
      } catch (error) { refusal = error; }
      assert(refusal instanceof MaintenanceTempBusyError, 'DEFAULT_DOMAIN_BUSY_WITH_LIVE_HOLDER');
      assert.equal(refusal.errorClass, 'worker_state_busy', 'EXPECTED_BUSY_CLASS');
      assert.equal(refusal.message, 'Maintenance temporary storage is busy: this command needs 256 MiB, 1 maintenance reservations hold 256 MiB of the separate 256 MiB budget (held by: command). Nothing ran. Retry after a maintenance command finishes; no agent runtime state was lost.', 'EXACT_BUSY_MESSAGE');
      console.log(JSON.stringify({ defaultDomain: 'refused', errorClass: refusal.errorClass, message: refusal.message, liveOwnerVerified: true }));
      const independent = reserveMaintenanceTemp(limits, { statePath: join(state, 'ui.db') });
      independent.release();
      assert.deepEqual(row(), before, 'HOLDER_UNCHANGED_DURING_INDEPENDENT_DOMAIN');
      process.kill(child.pid, 0);
      console.log('PASS DISTINCT_EXISTING_STATE_DOMAIN_ADMITS_WITH_UNCHANGED_LIVE_HOLDER');
      child.stdin.end();
      assert.equal(await child.exited, 0, 'HOLDER_JOINED_EXIT_ZERO');
      assert.equal(await stderr, '', 'HOLDER_NO_STDERR');
      assert.deepEqual(row(), [], 'OWNED_HOLDER_RELEASED');
      const restored = reserveMaintenanceTemp(limits);
      restored.release();
      assert.deepEqual(row(), [], 'POST_RELEASE_DEFAULT_ADMISSION_AND_CLEANUP');
      console.log('PASS LIVE_OWNER_START_BOOT_NAMESPACE, DEFAULT_BUSY, OWNED_RELEASE_AND_POST_RELEASE_ADMISSION');
    } finally {
      child.stdin.end();
      if (child.exitCode === null) child.kill('SIGKILL');
      await child.exited;
      await reader.cancel();
      db?.close();
      rmSync(state, { recursive: true, force: true });
    }

    Remaining evidence / next step: run the original fixture on an offline host permitting the required nested user/network/mount namespaces. Gate a separate acknowledged holder after fixture bootstrap and before its application index admission, prove it remains live at the named indexed-row assertion, and capture the application-index event alongside the live reservation. The independent admission refusal here cannot establish that timing or the historical owner. Keep production limits, :memory:, policy/Markdown/mask/resume/cleanup assertions and owned-only cleanup intact; do not retry into green or treat the October 27 mode-0755 setup refusal as the original busy failure. Full root/policy/native proof and a correction-removal/restoration test remain pending; this triage implements no correction.

    Checkout: git diff --exit-code and git status --porcelain=v1 are clean; no source mutation, fix, commit, PR, push, closure or assignment change was made. Before/after labels remain type: test, area: ui-server, priority: p2, needs: repro; milestone remains 0.45.0, issue open and unassigned.

  5. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    2026-11-10 triage at main 3aadc8df5: repaired three moved current-source pointers (turn-host-fixture.ts:15, host-boundary.ts:370, claude-worker-probe.ts:146). Added that the held by: command maintenance-busy refusal recurs in passing hosted unit shards. No failed main CI job from 2026-11-08 to 2026-11-10 shows the indexed-row assertion. needs: repro, p2 and 0.45.0 kept.

  6. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Test-health audit (run th-20261110163712-7242b8, cluster 0), 2026-11-10, at 0129244ad (integration branch epic/3855-test-health), Bun 1.4.2, non-root WSL2 host with other test workers sharing it.

    • bun scripts/test-health.ts measure tests/claude-worker.test.ts --runs 10 --shuffle --together: 20 runs, 1 failure in the in-order repeat variant, failing case "ordinary Claude worker protects policy bytes, applies and indexes permitted Markdown, masks, scratch and resumes". The tool keeps the failing case but not its output, so which assertion failed (and whether it was the indexed-row assertion at line 35) is unknown.
    • Then bun run test ./tests/claude-worker.test.ts 12 times in a row with every log kept: 12/12 pass, 0 failures.

    So the ordinary case did fail once in 20 runs here, but this run did not capture which assertion failed or why. That still leaves the live-holder/timing reproduction this issue asks for open. Verdict: unreproduced. needs: repro stays. The audit made no change to the test's assertions or timing; it only rewrote its boolean some(...) checks so a later failure prints the values.

  7. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Test-health push (#3855), shard e3855-root-02. Base 0129244ad, on a shared Linux host with load averages of 30–38 throughout.

    Baseline, unchanged file: measure tests/policy-write-boundary.test.ts --shuffle --together, 10 runs. 5 of the 10 runs failed. Failing cases and messages:

    One source of contention, confirmed. The body names the in-memory turn-host path, which falls back to the per-UID ledger at /tmp/brain-maintenance-budget-<uid> (const directory, packages/ui-sdk/src/server/maintenance-temp-budget.ts:32). The probe's outer bubblewrap ran --bind / /, so it shared the host /tmp. On this host that ledger's reservations.db is written continuously by other test processes, so the probe's maintenance admission competed with host-wide holders.

    Change (test code only, tests/policy-write-boundary.test.ts): the outer probe gets a private /tmp (--tmpfs /tmp). Only its own temporary root is bound back in. Nothing else changed: the product's per-UID fallback, every assertion, every deadline, and the shared createFixtureTurnHost helper.

    After the change: two consecutive measure --runs 5 --shuffle passes, at the same load, both clean. 20 of 20 runs passed, with every case executing its assertions.

    What this does and does not establish.

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

    @schlessera
    OwnerAuthor

    Deterministic reproduction (2026-11-13). A live foreign reservation in the per-UID default ledger reproduces this issue's indexed-row failure and the signatures of six sibling issues. Nothing else was running, so host load is not part of the cause.

    Setup. A clean 4-CPU Ubuntu 24.04 VM (Bun 1.4.2, bubblewrap, unprivileged user namespaces), main 631bbae2c. One foreign process holds the whole default-domain budget, using the helper that already exists:

    # shell 1: holds 256 MiB in /tmp/brain-maintenance-budget-<uid>, kind "command", until stdin closes
    sleep 86400 | bun packages/ui-server/tests/helpers/private-maintenance-test.ts --reserve
    # shell 2: one unchanged file at a time
    bun run test tests/claude-worker.test.ts

    The ledger row was {"bytes":268435456,"released":0,"kind":"command"} before and after every run, and the holder was still alive at the end. Each file also ran once with no holder, as the control.

    File Tree No holder Holder live
    tests/claude-worker.test.ts main 4 pass 1 fail: line 35, r.indexed is [], application event carries Maintenance temporary storage is busy
    packages/ui-server/tests/native-worker-startup-order.test.ts main 1 pass 1 fail in 8.5 ms: scratch writable expected true, received false (#3010)
    packages/ui-server/tests/close-cancels-shared-runs.test.ts main 7 pass 3 fail at about 15.7 s: timed out waiting for stats started twice, timed out waiting for add started once (#2866)
    tests/policy-write-boundary.test.ts fcc7f99ce, the parent of #3881 20 pass 8 fail (below)
    tests/policy-write-boundary.test.ts main, with #3881 20 pass 20 pass
    packages/ui-server/tests/app-state-isolation.test.ts main 2 pass 2 pass (it runs under its private ledger)

    The eight policy-boundary failures on the tree before #3881, one run:

    Case Assertion Issue
    Claude governed PreToolUse:Write hook error: Native writes require a governed typed turn. #2899
    Claude voice r.added has length 0, expected 1 #2923 (its later form)
    Pi interactive AREAS_WRITABLE, expected true, received false #2987
    Pi governed SHELL_WRITE_VISIBLE_OUTSIDE_WORKER, received ["notes/native.md"] #2988
    Claude interactive AREAS_WRITABLE #3010
    Governed voice capture application_failed: Maintenance temporary storage is busy … (held by: command) this issue
    Two governed Pi sessions serialization is null this issue's 2026-10-27 list
    Pi internal alias PI_INTERNAL_ALIAS_LOCK this issue's 2026-10-27 list

    That is the same eight-case set this body recorded on 2026-10-27, now produced on demand by one variable.

    What it settles.

    • The indexed-row assertion at tests/claude-worker.test.ts:35 fails because another process on the same UID holds the default ledger. The unchanged test reaches that assertion with the holder live, which is the witness the acceptance criteria asked for. My holder was live from before fixture bootstrap rather than gated after it; the test still reached line 35.
    • test(root): test-health batch e3855-root-02 #3881 fixed the policy-boundary probe only. claude-worker.test.ts, the startup-order fixture and the close-grace fixture still take the per-UID fallback on main.
    • It explains the correlation with a "loaded shared host": the trigger is any other test process of the same user, not CPU pressure. Hosted unit workers each bind a private ledger (scripts/unit-worker-entry.sh), which is why none of these has ever failed on main CI.

    Not explained by this cause. With the holder live, these passed unchanged on main, so their own sightings need another explanation: http-supported-mounts.test.ts (130 pass, #3574), brain-application-adapters.test.ts (#2403), turn-egress.test.ts (#2924), transcript-prefix.test.ts and output-staging-refusal.test.ts (#3007), ui-backend-claude/tests/worker.test.ts (#1902).

    Consequences. I am closing #2899, #2923, #2987 and #2988 as fixed by #3881, and folding #3010 and #2866 into this issue, since their remaining cases are this cause on fixtures #3881 did not touch. The body now lists those fixtures. needs: repro comes off: the reproduction is no longer missing. I have not added agent-ready; that is a readiness call for triage.

    A census of the root, backend and SDK suites under the same holder is running, to list every other exposed file. I will post it here.

  10. removed
    needs: repro
    on Nov 13, 2026
  11. schlessera commented on Nov 13, 2026

    @schlessera
    OwnerAuthor

    Census (2026-11-13): seven test files are exposed to a foreign holder of the default ledger. The other 1,270 I ran are not, or fail for unrelated reasons listed below.

    Method. Same holder as above, live for the whole run and verified alive at the end. Each file that failed under it was rerun with no holder, and the ones that matter were rerun both ways on a fresh VM. "Exposed" means it passes with no holder and fails with one.

    Coverage. 1,277 of the repository's 1,587 bun test files, on clean 4-CPU Ubuntu 24.04 VMs at main 631bbae2c: all of root tests/, packages/ui-sdk, packages/ui-backend-pi, packages/ui-backend-claude, the packages/ui-react runtime tests, and packages/ui-server (554 files of it in four shards: 6,357 cases passed with the holder live). Not covered, 315 files: packages/core (215), the packages/ui-react render tests (35), experiments/ (37), two module packages (26) and the native proof's own test. The Vitest browser and layout projects are outside this run.

    Exposed files.

    File Cases failing under the holder Signature
    tests/claude-worker.test.ts 1 line 35, r.indexed is []
    packages/ui-server/tests/native-worker-startup-order.test.ts 1 scratch writable false
    packages/ui-server/tests/close-cancels-shared-runs.test.ts 3 timed out waiting for stats/add started
    packages/ui-server/tests/cron-scratch-prune.test.ts 3 the three BrainUiApp.close > … boot-prune … cases, with the busy refusal in their output
    packages/ui-server/tests/admission-sub-phases.test.ts 1 GOVERNED_ADMISSION_STEPS in real governed admission records each step inside governedAdmissionMs
    packages/ui-sdk/tests/mask-scratch.test.ts 1 SYNC_QUERY_UNAVAILABLE_IS_NOT_NONIGNORED
    packages/ui-backend-claude/tests/sdk-options-snapshot.test.ts 1 SDK_OPTIONS_DRIFT_autonomous-summary, with the busy refusal in its output

    The first six were confirmed on a second VM. The last was seen in one run with a clean control on the same VM; treat it as probable until someone repeats it.

    Failed under the holder but not because of it.

    • tests/ci-build-boundary.test.ts, tests/workspace-lease.test.ts, tests/odysseus.test.ts, tests/build-repeat-observation.test.ts: they fail the same way with no holder on these VMs (no built dist, no pinned browser image).
    • packages/ui-sdk/tests/worker-pipes.test.ts and packages/ui-server/tests/dialogue-queue-adoption.test.ts: failed once inside a long run, and pass with and without the holder when run alone.
    • packages/ui-server/tests/external-speech.test.ts: failed 2 cases once with the holder and once without it, on different VMs, and passed 24 of 24 with the holder elsewhere. Unrelated to the ledger, and flaky in its own right.

    What this means for the fix. The audit the acceptance criteria asked for is this table. Seven files need test-owned admission state; the body's scope now names them.

    Three unrelated failures turned up inside the long single-process run and are worth knowing about, though I have not filed them: parallel-sessions-runtime.test.ts at 390 px (a watched session is not tracked, 2 cases), tracker-runtime.test.ts at 390 px (a reload announces nothing, received The voyage home is done.), and the duplicate exchange count now recorded in #3834.

  12. added
    agent-ready
    area: ui-sdk
    area: backends
    on Nov 14, 2026
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: backendsarea: ui-sdkarea: ui-serverpriority: p2type: test

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions