Repository navigation
perf(profiles): prepare disclosure through the profile reader - #166283
Conversation
Read self-profile details with the existing authority snapshot, prepare exact project aliases in the reader, and hydrate the resident catalog without native SQL. Keep physical-store aliases attached to one replacement catalog and retain current profile facts for cookie and media disclosure. Preserve synchronous SDK fallbacks, existing schemas, write ordering, settlement, and permission behavior.
Select one agreeing cookie profile reference before preparing its catalog, and avoid starting preparation for responses that already ended or closed. Keep the final policy and post-await lifetime checks. Exercise the real asynchronous HTTP boundary and preserve zero storage work for mixed grants and terminal responses.
Prune obsolete profile mock allowances and keep the media session type private after moving its last external consumer. Carry Vincent Koc’s already-landed private CallBrief export fix from #166147 so the pinned base passes the same unused-export guard.
|
🦞👀 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. Reviewed October 7, 2026, 6:00 PM ET / 22:00 UTC (Revision 24). ClawSweeper reviewWhat this changesMoves Gateway profile disclosure and catalog preparation to database workers, avoids unnecessary participant alias reads, and preserves retention progress across session metadata patches. Merge readiness✅ Ready for maintainer review Keep open as useful, ready work: current main still performs the targeted native profile reads, and the previous integration-evidence request is satisfied. No actionable correctness or security finding remains. Likely related people: steipete and vincentkoc, based on prior merged profile-authority and catalog work (medium-confidence routing). Priority: P2 Review scores
Verification
How this fits togetherThe Gateway uses profile identity, roles, and aliases to authorize requests and present session information. Database workers prepare these facts, while Gateway owners check current authority before returning profile data, assets, or media. flowchart TD
A[Profile and HTTP requests] --> B[Database read worker]
C[SQLite profile state] --> B
B --> D[Retained profile catalog]
D --> E[Current authority checks]
E --> F[Profile and session responses]
E --> G[Plugin assets and media]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +133, Tests +626, Docs +22, Other -2. Total +779 across 69 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing worker and profile owners for preparation while preserving synchronous final authorization, released SDK contracts, and committed retention receipts. Do we have a high-confidence way to reproduce the issue? Not applicable as a new bug reproduction: source inspection establishes the native reads being optimized, and the recorded paired Gateway workloads exercise the changed paths. Is this the best way to solve the issue? Yes. Reusing existing database and profile owners avoids competing storage or authority mechanisms, and the compatibility and lifecycle evidence supports the cutover. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 400bab4a7937. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (23 earlier review cycles; latest 8 shown)
|
Merge current main while preserving profile disclosure through the existing reader and main's GitHub identity binding and error handling. Prepare profile-bound browser asset cookies through the catalog owner, retain that catalog through the response, and recheck current request authority before serving bytes. Cover cold/replaced catalogs and credential rotation or response closure during preparation. Preserve RPC, SDK, storage, and permission contracts.
|
@clawsweeper re-review The browser-asset cookie caller is corrected at 932b473. Cold/replaced catalog requests and authority invalidation during preparation have passing boundary tests, including a negative control. The PR body records current proof and the remaining landing prerequisites. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Reuse the row owner's optional stored-entry type and remove the redundant session-entry type import. This keeps the integrated projection within its line limit with byte-identical emitted JavaScript and no signature change.
Preserve main's worker conversation guard alongside the metadata-only retention receipt. Retain all host-owned test routes and append this PR's cookie suite to the existing membership list without changing its routing.
Merge main's TEMP-generation schema validation optimization so the profile cutover and metadata retention receipt are tested against the current owner. Preserve main's mutation tracking and the retention freshness, transaction, and live-lease boundaries.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Preserve main's fixed-operation patch path and cover its metadata writes with the active retention receipt. Capture before patch-owned preparation and publish only after an actual metadata mutation and its replacement receipt preparation. Extend the existing retention boundary fixture for reducer commits and replacement.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Move the six retention cases without changing their assertions and share the existing database fixture. Keep the patch suite within its line budget while preserving both callback and worker-reducer coverage.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…aw#166283) * perf(profiles): prepare disclosure through the profile reader Read self-profile details with the existing authority snapshot, prepare exact project aliases in the reader, and hydrate the resident catalog without native SQL. Keep physical-store aliases attached to one replacement catalog and retain current profile facts for cookie and media disclosure. Preserve synchronous SDK fallbacks, existing schemas, write ordering, settlement, and permission behavior. * fix(profiles): reject inadmissible cookie reads before preparation Select one agreeing cookie profile reference before preparing its catalog, and avoid starting preparation for responses that already ended or closed. Keep the final policy and post-await lifetime checks. Exercise the real asynchronous HTTP boundary and preserve zero storage work for mixed grants and terminal responses. * chore(profiles): keep ticket assertion invariant adjacent * chore(profiles): finish cutover guard cleanup Prune obsolete profile mock allowances and keep the media session type private after moving its last external consumer. Carry Vincent Koc’s already-landed private CallBrief export fix from openclaw#166147 so the pinned base passes the same unused-export guard. * refactor(gateway): express projection startup drain condition * fix(gateway): satisfy profile cutover lint contracts * test(gateway): finish profile reader fixture migration * refactor(gateway): reuse prepared row owner type Reuse the existing prepared-reader owner parameter type for projection callbacks, removing the duplicated structural declaration. This restores the line cap without changing emitted JavaScript or runtime behavior. * perf(sessions): skip unused worker participant profile reads Resolve profile aliases only after an exact participant miss in the sharing worker. Preserve native eager preparation, merge attribution, participant limits, and transaction publication through the shared implementation. * perf(trajectory): reuse retention facts for metadata patches Advance the active sweep's committed mutation counter after session metadata patches without re-aggregating unchanged trajectory rows. Keep foreign-write, lease, rollback and connection-lifetime checks and the existing append/trim receipt behavior. Cover the worker patch boundary for commit, generation replacement, rollback and foreign writes, including the aggregate-read budget and retention outcome. * refactor(gateway): derive stored entry type from projection row Reuse the row owner's optional stored-entry type and remove the redundant session-entry type import. This keeps the integrated projection within its line limit with byte-identical emitted JavaScript and no signature change. * test(sessions): split metadata retention coverage from patch suite Move the six retention cases without changing their assertions and share the existing database fixture. Keep the patch suite within its line budget while preserving both callback and worker-reducer coverage.
What Problem This Solves
Self-profile disclosure, project recents, and cookie/media policy checks queried SQLite on the Gateway thread. Session projection startup also hydrated the profile catalog natively before preparing it through the reader.
User Impact
This internal performance and ownership change preserves RPC shapes, schemas, stored bytes, permissions, FIFO writes, and accepted-write settlement. It adds no service, cache, dependency, or new
OPENCLAW_*name.Why This Change Was Made
users.selfreuses identity and GitHub facts from its existing authority snapshot. Project recents prepare exact aliases through the read worker, preserve next-request foreign-commit visibility, and recheck current authority after awaited work. The resident profile catalog hydrates off-thread and remains retained through projection and HTTP response lifetimes; warm catalog reads use memory.Catalog replacement moves every alias to the replacement together and revokes old prepared identities. Cookie, asset, and media-ticket paths retain canonical profile resolution and current plugin access checks. The generic Gateway catalog hydration and person-reference SQL fallbacks are removed.
Worker participant writes now resolve profile aliases only after an exact participant miss. The native adapter still prepares aliases before its agent transaction. Exact-first selection, alias ordering, participant limits, rollback and publication remain intact.
Session metadata patches previously invalidated an active trajectory-retention sweep through the connection-wide mutation counter. Their receipt now advances only the committed counter, reusing the sweep's prepared run summaries because metadata upserts do not change trajectory rows. The freshness probe, lease and connection checks, deferred publication, rollback behavior and retention policy remain unchanged. Actual trajectory appends and trims still publish refreshed session summaries.
Evidence
Current head
f6b8cefbd66552ed0b824557d2f0c2f5d6de131f, treece61d633d528fc59a23744bf76accd315bcfd80b. It is a test-only descendant of production head85e08d2d83442fac07b8cfedb7b450370622d7d3, which integrates mainc6698b1e9b2b4adc9e0c2b0ee10439fe9936b693with a merge commit. Full production P2 review and the extraction review are clean. Final SQL and SDK qualification pass. Exact-current-head CI, ClawSweeper and the corrected 21-file integration run are complete. No merge or auto-merge request has been submitted.Exact-head CI is green: 108 successful checks, 61 skipped, one neutral and three successful status contexts, including the enforced CI gate. No CI rerun or admin exception was used for this head. All task-owned cloud leases are released.
The metadata receipt covers both callback patches and main's fixed-operation reductions. The negative control retaining callback-only capture failed exactly the reducer commit/replacement cases on retention completion, while the four original controls passed. Both final test files pass all 26 cases in 245.69 seconds including cold worker compilation; the session-test type graph passes in 13.41 seconds. The six moved retention cases are unchanged. Their extraction fixes the integrated test's 1,071-line failure against its 1,000-line cap; line and mock-export guards pass without exemptions. No assertions, timeouts, sleeps or retries were weakened.
The selected 21-file run covers both patch files, retention, turn/source publication, maintenance, deferred plugin refresh, placement and import/build boundaries, plus core/core-test/test-root types, Madge, focused lint and structural guards. All 21 files passed on f6 in 519.65 combined runtime command seconds. Core production types passed in 16.84 seconds, core-test types in 390.02 seconds, test-root types in 63.38 seconds and Madge in 18.20 seconds (zero cycles); focused lint/format and every structural guard passed. The complete focused proof took 1092.54 seconds, with no failed command or rerun. Exact head/tree/parents/base, source cleanliness, sealed inputs and all unique passing paths were independently verified. Archive SHA256:
70d17e4fb966282def90ac4f295ca19010393ca3c940ccc75b6bdb76259643c3. The completed 72-file e599 run remains evidence for unchanged contracts (1463.32 combined command seconds, full changed/types 1378.39 seconds, Madge 18.25 seconds). Its captured source/base/parents and all distinct passing file paths were independently verified. Prior archive SHA256:23d3e5024509dbd377189b12ec908b40b6055cc6fec2af6111af55b9a830e776.A separate integrated projection line-cap failure was repaired by
f8388333eefewith an equivalent type reference; the emitted JavaScript was byte-identical. Metadata repaira77bcdee624ebremoved repeated trajectory aggregates. Main's phase-local reducer integration is85e08d2d8344; the test-only cap repair isf6b8cefbd665.Final SQL qualification and measured-source reuse
The final measured flows satisfy the coordinator rules. Measurements compare main
c6698b1e9b2b4adc9e0c2b0ee10439fe9936b693with production head85e08d2d83442fac07b8cfedb7b450370622d7d3, using three alternating main/candidate pairs for full and focused workloads. All 12 workloads completed; independent inspection matched native/census sequence, site, phase and worker identity and conserved exact phase/thread/SQL totals. Zero native SQL calls failed. Node 24.21.0 / SQLite 3.53.4 / pnpm 12.5.1 match. Archive SHA256:cdc356fa5ef1bb9618beb92695a3356666c2d93f8b7ddd8d6c73a6eca175befa.The landing head
f6b8cefbd66552ed0b824557d2f0c2f5d6de131fis a direct test-only descendant. Its exact diff changes onlysession-entry-patch.test.ts, addssession-entry-patch.retention.test.ts, and addssession-entry-patch.test-support.ts. The helper has exactly two static consumers, both those tests. Excluding exactly these three paths, all 52,764 tracked tree entries have identical modes/blob IDs and manifest SHA25650c1fc4dd4f01cf996fdbed6f0819c3fc48bb47b78a6f7c9cb44312d7db33073. There are no runtime, dependency, build configuration or workload changes. Raw results remain labeled85e; reuse forf6rests on this source identity proof, not relabeling or an unperformed rerun.First/warmed medians improve; the 0.5% turn-noise exception is unnecessary. The positive non-turn windows (+1 second-session, +5 control-plane, +1 focused-connect) fit the absolute tolerance and have the owner attribution below. All other aggregate full-flow medians are flat or lower. The complete users.self/projects.list flow comprises ten requests; individual slices can contain periodic work and are retained without substituting a favorable slice.
Every positive warmed command group: totals below cover all 30 turns; group medians are diagnostic and are not added to construct a flow median.
session-exact-entriesreadExactSessionEntriesWithLifecycle/hasOpenClawAgentReadOnlySchema; sender session initialization and existing Gateway session readers. Existing schema/user-version/metadata checks; 1290 requests unchanged.8785:9:task-worker:155; 2026-10-07 21:08:36.769audit.writer.processsrc/audit/audit-event-writer.ts→audit-event-writer.worker.ts. Existing audit writer schema admission; request count unchanged.13531:5:sqlite-broker:625; 2026-10-07 21:16:15.243pluginState.entriesnotifyPendingPairingRequests(extensions/device-pair/notify.ts) → plugin-state worker entries. Concrete scheduled device-pair notifier; two additional entry reads fall in warmed windows.8785:5:sqlite-broker:507; 2026-10-07 21:08:46.161workers.placementProjectionrunRead/dispatchQueuedReadsinsession-row-placement-projection.ts→ placement store reader. Existing placement reader revalidation; 360 requests unchanged.8785:8:task-worker:291; 2026-10-07 21:08:45.488sessionRows.sharedFactswithSessionRowDatabaseFacts/readExactBatch→readSharedFacts/ ACP reader. Existing refresh facts/cache checks; total requests decrease 325→324.8785:7:task-worker:127; 2026-10-07 21:08:37.043acpSessions.metadatachat-send-admission.ts→session-meta-readonly.ts→readAcpSessionCommand. Existing ACP/schema admission; 60 requests unchanged.8785:7:task-worker:142; 2026-10-07 21:08:38.689devicePairing.listnotifyPendingPairingRequests→ device-pairing reader. One additional scheduled notifier read falls within warmed windows.8785:7:task-worker:294; 2026-10-07 21:08:46.160session-entry-readreadSessionEntryWorkerRequest→resolveSessionEntry; senders include reply session baseline and local-turn preparation. Existing private-entry schema/participant cache checks; 240 requests unchanged.8785:9:task-worker:166; 2026-10-07 21:08:36.894auth-profile-rowsreadAuthProfileRowsReadOnly/sqlite-json.tsthrough readonly helper process. Existing helper connection/schema/WAL checks; 90 requests unchanged.process:8937:7; 2026-10-07 21:08:36.978The pairing rows have observed scheduler capture→send→receive→SQL links to the device-pair notifier, not a background label inferred from table names or thread IDs. Other rows use their retained request/native stacks. Every source file in every positive warmed group was Git-blob-compared at the exact main/85e pins; the only changed file is the shared reader in the explicitly marked rows, whose relevant dispatch branches are unchanged. There are no positive warmed SQL groups with missing-send or unbound provenance. Profile catalog preparation occurs once/run during boot on both sides; no warmed profile catalog/alias/authority requests occur. New readiness checks are memory-only; the catalog-hydration path requires a catalog request, absent in these windows.
Positive non-turn windows and other important offsets:
mentions.mutate: SQL [7,7,7]→[7,9,11], requests 1/run unchanged; schema/user-version checks.mentions.snapshot: SQL [10,10,10]→[10,13,13], requests 2/run unchanged; schema/user-version/schema-metadata checks.commitMentionChanges/readMentionSnapshot→ mention-inbox worker/synchronization functions are unchanged. Only generic shared-reader profile dispatch differs; the mention branch is unchanged.session-row-placement-projectionqueued reads andwithSessionRowDatabaseFactsrefresh functions. Generic reader file has unrelated profile edits; these execution branches and sender functions are unchanged. No added profile hydration command.commitSessionEntryPatchare PR-touched. The executingreadSessionEntryPatchSnapshotfunction is byte-identical, as are its lower readers. No retention-capture or trajectory-aggregate SQL is observed in this phase. Source has a zero-SQL guard path when no current sweep exists; the trace does not directly observe WeakMap state.resolveSessionKeyForRequestInternal→prepareAgentCommandExecution→agentCommandFromGatewayIngress→chat-send-commentary-media.prepareWorkerGeneration/PreparedModelRuntimeBuildResources.load/acquireAgentRuntimePluginRegistryunchanged. Phase placement, not added profile catalog work.sessionDelivery.listSQL is 10/run on both sides; complete users.self flow 15→10 statements/request.startPendingSessionDeliveryRuntimeto restart-continuation delivery recovery; all relevant owner/sender/native files unchanged.The repaired retention receipt executes eight freshness reads and zero trajectory aggregates during the first turn of every final pair. Main starts/reads/deletes retention twice; candidate once. Combined retention-owned first-turn SQL is 48→43 in every pair. The reducer route captures for operation-or-next inputs and publishes only after an actual write; this preserves correctness without restoring aggregate reads. No receipt SQL is observed in warmed or second-session windows.
Non-turn trace samples:
session.entry.patch.prepare8785:13:sqlite-broker:890session.entry.patch.commit8785:13:sqlite-broker:934sessionRows.sharedFacts8785:7:task-worker:496workers.placementProjection8785:7:task-worker:502mentions.mutate11206:5:sqlite-broker:1108mentions.snapshot11206:7:task-worker:608sessionDelivery.list10282:6:sqlite-broker:45catalog10282:9:task-worker:1Raw audits retain all full source stacks, sender/receiver timestamps, monotonic times, request IDs and scheduler capture IDs. Line positions are advisory because of the existing source-map warning; owner assessments also use function symbols, command branches and pinned source/blob comparisons. Missing and unbound observations remain explicit rather than globally labeled background. Row payloads were intentionally not logged, so the exact row identity behind each cache miss cannot be reconstructed; the executed owner/operation and request census are recorded.
Historical +173 non-alias statements were attributed by receiver to row facts +62, state leases +46, target inventory +29, shared reader +25, plugin metadata +12, private entry +8, maintenance/activity −9. That nonalternating series lacked event clocks and sender census. Its exact initiating requests cannot be recovered; new worker IDs/timestamps are not retroactively attached to old events. Qualification uses the final alternating
85e/c669series, then the separately proved test-only identity from85etof6.Historical block-ordered receiver attribution
readSessionStoreTargetInventoryReleased SDK compatibility
The local c669→85e SDK report passed in 809.42 seconds, with zero direct SDK signature/kind changes, zero entrypoint changes and 130 compatible reachable-only exports. All five declaration differences match the already audited optional profile-authority fields, internal participant/retention helpers and equivalent projection types. Digest
a1b5215102060de63a0d96091ab6c72872b7fda2d51723c42073bf3b93ce6dd5(acknowledgementa1b52151). Stablev2026.9.8and betav2026.10.1-beta.1were checked; existing released signatures remain compatible.Reuse for f6 was separately verified from the exact three-file test diff. The new helper has only two test consumers, no ambient/global declarations, and is outside the SDK's explicit source and declaration roots. All runtime, SDK inventory/configuration, tooling and dependency bytes are unchanged. Broader namespace/configuration admission fingerprints observe the added paths; this is semantic SDK-input equivalence, not identical admission receipts or an unperformed f6 SDK run. Original report identity is preserved. All SDK temporary worktrees are removed.
Retained compatibility, CI history and overlap
Released synchronous coding-tool creation, Mention Inbox/model-account methods, transcript presentation and standalone bootstrap retain their native cold selectors. Eight shared profile sites remain follow-up debt until compatible callers migrate. The pre-existing indexed shared-profile alias fallback at
src/config/sessions/session-accessor.sqlite-participants.native.ts:86remains on worker exact misses; native preparation remains before the transaction. No new host read is introduced inside a grant.Earlier CI reds for terminal-font typing and X publication were independently inherited and resolved by integrated main fixes
1d10375ee563bandd641ea18101f8. Earlier worker-abort failures reproduced on both sources and their main fixes are integrated. No job was rerun merely to obtain green. Earlier ClawSweeper findings on browser assets and Activity fixtures were repaired and verified; the preceding head's review had no actionable correctness/security findings. ClawSweeper completed on f6 at 2026-10-07 21:25 UTC with no actionable correctness or security findings; its remaining evidence request is now complete.Overlap includes #166102, #166054, profile-adjacent worker cutovers, incognito #165901, locked writes #165921, ownership umbrella #162433, and test consolidation #166619. Main integrations preserve session authority, native creation, adjacent cleanup, avatar reuse, executor/worker repairs current reader custody, conversation worker authority from #166259, and phase-local reducers from #166674. The hunks remain focused on profile disclosure and its measured retention interaction.