Repository navigation
refactor: use resident profile authority in Gateway requests - #169799
Conversation
Replace remaining Gateway role, theme, preference, and PR disclosure profile reads with the existing prepared catalog. Remove the separate role-assignment cache and superseded synchronous profile exports while retaining live revocation and effect-boundary checks. Cover committed role changes, deletion, and merged identities without main-thread profile reads. Shared SDK and CLI profile kernels remain explicitly tracked.
|
🦞👀 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 real behavior proof before merge. What this changesThis PR moves remaining Gateway profile checks to the existing resident catalog and removes the separate role cache. Example: The profile [email protected] is deleted after its guest role has been read.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep this useful maintainer-authored refactor open: current main still uses the superseded readers, and the earlier retirement and ratchet blockers are resolved. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway requests consume committed profile identities, aliases, and roles to authorize operations, persist personal preferences, select notification recipients, and disclose session PR results. flowchart TD
A[Profile mutations] --> B[SQLite owner]
B --> C[Committed publications]
C --> D[Resident profile catalog]
E[Gateway requests] --> F[Current authority checks]
D --> F
F --> G[Authorized effects and responses]
Technical reviewBest possible solution: Use the existing committed profile catalog as the sole request-path source while preserving live authorization and accepted-work lifetimes. Do we have a high-confidence way to reproduce the issue? Current-main source establishes synchronous profile reads and the separate role cache; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? Reusing the existing lifecycle-owned catalog is a focused simplification that preserves the established authorization owners without introducing another identity mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 52dce97d15df. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Source review found no concrete introduced authorization bypass. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -33, Tests +188, Docs +19, Other -9. Total +165 across 76 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 HistoryReview history (2 earlier review cycles)
Reviewed October 12, 2026, 6:51 AM ET / 10:51 UTC (Revision 3). |
Publish every changed profile key at native commit, including rows absent from the committed result. This preserves deletion invalidation for Gateway readers using the resident catalog, without additional storage reads. The existing role-policy regression exposed the stale row.
) ## What Problem This Solves The admitted Stop tests invoke real session authorization without first preparing the resident user-profile catalog. After profile reads moved behind Gateway-owned preparation, this fixture could fail before reaching the Stop effect or its authority assertions. ## User Impact This repairs test setup without changing production behavior. All authority, revocation, interruption, persistence, and cleanup assertions remain intact. Scope: one test file, +10/−0 lines. ## Why This Change Was Made Create the isolated profile schema and retain the existing Gateway-owned catalog in each of the four fixture scopes before creating clients. Keep that catalog through dispatch and cleanup, matching the preparation owned by the real Gateway. No security checks or production SQLite paths are removed. The preparation requirement comes from `e9204c6dc6c4` (#169799), which replaced the operator-role cold read with resident profile authority. This Stop fixture was omitted from that change's preparation updates. ## Evidence Publication head `09468ea504111959fd00d8a80667b2104504c2d6` is one focused commit on `36e78f215f1f058af15919da8a60c06797a759e8`. It preserves the reviewed source slice without importing unrelated changes or diagnostic ancestry. The fixture is byte-identical to V28. Formatting, basic lint, normal commit hooks, and one isolated Codex review passed. [Candidate CI target](https://github.com/openclaw/openclaw/actions/runs/38314924879/job/115029540805) passed **12/12**, including all previously derivative effect failures, access boundaries, and revocation before and after signal. The Bun target reported **53.02 seconds Vitest duration / 55.45 seconds wrapper wall time**. CI executed merge ref `dc9a1f2d6e855542653dd1ab3dd3249193791f92`, combining this head with main `e3735bccb4c5164c5ef0016248a2c09e07249840`; this is candidate merge-ref proof, not local execution. The complete candidate CI run is green: **19 successful jobs, 29 skipped**, including baseline ratchets, source contracts, boundaries, selected lint, core test types, and `openclaw/ci-gate`. Scoped static reuse: V28 run `38311910220` executed Madge with zero cycles. The complete Stop fixture and both added profile-owner imports match that source. V28 also executed Knip; its only findings were three unused Team scale exports, removed by `36e78f215f1f058af15919da8a60c06797a759e8`, already in this branch's base. Dependency manifests, lockfile, static runners, and all-export configuration match; the production Knip configuration differs only in a comment. This is source-audited reuse for the one-file change, not a fresh whole-tree Knip pass or a skipped check counted as success. This test-only repair makes no SQL statement/request or T1 performance claim. Schema, public SDK, update, and service lifecycle behavior are unchanged, so no update cell is required.
…w#169799) Use the existing Gateway-owned profile catalog for role fallback, themes, preference notifications, and PR disclosure. Remove six synchronous profile-reader call sites and the independent role-assignment cache while preserving live revocation and effect-boundary checks. Publish deleted profile keys at commit so the resident catalog cannot retain authority for removed profiles. Prepare the same catalog boundary in Gateway fixtures and cover role downgrade, deletion, merged identities, and request lifetime. Completes the remaining request-path work from openclaw#162896; shared SDK and CLI profile kernels remain tracked for a separate owner/API cutover.
…claw#170310) ## What Problem This Solves The admitted Stop tests invoke real session authorization without first preparing the resident user-profile catalog. After profile reads moved behind Gateway-owned preparation, this fixture could fail before reaching the Stop effect or its authority assertions. ## User Impact This repairs test setup without changing production behavior. All authority, revocation, interruption, persistence, and cleanup assertions remain intact. Scope: one test file, +10/−0 lines. ## Why This Change Was Made Create the isolated profile schema and retain the existing Gateway-owned catalog in each of the four fixture scopes before creating clients. Keep that catalog through dispatch and cleanup, matching the preparation owned by the real Gateway. No security checks or production SQLite paths are removed. The preparation requirement comes from `f33505aadd8c` (openclaw#169799), which replaced the operator-role cold read with resident profile authority. This Stop fixture was omitted from that change's preparation updates. ## Evidence Publication head `09468ea504111959fd00d8a80667b2104504c2d6` is one focused commit on `2531250f65253f9d6466ee7f2d50c80184b41e42`. It preserves the reviewed source slice without importing unrelated changes or diagnostic ancestry. The fixture is byte-identical to V28. Formatting, basic lint, normal commit hooks, and one isolated Codex review passed. [Candidate CI target](https://github.com/openclaw/openclaw/actions/runs/38314924879/job/115029540805) passed **12/12**, including all previously derivative effect failures, access boundaries, and revocation before and after signal. The Bun target reported **53.02 seconds Vitest duration / 55.45 seconds wrapper wall time**. CI executed merge ref `dc9a1f2d6e855542653dd1ab3dd3249193791f92`, combining this head with main `1d13b36288e5768886fa2badab13cc6830ef7a70`; this is candidate merge-ref proof, not local execution. The complete candidate CI run is green: **19 successful jobs, 29 skipped**, including baseline ratchets, source contracts, boundaries, selected lint, core test types, and `openclaw/ci-gate`. Scoped static reuse: V28 run `38311910220` executed Madge with zero cycles. The complete Stop fixture and both added profile-owner imports match that source. V28 also executed Knip; its only findings were three unused Team scale exports, removed by `2531250f65253f9d6466ee7f2d50c80184b41e42`, already in this branch's base. Dependency manifests, lockfile, static runners, and all-export configuration match; the production Knip configuration differs only in a comment. This is source-audited reuse for the one-file change, not a fresh whole-tree Knip pass or a skipped check counted as success. This test-only repair makes no SQL statement/request or T1 performance claim. Schema, public SDK, update, and service lifecycle behavior are unchanged, so no update cell is required.
What Problem This Solves
Gateway role fallback, theme authorization, preference notifications, and PR disclosure still called synchronous profile readers after Gateway startup had already prepared the authoritative profile catalog. Role fallback also maintained a separate 1,024-entry assignment cache, so a profile write needed another cache invalidation before fallback authorization saw it.
User Impact
These Gateway request paths no longer open SQLite on the main thread. A committed deletion now removes the deleted row from the resident catalog, so fallback authorization cannot retain a deleted profile. No configuration or migration is required.
Why This Change Was Made
Use the existing Gateway-owned catalog for those remaining callers, delete the assignment cache, and remove the two superseded internal synchronous exports. Profile write receipts now supply the same facts to role policy and the other readers. Real revocation, deletion, transport, and disclosure checks stay in place. Accepted work retains its independent authority; same-person WebSocket refresh keeps the connection valid. No schema, SDK API, or update behavior changes.
The deletion regression exposed an existing publication gap: the catalog installed rows returned by the committed query but never removed requested IDs that no longer existed. Publication now removes the affected IDs before installing the returned rows, without adding SQL or a second freshness mechanism.
This finishes the remaining request-path work from #162896 without its per-transport identity-lease design. Earlier pieces landed in #166283 (prepared disclosure), #164682 (current chat admission), and #164630 (personal model-account workers).
Inventory and scope
The eight shared T1 primitives remain explicitly accounted for: three in
user-profile-identity.read.ts, one inuser-profile-github-identity.ts, three inuser-profiles-internal.ts, and one inuser-profile-mutation.ts. Synchronous SDK catalog/bootstrap contracts and shared CLI/Doctor kernels keep these mixed modules from being marked worker-only. Changing those public contracts requires a separate owner/API cutover; this PR does not disguise them with inventory reclassification.Removed work and accepted edges
Live SQL measurement
One baseline/candidate pair, per the relaxed testing policy, using the shared workload unchanged. Baseline:
292a9887dbbf; candidate runtime:9842bc3c9f97with source atd5123805bead(subsequent docs/mock-ledger changes only). The final09ee25074728head adds a conflict-only main integration; these numbers describe the pinned pre-integration pair. Both runs passed all 13 top-level turns plus child, RPC, cron, compaction, and shutdown; workload time was 601.4s / 622.9s.Profile operations were identical: catalog 1 request / 2 statements; authority resolution 3 / 19; ensure-owner 1 / 37; GitHub attribution 1 / 5; channel identity 1 / 4. Total: 7 requests / 67 statements → 7 / 67, all outside warmed turns. This fixture has no configured roles and does not call themes, preferences, or PR disclosure, so the raw reductions are not claimed as savings from this PR. The removed paths are covered by focused regressions with zero main-thread profile SQL. Whole-workload MAIN +5 is in unchanged session-entry/participant reads around second-session, compaction, and shutdown; no profile SQL was added.
Shared-family attribution across ten warmed turns (means per turn):
The shared ACP increase is seven executions of the same unchanged
acp_sessionsSELECT across ten turns. Background refreshes were 52 → 56 requests and 21 → 29 SELECTs; exact reads were 10 → 10 requests and 1 → 0 SELECTs. Each invocation still executes zero or one SELECT. Both saved configs omit roles, both RPC inventories omit the changed endpoints, no preference event or profile delete/merge occurs, and all profile operations match exactly. This is background cache miss/coalescing variation, not new profile invalidation. Both captures have zero SQLite errors and exact census conservation, with the same two known unresolved boot observer targets. The exact-entry operation total rises by four statements across ten turns because one candidate turn carries 13 existing row-cache trigger initialization statements (one temp-schema inspection, six DROP, six CREATE atsession-accessor.sqlite-entry-revision.ts:54), offset by eight fewer exact-entry SELECTs and one fewer participant SELECT. Its request count falls, and no query shape or profile operation was added.Evidence
Local formatting, basic oxlint, and
git diff --checkpassed. Both Codex autoreview rounds are complete: the production change had no actionable P0–P2 findings, and the fixture follow-up had no P0/P1 findings. Focused regressions cover immediate role downgrade/deletion, merge-sensitive theme authority, preference recipients, and PR disclosure with zero main-thread profile SQL. Existing continuation and WebSocket refresh contracts remain unchanged.Direct-call test fixtures now retain the same profile catalog that production Gateway startup prepares. The first CI run exposed those missing startup boundaries; the follow-up also makes the self-archive lifetime test wait for its existing authority subscription to be installed before archiving. Its synchronization uses a deferred, with no sleeps or polling. Two unrelated initial session-test failures have fixes on the current CI merge base:
8155863d0d1f4(#169673) waits for committed preview backfill, andfe79a0ff62af6rejects mismatched warm-window identities.Final CI run 38237991902, head
09ee250747287519bb0d7e72409d6f7dd1c70c51: all production/test typechecks, every lint stripe, source contracts/export boundaries, guards, Madge, docs, build artifacts, config docs, plugin inventory, and static ratchets passed. T1 is 536 → 536 globally, compatibility 2 → 2, and all dialect groups 0 → 0. The nine obsolete mock-baseline entries were pruned with the native tool. All 62 selected touched test files passed, including the committed role-change/deletion regression (96ms). Security and dependency reviews passed.Knip full-tree root/UI scan passed in 7m26s with no findings. Its production scan reported three unused exported types also reproduced by the same rules on pinned main
eb82fe6432d8:AgentWorkspaceContextParams,AgentWorkspaceContext, andOpenAiCompatibleImageProviderOptions. Their source is unchanged on the integrated head. The fourth earlier finding,renderPublicSessionCardSvg, was fixed upstream and is included in this head.Two unrelated runtime shards remain red, and therefore the aggregate CI gate is red. The authorized relaxed landing route is used with this evidence; they are not reported as green:
session-transcript-runtime.test.ts: transcript replacement returns “Session transcript projection is rebuilding” before the cursor mismatch check. The test, SDK export, catalog reader, history reader, worker runtime, reconciliation, and projection-error owners are byte-identical between the tested main base and this head. The failing read occurs before sender/profile preparation. Recent exact main runs were cancelled or security-only, so there is no claimed matching main runtime replay.server.sessions-send-resume.test.ts: the same six preparation/communication-receipt failures as the previous run. The test and six authority/receipt/patch owners are byte-identical on the tested main base and this head. The failing communication invalidation path excludes profile/catalog events and follows successful profile authority checks. No matching main runtime replay is claimed.Earlier CI caught the missing startup fixtures, catalog deletion bug, and stale mock baseline; these were fixed and verified. The earlier wrapper-inventory and avatar failures are absent from this run. Both allowed autoreview rounds are complete; no additional review loop was added. Diff: 76 files, +403/−238 lines. The six production files remove 33 lines overall; most changed files are startup fixtures. No update cell or SDK API diff is needed: schema/migrations, updater, Doctor, plugin loading, service lifecycle, and SDK API are unchanged.
Validation gap:
ui/src/e2e/session-pr-reader-lifetime.real-gateway.e2e.test.tsis typechecked but excluded from ordinary PR execution. A focused native run stopped before tests after 126.25s: the artifact-safety guard could not resolve the managed Gateway launcher to a package root and therefore could not prove physical separation. No artifacts or live service were changed; no guard was bypassed and no proof lease was created. The other 62 touched test files have passing cases in the current CI run. This non-executed UI integration check is recorded under the relaxed testing policy; it is not claimed as passing.