Skip to content

ui-sdk: name the identity supervisor's unfinished setup step when readiness times out #3664

Closed

Description

@schlessera

Context

Follow-up from the #3655 spike. That spike could not say which identity-supervisor setup step missed the 5,000 ms readiness deadline in run 42185293538, job 127784600665, because nothing records it. This issue adds the bounded diagnostic that would name the step the next time it happens. Citations are against origin/main 1619741f2.

What the host sees. readySteps (packages/ui-sdk/src/server/worker-identity.ts:124-154) polls only for the supervisor's ready file. On ENOENT it re-checks the supervisor's process identity and throws worker_identity_setup_timed_out once STATE_SETUP_MS (packages/ui-sdk/src/server/worker-launcher.ts:70) has passed (worker-identity.ts:148-150). That deadline is set when the bootstrap is spawned (worker-launcher.ts:1443). So the 5,000 ms covers the Bun worker-entry start, the execve into the Python supervisor, and every supervisor step before ready.

What the supervisor does before ready. In WORKER_IDENTITY_SUPERVISOR (packages/ui-sdk/src/server/worker-identity-program.ts), in order:

  1. Initialise and bind the control listener (:106).
  2. Spawn the helper's launch operation (:114) and wait for its acknowledgement through packet(launch_local) (:130). The socket timeout is 5 s (:110).
  3. Wait for bubblewrap's --json-status-fd child PID (:135-144), with its own 5 s bound.
  4. Call the helper's mounts operation (:147). This allows a 5 s socket timeout plus a 5 s wait (:50, :66).
  5. Publish ready (:164).

Why the reason is lost. Each of those steps has a bound of 5 s or more, so the host deadline always fires before the supervisor can name a stalled step. The supervisor reports a failure only through its except path (:236-245): a {ok:false} record plus a stderr line. That path runs terminate() first, which makes another helper call. Meanwhile the host's close request either fails at once or times out after 6 s. After that, the supervisor is SIGKILLed (supervisionLostSteps, worker-identity.ts:52-59), and the host reads stderr (launchDiagnostics, worker-launcher.ts:1316-1324, read at :1584). In the failed job that read was empty: the requirement has no (detail) suffix (:1596-1599).

