Repository navigation
fix(doctor): avoid excessive work on large transcript histories - #147464
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: blocked before merge. Reviewed September 13, 2026, 6:11 PM ET / 22:11 UTC (Revision 2). ClawSweeper reviewWhat this changesDoctor’s SQLite transcript checks stop reading ineligible header histories earlier and skip unnecessary JSON decoding, with regression coverage for memory use and preserved history. Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful and has no actionable findings. The newly supplied published-updater proof resolves the previous review blocker; current main and the latest release still have the original detection behavior. Priority: P2 Review scores
Verification
How this fits togetherDoctor checks stored conversation transcripts during maintenance and update finalization. Its detection readers identify repair candidates, which existing guarded transactions revalidate before changing stored history. flowchart TD
A[Doctor or update finalization] --> B[Stored SQLite transcripts]
B --> C[Header and legacy label detection]
C --> D{Repair candidate?}
D -->|No| E[Leave history unchanged]
D -->|Yes| F[Complete exact snapshot]
F --> G[Revalidate and repair transaction]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +74. Total +111 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep detection cheap for ineligible histories while preserving complete snapshots, canonical validation, and existing transaction safeguards for actual repairs. Do we have a high-confidence way to reproduce the issue? Yes: current main buffers the remaining history when a valid first event precedes an existing header, and the supplied constrained-heap regression reports an original-code OOM. This review verified the source path without executing it. Is this the best way to solve the issue? Yes: reusing the existing validator for early rejection and conservatively filtering label-free JSON narrows detection work without introducing another repair owner or changing eligibility. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f6f241952b0e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper Please re-review the remaining data-model compatibility gate for this exact head. Your latest review accepts the published-updater proof and says the previous blocker is resolved, but its generated checklist still asks for that same proof. Upgrade compatibility was tested and verified for existing data. The installed Please reconcile the structured stored-data compatibility assessment and generated checklist with this accepted evidence. If any concrete compatibility case remains unproven, identify that case. No gate bypass, repair, or merge is requested. |
|
🦞👀 I queued a lightweight read-only assist pass. It will post a separate answer comment and will not edit the durable ClawSweeper review comment or trigger close, merge, repair, label, or branch changes. Request: Please re-review the remaining data-model compatibility gate for this exact head. Your latest review accepts the published-updater proof and says the previous blocker is resolved, but its generated checklist still asks for that same proof. Upgrade compatibility was tested and verified for existing data. The installed |
|
Merged via squash.
|
`openclaw doctor` and the update-time candidate Doctor no longer scan and retain whole transcript histories for ineligible headers, so large installs avoid stalling in Doctor on those histories. Shared validation rejects ineligible prefixes early; eligible repairs still retain complete exact snapshots and guarded writer revalidation. Label-free rows skip unnecessary decoding while Unicode-escaped candidates retain canonical handling. The constrained-heap regression fails on the original implementation with a heap OOM and passes on this head; all 39 reader, header, and label tests pass. Exact-head CI is green. Contributor-supplied published 2026.9.3 updater proof preserves existing history through candidate finalization, Doctor, and restart. Thanks @VACInc (openclaw#147464). Co-authored-by: VACInc <[email protected]>
Summary
High Level TLDR
Doctor can spend substantial time and memory examining large SQLite transcripts that cannot need repair. Stop header detection as soon as the existing validator rejects a prefix, and avoid JSON decoding rows that cannot contain a frozen legacy label.
What Problem This Solves
Fixes excessive Doctor work when an existing session header follows another transcript event, and unnecessary JSON decoding of label-free history during update finalization.
User Impact
Large existing histories require less detection time and memory. Repair eligibility, exact transcript bytes, guarded writes, derived projections, and Unicode label support remain unchanged. No configuration or schema migration is required.
Why This Change Was Made
Root Cause
The read-only header reader previously materialized every storage row before the existing validator rejected any later session header. A valid indexed first event followed by a header at row two therefore caused the entire remaining history to be retained needlessly. The new constrained-memory regression fails on the original implementation with a heap OOM.
Label detection also decoded every serialized event before discovering whether it contained any legacy label. Every frozen rewrite requires decoded
untrustedorUntrusted. A conservative raw-text check rejects only rows containing neither spelling nor any Unicode escape; escaped candidates still use the existing decoder and normalization rules.The header reader now streams through the same validator used by writer revalidation. Positive candidates still retain complete exact snapshots. No write transaction, binding check, authority, retention, or projection-update policy changes.
Evidence
Verification
[email protected]upgraded to the exact PR package, automatic migration/finalization passed before any standalone Doctor pass, and persisted history survived subsequent Doctor and Gateway restart.Real behavior proof
The constrained-memory regression uses the actual Doctor header owner with a valid event, an existing header, and a large payload tail. Original code exhausts the constrained heap; the candidate reports
{found: 0, repaired: 0}and leaves the database content hash unchanged. Positive repair tests also exercise the actual owner and session reader.Copied result:
5 passedin the reader shard and34 passedin the commands shard; both shards passed.A synthetic 676,098,048-byte SQLite fixture with 8,194 events was measured at the Doctor owner boundary using Node 24.19.0, fresh processes, one warmup per variant, and five interleaved measured samples. Header results were always zero repairs; fixture SHA-256 stayed
0879e89c13eae3e258cafba6e6ebde324f016a35f02625e7f523e6e971771b3a.These are isolated owner benchmarks, not full Doctor or deployment timings. The candidate is exact commit
b92319c442977a1336d4c7259637aadc5b104e57, compared with base98101871f29fcb29d65cb8d916089aa2f14ad64b. Header samples ranged 296.25–313.22 ms before and 4.86–5.43 ms after; label samples ranged 271.43–312.66 ms before and 107.41–116.70 ms after.Published-driver upgrade proof
Upgrade compatibility was tested and verified for existing data. Existing data was preserved through the published updater, candidate finalization, Doctor idempotence, and Gateway restart, as shown by the completed scenario below. No data migration is required by this patch.
Completed on an isolated Linux Docker runner using the repository's published upgrade-survivor
sqlite-volumescenario, with the baseline updater performing the upgrade (candidateInstallMode: updater,updateOutcome: success). The candidate package embeds commitb92319c442977a1336d4c7259637aadc5b104e57; its SHA-256 isbf7c6d56ecc195319607530d9ee6dbed426bde31fd8f9bcba9a4ee9d54208271.The run reused a Docker runner freshly built from this checkout's
scripts/e2e/Dockerfile(baretarget); artifact paths above are portable equivalents of the isolated test paths.Copied output:
Automatic migration and survival assertions passed immediately after the installed updater finished; this scenario intentionally omits an intervening standalone Doctor. History RPC, health/readiness, and persisted-state assertions then passed again after restart. The 17-second Doctor result is the synthetic fixture's idempotence pass, not a production performance claim.
What was not tested
No live production rollout or whole-Doctor performance comparison has been measured. The Docker proof uses the harness's manual restart mode; it does not claim a real host systemd restart or live channel delivery. This PR does not change startup integrity checks.
ClawSweeper review
The review at
b92319c442977a1336d4c7259637aadc5b104e57reports no actionable findings and accepts the published 2026.9.3 updater compatibility proof above. Its remaining generated “Add data-model compatibility proof” checklist item repeats that accepted evidence; no additional code change is needed. The existing upgrade proof covers automatic finalization, persisted history, Doctor idempotence, and restart. No re-review was requested during landing because the code is unchanged.Maintainer validation and release-note context
The header-after-event regression was independently rerun with all three production files restored to the pre-fix implementation: it failed with
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory(1 failed, 14 skipped). Restoring the reviewed head and running the reader, header, and label suites passed all 39 tests, including the constrained-heap case and unchanged history checks.openclaw doctorand the update-time candidate Doctor no longer scan and retain whole transcript histories for ineligible headers, so large installs avoid stalling in Doctor on those histories. Thanks @VACInc (#147464).