Skip to content

fix: avoid agent database stalls after worker retirement - #194484

Merged
steipete merged 9 commits into
mainfrom
steipete/perf-micro-runtime-stale-lease-full-integrity-gate-20260919
Nov 11, 2026
Merged

steipete merged 9 commits into
mainfrom
steipete/perf-micro-runtime-stale-lease-full-integrity-gate-20260919

Conversation

@steipete

@steipete steipete commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

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 --timed passes all 38 selected gates. CI on 4fbe41602d2d757d09cd79c394f1ddfd2597ee96 exposed seven obsolete message assertions and one lifecycle fixture using the new foreground deadline. The test-only correction 560f907ff24cffc5bf9d26c19fb79768d2fce919 preserves 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 for 560f907ff24cffc5bf9d26c19fb79768d2fce919: all 73 selected jobs, including PostgreSQL conformance and openclaw/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.

Median owner metric Before After
Open wall time 8,225.46 ms 12.49 ms
Worker CPU 8,192.12 ms 7.72 ms
Process CPU during open 8,214.33 ms 16.20 ms
Sampled JavaScript allocation 23,028,664 B 1,244,048 B

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 parent 1f7035c15f3d6f89b7336c0d273ddcb18b8ff060, 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 published 2026.11.1 → candidate 2026.11.3 updater flow in one 19m01s survivor attempt. Automatic migration, retained sessions/settings, Doctor, Gateway health/readiness/status assertions all passed. Its artifact is exact 4fbe41602d2d757d09cd79c394f1ddfd2597ee96; 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.

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.
@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L labels Nov 7, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 7, 2026
@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The writer can remain occupied by another whole-file integrity scan, delaying queued requests.
  • After: Current-schema admission remains bounded, while the Gateway tracks the owed background verification independently of the worker.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful owner-level repair with native lifecycle coverage and supplied shipped upgrade evidence; no actionable code findings, with broad CI still pending.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; supplied native measurements cover stale-lease admission, and the successful published-upgrade job covers existing-state survival on the production-identical predecessor.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Session requests expire or queue behind repeated integrity scans when an agent database worker retires or stale leases are reclaimed.
Reason: The maintainer-approved direction removes repeated foreground scans while preserving explicit verification and quarantine contracts.

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
Reviewed head: 560f907ff24cffc5bf9d26c19fb79768d2fce919

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied upgrade scenario exercises the shipped updater and Gateway, while retirement followed by deferred-verification settlement is demonstrated through native owner tests rather than one recorded Gateway scenario.
Agent review details

How this fits together

Agent 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4464e6f adds src/state/agent-database-startup-integrity.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4464e6f09830; files: src/state/agent-database-startup-integrity.ts)

PR surface

Source +70, Tests +208, Docs +22, Other +149. Total +449 across 66 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 24 505 435 +70
Tests 37 676 468 +208
Docs 1 103 81 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 4 178 29 +149
Total 66 1462 1013 +449

Preflight source

Source 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

Metric Value Why it matters
Production versus test growth Production net +70 lines; tests/support net +208 lines Growth adds verification scheduling and settlement through existing owners, with distinct crash, replacement, cancellation, quarantine, and compatibility coverage.

Labels

Label changes:

  • add merge-risk: 🚨 session-state: Broadens bounded admission for existing session storage; the maintainer explicitly accepts the interval before background detection of untouched corruption.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Addresses substantial session delays on large agent databases after lease cleanup or worker retirement.
  • merge-risk: 🚨 session-state: Broadens bounded admission for existing session storage; the maintainer explicitly accepts the interval before background detection of untouched corruption.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-07T05:35:12.499Z sha 661a683 :: blocked before merge. :: none

Reviewed November 11, 2026, 2:04 PM ET / 19:04 UTC (Revision 2).

@steipete
steipete marked this pull request as ready for review November 7, 2026 05:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T18:43:24.251790Z 560f907 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XL and removed size: L labels Nov 7, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 112 to 114
if (!staleLease && url === startupUrl && values.arm === "baseline") {
assert(values["baseline-source"], "Baseline needs --baseline-source");
source = readFileSync(values["baseline-source"], "utf8");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.
Merge current main 8480230, including the required 75694cc fix. Keep final version rejection at canonical persistence admission, explicitly verify FTS corruption in Doctor fixtures, and allocate exactly 51 test lines.
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.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
@steipete
steipete merged commit 0e966cc into main Nov 11, 2026
197 of 201 checks passed
@steipete
steipete deleted the steipete/perf-micro-runtime-stale-lease-full-integrity-gate-20260919 branch November 11, 2026 19:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…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
obviyus added a commit that referenced this pull request Nov 12, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…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]>
RomneyDa added a commit that referenced this pull request Nov 14, 2026
…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)
RomneyDa pushed a commit that referenced this pull request Nov 15, 2026
…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]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant