Skip to content

fix(doctor): release stores held by dead agent-database leases and report holds in --json - #186535

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1925
Oct 28, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1925

Conversation

@steipete

@steipete steipete commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor's text output reports agent stores held after deletion-journal reconstruction, but doctor --json omitted the holds and their recovery actions.

Fixes #185843. Thanks @4140leal-cw for the stopped-Gateway reproduction and follow-up table counts.

User Impact

Read-only JSON and lint now identify each held store, its reason code, and its next step. Holds remain warnings; ownership verification and backups still gate restoration. Dead-holder lease reclamation is unchanged and already works on main. No schema, dependency, configuration, or CLI-option changes.

Why This Change Was Made

The original PR added a standalone lint check that repeated full database preflight outside the updater's inspection budget. That registration and its preflight/reconstruction path have been deleted. The existing core/doctor/state-schema check now consumes deletion-owner facts through the same shared-state read callback and prepared snapshot it already uses. Recorded holds come from the reconstruction receipt; unavailable history also reports the existing registry identities. Lint does not discover or open agent stores, reconstruct history, or add a check.

Evidence

  • The five CI failures at afebd94596b6 reproduced in both files on Bun and Node. Both files now pass 26/26 tests on each runtime, with every original check-count, deferral, required-gate, and elapsed-budget assertion unchanged. Commands: OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs src/commands/doctor-lint.test.ts src/commands/doctor-lint.update-budget.test.ts --maxWorkers=1, then the same command with OPENCLAW_VITEST_RUNTIME=node.
  • The JSON regression asserts zero calls to prepareDoctorDatabasePreflight, while still requiring the held store's path, agent, reason code, and next step. It also selects a different ambient profile to verify the explicit source profile remains authoritative.
  • Live Bun CLI with isolated HOME/OPENCLAW_STATE_DIR, three registered stores, eight dead-holder leases, and missing history: pnpm openclaw doctor --non-interactive --json exits 0, reports 3 per-store hold findings, and runs 41 checks, restoring the pre-PR count from 42. All six source config/database files remain byte-identical.
  • Updater-style CLI: OPENCLAW_UPDATE_IN_PROGRESS=1 pnpm openclaw doctor --lint --severity-min error --only core/doctor/state-schema --json exits 0, runs the single existing selected check, and retains all 3 coded hold advisories in warnings.
  • Earlier isolated baseline proof remains applicable to unchanged lease/restoration owners: the exact three-database/eight-dead-lease/empty-journal/empty-provenance fixture repairs with exit 0, zero remaining leases and no holds. Missing-history repair restores all three stores after verified shared-state/agent backups. No real package swap or Windows runtime was executed.
  • Six touched suites pass 57 tests on Bun (298.48 s wall time). The remaining direct-importer suites pass 221 tests on Node (116.92 s wall time; 10 opt-in/platform tests skipped). The modified restoration suite has 12 cases and approximately 48 s of test time; it proves released-schema restoration and verified backups. The unchanged deletion-journal suite took 140.38 s of test time on this shared host; no individual test exceeded 30 s, and no timeouts, retries, skips, or assertions were weakened.
  • Core and Doctor-test tsgo, targeted production/test oxlint, formatting, git diff --check, and madge (0 cycles) pass. The full check:changed SQLite inventory was omitted under the campaign's local gate budget; PR CI supplies broad proof.
  • Final staged isolated Codex autoreview at P0–P2: scoped-clean, no actionable findings. The review confirmed snapshot reuse, unchanged registration count, no preflight/reconstruction, profile ownership, older-schema behavior, and advisory updater reporting.
  • Simplification against the PR base: production +47/-2 (net +45, previously +46); tests +65/-7 (net +58); docs +9. The separate check, global-selector scope adapter, recovery-result wrapper, and duplicate discovery path are removed. The existing restoration fixture retains the three-store/eight-dead-lease coverage.

Expose recovery-owner warnings with reason codes and next steps in read-only Doctor findings, scoped to the requested profile. Preserve existing dead-holder lease reclamation, verified backups, and unresolved ownership holds.

Fixes #185843. Thanks @4140leal-cw for the stopped-Gateway reproduction and follow-up diagnostics.
@clawsweeper

clawsweeper Bot commented Oct 28, 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 commands Command implementations size: S labels Oct 28, 2026
@steipete
steipete marked this pull request as ready for review October 28, 2026 04:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T05:26:25.195775Z 621eb17 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.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR exposes agent deletion-journal recovery warnings in Doctor JSON and lint reports with reason codes and recovery guidance.

Example: The deletion journal is missing while stores for main, contador, and ayudante remain present.

  • Before: Text Doctor reports three held stores, but JSON contains no deletion-journal findings.
  • After: JSON reports five recovery advisories with reason codes and next steps; updater lint at error severity retains them as nonblocking warnings.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful patch with recorded CLI behavior and meaningful integration regressions; this read-only review found no introduced defect and did not independently rerun verification.
