Skip to content

CONTRACT: perf(ui-server,ui-sdk): attribute the native observation's writer hold and journal finish (#2915) - #4012

Merged
schlessera merged 9 commits into
mainfrom
perf/2915-native-observation-phases
Nov 15, 2026
Merged

schlessera merged 9 commits into
mainfrom
perf/2915-native-observation-phases

Conversation

@schlessera

@schlessera schlessera commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #2915
Refs #2834

What changed

A native journal observation's time can now be attributed step by step, on one clock, and it has been. A held observation reports every step to an internal journal trace: admission, a call's result, the periodic pass and finish, with the worker hold itself last. The native manager can report each request's wait for its single operation lock, the operation it waited behind, and its checkpoint, release and delta steps. --observation-timing records both, pairs each checkpoint and delta step with the one manager request that arrived inside it, and writes per-phase medians, coverage and the clock proof to observation-timing.json (phases), with the raw samples in observation-traces.json. Admission's lifecycle steps gain observe_reserve, observe_release_reads, observe_worktrees, observe_publish and observe_facts (additive; docs/integration-contract/wire.md, changeset). Nothing is traced unless a caller passes a trace. No check, intent, fsync, capture or durability step changed.

The decision record has the analysis: docs/decisions/governed-writable-workers.md, "Where an observation's time goes".

Why this shape

  • One clock across two processes. Bun's process.hrtime is process-relative, so both processes stamp performance.timeOrigin + performance.now(). A manager request is matched only when it arrives inside its app step. The run fails unless every native step pairs with exactly one request and each checkpoint answers before its step ends. Those two guards together bound any offset between the clocks.
  • No cut. In the paired same-runner runs, every remaining phase is a qualification check, an identity check, a fsynced intent, the snapshot, the content capture or the hold mechanism. The issue forbids skipping or caching any of them.
  • The slow-host cost. Run 1 shows where the slow-host finish time went: btrfs writeback of the turn's dirty data, absorbed by the intent fsync or the snapshot. Moving that writeback out of the hold is a separate design question, filed as ui-sdk: a native checkpoint's intent fsync and snapshot absorb the turn's btrfs writeback inside journal finish #4019. It is not a step to remove.

Proof

Native fixture timing, hosted runners. pi, governed, UID 1000, 2,000 notes, bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --observation-timing. The runs used temporary draft-only commits, since removed, that made the draft heavy-feedback runtime_host job run this cell. The paired rows ran back to back on one runner. Cells show median added ms / p95 with the median worker hold. Begin + finish is the median / p95 of paired totals.

Run Head Load (1-min start → end) write_file edit_file writing bash begin + finish
1 (run 43719436502) fed7d8b6 1.60 → 1.20 71/494, held 45 59/249, held 33 86/614, held 57 218/1,577 (begin 24, finish 140)
Paired base (run 43721871355) 3f8ff293 2.01 → 1.41 67/97, held 38 69/74, held 38 76/96, held 40 62/181
Paired head (same job) dbd3db82 2.22 → 1.30 68/126, held 38 68/80, held 40 72/79, held 38 68/144

The traced code under those heads equals this PR's code. The merge with main since then touched only unrelated files.

Failing-first and mutation receipts.

Test / guard broken Fails on
new trace test against main's source TRACE_EVERY_HELD_OBSERVATION (no trace)
drop observe_facts TRACE_BEGIN_STEPS
hold never ends TRACE_HOLD_ENDS_LAST
lifecycle also receives the hold LIFECYCLE_SEES_EVERY_STEP_BUT_THE_HOLD
record and publish overlap TRACE_LEAVES_DO_NOT_OVERLAP
finish untraced TRACE_EVERY_HELD_OBSERVATION
aggregation counts containers PHASES_LEAVES, SUMMARY_COVERAGE_AGAINST_MEASURED
no arrival containment PHASES_UNPAIRED_STEP_REPORTED
coverage against the trace instead of the measured hold SUMMARY_COVERAGE_AGAINST_MEASURED
absent phase dropped instead of zero SUMMARY_ABSENT_PHASE_IS_ZERO (survived until the test was strengthened)
transport ignores the lock wait PHASES_NATIVE_BREAKDOWN

The manager trace runs only as root on btrfs. The hosted native runs exercise it through the clock-proof assertions (OBSERVATION_TIMING_ONE_CLOCK).

Local suites.

  • 46 journal, native, scope, admission and lifecycle files in packages/ui-server: 435 pass, 10 fail. The same 10 fail on origin/main in this sandbox (index purge, maintenance probe, native host inputs, turn scope).
  • bun run typecheck, bun run build and bun run api-report (no diff) all pass.

Collisions at head 22857a95 (rechecked after the merge with main below): no path collisions. Closure-only overlaps with open drafts #3054, #3056, #3059, #3069, #3116, #3437, #3581, #3622, #3806, #4002, #4007, #4008, #4013, #4016, #4018 and #4020.

bun run check:pr --base origin/main
{"version":1,"kind":"brain-check-pr-receipt","head":"079cc7c6d86dbc32142368efca0e801547f9ca89","base":"origin/main","mode":"focused","startedAt":"2026-11-15T15:44:35.403Z","finishedAt":"2026-11-15T15:46:17.342Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":14140.765433999999},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":121.90144799999689},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":78.52037500000006},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":23.430453000000853},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":87555.28454600001}]}

Checklist

  • Focused local preflight/behavioral receipts passed; hosted measurement evidence is in Proof. Hosted confirmation runs through integrate.ts confirm.
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included.
  • No personal data anywhere in the diff.
  • The integration contract component (wire.md) is updated in the CONTRACT commit.
  • Docs under docs/ reflect the change.
  • Provider history stays append-only: nothing sent to a provider changes. The trace is internal and stays in the host process.

Anything left open

🤖 Generated with Claude Code

schlessera and others added 3 commits November 15, 2026 13:29
…tion (#2915)

The journal takes an internal observation trace for admission, a call's
result, the periodic pass and finish: every step reports to it, the worker
hold last. The observer now times its wait for room behind earlier releases
(observe_reserve), and the record step is split into record, publication and
facts query, repeated per recorded turn. Admission's lifecycle steps gain the
same new names (wire.md lists them); the hold stays trace-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2915)

An internal trace option on the manager reports each request's wait for the
single operation lock, with the operation it waited behind, the lock hold and
the checkpoint, release, delta and checkpoint-read steps, stamped with
performance.timeOrigin + performance.now() so the app process can align them.
No trace, no change: the lock and every check run as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sh on one clock (#2915)

--observation-timing now records the journal trace in the app child and the
manager spans in the fixture, pairs each checkpoint and delta step with the one
manager request that arrived inside it, and writes per-phase medians, coverage
of the measured hold or journal call and the clock proof to
observation-timing.json, with the raw samples in observation-traces.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added the contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. label Nov 15, 2026
@schlessera schlessera changed the title perf(ui-server,ui-sdk): attribute the native observation's writer hold and journal finish (#2915) CONTRACT: perf(ui-server,ui-sdk): attribute the native observation's writer hold and journal finish (#2915) Nov 15, 2026
@schlessera schlessera added type: fix Something is broken and must behave the way it is documented. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. labels Nov 15, 2026
@schlessera
schlessera force-pushed the perf/2915-native-observation-phases branch from dbd3db8 to 2d5a350 Compare November 15, 2026 14:32
@schlessera
schlessera marked this pull request as ready for review November 15, 2026 16:12
@schlessera
schlessera merged commit 388feb4 into main Nov 15, 2026
39 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. type: fix Something is broken and must behave the way it is documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui-server: attribute and cut the native observation's remaining writer hold and journal finish after #2872

1 participant