Skip to content

perf(control-ui): remove a transcript readiness round trip - #182846

Merged
steipete merged 13 commits into
mainfrom
solid2/w-perf-remote-rtt
Oct 25, 2026
Merged

steipete merged 13 commits into
mainfrom
solid2/w-perf-remote-rtt

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Remote chat reloads and session switches waited for a message-subscription acknowledgment before issuing the initial transcript request, adding a full network round trip.

User Impact

The initial transcript arrives with the subscription acknowledgment. Live events remain covered by the admitted observer, and history failures retain the subscription and use the existing retry path.

Why This Change Was Made

The Gateway accepts an optional initialHistory request on sessions.messages.subscribe, registers the observer first, and invokes the canonical chat.startup reader. The UI consumes that one-shot result through its existing history owner, including the exact cached cursor/state revisions and stale-result checks. Existing clients omit the new field and retain their response shape; the wire protocol remains v4. The UI and Gateway ship together.

Approval-enabled subscriptions keep their scoped read, replay, and session-access authority through history preparation and recheck immediately before committing the observer and publishing. The provisional observer already delivers events, so revocation can roll it back without leaving an unowned subscription. History read failure alone still returns a retryable history receipt with the authorized observer.

Snapshot restoration stays independent of subscription setup, which never waits for IndexedDB. The optional speculative validator prefetch was removed to retain the existing loader ownership and import budget. A full page requested before storage settles already covers a subsequently restored cache: the history owner consumes it under the original exact request parameters. Delta requests still discard mismatched cursor/state receipts and issue a current history read. A late stored snapshot cannot replace live history. Automatic reaction baseline reads wait for transcript readiness, using the existing hydration callback; live reaction events and writes remain immediate. HTML retains its existing private, no-store bootstrap contract. The transport requires connect as the first frame and admission before ordinary requests, so pre-connect pipelining cannot remove that exchange. HTML contains the current authority-scoped bootstrap preferences and plugin grants, so this change retains its existing cache contract rather than splitting them into another fetch.

Warm reload, before (5 serial exchanges):
HTML → WebSocket upgrade + challenge → connect/hello → subscribe → chat.startup → transcript
Warm reload, after (4 serial exchanges):
HTML → WebSocket upgrade + challenge → connect/hello → subscribe + initialHistory → transcript

Session switch: subscribe → chat.startup → transcript  ⇒  subscribe + initialHistory → transcript
Composer on warm reload: HTML → upgrade/challenge → connect/hello → models.snapshot push → ready

Config reads, snapshot validation, and session resolution overlap this authenticated warm path. Composer readiness retains three client-initiated exchanges plus a server push; combining history does not remove a composer dependency.

The first cold read exposed a separate pool issue: the existing prewarm task prepared only whichever history worker accepted it. A later request could select the other foreground worker and spend over a second loading presentation modules. Each existing foreground worker now prepares that same module group at startup, including replacement workers. Database admission stays in its existing prewarm owner; search, projection, and maintenance workers retain their lazy graphs. The existing two-worker foreground pool and its capacity are unchanged; preparation now follows each worker's lifetime.

Evidence

Rerunnable workload (both source checkouts detached, with their built bundles; output outside either repository):

node --import ./scripts/tsx.mjs scripts/bench-control-ui-wire.ts \
  --bundle-dir dist/control-ui --compare-source-dir ../base \
  --compare-bundle-dir ../base/dist/control-ui --profile remote \
  --auth token --pairs 20 --output /absolute/proof/remote

Repeat with --profile local; use the same base revision on both sides for the A/A control. Final-head functional checks omit the two comparison arguments and use --pairs 1. The committed benchmark guide describes the fixture and counters. The integrated byte check was pnpm ui:check-performance:base db9330ab86addb6d08d0b0679f9b05b0122ad2bd.

Acceptance rule: five base/base A/A pairs, then ten interleaved base/head pairs per profile (twenty when the A/A timing control falls outside the band), median and nearest-rank p95; remote profile is 100 ms RTT / 10 Mbps. Target: 30% lower remote warm transcript/composer medians. Local median regression must stay within 5% with no worse p95. When the A/A control falls outside the timing band, judge twenty paired samples with renderer thread CPU and structural counts; also report Gateway-process CPU and readiness RSS with their A/A variability. The final workload uses synthetic token authentication on both sides and waits, outside timed intervals, for the real app-written boot record and persisted transcript cursor. Earlier auth:none diagnostics are excluded from the final cohort; this is not a direct timing comparison with #182752.

The final five-pair A/A control and 20 interleaved base/head pairs per profile are complete. The A/A timing control missed the band, so CPU and structural counters are reported alongside all timings. The additional continuous CPU diagnostics below report the work overlapping each action; all original samples remain included.

The timing table describes the pinned pre-integration 1d9da0d / d879c6e source pair, not the final integrated head. Measurements use 20 serial interleaved pairs per profile and a five-pair A/A control. Values below are median / nearest-rank p95 [min–max], in milliseconds unless marked MiB. Renderer counters use thread CPU time.

Profile Readiness Base Head Median change
remote Cold transcript 4689.4 / 5816.2 [4319.3–6880.4] 4569.4 / 5289.6 [2034.8–5466.7] -2.6%
remote Cold composer 2925.8 / 3139.6 [2829.4–4026.9] 2960.5 / 4558.3 [691.2–4789.3] +1.2%
remote Warm transcript 817.1 / 903.7 [693.6–1013.6] 789.0 / 845.9 [634.2–872.6] -3.4%
remote Warm composer 511.9 / 610.7 [411.1–625.3] 480.4 / 555.2 [457.0–557.2] -6.1%
remote New Session 248.1 / 265.8 [167.0–279.1] 240.0 / 283.1 [164.9–283.1] -3.3%
remote Switch transcript 305.8 / 353.3 [277.1–379.2] 263.5 / 336.4 [216.1–342.0] -13.8%
remote Switch composer 43.1 / 49.9 [40.3–50.5] 42.4 / 50.2 [39.9–51.3] -1.5%
local Cold transcript 4736.8 / 9402.2 [2882.3–16022.3] 4284.9 / 11249.6 [2859.3–48618.8] -9.5%
local Cold composer 2929.9 / 5948.8 [1516.8–15426.7] 2876.4 / 8836.5 [1518.6–10641.8] -1.8%
local Warm transcript 364.0 / 641.2 [294.1–811.9] 361.3 / 439.0 [294.7–709.0] -0.8%
local Warm composer 203.8 / 320.7 [159.2–325.8] 214.5 / 290.1 [176.3–362.8] +5.3%
local New Session 89.8 / 194.3 [65.6–310.4] 84.1 / 149.8 [63.8–545.1] -6.2%
local Switch transcript 223.6 / 291.5 [143.4–764.3] 164.2 / 177.7 [130.2–202.3] -26.5%
local Switch composer 49.8 / 64.7 [40.4–65.1] 50.1 / 66.1 [40.9–69.3] +0.7%

The −30% remote warm-readiness target was not reached: transcript improved 3.4%, composer 6.1%, and session-switch transcript 13.8%. Localhost switch transcript improved 26.5%; warm transcript stayed nearly flat and warm composer median increased 5.3%. The A/A control itself missed the timing band. During localhost measurement, host load reached 79.1 and one cold candidate took 48.6 seconds; all samples remain included. These wall timings are not treated as clean-host latency guarantees.

