Repository navigation
Conversation
…ccepted When the Gateway reads a config an older supported release wrote and it fails validation, run Doctor's state-free config transform in memory (known migrations, then unknown-key removal) and start with a warning instead of refusing. The file is unchanged; the current release's writers stay strict. The first rewrite of an older release's config keeps the original as openclaw.json.pre-<version>. Doctor no longer restores last-known-good over a readable invalid config, which discarded newer settings. Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Co-authored-by: obviyus <[email protected]>
|
Codex review: needs maintainer review before merge. What this changesThis PR lets older-release configs run through Doctor migrations in memory, preserves versioned originals, and prevents stale recovery from replacing readable settings. Example: Replace OpenClaw 2026.11.2 with the candidate while the config still contains skills.workshop.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This maintainer-authored upgrade repair remains necessary on main; the earlier findings are fixed, and no actionable correctness or security findings remain. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherConfig snapshots resolve authored settings and validate them for Gateway and CLI consumers; Doctor owns persistent migration, while the config writer owns backups and publication. flowchart TD
A[Authored config] --> B[Config snapshot reader]
B --> C[Strict validation]
C --> D[Doctor migration projection]
D --> E[Gateway runtime and status]
A --> F[Doctor repair]
F --> G[Config writer and retained original]
Technical reviewBest possible solution: Use Doctor's existing transforms for temporary runtime admission, preserve original bytes, and keep canonical persistence under Doctor and the config writer. Do we have a high-confidence way to reproduce the issue? Current-main validation and recovery source support the reported failures, and the supplied real-install comparison records exit 78 before the fix; no target code was executed during this read-only review. Is this the best way to solve the issue? The change reuses Doctor's migration owners, preserves strict writes and authored input, and removes the narrower recovery exception without adding competing persistent migration machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3991f8f22494. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +164, Tests +118, Docs +30. Total +312 across 21 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed November 13, 2026, 3:52 PM ET / 20:52 UTC (Revision 4). |
…s in memory Co-authored-by: obviyus <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…he migration in status - A config valid only through the older-release projection is not restored over, promoted to last-known-good, or recovered from a larger stale backup. - The kept openclaw.json.pre-<version> is staged and linked, so a failed write never leaves a partial original and the next write retries. - openclaw status and status --json show the pending migration. Co-authored-by: obviyus <[email protected]>
… test Co-authored-by: obviyus <[email protected]>
The online status --json path reads Gateway projection, not local config, so a JSON field would appear only while the Gateway is down. Co-authored-by: obviyus <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Problem
Upgrades refuse or lose config that the previous release accepted. From 2,720 classified real upgrade failures:
Reproduced with a real
[email protected]npm install and a managed LaunchAgent Gateway. 2026.10.10 accepts this config (openclaw config validate→valid: true):{ "agents": { "defaults": { "embeddedAgent": { "cyberFailover": { "model": "openai/gpt-6-astra" } }, "compaction": { "memoryFlush": { "model": "openai/gpt-6-astra" } } } }, "channels": { "defaults": { "heartbeatVisibility": { "showOk": true } } }, "skills": { "workshop": { "autonomous": { "mode": "off" } } } }openclaw updatetomainworks: candidate Doctor migrates the keys before restart.npm i -g, a host that boots the new image) leaves the Gateway down:gateway startexits 78 withOpenClaw config is invalid ... Unrecognized key: "workshop".openclaw.json.last-goodwhenever a readable config is invalid and it has no automatic repair, replacing newer settings with older ones..bakring and the per-attempt.pre-updatecopy, so the file the old release wrote is eventually overwritten.What changed
src/config/io.snapshot.ts): when a config whosemeta.lastTouchedVersionis an older supported release (2026.7.1 or newer) fails validation, the Gateway runs Doctor's own state-free transform in memory:applyLegacyDoctorMigrations(with plugin contracts off), retired-heartbeat projection, then unknown-key removal. If that result validates, the Gateway starts with it and one warning lists every change and asks foropenclaw doctor --fix. The file andsourceConfigare unchanged. This is Doctor's transform, not a new runtime reader: runtime still consumes canonical config.src/config/backup-rotation.ts): the first rewrite by a newer release keeps the older release's bytes asopenclaw.json.pre-<version>, outside the.bakring.doctor-config-preflight-legacy-config.ts): Doctor restores last-known-good only whenopenclaw.jsoncannot be parsed. A readable invalid config keeps its newer settings for repair. The prompt-permission guard that existed only to block that restore is deleted.automatic-config-repair.ts): a snapshot that is valid only through this projection carriesolderReleaseMigration(source version and the list of changes), and Doctor's repair planner treats it like the invalid file it replaces, sodoctor --fixand update preflight write the migrated config as before. Without this, Doctor saw a valid snapshot and skipped the write (caught bydoctor-config-preflight.process.test.ts, stable-upgrade case).io.snapshot.ts,io.observe.ts,io.factory.ts): a snapshot valid only through the projection is not promoted to last-known-good and is skipped by Doctor's suspicious-read recovery, so a larger older.bakis never restored over it. Doctor migrates and saves it instead.backup-rotation.ts):openclaw.json.pre-<version>is written to a temp file and published withlink, so a failed write leaves no partial original and the next write retries; an existing original is never replaced.openclaw statusshows it: a "Config migration pending" block lists every in-memory change and namesopenclaw doctor --fix. Status reads the local snapshot, so it shows whether or not the Gateway is running.Diff vs
main: production +188 / -24, tests +147 / -29, docs +40 / -10. The growth is the in-memory projection hook (~50 lines, reusing Doctor's transform), the staged.pre-<version>writer (~45 lines), the projection module (~40 lines) and the status block (~25 lines). Deleted: the prompt-permission guard and the readable-config last-known-good restore path in Doctor. A follow-up could fold the per-attempt.pre-updatecopy into.pre-<version>; it sits in update rollback code another PR owns.Validation boundary
The boundary is the writer stamp
meta.lastTouchedVersion:config set, Doctor, any validated writer), validation is strict again.config seton a tolerated config refuses the retired key and namesopenclaw doctor --fix.openclaw config validatestays strict (it validates the file as written).Proof
Real installs, isolated profile (own LaunchAgent and port, clean env). Packed exact head
954dce0(self-contained package,build-info.jsoncommit954dce0a119a); later commits change only a test type and drop an unusedstatus --jsonfield.Package replacement on a config an older release wrote (published
[email protected]with the config above,meta.lastTouchedVersion: 2026.11.2, serving/readyzready). Database migration is held constant by running Doctor with the config read-only:main(before)954dce0(after)gateway startOpenClaw config is invalid ... skills: Unrecognized key: "workshop"/readyz→ready: true, coreReady: trueConfig written by OpenClaw 2026.11.2 uses settings this release retired. Running with Doctor's migration until it is saved: ...openclaw statusConfig migration pending:block (below)openclaw config set gateway.port 28794before Doctorcmp)openclaw doctor --fixopenclaw.json.pre-2026.11.2equals the original bytes (cmp);config validate→valid: true;skills.workshopmoved toplugins.entries.skill-workshop.config(autonomous.mode: off); port keptLatest stable
2026.11.3→ head viaopenclaw update(published[email protected], managed LaunchAgent, a third-party plugin,gateway.port/authset, 2 cron jobs, 1 user profile, a device identity;openclaw update --tag <head tarball> --yes):Recorded verification: ... HTTP ready; core ready;/readyzready on954dce0gateway.port 28792,auth.mode token, pluginconfig.label demo, stamp unchanged before and after Doctoropenclaw.json.pre-updateequals the pre-update file (cmp); no.pre-<version>(same-version writer, as designed)60764235…,e8f8c2d8…identical; 1 user profile;mainagent database; device IDb88f38fa…identical (moved bymain's schema migration intoclient/credentials.sqlite)Config migration pendingblock (config is current)doctor --fix,gateway restartFresh install of the head (new profile,
npm install -g <head tarball>,config set gateway.mode/port,gateway install): exit 0,/readyzready, config stamped2026.11.3, status shows no migration block, no.pre-*file.openclaw updatefrom2026.10.10(real npm install, same keys):mainalready succeeds, because candidate Doctor migrates the keys before restart; the only kept copy of the original is.pre-update, which the next update attempt overwrites. This branch keepsopenclaw.json.pre-2026.10.10permanently.Next blocker after config (out of scope, item 4): a direct replacement from 2026.10.10 or 2026.11.2 to
mainnow passes config admission and stops atagent database ... uses schema version 27; ... run openclaw doctor --fix to upgrade it to schema version 42. The copy-and-swap work owns that.Regression tests, red on the previous head and green here:
doctor-config-preflight.recovery.test.ts(1,024-byte.bakwith port 19091 vs compact older-stamped config with port 19092: before, Doctor restored the backup; now it keeps 19092 and migrates),config.backup-rotation.test.ts(injected ENOSPC mid-write: before, a partial.pre-2026.10.10stayed forever; now none is left and the next write keeps the full original).status.usage-routing.test.tscovers the status block.Focused tests:
io.snapshot.test.ts(older writer tolerated, heartbeat case, current writer still strict),config.backup-rotation.test.ts(.pre-<version>kept once),doctor-config-preflight.test.ts(readable invalid config is no longer replaced by last-known-good; unreadable file still restored), recovery, container-upgrade and state-migration suites.Accepted edge cases
status --jsondoes not carry the migration notice. With the Gateway online it reports the Gateway's status projection and reads no local config; reporting it there needs a Gateway-side fact kept across config reloads. Follow-up if wanted; text status, the Gateway log and Doctor show it.openclaw status, Doctor), recoverable (openclaw doctor --fix), and warned. No per-release key-acceptance records are kept.loadConfig()callers keep strict validation; the Gateway reads config through the async snapshot path, which is tolerant.plugins.entries.<id>.config, plugin channel schemas) are not stripped; they remain plugin validation errors.