Repository navigation
perf(state): reuse retained proof for native worker opens - #154258
Conversation
Transfer revocable host integrity proof after ordinary handle close through the existing native admission port. Keep receiver identity validation and durable verification gates intact. A synthetic 1 GiB database opens in 12 ms median versus 96 ms; Testbox regression, sibling tests, changed checks, and independent review pass.
|
🦞👀 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 20, 2026, 9:54 PM ET / September 21, 2026, 01:54 UTC. ClawSweeper reviewWhat this changesNative database Workers reuse retained integrity validation after the host connection closes, avoiding redundant scans while preserving existing admission checks. Merge readiness✅ Ready for maintainer review This remains a useful, focused performance fix: current main still requires an open host handle to transfer validation. No actionable correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherNative Workers open agent SQLite databases to perform session and agent operations. The validation owner supplies reusable integrity evidence, while the database opener independently checks identity, durable metadata, schema, and leases. flowchart TD
A[Agent database operation] --> B[Worker admission]
C[Retained host validation] --> B
B --> D[Check identity and revocation]
D --> E[Check durable record and lease]
E --> F[Reuse validation or scan database]
F --> G[Admitted database operation]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +9, Tests +20, Docs +3. Total +32 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep retained validation in its existing owner and reuse it through native admission while preserving receiver-side identity, revocation, durable-record, and migration checks. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the trigger: close a verified host handle while a sibling lease remains live, then open a native Worker; current main cannot transfer the retained evidence. The supplied regression reports this failure, but this review did not execute it. Is this the best way to solve the issue? Yes. The patch accesses the existing validation owner directly and preserves the canonical opener's checks, avoiding a competing cache or broader lifecycle change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 20eebbd5c7bf. 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.
|
…54258) Transfer revocable host integrity proof after ordinary handle close through the existing native admission port. Keep receiver identity validation and durable verification gates intact. A synthetic 1 GiB database opens in 12 ms median versus 96 ms; Testbox regression, sibling tests, changed checks, and independent review pass.
Related: #153581, #153463.
What Problem This Solves
Native agent database Workers repeat full integrity scans after the host's verified database handle closes or is evicted, delaying their first operation while another database lease is still live.
User Impact
Already-verified native Worker opens reuse retained proof without scanning the file again. Revoked proof, replacement files, missing or mismatched durable records, migrations, and Doctor retain their existing checks. There are no schema, configuration, durability, retention, or update-behavior changes.
Why This Change Was Made
The validation owner intentionally retains revocable, file-bound proof after an ordinary handle close. The native admission handoff previously required an open host handle to retrieve that proof. With a live sibling lease, the durable clean-close receipt also cannot substitute. The handoff now reads transferable proof from the same validation owner; the receiving opener still checks its physical identity and shared revocation flag before the existing durable-record and lease gates. Net production change: +9 lines; no new cache or lifecycle.
Evidence
Synthetic warm-cache benchmark on a 1,076,822,016-byte SQLite database, with a closed host handle and a live sibling lease. Three fresh native opens per version, on the same Blacksmith Testbox lease. The fixture adds 128 × 8 MiB zero-filled BLOBs; the measured interval is the existing agent-database open timer, excluding Worker startup and lease acquisition. A temporary probe printed the existing opener phase timings and counted actual integrity PRAGMA executions; the probe and large fixture are not included in the PR.
healthycachedintegrity_check/foreign_key_check, per openThe committed regression failed on the original code specifically for the closed-host case (
[1, 1]PRAGMA counts instead of[0, 0]); the eight other cases passed. New cases also cover revoked retained proof and a replaced file.All heavy validation used provider
blacksmith-testbox, profileopenclaw-check. No local tests, builds, or typechecks ran.tbx_01m30ppyjtrwq257y9gcs96ymg:node scripts/run-vitest.mjs src/state/openclaw-agent-execution.integrity.test.ts --maxWorkers=1reproduced the regression (1 expected failure / 8 passes). Testbox run. Lease stopped after a subsequent file-sync timeout.tbx_01m30qd53kwp4zy26bfj4bvk16: the same command with the temporary benchmark fixture passed three samples before and three after. Testbox run.tbx_01m30r0d93ydx1qf544t1vk2vz:node scripts/run-vitest.mjs src/state/openclaw-agent-execution.integrity.test.ts src/state/openclaw-agent-db-validation-cache.test.ts src/state/openclaw-agent-db.integrity-policy.test.ts --maxWorkers=1passed all 45 tests. The changed native Worker test file passed all 9 cases in 7.46 s wall time (one worker); the other two files passed 36 cases in 15.01 s including worker compilation. Final validation Testbox run.tbx_01m30r0d93ydx1qf544t1vk2vz:node scripts/check-changed.mjs --base HEADpassed (23m 03s command time).HEADwas the unchanged pre-commit lane base21688de06da; this covered core and test types, ratchets, formatting, lint, export scans, runtime import cycles, and ownership guards. All three task-owned leases were stopped.git diff --checkpassed.Validation setup and recovered infrastructure failures
Validation setup encountered missing dependencies in the synchronized checkout, resolved with
pnpm install --frozen-lockfilethere. An initial login-shell invocation ran six unchanged tests in the hydration checkout and was excluded from candidate proof. A temporary benchmark filename selected the thread pool and hit the host-only admission guard; moving the probe into the existing fork-based integrity test route fixed that harness issue. Two later incremental-sync timeouts required replacing the first and second leases. The default changed gate compared against a newerorigin/mainand reported line-cap growth in untouched files:src/agents/agent-tools.tsandsrc/gateway/config-reload.test.ts. Upstream commitsddc25180e5cand052d26eec0bexplain those differences; the gate was corrected to the unchanged lane base. No failed product test was retried without a diagnosed change.Gap: this proves the native execution Worker path and synthetic performance. Production journal correlation and production-scale timing remain unverified; no live deployment was performed.
Landing CI investigation
The initial exact-head CI run failed only
checks-node-compact-small-45and its aggregate gate. The failing case wastest/scripts/crabbox-staging.test.ts→ “keeps preparation callbacks and additional Git workspaces held without disabling them”: its child command exceeded 30 seconds. The fixture does not retain the specific child arguments/output on timeout, so the precise stalled operation remains unknown. The staging owner and helper code are identical on this PR and the inspected main revision; the fixture does not execute the changed native database validation path.The original three-group shard plan was replayed in order on pure main
894fb140a22246bc1574d5b29fe61e10f77036de, using Blacksmith Testboxtbx_01m30xbwn1bdd19661xvqdbjh5andnode --import tsx scripts/ci-run-node-test-shard.mtswith the original shard groups and two workers. All 74 files passed: 1,769 tests passed and seven were skipped. Command time was 413.155 seconds; the previously failing case passed in 12.743 seconds. The lease was stopped. This passing replay does not establish a fix for the original timeout. No source changes, test retries, timeout changes, local tests, builds, or typechecks were introduced during landing.The single operator-authorized job-specific rerun passed on unchanged head
29bc4a0c6d743884f1d6559b12e7718dd1f04a22: CI run 35551629220, attempt 2. The successful shard job was106197640653; the CI gate job was106199710586. The CLI rerun shim refused before dispatch, so the equivalent job-specific REST endpoint was used once.