Repository navigation
Conversation
Treat dead leases as lifecycle cleanup, preserve admitted physical-file facts, and use bounded schema/header admission after worker revocation. Keep authority checks, explicit FULL verification, migration checks, and corruption quarantine. Remove crash-provenance scan escalation and sticky FULL lease bookkeeping.
|
🦞👀 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. What this changesThis PR replaces lease-driven database rescans with bounded admission and Gateway-owned background verification that survives native worker retirement. Example: A worker reopens a healthy 34.94 GiB agent database after stale-lease cleanup.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a current database stall path. The supplied upgrade evidence resolves the previous compatibility concern, and no actionable patch defect was found. Exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherAgent database admission sits between session operations and native SQLite workers; it validates storage ownership and schema, publishes admitted facts, and coordinates verification, quarantine, and clean-close seals. flowchart TD
A[Session requests] --> B[Agent execution owner]
B --> C[Bounded schema admission]
C --> D[Native SQLite worker]
C --> E[Gateway verification owner]
E --> F[Read only integrity child]
F --> G[Verified receipt or quarantine]
Technical reviewBest possible solution: Keep bounded admission and verification settlement in their existing owners while preserving live write authority, migration checks, and corruption quarantine. Do we have a high-confidence way to reproduce the issue? Current-main source can escalate stale leases or revoked admission into whole-file verification; the supplied native benchmark and crash regressions exercise that path, but no target code was run during this read-only review. Is this the best way to solve the issue? The change fixes the admission owner rather than adding caller retries, removes superseded crash-provenance selection, and reuses the existing Gateway verifier without introducing another persistence owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3492199a84ff. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +70, Tests +208, Docs +22, Other +149. Total +449 across 66 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 11, 2026, 2:04 PM ET / 19:04 UTC (Revision 2). |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a06e67ceb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!staleLease && url === startupUrl && values.arm === "baseline") { | ||
| assert(values["baseline-source"], "Baseline needs --baseline-source"); | ||
| source = readFileSync(values["baseline-source"], "utf8"); |
There was a problem hiding this comment.
Preserve compatibility for the derived-index benchmark baseline
When the default derived-index scenario uses the documented --baseline-source option with the pre-change startup-integrity module, this hook substitutes only that old module while retaining the current callers. The old module exports admitAgentDatabaseStartupStructure, but openclaw-agent-db-schema.ts now imports admitAgentDatabaseRuntimeStructure, so the baseline sample fails during ESM linking instead of producing a measurement. The six-module substitution handles the stale-lease scenario but does not cover this existing benchmark mode. Adapt the baseline module's interface or load a matching set of baseline callers so the documented derived-index comparison remains runnable.
Useful? React with 👍 / 👎.
Avoid redundant schema initialization after current-schema admission while retaining creation, convergence, and application-version metadata repair. Make held verification and reclamation fixtures request their actual owner work, isolate cleanup warnings, and allocate the exact test-line growth plus the requested baseline reconciliation.
Baseline-Refresh: d33f155dd3099fa6e635c41902420d333cf666f0
Schedule owed full verification through the existing Gateway owner after accepted runtime preparation. Retain completed and inconclusive attempts across native worker retirement, preserve quarantine and real verification receipts, and keep caller waits bounded without cancelling preparation. Report blocking clean-close leases and integrity outcomes in journal text. Run background integrity children at low process priority and repair the benchmark to load coherent baseline checkouts. Validation: 141 focused database tests and 7 affected browser cases pass; check:changed passes; complete staged Codex review has no actionable P0-P2 findings. Scoped test allocations cover 204 net regression-test lines. Full SQLite checks remain non-resumable and have no page-level I/O pacing.
|
Merged via squash.
|
…4484) * fix: avoid agent database scans after worker retirement Treat dead leases as lifecycle cleanup, preserve admitted physical-file facts, and use bounded schema/header admission after worker revocation. Keep authority checks, explicit FULL verification, migration checks, and corruption quarantine. Remove crash-provenance scan escalation and sticky FULL lease bookkeeping. * test: keep stale lease benchmark setup scan-free * fix: preserve startup verification during bounded runtime admission * fix(state): preserve bounded admission receipts at startup Avoid redundant schema initialization after current-schema admission while retaining creation, convergence, and application-version metadata repair. Make held verification and reclamation fixtures request their actual owner work, isolate cleanup warnings, and allocate the exact test-line growth plus the requested baseline reconciliation. * fix(state): settle deferred agent database verification Schedule owed full verification through the existing Gateway owner after accepted runtime preparation. Retain completed and inconclusive attempts across native worker retirement, preserve quarantine and real verification receipts, and keep caller waits bounded without cancelling preparation. Report blocking clean-close leases and integrity outcomes in journal text. Run background integrity children at low process priority and repair the benchmark to load coherent baseline checkouts. Validation: 141 focused database tests and 7 affected browser cases pass; check:changed passes; complete staged Codex review has no actionable P0-P2 findings. Scoped test allocations cover 204 net regression-test lines. Full SQLite checks remain non-resumable and have no page-level I/O pacing. * test(state): align startup verification admission expectations
…196378) fix(memory): let large memory rebuilds finish without running out of worker memory A full memory rebuild ran out of its 512 MiB worker and restarted on every attempt when the index held tens of thousands of embedded chunks, for example after the chunking-format upgrade from 2026.10.9, so vector search never came back and search kept serving the old keyword index. Two steps held a whole pass in one worker. Vector reuse now reads cached embeddings in pages of whole hashes sized to 8 MiB of decoded vectors. The SQLite publication worker now parses each staged row as it arrives and keeps its vector as a Float64Array instead of JSON, turning one row at a time back into a number array at source.replace, which stays one atomic replace. Stored bytes, schema and retention are unchanged, no table is added, and the PostgreSQL path is untouched. Evidence: a 94,919-chunk index at 1536 dimensions built through the real import and memory index paths in a secretless node:24.22.1 container with a stand-in embeddings server. On the PR base and current main, the format-upgrade rebuild and memory index --force ran out of memory after 19-33 s with the read worker near 490 MiB, and a running Gateway retried and failed again while search served the keyword index. With this change both rebuilds finish in 320-415 s with peak worker heaps near 100-110 MiB, no embedding calls, byte-identical stored vectors and vector search hits. A 634-chunk index and an already-rebuilt index behave the same on both. The red changed-extensions bundles are three memory-core integrity tests that fail on main since #194484: #196378 (comment). Net 0 test lines. Details: #196378 (comment). Thanks @garrytan. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#196378) fix(memory): let large memory rebuilds finish without running out of worker memory A full memory rebuild ran out of its 512 MiB worker and restarted on every attempt when the index held tens of thousands of embedded chunks, for example after the chunking-format upgrade from 2026.10.9, so vector search never came back and search kept serving the old keyword index. Two steps held a whole pass in one worker. Vector reuse now reads cached embeddings in pages of whole hashes sized to 8 MiB of decoded vectors. The SQLite publication worker now parses each staged row as it arrives and keeps its vector as a Float64Array instead of JSON, turning one row at a time back into a number array at source.replace, which stays one atomic replace. Stored bytes, schema and retention are unchanged, no table is added, and the PostgreSQL path is untouched. Evidence: a 94,919-chunk index at 1536 dimensions built through the real import and memory index paths in a secretless node:24.22.1 container with a stand-in embeddings server. On the PR base and current main, the format-upgrade rebuild and memory index --force ran out of memory after 19-33 s with the read worker near 490 MiB, and a running Gateway retried and failed again while search served the keyword index. With this change both rebuilds finish in 320-415 s with peak worker heaps near 100-110 MiB, no embedding calls, byte-identical stored vectors and vector search hits. A 634-chunk index and an already-rebuilt index behave the same on both. The red changed-extensions bundles are three memory-core integrity tests that fail on main since openclaw#194484: openclaw#196378 (comment). Net 0 test lines. Details: openclaw#196378 (comment). Thanks @garrytan. Co-authored-by: Ayaan Zaidi <[email protected]>
…196378) fix(memory): let large memory rebuilds finish without running out of worker memory A full memory rebuild ran out of its 512 MiB worker and restarted on every attempt when the index held tens of thousands of embedded chunks, for example after the chunking-format upgrade from 2026.10.9, so vector search never came back and search kept serving the old keyword index. Two steps held a whole pass in one worker. Vector reuse now reads cached embeddings in pages of whole hashes sized to 8 MiB of decoded vectors. The SQLite publication worker now parses each staged row as it arrives and keeps its vector as a Float64Array instead of JSON, turning one row at a time back into a number array at source.replace, which stays one atomic replace. Stored bytes, schema and retention are unchanged, no table is added, and the PostgreSQL path is untouched. Evidence: a 94,919-chunk index at 1536 dimensions built through the real import and memory index paths in a secretless node:24.22.1 container with a stand-in embeddings server. On the PR base and current main, the format-upgrade rebuild and memory index --force ran out of memory after 19-33 s with the read worker near 490 MiB, and a running Gateway retried and failed again while search served the keyword index. With this change both rebuilds finish in 320-415 s with peak worker heaps near 100-110 MiB, no embedding calls, byte-identical stored vectors and vector search hits. A 634-chunk index and an already-rebuilt index behave the same on both. The red changed-extensions bundles are three memory-core integrity tests that fail on main since #194484: #196378 (comment). Net 0 test lines. Details: #196378 (comment). Thanks @garrytan. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 3e7fb1b) Release adaptation: page the release branch's existing cache-only reads; do not import newer published-vector fallback, PostgreSQL, or retirement owners. Retain provider identity order, disabled-cache behavior and SQLite publication contracts. Packed staging is unchanged from the source fix. Companion review: 3ea0883 (#195369) is a separate cache-retention change, not required for bounded reads or packed staging; intentionally excluded. No later PR-number follow-ups. Existing transfer/settlement fixtures retain the same protocol. No storage format, schema or retention change. Proof: Node syntax checks and exact production staging-helper value/order, replay and fragmented-tail checks pass. Full owner tests/typecheck remain unrun: isolated worktree has no dependencies; no install authorized. Independent review remains with the parent (worker cannot spawn children). Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit 8d8df0799fba9770b913bdc9be546915c8351a8c)
…196378) fix(memory): let large memory rebuilds finish without running out of worker memory A full memory rebuild ran out of its 512 MiB worker and restarted on every attempt when the index held tens of thousands of embedded chunks, for example after the chunking-format upgrade from 2026.10.9, so vector search never came back and search kept serving the old keyword index. Two steps held a whole pass in one worker. Vector reuse now reads cached embeddings in pages of whole hashes sized to 8 MiB of decoded vectors. The SQLite publication worker now parses each staged row as it arrives and keeps its vector as a Float64Array instead of JSON, turning one row at a time back into a number array at source.replace, which stays one atomic replace. Stored bytes, schema and retention are unchanged, no table is added, and the PostgreSQL path is untouched. Evidence: a 94,919-chunk index at 1536 dimensions built through the real import and memory index paths in a secretless node:24.22.1 container with a stand-in embeddings server. On the PR base and current main, the format-upgrade rebuild and memory index --force ran out of memory after 19-33 s with the read worker near 490 MiB, and a running Gateway retried and failed again while search served the keyword index. With this change both rebuilds finish in 320-415 s with peak worker heaps near 100-110 MiB, no embedding calls, byte-identical stored vectors and vector search hits. A 634-chunk index and an already-rebuilt index behave the same on both. The red changed-extensions bundles are three memory-core integrity tests that fail on main since #194484: #196378 (comment). Net 0 test lines. Details: #196378 (comment). Thanks @garrytan. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 3e7fb1b) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 512b5d231bff565381824a8796ccb9417f118ef6) Co-authored-by: vincentkoc <[email protected]>
…law#194599) An agent database on an older schema is now reported as a required state migration, so the managed service is parked with the existing "run openclaw doctor --fix" guidance instead of restart-looping the Gateway. The session-SQLite import still defers such a target and processes the others (fixes openclaw#194580). Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: steipete <[email protected]> (cherry picked from commit 8bea0c1) Release adaptation: Classify only older canonical agent schemas as existing state-migrations maintenance; Doctor continues deferring matching targets. Keep newer schema refusal/media migration identity. No schema/version/data migration changes; retain focused Gateway parking, committed reader and Doctor regressions. Later cancellation-owner and unrelated Doctor repairs are not prerequisites. Follow-up dispositions: 410c0dd refactor(infra): read SQLite cancellation from its scope owner (openclaw#200179); 8cd7d87 chore(ci): drop retired test-lines allocation records (1/3) (openclaw#197655); 0e966cc fix: avoid agent database stalls after worker retirement (openclaw#194484); ef47e2e fix(doctor): defer update session-entry inspection when snapshot space runs out (openclaw#196370); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685) Validation: Source baseline old-schema error was generic SqliteSchemaMismatchError and did not trigger service maintenance parking. Matching existing maintenance codec and Doctor catch reviewed; exact regression group queued. diff check passed. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f61a73edfda73dc6452f3e0e534cb9e891c05ae6) (cherry picked from commit 4e8445923f2522eb6b42ab705e15624a1a674a39)
What Problem This Solves
A runtime agent writer could spend minutes in a whole-file integrity check after lease cleanup or worker retirement. Callers expired while that writer was held; replacement workers could select another full scan.
User Impact
Current-schema admission now uses the existing bounded schema/header owner, while the Gateway schedules owed full verification in its read-only background child.
Requests waiting for writable preparation receive a retryable verification/preparation-in-progress response after one second. The Gateway's work and internal recovery joins continue.
Why This Change Was Made
The same Gateway owner tracks queued, completed, and inconclusive attempts by shared-state scope and physical file. Replacing a native worker does not restart the scan; replacing the file creates a new obligation. Successful verification publishes the existing full receipt, proven corruption fences access and persists quarantine, and incomplete verification publishes neither a timestamp nor a seal. Explicit FULL, migration, noncanonical schema repair, and recovery checks retain their required policies. See the integrity policy.
Close diagnostics identify the first lease preventing a clean seal, and gate journal text includes its reason, mode, outcome, and elapsed time. The exact holder and error in the original incident cannot be reconstructed from the old journal text; no timeout or corruption attribution is asserted.
Background scans use low OS process priority and the existing two-scan permit pool and inspection deadline. SQLite's current binding does not provide a resumable full-check cursor or page-level I/O pacing. An incomplete attempt is logged and retained until the Gateway ends; a later startup or explicit verification can try again. This removes immediate rescan amplification without claiming resumability or an I/O bandwidth limit.
Evidence
Focused regressions fail before their fixes and pass afterward. Current local proof: 71 scheduling/authority/recovery tests, 44 lease/cache tests, and 26 integrity-child tests pass. The affected post-deploy Control UI E2E passes 6/6; the browser's retryable-inspection presentation case also passes. Codex autoreview of the complete staged candidate is scoped-clean P0-P2.
pnpm check:changed --base 5d8c25101e6726d64348ec014a3e2e8e7467884e --timedpasses all 38 selected gates. CI on4fbe41602d2d757d09cd79c394f1ddfd2597ee96exposed seven obsolete message assertions and one lifecycle fixture using the new foreground deadline. The test-only correction560f907ff24cffc5bf9d26c19fb79768d2fce919preserves behavior assertions and passes all 61 tests in the three affected files (32/16/13), with separate clean Codex review. Seven cases reproduced red locally; the timing-sensitive lifecycle failure reproduced in CI but passed the pre-fix local replay. Follow-up change checks passed after recovering an interrupted task-owned lint artifact lock and replaying the blocked script-lint gate. Final-head CI passed for560f907ff24cffc5bf9d26c19fb79768d2fce919: all 73 selected jobs, including PostgreSQL conformance andopenclaw/ci-gate, succeeded.The retained production-shaped synthetic campaign used a 34.94 GiB database with 1,000,000 transcript events, 10,000 sessions, and an inert 62,000-file/1.116 GB workspace. Five counterbalanced timing pairs, five allocation pairs, and four A/A controls preserved committed data and rolled back interrupted writes.
A/A wall times were 13.72/13.45 ms; allocations 1,189,112/1,242,016 B. Baseline range was 8.13-360.47 seconds; candidate range 12.15-21.07 ms. These are historical measurements at
661a6837918893872fecad1f8b290721303df6f9, against original parent1f7035c15f3d6f89b7336c0d273ddcb18b8ff060, on shared APFS with unforced cache state. They are not final-head, cold-cache, btrfs, or production absolute-latency claims; allocation excludes native SQLite memory.The repaired benchmark now loads each arm's complete prepared checkout, dependencies, and tsconfig, replacing incompatible partial-module swaps. A separate 64.8 MB setup smoke passed eight timing/allocation/A/A samples with baseline FULL count 1 and candidate/control count 0, including committed-row, rollback, index, and census assertions. That smoke validates the benchmark and current admission behavior; it does not replace the large-fixture campaign. Current reproduction uses
scripts/perf/derived-index-admission-measure.ts --scenario stale-lease --baseline-dir <prepared-schema-compatible-before-checkout>; historical measurements retain their original command/revisions.Scope and remaining proof
Production delta against main baseline
5d8c25101e6726d64348ec014a3e2e8e7467884e: +70 lines; tests +208. The change removes crash-provenance scan selection and obsolete bypass-token transport. Growth supplies the missing runtime verification scheduling, retained attempt outcomes, and incident diagnostics through existing owners. Exact scoped test allocations total 208. No schema, configuration, or durability-setting change.Package Acceptance from released
[email protected]passed the published2026.11.1→ candidate2026.11.3updater flow in one 19m01s survivor attempt. Automatic migration, retained sessions/settings, Doctor, Gateway health/readiness/status assertions all passed. Its artifact is exact4fbe41602d2d757d09cd79c394f1ddfd2597ee96; package integrity and npm 12 installation also passed. The final test-only descendant changes no executable/package inputs, and the inspected archive excludes all four changed test/allocation paths. Embedded source metadata differs, so this is predecessor artifact proof with unchanged runtime inputs, not a final-head artifact claim. The first-hop post-core snapshot was unavailable, so no claim is made about that intermediate diagnostic. Historical lease and seal variants are covered by owner regressions; the package base scenario does not separately assert those variants. Production proof belongs to the next deployment.