Repository navigation
improve(doctor): reduce repeated state copies during update checks - #145577
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 12, 2026, 10:00 PM ET / September 13, 2026, 02:00 UTC (Revision 5). ClawSweeper reviewWhat this changesDoctor reuses its temporary shared-state database during health checks, avoiding redundant copies while retaining source-state protection. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful, distinct optimization with no actionable correctness or security findings. The previous data-model compatibility blocker does not apply: no persistent contract changes, and published-updater evidence is already supplied. Priority: P2 Review scores
Verification
How this fits togetherDoctor runs health and update-readiness checks against an isolated copy of OpenClaw’s shared state. The shared database reader supplies those checks with data, then Doctor closes private handles and removes the temporary files. flowchart TD
A[Doctor health checks] --> B[Snapshot operator state]
B --> C[Private database scope]
C --> D{Read targets active private database?}
D -->|Yes| E[Read private database directly]
D -->|No| F[Preserve source through snapshot]
E --> G[Return health findings]
F --> G
G --> H[Revoke scope and clean up]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +34, Tests +45. Total +79 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep one operator-state snapshot per isolated check scope, reuse its private database, and retain the existing read admission and cleanup owners. Do we have a high-confidence way to reproduce the issue? Yes, source inspection shows that current main snapshots fresh reads even after Doctor redirects them to its private database. The supplied registered-readiness evidence reports three snapshots before and one after; this review did not execute tests. Is this the best way to solve the issue? Yes. The exemption is limited to an active, explicitly owned disposable path and reuses existing read and cleanup machinery without introducing a competing storage implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 745ee6af3429. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
9cdebdc to
813671d
Compare
|
Rebased onto main at d093d65; head 813671de69b. Preserved upstream asynchronous private-state cleanup and retained disposable-reader scope. Focused Doctor lint and read-only state suites: 55 tests passed. Formatting and diff checks passed. |
|
@clawsweeper re-review Please reconcile the remaining Add data-model compatibility proof item with the published-updater evidence already accepted in the current review. At head The PR body records the actual published Please determine whether the remaining item is a false-positive data-model classification, or identify the specific changed persistent contract that still lacks proof. CI failures are being diagnosed separately; this request is review-only, not automerge. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: VACInc <[email protected]>
813671d to
5e002cd
Compare
…5577) Co-authored-by: VACInc <[email protected]>
|
#143802 merged to main with an agent schema-shape read optimization. This PR's reuse of Doctor's already-disposable shared-state lint database is complementary work; neither change supersedes the other. |
Summary
High Level TLDR
Doctor's post-plugin readiness check makes a private copy of shared state, then unnecessarily copies that private database again for subsequent reads. This change keeps those reads on the disposable database already owned by the check.
What Problem This Solves
Fixes an issue where update finalization performs redundant full shared-state copies during Doctor lint. The existing real-SQLite readiness scenario produces three snapshots: the original operator-state snapshot and two copies of that temporary database.
Root Cause
Doctor correctly wraps lint in artifact-preserving reads and creates a private plugin-state view. The shared read owner inherits the artifact-preserving context even after reads have been redirected to that disposable view, so fresh reads snapshot it again.
Why This Change Was Made
The shared read owner now recognizes an explicitly scoped disposable path. Doctor activates that scope only around its own private database. Native read-only handles, schema checks, and tracked handle cleanup remain with their existing owners. Other paths retain artifact-preserving reads, nested scopes remain independent, and inherited asynchronous contexts lose the exemption when their owner finishes.
No persistent schema, data representation, migration, configuration option, or cross-run cache changes. Installed update drivers remain unchanged; the optimization runs inside the candidate's existing Doctor lint path. Rollback needs no data conversion.
User Impact
A synthetic 206,671,872-byte shared database produces one full snapshot instead of three, avoiding 413,343,744 bytes of redundant copied output and two snapshot workers per exercised readiness pass. This is a bounded I/O optimization, not a claim to resolve all update latency.
Verification
Real behavior proof
The existing registered post-plugin readiness scenario runs real SQLite readers and snapshot workers. Its new assertion fails on the original code because two extra private paths are copied, and passes with this patch. It still reports the required missing local-embedding setup error, preserves the operator database family byte-for-byte, and never opens the operator database in the parent.
git diff --checkpassed.pnpm buildand the complete four-filecheck:changedgate passed, including core/core-test typechecks, dead-export scans, scoped lint, and storage/import guards.[email protected]updater × exact candidate9cdebdc907a1f629174bab85cfc0a3d4c43de329: passed using the repository's isolated Dockersqlite-volumescenario. The actual installed updater performed the npm update; the scenario preserved 4,800 sessions, 23,890 events, and 2,200 cron jobs, verified eight conversations across two agents before and after Gateway restart, and passed repeat Doctor idempotence in 18 seconds.Focused tests:
Published-driver cell (Node 24.19.0/Linux; candidate built and packaged with the canonical package helper):
Copied output:
Update receipt:
status=ok,mode=npm; published build2026.9.4-release-3a9d69db306c-2026-09-10T22-53-16.719Z→ candidate build2026.9.4-9cdebdc907a1-2026-09-12T03-42-19.063Z. Local Docker was used because hosted Package Acceptance accepts upstream-reachable refs, while this candidate is on the author fork. Its source-trust gate was preserved.Performance limits
One warm run showed a large timing difference, but the repeated comparison measured essentially identical warm medians: 0.970 s baseline and 0.977 s candidate. Disk/cache variability prevents a reliable percentage latency claim. Snapshot counts consistently fell from three to one; findings and operator-state bytes remained unchanged.
What was not tested
No production update, restart, or operator-state mutation was performed. No claim is made about total update duration or Windows/macOS performance.
Related: #143802 and #145541 avoid agent-database copies during schema/header inspection. This PR addresses repeated shared-state copies inside Doctor's already-isolated lint view.
The first ClawSweeper review found no actionable correctness/security defects and requested the published-updater evidence now recorded above.