Repository navigation
improve: speed up Control UI device authentication - #199136
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR uses native WebCrypto Ed25519 signing when available, preserves Noble fallback, and extends the boot benchmark to measure accepted connections. Example: A warm WebKit 27.2 reload uses an existing 32-byte device seed.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored draft open: it contains distinct signing work absent from current main, with no concrete introduced correctness defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Control UI signs a nonce-bound connection payload using its existing device identity; the Gateway verifies that signature before completing authentication. flowchart LR
A[Stored device seed] --> B[Browser signing owner]
B --> C[WebCrypto Ed25519]
B --> D[Noble fallback]
C --> E[Signed connect request]
D --> E
E --> F[Gateway nonce and signature verification]
Technical reviewBest possible solution: Retain the small change in the existing signing owner only if the declared whole-flow performance acceptance rule is met. Do we have a high-confidence way to reproduce the issue? Current main directly loads Noble at the signing boundary, and the profiling evidence in #199081 identifies pre-connect signing work; this read-only review ran no product code. Is this the best way to solve the issue? The existing signing owner is the right boundary: native signing removes JavaScript curve work, the bounded cache follows the seed, and the fallback module preserves supported insecure contexts without adding a network request. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 210458b3d434. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +45, Tests +118, Other +129. Total +292 across 8 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 14, 2026, 3:15 PM ET / 20:15 UTC. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
a42ba73 to
8671941
Compare
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* perf: use native Ed25519 for Control UI device signing * perf: preserve the lazy signer chunk for cold boot * perf: defer noble initialization inside the signer chunk * test: measure connected boot alongside cached UI readiness * perf(ui): accept measured native signing route bytes * test(ui): clear model search before checking picker dismissal
What Problem This Solves
Warm Control UI boot spends avoidable time in JavaScript Ed25519 curve math and initialization before connecting, especially in WebKit.
User Impact
The existing device identity now signs with native WebCrypto Ed25519 where available. Noble still derives public keys and handles insecure contexts, unsupported engines, and native import/sign failures. Public keys and stored seed, token, and credential formats are unchanged.
Why This Change Was Made
The native signing owner avoids JavaScript curve math and unused noble initialization during warm connection setup, while preserving the established identity and fallback contracts.
Result and coordinator-accepted timing band
Coordinator-accepted: localhost is the target flow, with a ≥5% gain required; the other conditions must not regress beyond the band. WebKit warm localhost connected readiness improves 433→365.5 ms (−15.59%), against A/A −0.46%. The 100 ms RTT guard improves 947→904 ms (−4.54%) across all 30 retained triplets, against A/A −0.79%. This is a guard improvement. The coordinator corrected the earlier wording requiring a separate 5% win at RTT; that correction is explicit rather than a claim that 4.54% met the original target.
The WebKit RTT first-UI p95 is 882→904 ms (+2.49%), within the coordinator's tail rule of no more than 5% above the higher control; that tail did not reproduce in the extra ten (867→865 ms). All original observations remain included. No new timing runs were performed for this band call.
Chromium and Firefox guards confirmed from the existing matrices: cold/warm at localhost and 100 ms RTT, both first UI and connected readiness, all stay within the band. The largest median increase versus base is +0.31%. The largest p95 increase above the higher control is +0.32%; no cell exceeds 5% on either comparison.
Signing and security contract
WebKit signatures are randomized and still valid. A same-seed/same-message WebKit 27.2 probe produced five distinct signatures, all verified against the RFC public key. The final-layout qualification separately delivered 50 native-signed real UI handshakes per engine accepted by a real isolated Gateway: 150 total. The wire signatures matched successful native signing output using non-extractable, sign-only keys. A tampered signature was rejected as
device-signaturein each of Chromium, WebKit and Firefox. Deterministic signature fixtures apply only to noble fallback; native outputs are cryptographically verified.The native owner imports the existing 32-byte seed in RFC 8410 PKCS8 form and caches only the most recent seed's non-extractable, sign-only key for the document. It stores neither signatures nor payloads. Failed native import/sign and insecure contexts retain the noble path and its input errors. Accepted edge: a rejected import stays cached until the identity changes or the document ends; noble remains usable.
Replay audit:
src/gateway/server/connection.ts:325creates a fresh UUID challenge per WebSocket.src/gateway/server/ws-connection/connect-auth.ts:384-408checks the two-minute timestamp window and exact connection nonce before signature verification.handshake-auth-helpers.ts:217-242reconstructs v3/v2 payloads;src/infra/ed25519-signature.ts:177-190callscrypto.verify, rather than deterministic re-signing. Watch HTTP consumes its challenge by nonce (src/gateway/watch-node-http.ts:490-499). Browser-pair throttling keys device ID and request ID (src/gateway/browser-pair-http.ts:194); pairing/token owners key device ID, role, public key, request ID or token. The actual UI (ui/src/api/gateway-connect-plan.ts:253-271) attaches signature bytes only as proof over the nonce/timestamp-bound v2 payload. No signature-byte replay, dedupe, idempotency or logging identity was found. The misleading V3 helper comment now describes payload reconstruction.Fresh independent security review of randomized signing, cache identity, non-extractability, fallback and Gateway verification found no actionable P0–P2 issues. The subsequent benchmark correction/test simplification was independently reviewed clean. The two cap changes were separately reviewed; implementation and measured bundles are unchanged.
Loading and bytes
Noble stays in the original lazy signer chunk but initializes only for public-key derivation or fallback. Emitted Rolldown output uses
Promise.resolve()for the nested import: native warm signing skips noble setup, and cold identity creation adds no network request. No theme/CSS/scheduling or dependency changes.Post-paydown comparison: base
18a62d6ff93428f15b0801ba5efe4ef0452a8f15→ reviewed head86719414f1ee17bdb50b9d42effa469e0dd3f6d9, same Node 26.12.1/toolchain, fixed build identity and matching canonical packaged Settings inventories (memory-core,nostr,whatsapp).Strict paired check passed: zero violations. The largest chunk's existing main overage is unchanged. Coordinator-accepted: only the original +235 B cap edits are reapplied to #199256's refreshed main caps: 1,310,659→1,310,894 B and 814,328→814,563 B. No shared-checker, startup, CSS, request-count or other cap changes. This integrated graph emits +238 B per route: 3 B above the original +235 B local measurement, within the checker's 64 B variance band and below both exact requested caps. The original Linux pair emitted +236 B.
Original qualification bytes are retained for comparison: startup JS 90,945→90,945 B and CSS 40,781→40,781 B; Chat 1,315,251→1,315,486 B and New Session 818,719→818,954 B (+235 B each). Original served startup JS was 91,606→91,619 B (+13 B generated asset-name noise).
The first post-rebase local pair was discarded because generated packaged-plugin inputs differed (ten catalogs in the long-lived lane checkout versus three in the fresh base). Source-map attribution placed all 2,730 added shared raw bytes in the generated
control-ui-distributioninventory; its 900 original source files were identical. Remeasuring the unchanged head in the existing proof checkout with the same three canonical catalogs removes that mismatch. No source or checker change was made to obtain the qualified pair.Evidence
scripts/perf/web-push-measure.ts: openssl(unlisted binary); no ignore or unrelated repairWorkload: real isolated Gateway/WebSocket, synthetic 400-message Chat, desktop 1440×1100, service workers blocked, headless Chromium 156.0.8078.4, WebKit 27.2 and Firefox 157.0. Twenty rotated base/head/base-control triplets per engine, cold/warm, at localhost and 100 ms TCP RTT; one predeclared additional ten WebKit RTT triplets. Host one-minute load ranges: localhost 3.288–9.607; original RTT20 4.655–8.953; extra RTT10 2.453–4.467. No model calls.
Measurement correction: cached transcript/composer can render before authentication. The initial first-UI-only RTT run closed 113/120 warm WebKit/Firefox samples before capturing accepted connect. Its separate first-UI result is retained (WebKit warm 842→834 ms); it is not connection-latency proof. The corrected runner preserves first-UI
readyMs, records connected readiness as max(first UI, first successful Gateway connect response), and waits for both before capture. The correction and metric were declared before corrected runs; frozen product bundles did not change. All 780 corrected samples include accepted connect. These are elapsed application phase measurements, not CPU claims.Known WebKit warm
index.htmlfetch access-control errors occurred in all RTT arms (30 rows each across 30 triplets); localhost had three base rows and one head row. No errors were hidden or reported as zero. In the original RTT20, challenge-to-connect drops 156→107 ms while connect response wait stays 107 ms in both arms.No appearance, storage or authority change; no screenshot proof applies to this nonvisual path. Solid refactor counters stay 0→0. Simplification preserves one signing owner and removes three redundant browser unit fixtures in favor of live Gateway qualification. LOC against the refreshed merge base: production/tooling 2,598→2,768 (+170; +129 extends the existing benchmark), tests 774→894 (+120), generated manifest 1,963→1,964 (+1). The signer itself is 13→49 lines across runtime and noble helper.
Retained timing matrices
Localhost connected readiness — 20 rotated triplets
Values are median / p95 in milliseconds. A/A is the unchanged base control.
100 ms RTT connected readiness — original 20 rotated triplets
Values are median / p95 in milliseconds. A/A is the unchanged base control.
100 ms RTT follow-up — the single predeclared 10 WebKit triplets
Values are median / p95 in milliseconds. A/A is the unchanged base control.
100 ms RTT connected readiness — all retained samples
Values are median / p95 in milliseconds. A/A is the unchanged base control.
100 ms RTT first UI — all retained samples
Values are median / p95 in milliseconds. A/A is the unchanged base control.
The original 20 RTT triplets, predeclared extra ten and combined thirty are all shown. The extra ten alone gave −5.32%; admission uses the full retained set and the coordinator-accepted target/guard rule. Earlier separate-chunk and static-initialization candidates remain rejected; this PR defers noble initialization within the original request boundary.
Post-paydown integration
Source paydown #199196 and cap accounting #199256 have landed. Rebased onto main 18a62d6 as requested; the only conflict was the cap hunk, resolved as exactly +235 B per route over the refreshed caps. The signer, noble helper, payload construction and verification owners, and benchmark blobs are identical to the qualified head: the existing 780 timing observations, 150 accepted native handshakes, per-engine tamper rejection and identity/fallback proof are reused. No timing rerun after integration, and no claim of newly measured timing on the refreshed main.
Fresh full-scope independent P0–P2 review, including current verification and replay owners, is clean. The two-line model-menu test correction passed on both exact product inputs. Main #199224 also fixes the stale direct-setup selector and terminal-upload recovery selector. Production Knip's sole
openssldeclaration failure reproduces with the same command on the exact merge base; completed broad replacement-head CI is qualified below.#199256 records the measured feature-owner table: the first New Session crossing was #197481, the first Chat crossing was #197804; the largest later contributors were localized slash commands #197817, Search/Compose #186059 and inline mentions #192242. Its coordinator-accepted accounting handles main's remainder separately from this PR's increment.
Historical main budget debt and CI investigation
The exact +235 B cap edits are retained. This PR adds 235 B to each route, coordinator-accepted; the rest of the overage predates it, from main at
bb905f76e55de2934e868434ea23c345893cdc6c. The paired Linux CI build measures +236 B per route, a 1 B difference from the local measurement.Source: PR size job 132578228987, Node 24.22.1, tested merge
4fd96b7a481d0823db96ac0993e9538b7254427d, explicitly comparing main bb905f7 with the merge of this PR. The unchanged checker rejects the +236 B differential because an over-cap base permits only 64 B variance, even after the cap increments. It reports: “base already exceeds the cap … no growth beyond 64 B build variance is allowed.”Scheduled-main qualification limitation: main's bbc05327 size job passed, measuring Chat 1,314,203 B against 1,303,711 B (+10,492 B) and New Session 817,774 B against 805,886 B (+11,888 B); it compared identical inputs and reported zero delta. The latest completed scheduled run 43626582044, ad6738d4 also passed the size job, at Chat 1,313,824 B (+10,113 B) and New Session 817,456 B (+11,570 B). Therefore the old absolute overage is proven, but an identically failing scheduled-main differential size check is not proven. No such failure is fabricated for inherited admission.
Direct setup failure now reproduced on the exact main base:
Control UI WhatsApp logout mocked Gateway E2E > completes direct setup as the selected channelfailed 10/10 on the CI-tested merge4fd96b7a481d0823db96ac0993e9538b7254427dand 10/10 on its main parentbb905f76e55de2934e868434ea23c345893cdc6c, using Chromium headless shell, the pinned Bun Vitest wrapper, one worker, and fresh browser contexts. All 20 attempts reached connected, route-ready state, then timed out atchannels-whatsapp-logout.e2e.test.ts:119looking for exact accessible nameSet up. Main #199130 (ef4a3c8b3abc) addedaria-label="Set up Slack"atui/src/pages/channels/view.tsx:316; the test and view blobs are byte-identical across these two inputs. The earlier scheduled-main pass predates that change. This is matching-case baseline reproduction of PR shard 6/7, rather than source-only attribution. No CI rerun: both arms reproduce. Exact-revision bundles were built on SSD and supplied to the unchanged E2E setup through a scratch config; no test or product source changes.Completed run 43637614411 contains five E2E failing cases across four jobs. Attribution after reading each failed job once:
completes direct setup as the selected channelkeeps the empty model picker beside Dictate at 390 pixelsuploads picked and dropped files, then pastes staged paths without Enterkeeps independent model and effort controls within the new composerkeeps the themed connection shell instead of the login gate while a configured token connectsNo product, signing, focus, timing, or budget-checker logic changed during these investigations. The full current-head CI after cap integration must still qualify the landing.
The requested wait is complete: #199196 and #199256 landed, integration and the strict size check are complete, and fresh native review/preparation now qualify the replacement head. The PR remains ready and all earlier evidence is retained.
Native auto-merge was retired through supported recovery while the gate qualification is unresolved. No budget debt was absorbed and no shared-checker behavior was changed.
Completed replacement-head CI and inherited-failure qualification
Full run43648875464, attempt1 completed failure on reviewed head
86719414f1ee17bdb50b9d42effa469e0dd3f6d9, tested merge71c44f1b5a133f5b37702a9959bfa0320d6894fa(main parentb37978a42bdf6363e42c7f5cdee922bb1ffe7753). All76 jobs are terminal. Size,security-fast, both real-Gateway shards, UI units and all remaining selected jobs passed. Only UI E2E jobs3/7 and4/7 failed, with these four cases; all also fail scheduled main43648056043 on exact merge base18a62d6ff934.Chat header connection feedback > keeps cached chat header geometry through a slow or failed connectionControl UI new-session page mocked Gateway E2E > keeps blocked palette readiness out of creation errorsControl UI mocked Gateway E2E > preserves tool source in Activity while bounding the visible preview.activity-emptytimeout119Control UI floating header page actions mocked Gateway E2E > moves page menus into the pill with the title centered at 320pxAll four test files and their common E2E harness are byte-identical across the exact merge base18a, tested main parentb379, and tested PR merge71c. The gate's table identifies the two jobs as pre-existing by job name only; the additional exact-case comparisons above supply attribution. Header geometry is a matching failing case/invariant, not an identical failure-signature claim. The CI aggregate fails solely downstream of those two jobs. Security policy/required review clearance remains subject to native live verification. No failed CI is relabeled green, no new run requested to chase green, no size exception used.
The earlier unmatched splash, original model-control, direct-setup and terminal-upload cases pass this replacement-head full run. Native inherited recovery uses only the four current matched failures, with exact run/attempt/head, checkout, source-object and retained-artifact bindings.