Skip to content

fix(config): migrate and validate recovery snapshots before restore - #120475

Merged
steipete merged 1 commit into
mainfrom
codex/fix-112962-bind-normalize
Aug 8, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-112962-bind-normalize

Conversation

@steipete

@steipete steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor's .last-good recovery restores hash-matching snapshot bytes without current-schema validation or migration. A snapshot written by an older release (e.g. containing legacy gateway.bind: "localhost") gets restored verbatim, the schema then rejects it, and the gateway is left with an invalid active config — the "recovered into a broken state" loop reported as a perpetual crash-restart.

Fixes #114965 and resolves #112962 (whose direct-normalization claim did not reproduce — canonical bind modes survive load byte-for-byte on main and on the reported release; the actual defect was this recovery path).

Why This Change Was Made

Maintainer decision on the open #114965 question (reject vs migrate): migrate-and-validate. A recovery path that refuses schema-obsolete snapshots discards valid user config that merely needs alias migration; repo doctrine is "doctor migrates, verifies, then runtime assumes the new shape". Rejection remains the fail-closed fallback when migration+validation still fails — an invalid snapshot is never written and the active file plus diagnostics are preserved.

.bak and .last-good recovery now share one canonical candidate-preparation and atomic-replacement flow (apply canonical Doctor migrations to authored bytes → enforce include/env ownership → resolve includes for validation only → current plugin-aware schema validation → write only migrated valid authored config). Their distinct backup-eligibility rules remain separate deliberately (different trust/audit semantics — documented inline). Provenance of the hazard: ffb1628 introduced .last-good recovery without validation; f937775 (#117100) fixed .bak only.

User Impact

Config recovery can no longer resurrect legacy shapes the runtime rejects. A .last-good containing bind: "localhost"/0.0.0.0 restores as canonical loopback/lan; truly invalid snapshots are refused with the active config untouched.

Evidence

  • Focused recovery/startup suite 91/91 + ownership classifier 13/13, incl. localhost→loopback, 0.0.0.0→lan, invalid-snapshot refusal with active bytes untouched, .bak parity, Doctor persistence, canonical-load byte identity, and real gateway startup (re-verified after review).
  • pnpm tsgo:core + tsgo:core:test, import-cycle check (0 runtime cycles), full pnpm build, deadcode scans, git diff --check: all pass.
  • Codex autoreview (gpt-5.6-sol, high): clean (0.96), plus worker-side review.
  • Production +212/−45 (net +167: the unified recovery boundary); tests +463/−53.
  • Residual: migrated JSON5 may lose comments (targeted warning emitted); unavailable plugin validation fails closed.

@steipete
steipete marked this pull request as ready for review August 8, 2026 04:56
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations labels Aug 8, 2026
@steipete
steipete merged commit 267268f into main Aug 8, 2026
69 of 71 checks passed
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 8, 2026
@steipete
steipete deleted the codex/fix-112962-bind-normalize branch August 8, 2026 04:56
steipete added a commit that referenced this pull request Aug 8, 2026
…undled plugin

The test added in #120475 deterministically times out (120s budget) on cold
module caches: its repair-enabled preflight walks
collectChannelLegacyStateMigrationPlans and the plugin doctor contract
registry, which cold-compile all 38 bundled plugin runtimes (~200s measured
under the Vitest transform); the second table case only passed on the warmed
worker. Bind persistence is core config-migration behavior, so stub the two
contract-resolving surfaces (bundled channel legacy artifacts, plugin doctor
contract registry) with narrow importActual partial mocks; cheap raw-config
helpers stay real. 2 tests now pass in ~27s cold.
steipete added a commit that referenced this pull request Aug 8, 2026
…ration drift

Repair the main-owned landing-gate failure from #120475, whose declaration emission changed the session-catalog baseline without regenerating this manifest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

1 participant