Repository navigation
fix(doctor): post-session plugin repair fails when a historical transcript is deferred - #160703
jayzhou2309 wants to merge 4 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesAllow verified plugin session-source settlement to finish while deferred historical transcripts remain protected. Example: Codex migration has verified retained sources alongside boot-2026-06-12_01-38-43-539-a2a5aeed.jsonl containing an unrecognized historical record.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still rejects deferred historical warnings during verified source settlement, and this focused repair preserves the existing safeguards. No actionable patch defect found; current-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor imports legacy session files into canonical SQLite storage, retains verified originals for pending plugins, then archives those originals before plugin migration completion. flowchart TD
A[Legacy session files] --> B[Doctor import and verification]
B --> C[Canonical SQLite sessions]
B --> D[Verified retained-source receipt]
D --> E[Post-session plugin settlement]
E --> F[Protected original archives]
E --> G[Plugin migration completion]
Technical reviewBest possible solution: Keep settlement tolerant of protected historical warnings while leaving receipt capture, source verification, and archival ownership unchanged. Do we have a high-confidence way to reproduce the issue? Current-main discovery produces historical_transcript_deferred, and settlement rejects that code despite its warning classification; supplied control runs and regression results corroborate the path, but this read-only review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair: distinguish settlement eligibility from receipt-capture eligibility and use the existing verification, archival, and retirement owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a3267d4b57e8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +219. Total +224 across 4 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (9 earlier review cycles; latest 8 shown)
Reviewed October 20, 2026, 5:47 AM ET / 09:47 UTC (Revision 10). |
1be4d9a to
7d835e5
Compare
7d835e5 to
99d5369
Compare
99d5369 to
b5d32c8
Compare
b5d32c8 to
025b16d
Compare
Co-authored-by: RomneyDa <[email protected]>
Integrate tested main 37e60af for the historical-header contract exercised by CI 39397926202. Preserve the contributor repair and all protected-original assertions. Co-authored-by: RomneyDa <[email protected]>
|
@clawsweeper re-review Current head: 94fc59b. Named CI fixture failure repaired without weakening historical-refusal or protected-original assertions. Pinned Bun and Node each pass all 13 affected cases. The 809 core-type diagnostics independently match the executed main baseline exactly; no rerun, suppression or green-CI claim. Body and proof are current; earlier CLI/updater scope remains explicit. |
|
🦞👀 Re-review progress:
|
…one (#178779) Fixes #167385. A hand-deleted sessions-delete archive made retained-source settlement fatal forever. Historical recovery warnings are now kept as warnings with an unavailable-history outcome, and verified plugin repair completes; surviving originals and deleted-session state stay protected. Supersedes #160703, thanks @jayzhou2309. Co-authored-by: Jay Zhou <[email protected]>
|
Thank you @jayzhou2309! We re-implemented this fix in #178779. It landed with you credited as co-author. Closing this one as superseded. |
…one (openclaw#178779) Fixes openclaw#167385. A hand-deleted sessions-delete archive made retained-source settlement fatal forever. Historical recovery warnings are now kept as warnings with an unavailable-history outcome, and verified plugin repair completes; surviving originals and deleted-session state stay protected. Supersedes openclaw#160703, thanks @jayzhou2309. Co-authored-by: Jay Zhou <[email protected]>
…one (#178779) Fixes #167385. A hand-deleted sessions-delete archive made retained-source settlement fatal forever. Historical recovery warnings are now kept as warnings with an unavailable-history outcome, and verified plugin repair completes; surviving originals and deleted-session state stay protected. Supersedes #160703, thanks @jayzhou2309. Co-authored-by: Jay Zhou <[email protected]> (cherry picked from commit 73f2bf2) Co-authored-by: RomneyDa <[email protected]>
…one (#178779) Fixes #167385. A hand-deleted sessions-delete archive made retained-source settlement fatal forever. Historical recovery warnings are now kept as warnings with an unavailable-history outcome, and verified plugin repair completes; surviving originals and deleted-session state stay protected. Supersedes #160703, thanks @jayzhou2309. Co-authored-by: Jay Zhou <[email protected]> (cherry picked from commit 73f2bf2) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 8b28b58)
Closes #153502
Original contribution: @jayzhou2309.
Work sessions
What Problem This Solves
Fixes: post-session plugin repair fails and leaves verified retained session sources unsettled when a session store also has a deferred historical transcript (
historical_transcript_deferred, including unrecognized historical records).User Impact
User impact:
openclaw doctor --fixandopenclaw update repairfinish the deferred plugin repair (such as Codex) for these stores instead of reportingretained_plugin_source_settlement_failed. The deferred historical original is still kept in a protected archive with its bytes unchanged.Why This Change Was Made
historical_transcript_deferredis a warning (src/infra/session-sqlite-migration-issues.ts), and the Doctor guide says retained historical conflicts do not block post-session plugin repair. ButsettleRetainedDoctorSessionSourcesgated onisRetainedSourceIssue, which does not list that code, so settlement threw on the first deferred historical transcript.The fix treats
historical_transcript_deferredas settleable insidesettleRetainedDoctorSessionSourcesonly. The sharedisRetainedSourceIssuepredicate is unchanged, because it also gates import-time source capture and receipt recording, and widening it there would change what goes into a receipt. Store archiving during settlement uses the same local predicate, matching the normal import path, which already archives a store that carries only warnings.Evidence
Exact-head CI follow-through (October 20, 09:57 UTC)
CI run 39402331678 completed on
94fc59b0172bd1f2aae373c7715fe0d07c19af5bwith a failed production-typecheck job (check-prod-types). All 809 ordered compiler diagnostics match the previously independently executed clean-main baseline37e60afc6d2ffb3dab5dee16a52f2aae2554d4ab; no additional compiler diagnostic differs. Main'ssrc/gateway/chat-display-replay.test-support.tsimports UI replay consumers into the Node-only core compiler graph, producing the same DOM/JSX diagnostics. No compiler-policy broadening, suppression, workflow rerun, or main-branch repair was used. This is attributed failed CI, not a green CI gate.The earlier
checks-node-changed-6historical-fixture failure is absent from this completed run: that shard passed after the fixture repair.The original contributor runs below are historical, at their stated heads; filename/header mismatches alone are now accepted by main #178146. Current integration and CI attribution are recorded in the CI follow-up below.
settles verified retained sources when a historical transcript stays deferredinsrc/commands/doctor-session-sqlite.retained-source-verification.test.ts. It records a verifiedcodexreceipt, adds a transcript whose header does not match its filename, and runs settlement. Onmain(test-only commit) it fails, 1 failed and 14 passed, with thePrimary transcript header does not match its original filenameerror thrown from settlement. With the fix, 15/15 pass. It asserts the retained sources are archived as protected with original bytes, the historical original sits in one protectedunreferenced-historyarchive with original bytes, and a rerun reports only the boot transcript'shistorical_transcript_deferredwarning. Before fix(doctor): retire deferred receipts and track migration backups #162771 the rerun reported 0 issues. Since fix(doctor): retire deferred receipts and track migration backups #162771, Doctor re-discovers archived historical transcripts after a retained source index rebuild, so the mismatched header stays a warning, and the test now expects exactly that one warning.06d2de9d9e8(main CI green). The test file passes 15/15 on the branch. With only the test commits on that main, the new case fails (1 failed, 14 passed): settlement rejects with the header-mismatch error.src/commands/doctor-session-sqlite*.test.tsfiles: 392 tests pass (rerun after rebasing onto0783e3f28d4). The helper now lives indoctor-session-sqlite-types.tsbesideisRetainedSourceIssue, sodoctor-session-sqlite.tsdoes not grow past the line-cap ratchet.pnpm test src/commands/doctor-session-sqlite.retained-source-verification.test.ts --maxWorkers=1on an Apple Silicon Mac: 24.7s Vitest duration warm (26.2s wall), 42.9s cold, 15 tests; the new case takes 989ms of that. CI for head 7d835e5df93 (run 36484133455, jobchecks-node-changed-compact-large-8, shardagentic-commands-doctor-sessions-cron): the file's 15 tests sum to 53.6s, and the new case to 2.3s. The new case adds no timers, sleeps, polling, Gateway or process boot, serial config, or worker pin. It reuses the file's existing fixtures.oxlint --deny-warningsandoxfmt --checkclean on changed files.pnpm tsgo:coreandpnpm tsgo:test:srcpass..agents/skills/autoreview(codex engine, branch mode againstmain): no actionable findings.openclaw doctor --fix --non-interactivefrom source on macOS, main 5c3d2ee against this branch at 7d835e5df93. The state was built on disk by the published[email protected]CLI (doctor --session-sqlite import, which records a verified codexplugin_migration_source_retainedreceipt). It has two codex transcripts with app-server sidecars, aboot-2026-06-12_...jsonlwhose header id does not match its filename, a pendingdeferred-plugin-migration:codexrow (inserted withsqlite3, the one non-CLI step), andsessions.jsonmoved aside as in the unit test. Identical twins were seeded in place, since receipts bind to path and inode.HOME,OPENCLAW_HOME,OPENCLAW_STATE_DIRandOPENCLAW_CONFIG_PATHpointed at a scratch dir.Plugin session repair did not settle: ... boot-2026-06-12_01-38-43-539-a2a5aeed.jsonl: Error: Primary transcript header does not match its original filename.thenDoctor stopped because a state migration refused to continue.The settlement manifest recordsretained_plugin_source_settlement_failedand codex stayspending.Deferred state migration completed for plugin "codex".thenDoctor complete.Codex endscompleted, and the manifest has nofailedAt. A seconddoctor --fixexits 0 with no session SQLite issues.protected/indexed-historical-primaryand the boot file asprotected/unreferenced-history(disposalretained). sha256 of each archive file matches the pre-repair original on both builds.doctor --fixthen exits 0 and settles, because the first run moved the sources before it threw. So the user-visible failure is that first run: exit 1,retained_plugin_source_settlement_failed, and every later Doctor repair skipped. The branch completes in one run.doctor --fixon this state exits 0 but does not reach settlement ("installed plugin has not confirmed"). This branch'sdoctor --fixrun after it then upgrades the state DB from schema 18 to 19 and completes codex with matching hashes. main run in the same order fails with the header-mismatch error.openclaw update repair --yes --no-restart(local fixture plugin viaplugins.load.paths) exits 0 on both builds and holds the plugin back ("Package convergence must wait until the updating parent releases its install records"). The follow-updoctor --fixit asks for reproduces the split: main exit 1 with the header error, branch exit 0 with the plugincompleted.node scripts/package-openclaw-for-docker.mjs --allow-unreleased-changelog, which passed its tarball integrity check (dist/build-info.jsoncommit b5d32c8927c). Two twins were installed from npm[email protected](c074824), each with its own npm prefix and scratch state, and both were seeded with the fixture above by the published CLI. On one twin, published 2026.9.7 ranopenclaw update --tag <candidate .tgz> --yes --no-restart, which exited 0 and printedOpenClaw updated to 2026.9.7 (from 2026.9.7)andAdmission: candidate (2026.9.7). After that,--versionreports(b5d32c8), andgrep -rl isSettleableIssuein the installeddistfinds 4 files where it found 0 before. The other twin stayed on 2026.9.7 as the control.codex, so on both twins the update's own Doctor pass left codexpending.openclaw plugins install @openclaw/codex(2026.9.7 from ClawHub) was run on both twins before Doctor.doctor --fix --non-interactiveexits 1 withPlugin session repair did not settle: ... Primary transcript header does not match its original filename.The manifest recordsretained_plugin_source_settlement_failed, and codex stayspending.Deferred state migration completed for plugin "codex".andDoctor complete.. Codex iscompleted, and the three originals are archived (protected/indexed-historical-primaryx2,protected/unreferenced-history, disposalretained), each with a sha256 that matches its pre-repair original. A rerun exits 0 and reports only the deferred boot warning.--no-restartwas used, and service management was skipped for the non-default state paths),update repairitself reaching settlement, the reporter's own operator state, and Linux or Windows.Additional missing-original coverage (#167385)
Related: #167385. Native deletion followed by removing its generated
.jsonl.deleted.*.zstalready settles on main; that canonical archive-copy case is distinct from a missing retainedsession-sqlite-import-archive/*.imported-*original. The canonical fix is #165854.The added storage-boundary regression creates historical duplicate claims through the real manifest producer, removes an import original, and invokes real Doctor import/settlement under its maintenance lock. It requires an actual retained plan and verifies the legacy index is archived, so a successful no-op cannot satisfy it. The missing original remains absent, its manifest claim stays retained, and the surviving copy keeps its bytes. Receipt capture and recovery/retention policy are unchanged.
692a4d02d3ce528cf460c744baf19899c17e7534: canonical deleted-copy case passes; missing import-original case fails at settlement withartifact is unexpectedly missing; original retained. The five relevant storage/settlement owner files are unchanged at the current task pince3f47b60a55d9302c70936c680319a039a68eed.025b16d167be42b3e6a2595558e08500ae73de5bplus the initial regression: 13/13 pass in secretless AWS, covering the new two-case file, retained-source verification, and both exact-content missing-source recovery cases. Cold three-file wrapper wall: 125.50s (126.35s outer); added cases: 3.879s and 1.136s.efce8fd766013610fb87db94bc89c5f96b965d29, directly on contributor head025b16d167be42b3e6a2595558e08500ae73de5b, with no production changes or rebase. The final isolated proof run exited 0; native isolated proof is not GitHub CI. Hosted CI seconds for this new file are not yet available.CI integration follow-up (39397926202)
The first updated-head CI run tested merge
7d09758e7a148546e1dfe264bde82c2c8a28b298(main37e60afc6d2ffb3dab5dee16a52f2aae2554d4abplus PR headefce8fd766013610fb87db94bc89c5f96b965d29). It exposed one stale regression fixture and an independently reproduced main-branch typecheck failure.fd566f2a968b27d1ba500c4127e3470f5f2aba76) now imports filename/header mismatches by header identity. The old fixture therefore no longer producedhistorical_transcript_deferred. The repair does not accept the weaker filename warning: it appends one unrecognized historical record, which registered import preserves but historical discovery refuses. The case still requires real settlement, exactly one protected retained historical archive, unchanged original bytes including the added record, and the warning on rerun.94fc59b0172bd1f2aae373c7715fe0d07c19af5bintegrates only that tested main for this named contract failure, preservingefce8fd…as first parent and contributor ancestry. Its delta against the tested merge is only three added/one removed lines in the existing regression. No production changes or recovery-policy changes.check-prod-typescore leaf is inherited from the exact tested main: both repaired merge and clean main37e60af…, using separate frozen installs, fail with the same 809 diagnostics. After normalizing only checkout-root paths, these match all 809 diagnostics in CI job118546397813. The root core project includes main’ssrc/gateway/chat-display-replay.test-support.ts(introduced bya2332caed768dab02dfa6586b478c8f89b819535); its Control UI consumer imports pull browser DOM/JSX into the Node-only compiler target. This PR does not change that helper, compiler configuration or dependencies. The gate remains failed; no CI rerun, suppression or type-policy broadening was used.Proof ran entirely in secretless AWS with no credential hydration. Completed test/compiler results were retained through two harness-only recovery steps (Corepack preparation after the merge changed its pin, then a diagnostic-comparison script syntax fix); the native validation run itself was nonzero for that script error. The remaining comparison, normal commit guard and export completed without replaying tests. This is focused isolated proof, not a green GitHub CI receipt or fresh CLI/updater/live-model proof.
Implementation and verification.
AI disclosure
An AI agent (Claude Code) found this issue, reproduced the defect with the failing test above, wrote the fix and the test, and ran these commands:
pnpm test src/commands/doctor-session-sqlite*.test.ts,npx oxlint --deny-warnings,npx oxfmt --check,pnpm tsgo:core,pnpm tsgo:test:src,.agents/skills/autoreview/scripts/autoreview --mode branch, and for the updater proofnode scripts/package-openclaw-for-docker.mjs,npm install -g [email protected],openclaw update --tag <tgz>,openclaw plugins install @openclaw/codex, andopenclaw doctor --fix --non-interactivein scratch state.Rebased 2026-10-17 onto main f4fd06c (head 025b16d). Main rewrote retained-source-verification.test.ts with shared helpers, so the new case is a top-level
itthat uses them, with the same assertions. The rerun-expectation commit had nothing left to add and was dropped. The commit ids and counts above are from the old head. With main's source and the new test, the file has 1 failed of 9. On 025b16d it passes 9/9, the doctor-session-sqlite tests pass (315 tests), andtsgo:core, oxfmt and oxlint pass. The real-CLI and updater evidence above ran on the old head. The source diff is the same.🤖 Written and posted by an AI agent (Claude Code) on behalf of @jayzhou2309.