Skip to content

refactor(gateway): invert config reloader ownership - #122004

Merged
steipete merged 1 commit into
mainfrom
steipete/gateway-config-reloader-inversion
Aug 11, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/gateway-config-reloader-inversion

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Phase-2 PR 6 removes the config reloader’s reverse dependency on raw Gateway kernel state after the resident registry landed in #121996.

Why This Change Was Made

The kernel now owns reload snapshots and the named swapHeartbeatRunner() and swapCronState() operations, including the live deps.cron publication. The reloader calls those methods in the same synchronous order as the prior field assignments. Plugin replacement is exposed only as kernel.reloadPlugins(), while plugin-service publication also stays behind the kernel setter.

Request-context plugin metadata notifications and hot-reload status no longer reach into runtimeState.configReloader. They call kernel bridges that resolve the current GatewayConfigReloaderHandle, whose pre-start inert implementation remains unchanged. There are no config, protocol, default, ordering, or user-visible behavior changes.

This is phase-2 PR 6 of the Gateway kernel split. The next and final authorized step is PR 7: final composition plus the kernel import-boundary invariant.

User Impact

No user-visible change. Config reload, cron/heartbeat swaps, plugin reload, and metadata refresh keep their existing behavior behind an explicit kernel ownership boundary.

Evidence

  • reload handlers, hot-reload status, restart, all startup-config suites, request-context bridge, and socket-free kernel: 8 files, 291 passed
  • core and core-test tsgo lanes: passed
  • node scripts/check-changed.mjs -- <touched>: formatting, dead exports, lint, plugin boundaries, schema/runtime/import-cycle/auth guards passed locally after remote backend fallback
  • pnpm build: passed
  • Codex autoreview: clean, no accepted/actionable findings

The default local multi-project Gateway runner still reproduces the current-main stale state-schema inlining issue recorded on PR 5; the focused proof uses OPENCLAW_GATEWAY_PROJECT_SHARDS=0 without changing assertions. Exact-head hosted CI remains the heal-check.

ClawSweeper review metrics: production +61/-30 (net +31) for kernel-owned reload state, plugin reload, and resident-handle bridges; tests +20/-34 (net -14). 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.

@steipete steipete self-assigned this Aug 11, 2026
@steipete
steipete marked this pull request as ready for review August 11, 2026 11:05
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels 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:

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 7:10 AM ET / 11:10 UTC.

ClawSweeper review

What this changes

The PR routes Gateway configuration-reload state changes, plugin reload, and request-context reloader access through kernel-owned operations instead of direct mutable-state access.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking findings. This focused, maintainer-owned Gateway refactor preserves the existing reload sequence while moving mutable-state access to the kernel boundary; retain it for exact-head CI and normal maintainer merge review.

Priority: P3
Reviewed head: 9c068277dbbee7fe9967fbc85d723cc83a0f2f21

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and preserves the reviewed live-handle semantics.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor has no directly user-visible flow to demonstrate; its focused test and build evidence is supplemental while exact-head CI runs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor has no directly user-visible flow to demonstrate; its focused test and build evidence is supplemental while exact-head CI runs.
Evidence reviewed 6 items Reload state ownership: The branch makes the kernel return the current reload state and perform each prior live-state update, including synchronous cron publication to Gateway dependencies.
Entry point and caller: Startup now supplies the reloader with kernel methods, while request-context construction receives kernel bridges for plugin metadata notifications and hot-reload status.
Current-main comparison: Current main performs these same reload writes directly in startup configuration, so the refactor is not already implemented or obsolete.
Findings None None.
Security None None.

How this fits together

Gateway startup creates a kernel around live server state, then starts the configuration reloader and exposes an RPC request context. Reloads update cron, heartbeat, plugin, and health-monitor handles that Gateway services subsequently read.

flowchart LR
  A[Configuration or plugin change] --> B[Gateway config reloader]
  B --> C[Gateway kernel]
  C --> D[Live Gateway state]
  C --> E[Plugin services and discovery]
  D --> F[Health and RPC request context]
  E --> F
Loading

Before merge

  • Complete next step (P2) - No discrete repair is needed; the remaining action is exact-head validation and normal maintainer merge review.
Agent review details

Security

None.

PR surface

Source +31, Tests -14. Total +17 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 5 61 30 +31
Tests 1 20 34 -14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 81 64 +17

Review metrics

Metric Value Why it matters
Production vs test LOC production +61/-30 (net +31); tests +20/-34 (net -14) The production growth is the explicit kernel ownership surface and its call sites; test changes replace live-state fixtures with bridge assertions.

Root-cause cluster

Relationship: canonical
Canonical: #122004
Summary: This PR is the focused next phase after the resident-lifecycle kernel boundary work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep reloader-owned operations behind the Gateway kernel and merge once exact-head required checks complete.

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

Not applicable: this PR refactors an internal ownership boundary rather than reporting a user-facing failure.

Is this the best way to solve the issue?

Yes: adjacent Gateway lifecycle operations already use the kernel boundary, so moving the reloader and request-context access there avoids retaining a reverse dependency on raw live state.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is an internal Gateway refactor with no intended user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor has no directly user-visible flow to demonstrate; its focused test and build evidence is supplemental while exact-head CI runs.

Label justifications:

  • P3: This is an internal Gateway refactor with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor has no directly user-visible flow to demonstrate; its focused test and build evidence is supplemental while exact-head CI runs.

Evidence

What I checked:

Likely related people:

  • steipete: Authored this PR and the immediately preceding merged resident-lifecycle refactor that established the kernel setter boundary. (role: recent Gateway lifecycle contributor; confidence: high; commits: ad22faffe06d, 9c068277dbbe; files: src/gateway/server-lifecycle.ts, src/gateway/server-startup-finish.ts, src/gateway/server-core-runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the in-progress exact-head CI checks before merge.

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

Copy link
Copy Markdown
Contributor Author

Land-ready proof:

  • Native review: READY FOR /prepare-pr, zero findings.
  • ClawSweeper exact-head review: no findings; its only optional Rank-up move was to wait for exact-head CI, now satisfied.
  • Exact-head CI: green for 9c06827.
  • Reload/startup/request-context/kernel proof: 8 files, 291 passed.
  • Changed-file gates, core/core-test tsgo, lint/architecture guards, and pnpm build: passed.
  • Fresh commit-mode autoreview: clean.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 122004: passed.

This is phase-2 PR 6 of the Gateway kernel split. Next is the final composition and import-boundary PR, then the authorized sequence stops.

@steipete
steipete merged commit 2b0ceb5 into main Aug 11, 2026
186 checks passed
@steipete
steipete deleted the steipete/gateway-config-reloader-inversion branch August 11, 2026 11:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant