Repository navigation
improve(gateway): reuse profile facts during client connections - #170228
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR reuses committed profile catalog facts during authority preparation instead of issuing another worker read. Example: [email protected] reconnects with role admin while the Gateway profile catalog is resident.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this PR provides a focused connection-path optimization that current main does not implement; no concrete introduced defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe profile owner publishes committed identity, role, login, alias, and display facts; Gateway authentication and session-access consumers prepare those facts and check their authority before use. flowchart TD
A[Profile mutations] --> B[Shared state writer]
B --> C[Committed profile catalog]
C --> D[Authority preparation]
E[Standalone or full profile worker read] --> D
D --> F[Live authority checks]
F --> G[Gateway connection and privileged effects]
Technical reviewBest possible solution: Reuse the committed catalog under the existing authority fence, retaining worker reads for full profiles and standalone callers. Do we have a high-confidence way to reproduce the issue? Current main unconditionally dispatches the authority worker read even when the profile catalog is resident; the redundant request is source-verifiable, but no runtime measurement was run during this review. Is this the best way to solve the issue? The change fits the existing owner and preserves fallback and revision checks, avoiding another cache or freshness mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 069b5dda4813. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete bypass was found, but the changed authority source requires final-effect validation. EvidenceWhat I checked:
PR surfaceSource +22, Tests +45, Docs +5. Total +72 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 October 12, 2026, 4:47 PM ET / 20:47 UTC. |
Two tests still encode contracts that changed on main. The resident profile authority path added by #170228 consumes aliases and display facts that the personal-file mock does not provide; seven cases fail before exercising their intended behavior. The fallback notice added by #169773 is a stopped assistant message, so the cron test incorrectly counts the notice as a second answer. Complete the personal-file mock using the existing `UserProfileIdentity` and `UserProfileDisplay` types. In the cron test, assert one primary-to-backup timeout notice through `readModelFallbackNotice`, then count successful assistant answers separately. Preserve the original requester, revocation, filesystem, one-user-turn, provider-order, and successful-result assertions. Production code and authority checks are unchanged. Cached failure evidence: - Personal-file mock: [Bun job 115027766429](https://github.com/openclaw/openclaw/actions/runs/38313840692/job/115027766429), `profile.aliases` spread failure. - Cron transcript: scheduled-main [run 38317311743, job 115037168335](https://github.com/openclaw/openclaw/actions/runs/38317311743/job/115037168335), expected one stopped assistant message, received two. The same signature appeared in prior candidate CI. Source and history were checked against main `395ea60dea893feb48782c0ac5fd4fc5a148a42a`. The profile failure is a prior candidate observation; the cron failure is reproduced by the cited scheduled-main run. Changed-file formatting, basic lint, and whitespace checks passed. One isolated Codex review completed scoped-clean with no actionable P0–P2 findings; both changed tests passed in PR CI [38318717235](https://github.com/openclaw/openclaw/actions/runs/38318717235), testing merge `634ae26bddea49d922f784c57805b11db5159773` (candidate `d171a04362e17b99fae68e59f1e593f2b173edf2` into base `f307d643`). The run finished green: 20 successful and 29 skipped jobs. Selected lint, test types, baseline ratchets, source contracts, boundaries, guards, and the CI gate passed: ```sh pnpm test src/gateway/server-methods/users-personal-file.test.ts --maxWorkers=1 pnpm test src/cron/isolated-agent/run.fallback-transcript.test.ts --maxWorkers=1 ``` Test-only change: two files, +31/−3. One commit per root cause. CI executed all 42 personal-file cases (26.40s Vitest, 28.34s wrapper) and the cron fallback case (15.580s case, 29.67s Vitest, 31.20s wrapper). No local runtime timing is claimed. Standalone Knip and Madge jobs were not selected for this test-only PR; no fresh whole-tree graph pass is claimed. The bounded source disposition reuses the prior clean topology and unaffected production/export scans: these two test leaves add no exports or production edges. The only value import added is the existing leaf `readModelFallbackNotice`, whose sole dependency is the existing normalization-core record coercer. Other added imports are erased types from an already-imported module. The historical full-tree unused-file findings concern the unrelated executable roots repaired separately in #170347. Before landing, source checks against main `81ad3bf71935d80c60a8b4a34492e51630d883c3` found no changes to either repaired test or the imported fallback-notice helper. No SDK, schema, update, Doctor, plugin-loading or service-lifecycle change; no SQL/T1 performance claim. Direct-main publication previously hit repository protection, so this emergency repair uses the authorized exact-head PR squash fallback.
…penclaw#170228) Reuse the receipt-maintained profile catalog when preparing connection authority. Keep cold/full-profile worker reads and existing authority revocation and authorization checks. Retained Control UI connections use 15 -> 9 SQL statements and 4 -> 3 worker requests. Warmed-turn statements, requests, and main-thread SQL are unchanged; no latency improvement is established. Cover committed role/display updates and profile merges with a regression. Two Codex review rounds are clean; merged-head CI passes. Knip has only the independently reproduced unused UI-fixture exports already present on main.
…law#170355) Two tests still encode contracts that changed on main. The resident profile authority path added by openclaw#170228 consumes aliases and display facts that the personal-file mock does not provide; seven cases fail before exercising their intended behavior. The fallback notice added by openclaw#169773 is a stopped assistant message, so the cron test incorrectly counts the notice as a second answer. Complete the personal-file mock using the existing `UserProfileIdentity` and `UserProfileDisplay` types. In the cron test, assert one primary-to-backup timeout notice through `readModelFallbackNotice`, then count successful assistant answers separately. Preserve the original requester, revocation, filesystem, one-user-turn, provider-order, and successful-result assertions. Production code and authority checks are unchanged. Cached failure evidence: - Personal-file mock: [Bun job 115027766429](https://github.com/openclaw/openclaw/actions/runs/38313840692/job/115027766429), `profile.aliases` spread failure. - Cron transcript: scheduled-main [run 38317311743, job 115037168335](https://github.com/openclaw/openclaw/actions/runs/38317311743/job/115037168335), expected one stopped assistant message, received two. The same signature appeared in prior candidate CI. Source and history were checked against main `3dd81bae92980aecaf0920bbad841c10486dea75`. The profile failure is a prior candidate observation; the cron failure is reproduced by the cited scheduled-main run. Changed-file formatting, basic lint, and whitespace checks passed. One isolated Codex review completed scoped-clean with no actionable P0–P2 findings; both changed tests passed in PR CI [38318717235](https://github.com/openclaw/openclaw/actions/runs/38318717235), testing merge `634ae26bddea49d922f784c57805b11db5159773` (candidate `d171a04362e17b99fae68e59f1e593f2b173edf2` into base `68ba0b0a`). The run finished green: 20 successful and 29 skipped jobs. Selected lint, test types, baseline ratchets, source contracts, boundaries, guards, and the CI gate passed: ```sh pnpm test src/gateway/server-methods/users-personal-file.test.ts --maxWorkers=1 pnpm test src/cron/isolated-agent/run.fallback-transcript.test.ts --maxWorkers=1 ``` Test-only change: two files, +31/−3. One commit per root cause. CI executed all 42 personal-file cases (26.40s Vitest, 28.34s wrapper) and the cron fallback case (15.580s case, 29.67s Vitest, 31.20s wrapper). No local runtime timing is claimed. Standalone Knip and Madge jobs were not selected for this test-only PR; no fresh whole-tree graph pass is claimed. The bounded source disposition reuses the prior clean topology and unaffected production/export scans: these two test leaves add no exports or production edges. The only value import added is the existing leaf `readModelFallbackNotice`, whose sole dependency is the existing normalization-core record coercer. Other added imports are erased types from an already-imported module. The historical full-tree unused-file findings concern the unrelated executable roots repaired separately in openclaw#170347. Before landing, source checks against main `53575ccd561ef562d46ff259fc47b7f4582dc7dc` found no changes to either repaired test or the imported fallback-notice helper. No SDK, schema, update, Doctor, plugin-loading or service-lifecycle change; no SQL/T1 performance claim. Direct-main publication previously hit repository protection, so this emergency repair uses the authorized exact-head PR squash fallback.
What Problem This Solves
Client connections reread profile authority from SQLite even when the Gateway already holds the current role, display, GitHub login, and aliases in its profile catalog. On the measured reconnect path, this duplicate authority preparation costs four SELECTs plus BEGIN/COMMIT and one worker request.
User Impact
Connections now reuse the profile writer's receipt-maintained catalog facts. The catalog remains the single owner; no new cache, worker, schema, or invalidation protocol is added. Full-profile requests and cold/standalone callers keep the worker operation because the resident projection does not contain the complete profile. Existing authority revocation and credential/authz checks remain in place.
The hello snapshot, presence, configuration, and subscription projections already use resident owners. This change removes the redundant profile lookup rather than moving its SQL to another thread. Scope is separate from the startup projection and reply-initialization work.
Removed Duplicate Read and Accepted Edge Case
No security check is removed. The regression exercises real worker commits for admin-to-member changes, display changes, and source-to-target merging; the next authority is fresh, the prior authority is revoked, and no extra worker read occurs. No retired alternate cache or synchronous fallback remains.
Measurement
One same-host baseline/candidate pair under the current campaign proof policy: baseline
24dec4d6c370c9ac1b8f1f534efc20e8b37dd27a, candidate5d38fc0582d7ef4b638321a21379e1a08cfbc1b4. Remote Testbox run. The measured patch is unchanged in final headb04e6cf6edf1f99f7ed647978801c833f896b4e9, which mechanically merges maina3bbfaab02b265775f443b4d5fd4029525bd1b65to pick up unrelated export-scan fixes. Exact remote Git identities and harness hashes match; Node 24.21.0 / SQLite 3.53.4. Pre-run CPU idle was 99.25% for both revisions.The task-local copy of shared harness v2 preserves all 13 original turns and adds 20 signed Control UI connections using one installation identity. Samples 2–20 measure retained-identity connections; sample 1 is separate. Causal instrumentation counts successful native executions across all threads, excludes prepares, and attributes admission to its originating operation. All SQL attributed to the 20 measured Control UI connections executed before snapshot receipt; none occurred afterward. All turns, child execution, cron, compaction, shutdown, and connections passed. The initial fixture omitted the required Control UI build ID; that failed run was discarded, then both revisions used the build ID advertised by the initial hello.
The SQL target is met at the median; the −30% latency target is not met. This pair demonstrates a deterministic SQL/request saving, not a reliable latency improvement. The first UI sample was 19→13 statements, 4→3 requests, 61.060→93.885 ms; those single latency samples are not a distribution. These are instrumented loopback
auth=noneconnections with signed device identities, not browser-render or production token/Tailscale measurements. Owner attribution covers SQL/requests; wall time is measured for the entire connect-to-snapshot boundary.Zeros indicate no connect-caused SQL/worker request, not absence of in-memory work.
Legacy warmed-window means were 214.2→213.7 statements and 55.4→55.3 requests. Whole-workload totals, including boot and background work, were 6,966→6,831 statements, 1,300→1,283 requests, and MAIN 838→838. The profile authority operation saves exactly six statements and one request per connection; background scheduling is not credited as a product saving.
The corresponding distinct attached worker-request counts are 4, 2, 0, 0, 5 on both revisions (non-additive across families). Whole-workload family counts also do not rise: exact-entry 65→64, actor 36→36, snapshot 7→7, row facts 6→6, watermark 129→129. Stable SQL aliases/direct execution frames identify each family; no broad worker-operation name is substituted for a query family.
Proof and Scope
git diff --check: passed.a3bbfaab02b265775f443b4d5fd4029525bd1b65independently passes script/production Knip scans; its full-tree scan flags onlyTEAM_SCALE_CATALOG_PROGRESS_ID,TEAM_SCALE_COUNTS, andTeamScaleEventin untouchedui/src/test-helpers/control-ui-team-scale-fixture.ts.