Repository navigation
improve: speed up Doctor checks for absent plugin state - #146926
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:57 AM ET / 10:57 UTC (Revision 2). ClawSweeper reviewWhat this changesDoctor avoids loading unnecessary storage code for plugin checks, while Memory Host loads its storage implementation only when reading or writing events. Merge readiness⛔ Blocked before merge - 3 items remain The optimization remains useful on current main, and no introduced correctness defect was found. The maintainer-owned PR is not a cleanup-close candidate. Priority: P2 Review scores
Verification
How this fits togetherDoctor inspects plugin state and delegates repairs to plugin-owned migrations. These changes reduce dependencies loaded during inspection while retaining the existing SQLite storage and recovery owners. flowchart TD
A[Doctor state checks] --> B[Crabbox migration context]
A --> C{Voice Call store exists?}
B --> D[Existing plugin storage]
C -->|No| E[Empty result]
C -->|Yes| F[Existing detection and repair]
F --> D
G[Memory event reads and writes] --> H[Load storage on demand]
H --> D
Before merge
Agent review detailsSecurityNone. PR surfaceSource +45, Tests +37. Total +82 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the lightweight shared record policy and existing migration/storage owners, with published-updater compatibility established before landing. Do we have a high-confidence way to reproduce the issue? Yes for the unnecessary-loading mechanism: current-main source reaches the identified imports during otherwise empty checks. The local timing comparison is contributor-reported; this review did not execute it. Is this the best way to solve the issue? Yes. Reusing the supplied store context and deferring imports removes the observed overhead without duplicating migration logic or changing persisted formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4d48e9c1e026. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* temp/pr-146799: (70 commits) test: reuse explicit fallback config fixtures (openclaw#146948) fix(computer): return fresh window observations after actions (openclaw#146822) refactor(feishu): remove unreachable requester topic selection (openclaw#146904) improve(gateway): reduce CPU spent listing agent-owned sessions (openclaw#137745) fix(ui): avoid recapturing chat drafts during UI updates (openclaw#146884) fix(ui): show system uptime in the debug overlay (openclaw#146960) fix(retry): honor waits beyond the native timer limit (openclaw#145718) fix(ui): keep chat history idle when run status changes (openclaw#146802) fix(ui): reuse persisted text during chat streaming (openclaw#146831) refactor(qa): share harness drift result construction (openclaw#146903) test(agents): coordinate settings lock contention (openclaw#146949) fix(worker): avoid repeatedly serializing screenshot history (openclaw#146907) fix(secrets): stop buffered upload writes after cancellation (openclaw#146840) perf(doctor): avoid unnecessary state runtime imports (openclaw#146926) improve: reduce compaction request estimation work (openclaw#146961) fix(ci): wait for forwarded avatar imports before assertions (openclaw#146729) perf(workers): skip configured Git author lookups (openclaw#146833) fix: admit borrowed memory writes through the agent database owner (openclaw#146760) fix(discord): prevent voice playback gaps and stale turn controls (openclaw#146798) improve: reduce worktree filesystem stalls and archive syncs (openclaw#146906) ...
* commit 'ccfd2377cd07d1ad3a583ba64d08e29a065f7061': (1587 commits) fix(ui): avoid recapturing chat drafts during UI updates (#146884) fix(ui): show system uptime in the debug overlay (#146960) fix(retry): honor waits beyond the native timer limit (#145718) fix(ui): keep chat history idle when run status changes (#146802) fix(ui): reuse persisted text during chat streaming (#146831) refactor(qa): share harness drift result construction (#146903) test(agents): coordinate settings lock contention (#146949) fix(worker): avoid repeatedly serializing screenshot history (#146907) fix(secrets): stop buffered upload writes after cancellation (#146840) perf(doctor): avoid unnecessary state runtime imports (#146926) improve: reduce compaction request estimation work (#146961) fix(ci): wait for forwarded avatar imports before assertions (#146729) perf(workers): skip configured Git author lookups (#146833) fix: admit borrowed memory writes through the agent database owner (#146760) fix(discord): prevent voice playback gaps and stale turn controls (#146798) improve: reduce worktree filesystem stalls and archive syncs (#146906) fix(ui): avoid extra chat rail work while replies stream (#146883) improve(ui): speed up populated Usage timelines (#146947) test(gateway): retain auth recovery failure diagnostics (#146925) fix(tests): create private temporary home directories (#146931) ... # Conflicts: # test/tsconfig/tsconfig.core.test.agents-other.json # test/tsconfig/tsconfig.core.test.agents-root.json
What Problem This Solves
Cold Doctor state checks load a broad runtime dependency graph even when they already have the required store context or the plugin's state directory is absent.
User Impact
Doctor avoids unnecessary imports while preserving the existing migration owners, state formats, validation and recovery behavior. Existing Voice Call databases still receive schema checks even without a legacy call log. No configuration, schema, retention, resource-custody or public SDK contract changes are introduced.
The measured improvement is local test-case time. Full command and Linux CI speedups are not yet established.
Why This Change Was Made
Crabbox Doctor now reads both required namespaces through its supplied context and shares unchanged limits, selectors and row projection with the runtime through a lightweight private module. Memory Host defers its state-store dependency until an actual read or write; every original key, timestamp and query argument is prepared before that await. Voice Call returns the existing empty result before loading repair machinery only when its entire store root is absent.
These changes belong together: the first two partial versions merely moved the same cold load to the next detector. The complete change removes that unnecessary load from the observed sweep. Runtime storage operations remain with their existing owners.
Evidence
An uninstrumented original/candidate/original comparison ran the same first two corpus cases in the same order, preserving both Doctor/startup passes and all assertions. First-case times were 39.02 / 31.08 / 36.83 seconds. The two-case total was 40.90 seconds for the candidate versus 48.00 seconds averaged across the controls, a 14.8% local reduction. The diagnostic sweep separately retained all 46 declared migration owners and 512 callback invocations, while first detection fell from 18.38 to 10.05 seconds.
The candidate's dirty checkout triggered an extra canonical pretest build, so its overall local command was slower. No wrapper or CI speedup is claimed; committed CI must establish the job-level result. This was a same-host macOS source-mode sample using Node 24.21 and pnpm 12.3.4, not the full corpus or a Linux benchmark.
All 235 focused tests, the full build and required changed-file checks passed. Four absent-state regression cases fail at the original repair imports and pass with the fix; retained cases cover database-only repair, malformed logs, partial writes/retry, capacity, concurrent sequencing, rollback and reopen. Two fresh plain-Node processes also exercised the compiled public SDK: append/read followed by a separate lock-owned export and persisted read, with exact event bytes and cleanup verified.
Exact-head CI34751724130 passed, including both startup corpus files (58 tests) and all 91 affected plugin Doctor cases. The actual tested merge preserves the eight candidate files. The full corpus group took242.96s; that is an observation, not a controlled before/after improvement.
The repository-required published-updater compatibility cell passed: published [email protected] updater to exact candidate607628d8, using existing base-scenario state and trusted harnessf3bdcc10. The actual file-tag update is followed by automatic-migration assertions before the subsequent standalone Doctor phase, preserved-state checks and Gateway health/readiness/status. The lane passed in393s, one attempt, zero retries; artifact hashes and phase order were verified. The explicit file spec bypasses the published driver's same-version no-op. Inner updater/repair JSON and a direct installed-tree hash are not uploaded, so zero repair and byte-for-byte installed-tree attestation are not claimed. This resolves the review's required compatibility items without changing migration or stored-data contracts.
Independent P2 review found no actionable defect across two evidence batches; maintainer review covered the full owners and the split-context limitations. Source checks confirm unchanged selectors, limits, persisted types, normalizer and journal/query arguments. The final eight source files are identical to their tested and reviewed bytes after the mechanical refresh onto current main.
Production adds 45 net lines for the shared lightweight record owner, prepared arguments and absent-directory checks; tests add 37. No new loader, cache, SDK seam, worker, shard, wait or deadline. Changelog remains release-owned.