CPU, RSS, and control details
Profile Flow Renderer task CPU base Renderer task CPU head Median change
remote cold-chat 510.7 / 561.5 [471.0–630.1] 490.5 / 535.8 [414.9–559.8] -3.9%
remote warm-chat 354.9 / 384.1 [326.8–384.2] 341.8 / 368.6 [307.9–388.9] -3.7%
remote new-session 60.8 / 67.5 [57.0–69.0] 61.3 / 65.7 [54.9–69.4] +0.8%
remote session-switch 143.3 / 161.2 [132.6–164.3] 141.0 / 157.2 [128.5–172.3] -1.6%
local cold-chat 668.8 / 804.2 [553.4–987.3] 667.2 / 780.5 [563.8–1804.5] -0.2%
local warm-chat 359.5 / 413.9 [289.9–421.1] 361.3 / 400.2 [287.9–429.3] +0.5%
local new-session 67.5 / 74.9 [56.0–79.0] 67.4 / 75.0 [55.5–80.6] -0.2%
local session-switch 178.5 / 194.7 [122.6–220.9] 180.4 / 195.7 [136.6–202.3] +1.1%
Profile Flow Gateway-process CPU base Gateway-process CPU head Median change
aa cold-chat 6015.9 / 6370.9 [4745.0–6370.9] 6164.0 / 6612.1 [5402.1–6612.1] +2.5%
aa warm-chat 335.2 / 685.6 [285.4–685.6] 695.2 / 802.6 [564.6–802.6] +107.4%
aa new-session 81.7 / 201.8 [72.2–201.8] 87.0 / 105.2 [69.0–105.2] +6.5%
aa session-switch 230.3 / 638.5 [77.0–638.5] 247.4 / 438.5 [97.9–438.5] +7.4%
remote cold-chat 5607.8 / 6300.2 [4868.9–7523.0] 5036.3 / 5948.0 [4541.5–6035.4] -10.2%
remote warm-chat 627.4 / 871.7 [268.7–910.6] 602.4 / 696.4 [249.1–702.3] -4.0%
remote new-session 88.6 / 129.1 [71.9–216.3] 86.6 / 105.2 [76.0–116.0] -2.2%
remote session-switch 104.4 / 439.4 [68.0–735.4] 305.8 / 383.1 [97.7–446.0] +193.1%
local cold-chat 7166.8 / 11985.5 [5047.7–12653.9] 6968.6 / 11161.2 [4789.6–34700.5] -2.8%
local warm-chat 572.1 / 1123.6 [170.1–1536.1] 541.1 / 1006.6 [146.6–1169.6] -5.4%
local new-session 132.7 / 257.7 [70.0–446.2] 141.7 / 505.9 [69.5–548.9] +6.7%
local session-switch 319.5 / 617.1 [223.3–778.1] 246.9 / 351.1 [182.4–695.8] -22.7%

Gateway-process CPU includes its worker threads and the Node benchmark/proxy, measured through the driver readiness assertion; it excludes Chromium and the post-ready tail. It is not whole-session CPU. The original remote switch window increases 193.1%; the independent continuous/task-labelled investigation is reported below. Its exact historical cause remains unknown because that cohort did not record worker tasks.

Profile Flow RSS base (MiB) RSS head (MiB) Median change
remote cold-chat 3584.5 / 3855.5 [3541.7–3921.4] 3547.9 / 3826.6 [3424.2–3836.4] -1.0%
remote warm-chat 3734.3 / 3827.4 [3614.9–4018.3] 3715.9 / 3999.2 [3518.1–4005.9] -0.5%
remote new-session 3729.4 / 3780.8 [3614.8–3799.2] 3715.1 / 4003.8 [3521.1–4016.1] -0.4%
remote session-switch 3727.1 / 3778.1 [3558.9–3780.4] 3701.6 / 4011.9 [3525.2–4013.8] -0.7%
local cold-chat 3627.2 / 3968.0 [3285.8–3979.3] 3665.6 / 3976.3 [3137.1–3990.6] +1.1%
local warm-chat 3802.1 / 4112.4 [3334.4–4128.8] 3750.2 / 4064.1 [3098.7–4065.8] -1.4%
local new-session 3803.1 / 4112.7 [3339.1–4128.1] 3753.7 / 3989.6 [3099.1–3992.7] -1.3%
local session-switch 3799.3 / 4045.2 [3348.2–4065.4] 3697.6 / 3991.9 [3110.5–3996.1] -2.7%

