Repository navigation
fix(state): retain startup integrity proof through idle retirement - #166412
Conversation
Keep a logical executor borrow from enqueue through full-check result publication. Release it when verification completes, fails, is superseded, or is canceled, and preserve custody across verifier handoff. This prevents idle expiry and warm-pool eviction from closing the original writer before its integrity receipt is retained. Explicit close, revoked admission, foreign commits, and physical-file replacement still refuse proof. Move the unchanged shared-state identity check into the execution scope owner to preserve the executor's file-size limit.
|
🦞👀 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 October 6, 2026, 11:49 PM ET / October 7, 2026, 03:49 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR keeps an agent’s SQLite executor alive until background integrity verification settles, preserving reusable restart proof through idle expiry and eviction. Merge readiness✅ Ready for maintainer review This repair remains necessary on current main. No actionable introduced defects were found, and the recorded production-boundary validation supports the change. Priority: P2 Review scores
Verification
How this fits togetherAgent database admission can defer a full integrity scan after a proven process crash. The background verifier returns successful results to the original writer, whose orderly checkpoint and close can certify proof for the next restart. flowchart TD
A[Agent database admission] --> B[Queued full integrity check]
B --> C[Retained executor borrow]
B --> D[Verifier child scans SQLite]
D --> E[Original writer checks current admission and continuity]
E --> F[Durable verification]
E --> G[Release executor borrow]
F --> H[Clean close enables restart reuse]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +47, Tests +128, Docs +4. Total +179 across 7 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep verification custody within the existing executor and queue owners while preserving live publication checks and clean-close certification. Do we have a high-confidence way to reproduce the issue? Yes: current main queues publication against the original writer without retaining its executor, allowing idle retirement to close it first. The PR records a failing real SQLite eviction regression; this review did not execute tests. Is this the best way to solve the issue? Yes: borrowing the existing executor through verification settlement repairs the missing lifetime contract without adding a second proof owner or relaxing publication safeguards. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 30d563e262aa. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Verified inherited-failure landing qualification for exact head I inspected all eight failed Node job logs from CI run 37565241487, including 40 reported cases across 12 files. The checkout was merge The distinct cron failures were independently reproduced on an isolated Linux rig at that exact unchanged first parent: Exact-head validation on Blacksmith Testbox The PR CI run was not rerun, and the branch was not updated or given an unrelated fix. The native merge route refused before submission because its review worktree was unavailable; initialization in the isolated landing checkout is blocked by missing tooling dependencies on this restricted host. The authorized REST fallback pinned the exact reviewed head and landed squash commit |
…penclaw#166412) Retain the originally admitted SQLite executor while a deferred full integrity check is queued, scanning, or publishing, and release it after verification and cleanup settle. This preserves clean-close proof through idle expiry and eviction without relaxing stale-publication checks or changing stored schemas. Validated with exact-head export/closure guards and 1,205 additional state sibling tests on Blacksmith Testbox. Inherited CI failures independently qualified against main; see the PR landing evidence. No live deployment was performed.
What Problem This Solves
Fixes lost startup integrity proof when an agent executor retires while its background full check is queued or publishing. A successful scan previously reached a closed SQLite worker store, leaving the next orderly restart without reusable clean-close proof.
Related: #166112, #165993.
User Impact
A deferred full check retains its original writer across idle expiry and warm-pool eviction. Its normal final checkpoint and close can then make the verification reusable at restart. Explicit close, revoked admission, foreign commits, and file replacement still prevent stale publication. No schema, configuration, update, or rollback contract changes.
Why This Change Was Made
Full checks now borrow the existing executor at enqueue time. The verifier queue releases that borrow after result application, scan failure, cancellation, or supersession, and preserves it across verifier handoff. Shutdown joins asynchronous cleanup. The existing shared-state identity check moves into the execution-scope module to keep the executor within its line cap; its physical-store and Windows environment-casing checks are unchanged.
Production LOC delta: +47 (65 added, 18 removed). The missing queue ownership and cleanup contract requires retaining the same admitted writer through asynchronous verification. The small scope extraction preserves the existing admission contract and file cap. This uses one borrower/retirement owner, with no second proof path, cache, or retry loop.
Evidence
All heavy validation uses Blacksmith Testbox (
blacksmith-testbox, profileopenclaw-check). Behavior proof and review used07e9a2519420, which includes the four-slot warm executor pool. Publication was rebased onto2beca62e67b1with an identical stable patch ID; only this lane's commit remains on top.background-idle-swap: expected undefinedfor the verification record after five sibling agents create eviction pressure. Testboxtbx_01m4a207gmf2bt324zp81fnzm7,node scripts/run-vitest.mjs src/state/openclaw-agent-execution.integrity.test.ts --maxWorkers=1 -t 'classifies dead-owner': expected failure, 13.67 s wall.node scripts/run-vitest.mjs src/state/openclaw-agent-execution.integrity.test.ts src/state/openclaw-database-verify.shutdown.test.ts src/state/openclaw-database-verify.test.ts src/state/openclaw-agent-execution.idle.test.ts --maxWorkers=1: 40.82 s wrapper time; integrity file 27.57 s wall, unit files 8.79 s. The regression retains proof through eviction and expiry, completes clean close, and reopens with zero integrity/foreign-key scans. Its real process-death provenance and native lease lifetime require the existing worker fixture.tbx_01m4a32k1zv3bqsb2kg27ax6m5; exact hashes of all seven files are checked beforenode scripts/check-changed.mjs --stagedandnode scripts/run-vitest.mjs src/state/openclaw-agent-execution.integrity.test.ts src/state/openclaw-database-verify.shutdown.test.ts src/state/openclaw-database-verify.test.ts src/state/openclaw-agent-execution.idle.test.ts src/state/openclaw-agent-execution.creation-witness.test.ts --maxWorkers=1. Gate passed; 110 tests passed. The combined remote command took 26m58.7s; focused wrapper time was 74.84s. Final reported test time: integrity 26.868s, verifier shutdown 0.025s, creation-witness 14.930s. All owned leases were stopped.Some reused-lease checksum syncs timed out before commands started. Fresh, normally synced leases supplied the passing validation above.
Gap: no live Gateway deployment or production latency measurement. This repair is measured by retained proof and avoided repeat integrity scans.
Inherited CI failures reproduced without this patch
On Blacksmith Testbox
tbx_01m4a5xc7gfhw7kf7kkzvmkvhm, a separate clean worktree at main3a085ea5dee4c704c6df4e972ae84335177aed09ran each file below withnode scripts/run-vitest.mjs <file> --maxWorkers=1, preserving each file's test order. No lane patch was applied. All ten files failed, with 36 failures in 394.6 seconds of remote command time. Each of the eight failed CI shards has an exact matching baseline case (22 matching cases overall). Configuration lifecycle failure case identities also vary during isolated replay, so the remaining individual case differences are not claimed as proven fixes or exact reproductions.src/auto-reply/reply/reply-turn-admission.worker.test.tssrc/config/sessions/session-transcript-reconcile.lifecycle.test.tssrc/config/sessions/session-transcript-reconcile-pool.test.tssrc/gateway/server.chat.gateway-server-chat-b.test.tssrc/gateway/server.sessions.create.authority.test.tssrc/gateway/server.sessions.create.lifecycle.test.tssrc/gateway/board-store.test.tssrc/cron/session-registry-maintenance.test.tssrc/gateway/worker-environments/live-events.test.tssrc/gateway/server-methods/chat-send-global-identity.test.tsThe failures include expectations of one idle executor where four can now remain warm, admission closed after config publication, and related existing lifecycle assertions. The baseline lease is stopped. These inherited failures remain unresolved; main repairs are still needed for green CI. Independent inherited-failure qualification and the verified merge are recorded in the landing comment.