Repository navigation
fix(state): renew maintenance leases during synchronous work - #134880
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed September 1, 2026, 5:47 AM ET / 09:47 UTC. ClawSweeper reviewWhat this changesThis PR moves Doctor’s shared SQLite maintenance-lease renewal into a dedicated worker and updates runtime-worker build and test inventories. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the new heartbeat cannot start from a Node 22 source checkout because its worker loader does not register the resolver required for the worker’s Priority: P1 Review scores
Verification
How this fits togetherDoctor holds a shared-state lease while it scans or migrates agent databases, preventing other writers from entering maintenance-sensitive paths. The new worker is intended to renew that lease independently while the Doctor process is synchronously blocked. flowchart LR
A[Doctor maintenance] --> B[Shared SQLite lease]
B --> C[Heartbeat worker]
C --> D[Lease renewal record]
A --> E[Synchronous scan or migration]
D --> F[Final ownership check]
E --> F
F --> G[Commit or release]
Decision needed
Why: The source-loader failure is mechanical, but the protected maintainer label requires explicit maintainer handling and the prior Windows lifecycle rank-up remains unresolved. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +254, Tests +204, Docs +4, Other +16. Total +478 across 21 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use the existing programmatic Do we have a high-confidence way to reproduce the issue? Yes, from source: on Node 22, run Doctor from a source checkout so the maintenance heartbeat starts its Is this the best way to solve the issue? No: the independent heartbeat is the right ownership boundary for a blocked event loop, but this implementation must use the repository’s programmatic Worker resolver before it is a supported source-runtime solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f2646be7a983. LabelsLabel changes:
Label 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 (4 earlier review cycles)
|
Integrate main and copy both runtime build-entry modules into the isolated declaration graph. The core entry module must resolve its import.meta.url-owned inputs inside that graph; keep the existing path-escape guard intact.
|
Merged via squash.
|
…w#134880) * fix(state): renew maintenance leases during synchronous work * test(state): align maintenance worker integration checks
What Problem This Solves
Doctor can lose its database maintenance lease when a synchronous SQLite scan or migration blocks the parent event loop beyond the existing 60-second expiry. The timer cannot renew during that operation. The real maintenance-owner reproduction failed before this repair, matching the release feedback; the blocked-timer path exists in
v2026.8.1and main.Why This Change Was Made
The existing lease owner starts an independent Worker heartbeat only for agent-database maintenance, implementing the approved design. Acquisition and renewal retain one canonical policy: the same schema, 60-second expiry, exact scope/key/owner tuple, and refusal to renew expired, deleted, or replaced ownership. Other leases keep their timer path.
SQLite remains authoritative. Parent assertions read the exact unexpired row, request a fresh Worker acknowledgement, and recheck ownership afterward. Acknowledgement performs no SQLite access, including when the caller already holds a write transaction. Completion, failure, and cancellation await Worker termination before release; process exit fences shared state before synchronous release. Worker loss and ownership loss fail closed.
The runtime-entry registry now supplies packaged workers, test artifacts, and executable audit roots. A plugin-free core build map lets the Doctor fixture include its worker without importing plugin-private code; the full build composes that map with the existing plugin-owned entry. This removes the hard-coded audit inventory. The shared declaration fixture copies both resolver modules so
import.meta.urlstays within its isolated tree; its root-escape guard remains intact.Long synchronous maintenance therefore retains its writer fence without extending expiry. A healthy Worker can also retain a stuck parent's lease until that process is stopped: it measures liveness, not progress. The database schema reference documents that accepted tradeoff. This PR changes no schema version, migration content, public configuration, environment option, or dependency.
Candidate and Change Size
Committed and pushed
efbf78adcb4568a8b5d32d60944ce1b75bb7d6cdintegrates main2bd12c77bab9c76752ec8dbc1e8679e791a2f282. All 21 candidate hashes match the committed manifest. Main owns canonical packaged Doctor readiness from #134812; the earlier duplicate Gateway test is removed.Runtime growth implements the explicitly approved independent renewal and lifecycle boundary; the existing shared lease owner is net -1. The final declaration integration repair adds three net test-support lines and no runtime code.
Final Proof
efbf78a/readyz, retained the valid automation, and verified both invalid legacy records were quarantined in SQLite. Existing 30-second readiness and 45-second test bounds stayed intact..tsWorker through production--import tsx, reached lease readiness, acknowledged inside a real SQLite write transaction, and released the row. No Vitest or built-worker substitution was used.The worker/lease/generation and packaged-readiness rows contain 18 executed cases, separately from the declaration suites, two source probes, and Windows cases. Two initial transform filters selected zero cases; corrected filters each executed one existing case. Empty selections contribute zero proof, and no product failure, timeout, assertion, or runtime setting was retried or weakened.
Canonical preparation rebuilt the prior runtime and produced
OpenClaw 2026.8.1 (efbf78a); the build stamp, runtime-postbuild stamp, and build metadata agree. All 21 candidate and five additional test/dependency hashes remained unchanged, and the checkout stayed clean. Source probes also retained the expanded dependency hashes. The Node 22 binary came from the official archive, verified against its published SHA-256 checksums.Reviews, CI, and ClawSweeper Disposition
The complete candidate passed P0-scoped Codex autoreview with no accepted findings (0.95 confidence; lower priorities excluded). A separate independent review reported no actionable correctness or security findings across all 21 committed files, verifying the exact head, merge parents, hashes, and clean checkout. It directly inspected Node Worker handling, termination/lifecycle, Node SQLite, and SQLite transactions.
The
efbf78aCI rollup, recorded September 1 at 09:52 UTC, is 225 successes, 44 skips, one neutral result, and no failed or pending checks. Windows evidence is bound to tested merge8a8fffda4800572bb10d4f9433d148e096f7a1f4, incorporating this exact PR head.The latest ClawSweeper review, reviewed at 09:47:41 UTC on
efbf78a, raised a late P1 about missing Node 22 source-worker resolver registration. Rejected for the supported runtime and pinned dependency: both unchanged-source probes pass, and tsx 4.23.12 automatically registers in non-internal Workers. Its synchronous-hook feature floors are Node 22.22.3, 24.11.1, and 25.1.0; OpenClaw's supported floors meet them. Node 22 loads import preloads before the entry point, and direct inspection confirms theregisterHooksresolve/load path. The older archive-worker comment does not establish a failure under this current contract.Both rank-up moves have explicit dispositions:
Final native landing verification remains separate from these completed results.
Historical proof and validation limits
Earlier repair checkpoints retain a real 61,003 ms parent block with a 60,000 ms lease and a competing writer refused at +60,201 ms. A generated 90,050,560-byte, 10,000-session database migrated from schema 18 to 19 with payload, integrity, foreign-key, backup, and subsequent writer-admission checks. SIGKILL stopped renewal and allowed reacquisition after expiry. This is not performance proof for the reporter's 18 GB database.
The original 154 focused tests and four existing platform skips, later overlapping lease/migration cases, and plain-Node compiled Worker/preload-isolation proof retain their original source checkpoints. Three existing Doctor cases passed with a 256 MiB old-space setting, including 100,000-message history and public health flow; those runs predate core-map extraction and do not measure process RSS. The prior
5dfb87fcanonical readiness result was 11.106 seconds; the removed duplicate's 5.203-second result is historical only.Earlier test/tooling deadlines passed unchanged in isolation; load causation was not established. An initial full build hit a baseline UI-budget failure. A prior
5dfb87f-associated CI run exposed the repaired declaration-fixture escape; its two Linux failure causes remain unknown because log capture failed. These are historical outcomes, not current CI failures. The two empty transform selections are excluded from final proof.Current proof covers local packaged process/SQLite behavior, source Workers, and the specified Windows artifact cases. It does not claim live-provider/channel traffic, a reporter-database reproduction, dedicated Windows heartbeat lifecycle execution, a repeated full stress/heap suite, clean-install acceptance, or a full release validation.