RSS is a snapshot at readiness, not peak memory or a retention proof. The A/A control has substantial process-CPU drift even for identical sources. Renderer CPU and structural counts are the primary checks under the noisy-host rule. The additional process-CPU investigation below retains the original increase and separates observed work from inferred attribution.

Measured source pair: base 1d9da0d5dce9ea92065015cb5de0671d2e68db8b, head d879c6ec8d57ed753582f63c932ccddcbb516295. Subsequent integration through db9330ab86addb6d08d0b0679f9b05b0122ad2bd includes other lanes’ startup, canonical history, transcript-storage, and virtualizer changes. These timing cohorts describe their pinned source pair; final integrated build checks and bounded smoke are recorded separately. The initial integration checkpoint was 7505f76b6fd181404e77fe4017763d05f0533ee5; a final functional trace found and reproduced the late-cache full-page race, which the history owner now handles without another read in 12e339678d673ed752a1fd40529e3b916e86714b.

Additional CPU attribution (diagnostics, not a replacement timing cohort): four counter-only captures in base/head/head/base order include New Session, return to A, switch to B, and a one-second tail. Continuous process CPU was 2,047 / 708 / 2,090 / 1,951 ms, respectively; main-thread CPU was 298 / 298 / 326 / 433 ms. The large same-head variation demonstrates why short readiness windows cannot isolate this request’s CPU.

A separate task-labelled base/head pair records identical work: 39 tasks from setup through the tail, 10 during the measured sequence, the same task-kind counts, 84 trace events each, and zero drops. No worker starts inside the window. Head’s two eager-prewarm workers already existed about 33 seconds before New Session. Continuous process CPU falls 1,336 → 1,137 ms, main-thread CPU 373 → 338 ms, and switch-window process CPU 442 → 314 ms. The worker observed serving the RPC history task uses 54 → 8 ms sampled switch CPU (it also serves reactions, pending inputs, and progress; this is not exclusive RPC CPU).

The task trace independently identifies a non-history session-exact-entries read overlapping switch readiness and continuing into the tail. Its worker’s sampled continuous CPU increases 246 → 298 ms while history-serving worker work falls. Native/nested/untracked CPU remains separate. These captures establish equal task counts, lower repeated history-serving work, and substantial background overlap; they cannot retroactively identify the exact cause of the original 193% process-window increase. No profiler is activated by these counter/task captures; product-owned automatic stall profiling may run independently. The instrumented all-isolate profiles were used only for exploration because their overhead changes scheduling.

The remote-link simulator was corrected before the accepted cohort: it now bounds each shared-bandwidth direction, rotates active flows in 16 KiB turns, overlaps propagation, honors backpressure, and drops cancelled flow reservations. The previous unbounded future reservations could make a cancelled speculative preload delay the next navigation. A real TCP half-close test and four shaping/cancellation tests pass; all accepted base/head measurements use the same corrected instrument.

Final matched builds at 1cb20e1b5258d68b7009c8fa1550feb8fc405f57 against base db9330ab86addb6d08d0b0679f9b05b0122ad2bd use one Node 26.12.1 / Vite 8.3.4 / Pako 3.0.2 toolchain and fixed build identity. Startup is 281,207 → 281,247 B gzip (+40 B), seven JavaScript requests and one CSS request on both sides. Chat boot is 1,270,847 → 1,271,383 B (+536 B) with 19 JS / 3 CSS requests; New Session is 766,679 → 766,731 B (+52 B) with 16 JS / 3 CSS requests. Startup and New Session movement stays inside the 64 B build-variance allowance; the roughly half-KiB Chat increase accompanies one fewer serial history exchange. Strict base-relative comparison and verification of 2,322 finalized precompressed sidecars pass. Main's committed startup baseline remains unchanged at 281,702 B. All CSS is byte-identical; the absolute-only total-CSS ceiling remains exceeded on both sides (303,561 B versus 303,372 B), with zero growth and no allowance change.

The worker initialization and custody checks pass 47 tests across three files; the new foreground-startup case fails on the previous worker source. The reaction owner suite passes 13 tests and post-transcript hydration passes seven on the integrated source. The actual-request reaction regression is red on the base and green with the guard. UI and core typechecks passed at 1cb20e1; the latest merged-head core type exception is recorded below. The later CI repair also passes focused lint, the assertion-safety and manual-import ratchets, the mock-export guard, the line-cap ratchet (38 changed source files), and the zero-cycle import check. Four real-Gateway observers now recognize bundled history while retaining transcript, cursor, recovery, and readiness assertions; the selected-agent fixture uses the real session capability. After integrating main’s nonblocking cache restoration and owned-buffer serialization, the 27-test warm-startup file, five history-issuance tests, and 15 serialization/transport tests pass. The first added lazy-import assertion raced module loading; it now waits for the observable request while storage stays unresolved.

Focused proof: UI history issuance regression fails on the base and passes with the change; SDK one-shot ownership tests, protocol schema rejection, observer-before-history/failure tests, raw nested-array serialization, UI typecheck, scoped lint, and native protocol determinism pass. Production Knip was run on the integrated head and exact base db9330ab86addb6d08d0b0679f9b05b0122ad2bd: both fail with the same four unused files: protocol-validator-schemas.ts, mcp-app-standalone-host.ts, repository-node-requirement.ts, and src/sessions/runtime-context.ts. No ignore or allowance was added.

Independent Codex review: the full change, reaction scheduling fix, worker initialization, and measurement additions have no actionable P0–P2 findings; fresh full candidate review against integrated main completed in two isolated passes with no actionable P0–P2 findings. Review caught an event-triggered baseline read bypass in the first scheduling fix; the central owner now gates it. A subsequent hosted P1 found premature approval-authority release before initial history; the repair retains and rechecks that authority through publication. Its focused regression reaches the real history reader and is red on the previous handler. pr-simplify: the existing history owner still owns retries and publication; the subscription coordinator retains only the observer, not a reusable history snapshot.

LOC before/after across final changed files against the integrated base: production 7,923 → 8,151; tests 6,081 → 6,849; benchmark 1,196 → 1,522; protocol docs plus benchmark guide 1,002 → 1,050. The startup baseline remains unchanged from main. Generated validator output 23,052 → 23,071 lines; generated identifier renumbering accounts for the larger diff. Across the eight touched UI production files, the refactor census is 0 → 0 for rendering controllers, effects, render effects, untrack, DOM listeners/queries, flush, and owner APIs. No view owner is added.

Final functional smoke uses clean committed head 1cb20e1b5258d68b7009c8fa1550feb8fc405f57, one run per profile. These runs verify readiness and wire counts; they are not a new timing cohort. The local trace before the final repair made one subscription plus one redundant startup request on warm reload; the final local and remote traces make one subscription and no standalone history request.

Proof Result
UI types and protocol generation Passed; latest core typecheck reproduces main’s TS2739 (details below)
Approval disclosure and provisional observer rollback 12 Gateway tests passed; shared-session revocation is red on the prior handler and green after retaining authority through publication
Selected-agent approval delivery 20 tests passed using the real session capability; synthetic fixture updated for reconciliation capture
Nonblocking cache and cursor fallback 27 tests; the full-page race is red on the prior head with two RPCs instead of one
Canonical history issuance 5 tests passed
Owned buffers, nested serialization and real WebSocket transport 15 tests passed
SDK ownership, Gateway admission, reactions and worker lifecycle Prior focused proof passed; unchanged contracts retain that evidence
Real Gateway at 1cb20e1, local and 100 ms RTT / 10 Mbps, synthetic token auth Both passed; cold/warm/switch each 1 subscription + 0 standalone history RPCs; New Session ready; no driver errors
Fixed-toolchain build and strict base-relative budgets Passed; startup +40 B, Chat +536 B, New Session +52 B; requests/CSS unchanged; startup/New movement inside64 B variance
Isolated review of integrated candidate Two full-candidate passes plus focused full-page and approval-lifetime/CI repair reviews; no actionable P0–P2 findings
Production Knip Stable final head ed94965 and exact base8e both pass with no findings. No new ignores.
Full current-head CI All 98 jobs completed; all test/security/lint jobs pass, with two inherited typecheck failures and their aggregate failure detailed below

