Skip to content

fix(doctor): settle imported JSONL transcript leftovers - #154413

Merged
steipete merged 2 commits into
mainfrom
upd/doctor-unverified-jsonl-settlement
Sep 21, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/doctor-unverified-jsonl-settlement

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #154277. Thanks @cortanapham for the detailed report and verification.

What Problem This Solves

Fixes repeated doctor --fix refusal when old JSONL transcripts already imported into SQLite remain outside a later plugin-import receipt. Recovery previously reported no moves, and a clean agent could receive another agent's settlement failure.

User Impact

Doctor and session recovery verify those originals, import an appendable missing suffix when necessary, and archive verified bytes with the existing migration receipts. Current session settings and newer SQLite history stay authoritative. Conflicting identities or ordering remain protected and named; no options, dependencies, or schema changes are introduced.

Why This Change Was Made

The retained-import shortcut skipped uncaptured originals while a separate diagnostic blocked them. Settlement now uses the existing content verifier, importer, and archive publication owner. Advisory severity no longer authorizes index archival: an index stays live while an active original remains; interrupted and missing-source recovery retain their existing receipt semantics. Failures stay with the owning agent. Noninteractive GitHub-report handling also records why creation was skipped; existing --yes authorization remains supported.

Evidence

  • Reproduced the halt, zero-move recovery, and clean-agent path leak in an isolated three-agent June-layout fixture. The regression replay failed on the original code.
  • Testbox: all eight touched suites passed (301 tests, 2 existing platform skips), node scripts/check-changed.mjs passed, and the runtime build passed. Validation lease, tbx_01m30xxn72g5v03xypjxz1e5zd.
  • New regression file: 5/5 standalone, --maxWorkers=1, 22.066s wall / 4.775s test execution. Changed retained-source and Doctor-command files took 11.551s and 0.050s test time in the full run. The existing large migration suite took 180.8s (previously 189.5s); its performance work belongs to C3/improve(test): reduce Doctor SQLite test time #153929.
  • Mac packaged CLI: doctor --fix --yes --non-interactive reached “Doctor complete.” A separate doctor --session-sqlite recover --session-sqlite-all-agents --json --yes --non-interactive exited 0, verified six events, and archived two leftovers. Read-only SQLite and receipt checks proved unchanged events, byte-identical archives, and no cross-agent failure on the clean third agent. All state, config, plugins, and ports were synthetic and isolated.
  • Published-driver cell: published 2026.9.2 updated to the candidate package in 33.363s; the update itself settled both leftovers before standalone Doctor (5.726s, exit 0). No Gateway was started. The frozen package SHA-256 is 4e2677d12b6db158ebff3a9be939c2f4d6c0e7df38fdd56dde56260a1178e9fa.
  • Fresh P1 review: no actionable findings. No schemas, options, dependency versions, baselines, or new suppressions changed.

The six sibling regressions found during development are resolved: referenced indexes remain live after failed publication; interrupted publication and disappeared-source recovery retain their original receipt semantics; recovery JSON keeps its optional-field shape; header-only known sessions settle; unsupported fragments remain protected. Early live fixtures were corrected to keep the plugin inventory stable and bundled Doctor modules available; the successful runs above use fresh state.

Production +400/-153 LOC; tests +322/-34; docs +14/-3. The only extraction is the existing archive-path planners; verifier, importer, publication, and recovery receipts retain their existing owners.

CI ownership registration follow-up

The red planner check on d433787d475 was reproduced: active-settlement fell through to the generic Doctor-session owner, producing 27 files against its explicit 26-file inventory. It is now registered by name in resolveCommandShardName under the existing agentic-commands-doctor-sessions-cron-sqlite-recovery owner alongside receipt recovery and missing-index verification. The test names the file in that owner and retains complete, duplicate-free coverage and isolation checks.

Testbox tbx_01m31s3d3zj462x3zx3fytvfyp: all 119 planner tests passed (81.48s Vitest wall / 75.614s test time), the original Doctor set passed 301 tests with 2 existing platform skips, and scoped check:changed passed. The planner file exercises complete repository inventories and supported compact-plan profiles; no cases, assertions, or budgets were weakened. P1 review had no actionable findings.

Interdiff from d433787d475: CI planner +1/-0 line, planner test +1/-0 line; src/** unchanged. Head 27ee0591f7be88283723361ae098e310b678eee3; CI run is attached. Auto-merge remains disabled for lead review; this update does not land the PR.

@clawsweeper

clawsweeper Bot commented Sep 21, 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 commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 7:28 AM ET / 11:28 UTC (Revision 4).

ClawSweeper review

What this changes

Doctor verifies and archives leftover JSONL conversation files, safely imports missing trailing history, keeps failures scoped to each agent, and explains skipped noninteractive issue reporting.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful repair absent from inspected main. No actionable introduced defect was found, and the recorded updater evidence addresses the previous upgrade-proof request.

Priority: P0
Reviewed head: 27ee0591f7be88283723361ae098e310b678eee3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression coverage and recorded runtime and upgrade evidence; no blocking defect remains in this review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded packaged-CLI runs exercise Doctor import and recovery on isolated legacy state, showing verified archival, unchanged history and agent isolation; the published 2026.9.2 updater cell addresses upgrade compatibility. Runtime code is unchanged since that evidence. Independent Testbox log inspection was blocked by the storage-host allowlist.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded packaged-CLI runs exercise Doctor import and recovery on isolated legacy state, showing verified archival, unchanged history and agent isolation; the published 2026.9.2 updater cell addresses upgrade compatibility. Runtime code is unchanged since that evidence. Independent Testbox log inspection was blocked by the storage-host allowlist.
Evidence reviewed 9 items Pinned scope and review continuity: The introduced delta was inspected from fd578cb to the pinned head. Comparison with the previous reviewed head d433787 shows only the CI owner registration and matching planner assertion; runtime source is unchanged. The supplied stale test merge was not used to infer removal of main behavior.
Current-main necessity: Inspected main still builds exclusions from retained receipt sources without the new active-transcript settlement path, and still propagates the first settlement issue across owners. No merged replacement was established. The linked report identifies the failure on released 2026.9.5; independent release-blob retrieval failed, so no shipped-fix claim is made.
Conservative settlement boundary: The new owner validates source identity, checks ordered canonical events, rejects conflicting IDs or missing middle history, uses historical-only import, verifies again, and supplies fingerprints to the existing archive publication owner. The importer preserves existing session nodes and validates window ownership.
Findings None None.
Security None None.

How this fits together

Doctor repairs OpenClaw’s stored session history during maintenance and updates. It compares legacy conversation files with each agent’s SQLite database, then records verified archival or a specific recovery finding.

flowchart TD
  A[Doctor or update recovery] --> B[Find leftover conversation files]
  B --> C[Compare identity and ordered history]
  D[Agent SQLite database] --> C
  C --> E[Import safe missing suffix]
  E --> C
  C --> F[Archive verified original with receipt]
  C --> G[Retain conflicting original and report]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +247, Tests +289, Docs +11, Other +1. Total +548 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 9 400 153 +247
Tests 4 323 34 +289
Docs 1 14 3 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 15 738 190 +548

Review metrics

Metric Value Why it matters
Production versus regression growth Production/tooling net +248 lines; tests net +289 lines Production growth implements conservative settlement while retaining the existing import and archive owners.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-session-sqlite-active.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-archive.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-diagnostics.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-recover-report.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-verification.ts, migration/backfill/repair: src/commands/doctor-session-sqlite.ts, and 8 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #154277
Summary: This PR is the explicit implementation candidate for the reported leftover-transcript recovery failure.

Members:

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

Technical review

Best possible solution:

Keep settlement within Doctor’s existing verifier, importer and receipt owners, preserving current session settings and retaining any original whose history cannot be safely verified.

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

Yes, from source: imported JSONL files outside a later retained-source receipt reach the active-file diagnostic without a settlement path on inspected main. The contributor also records a failing original-code replay; this reviewer did not execute it.

Is this the best way to solve the issue?

Yes. Extending the existing content verifier and historical-only importer avoids count-only archival, stale metadata replay, and a competing recovery mechanism.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P0: The linked released-version failure blocks supported update recovery and includes a Gateway outage requiring manual intervention.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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): Recorded packaged-CLI runs exercise Doctor import and recovery on isolated legacy state, showing verified archival, unchanged history and agent isolation; the published 2026.9.2 updater cell addresses upgrade compatibility. Runtime code is unchanged since that evidence. Independent Testbox log inspection was blocked by the storage-host allowlist.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded packaged-CLI runs exercise Doctor import and recovery on isolated legacy state, showing verified archival, unchanged history and agent isolation; the published 2026.9.2 updater cell addresses upgrade compatibility. Runtime code is unchanged since that evidence. Independent Testbox log inspection was blocked by the storage-host allowlist.

Evidence

What I checked:

  • Pinned scope and review continuity: The introduced delta was inspected from fd578cb to the pinned head. Comparison with the previous reviewed head d433787 shows only the CI owner registration and matching planner assertion; runtime source is unchanged. The supplied stale test merge was not used to infer removal of main behavior. (scripts/lib/ci-node-test-plan.mts:1315, 27ee0591f7be)
  • Current-main necessity: Inspected main still builds exclusions from retained receipt sources without the new active-transcript settlement path, and still propagates the first settlement issue across owners. No merged replacement was established. The linked report identifies the failure on released 2026.9.5; independent release-blob retrieval failed, so no shipped-fix claim is made. (src/commands/doctor-session-sqlite.ts:831, 2cc189c8735f)
  • Conservative settlement boundary: The new owner validates source identity, checks ordered canonical events, rejects conflicting IDs or missing middle history, uses historical-only import, verifies again, and supplies fingerprints to the existing archive publication owner. The importer preserves existing session nodes and validates window ownership. (src/commands/doctor-session-sqlite-active.ts:44, 27ee0591f7be)
  • Publication and authorization safeguards: Destructive CLI modes remain inside the existing exclusive maintenance lock. Archive publication retains descriptor identity, content-hash, link-count and durable-publication checks. GitHub issue creation still requires explicit --yes or interactive approval; the change prevents prompting when input is unavailable. No new principal, permission, dependency, or execution source is introduced. (src/commands/doctor.ts:191, 27ee0591f7be)
  • Behavioral regression coverage: The five new cases exercise import and recovery, unchanged session metadata, byte-identical archives, newer SQLite history, missing suffixes, conflicting content, missing middle events, and clean-agent isolation. The captured body reports a failing original-code replay, 301 passing Doctor tests with two existing skips, and 119 passing planner tests. Tests were inspected rather than executed in this read-only review. (src/commands/doctor-session-sqlite.active-settlement.test.ts:144, 27ee0591f7be)
  • Runtime and upgrade evidence resolves prior request: Captured context revision 9da1ccc61579d5551f4a9c972d9e38dd484f3e3baa0b24ddc1ca3d93657edc6a records packaged macOS Doctor completion and separate recovery exit 0, six verified events, two archived leftovers, unchanged SQLite events, byte-identical archives, and clean-agent isolation. It also records published 2026.9.2 updating to the candidate in 33.363 seconds and settling both leftovers before standalone Doctor. The candidate package hash is recorded in the body. The linked Testbox lease https://github.com/openclaw/openclaw/actions/runs/35555916540 has a cancelled workflow conclusion; that is not treated as an execution PASS. Its log redirects to a blocked storage host, limiting independent log inspection without invalidating the detailed recorded runtime observations.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-21T04:35:24.803Z sha 36a9f2f :: blocked before merge. :: none
  • reviewed 2026-09-21T04:47:03.216Z sha 36a9f2f :: blocked before merge. :: none
  • reviewed 2026-09-21T08:48:34.301Z sha d433787 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review September 21, 2026 04:40
@steipete
steipete enabled auto-merge (squash) September 21, 2026 04:56
Verify leftover active JSONL contents against the owning SQLite session, import only an appendable suffix, and archive originals with existing recovery receipts. Preserve current session metadata, partial-publication recovery, and per-agent diagnostics.\n\nFixes #154277. Thanks @cortanapham for the report.
@steipete
steipete force-pushed the upd/doctor-unverified-jsonl-settlement branch from 36a9f2f to d433787 Compare September 21, 2026 08:39
@steipete
steipete disabled auto-merge September 21, 2026 10:36
Route active-settlement through the existing SQLite recovery owner instead of the generic Doctor session fallback. Keep the planner regression explicit about the owning shard and exact filename.

Refs #154413. No Doctor runtime changes relative to d433787.
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 21, 2026
@steipete
steipete enabled auto-merge (squash) September 21, 2026 11:20
@steipete
steipete merged commit 383fdbd into main Sep 21, 2026
219 checks passed
@steipete
steipete deleted the upd/doctor-unverified-jsonl-settlement branch September 21, 2026 11:36
vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit '0883394977d1fb3af657635967f6e447bd7fff9a': (72 commits)
  fix(ui): await scheduled rail layout in focus test
  fix(cron): keep healthy active runs from delaying job lists (#154421)
  fix(plugins): prevent config conflicts during legacy plugin installation (#154539)
  perf(gateway): reduce repeated session-list work (#154551)
  fix(tasks): retain admitted work across list retries (#154338)
  perf(gateway): speed up transcript artifact downloads (#154726)
  chore(ui): refresh control ui locales (#154580)
  fix(release): keep two extended-stable months eligible (#154777)
  fix(tests): avoid avatar descriptor reuse race (#154747)
  perf(plugins): reduce callback scope overhead (#154625)
  fix(ui): include final request time in completed work summaries (#149240)
  fix(ai): avoid retrying conflicting Responses terminal statuses (#149242)
  fix: identify malformed Code Mode JavaScript as input errors (#149222)
  fix(doctor): settle imported JSONL transcript leftovers (#154413)
  fix(cloud): restore node bootstrap with bundled browser runtime (#154654)
  test(ui): await publication state notifications (#154768)
  fix(plugins): keep unchanged plugins running across metadata refreshes (#151281)
  fix: keep chat panel accessibility targets within each pane (#153478)
  fix: forced Gateway restarts cancel healthy subagent work (#154300)
  improve: reduce session delivery reader imports (#154740)
  ...
steipete added a commit that referenced this pull request Sep 22, 2026
Coalesce trusted identical archive claims through the recovery journal, redirect retained migration manifests without losing import acknowledgments, and preserve session warnings through Doctor and the installed updater. Recover uses the same settlement for historical-only stores.

Fixes #155095. Related: #154413. Thanks @fozzels-assistant for the detailed report.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
)

* fix(doctor): settle imported JSONL transcript leftovers

Verify leftover active JSONL contents against the owning SQLite session, import only an appendable suffix, and archive originals with existing recovery receipts. Preserve current session metadata, partial-publication recovery, and per-agent diagnostics.\n\nFixes openclaw#154277. Thanks @cortanapham for the report.

* fix(ci): register Doctor settlement tests under SQLite recovery

Route active-settlement through the existing SQLite recovery owner instead of the generic Doctor session fallback. Keep the planner regression explicit about the owning shard and exact filename.

Refs openclaw#154413. No Doctor runtime changes relative to d433787.
steipete added a commit that referenced this pull request Sep 22, 2026
…155194)

* fix(doctor): settle byte-identical duplicate session import archives

Coalesce trusted identical archive claims through the recovery journal, redirect retained migration manifests without losing import acknowledgments, and preserve session warnings through Doctor and the installed updater. Recover uses the same settlement for historical-only stores.

Fixes #155095. Related: #154413. Thanks @fozzels-assistant for the detailed report.

* fix(ci): register session archive recovery owner
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…penclaw#155194)

* fix(doctor): settle byte-identical duplicate session import archives

Coalesce trusted identical archive claims through the recovery journal, redirect retained migration manifests without losing import acknowledgments, and preserve session warnings through Doctor and the installed updater. Recover uses the same settlement for historical-only stores.

Fixes openclaw#155095. Related: openclaw#154413. Thanks @fozzels-assistant for the detailed report.

* fix(ci): register session archive recovery owner
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 maintainer Maintainer-authored PR P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant