Skip to content

ui-server: nothing records how long an observation kept workers stopped, or what the stop overlapped #4280

Open

Description

@schlessera

Context

Part of #4278.

A journal observation runs under a hold that stops the workers of every active turn (held, packages/ui-server/src/brain/turn-journal.ts:293; worker.freeze(), packages/ui-server/src/brain/turn-scope.ts:166; resumed at :183). It runs after every tool result that is not proven read-only (toolEnded, turn-journal.ts:614-620), every 15 s while any turn is active (:559-560), and at journal begin and finish.

A turn's record does not say how long its workers were stopped. The journal can time an observation's steps (observationTrace, turn-journal.ts:110-112, kinds begin, finish, tool, periodic), but only the native proof harness supplies that option (scripts/native-proof/hosted-app-child.ts). A hosted server records the steps of journal begin only, through the lifecycle record's subPhases (#3355).

So the measurement behind #4278 had to infer the stop from the gap between a tool result and the next request's arrival at the relay: 0.76 s median and 2.0 s p90 per after-tool request, 2.76 s and 10.1 s per turn. It could not say:

  • how long a worker was actually stopped per result, as opposed to waiting for the hold or for another turn's observation;
  • how often the 15 s periodic observation stops a worker while a response is streaming to it. A response lasting 4.5 s overlaps a 15 s tick about 30% of the time, and block-level clocks cannot see it;
  • how often one turn's observation stopped another session's workers.

Scope

Use the existing journal hold (held, packages/ui-server/src/brain/turn-journal.ts:293-314) and per-turn lifecycle evidence writer (createTurnLifecycle, packages/ui-server/src/activity/turn-lifecycle.ts:14-27). Capture timestamps at their actual boundaries. An unconfirmed stop or resume has no success timestamp. A per-turn read uses its existing owner scope and includes counts, not the identities of another owner’s turns. A new wire field is needed only if the chosen exposure actually changes that envelope.

  • Record, for every hold on a hosted server: its cause (begin, finish, tool, periodic, scope), the turn and tool call that caused it when there is one, when the hold was requested, when the workers were confirmed stopped, when they were resumed, the number of changed paths the observation recorded, and how many other active turns' workers it stopped.
  • Record for each affected turn whether one of its inference requests was in flight when its workers were stopped. The turn's relay knows (prepareRelayedEgress, packages/ui-server/src/ws/session-run/backend-entry.ts:149).
  • Store the records where the lifecycle record's reader can join them to a turn. Use the existing step timers; do not add a write to the turn's path that a milestone write could carry.
  • Extend the --observation-timing harness to print the same records, so a local run and a hosted run are comparable.

Out of scope

Acceptance criteria

  • After a governed turn with three shell tool calls on the native fixture, the turn's record lists three tool holds, each with requested, stopped and resumed times in order and a changed-path count.
  • A turn that runs for more than 15 s records at least one periodic hold.
  • With two active turns, an observation caused by one records that it stopped the other's workers, and the other turn's record shows the same interval.
  • A hold taken while a fake upstream is streaming a response to the turn is marked as overlapping an in-flight inference request.
  • Recording adds no awaited write between a tool result and the hold, shown by the existing ordering test for the hold.
  • If the records are exposed through the wire lifecycle record, docs/integration-contract/wire.md ("Host turn lifecycle", line 554) describes them.
  • A test covering this fails on the tree before the change and passes after.

Verification

bun run test packages/ui-server/tests
bun scripts/prove-native-host.ts --backend=claude --observation-timing
bun run typecheck
bun run lint

Contract impact

  • This touches the integration contract if the records are added to the lifecycle record: additive, CONTRACT: prefix, contract label, docs/integration-contract/wire.md in the same commit.
  • This changes a published package's behaviour, so it needs a changeset.

2026-11-20 triage — Verified the hold and lifecycle anchors at 63bb400b3. The measurements can be implemented against the existing hold schedule and can identify in-flight overlap without waiting for #4279’s finer relay duration fields.

Activity

  1. added
    type: feat
    area: ui-server
    on Nov 20, 2026
  2. added
    priority: p2
    area: ui-sdk
    agent-ready
    on Nov 20, 2026
  3. self-assigned this
    on Nov 20, 2026
  4. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-06b8c71e. Branch: feat/4279-turn-clocks.

    Worked as part of the #4278 epic integration branch epic/4278-host-overhead (one main landing for the epic). Collisions: none recorded at claim.

  5. added this to the 0.45.0 milestone on Nov 21, 2026
  6. removed their assignment
    on Nov 23, 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: ui-sdkarea: ui-serverpriority: p2type: feat

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions