Repository navigation
refactor(gateway): deslop gateway fourth pass - #158786
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 September 27, 2026, 6:00 AM ET / 10:00 UTC (Revision 18). ClawSweeper reviewWhat this changesThe branch consolidates Gateway request, session, worker, approval, and reload helpers, reduces the assertion-safety baseline, and moves three test-support type imports. Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open. Current main does not contain its distinct Gateway cleanup, and the merged fifth pass excluded these files. No concrete patch defect was found in the inspected paths, but the required upgrade transition remains unproven. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway receives client requests and configuration edits, then coordinates authorization, sessions, workers, and replies. Its reload path applies safe changes in process or drains active work before a restart. flowchart LR
A[Client requests] --> B[Gateway validation]
B --> C[Session and approval owners]
C --> D[Worker and channel actions]
D --> E[Replies and events]
F[Config edits] --> G[Reload coordinator]
G --> H[Hot apply or restart]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one Gateway reload and restart owner that preserves existing configuration and produces a recorded outcome for active work across an upgrade. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes a behavior-preserving refactor rather than reporting a defect. Its reported Testbox validation does not exercise the installed-updater transition. Is this the best way to solve the issue? Unclear: the inspected owner consolidation is coherent, but the required upgrade scenario must establish that existing settings and active work survive the lifecycle path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 244d44197232. 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
HistoryReview history (17 earlier review cycles; latest 8 shown)
|
b071c86 to
d6c7f4d
Compare
d6c7f4d to
99d23ae
Compare
ebc1d6d to
a40df3a
Compare
99d23ae to
4ae4070
Compare
4ae4070 to
5413fc9
Compare
5413fc9 to
e2484a9
Compare
3fa091d to
954fada
Compare
Restore the canonical bundle-or-npm installation type while retaining the prepared-node initializer. This fixes the TS2322 regression introduced by #158786. Production types, test types, declaration generation, aggregate CI, source autoreview, and ClawSweeper passed. Co-authored-by: Altay <[email protected]>
* commit '69809d7a94277d01be964bd1cbbb7aa0ebc58c9b': (219 commits) perf(agents): serialize large model requests once (#159574) refactor(cli): share capability agent-selection test cases (#159616) fix(workers): restore installation type checks (#159629) test(channels,qa,providers): remove low-value tests (batch d065) (#159627) test(doctor): run isolated migration cases concurrently (#159609) feat(apple): show agent identities in native chat (#159528) chore(i18n): refresh native locales (#159635) fix(gateway): keep node provisioning's installation contract after overlapped preparation fix(models): keep shared catalog requests alive for remaining callers (#157191) feat: let agents query online people and device activity (#159117) perf(gateway): first cloud dispatch prepares worker artifacts one after another (#159520) refactor(android): deslop Android app third pass (#159589) test(qa-lab,openshell,slack,reef,team-reports): remove low-value tests (batch d064) (#159607) fix: align process liveness checks (#151107) thanks @ekinnee fix: sessions model default does not clear the override (#159587) fix(ios): preserve typing during reentrant SwiftUI updates fix(ci): frozen 2026.8.33 validation fails on inherited test clock (#159594) perf(gateway): avoid duplicate recipient row lookup (#159595) refactor(gateway): deslop gateway fourth pass (#158786) test(agents): split subagent task-settlement test support under the line cap (#159584) ...
* commit '69809d7a94277d01be964bd1cbbb7aa0ebc58c9b': (219 commits) perf(agents): serialize large model requests once (#159574) refactor(cli): share capability agent-selection test cases (#159616) fix(workers): restore installation type checks (#159629) test(channels,qa,providers): remove low-value tests (batch d065) (#159627) test(doctor): run isolated migration cases concurrently (#159609) feat(apple): show agent identities in native chat (#159528) chore(i18n): refresh native locales (#159635) fix(gateway): keep node provisioning's installation contract after overlapped preparation fix(models): keep shared catalog requests alive for remaining callers (#157191) feat: let agents query online people and device activity (#159117) perf(gateway): first cloud dispatch prepares worker artifacts one after another (#159520) refactor(android): deslop Android app third pass (#159589) test(qa-lab,openshell,slack,reef,team-reports): remove low-value tests (batch d064) (#159607) fix: align process liveness checks (#151107) thanks @ekinnee fix: sessions model default does not clear the override (#159587) fix(ios): preserve typing during reentrant SwiftUI updates fix(ci): frozen 2026.8.33 validation fails on inherited test clock (#159594) perf(gateway): avoid duplicate recipient row lookup (#159595) refactor(gateway): deslop gateway fourth pass (#158786) test(agents): split subagent task-settlement test support under the line cap (#159584) ...
* refactor(gateway): deslop gateway fourth pass * refactor(gateway): avoid reserved environment prefix for model pattern * chore(gateway): shrink assertion baseline after cleanup * refactor(gateway): preserve typed handlers and canonical type imports * refactor(gateway): retain callback receivers and satisfy lint contracts
Restore the canonical bundle-or-npm installation type while retaining the prepared-node initializer. This fixes the TS2322 regression introduced by openclaw#158786. Production types, test types, declaration generation, aggregate CI, source autoreview, and ClawSweeper passed. Co-authored-by: Altay <[email protected]>
The tooling dependency #159068 is merged. This diff now contains only the Gateway cleanup and its assertion-baseline reduction.
Status: September 27 rebase force-pushed; exact-head hosted CI is attached and queued. Published head:
954fada0ff9d67059e9182c85e51cb1ef41f8eeb. CI run 36310507291 reports that exact head. Tests, protocol, SDK checks, and build passed; the changed-file gate failed only two unchanged main line caps. Earlier evidence below is historical.What Problem This Solves
Gateway internals still duplicate request adapters, projections, lifecycle plumbing, and shared utility behavior after earlier cleanup passes. The prepared rebase of this fourth pass removes 1,253 net production lines across 131 Gateway files.
User Impact
No intentional user-visible change. RPC names, parameter/result/event shapes, authorization, transcript bytes and ordering, restart and worker fencing, persistent-store semantics, config keys, and public plugin SDK exports remain unchanged.
Why This Change Was Made
Existing owners now serve more callers, with small descriptors where handlers share a flow. Production changes stay in
src/gateway; the assertion baseline shrinks by exactly 20 removed assertions. Three test/support files move type imports without changing cases or assertions.defineValidatedGatewayHandlerfor channel pairing, effective tools, approval configuration, wizard sessions, catalog terminal start, session discussion, and Talk marks. Remove redundant parameter copies and forwarding while preserving original request objects and specialized errors.The four preceding PR file lists were checked before the size census. Most edited production files were untouched by those passes; overlaps complete caller cutovers.
Evidence
Rebase on September 27, 2026
Rebased the five Gateway cleanup commits onto main
9ae6e185306272725c36231de98017515c475d33. Candidate head:954fada0ff9d67059e9182c85e51cb1ef41f8eeb; tree:0e8b4e33b38dfd56567f12926397a4ca622b0a25.setInterval/unrefsimplification inauth-rate-limit.ts, because main replaced that code withGatewaySchedulerin refactor(gateway): schedule auth pruning with the runtime owner #159455. Main's scheduler injection, clock, cancellation, disposed guard, and penalty settlement remain intact. The retained auth-file diff now removes comments only. No behavior decision was needed.3fa091da8b6af0869b72044565f732e0ff81216dhad no manual resolution delta and its main parent is an ancestor of this base. All main tests remain unchanged except the three historical type-import edits; no test logic, assertions, timeouts, concurrency settings, or skips changed.blacksmith-testbox, leasetbx_01m3gyeq9kwp0t5tce7adbjbga, run 36305198391. The wrapper verified the exact candidate source/tree. Frozen install passed before the gates. The cross-project selection remained the exact 417 files listed below, all present on this base. Source-tree identity and zero tracked drift were checked before and after.node scripts/check-changed.mjs --base 9ae6e185306272725c36231de98017515c475d33 -- <135 changed paths>completed in 1,585s. Every phase except broad core lint passed, including all 25 test type partitions, core types, formatting, boundaries, ratchets, and dead-export scans. Lint found two untouched files above 700 lines:src/gateway/session-row-projection.ts(701) andsrc/agents/subagents/registry/subagent-registry.task-settlement.test-support.ts(811). Both are byte-identical at base, candidate, and refreshed maind86796f25b3632bd211ebf1d78e430c7bd844c88. The existing untouched-file enforcement repair fix(ci): keep untouched line-limit drift from blocking changed checks #158995 remains open. No duplicate repair, suppression, or test change was added.pnpm protocol:checkpassed (2s),pnpm plugin-sdk:check-exportspassed (under 1s),pnpm plugin-sdk:surface:checkpassed (4s), andpnpm buildpassed (382s). Build emitted a non-blocking UI startup gzip warning, 362.7 KiB against 362.6 KiB; no budget was changed.3fa091da8b6af0869b72044565f732e0ff81216d. Exact-head hosted CI attachment is confirmed. A new auto-merge request was observed afterward at 09:48:31 UTC; this rebase operation did not re-arm or merge.Rebase on September 26, 2026
Rebased onto main
40a14550a2b017010417d4225b6bc7a0ab44b153. Candidate head:e2484a96c62ab217b230a6fa8f3abf1875b1bf14; tree:b99cfb1d6cb484c2282d70f13f495f880ff54929.defaultSha === headShashortcut incontrol-ui-session-prs-landing.tsand reapplied the shortened adjacent comment. Main's scheduler injection, proxy-capture shutdown cleanup, and queued-abort diagnostics also remain intact. No behavior choice was needed; main's tests are unmodified.http-common.fuzz.test.tsdeliberately deleted on main by test(runtime,plugins): remove low-value tests (batch d015) #158721, union the prior 17-file boundary selection, and add main'scontrol-ui-session-prs-branch.test.ts: 417 files through the canonical cross-project Vitest router.provider-lifecycle.ts:598–601handles non-null destroy intent withfinishDestroyand an unconditional return before the simplified branch. There is no intervening fallthrough await or record reassignment. No accepted finding remains.pnpm install --frozen-lockfilepassed;node scripts/check-changed.mjs -- <135 changed paths>ran for 1,536.20 seconds and failed only broad core lint: untouchedsrc/gateway/session-row-projection.tshas 701 counted lines against its 700-line cap. Core/test type graphs, formatting, boundaries, ratchets, coercion/deprecation guards, and all dead-export scans passed. The failing file is identical at base, candidate, and refreshed main (e8b90850758fa0e69bc0b9d29fff5b9c77ba504c). Existing #158995 owns the proposed untouched-file enforcement fix; it is open and not incorporated here. No duplicate repair, suppression, or unrelated test change was added.node scripts/run-vitest.mjs <417-file selection below>finished all 12 projects in 2,122 seconds: 9,609 passed, 1 failed, 7 existing skips. The sole failure was unchangedsrc/agents/bash-tools.exec-gateway-approval.e2e.test.ts, “keeps a scheduled approval floor in a reused full-permission session,” during initial connection:gateway closed (4000): connect timeoutat 16.9 seconds, before exec assertions. The original seven-file E2E selection subsequently passed 7 files / 9 tests on the fresh lease (513s wrapper wall, including prerequisites; 66.41s Vitest). The same timeout, assertion, and concurrency settings were retained. This is nonreproduction evidence, not a fix or a green replacement for the original broad run. The close reason comes from the unchanged fixed 15s client connect/hello timer; the test's 120s acquisition/request/preauth settings do not configure it. No safe causal repair was established.pnpm protocol:checkpassed (2s), tracked protocol-output comparison showed zero drift,pnpm plugin-sdk:check-exportspassed (1s), andpnpm plugin-sdk:surface:checkpassed (3s).pnpm buildwas active, so that attempt supplies no build verdict. Original lease completed and was stopped. Freshblacksmith-testboxleasetbx_01m3gg95e223848qy5trp2jy1w, run 36292996872, passed frozen installation (1s),pnpm build(399s), and the original seven-file E2E selection (513s). The completion command exited zero and verified the exact source tree before and after. The original lease and fresh completion lease are stopped. Providerblacksmith-testbox, leasetbx_01m3g9t0v3sbefj7550nh6nng0, Testbox run 36287534534.Force-pushed with an explicit lease against the prior head. CI run 36294437446 is attached to exact head
e2484a96c62ab217b230a6fa8f3abf1875b1bf14and its hosted outcome remains pending. GitHub reports the PR open and mergeable, with no auto-merge request. The unrelatedmac-elevation-artifact.test.tsfailure is untouched. No auto-merge operation was performed.Historical evidence
Independent Codex review is clean through P2. The previous head was
5413fc9bf5779c5bda5f9d851673efb60aa746f7; all five Gateway commits remained patch-identical during the final mechanical rebase. Its exact tree,1e63ffc993055babffc12d84df29a65ecc4af3e4, passed remote validation before publication.blacksmith-testbox, leasetbx_01m3fk99zdcyj4zhe89w8pem0d, run 36266423609. Frozen dependency install;node scripts/check-changed.mjs -- <changed files>passed (1,879s);node scripts/run-vitest.mjs <17 rebase/importer boundary files>passed 502 tests across three projects (84s);pnpm buildpassed (374s).pnpm protocol:checkplus tracked-output comparison produced zero protocol drift.pnpm plugin-sdk:check-exportsandpnpm plugin-sdk:surface:checkpassed. Source tree was checked before and after; final receipt was exit 0. Lease stopped.tbx_01m3eh08ffz8e306qkvq4t4hdh, run 36233149170: 409-filenode scripts/run-vitest.mjsselection, all 12 shards passed, 9,641 tests passed / 7 existing skips, 2,348s. Later correction/rebase boundary selections, full builds, dead-code, protocol, and SDK checks also passed. Corrected worker selection passed 127 tests across eight files in 82s. These historical results cover the unchanged cleanup; the final campaign above covers intervening boundary changes.pnpm test <file> --maxWorkers=1on Testbox: prepared-pool repository 2 tests / 20s wall; provider retention 14 tests / 25s wall. Hosted run 36237243299 measured test-body times 5.440s and 17.393s. No new test cases.macos-node-2failed in the unchangedmac-elevation-artifact.test.tscase “rejects mismatched worker commit.”/usr/bin/liporeached termination, but managed process cleanup reportedkill EPERMfor process group 28513 andEPROCESSGROUP_CLEANUP_FAILED. The shard passed 552 of 553 tests. Bounded owner-level investigation did not establish a safe repair; the cancelled Swift job provides no final-head Swift verdict. Previous head99d23ae82a3bpassed run 36262507857; that is historical evidence, not final-head green.Fixes Found Along the Way
Validation corrections preserve handler-key typing, callback receivers, canonical type imports, and existing lint/normalization contracts. No deadlines, assertions, concurrency settings, or skips were relaxed.
Separate tooling repairs address a disappearing Linux thread during process-fixture inspection and unnecessary declaration parsing; their proof and limits are documented in the dependency PR. Main independently repaired QA references (
18b0130a21b), tooling fetch expectations (380a77a86f6), UI line limits (ea400438182), and the state-worker line cap (6c7325097fae); all are incorporated.The prior head's macOS job in run 36265998280 failed the unchanged
MacNodePresenceReporterTestscase “activity crossing opt out is followed by a clear” withretryClear=true: one clear was observed, two expected. The reporter and test match main. Investigation remains separate; a later green replay will not be represented as a fix.An earlier Testbox stream exited 255 while its remote command continued. Completed receipts were recovered; incomplete pipeline work was not counted. The final campaign used quiet per-phase logs and an atomic completion receipt and completed successfully. All lane-owned Testboxes are stopped. The Windows dispatcher left a temporary namespace whose descendant settlement was unverified; the disposable Actions runner owned cleanup.
Native failure investigation
The unchanged Mac Node 2 shard was replayed on matching macOS 15.7.9 / Darwin 24.6.0 resources in diagnostic run 36277943074: 553/553 tests passed, then 20/20 focused artifact-case repetitions passed. No EPERM, cleanup diagnostic, or retained-resource outcome appeared. This is nonreproduction evidence, not a fix.
On a fresh main base with the affected presence reporter and test unchanged, Swift diagnostic run 36279900524 completed five full default-profile suites, 2,289 tests each, plus the existing rendered and named partitions. Every receipt exited zero; no presence timing-failure observation was emitted. The older failing suite had 2,291 tests; unrelated main changes account for the different suite source. The deadline, retry assertion, runner width, and selected partitions were preserved. The crossing-opt-out case uniquely requires the automatic retry; the simpler retry test can make both attempts inside its setter and is not a substitute.
Controlled Darwin run 36283429845 established a real zombie-only group and reproduced EPERM, with verified cleanup of every fixture child. It did not establish false cleanup: a live custodian in the same session could rejoin the retained group. The receipt's
falseCleanupReproducedfield records the original hypothesis and is not an accepted bug verdict. Linux's existing guard examines the whole session; Darwin'sps sessfield cannot provide equivalent evidence. A group-only exception would weaken the boundary, so none was added. This experiment does not attribute the original transient lipo failure.The diagnostic harness first hit GitHub's 500 KiB workflow-file limit, then a missing receipt-directory setup error before Swift execution. Both harness problems were corrected and reviewed before the completed runs above. Diagnostic-only workflows are not final-head CI proof. No test timeout, threshold, assertion, concurrency setting, skip, process-fencing contract, or production behavior was changed to obtain green. No safe additional repair PR was established for the two unresolved native failures.
Exact current cross-project test selection (417 files)