Skip to content

fix(doctor): allow repair with retained deleted-agent sessions - #155752

Merged
steipete merged 2 commits into
mainfrom
codex/fix-doctor-orphan-family-targets-20260922
Sep 22, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-doctor-orphan-family-targets-20260922

Conversation

@steipete

@steipete steipete commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Doctor and update finalization failing when a deleted agent intentionally retains legacy session files.

User Impact

Doctor can finish repair without importing or changing the deleted agent’s retained history. Live shared-store history still requires a verified import, and unknown ownership, changed sources, and empty shared indexes retain their existing refusal rules. Automatic imports also preserve orphaned SQLite history instead of treating it as a fresh installation.

Why This Change Was Made

The existing deletion classifier now guides both automatic session discovery and startup readiness. Held owners stay in shared-source ownership checks, while only positively recorded retained ownership can waive an import receipt. Whole-file exemptions require an authored per-agent path; explicit store, agent, restore, and recovery behavior stays unchanged. No schema or configuration migration is added.

Related: e99e75e.

Evidence

  • The pre-fix checker fails both retained per-agent and mixed live/retired source regressions. The published 2026.9.5 control reached candidate Doctor after successful migration, preserved all retired bytes and links, and reproduced the final readiness refusal.
  • The authored patch passed 161 focused tests across 11 files, including shared-source custody, Gateway startup, active-survivor checks, and public Doctor refusal controls. Its six file postimages remain byte-identical after the mechanical merge checkpoint onto main.
  • Core types, the owning infra and commands-doctor test type graphs, scoped lint, formatting, whitespace, and native-schema guard pass. Independent P0–P2 review is clean.
  • Four new cases take 2.807 seconds combined on a four-core Linux Testbox; 2.706 seconds covers the real shared-store import, verified receipt, and deletion-custody contract. File wall times with --maxWorkers=1: targets 23.98 seconds (11 cases), retained-agent migration 37.48 seconds (8), deferred-plugin sources 74.40 seconds (35). Hosted CI reports the same four new cases at 2.799 seconds combined, including 2.702 seconds for the mixed-source import. These are reported case times, separate from command wall times.

The required refreshed-package check also passed on dbb4bad9 (tree d84ec7e0): the unmodified published 2026.9.5 updater ran first and completed in 47.717 seconds, then a fresh installed Doctor run exited successfully. Shared state reached schema 18, the active agent reached schema 23 with its session and two transcript events, and retained schema-21 database/legacy-file bytes, inodes, links, deletion journal, registry row, and sidecars remained unchanged. Comparing 12,694 package members confirmed that the canonical first-hop fixture changed only the three permitted version/inventory metadata members; product code and dependencies were unchanged. This covers the updater lifecycle changes inherited from main in isolated Linux/npm state, without a managed-service restart or model API calls.

CI Follow-Up

Refreshed CI run 35748106310 passed on dbb4bad9: 121 successful jobs, 16 skipped, no failures. The native review and exact-head ClawSweeper review are also clean.

The original CI run on 788b819c (35735766610) finished with 120 successful jobs, 16 skipped jobs, two failing test shards, and the failed aggregate gate. Both failing tests and their production owners were inherited unchanged from the main commit used by that CI run.

  • The memory candidate-repair case expected two completed reads within a one-second poll. Main now contains the canonical fixture repair in #155745 (5c9d100c), which synchronizes with the retrieval worker and verifies both reads complete before releasing the pending repair. This branch incorporates that main commit without another memory patch.
  • The Gateway config include-only audit case reported ConfigWritePostCommitError: the managed runtime environment generation changed during post-write validation, and the file was rolled back. One passive Linux/Node 24.19.0 observation replayed all 79 cases in the original order with unchanged assertions, deadlines, and production code. All passed in 213.79 seconds (217.14 seconds including the runner); the failing case took 2.231 seconds. Its trace showed no generation change before the write notification. This four-core replay does not reproduce the historical two-core CI failure or establish a fix. The writer's generation, approval, and rollback guards remain intact.

Use recorded deletion ownership during automatic session import and startup readiness. Retained owners remain part of shared-source ownership matching without demanding import receipts; live and unknown sources keep their existing integrity checks.

Preserve orphaned SQLite families when shared history is missing, while admitting fresh file-only imports. Explicit selection and recovery behavior stays unchanged.

Follow up on e99e75e.
@steipete steipete self-assigned this Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 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 commands Command implementations size: M maintainer Maintainer-authored PR labels Sep 22, 2026
@steipete
steipete marked this pull request as ready for review September 22, 2026 13:46
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 12:12 PM ET / 16:12 UTC (Revision 3).

ClawSweeper review

What this changes

Doctor and startup readiness recognize retained deleted-agent session history, while automatic imports preserve orphaned SQLite files.

Merge readiness

✅ Ready for maintainer review

This remains a useful repair: current main still rejects intentionally retained legacy sessions, and the reviewed patch has no identified blocking defects.

Priority: P1
Reviewed head: dbb4bad9372849fc46b9222af73dbf4639712938

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant upgrade observations, meaningful refusal coverage, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body reports exact-head installed Doctor success after the published updater exercised migration and final readiness in isolated Linux/npm state, with active history recovered and retained artifacts unchanged. Existing-state compatibility is supported by that preservation check; the patch adds no schema or stored-format change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports exact-head installed Doctor success after the published updater exercised migration and final readiness in isolated Linux/npm state, with active history recovered and retained artifacts unchanged. Existing-state compatibility is supported by that preservation check; the patch adds no schema or stored-format change.
Evidence reviewed 8 items Introduced change and review continuity: Reviewed the pinned merge-base-to-head changes. The three production files are unchanged from the earlier reviewed head 788b819; the prior review projection contains no findings. The supplied stale test merge was not used to infer merge behavior.
Repair remains necessary on main: Fetched main still requires an import receipt for retained legacy owners without consulting completed retained deletions. The PR adds that distinction while preserving source ownership and digest checks. No local release tag contains the authored fix commit.
Ownership and refusal controls: Only positively classified retained ownership waives receipts; unavailable deletion history does not. Shared sources retain record-level ownership matching. Regression coverage checks live-owner import requirements, changed-source refusal, unknown owners, empty shared indexes, retained bytes, and explicit hard-link refusals.
Findings None None.
Security None None.

How this fits together

Doctor migrates legacy session files into OpenClaw’s SQLite stores, and startup checks whether that migration is complete. Recorded agent deletions distinguish intentionally retained history from live history that still requires verified import.

flowchart TD
  A[Legacy session files] --> C[Doctor target discovery]
  B[Recorded deletions and owners] --> C
  C --> D[Import live history]
  C --> E[Preserve retained history]
  D --> F[Readiness checks]
  B --> F
  F --> G[Complete repair or report refusal]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +51, Tests +241. Total +292 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 83 32 +51
Tests 3 243 2 +241
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 326 34 +292

Review metrics

Metric Value Why it matters
Production versus regression coverage production +51 net lines; tests +241 net lines Production growth extends the existing admission owner; most growth exercises preservation and refusal contracts.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-session-sqlite-targets.ts, unknown-data-model-change: src/commands/doctor-session-sqlite-targets.ts, unknown-data-model-change: src/config/sessions/startup-migration.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Use the existing deletion owner consistently so retained history stays untouched and live history still requires verified migration.

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

Yes, from source: retain a deleted agent’s legacy session files and reach Doctor’s final readiness check; current main still demands their import receipt. The body reports matching failing controls, but this review did not execute them.

Is this the best way to solve the issue?

Yes. Reusing the existing deletion classifier repairs the readiness mismatch without introducing a second retention policy or weakening live-source verification.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Retained deleted-agent history can prevent Doctor repair and update finalization from completing.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body reports exact-head installed Doctor success after the published updater exercised migration and final readiness in isolated Linux/npm state, with active history recovered and retained artifacts unchanged. Existing-state compatibility is supported by that preservation check; the patch adds no schema or stored-format change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports exact-head installed Doctor success after the published updater exercised migration and final readiness in isolated Linux/npm state, with active history recovered and retained artifacts unchanged. Existing-state compatibility is supported by that preservation check; the patch adds no schema or stored-format change.

Evidence

What I checked:

  • Introduced change and review continuity: Reviewed the pinned merge-base-to-head changes. The three production files are unchanged from the earlier reviewed head 788b819; the prior review projection contains no findings. The supplied stale test merge was not used to infer merge behavior. (dbb4bad93728)
  • Repair remains necessary on main: Fetched main still requires an import receipt for retained legacy owners without consulting completed retained deletions. The PR adds that distinction while preserving source ownership and digest checks. No local release tag contains the authored fix commit. (src/config/sessions/startup-migration.ts:124, dd0003ac5c52)
  • Ownership and refusal controls: Only positively classified retained ownership waives receipts; unavailable deletion history does not. Shared sources retain record-level ownership matching. Regression coverage checks live-owner import requirements, changed-source refusal, unknown owners, empty shared indexes, retained bytes, and explicit hard-link refusals. (src/config/sessions/startup-migration.ts:115, dbb4bad93728)
  • Automatic discovery preserves unknown SQLite history: The existing matcher now accepts legacy database discovery and checks destination/shared-state SQLite families before admitting a file-only installation. Explicit store, agent, restore, and recovery selection retain their existing branches. (src/commands/doctor-session-sqlite-targets.ts:74, dbb4bad93728)
  • Exact-head published-driver upgrade evidence: The captured PR body reports the unmodified published 2026.9.5 updater completing against dbb4bad in 47.717 seconds, followed by successful installed Doctor execution. Active history migrated while retained schema-21 bytes, inodes, links, journal, registry row, and sidecars remained unchanged. Its package comparison covered 12,694 members and found only three permitted fixture metadata changes. This is reported isolated Linux/npm execution evidence, not a reviewer-run test; it does not claim managed-service restart coverage. (dbb4bad93728)
  • Hosted validation: GitHub confirms the refreshed CI run completed successfully on the exact reviewed head. The body reports 161 focused tests and separately records regression-case and file wall times. No target code or tests were executed during this read-only review. (dbb4bad93728)

Likely related people:

  • Peter Steinberger: Raw commit b068eab adds src/state/agent-deletion-discovery.ts:73 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b068eab40767; files: src/state/agent-deletion-discovery.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-22T13:53:58.938Z sha 788b819 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-22T15:40:39.386Z sha dbb4bad :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 22, 2026
@steipete
steipete merged commit f0abe21 into main Sep 22, 2026
205 checks passed
@steipete
steipete deleted the codex/fix-doctor-orphan-family-targets-20260922 branch September 22, 2026 16:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 22, 2026
* commit 'f3327bde3c6052a4ed6d487bb09fbe1e11c0cd35': (25 commits)
  fix(test): pass the fixture lifetime to launcher fixtures (#155825)
  fix(test): prepare history benchmark before child deadlines (#155780)
  refactor(config): derive tool contracts from schemas (#155484)
  chore(deps): update fs-safe to 0.18.1 (#155771)
  fix(doctor): allow repair with retained deleted-agent sessions (#155752)
  fix(setup): await inference probe cleanup (#155407)
  fix(mcp): recover expired SSE sessions and speed up parsing (#155497)
  fix(release): forward the stable soak waiver through the candidate helper (#155798)
  feat: calibrate Gateway plugin resources through retirement (#155792)
  fix: preserve the invoked launcher when restarting Node (#147621)
  fix(sessions): stop repeated failed worker exit cleanup (#154720)
  fix(ui): preserve active replies and tools after failed steering (#155746)
  fix(ci): retain missing-load-path baseline diagnostics (#154861)
  fix(gateway): keep session lists responsive during activity updates (#155767)
  fix: keep plugin queues bound to their selected session (#155714)
  chore(i18n): refresh native locales (#155571)
  fix(ci): wait for reset hook entry and join fixture cleanup (#155770)
  test: move subagent fixtures to module boundaries (#155727)
  fix(gateway): retain question requester authority through settlement (#155335)
  perf(gateway): move progress-card reads off the main thread (#153857)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…law#155752)

* fix(doctor): allow repair with retained deleted-agent sessions

Use recorded deletion ownership during automatic session import and startup readiness. Retained owners remain part of shared-source ownership matching without demanding import receipts; live and unknown sources keep their existing integrity checks.

Preserve orphaned SQLite families when shared history is missing, while admitting fresh file-only imports. Explicit selection and recovery behavior stays unchanged.

Follow up on 2a74f33.

* chore: sync main after canonical memory fixture repair

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant