Repository navigation
refactor(gateway): share handler preparation and lifecycle projections - #167335
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. |
d01 PR 3 per-file coverage — part 1/5Reviewed implementation head: Gateway server-methods lane d01, PR 3 coverageBaseline 608 production modules have per-file decisions, including all 427 current server-methods modules and the original exclusions. The implemented production diff removes 693 net lines; no test, protected storage, global-identity, config-retirement, tooling, or changelog paths changed. Existing assertions remain intact. Counts describe the actual applied source against the original fresh-main base. Measured rejected prototypes are recorded in each relevant row. The PR body records executed validation separately; a named test below is a target unless that validation says it passed.
|
d01 PR 3 per-file coverage — part 2/5Reviewed implementation head: Gateway server-methods lane d01, PR 3 coverageBaseline 608 production modules have per-file decisions, including all 427 current server-methods modules and the original exclusions. The implemented production diff removes 693 net lines; no test, protected storage, global-identity, config-retirement, tooling, or changelog paths changed. Existing assertions remain intact. Counts describe the actual applied source against the original fresh-main base. Measured rejected prototypes are recorded in each relevant row. The PR body records executed validation separately; a named test below is a target unless that validation says it passed.
|
d01 PR 3 per-file coverage — part 3/5Reviewed implementation head: Gateway server-methods lane d01, PR 3 coverageBaseline 608 production modules have per-file decisions, including all 427 current server-methods modules and the original exclusions. The implemented production diff removes 693 net lines; no test, protected storage, global-identity, config-retirement, tooling, or changelog paths changed. Existing assertions remain intact. Counts describe the actual applied source against the original fresh-main base. Measured rejected prototypes are recorded in each relevant row. The PR body records executed validation separately; a named test below is a target unless that validation says it passed.
|
d01 PR 3 per-file coverage — part 4/5Reviewed implementation head: Gateway server-methods lane d01, PR 3 coverageBaseline 608 production modules have per-file decisions, including all 427 current server-methods modules and the original exclusions. The implemented production diff removes 693 net lines; no test, protected storage, global-identity, config-retirement, tooling, or changelog paths changed. Existing assertions remain intact. Counts describe the actual applied source against the original fresh-main base. Measured rejected prototypes are recorded in each relevant row. The PR body records executed validation separately; a named test below is a target unless that validation says it passed.
|
d01 PR 3 per-file coverage — part 5/5Reviewed implementation head: Gateway server-methods lane d01, PR 3 coverageBaseline 608 production modules have per-file decisions, including all 427 current server-methods modules and the original exclusions. The implemented production diff removes 693 net lines; no test, protected storage, global-identity, config-retirement, tooling, or changelog paths changed. Existing assertions remain intact. Counts describe the actual applied source against the original fresh-main base. Measured rejected prototypes are recorded in each relevant row. The PR body records executed validation separately; a named test below is a target unless that validation says it passed.
|
|
|
Codex review: blocked before merge. Reviewed October 8, 2026, 1:02 PM ET / 17:02 UTC. ClawSweeper reviewWhat this changesThe branch shares Gateway request preparation, response projection, and lifecycle cleanup while preserving existing behavior. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this maintainer-authored refactor contains useful, distinct consolidation, and review found no concrete introduced correctness or security defect. Priority: P3 Before merge
FindingsNone. Provenance
Agent review detailsHow this fits togetherThe Gateway receives requests from OpenClaw clients and coordinates conversations, session storage, approvals, and terminal processes. These changes simplify the handlers that prepare those operations and publish their results. flowchart TD
A[Client requests] --> B[Gateway validation]
B --> C[Prepared session and request facts]
C --> D[Current authority checks]
D --> E[Session and runtime owners]
E --> F[Shared result projection]
F --> G[Client responses and events]
Technical reviewBest possible solution: Keep the consolidation in the existing Gateway owners while preserving their current authority, persistence, response, and cleanup contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving refactoring rather than a reported defect. Is this the best way to solve the issue? Yes: the introduced changes reuse existing owners and remove repeated preparation and projection without establishing a competing implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fc1b2e66564e. Provenance checked
TestingProof path: in-process harness. Added test files: 0. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Stored data modelPersistent data-model change detected: 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 |
openclaw#167335) * refactor(gateway): consolidate handler preparation and lifecycle projections * fix(gateway): preserve narrowing and avoid shadowed locals * fix(gateway): retain the existing SDK declaration surface * fix(gateway): preserve validated presence parameter reads
What Problem This Solves
Gateway session and request handling repeats preparation, error projection, and lifecycle bookkeeping across variants.
User Impact
No user-visible change. Authorization, recovery and replay, configuration, RPC and persisted shapes, SDK declarations, and response text stay the same. Tests are unchanged.
Why This Change Was Made
Share membership access and mutation handling, session creation/reset refusals, chat preparation and delivery projections, and terminal/runtime cleanup cores. Keep variant-specific authority checks, actor/timestamp capture, partial-delivery precedence, and late cleanup explicit. Derive settled state from the owning registries and remove single-use internal seams and unreachable stored-state handling.
The authored diff removes 693 net production lines across 92 files, measured against
b3196dfda33555857eae9cd52ea29367a91bd9ea. The per-file census covers 608 production modules, including all 427 current server-methods modules and reserved exclusions. Measured alternatives that grew the code, obscured ownership, changed reachable SDK declarations, or lost accepted raw parameter properties were discarded.Per-file coverage: part 1, part 2, part 3, part 4, part 5.
Evidence
Independent review through P2 is clean for the complete refactor and each correction.
Production types, all selected test type graphs, structural guards, formatting, and focused lint pass.
check-changedreports only two untouched unused exports reproduced on the clean base:SessionPendingInputStatein config/session storage anddiscardStreamSegmentIndexesin the UI. The former is already removed upstream by19f37f076862830f9b8953287f94a4725e3b8908.SDK API comparison reports no direct, reachable, or entrypoint changes at implementation commit
6e3961495e544f65e350e6b2e18c5e5265b260a7. The later delta only restores the baselinesystem-eventbody under its unchangedGatewayRequestHandlersannotation.Terminal tests: 128 passed; suppression tests: 3 passed. Presence routing after restoration: 9 passed, plus the suppression suite. Packaged-script and PR-wrapper eager-import closure tests passed. Direct tooling-import audit found no imports from changed modules in the protected landing helpers.
The focused send file passes all 78 tests. Same-host wall times were 90.98 seconds before and 364.00 seconds after, with the latter rebuilding the worker cache on a host reporting load 61.50 on 16 CPUs. These are validation timings, not a performance comparison; no tests or their CI cost were added.
Dedicated AWS validation passed all four selected Vitest projects: 9,787 tests passed across 749 files, with 21 existing skipped tests in four files. This includes the full server-methods directory, agent-turn, desktop, methods, Talk, terminal, and affected adjacent-owner suites. The test wrapper exited 0 in 3,424.77 seconds; runtime and Madge cycle checks both passed. The clean baseline also has zero cycles.
Remote run
run_373168b5e65d4264e817cf03b496c537on AWS leasecbx_7802687261d5tested implementation commit6e3961495e544f65e350e6b2e18c5e5265b260a7. Every final changed production file is byte-identical to that snapshot; final head900b74a38d291476a712cfa5c601cf2c269e8eb1only restores the untouched baselinesystem.ts, covered by the focused routing check above. The aggregate remote command exited 1 solely for the two inherited Knip findings. Hosted CI run 37812357878 passed on exact head900b74a38d291476a712cfa5c601cf2c269e8eb1; the combined CI, dependency-review, and security-sensitive-review statuses are successful. Three publication-time cancelled automation jobs (Auto response, PR context and evidence, and ClawSweeper Dispatch) were rerun successfully; no cancelled job is being treated as passing proof.ClawSweeper reported no correctness or security findings and requested compatibility review because its file inventory was incomplete and
doctor.tswas classified as an unknown data-model change. The paginated GitHub inventory matches all 92 local changed files. The onlydoctor.tsedit derives diagnostic arrays/sets from the same prepared records inmergeDreamingStoreStats, preserving filtering, ordering, totals, sort limits, and timestamp selection. It performs no writes and changes no config key, default, schema, migration, or stored shape. The complete diff and zero-change SDK declaration comparison confirm that no upgrade action is required. This completes the compatibility follow-up.Investigated local failures
A partial local broad run hit the 90-second first-case timeout in
chat.reset-visible-yield.test.tsbefore any provider or lifecycle event. The clean base reproduced that exact timeout. The following candidate case reported revoked reader custody; the baseline instead reported changed session authority. That secondary custody error is not an exact baseline reproduction. The startup/cleanup-overlap explanation remains a hypothesis, and no passing replay is claimed as a fix.The focused Talk selection passed 295 cases and failed only
client-native-control.test.ts's registration-readiness case. A clean-base full-file run reproduced the exact error and assertion:registration readiness not observed within 1000 ms; last phase: preparing tool authorityat line 94. The deliberate workspace delay precedes that timer; the failure occurs during later real authority preparation. No timeout, retry, skip, assertion, baseline, or suppression was changed.The local broad run was stopped under measured host contention and replaced by dedicated Linux validation. Both visible-yield cases passed there (26.930 seconds and 10.574 seconds), as did the Talk readiness case (4.413 seconds). These passes establish dedicated-run coverage, not a fix for the local failures; those failures remain recorded separately.