Proof confidence 🐚 platinum hermit (4/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; its body nevertheless records isolated Doctor JSON, updater-threshold, profile-scope, source-byte preservation, and subsequent repair results through the shipped CLI.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Tools reading Doctor JSON cannot see held agent stores or their recovery actions even though text Doctor reports them.
Reason: The maintainer-authored direction closes a demonstrated diagnostic gap through existing owners without adding settings or changing recovery authority.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a concrete JSON diagnostic omission still present on main, preserves existing recovery safeguards, and has no actionable findings from this review.

Priority: P2
Reviewed head: afebd94596b67a3187dc82d5ef795e2ede2002bf

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor inspects configuration and database inventory, passes those facts to the existing deletion-journal recovery owner in preview mode, and serializes its diagnostics through the lint findings pipeline.

flowchart TD
  A[Doctor CLI] --> B[Read-only inspection scope]
  B --> C[Database preflight]
  C --> D[Deletion-journal recovery owner]
  D --> E[Structured health findings]
  E --> F[JSON and lint output]
Loading

Technical review

Best possible solution:

Expose recovery-owner diagnostics through the existing read-only findings pipeline while preserving lease reclamation, verified backups, and ownership holds.

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

Current-main source establishes the omitted JSON path, corroborated by the reporter's text/JSON comparison and the PR's recorded isolated CLI reproduction; no target code was executed in this review.

Is this the best way to solve the issue?

The patch is a focused fix: one recovery owner supplies text and structured diagnostics, existing profile scoping is reused, and no competing lease or recovery policy is introduced.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Deletion-history holds and recovery diagnostics keeps the original intent (c6b21f6: Preserve unverified stores when deletion history is lost and provide explicit recovery guidance.)
  • Verified ownership configuration keeps the original intent (88d8a4c: Prevent reconstruction from an incomplete inventory derived from malformed or unverified configuration.)
  • Configured-store restoration keeps the original intent (d75915e: Restore configured stores after ownership and backup verification while retaining mismatched, unconfigured, and incomplete-history holds.)
  • Read-only Doctor inspection keeps the original intent (3be8851: Keep lint and bare JSON from migrating or altering existing SQLite artifacts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c6b21f6 adds src/commands/doctor-agent-deletion-journal.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c6b21f6f086a; files: src/commands/doctor-agent-deletion-journal.ts)
  • Vincent Koc: Raw commit 470ba96 adds src/commands/doctor-lint-runner.ts:308 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 470ba9649aaa; files: src/commands/doctor-lint-runner.ts)

PR surface

Source +46, Tests +57, Docs +9. Total +112 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 63 17 +46
Tests 1 66 9 +57
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 138 26 +112

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +63/-17; tests +66/-9 Growth supplies structured diagnostics through the existing owner and extends an existing fixture for profile scope, JSON transport, and reported dead-lease conditions.

Labels

Label changes:

  • add P2: Missing structured recovery diagnostics hinder Doctor tooling, but this patch does not establish a new runtime outage or change recovery eligibility.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Missing structured recovery diagnostics hinder Doctor tooling, but this patch does not establish a new runtime outage or change recovery eligibility.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 28, 2026, 12:58 AM ET / 04:58 UTC.

Remove the standalone recovery check and its duplicate full preflight. Report recorded holds and unavailable deletion history through the existing shared-state health check and prepared snapshot, preserving updater check counts and budget gates.

Keep the original CI assertions unchanged and prove JSON lint makes zero full-preflight calls. Related: #185843.
@steipete
steipete merged commit adfb544 into main Oct 28, 2026
118 of 119 checks passed
@steipete
steipete deleted the upd/upd-l1925 branch October 28, 2026 05:33
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
Doctor printed agent stores held after deletion-journal reconstruction only in text mode; doctor --json and update lint omitted them. The shared-state lint check now reports each held store as a core/doctor/agent-deletion-journal warning with a reason code and fix hint, reusing its existing read-only snapshot. Dead-holder agent database leases already recover on main. Refs openclaw#185843. Thanks @4140leal-cw.
vincentkoc added a commit that referenced this pull request Oct 29, 2026
* commit '04681a3efcb110ecf073fb610eed6e4ea4f87fed':
  fix(memory): avoid redundant repairs and heavyweight read imports (#186483)
  fix(doctor): report held agent stores in doctor --json (#186535)
  fix(ci): complete maintained script and export discovery (#186466)
  perf(control-ui): restore the Details panel from the cached pane in one step (#185242)
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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

[Bug]: doctor still holds configured agent stores when agent_deletion_journal is empty (10.7 / #181804 does not cover it)

1 participant