Before (synthetic token-authenticated warm reload):

Before: populated conversation and ready composer

After (same synthetic conversation):

After: same conversation and ready composer

Final integration head ed949658241b909f558ac8835b57a9d27a7ee929 merges main 8e7fedf after a real conflict in the subscription handler. The resolution retains main’s synchronous respondError helper and the reviewed history/replay-authority lifetime. Both subscription suites pass all 12 cases, UI types and production Knip pass, and a fresh two-pass isolated review is clean. Earlier build, functional and timing numbers remain pinned to their stated revisions. The stable final tree is clean; Knip reports no findings on both final head and exact base.

Full CI 40150818384 completed all 98 jobs: 76 passed, 19 skipped, and three failed. All UI, real-Gateway, PostgreSQL, lint, ratchet and security-fast jobs passed. The only root failures are check-prod-types and check-test-types-core-2; both report exactly TS2739 at src/gateway/server-methods/session-catalog.test-helpers.ts(122,5) (missing minProtocol, maxProtocol, client). The aggregate openclaw/ci-gate fails from those two roots. This exact diagnostic also fails in latest completed scheduled main 40149301577 and was reproduced locally on exact base 8e7fedf. The CI checkout is 4e30f074, merging this PR head into d2af8361; its ordered parents and tree are verified, and all seven relevant helper/type/config inputs are unchanged. Landing uses the native inherited-failure recovery; CI is not represented as green.

Return an optional initial chat snapshot after observer admission, preserving cursor reads and history retries while removing one sequential round trip from chat startup and session switches.
Initialize presentation code per actual history worker instead of warming only the slot selected by a pool task. Keep database admission in its existing prewarm owner and remove the superseded request flag. Search, projection, and maintenance workers remain lazy.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts size: XL labels Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR returns initial chat history with message-subscription admission and prepares each foreground history worker.

Example: Open agent:main:wire-fixture-b over a 100 ms RTT connection.

  • Before: Wait for the subscription acknowledgment before requesting chat.startup.
  • After: Receive initial history in the subscription acknowledgment, removing one sequential exchange.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The owner-directed optimization has focused supporting coverage, but final-effect security proof is absent and source shows an introduced disclosure defect.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Remote conversation reloads and switches incur an extra sequential network exchange before receiving the transcript.
Reason: The maintainer-authored direction removes a concrete dependency while reusing existing observer, history, retry, and worker owners.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this maintainer-authored draft open: the optimization is useful, but the combined response introduces an approval-disclosure regression.

Priority: P2
Reviewed head: 8d5ad9a6de2ca1352796302e1d522596c2c6bc6a

Before merge

  • Add real behavior proof - Authority-chain proof required: exercise the combined subscription response for an allowed viewer and a viewer whose session becomes private during history I/O, proving rejection before socket disclosure. Inspected screenshots show the synthetic transcript and composer but not that boundary; the final authenticated performance cohort remains pending, and no latest-stable protocol upgrade run is supplied. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Revalidate approval disclosure after the initial history read (P1) - With includeApprovals and initialHistory together, approvalReplay is captured under the session-access checks, but read and prepared are released before the new awaited history read. A paired reviewer using operator.read under a role-limited session policy can begin on a shared foreign session, then lose access when its owner changes it to draft while history is loading. The history reader correctly refuses that session, yet this response still includes the earlier approvalReplay. Socket authority checks do not check that session's visibility, so approval presentation details are disclosed after access was revoked. Retain the existing session/replay access owners through publication and recheck them immediately before returning the replay.
  • Resolve security concern: Approval replay crosses the session disclosure boundary - Approval projections include presentation data and approval links; sanitization does not authorize disclosure to a viewer who can no longer read the session.
  • Explain or restore the original intent of Approval replay custody through publication - 970de87: fix(gateway): keep chat subscriptions stable during unrelated approvals #158633 retains the audience/reviewer replay scope until response or failure and rejects revoked access.

Findings

  • [P1] Revalidate approval disclosure after the initial history read — src/gateway/server-methods/sessions-subscriptions.ts:269-270
  • [high] Approval replay crosses the session disclosure boundary — src/gateway/server-methods/sessions-subscriptions.ts:269

Provenance

Tests

  • Missing end-to-end proof: Show allowed and revoked-session combined responses at the socket boundary, complete the declared performance comparison, and supply the latest-stable protocol upgrade run with settings and data intact.
Agent review details

How this fits together

The Control UI acquires a Gateway message observer, then publishes bounded transcript data through its existing history owner; SQLite transcript workers supply the history.

flowchart LR
  A[Control UI] --> B[Subscription coordinator]
  B --> C[Gateway observer admission]
  C --> D[Canonical history reader]
  D --> E[Transcript workers]
  E --> F[Combined response]
  F --> G[UI history owner]
Loading

Technical review

Best possible solution:

Keep replay and session-access custody through final publication, recheck disclosure authority after history completes, and release custody afterward.

Do we have a high-confidence way to reproduce the issue?

Source establishes the serial subscription/history path and the introduced replay-disclosure window; no target code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Combining admission with the canonical reader is a sound optimization, but moving final publication beyond the existing access lifetime violates its disclosure contract.

Full review comments:

  • [P1] Revalidate approval disclosure after the initial history read — src/gateway/server-methods/sessions-subscriptions.ts:269-270
    With includeApprovals and initialHistory together, approvalReplay is captured under the session-access checks, but read and prepared are released before the new awaited history read. A paired reviewer using operator.read under a role-limited session policy can begin on a shared foreign session, then lose access when its owner changes it to draft while history is loading. The history reader correctly refuses that session, yet this response still includes the earlier approvalReplay. Socket authority checks do not check that session's visibility, so approval presentation details are disclosed after access was revoked. Retain the existing session/replay access owners through publication and recheck them immediately before returning the replay.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f3464c792dbf.

Provenance checked

Testing

Proof path: shipped entry point.

Security

Needs attention: The combined acknowledgment can disclose approval presentation details after session access is revoked.

Evidence

Security concerns:

  • [high] Approval replay crosses the session disclosure boundary — src/gateway/server-methods/sessions-subscriptions.ts:269
    Approval projections include presentation data and approval links; sanitization does not authorize disclosure to a viewer who can no longer read the session.
    Confidence: 0.96

What I checked:

PR surface

Source +249, Tests +472, Docs +48, Other +326. Total +1095 across 38 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 20 2477 2228 +249
Tests 13 536 64 +472
Docs 3 55 7 +48
Config 0 0 0 0
Generated 0 0 0 0
Other 2 393 67 +326
Total 38 3461 2366 +1095

Review metrics

Metric Value Why it matters
Protocol extension 1 optional initialHistory object with 6 history selectors The additive request preserves omitted-field behavior and wire protocol v4; it introduces no stored-data format.
Benchmark options 2 new flags: --auth and --compare-bundle-dir These select authenticated comparison fixtures and separate baseline UI bundles.

Labels

Label changes:

  • add P2: This is a bounded chat-readiness improvement; its review finding concerns a specific shared-session disclosure path.
  • add merge-risk: 🚨 security-boundary: A viewer whose session access changes during initial history can still receive approval details captured before that change.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a bounded chat-readiness improvement; its review finding concerns a specific shared-session disclosure path.
  • merge-risk: 🚨 security-boundary: A viewer whose session access changes during initial history can still receive approval details captured before that change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 24, 2026, 4:22 PM ET / 20:22 UTC.

