Repository navigation
refactor(storage): keep lease transactions on their acquired database - #138507
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 real behavior proof before merge. Reviewed September 4, 2026, 3:03 PM ET / 19:03 UTC. ClawSweeper reviewWhat this changesThe PR moves SQLite lease acquisition and release row operations into the lease store and makes lease write transactions explicitly use the database handle they first acquired. Merge readiness⛔ Blocked before merge - 3 items remain No correctness defect was found in this focused lease-store refactor. Merge remains blocked on inspectable, exact-head real-behavior proof: the PR body describes a prior native run but supplies no trace, artifact, or link that can be audited for the current head. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s state lease subsystem coordinates exclusive work through rows in the shared SQLite state database. Lease lifecycle code acquires, renews, heartbeats, and releases those rows while the state database layer owns the connection and transaction boundary. flowchart LR
A[Lease caller] --> B[Lease lifecycle]
B --> C[Shared state database]
C --> D[Write transaction]
D --> E[Lease store]
E --> F[SQLite lease rows]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +15. Total +15 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single lease-store owner and explicit acquired-handle transaction boundary, then attach redacted exact-head runtime evidence that exercises separate database roots and the lease contention/release invariants. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR describes a behavior-preserving ownership refactor, not a reported user-facing defect. Is this the best way to solve the issue? Yes: moving acquisition and release beside the existing read and renew operations gives the lease store one row-operation owner, while the lifecycle module retains scheduling, retries, and cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 38711206175b. 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
|
|
Merged via squash.
|
What Problem This Solves
Lease acquisition and release built their queries in the lifecycle module while reads and renewals already belonged to the lease store. The transaction helper acquired the shared database but did not pass that exact handle to its callback, leaving the ownership contract implicit.
Why This Change Was Made
Acquisition and release queries now live beside read/renew in the lease store, and the transaction callback receives the exact acquired database. The lifecycle owner retains timing, contention/backoff, worker heartbeat and cleanup responsibilities.
Expiry time is still sampled after entering the transaction. Owner comparisons, zero-busy contention behavior, worker connections and process-exit cleanup remain unchanged. This is a structural improvement; no wrong-database production failure was reproduced. There are no schema, index, configuration, public API, storage representation or concurrency-policy changes.
User Impact
Lease behavior remains the same, with an explicit connection boundary that a future database adapter can preserve.
Evidence
Production delta: +64/-49 (net +15). The growth makes the exact database handle explicit and consolidates row operations in one owner; it adds no parallel implementation or new policy. Existing tests cover the unchanged behavior.
Batch integration and CI refresh
The composed database candidate passed 489 tests across 36 files and ten test projects, 52 native phase records including real CLI/Gateway restart and fresh-process readback, and the complete changed-file gate. The branch was mechanically rebased onto the landed UI startup-budget repair (#138447); its stable patch identity is unchanged. Exact-head hosted CI is required before merge.
Exact-head native lease proof
Passed on Node v24.20.0 with real SQLite, a second Node process and the actual heartbeat worker. The fixture used two isolated synthetic database roots. Source was clean before and after:
PROOF_SCRIPTdenotes the task-locallease-process.mjsfixture; its absolute host path is omitted. Script SHA-256:3430cc80d94693b513a507771c0baa5af6ae12819c8e6f7288a295c4c7489a86.secondProcessRefused: true; the contender receivedOPENCLAW_STATE_LEASE_TIMEOUT.synchronousBlockMs: 10250,leaseMs: 10000,ownershipRenewedWhileParentBlocked: true,workerTerminatedAndLeaseReleased: true.Final emitted result:
{"ok":true,"proof":"two-database-leases-native-process-worker-and-fresh-reopen","noLeakedLeases":true,"quickCheck":"ok"}Raw native-output SHA-256:
d3697ce40ff36d692c36d1a3dd76170a2eec8e1b522fd187252bb86e0e9e277d. This is a native macOS process/worker proof; platform CI is separate.