Repository navigation
improve(config): keep recovery responsive during health snapshots - #145965
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. Reviewed September 12, 2026, 8:45 AM ET / 12:45 UTC. ClawSweeper reviewWhat this changesConfig recovery now awaits the existing private SQLite snapshot worker when reading saved health information, allowing unrelated Gateway work to continue. Merge readiness✅ Ready for maintainer review This remains a useful, focused responsiveness improvement absent from fetched main. No introduced correctness or security defect was found, and the supplied production-path measurements support the stated benefit. Priority: P2 Review scores
Verification
How this fits togetherConfig recovery compares the current configuration with saved health fingerprints and backup contents before preparing a restoration. The shared-state reader supplies those fingerprints while preserving the source database and its sidecar files. flowchart TD
A[Current config and backup] --> B[Recovery preparation]
B --> C{Artifact-preserving read?}
C -->|Yes| D[Await existing snapshot worker]
C -->|No| E[Existing live reader]
D --> F[Read saved health fingerprints]
E --> F
F --> G[Prepare recovery candidate]
G --> H[Recheck sources before restoration]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +33. Total +33 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep snapshot preparation with the existing SQLite owner while preserving synchronous row reads, ordinary live-read behavior, and final recovery commit checks. Do we have a high-confidence way to reproduce the issue? Yes: fetched main's asynchronous recovery preparation reaches the synchronous snapshot reader on a cold artifact-preserving read. The supplied real SQLite pilot measures that blocking; this review verified the source path without executing it. Is this the best way to solve the issue? Yes: selecting the existing async snapshot reader at the recovery effect is a narrow repair that preserves the query, storage lifecycle, and commit safeguards. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b654dcaa7964. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What Problem This Solves
Config recovery can pause unrelated Gateway work while it checks the health of saved configuration, even though recovery preparation runs asynchronously.
Why This Change Was Made
Use the existing asynchronous artifact-preserving snapshot reader in the async recovery effect, sharing the existing ordered health-row query with the synchronous reader. Keep synchronous recovery, ordinary live reads, snapshot/artifact ownership, error handling and final config/backup/lease commit guards unchanged; no schema, configuration, cancellation API, snapshot coalescing or new storage owner is introduced.
User Impact
The event loop can remain responsive while the existing snapshot worker runs. This reduces blocking, not snapshot work, and does not establish a throughput or end-to-end Gateway speedup. Ordinary async recovery gains one Promise yield. The final change adds 33 production lines, compared with 34 in the measured unformatted candidate.
Evidence
Matching Oxfmt 0.66,
git diff --check, and fresh managed Codex review through P2 passed on the final source. Darwin/Node 26.8.1 validation passed 106 existing assertions acrossio.health-state.test.ts,io.observe-recovery.test.ts,io.snapshot.recovery.test.ts, andopenclaw-state-db-readonly.test.ts; all 25 small guards selected by the actual changed-check owner passed under unchanged per-child 300s/6 GiB/64-process limits. No dependency install or new permanent implementation-mirroring test was added.The first small-guard phase stopped at assertion safety: the new generator-result cast raised undocumented assertions from 7 to 8. The original failure remains retained. An inline SAFETY comment documents the existing runner invariant; no assertion type, baseline, test or executable behavior changed. Fresh P2 and the selected guards passed afterward; the 106 behavioral assertions were retained without rerunning for the comment-only change. Hosted CI remains pending for
tsgo:core,tsgo:core:test, and changed core type-aware lint because of the established local capacity limit; none is claimed passed.One isolated Linux/Node 24.19.0 B1/C1/C2/B2 pilot at
7292689e7f78026060491fc94923cafdec48733fexercised actualprepareConfigRecoverywith real SQLite snapshots, plus ordinary-async and synchronous controls. Each case/phase had one warmup and two measured calls. Relative to the measured candidate, author changes are formatting and the comment-only SAFETY annotation; executable code is unchanged. Relevant owners, callers and tests were verified unchanged at93a5d822750d726481ab2998e53b404d04e58b27; no retiming was performed.For the four cold snapshot cases, median maximum callback gaps dropped from 422–557 ms to 5.4–7.5 ms in both comparisons. The real 5 ms sampler starts before the call and drains after completion; performance clocks and timers remain live. Snapshot count stays one per cold call. All 32 case/phase graphs, warnings, health rows, config/backup artifacts and 144 decoded SQLite artifact images passed parity/preservation checks; four additional freshness checks passed.
The tradeoffs remain explicit: cold parent CPU increases 9.7–71.6%, including callbacks that can now run during the call. Transaction call wall time worsens +1.51/+2.21%, warm call wall is −7.93/+15.68%, and ordinary-async call wall is +19.63/−4.70%. Ordinary-async whole-child wall worsens +4.70/+4.98%, CPU +0.74/+4.26%, and observed tree peak RSS +1.03/+0.99%. Whole-child clocks include imports, setup and verification; they are separate from call clocks.
Complete eight-case paired measurements and resource observations
Each pair is B1→C1 / B2→C2. Times are median milliseconds per call; positive percentage changes in wall, CPU or gaps are adverse. These are two-sample pilot medians, not a throughput distribution. Every raw sample and both comparison orders are retained.
Whole-child metrics include imports, fixtures, verification, compression and timer draining. RSS is process high-water/observed tree peak, not exact per-call allocation.
No benchmark retry, cap increase or acceptance-threshold adjustment was used. Measurement closure verified 38 successful native commands, 190 distinct PIDs and 38 groups, source/worktree cleanup and exact Testbox lease closure. Local validation and reviewer children also closed.