Skip to content

refactor(gateway): deslop gateway core files third pass - #162010

Merged
steipete merged 2 commits into
mainfrom
deslop/l238-gateway-core3
Sep 30, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/l238-gateway-core3

Conversation

@steipete

@steipete steipete commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway runtime code still repeats forwarding, validation, and projection work after the earlier cleanup passes.

User Impact

No user-visible behavior change. Gateway protocol, RPC inputs/results/errors, authorization, live authority checks, lifecycle fencing, and persisted state remain unchanged.

Why This Change Was Made

The reviewed diff removes 180 net production lines across 11 files (168 in the final merge after main's concurrent helper extraction):

  • Use the existing lazy-runtime binder for ordinary cron forwarding; keep lifecycle operations, generic transactions, and authority-bearing reads explicit. Replace watcher reference boxes with closure variables.
  • Inline single-use health account wrappers, preserving fallback values, hook order, and diagnostics.
  • Share pairing rejection and avatar attachment within connection setup, plus the identical local-backend predicate.
  • Share worker reply eligibility and reservation-timeout publication without changing their authority checks.
  • Centralize managed-media byte-limit checks and their existing error text.
  • Simplify Talk launch-option projection, transport defaults, and desktop stderr selection.
  • Pass media records directly to node-event cleanup and inline the single-use model-catalog loader adapter.

The earlier Gateway passes and September 20 onward file history were inspected before choosing these remaining reductions. Coverage records all 373 production files over 200 lines and a separate 494-file small-module pass. Existing tests are retained; this adds no per-PR test cases. The assertion-safety baseline shrinks by one after removing the redundant Talk cast.

Evidence

Independent review completed, with the final correction re-reviewed clean. The branch was rebased before validation; the final committed source tree matches the verified Testbox snapshot.

Blacksmith Testbox proof:

  • 858 tests passed in 26 files across five Vitest shards (166 seconds), including Gateway flows, the health importer, and import-boundary tests. Admission tests were rechecked after the narrowing fix; 277 cron/reload tests passed after the final const correction.
  • Both import-cycle checks reported zero cycles on the final source tree.
  • Changed-file guards, core production types, all 27 core test type graphs, and Knip passed. The last changed-file lint initially flagged prefer-const; the corrected 11-file lint rerun passed with zero warnings/errors, followed by another core typecheck.
  • pnpm protocol:check passed with zero generated-protocol drift; pnpm plugin-sdk:check-exports passed.
  • pnpm build, including built Plugin SDK export/consumer checks, passed after the admission type fix. The subsequent const-only lint correction was separately rechecked with types, lint, cycles, and affected tests.

The initial build caught lost TypeScript narrowing in the cleanup; it was fixed before publication. Removing the Talk cast also required an exact shrink-only assertion-baseline update.

Lease runs: main validation, final targeted validation. Results above come from the remote command exit statuses; these links identify the supporting Testbox leases. Hosted CI on the published head remains the merge gate.

Hosted CI completed with one inherited failure: checks-node-changed-compact-large-5 fails src/cli/update-cli.windows-lifecycle.test.ts / restores Windows Scheduled Task autostart on SIGINT during package suspension with ExitError: exit 1 at one-shot-exit.ts:155 via update-command-triage.ts:177. The same test and stack fail on hourly main at ad8327f586926caf7a6a3e8c2e361ef162c98f84: main job 110013033066. Existing fix #161990 owns the updater defect. The failing update/Windows-task recovery route does not execute any production file changed here; Gateway dispatch and service operations are mocked. All other CI test/check jobs on this PR head passed; the aggregate gate reflects the inherited failure. PR merged as 3044ac325126636ee0fb7a44fa6f1bfa52028674.

Post-merge integration check: fresh-main typechecking later caught an orphaned reconcileCronExitWatchers import after this cleanup merged with #161007, which had moved the local adapter into the watcher module. The published head here did not contain that import. Canonical main repair d5e602f0bcf8 removes the orphaned import and now-unused adapter. The follow-up cleanup was rebased onto that repair.

Reuse the lazy runtime binder, remove single-use health and catalog wrappers, and consolidate equivalent Gateway validation and projection paths. Preserve protocol, authority, lifecycle, and persistence contracts.
Carry the validated reservation expiry through shared timeout handling, declare the once-initialized stream watcher as const, and shrink the Talk assertion baseline for the removed cast.
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: c02a8f6a8960cbb974b8dc78535d3d14641a51e7
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server/ws-connection/connect-session.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/worker-connection.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L labels Sep 30, 2026
@steipete
steipete enabled auto-merge (squash) September 30, 2026 17:24
@clawsweeper

clawsweeper Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 30, 2026, 1:25 PM ET / 17:25 UTC.

ClawSweeper review

What this changes

The branch simplifies Gateway cron forwarding, connection and worker guards, account health, managed media, model loading, and Talk option handling.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this fresh maintainer PR remains distinct from current main, and the reviewed changes have no supported blocking defect.

Priority: P3
Reviewed head: c02a8f6a8960cbb974b8dc78535d3d14641a51e7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The cleanup is coherent and reports substantial focused validation, with no supported blocking finding from source review.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal refactor is exempt from external contributor behavior proof. The PR reports focused Testbox validation, but this read-only review did not execute a production-path run; no stored-data contract changes were identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal refactor is exempt from external contributor behavior proof. The PR reports focused Testbox validation, but this read-only review did not execute a production-path run; no stored-data contract changes were identified.
Evidence reviewed 7 items PR-introduced cron refactor: The pinned introduced patch replaces ordinary lazy cron forwarding with the existing runtime method binder while leaving lifecycle and guarded scratch operations explicit.
Current main still has the old forwarding: The pinned main revision retains individual lazy cron forwarding methods, so the central cleanup is not already present there.
Worker cancellation boundary: The changed branch passes the connection signal only for long tool operations. The dispatcher consumes that signal for Gateway-tool invocation and computer execution; other worker RPCs do not consume it.
Findings None None.
Security None None.

How this fits together

The Gateway accepts client and worker connections, then coordinates scheduled jobs, media, and session services. Those services return replies, events, and health information to clients.

flowchart LR
Clients[Clients and nodes] --> Admission[Connection admission]
Admission --> Services[Gateway services]
Services --> Cron[Cron scheduling]
Services --> Media[Media and node events]
Cron --> Results[Replies and events]
Media --> Results
Loading

Before merge

  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
Agent review details

Security

None.

PR surface

Source -180, Other 0. Total -180 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 11 170 350 -180
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 12 171 351 -180

Review metrics

None.

Technical review

Best possible solution:

Keep the leaner Gateway implementation with node pairing, worker cancellation, and cron handoff contracts unchanged.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR reports no user-facing defect to reproduce; the review compared the introduced paths with their existing dispatch and admission contracts.

Is this the best way to solve the issue?

Yes: the patch reuses an existing lazy-runtime binder and removes redundant wrappers without establishing a competing owner or stored-data contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e1b459ec5d04.

Labels

Label changes:

  • add P3: This is an internal Gateway cleanup with no claimed user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is an internal Gateway cleanup with no claimed user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 3044ac3 into main Sep 30, 2026
206 of 210 checks passed
@steipete
steipete deleted the deslop/l238-gateway-core3 branch September 30, 2026 17:54
@steipete

Copy link
Copy Markdown
Contributor Author

Coordinator admin-land on exact head c02a8f6 under the campaign's pre-existing-failure exception.

CI run 36750778079's only failing test is src/cli/update-cli.windows-lifecycle.test.ts › "restores Windows Scheduled Task autostart on SIGINT during package suspension". It fails deterministically on untouched origin/main (reproduced locally on accde9e: 1 failed | 19 passed) and passes on the head of the open repair #161916. This PR touches 12 top-level src/gateway files, none of them in the updater. Every other job passed, and auto-merge was armed by the lane worker.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
)

* refactor(gateway): deslop gateway core files third pass

Reuse the lazy runtime binder, remove single-use health and catalog wrappers, and consolidate equivalent Gateway validation and projection paths. Preserve protocol, authority, lifecycle, and persistence contracts.

* refactor(gateway): preserve narrowed admission and watcher bindings

Carry the validated reservation expiry through shared timeout handling, declare the once-initialized stream watcher as const, and shrink the Talk assertion baseline for the removed cast.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant