Skip to content

refactor(gateway): extract socket-free kernel factory - #121981

Merged
steipete merged 1 commit into
mainfrom
steipete/gateway-kernel-factory
Aug 11, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/gateway-kernel-factory

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Phase-2 PR 4 extracts the socket-free Gateway kernel factory after the landed connection/transport split (#121931) and dispatch ownership seam (#121961).

Why This Change Was Made

createGatewayKernel() now owns bootstrap, kernel-state preparation, lifecycle/live state, subscriptions and approval managers, the method registry, request-context construction, instance-runtime/facade wiring, and fallback context publication. startGatewayServerCore() composes that kernel with the HTTP transport and then starts transport-bound residents.

A late-bound transport bridge supplies worker ingress and sandbox accessors to the kernel. Before attachment it preserves the existing fail-closed sandbox error and undefined post-bind endpoints. Normal shutdown retains the same WebSocket/HTTP order; kernel-construction failures can run the full non-transport teardown, including the previously pre-lifecycle TLS failure surface.

The original startup log order, minimalTestGateway short-circuits, startup measure names, request-envelope/root-admission path, and 500ms post-ready barrier remain unchanged. There are no config, protocol, default, or user-visible behavior changes.

Next is phase-2 PR 5: the ordered resident registry and named kernel setters for resident-owned live-state slots.

User Impact

No user-visible change. The Gateway kernel can now be constructed and used for internal dispatch without creating or listening on HTTP/WebSocket servers.

Evidence

  • new server-kernel.test.ts: constructs createGatewayKernel() without transport/listen, verifies the exact startup measure sequence, fail-closed sandbox access, in-process health, and a cached agent turn through the internal facade; also proves TLS construction failure performs teardown with the unchanged error — 2 passed
  • full server.agent.* + server.chat.* suites — 7 files, 200 passed
  • PR 2/3 regression suites, transport/network E2E, startup/close proof — 16 files, 239 passed with expected platform skip
  • node scripts/check-changed.mjs -- <touched> — core/core-test tsgo, lint, guards, import cycles, and runtime architecture lanes passed
  • pnpm build — passed
  • Codex autoreview — clean, no accepted/actionable findings

ClawSweeper review metrics: production +493/-411 (net +82) for the factory, late-bound transport boundary, and transport-optional teardown; tests +190/-0. AI-assisted; implementation and evidence were reviewed directly.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete marked this pull request as ready for review August 11, 2026 09:42
@steipete steipete self-assigned this Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof:

  • Native review: READY FOR /prepare-pr, zero findings.
  • Exact-head CI: green for f627743.
  • Focused proof: socket-free kernel test 2/2; server.agent.* + server.chat.* 200/200; startup/close/runtime/race 68 passed with 1 expected skip; PR 2/3 regression group 164/164; network runtime E2E 7/7.
  • Changed-file gates and pnpm build: passed.
  • Local autoreview: clean.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 121981: passed.
  • ClawSweeper first review was explicitly queued; latest published comment has no findings or Rank-up moves. Per repository policy, the late publisher does not block an otherwise exact-head-green landing.

This is phase-2 PR 4 of the Gateway kernel split. The design-verified resident inventory preceded this extraction; next is the resident-registry PR.

@steipete
steipete merged commit f11b08c into main Aug 11, 2026
181 checks passed
@steipete
steipete deleted the steipete/gateway-kernel-factory branch August 11, 2026 09:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

obviyus added a commit that referenced this pull request Aug 11, 2026
…tion server (#112032)

A 401 challenge pointing at new protected-resource metadata let the MCP SDK rediscover
a different authorization server and POST the stored refresh token to it. Token issuer
is now persisted with the tokens and disclosure is gated on exact issuer identity;
legacy rows without recoverable issuer provenance fail closed to an explicit re-login.

Admin-merged past checks-node-compact-small-1 by maintainer decision: five runs of
attribution show the failure is src/gateway/server-kernel.test.ts (added in #121981)
hanging at HTTP-listen under this merge ref's shard composition — unrelated to this
diff and green on main. Evidence on the PR.

Co-authored-by: yetval <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
…tion server (openclaw#112032)

A 401 challenge pointing at new protected-resource metadata let the MCP SDK rediscover
a different authorization server and POST the stored refresh token to it. Token issuer
is now persisted with the tokens and disclosure is gated on exact issuer identity;
legacy rows without recoverable issuer provenance fail closed to an explicit re-login.

Admin-merged past checks-node-compact-small-1 by maintainer decision: five runs of
attribution show the failure is src/gateway/server-kernel.test.ts (added in openclaw#121981)
hanging at HTTP-listen under this merge ref's shard composition — unrelated to this
diff and green on main. Evidence on the PR.

Co-authored-by: yetval <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant