Skip to content

fix: recover configured agents after deletion journal loss - #181804

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1865
Oct 23, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1865

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor repeatedly holds valid configured agent stores after deletion-journal reconstruction, and its suggested agents add recovery can hide the actual refusal behind “already exists.” A skipped Memory Core import can then stop unrelated repairs and update finalization.

Fixes #181765. Thanks @4140leal-cw for the detailed report.

User Impact

openclaw doctor --fix automatically restores configured stores whose database ownership and missing-journal provenance can be verified, even after an upgrade changed their producer stamp. It preserves a verified backup group first. Real deletion records, quarantined history, unconfigured stores, and mismatched owners retain their existing protections. Explicit recovery failures retain the owner's actionable diagnostic.

Deferred derived memory-index imports leave their sources intact and no longer prevent independent Doctor repairs. No new options, dependencies, or database schemas.

Why This Change Was Made

The restoration owner required an unchanged creation stamp from a fixed version/schema allowlist, which excluded stable 2026.10.5 / 2026.10.6 and upgraded stores. Configured physical ownership, matching database metadata, no deletion record, missing-table reconstruction provenance, and verified rollback backups provide the recovery decision instead. The existing agent-creation owner still performs restoration and releases only the selected holds.

The CLI discarded that owner's diagnostic for every already-exists result. Separately, Memory Core returned an unclassified migration warning after preserving a derived index, causing the Doctor runner to treat it as a refusal. The fix stays in those owners; generic data-risk refusals are unchanged.

Evidence

  • Red on the base: a populated schema-26 store stamped 2026.10.6 remained held; the CLI replaced a specific recovery refusal with “already exists”; a held Memory Core import returned no recoverable disposition.
  • Bun: all 45 focused tests pass across restoration, CLI diagnostics, the real plugin-migration runner, and injected Windows registry/reconstruction paths. The runner test verifies an independent QMD repair completes while the original sidecar, held agent database, and memory source remain byte-identical.
  • Node: 297 passing tests across the 20 selected direct/barrel consumer files; two inherited failures and 13 opt-in PostgreSQL skips. All 13 remaining consumer files passed after the first shard reported the inherited failures. The full-process lost-journal regression also passes, verifying an OK updater receipt, auth/session migration, and idempotent second Doctor run.
  • Core and touched-test tsgo, scoped core/test/extension oxlint, formatting, git diff --check, and Madge (0 cycles) pass. Full check:changed SQLite inventory was omitted under the lane's local gate budget; PR CI supplies broad proof.
  • Isolated live package CLI: built the reviewed source with node --import ./scripts/tsx.mjs scripts/build-all.mts cliStartup, then ran pnpm exec ./openclaw.mjs doctor --fix --non-interactive --no-workspace-suggestions against three synthetic schema-26 stores (main, ayudante, contador) and a missing journal. Exit 0, “Doctor complete,” all three restored, zero remaining holds, and all original sentinel values preserved. All four rollback databases passed integrity checks; the shared backup retains the original three holds. Windows path behavior is injected; the live CLI host is macOS.
  • The source-development launcher conservatively refused runtime publication on this host, so the live proof used a separately built snapshot and its package entrypoint. No operator Gateway was restarted. The synthetic external-volume fixture reported an unavailable optional whole-state copy and missing-model diagnostics; the restoration owner's verified per-database backup group succeeded.
  • Final isolated Codex review: scoped clean through P2.

Inherited Node failures reproduced separately on untouched base 95fecb2dafe4:

  • state-migrations.test.ts: “previews and repairs the released audit ledger before other state migrations” expects six preview lines, while the current schema supplies eight (heartbeat and workspace-baseline migrations).
  • agent-create.integration.test.ts: “stops delegated creation after authority closes during workspace-write preparation” reports missing native Darwin descriptor ACL inspection, followed by no such table: migration_sources.

The opt-in PostgreSQL file is skipped without its external fixture. The inherited large migration file uses about 174.7 seconds of test time; the new restoration regression takes about 3 seconds. The restoration file takes about 36.4 seconds of test time. The process regression takes 48.13 seconds of test time (81.07 seconds file wall time): it reuses the built runtime and exercises two real Doctor processes with three historical databases, preserving the existing cross-process recovery contract. No timeout or retry increases. Setup and compilation account for additional wall time.

Simplification: removed the version allowlist and the CLI's duplicate diagnostic rewrite; reused existing restoration, backup, and migration-result contracts. Production: +22/−47 lines; tests: +176/−75; docs: +7/−2.

Restore verified configured stores through the existing agent owner after missing-journal reconstruction, including stores stamped by later upgrades. Preserve explicit recovery diagnostics and keep retained derived memory-index warnings from blocking unrelated Doctor repairs.

Fixes #181765. Thanks @4140leal-cw for the detailed reproduction.
@clawsweeper

clawsweeper Bot commented Oct 23, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core commands Command implementations size: M labels Oct 23, 2026
@steipete
steipete marked this pull request as ready for review October 23, 2026 17:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-23T17:57:49.890369Z b27d368 Draft marked ready
ℹ️ 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR restores verified configured agents after deletion-journal loss, preserves recovery diagnostics, and lets deferred memory-index imports remain advisory.

Example: A configured main agent has a schema-26 database stamped 2026.10.6 and a missing-journal reconstruction hold.

  • Before: Doctor rejects automatic restoration because the producer stamp is outside its fixed allowlist.
  • After: Doctor verifies ownership and reconstruction provenance, preserves rollback backups, and restores the selected store.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused, useful implementation with meaningful recovery and preservation evidence; published-driver upgrade compatibility remains unproven.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Configured agents remain held after journal reconstruction, recovery guidance hides the refusal reason, and a deferred memory import blocks later repairs.
Reason: The official-release report establishes user value, and the maintainer-authored change explicitly owns the broader recovery direction.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR addresses a concrete recovery failure on an official release, and the pinned diff introduces no identified correctness defect.

Priority: P1
Reviewed head: b27d3687cbe4579dc7b34e044a8f4ab1fdaa4066

Before merge

  • 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

None.

Tests

  • Missing end-to-end proof: Supply a latest-stable published-updater-to-candidate recovery run preserving existing settings and data; the synthetic CLI run and historical process regression do not exercise that driver.
Agent review details

How this fits together

Doctor consumes configured database targets and deletion-recovery receipts, then delegates restoration to the existing agent owner before normal database and session migrations continue.

flowchart TD
  A[Doctor repair] --> B[Configured targets and recovery receipts]
  B --> C[Ownership and deletion checks]
  C --> D[Verified rollback backups]
  D --> E[Existing agent restoration owner]
  E --> F[Database and session migrations]
  F --> G[Plugin repairs and recorded warnings]
Loading

Technical review

Best possible solution:

Restore verified configured stores through the existing agent owner after verified backups, preserving explicit deletion holds and actionable refusal messages.

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

Current-main source deterministically excludes 2026.10.6 and rewritten producer stamps and discards the recovery owner's diagnostic; the PR reports matching base failures and an after-fix package CLI run.

Is this the best way to solve the issue?

The diff is a small complete repair using existing restoration, backup, and migration-result owners, with no parallel recovery machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Automatic restoration eligibility changes intended behavior with a stated reason (4c15811: The original repair limited automatic restoration to verified affected producer stamps and deliberately left rewritten stamps held.)
  • Reserved system-agent recovery keeps the original intent (f02658f: Reserved agents cannot be deleted, so verified canonical stores may recover independently of ordinary missing-journal eligibility.)
  • CLI recovery diagnostics changes intended behavior with a stated reason (2bf99df: Command-boundary state ownership routed noninteractive creation through the existing owner; its duplicate-error formatting concealed specific held-store refusals.)
  • Memory migration warning classification changes intended behavior with a stated reason (fec7692: Earlier recoverable-warning work preserved failed imports as blockers until their owner established safe deferral; this patch explains derived-index preservation and adds a runner-level preservation regression.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4c15811 adds src/commands/doctor-agent-deletion-journal-restore.ts:98 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4c15811faab4; files: src/commands/doctor-agent-deletion-journal-restore.ts)
  • Dallin Romney: Raw commit 7187a9a adds extensions/memory-core/src/migration/doctor-memory-sidecar.ts:508 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 7187a9afa71a; files: extensions/memory-core/src/migration/doctor-memory-sidecar.ts)

PR surface

Source -25, Tests +101, Docs +5. Total +81 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 22 47 -25
Tests 5 176 75 +101
Docs 1 7 2 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 205 124 +81

Review metrics

Metric Value Why it matters
Production versus test changes Production +22/-47; tests +176/-75 Production removes a restrictive allowlist and duplicate diagnostic rewriting; test growth covers recovery eligibility, preservation, independent repair continuation, and Windows receipt paths.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #181765
Summary: This PR directly addresses the reported recovery refusal and blocked derived-index migration.

Members:

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

Labels

Label changes:

  • add P1: The linked official-release report establishes blocked Doctor/update recovery and skipped maintenance for configured agents.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: The linked official-release report establishes blocked Doctor/update recovery and skipped maintenance for configured agents.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

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 23, 2026, 2:12 PM ET / 18:12 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Landing note: the only red check on head b27d368 is checks-node-changed-3, failing in src/infra/state-migrations.test.ts (expected 6 shared-schema migration descriptions, received 8). The same assertion fails identically on clean origin/main e96c704. It compares hard-coded expectations against runtime migration descriptions that predate this PR, and this PR doesn't touch that inventory. The failure is inherited, and a separate fix for main is in progress. Every other check is green, so this is a pinned squash merge of that exact head.

@steipete
steipete merged commit d75915e into main Oct 23, 2026
203 of 208 checks passed
@steipete
steipete deleted the upd/upd-l1865 branch October 23, 2026 18:25
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…penclaw#181804)

After an agent deletion journal was reconstructed, doctor --fix held every configured agent's store ('3 stores held back'), stopped later repairs, and suggested 'openclaw agents add', which is a no-op for existing agents. Doctor's restoration owner only accepted stores stamped by the current build, so upgraded stores could never be restored. It now restores configured agents' stores after verifying ownership and backups regardless of producer build stamp, the CLI preserves recovery diagnostics, and Memory Core retained-index warnings no longer stop later repairs. Mismatched owners, unconfigured agents and incomplete deletion records stay held. Fixes openclaw#181765, reported by @4140leal-cw.
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…181804)

After an agent deletion journal was reconstructed, doctor --fix held every configured agent's store ('3 stores held back'), stopped later repairs, and suggested 'openclaw agents add', which is a no-op for existing agents. Doctor's restoration owner only accepted stores stamped by the current build, so upgraded stores could never be restored. It now restores configured agents' stores after verifying ownership and backups regardless of producer build stamp, the CLI preserves recovery diagnostics, and Memory Core retained-index warnings no longer stop later repairs. Mismatched owners, unconfigured agents and incomplete deletion records stay held. Fixes #181765, reported by @4140leal-cw.

(cherry picked from commit d75915e)

Release adaptation: stable agents add still calls createAgent directly (no local-state-owner RPC), so only the already-exists message override was removed. Restore test cases were ported onto the stable fixture helpers; the memory sidecar case lives in a new trimmed state-migrations.plugin-doctor.memory.test.ts (the main file is not on stable).

Update behavior: the post-update Doctor now restores configured, ownership-verified agent stores after a reconstructed deletion journal instead of holding them and refusing the update finalization.
RomneyDa added a commit that referenced this pull request Oct 26, 2026
#181356 resolves an API-key-only ChatGPT catalog row to the Platform
contract, so the Codex PDF case seeds the OAuth login as main does.
#181923 lets the K3 policy name hosted-catalog K3.1 rows the bundled
manifest lacks. #181804 restores configured stores after journal loss,
so Doctor refuses the legacy schema instead of holding them; the test
takes main's expectations and its host-broker project (#181964). The
Control UI locale artifacts are regenerated for the dropped restart
summary string.
tideclaw-bot added a commit that referenced this pull request Nov 4, 2026
Adapt 21 audited fixes to release-native ownership and recovery.
Retain strict temporary environment isolation and provider-only cooldowns.

Original-source provenance and contributor credit:
#179144 5a97c90 — Peter Steinberger <[email protected]>
#180280 442c2f7 — Jason (Json) <[email protected]>
#178596 63f386b — Braden Guliano <[email protected]>
#181804 d75915e — Peter Steinberger <[email protected]>
#181140 b4031b2 — Peter Steinberger <[email protected]>
#182207 b8fae65 — Peter Steinberger <[email protected]>
#180792 d2c70dd — Peter Steinberger <[email protected]>
#179205 c08aa6d — Peter Steinberger <[email protected]>
#179997 f178dd9 — mali <[email protected]>
#181270 e204484 — Peter Steinberger <[email protected]>
#179031 855b0aa — Peter Steinberger <[email protected]>
#179726 3d51d00 — Peter Steinberger <[email protected]>
#179249 b617d97 — Josh Avant <[email protected]>
#182385 bb13bcd — Peter Steinberger <[email protected]>
#182615 411bac2 — Peter Steinberger <[email protected]>
#181300 765c2f1 — Peter Steinberger <[email protected]>
#179549 09ba994 — Peter Steinberger <[email protected]>
#179445 ac5587b — Peter Steinberger <[email protected]>
#181127 25dde25 — Josh Lehman <[email protected]>
#173209 ebccf57 — Peter Steinberger <[email protected]>
#175289 e579f09 — Peter Steinberger <[email protected]>

Proof: targeted owner/regression tests; Qwen15 and catalog pool13 pass.
Final integrated lint/type/format pass remains pending under user direction.

Co-authored-by: RomneyDa <[email protected]>
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 extensions: memory-core Extension: memory-core P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: agent stores stay held after 2026.10.6 - doctor --fix and update repair both refuse; agents add is a no-op

1 participant