Repository navigation
refactor(gateway): table-drive lazy method registration - #118232
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 6:31 PM ET / 22:31 UTC. ClawSweeper reviewWhat this changesThe PR moves lazy core gateway-method ownership into the canonical descriptor table, derives cached lazy handlers from that table, and lets selected terminal handler failures reach the authenticated WebSocket redaction backstop. Merge readinessKeep this maintainer-labeled PR open for explicit maintainer review. The branch’s descriptor-table ownership model is a coherent replacement for duplicated method-name and lazy-loader lists, and the authenticated WebSocket dispatcher already owns the redacted terminal-error response path; no concrete patch defect was found. The branch is behind current Priority: P2 Review scores
Verification
How this fits togetherGateway clients send authenticated RPC requests to the WebSocket dispatcher, which authorizes a method through a registry and invokes its lazily loaded handler. Core method metadata controls what is advertised and authorized, while handler-family ownership determines which module supplies the method at runtime. flowchart LR
Client[Authenticated gateway client] --> Dispatch[WebSocket request dispatcher]
Dispatch --> Registry[Method registry and authorization]
Registry --> Table[Canonical core method table]
Table --> Families[Handler-family mapping]
Families --> Lazy[Lazy module loader]
Lazy --> Handler[Core request handler]
Handler --> Response[Protocol response or redacted failure]
Decision needed
Why: The code path is technically coherent, but the protected Before merge
Agent review detailsSecurityNone. PR surfaceSource -724, Tests -6, Other +8. Total -722 across 12 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical core method table that owns method policy and lazy handler family, retain authenticated dispatch as the sole fallback owner for terminal error redaction, then merge only after current-base validation is refreshed. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is an internal refactor rather than a report of a separately reproducible user defect. Its relevant verification is preservation of registry dispatch and terminal failure handling, for which the PR supplies focused tests and exact-head CI evidence. Is this the best way to solve the issue? Yes. Consolidating policy metadata and lazy-handler ownership into one typed source is a better fix than preserving synchronized method arrays, because the loader map is checked against the table-derived family union and dispatch keeps its existing canonical error boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a1c2009b91b9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
Re-integrate upstream/main (base a3ca846 → tip 784a228, 266 commits) into the cortex fork. Conflict resolution + keystone reconciliation summary in RESYNC_LEDGER.md. Foundation (lead-owned): MCP fence ENHANCE (fence sanitized publicValue + fix a latent _meta-leak), openshell buildRemoteCommand union-trap → adopt upstream extraction, cron completion-announce grafted onto upstream openclaw#126483 failure- threshold rewrite, memory-core prompt-section KEEP-OURS, ui/package.json union. Gateway/protocol second pass (split-brain repair): grafted upstream's GitHub- identity schemas; re-grafted 37 dropped methods (openclaw#118232) + placement scopes + handler wiring; method-scope drift (config.schema/fs.listDir/worktrees.create, sessions.groups.*, skills.forge.*); embedded-agent type extensions; agentHarnessStructuredInput SDK export; resolved-v1 provenance; AgentToolResult<unknown>; cron-trigger-filter; exec-approval; copyImage icon. GitHub-identity (adopt fully): core adopted + working; UI ported to ui/src/ui (compiles + unit-tested); app-shell live-wire + runExternalMutation + visual verification are the documented land-time step. Agent-loop (merge + restore fork features): restored the fork's tool mutation- tracking + recovery cluster (20 files) to fork-main; grafted upstream's clean before-tool-call owner-arg change; deferred upstream intentionalTermination hardening as a follow-up. UI divergence: fork owns ui/src/ui; upstream's ui/src/pages restructure not adopted (184 files kept-deleted). i18n kept-ours (fork en.ts superset). Verification: tsgo core/extensions/test:ui/test:packages = 0 (zero new errors; core:test/extensions:test residuals proven identical to fork-main baseline). Behavior: cron, mcp, memory-core, agent-loop mutation-recovery green (merge regressions fixed). Pending land-time: Linux build + behavior proof + autoreview + GitHub-identity UI wiring/visual. Co-Authored-By: Claude Opus 4.8 <[email protected]>
What Problem This Solves
Gateway method policy and lazy dispatch ownership were maintained in separate hand-written lists. That duplication had already allowed advertised methods to ship without a dispatch route, and every new method required synchronized edits across multiple files. Several terminal handler catches also returned raw
String(error)text instead of using the WebSocket dispatch backstop's safer redaction.Why This Change Was Made
The canonical core method table now carries a handler-family column for all 330 lazy-routed methods. A single typed 69-family module map builds the lazy handlers while retaining one-import-per-family caching, deterministic descriptor order, and the existing missing-handler runtime invariant. The two residual method-name arrays and the 715-line registration duplicate are deleted;
server-methods.tsdrops from 1,158 to 486 lines and its max-lines grandfathering is removed.Ten terminal, single-response catches now delegate failures to the authenticated WebSocket backstop, which emits
UNAVAILABLEafter applyingformatForLogredaction. Three superficially similar paths remain deliberately local: worktree snapshot errors and board validation errors have structured outcomes, while chat send owns early acknowledgements and lifecycle cleanup. No current in-process call site targets the ten changed methods; generic raw in-process dispatch would receive a rejected handler error rather than a synthesized protocol response.The per-request registry rebuild for callers without an owning attached registry remains unchanged. That fallback is intentional for #94127 so late process-root plugin methods remain visible.
AI-assisted change; the final Codex autoreview reported no accepted/actionable findings.
User Impact
There is no intended visible behavior change in successful requests. Maintainers now add a core method's policy and lazy owner in one row, preventing advertised-but-unknown drift. Unexpected failures on the affected WebSocket methods are redacted consistently before being returned.
The proposed four test-suite file renames were intentionally omitted: each file carries a grandfathered max-lines suppression, and renaming would require baseline path replacements forbidden by this cleanup fleet's shrink-only baseline rule.
Evidence
origin/main: all 350 method names, scopes, release metadata, visibility/startup/write flags, and ordering are unchanged; all 330 lazy methods retain their prior family; 69 loader import/export selectors are unchanged.node scripts/run-vitest.mjs src/gateway/server-methods-list.test.ts src/gateway/server-methods/lazy-core-handlers.test.ts src/gateway/server-methods/models.test.ts src/gateway/server-methods/worktrees.test.ts— 4 files, 55 tests passed.node scripts/run-vitest.mjs src/gateway/server/ws-connection/authenticated-request-dispatch.server.test.ts src/gateway/method-scopes.test.ts src/gateway/methods/registry.test.ts src/gateway/methods/core-descriptors.since.test.ts src/gateway/server-methods.plugin-gateway-dispatch.test.ts src/gateway/server.models-voicewake-misc.test.ts— 6 files, 173 tests passed.node scripts/check-changed.mjs --dry-run— correctly selectedcore,coreTests, andtoolinglanes.node scripts/check-changed.mjs— broader remote gate could not start because no approved Crabbox provider was ready.30769789621passed at head87429b5b766b491a934134e9d90b43bd5e2d0196, including build, lint, production/test types, protocol, and package-boundary checks..agents/skills/autoreview/scripts/autoreview --mode uncommitted— TruffleHog clean; Codexgpt-5.6-solhigh-reasoning review clean, no actionable P0 findings.git diff --check— clean.