Skip to content

fix(doctor): keep a valid reseeded config that lacks meta - #183703

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1910
Oct 25, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1910

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #183641. After the documented Kubernetes reseed (docs/install/kubernetes.md), the persisted openclaw.json is deleted and the init container copies a valid ConfigMap version that has no meta block. The next openclaw doctor --fix reports Config auto-restored from backup: … (missing-meta-vs-last-good), puts the previous last-good config back, and keeps the operator's new file only as openclaw.json.clobbered.<timestamp>. The Gateway then runs the old configuration with no error. The image entrypoint runs doctor --fix before every gateway start, so every reseed hits this when that entrypoint is used; with the official manifest it hits whenever Doctor runs later, for example during an upgrade.

Why This Change Was Made

A missing meta block alone is not evidence that the file was clobbered. The shared clobber detector no longer treats it as one, so Doctor keeps a valid reseeded file as is, and the Gateway promotes it to last-good after a successful start (existing behavior in src/gateway/server-startup-finish.ts). The real protections stay: a large size drop or a missing gateway.mode still triggers recovery, and invalid files still restore. Any restore now warns with the path of the preserved original and how to undo it, so a restore is never silent. The Kubernetes reseed docs are updated to match.

User Impact

Operators who reseed config from a ConfigMap keep the configuration they deployed. Doctor no longer silently swaps it for the previous one during startup or upgrades.

Evidence

  • New regression reproduces the reseed sequence (last-good and .bak ring present, valid meta-less replacement): Doctor keeps it unchanged with no .clobbered file, the meta-less config can be promoted to last-good, and a later invalid config still restores with the undo warning. It fails on main (verified by reverting the detector change).
  • doctor-config-flow, io.observe-recovery and io.snapshot.promotion tests pass on Node; the Doctor config-flow files also pass under Bun.
  • 113 config-owner tests pass. In a 52-file consumer sweep, the 41 files that ran passed apart from two host-permission failures, which reproduce identically on unchanged main.
  • Typecheck, lint, format, docs links and import-cycle checks pass.
  • Autoreview (branch mode, P1): scoped-clean.
  • Production LOC +5/−10 (net −5); tests +54/−26; docs +7.

Thanks @csabatatrai for the precise report and workaround.

Review Notes

  • ClawSweeper's P2 finding (Doctor consumer fixtures vs. the new metadata repair at src/commands/doctor-config-flow.ts:167-174) was against 25aa585. Head 0f79666 removes that metadata repair entirely, so doctor-config-flow.ts matches main and its fixtures pass unchanged (46/46 on Node, also green under Bun).
  • Upgrade-run proof: skipped. The fix is the shared read-time clobber detector, which runs the same way on any upgrade path. The regression test reproduces the exact reseed state from the report (last-good and .bak ring present, valid meta-less file) and the later invalid-config recovery.

After the documented Kubernetes reseed, a valid openclaw.json without a meta
block was classified as clobbered (missing-meta-vs-last-good) and doctor --fix
restored the previous last-good config, keeping the operator's new file only as
openclaw.json.clobbered.<ts>. Missing meta alone is no longer clobber evidence:
doctor keeps the valid file, stamps meta, refreshes last-good and reports the
repair. Truncated or invalid files still restore, with a warning naming the
saved original and how to undo it.

Fixes #183641. Thanks @csabatatrai.
@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 25, 2026 16:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T16:39:59.187494Z 0f79666 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: S labels Oct 25, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR preserves valid metadata-free configurations, makes Doctor stamp their metadata and refresh recovery backups, and adds actionable restore warnings.

Example: A Kubernetes reseed replaces gateway.port 19091 with 19092 in a valid configuration without meta.

  • Before: Doctor restores the older configuration and the Gateway uses port 19091.
  • After: Doctor retains port 19092, stamps metadata, and refreshes last-good.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused shared-owner fix has clear value, but attributable consumer-test failures and incomplete upgrade qualification prevent a pass.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor can silently undo a valid Kubernetes configuration reseed and run the operator's previous settings.
Reason: The reported release failure conflicts with the documented reseed flow, and maintainer authorship establishes acceptance of removing metadata-only recovery.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open: it addresses a confirmed configuration-recovery bug, but the new metadata repair causes five Doctor consumer-test failures that need updating.

Priority: P1
Reviewed head: 25aa585f9cf39ec81f284518e9276559d8eaf5ef

Before merge

  • Update Doctor consumer fixtures for the new metadata repair (P2) - Every valid metadata-free snapshot now plans a write, but the existing consumer tests still use such snapshots to assert unrelated no-op behavior. The reviewed-head CI reports five failures at doctor-config-flow.test.ts:290 twice, :430, :577, and :619, including the new metadata repair text in the failure. Give fixtures that test unrelated no-op behavior existing metadata, or explicitly account for the intended repair where appropriate, while preserving their original ownership, warning, and preview assertions.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Update Doctor consumer fixtures for the new metadata repair — src/commands/doctor-config-flow.ts:167-174

Tests

  • Missing end-to-end proof: Provide a redacted v2026.10.7-to-head upgrade run showing the reseeded settings and existing backups survive, with later invalid-config recovery still working.
Agent review details

How this fits together

The shared config observer classifies suspicious reads, recovery restores eligible backups, and Doctor persists validated repairs through the existing guarded config writer.

flowchart TD
  A[ConfigMap reseed] --> B[Config snapshot]
  B --> C[Shared suspicion detector]
  C --> D[Backup recovery]
  C --> E[Doctor repair planner]
  E --> F[Guarded config writer]
  F --> G[Last-good promotion]
Loading

Technical review

Best possible solution:

Keep the shared detector fix and existing guarded persistence owners, update the affected consumer fixtures, and qualify preservation of existing installations.

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

The released-version report and current-main detector-to-recovery path establish the failure; this read-only review ran no target code.

Is this the best way to solve the issue?

Removing metadata absence at the shared detector fixes the cause for all consumers while retaining stronger clobber signals; the small receipt cleanup reuses the existing canonical owner.

Full review comments:

  • [P2] Update Doctor consumer fixtures for the new metadata repair — src/commands/doctor-config-flow.ts:167-174
    Every valid metadata-free snapshot now plans a write, but the existing consumer tests still use such snapshots to assert unrelated no-op behavior. The reviewed-head CI reports five failures at doctor-config-flow.test.ts:290 twice, :430, :577, and :619, including the new metadata repair text in the failure. Give fixtures that test unrelated no-op behavior existing metadata, or explicitly account for the intended repair where appropriate, while preserving their original ownership, warning, and preview assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3d83f96a4f25.

Provenance checked

  • Metadata-only suspicion changes intended behavior with a stated reason (72628f9: This commit extracted the existing clobber checks into one shared detector; it does not establish their original introduction. The older-content git log -S search encountered an unavailable promisor blob.)
  • Last-known-good promotion and inherited anomaly protection changes intended behavior with a stated reason (99418fc: Prevent parseable truncations and later ordinary writes from overwriting the healthy recovery copy.)
  • Doctor source revision receipt keeps the original intent (1a7911f: Keep each successive repair bound to its preceding committed revision and refuse stale writes.)
  • Recovery diagnostics keeps the original intent (aa9db99: Expose rejected validation details during recovery so operators can identify the invalid configuration.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/commands/doctor-config-flow.test.ts
  • pnpm test src/commands/doctor-config-flow.workspace-persistence.test.ts src/config/io.observe-recovery.test.ts src/config/io.snapshot.promotion.test.ts
  • pnpm check:changed
  • git diff --check

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 1a7911f adds src/flows/doctor-health-contribution-runners.config.ts:277 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1a7911f56c11; files: src/flows/doctor-health-contribution-runners.config.ts)
  • weiqinl: Raw commit 99418fc adds src/config/io.observe-suspicious.ts:61 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 99418fcd427b; files: src/config/io.observe-suspicious.ts)

PR surface

Source +9, Tests +34, Docs +7. Total +50 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 29 20 +9
Tests 3 60 26 +34
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 96 46 +50

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #126806
Summary: This PR addresses the metadata-only restoration mechanism tracked by the canonical issue, including the documented Kubernetes reseed trigger.

Members:

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

Labels

Label changes:

  • add P1: The reported released-version workflow silently replaces deployed operator settings with an older configuration during Doctor or container startup.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: The reported released-version workflow silently replaces deployed operator settings with an older configuration during Doctor or container startup.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 25, 2026, 12:35 PM ET / 16:35 UTC.

Drop the extra Doctor meta stamping and last-good refresh: the Gateway already
promotes an accepted config to last-good after startup, and stamping every
hand-written config made Doctor report a repair for valid configs. Restore the
session-store owner confirmation and config path fallback that the previous
commit removed by accident.
@steipete
steipete merged commit 159c14a into main Oct 25, 2026
133 of 136 checks passed
@steipete
steipete deleted the upd/upd-l1910 branch October 25, 2026 16:51
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…83703)

After the documented Kubernetes reseed, a valid openclaw.json without a meta block was classified as clobbered (missing-meta-vs-last-good) and doctor --fix restored the previous last-good config, keeping the operator's new file only as openclaw.json.clobbered.<ts>, so the Gateway silently ran the old configuration. Missing meta alone is no longer clobber evidence, so the valid reseed is kept and the Gateway promotes it to last-good after starting. Size-drop and missing gateway.mode checks still trigger recovery, and every restore warning now names the preserved original and how to undo it.

Fixes openclaw#183641. Thanks @csabatatrai for the report.
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
After the documented Kubernetes reseed, a valid openclaw.json without a meta block was classified as clobbered (missing-meta-vs-last-good) and doctor --fix restored the previous last-good config, keeping the operator's new file only as openclaw.json.clobbered.<ts>, so the Gateway silently ran the old configuration. Missing meta alone is no longer clobber evidence, so the valid reseed is kept and the Gateway promotes it to last-good after starting. Size-drop and missing gateway.mode checks still trigger recovery, and every restore warning now names the preserved original and how to undo it.

Fixes #183641. Thanks @csabatatrai for the report.

Release adaptation: the baseline has no io.observe-promotion.ts or io.snapshot.promotion.test.ts; last-known-good promotion lives in io.observe-recovery.ts, so the hasMeta plumbing was removed there instead. The doctor regression test was ported into the baseline describe block without the main-only helpers (await using, withHome).

(cherry picked from commit 159c14a)
RomneyDa added a commit that referenced this pull request Oct 26, 2026
…ed semantics

Bedrock Responses routing cases used the shared discovery cache key, so the
default-region case read a cached result. #179471 no longer fails updates on
an unavailable channel, #183703 no longer treats missing meta as clobber
evidence, #180174 downgrades a missing legacy OAuth dir to a warning, and
#180280 leaves untimed 429s without a cooldown; their stale expectations
are updated to match main. The #183390 media case is wrapped in the stable
harness shape, and the Codex ownership harness now reports the original
owner's thread as loaded until it exits, as the app server does.
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
After the documented Kubernetes reseed, a valid openclaw.json without a meta block was classified as clobbered (missing-meta-vs-last-good) and doctor --fix restored the previous last-good config, keeping the operator's new file only as openclaw.json.clobbered.<ts>, so the Gateway silently ran the old configuration. Missing meta alone is no longer clobber evidence, so the valid reseed is kept and the Gateway promotes it to last-good after starting. Size-drop and missing gateway.mode checks still trigger recovery, and every restore warning now names the preserved original and how to undo it.

Fixes #183641. Thanks @csabatatrai for the report.

(cherry picked from commit 159c14a)

Adapted for 2026.9.x: ported only the core removal of the missing-meta-vs-last-good reason (io.observe-suspicious.ts plus its two 9.x callers in io.observe-suspicious.ts and io.observe.ts dropping the hasMeta argument). The restore-warning wording change in io.observe-recovery.ts and the io.observe-promotion.ts / io.snapshot.promotion.test.ts parts are not ported; the Kubernetes doc paragraph omits the sentence about that warning. The 9.x test that asserted recovery from a meta-less config ("recovery uses canonical metadata fingerprints") is replaced by a regression that keeps the valid meta-less config.
RomneyDa added a commit that referenced this pull request Oct 26, 2026
…183703

Completes the #183703 backport (ade3949): a valid config without meta is no longer treated as clobbered, so the 'discarded clobbered environment' fixture now drops gateway.mode to stay clobbered against its healthy last-good backup. FRV 40403788884 normalCi agentic-cli.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doctor --fix restores the old config after a documented Kubernetes reseed (missing-meta-vs-last-good)

1 participant