Preserve main-owned snapshot retirement and owned serialized buffers while issuing the initial history subscription without waiting for browser storage. Cover delayed storage and a changed cursor through the existing history owner.
Consume the exact full-page subscription receipt when browser storage restores a cursor during admission. Keep cursor-delta mismatches on the current history read path. The regression made two RPCs on the prior head and one with this fix.
@steipete
steipete marked this pull request as ready for review October 24, 2026 23:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T01:32:25.268018Z ed94965 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: ed949658241b909f558ac8835b57a9d27a7ee929
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server/ws-connection/request-start.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12e339678d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Keep replay and scoped read resources through the canonical history read, recheck disclosure authority before publication, and roll back provisional observers on revoked access. Update CI observers for combined history responses, preserve actual session capability behavior in fixtures, and remove speculative validator prefetch.
@steipete
steipete enabled auto-merge (squash) October 25, 2026 00:30
@steipete
steipete disabled auto-merge October 25, 2026 00:36
@steipete
steipete merged commit f20e7db into main Oct 25, 2026
167 of 171 checks passed
@steipete
steipete deleted the solid2/w-perf-remote-rtt branch October 25, 2026 02:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…182846)

* perf(control-ui): read initial history with message subscription

Return an optional initial chat snapshot after observer admission, preserving cursor reads and history retries while removing one sequential round trip from chat startup and session switches.

* perf(control-ui): defer reaction reads until transcript paint

* test(perf): bound simulated remote link queues

* perf(control-ui): prepare each foreground history worker

Initialize presentation code per actual history worker instead of warming only the slot selected by a pool task. Keep database admission in its existing prewarm owner and remove the superseded request flag. Search, projection, and maintenance workers remain lazy.

* test(perf): cover authenticated warm boot in wire benchmark

* test(perf): count gateway process work through readiness

* perf(ui): retain full initial history across cache hydration

Consume the exact full-page subscription receipt when browser storage restores a cursor during admission. Keep cursor-delta mismatches on the current history read path. The regression made two RPCs on the prior head and one with this fix.

* fix(ui): retain subscription authority through initial history

Keep replay and scoped read resources through the canonical history read, recheck disclosure authority before publication, and roll back provisional observers on revoked access. Update CI observers for combined history responses, preserve actual session capability behavior in fixtures, and remove speculative validator prefetch.

* chore(ui): attach history safety invariant to assertion
steipete added a commit that referenced this pull request Oct 26, 2026
)

The Control UI mock Gateway answered sessions.messages.subscribe with only the canonical key, even when the request asked for initialHistory. Since #182846 the real Gateway returns the initial transcript inside the subscription reply, so the fixture forced a fallback chat.startup round trip that production no longer makes. Every reload benchmark and browser test therefore measured an outdated request chain.

The mock subscription now builds initialHistory from the existing startup-response owner when requested, matching the Gateway contract. Scenarios that exercise the separate chat.startup fallback opt in with subscriptionInitialHistory: false. Browser tests wait on subscription readiness instead of the removed standalone history request, and the warm-reload probe recognizes the subscribed-history transport.

Test and tooling only; no runtime code changes. Exact-head CI green; focused fixture and probe tests plus native e2e of the rebased files pass; full AWS UI suite earlier: 3,275 passed, 2 failures reproduced on main.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…claw#183832)

The Control UI mock Gateway answered sessions.messages.subscribe with only the canonical key, even when the request asked for initialHistory. Since openclaw#182846 the real Gateway returns the initial transcript inside the subscription reply, so the fixture forced a fallback chat.startup round trip that production no longer makes. Every reload benchmark and browser test therefore measured an outdated request chain.

The mock subscription now builds initialHistory from the existing startup-response owner when requested, matching the Gateway contract. Scenarios that exercise the separate chat.startup fallback opt in with subscriptionInitialHistory: false. Browser tests wait on subscription readiness instead of the removed standalone history request, and the warm-reload probe recognizes the subscribed-history transport.

Test and tooling only; no runtime code changes. Exact-head CI green; focused fixture and probe tests plus native e2e of the rebased files pass; full AWS UI suite earlier: 3,275 passed, 2 failures reproduced on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui ci:full Keep ordinary native-locale CI selection on the next PR run. docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant