Repository navigation
refactor(gateway): deslop gateway request and runtime flows - #162874
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: blocked before merge. Reviewed October 2, 2026, 12:22 AM ET / 04:22 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR consolidates Gateway session targeting, permission predicates, queues, normalization, and lifecycle helpers while retaining existing request behavior and strengthening validation fixtures. Merge readiness⛔ Blocked before merge - 3 items remain This maintainer-requested cleanup remains useful and has no concrete blocking code finding. The previously identified published-updater compatibility proof gap remains unresolved. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway receives requests from chat clients, plugins, and operators, resolves their session and permissions, and dispatches work to agent, device, and maintenance owners. These shared helpers coordinate that dispatch and its runtime lifecycle. flowchart TD
A[Clients and plugins] --> B[Gateway request admission]
B --> C[Session and permission resolution]
C --> D[Agent and maintenance handlers]
D --> E[Ordered runtime work]
E --> F[Replies and session events]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -193, Tests -19, Other 0. Total -212 across 58 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the shared-owner cutover with unchanged request and stored-state contracts, supported by published-updater compatibility evidence. Do we have a high-confidence way to reproduce the issue? Not applicable: this is an internal refactor, and source review found no concrete introduced failure to reproduce. No target code or tests were executed during this read-only review. Is this the best way to solve the issue? Yes: reusing the existing targeting, queue, normalization, and scope owners is a maintainable consolidation; the remaining gap is upgrade evidence rather than an identified code repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2dd93a290b74. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
## What Problem This Solves The Control UI still reads top-level session selections and rewrites durable shared-token settings produced before the supported July 2026 upgrade window. ## User Impact Upgrades from pre-July-2026 versions are no longer migrated: top-level remembered session selections and durable-token settings cleanup. Users with those unsupported selections can select their session again; conversations remain on the Gateway. Current shared credentials stay in session storage and are never restored from durable settings. ## Why This Change Was Made This implements the maintainer's July-and-later migration policy at the settings owner. The scalar session writer was replaced by `sessionsByGateway` in d37e3d5, first shipped in v2026.3.22 (March 23); v2026.3.13-1 was the last prior tagged writer. Durable token writes were removed by 10d0e3f, first shipped in v2026.3.7 (March 8); v2026.3.2 still wrote them. Actual v2026.7.1-beta.1, v2026.7.1, and v2026.7.35 source writes `sessionsByGateway` and omits durable tokens. The July sidebar-pins upgrader, device-token import, and chat-outbox/group migrations remain: supported releases still produced those shapes. The September-published v2026.7.35 still writes outbox v1 and browser-local groups, so main's earlier cutovers are insufficient evidence for deleting them. Net production reduction: 9 lines. The obsolete migration test is removed, and the existing settings-upgrade test now exercises representative July beta/stable persisted shapes. No protocol, schema, SDK, or rendered appearance changes. ## Evidence - Isolated Codex AutoReview: no actionable P0–P2 findings. - Blacksmith Testbox, pinned source and edited-file hashes: settings and preference suites passed, 33 tests, 1.60 s total Vitest duration; July beta/stable fixtures load, migrate pinned routes where present, and round-trip. - Both import-cycle checks: 0 cycles. - `check-changed` against pinned base 04fbf17: passed, including UI types, eight affected test-type graphs, lint, i18n, and dead-export checks. - Doctor legacy-config and migration suites: both passed (32.03 s across the two Vitest shards, including cold worker preparation). - `git diff --check`: clean. The repository wrapper's source staging hit local ENOSPC before upload. Native Blacksmith sync on the same owned lease verified the exact base and file hashes and ran the proof remotely. An initial changed-check invocation used the remote's newer `origin/main` and included inverse sibling changes; the corrected invocation pins this branch's actual base. Hosted CI on head `7366eaed49bcc5f3e9750418180795bdc7355179`: [checks-ui (1/3)](https://github.com/openclaw/openclaw/actions/runs/36940168750/job/110629901361) passed 8,023 tests but failed `UsagePage detail requests > releases a loaded overview when its Gateway identity is replaced`: `expected OverviewPayload to be undefined`. Fail-fast cancelled the remaining run. The same failure is independently verified on unrelated PR #162874's still-current head `dda3f8258915c215083578eb6a46dc4b95c6d9ae`, [run 36898732505](https://github.com/openclaw/openclaw/actions/runs/36898732505/job/110492893649); its Usage test and page blobs match this head. Existing repair #163018 owns it; this PR does not duplicate that fix. The failing synthetic lifecycle does not call settings readers and does not mount its dormant sidebar loader. A conservative graph including that dynamic loader still reaches settings, so no unconditional import-disjointness or admin exception is claimed. Hosted CI remains failed/pending acceptance, not green.
dda3f82 to
73a5ba9
Compare
## What Problem This Solves The Control UI still reads top-level session selections and rewrites durable shared-token settings produced before the supported July 2026 upgrade window. ## User Impact Upgrades from pre-July-2026 versions are no longer migrated: top-level remembered session selections and durable-token settings cleanup. Users with those unsupported selections can select their session again; conversations remain on the Gateway. Current shared credentials stay in session storage and are never restored from durable settings. ## Why This Change Was Made This implements the maintainer's July-and-later migration policy at the settings owner. The scalar session writer was replaced by `sessionsByGateway` in e981fb5, first shipped in v2026.3.22 (March 23); v2026.3.13-1 was the last prior tagged writer. Durable token writes were removed by 3d59297, first shipped in v2026.3.7 (March 8); v2026.3.2 still wrote them. Actual v2026.7.1-beta.1, v2026.7.1, and v2026.7.35 source writes `sessionsByGateway` and omits durable tokens. The July sidebar-pins upgrader, device-token import, and chat-outbox/group migrations remain: supported releases still produced those shapes. The September-published v2026.7.35 still writes outbox v1 and browser-local groups, so main's earlier cutovers are insufficient evidence for deleting them. Net production reduction: 9 lines. The obsolete migration test is removed, and the existing settings-upgrade test now exercises representative July beta/stable persisted shapes. No protocol, schema, SDK, or rendered appearance changes. ## Evidence - Isolated Codex AutoReview: no actionable P0–P2 findings. - Blacksmith Testbox, pinned source and edited-file hashes: settings and preference suites passed, 33 tests, 1.60 s total Vitest duration; July beta/stable fixtures load, migrate pinned routes where present, and round-trip. - Both import-cycle checks: 0 cycles. - `check-changed` against pinned base 5729541: passed, including UI types, eight affected test-type graphs, lint, i18n, and dead-export checks. - Doctor legacy-config and migration suites: both passed (32.03 s across the two Vitest shards, including cold worker preparation). - `git diff --check`: clean. The repository wrapper's source staging hit local ENOSPC before upload. Native Blacksmith sync on the same owned lease verified the exact base and file hashes and ran the proof remotely. An initial changed-check invocation used the remote's newer `origin/main` and included inverse sibling changes; the corrected invocation pins this branch's actual base. Hosted CI on head `7366eaed49bcc5f3e9750418180795bdc7355179`: [checks-ui (1/3)](https://github.com/openclaw/openclaw/actions/runs/36940168750/job/110629901361) passed 8,023 tests but failed `UsagePage detail requests > releases a loaded overview when its Gateway identity is replaced`: `expected OverviewPayload to be undefined`. Fail-fast cancelled the remaining run. The same failure is independently verified on unrelated PR openclaw#162874's still-current head `dda3f8258915c215083578eb6a46dc4b95c6d9ae`, [run 36898732505](https://github.com/openclaw/openclaw/actions/runs/36898732505/job/110492893649); its Usage test and page blobs match this head. Existing repair openclaw#163018 owns it; this PR does not duplicate that fix. The failing synthetic lifecycle does not call settings readers and does not mount its dormant sidebar loader. A conservative graph including that dynamic loader still reaches settings, so no unconditional import-disjointness or admin exception is claimed. Hosted CI remains failed/pending acceptance, not green.
…#162874) Consolidate Gateway session-target admission, strict scope predicates, keyed queues, model-auth errors, observer/run facts, and normalization under their existing owners. Preserve RPC contracts, caller-specific authority checks, CLI behavior, and persisted session state. Rebase onto current main while retaining its simplified web-search test fixture, Cron status contract, and deterministic usage-retention fix. Remove 193 net production lines without weakening coverage.
What Problem This Solves
Gateway handlers repeat session-target resolution, scope predicates, queue mechanics, and normalization already owned by shared modules. This continues the maintainer-requested Gateway duplication sweep.
Related: #162413.
User Impact
No intended user-visible change. RPC names, schemas, error codes and text, authorization timing, CLI behavior, and persisted session state remain unchanged.
Why This Change Was Made
Measured candidate: 193 net production lines removed. No generated-code or test deletion is credited.
Fixes Found Along the Way
The update campaign fixture bypassed both validation layers and asserted an inner rejection unreachable through the real RPC. It now uses canonical admission and verifies malformed targets fail before update effects. Existing logout cases additionally cover ordered trim/deduplication and malformed or sparse selectors.
Evidence
058d3c92278af9145a5379c2c95bb3b99109a111. Earlier full-suite results are reused only for unchanged inputs.Rebase recovery
The earlier UI retention failure was fixed on main by #163018 (
a9665e46cc28db91063e21a06fdc0fd814231773). This branch is rebased onto2dc1071d20812751fe55daab18b788fccf95c745, which contains that fix. The only manual resolutions preserve main's simplified web-search scope mock while removing the retired error-mapper mock, and preserve itsCronStatusSummaryimport alongside the canonical model-auth type import. The two correction commits replayed unchanged.Rebased head:
73a5ba9710ae685cf3730e035e08f4ff494413d6. Fresh independent Codex review found no actionable P0–P2 findings. Blacksmith Testboxtbx_01m3xc6833f2ag6sbpf6w72b1x(run 36962472110) verified all 58 changed-file SHA-256 hashes and passed 1,166 tests across 50 files in four Vitest shards (143.05 seconds), including the repaired usage-retention test. Both cycle checks report zero, protocol verification passes without drift, and the core production typecheck passes. The completenode scripts/check-changed.mjs --base origin/maininvocation passed, including all 27 core-test type shards, UI types, boundary/ratchet/dead-export checks, and core/UI/script lint. The complete remote command exited 0 in 27m22.745s. Earlier evidence above remains explicitly prior-head evidence.The first replacement attempt never executed tests: its admission log identifies lease
tbx_01m3xbf6bzhagbkp78bpc5r0eh, whose workflow was cancelled while the provider continued to report it queued. That lease was stopped; the fresh lease above acquired a runner normally. No validation was weakened or rerun merely for green.Independently verified inherited CI failure
The current PR Node job 110703173185 reports
TypeError: log.trace is not a functionatsrc/infra/gateway-scheduler.ts:282whilesubagent-spawn.production-boundary.test.tsruns. The identical stack and test are recorded on scheduled main run 36961023723 / job 110694726457, head4e397534d9eaa24631ecef85134055b8f7fefd46. The logger mock inprepared-model-runtime.test-harness.tsomitstrace, while the scheduler's cadence logging uses it.The actual PR CI checkout is merge
e4dcfd5eb9dd1d0ccd2ca2b1a5018dc5aed4ec9d, with parents main35b8a1ae736f0090a70cb095c09128aba934daa8and PR73a5ba9710ae685cf3730e035e08f4ff494413d6. The scheduler, logger harness, and originating test are byte-identical across the independently failing main head, that merge's main parent, and the tested merge. The PR does not change any of those three files. This qualifies the maintainer-authorized pre-existing-failure exception; no retry, weakened test, or production workaround was used.