The identity helper in the native proof is test-only fixture code (packages/ui-sdk/tests/fixtures/identity-helper.c and the fixture's helper.py). The diagnostic therefore has to tell three things apart: host startup cost (infrastructure), a helper launch/mounts stall (fixture), and a bubblewrap status or supervisor stall (product or infrastructure).

Out of scope

  • Raising STATE_SETUP_MS or any supervisor sub-step bound, adding retries, or weakening the separate-UID qualification.
  • Any change to cleanup, closeSteps/fallback ordering, or identity verification.
  • Writing progress to the supervisor's stderr. After a successful launch that stream is the worker's stderr (worker-launcher.ts:1439-1440, pipes.streams() at :1491), so progress lines would pollute it on every launch.
  • The ci: attribute recurring native automatic-index aborts on main #2921 automatic-index abort.

Scope

  1. Supervisor. Before each pre-ready step, the supervisor overwrites one bounded progress record at cfg['ready'] + '.progress'. The record is at most 128 bytes, is written by temporary file plus rename, and holds {"step": <name>, "ms": <ms since supervisor start>, "wallMs": <time.time()*1000>}. The steps are started (after the server identity check), listening (after :106), launch-sent (after the sendmsg at :127-129), launch-acked (after :130), status-read (after :144) and mounts-acked (after :147). The record lives in the broker's existing private mkdtempSync directory (worker-identity.ts:46), so the existing rmSync at close removes it. It carries no descriptor, path or authority.
  2. Host. Only when readySteps throws worker_identity_setup_timed_out, and only when launchDiagnostics is empty, the launcher fills the existing (detail) channel (worker-launcher.ts:1584, :1596-1599). It reads the record with a bounded, non-following read, and the detail is capped at the existing 400 bytes (:1321). The detail gives the last step, its ms, and wallMs minus the host's spawn time. A missing record reads as step: none. The requirement prefix, errorClass and the cleanup path stay byte-identical.
  3. Fixture. captureMaintenanceStage (packages/ui-sdk/tests/maintenance-stage-provenance.native.ts) and the separate-UID harness already retain the thrown message in default-controls-server.stderr and native-fixture.json. Confirm the detail reaches runtime-host-proof.

Acceptance criteria

  • A keyless unit test drives readySteps with a progress record of launch-sent and no ready file. It asserts that the launch failure's requirement is worker_identity_setup_timed_out (… launch-sent …) and that its errorClass is worker_host_unsupported. Receipt: the test fails on origin/main because the requirement has no detail, and passes after the change.
  • A test with no record asserts step: none. A test with an oversized record, or one that is a symlink, asserts a bounded refusal, not a read through the link.
  • A new native fault variant joins the separate-UID qualification (packages/ui-sdk/tests/identity-broker-qualification.native.ts, beside the existing fault-* helpers): a helper whose launch operation never acknowledges. Its expected outcome names launch-sent, and ordinary identity cleanup still passes. Mutation receipt: remove the launch-sent write, watch that case fail on its step assertion, then restore.
  • STATE_SETUP_MS, every supervisor bound and the cleanup and identity assertions are unchanged, which the diff shows.
  • bun scripts/prove-worker-identity.ts passes with its existing bounds in the hosted runtime_host job.

Verification

Keyless unit tests through bun run test. Native proof comes only from hosted runtime_host (bun scripts/prove-worker-identity.ts). A host without unprivileged user namespaces cannot run it locally.

Contract impact

Expected to be additive. WorkerHostError already carries requirement (detail) whenever launch stderr has content, and this issue adds detail only to a case that today has none. Before implementing, confirm this against docs/integration-contract/wire.md:938 and docs/integration-contract/http.md:224. If it counts as a contract change, the commit takes the CONTRACT: prefix and updates the index in the same commit.

Refs #3655

Triage 2026-11-08 at main 1619741f291f525d17cde4970a5ada40644117c1: Rechecked the readiness loop, host deadline, supervisor sequence and empty-stderr detail path against cited main. The prescribed bounded diagnostic/native fault proof is a complete brief; preserve p1 and add agent-ready. No native qualification was run by this triage.

Activity

  1. added
    type: feat
    area: ui-sdk
    priority: p1
    agent-ready
    on Nov 8, 2026
  2. added this to the 0.45.0 milestone on Nov 8, 2026
  3. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Maintainer, 2026-11-08: commit this to 0.45.0 and work it in the current run. Before implementing, the readiness review still has to check the contract surface (docs/integration-contract/wire.md, http.md).

  4. self-assigned this
    on Nov 8, 2026
  5. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Claiming (claim token wi-3664-a63e5), branch feat/record-readiness-progress, from origin/main a63e564f0.

    Readiness. Every file:line in the body still matches a63e564f0: none of worker-identity.ts, worker-identity-program.ts, worker-launcher.ts, identity-broker-qualification.native.ts, maintenance-stage-provenance.native.ts, wire.md or http.md changed since 1619741f2. bun scripts/collisions.ts --paths reports one path collision: draft #3464 also edits worker-launcher.ts (different region). The rest are closure-only.

    Contract check (wire.md:938, http.md:224): additive.

    • errorClass stays worker_host_unsupported and the message stays Agent worker boundary unavailable: <requirement>. <route>.
    • The contract says only that the message (and WorkerHostStatus.requirement) names the requirement. It does not list requirement strings, and no contract or hosting doc names worker_identity_setup_timed_out.
    • A (detail) suffix already appears on requirements whenever launch stderr has content. This change adds a detail to one requirement that today never has one. No field is added, removed or retyped, and no value changes meaning.
    • So the commit takes CONTRACT:, a sentence goes into wire.md, http.md and the index, and there is a minor changeset. No needs: decision.

    One implementation note, from the source. For a helper that never acknowledges launch (the native fault case), the supervisor's packet(launch_local) times out about 5 s after launch-sent. That is a few hundred ms after the host deadline, so its except path usually does write Worker identity supervision failed: timed out to stderr before the host reads it. That line doesn't name a step. If the progress detail appeared only when stderr was empty, this fault case would never show launch-sent. So on a worker_identity_setup_timed_out the progress record goes first in the existing (detail), followed by any stderr, all within the existing 400-byte cap. Every other requirement keeps its detail byte-for-byte, and the NO_TMPFS_SIZE mapping still tests only the stderr part.

  6. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Delivered in #3703, squash e4d4ac8434a41b0f4c2d1c7997dbc601756390b7 on main. Its parent is the tested base a63e564f0, and its tree fc556eb0 matches the candidate checkout 1da147f83.

    • Unit tests. packages/ui-sdk/tests/worker-identity-progress.test.ts failed first on origin/main: Received: "worker_identity_setup_timed_out", with no detail. It passes with the change. There were three mutations, each restored: the supervisor's launch-sent write, the launcher's read, and O_NOFOLLOW. Each failed its named assertion.
    • Native proof. Hosted runtime_host (candidate run 42475324020, job 128715561636) ran the new no-launch-ack fault case:
      {"setupTimeout":{"requirement":"worker_identity_setup_timed_out (step: launch-sent, ms: 0, sinceSpawnMs: 69; Worker identity supervision failed: timed out)","errorClass":"worker_host_unsupported"}}. The case passed, as did identityQualification (29 cases).
    • Ordering confirmed. As the readiness note predicted, the supervisor's own stderr did arrive and names no step. That is why the recorded step leads the detail.
    • Unchanged. The contract change is additive (the index, wire.md and http.md, plus a minor changeset). STATE_SETUP_MS, the supervisor bounds, cleanup and identity checks did not change.

    The #3655 root cause stays unattributed until a recurrence carries this detail.

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

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-sdkpriority: p1type: feat

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions