Skip to content

test: offline runtime placement probe exits before producing its receipt #4005

Closed

Description

@schlessera

Context

During #3711 verification at main 3f8ff29341fbe25665cea42659f92e6f3d3ccef0, bun run test:experiments fails experiments/turn-surface-runtime-placement.test.ts:5-17. Its bwrap child exits 1 before producing the placement receipt. The original report attributed that to the installed runtime; the bounded reproduction below instead identifies an earlier worker-host probe refusal before that runtime is launched. The named assertion at line 10 expects exit 0 and receives 1; the SDK reports Claude Code process exited with code 1 from the fixture worker. The test runs in a kernel network namespace, with the offline guard intact. No provider call or credential was supplied.

This is independent of the bridge-name pin repaired by #3711: the placement probe imports neither changed expectation. The 2026-11-16 reproduction identifies an outer bubblewrap AppArmor label that denies the nested worker namespaces before runtime launch. A same-byte, loopback-only two-placement control passes when that host prerequisite is satisfied; see the reproduction comment for its exact environment and limits.

Scope

Reproduce the placement failure with the installed pinned runtime; capture a concise sanitized child diagnostic and establish whether the probe, installed environment or runtime is responsible.

Out of scope

Changing bridge registrations, disabling network isolation or relaxing the exit-code and receipt assertions.

Acceptance criteria

  • Identify the first child failure with a bounded keyless reproduction.
  • Specify and implement the appropriate scoped correction, or document the exact missing prerequisite and completion evidence.
  • Preserve both placement receipts and the kernel network isolation proof.

Verification

bun run test ./experiments/turn-surface-runtime-placement.test.ts; record the actual assertion outcome and a mutation receipt for any fix.

Contract impact

None established.

First-failure attribution — 2026-11-15

At main c09454c338b6c420fedee8e1a66aa338a695bcdd, with frozen dependencies, Bun 1.4.4, agent SDK 0.3.293 and Claude Code 2.1.293, bun run test ./experiments/turn-surface-runtime-placement.test.ts exits 1 at the original line-10 assertion: 0 pass / 1 fail. The outer kernel network namespace and repository offline guards remain in place; no provider credential or request is used.

A temporary diagnostic in the isolated archive’s deferredWorkerSpawn catch reveals WorkerHostError, errorClass: worker_host_unsupported, from (requiredWorkerHost, packages/ui-sdk/src/server/worker-launcher.ts:1924-1932), through requireWorkerHostAsync and (spawnNow, packages/ui-backend-claude/src/worker-spawn.ts:140-146). The inner bubblewrap probe reports No permissions to create a new namespace. This occurs during worker preparation, before the copied CLI executes. Adding only the SDK stderr callback did not reveal that preparation error. Both temporary diagnostics were restored; no product/harness correction was made.

The host directly accepts bwrap --unshare-user --unshare-net --ro-bind / / --proc /proc --dev /dev /bin/true (exit 0). The same inner command under the test’s outer bwrap --unshare-net --bind / / --proc /proc --dev /dev fails with the namespace refusal (exit 1). This narrows the local failure to the nested boundary; it does not prove that user namespaces are globally disabled or that the original author’s machine has the same cause. Further controls at 14:13 UTC kept the same inner command and added --unshare-user --unshare-net or --unshare-all to the outer namespace. Both also exited 1 with the same inner namespace refusal. Merely adding an outer user namespace did not repair this local prerequisite; neither control ran a placement or produced runtime-serialization evidence. The wrapper’s generic SDK exit hides the earlier preparation failure; the original assertion remains red, with no placement receipt.

Current correction and completion evidence

The 2026-11-16 reproduction comment supplies the missing first cause and a passing two-placement receipt. The scoped correction is an early nested-worker-host precondition in experiments/fixtures/runtime-placement-probe.ts:10-21, using the launcher's real workerHostBoundary.probeAsync (packages/ui-sdk/src/server/worker-launcher.ts:1933-1941) inside the existing outer offline namespace. On refusal, identify the missing namespace prerequisite, retain its diagnostic and report the current AppArmor label when available. The experiment must still fail rather than skip, and a qualified host must still execute both original placements and all receipt assertions.

Add a controlled failing-first/restored check of that diagnostic. Document the prerequisite under the experiment-tier testing instructions. Do not change host security configuration, network isolation, worker launch policy, exit assertions or runtime bytes. Broader capture-harness diagnostics and host snapshot behavior are outside this correction.

Priority p2: unscheduled verification follow-up. Remains standalone: #736’s outcome fits, but its native direct-child list is already at GitHub’s 100-child limit; no new grouping or reparenting is authorized in this pass. This is an environment/repro requirement, not an account/login or reserved human-only action.

2026-11-15 follow-up triage at main c09454c338b6c420fedee8e1a66aa338a695bcdd: Reproduced the reported exit and exposed the pre-runtime nested worker-namespace refusal with direct/nested controls. Retained needs: repro for actual two-placement qualification, sorted p2 and preserved all offline/worker guards.

2026-11-15, 14:13 UTC bounded follow-up at unchanged main c09454c338b6c420fedee8e1a66aa338a695bcdd: Recorded two additional outer-namespace controls; both retain the earlier inner-boundary failure. The qualified-host/two-placement requirement and needs: repro remain. No guard, host configuration or product source was changed.

2026-11-16 readiness reconciliation: folded the maintainer's reproduced nested-namespace prerequisite and qualified two-placement control into the current specification; the narrow correction is ready for implementation. Historical failed controls remain evidence of their stated environments.

Activity

  1. added
    type: test
    area: ci
    needs: repro
    on Nov 15, 2026
  2. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Triage — 2026-11-15. The line-10 failure reproduces. Temporary diagnostics identify an earlier worker_host_unsupported namespace-probe failure; the copied CLI never launches in this local case. A direct bubblewrap control succeeds while the same inner command under the test’s outer offline namespace fails. The body now records this distinction and the exact missing two-placement evidence. Keep needs: repro and p2; no guard was bypassed and no runtime-placement result is claimed.

  3. added
    priority: p2
    on Nov 15, 2026
  4. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Additional local evidence from #3787 (2026-11-15): bun run test packages/ui-backend-claude/tests/provider-history.test.ts also exits at captureOffline's child-exit assertion before producing a capture. The generic SDK diagnostic is process_exited_nonzero, exit 1. The same failure reproduces from an unchanged source archive of main c09454c338b6c420fedee8e1a66aa338a695bcdd with its own frozen dependency install. A second run using an owned disk-backed temporary directory has the same outcome. No isolation or worker guard was relaxed, and no external provider was contacted. This is analogous to this issue's hidden preparation failure; these controls do not independently establish the underlying cause. The four host-authority provider-history tests pass locally.

  5. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Additional local verification evidence from #3790 (2026-11-15): the complete Claude backend suite has the same failing-test names with the archive timestamp fix present and with both touched archive files restored to base 3988a9bf9aab8c3730ca8e1228a63c169d17cab8. Changed tree: 809 pass / 8 skip / 51 fail / 1 error; base control: 807 pass / 8 skip / 51 fail / 1 error. The two extra passing cases are the new archive regressions. Both runs preserve the offline preload and native boundary guards. Representative local diagnostic is WorkerHostError, worker_host_unsupported, with unshare: write failed /proc/self/uid_map: Operation not permitted; several SDK fixtures expose only the generic child exit described here. This is comparison evidence, not attribution of every failure to this issue or a claim that the full suite passes. Hosted candidate/main proof remains required; no harness or guard was weakened.

  6. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Reproduction — 2026-11-16

    Three agents on different models worked this independently, then cross-reviewed each other's write-ups. All three converged on the same first cause, and it was reproduced in both directions on one host. Removing needs: repro. The acceptance criterion "document the exact missing prerequisite" is met below. The scoped correction it allows is listed at the end.

    Reproduction: the placement probe's exit 1 is a nested-namespace refusal, not a runtime failure

    At 5af68976988140d8d916f74d7342959a4cc4e66d, Bun 1.4.4, agent SDK 0.3.293, Claude Code 2.1.293, on Ubuntu 26.04 with
    kernel.apparmor_restrict_unprivileged_userns=1 and the distribution's bwrap-userns-restrict AppArmor profile loaded.
    Keyless, offline guard intact, no source edited.

    Mechanism. The profile attaches to /usr/bin/bwrap. Everything that bwrap executes runs under the stacked label
    bwrap//&unpriv_bwrap, which denies all capabilities. The test wraps the whole capture in bwrap --unshare-net; the
    worker launcher then starts its own bwrap inside it, which can no longer create namespaces. The launcher's host probe
    refuses (worker_host_unsupported) before the copied CLI is ever executed, and the capture harness reports only the SDK's
    generic Claude Code process exited with code 1.

    Step 1 — the reported failure.

    bun install --frozen-lockfile
    bun run test ./experiments/turn-surface-runtime-placement.test.ts
    # 0 pass / 1 fail at line 10: Expected 0, Received 1; "Claude Code process exited with code 1"

    If the error is Cannot find module ..., dependencies are missing; that is a setup artefact, not this failure.

    Step 2 — its first cause, from the launcher's own probe. Save this outside the repository as first-cause.ts:

    // Read-only first-cause probe: asks the worker launcher's own host probe, edits nothing.
    // Usage: bun first-cause.ts <repo-root>
    import { mkdtempSync, readFileSync, rmSync } from "node:fs";
    import { tmpdir } from "node:os";
    import { join, resolve } from "node:path";
    const repo = resolve(process.argv[2] ?? ".");
    const { workerHostBoundary } = await import(join(repo, "packages/ui-sdk/src/server/worker-launcher.ts"));
    const brain = mkdtempSync(join(tmpdir(), "odysseus-first-cause-"));
    try {
      const label = readFileSync("/proc/self/attr/current", "utf8").replace(/\0/g, "").trim();
      const offline = readFileSync("/proc/net/dev", "utf8").trim().split("\n").slice(2).every(line => line.split(":")[0]!.trim() === "lo");
      console.log(JSON.stringify({ label, loopbackOnly: offline, result: await workerHostBoundary.probeAsync(brain, {}) }));
    } finally { rmSync(brain, { recursive: true, force: true }); }
    BUN=$(bun -e 'console.log(process.execPath)')
    "$BUN" /path/to/first-cause.ts "$PWD"
    # {"label":"unconfined","loopbackOnly":false,"result":{"ok":true}}
    bwrap --unshare-net --bind / / --proc /proc --dev /dev "$BUN" /path/to/first-cause.ts "$PWD"
    # {"label":"bwrap//&unpriv_bwrap (enforce)","loopbackOnly":true,"result":{"ok":false,
    #  "requirement":"bubblewrap namespaces, ... failed (bwrap: No permissions to create a new namespace, ...)"}}

    The second command uses exactly the outer arguments of the test (line 6).

    Step 3 — the same unmodified test passes when the wrapper's children do not carry that label. In a rootless Docker
    container (29.1.3 used; an Ubuntu 24.04 image with bubblewrap installed), with the repository mounted read-only at its
    own path, a scratch directory over its tmp/, and a copy of the image's own bwrap placed first on PATH:

    REPO=$PWD; SCRATCH=$(mktemp -d); BUN=$(bun -e 'console.log(process.execPath)')
    docker run --rm --network none \
      --security-opt seccomp=unconfined --security-opt systempaths=unconfined -e HOME=/tmp \
      -v "$REPO:$REPO:ro" -v "$SCRATCH:$REPO/tmp" -v "$BUN:/usr/local/bin/bun:ro" \
      --entrypoint sh <ubuntu-24.04-image-with-bubblewrap> -c '
        mkdir -p /tmp/bin && cp /usr/bin/bwrap /tmp/bin/bwrap && export PATH=/tmp/bin:$PATH &&
        sha256sum /usr/bin/bwrap /tmp/bin/bwrap &&
        unshare -U --map-user=1000 --map-group=1000 sh -c "
          cd '"$REPO"' && bun run test ./experiments/turn-surface-runtime-placement.test.ts"'
    # 1 pass / 0 fail, 6 expect() calls
    # OWNED_RUNTIME_RECEIPT {"networkInterfaces":["lo"],"placements":2,"measuredRequests":2,
    #   "installedDigest":"8968405e…e978","runtimeDigests":[same, same],"installedVersion":"2.1.293","cliVersions":["2.1.293","2.1.293"]}

    Control. The identical container command without the three PATH-copy steps fails again exactly as in step 1, and the
    probe script inside it reports bwrap//&unpriv_bwrap (enforce) and ok:false. Same kernel, image, tree, runtime bytes
    and bwrap bytes; only the path bwrap is executed from differs.

    What this establishes. On this host class the failure is an undeclared host prerequisite: the outer offline wrapper
    must not hand its children a label that forbids nested namespaces. With that satisfied, both placements run, serve a
    measured request each, and report equal digests and versions under a loopback-only namespace; no placement or runtime
    defect appeared.

    What it does not establish. Whether the original reporter's machine had the same cause; whether setting
    kernel.apparmor_restrict_unprivileged_userns=0 alone is sufficient while the profile stays loaded (needs a privileged
    A/B on a disposable host); behaviour under rootful Docker. The green run uses a container, an extra user-namespace
    mapping step and bubblewrap 0.9.0 rather than the host's 0.11.1, so it qualifies the placements in that environment, not
    on the bare host.

    Candidate narrow corrections (neither relaxes the network namespace, the worker probe, the exit assertion or either
    placement):
    a nested-namespace precondition in the experiment tier that fails early naming the AppArmor label, and
    surfacing the retained worker start failure in the capture harness instead of the generic SDK exit.

  7. added
    agent-ready
    and removed
    needs: repro
    on Nov 16, 2026
  8. self-assigned this
    on Nov 16, 2026
  9. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-f9503be3. Branch: test/4005-nested-runtime-prerequisite.

    Closure-only proof overlaps with open PRs; no reported path collision. Requested issue selected explicitly.

  10. added this to the 0.45.0 milestone on Nov 16, 2026
  11. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Implementation and readiness reconciliation — 2026-11-16. The body now incorporates the reproduction and scoped correction previously held in comments. The requested batch is implemented in #4084, head bb23e28df83c3afa1edbb982cbdd1ecbd7d16ca5, based on 3b104890f84e2eeca687d3c4fbdd1dbb02fb3ae9.

    The new nested-host diagnostic fails first and when removed, then passes when restored. The qualified offline two-placement control passes both tests / 11 assertions, with two measured requests, loopback-only interfaces and identical installed/copied runtime digests. The original host refusal remains a failure with its first cause exposed; no boundary or receipt assertion was relaxed.

    Local bun run check:pr --base origin/main passes all gates and 1,208 affected fast tests. Root typecheck passes with an 8 GB V8 heap. PR and issue milestones are verified as 0.45.0. The PR stays draft while existing main incident #4081 blocks ordinary candidate confirmation; merge and closure are not yet claimed.

  12. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Merged in #4084 as ad3611ae15f3af82eba14ac9aaf4a8727b3920eb, verified as an ancestor of origin/main. Candidate run 43873943931, attempt 1, passes all selected fast jobs and proof; the selected job checkout logs identify 620cbd8eab58f34272ee7f294e4e19d38a82d02c, whose tree exactly matches the squash. The issue is closed and retains milestone 0.45.0, as does the PR.

    Local failing-first and restored-mutation evidence remains in the PR. Required proof on the actual squash is still running in main run 43877725319; full post-merge verification is not yet claimed.

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

Metadata

Metadata

Assignees

Labels

agent-readyarea: cipriority: p2type: test

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions