Repository navigation
Description
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-timingharness to print the same records, so a local run and a hosted run are comparable.
Out of scope
- Changing when a hold is taken or what it stops: ui-server: after each tool result the worker is stopped before it can send its next model request (0.8 s median per request) #4292 and ui-server: an observation of twenty changed notes keeps every worker stopped for about four seconds #4294.
- The relay’s own timing marks: ui-sdk: the inference relay records one duration per request, so host time cannot be told from the provider's time to first byte #4279.
Acceptance criteria
- After a governed turn with three shell tool calls on the native fixture, the turn's record lists three
toolholds, 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
periodichold. - 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 lintContract impact
- This touches the integration contract if the records are added to the lifecycle record: additive,
CONTRACT:prefix,contractlabel,docs/integration-contract/wire.mdin 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
schlessera commentedon Nov 20, 2026
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.