Skip to content

fix(gateway): preserve native runtime selection across reloads - #133195

Merged
steipete merged 1 commit into
mainfrom
codex/cloud-runtime-source-reload
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cloud-runtime-source-reload

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users changing a model to the Codex runtime through hot reload could still see and execute the OpenClaw runtime until restarting the Gateway. Reloading secrets could cause the same unexpected runtime fallback.

Why This Change Was Made

The reload owners were publishing effective model settings as authored settings. Catalog compatibility defaults then looked like custom request overrides, which correctly triggered the native runtime's unsupported-override fallback.

Both managed config reload and secrets reload now carry the separately authored config through the existing activation and guarded restoration APIs. Failed publications restore the predecessor's authored settings, while the existing revision and ownership checks prevent a stale rollback from replacing a newer publication. Source-only reload, provider credential refresh, and runtime compatibility policy retain their existing behavior.

User Impact

Model runtime changes take effect through hot reload without a restart to remove a false compatibility fallback. Credential refresh preserves the selected runtime when users have not authored request overrides. No configuration, environment, protocol, storage, or dependency surface is added.

Release-note context: preserve authored model settings through config and secrets reload so catalog defaults cannot unexpectedly switch native runtimes back to OpenClaw.

Evidence

  • Reproduced against base 357078cf7087534443dac92eb86e8aa32abb7b08: the effective config changed to Codex, but publication promoted generated compatibility metadata into authored request overrides. An unchanged-config restart restored Codex selection in the original live session.
  • Regression tests were added before production changes: six intended provenance failures and seven passes. The identical command passes all 13 tests after the fix, including successful publication, failed-commit restoration, and newer-publication fencing through both activation paths.
  • Broader owner and sibling coverage passes 541 tests across managed reload, secrets/model publication, startup, secrets lifecycle, config snapshot, secret-state ownership, and harness selection.
  • Final independent Codex review: no actionable P0–P2 findings. The reviewer checked source preservation and existing revision/ownership guards.
  • Canonical changed checks passed source policy, formatting, dead-export checks, and production types. Core test typing hit an unrelated shared-checkout missing pako declaration. A fresh frozen install of the exact base plus reviewed patch then passed all 541 tests, production and full core test typing, and scoped lint. Remaining source guards passed separately. This is composed verification, not a claim that the original aggregate passed. No shared dependency was modified or check weakened.
  • Real packaged Gateway proof passes on the exact PR commit without restart: canonical config set changes the selected runtime from OpenClaw to Codex/remote execution, then secrets.reload succeeds with zero warnings and retains Codex. The same Gateway process handled the entire 4.426-second sequence. A pre-listen readiness refusal had no config mutation and is recorded separately. Fresh cloud execution through the UI and cleanup also passed, as recorded below.

Production LOC: +43/-6 (net +37). Tests: +179/-6. Docs: +5/-0. Production growth carries the existing authored-source datum through the publication owners and narrows one internal dependency type to its five consumed services; no new fallback or parallel publication path is introduced. Inferring source in a consumer or generic publisher would lose the distinction between a new config and a credential-only refresh.

Provenance: the current-main baseline is reproduced. Earlier source-projection work establishes the contract, but the introducing commit and stable-release impact have not been established; this PR makes no stable-release regression claim.

Integration review and ClawSweeper disposition

ClawSweeper found no correctness or security issue. Its current-main integration request is addressed: exact-head CI run33301865522 passed 168 jobs with 17 intentional skips on verified synthetic merge 643d5e7fb620715bfff8d02fe58137ee9c7260ef (main f2cc4f1a0f4bf3d2aadbb677a2bf6cf75dea23a3 plus this exact head). All five PR blobs match that tested merge. Canonical prepare passed without rebasing or pushing.

Reviewed main baseline 043c1ae6167f01e085c5272ef24a8d2b5a965b59 adds the computer observation-classifier repair and a TTS CLI option-conflict fix after the tested main parent. Direct source review found no change to runtime source publication, selection, or rollback ownership. A conflict-free merge-tree preserves all five PR blobs; this source composition is not claimed as another executed integrated build. Connected plugin/model-picker refactors were already included in the successful CI merge. Actual packaged hot reload and secrets reload pass without restart; fresh UI cloud tool execution and cleanup also passed, as recorded below.

Final cloud execution proof

The same packaged Gateway process handled hot reload, secrets reload, and a new cloud session created through the real UI. That session selected Codex from the model configuration and used remote execution. The installed native runtime was Codex 0.151.0. Three native clicks changed the test page counter from 0 to 3; a fresh native turn read 3. Five structured native images were returned, both native executions acknowledged close, and the observed UI and RFB output agreed. Canonical reclaim completed and independent provider inspection confirmed the lease released.

{"sourceCommit":"470675aa2a450ab2317b83d490a351a8c8143fb7","sameGatewayProcess":true,"hotReload":"codex/remote-exec","secretsReload":{"ok":true,"warnings":0},"uiCreatedCloudSession":true,"codexVersion":"0.151.0","nativeImages":5,"clicks":3,"startingCount":0,"endingCount":3,"freshTurnCount":3,"bothNativeClosesAcknowledged":true,"canonicalReclaim":"passed","providerLease":"released"}

This candidate does not claim active-turn Stop stress or the concurrent Web VNC viewer repair; those are separate fixes. The package was built locally from the exact reviewed commit; no byte-equivalence to CI artifacts is claimed.

Final main audit at 1f017332a65282225f510e066423a91a8add9a53 covers the later auth-profile/model-id separation, session-owned UI metadata, and supervised-process shutdown changes. None changes the authored runtime-source publishers. Explicit configured-profile validation is separate from this unsuffixed model flow; supervisor drain runs during Gateway shutdown, not hot reload or secrets reload. Current-main source composition is conflict-free and preserves every PR blob. This is source compatibility evidence, not a claim of another integrated native build. Fresh pre-landing Codex review again found no actionable P0–P2 defect.

@clawsweeper

clawsweeper Bot commented Aug 30, 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 docs Improvements or additions to documentation gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 08:33
@steipete
steipete requested a review from a team as a code owner August 30, 2026 08:33
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 4:40 AM ET / 08:40 UTC.

ClawSweeper review

What this changes

This PR preserves the separately authored model configuration through gateway hot reload and secrets reload so generated catalog metadata cannot change the selected native runtime.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this member-authored, maintainer-labelled compatibility fix open for normal maintainer review. The introduced activation changes consistently preserve the authored configuration through hot reload, secrets reload, and rollback; no concrete patch defect was found.

Priority: P2
Reviewed head: 470675aa2a450ab2317b83d490a351a8c8143fb7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The targeted owner-boundary repair and race-focused tests are solid; final exact-head integration remains the relevant merge check.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; the supplied tests still provide focused supplemental coverage of the changed reload owners.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; the supplied tests still provide focused supplemental coverage of the changed reload owners.
Evidence reviewed 7 items Activation owner preserves authored source: The snapshot activation owner stores the resolved runtime configuration while accepting a distinct authored-source configuration; the PR supplies that source on both successful and rollback activation paths.
Caller builds an effective runtime candidate separately: Managed reload restores canonical secret references, reapplies runtime overlays, and then prepares the effective candidate, establishing why the original source configuration must be carried separately.
Route resolver consumes authored projection: Provider route resolution projects the runtime snapshot back to its authored source before determining whether request transport overrides exist, so catalog compatibility fields are not treated as user policy.
Findings None None.
Security None None.

How this fits together

Gateway reload prepares a secrets-resolved runtime configuration, publishes it, and rebuilds model-runtime state. The route resolver uses the authored configuration to distinguish user request overrides from catalog-derived compatibility metadata before selecting a native runtime.

flowchart LR
  A[Authored model settings] --> C[Gateway reload transaction]
  B[Secrets-resolved runtime config] --> C
  C --> D[Snapshot activation]
  D --> E[Authored-source projection]
  E --> F[Model route resolution]
  F --> G[Selected native runtime]
Loading

Before merge

  • Resolve merge risk (P1) - This changes compatibility-sensitive runtime-source publication during reload and rollback; a maintainer should confirm the final exact-head integration against the latest main because current-main source blobs could not be hydrated in this review environment.
  • Complete next step (P2) - This protected member-authored PR already contains the bounded implementation; it needs normal maintainer integration review rather than a separate repair job.
Agent review details

Security

None.

PR surface

Source +37, Tests +173, Docs +5. Total +215 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 43 6 +37
Tests 2 179 6 +173
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 227 12 +215

Review metrics

Metric Value Why it matters
Production versus test delta production +37 net; tests +173 net; docs +5 The production growth threads authored-source state through two reload owners and their rollback paths; the test growth covers the affected publication races.

Merge-risk options

Maintainer options:

  1. Confirm the exact-head reload invariant (recommended)
    Rebase or merge-test against current main and verify that hot reload, secrets refresh, and rollback retain authored runtime selection without changing generated catalog defaults.

Technical review

Best possible solution:

Keep one authored-source datum distinct from effective runtime configuration at the snapshot activation owner, with the same distinction preserved on success, failure restoration, and subsequent secrets refreshes.

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

Yes, from source: pre-PR activation defaults the authored snapshot to the effective prepared configuration, while route selection uses that authored view to classify transport overrides; the new focused test encodes the catalog-metadata case.

Is this the best way to solve the issue?

Yes: preserving the authored source at the activation owner is narrower and safer than teaching downstream route selection to guess which effective fields came from a catalog.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The PR repairs a limited but user-visible runtime-selection defect during gateway reload.
  • add merge-risk: 🚨 compatibility: It changes how existing authored model settings are retained and interpreted across reload activation and rollback.
  • 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 is a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; the supplied tests still provide focused supplemental coverage of the changed reload owners.

Label justifications:

  • P2: The PR repairs a limited but user-visible runtime-selection defect during gateway reload.
  • merge-risk: 🚨 compatibility: It changes how existing authored model settings are retained and interpreted across reload activation and rollback.
  • 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 is a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; the supplied tests still provide focused supplemental coverage of the changed reload owners.

Evidence

What I checked:

  • Activation owner preserves authored source: The snapshot activation owner stores the resolved runtime configuration while accepting a distinct authored-source configuration; the PR supplies that source on both successful and rollback activation paths. (src/secrets/runtime-state.ts:979, 470675aa2a45)
  • Caller builds an effective runtime candidate separately: Managed reload restores canonical secret references, reapplies runtime overlays, and then prepares the effective candidate, establishing why the original source configuration must be carried separately. (src/gateway/server-reload-managed.ts:63, 470675aa2a45)
  • Route resolver consumes authored projection: Provider route resolution projects the runtime snapshot back to its authored source before determining whether request transport overrides exist, so catalog compatibility fields are not treated as user policy. (src/plugins/provider-model-routes.ts:88, 470675aa2a45)
  • Native-runtime fallback condition: The bundled Codex runtime falls back only when the prepared model-provider facts report authored request transport overrides; this is an OpenClaw-internal contract, not a dependency on the sibling OpenAI Codex repository. (extensions/codex/harness.ts:180, 470675aa2a45)
  • Focused regression coverage: The added table-driven test covers both activation entrypoints, successful publication, failed-commit restoration, and fencing of a newer publication while asserting that generated compatibility metadata remains absent from authored override policy. (src/gateway/server-reload-managed-secrets.test.ts:132, 470675aa2a45)
  • Feature-history routing: Recent gateway history includes the prior merged model-runtime/secrets publication work by Peter Steinberger; a related model-selection repair was authored by Hannes Rudolph in commit 9441e3f. (src/gateway/server-secrets-reload.ts:189, 9e302fb57e4c)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Hannes Rudolph: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Verify the exact-head hot-reload, secrets-refresh, and rollback invariant after current-main integration.

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 3483c89 into main Aug 30, 2026
319 checks passed
@steipete
steipete deleted the codex/cloud-runtime-source-reload branch August 30, 2026 09:02
@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

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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