Repository navigation
fix(memory): back off failed full reindexes - #138786
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 maintainer review before merge. What this changesThis PR adds exponential cooldowns after failed full memory rebuilds while preserving published-index searches and targeted session updates. Example: Four memory searches follow a failed document-embedding request to Ollama using nomic-embed-text.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a current retry-scheduling defect, has relevant live proof, and has no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherMemory Core accepts search and synchronization requests, prepares memory files and session transcripts, and publishes replacement SQLite indexes for subsequent recall. flowchart LR
A[Memory search] --> B[Published index]
A --> C[Sync owner]
C --> D[Retry cooldown]
D --> E[Embedding provider]
E --> F[Shadow publication]
F --> B
Technical reviewBest possible solution: Land the existing sync-owner cooldown while retaining revision fencing, keyword bootstrap, and explicit repair behavior. Do we have a high-confidence way to reproduce the issue? Current source shows failed full rebuilds rearming without a deadline, and the supplied Gateway baseline demonstrates repeated attempts; this review ran no target code. Is this the best way to solve the issue? The repair belongs at the shared sync owner, where it covers detached maintenance and automatic identity recovery without weakening publication safety. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 699636375966. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +94, Tests +234, Docs +6. Total +334 across 15 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 (8 earlier review cycles)
Reviewed October 10, 2026, 3:37 AM ET / 07:37 UTC (Revision 9). |
607df28 to
411a5b4
Compare
|
Updated on The earlier P2 is fixed: successful source-wide sessions-only recovery clears the failed-rebuild streak, and a failed retry advances its deadline. Automatic missing-metadata and older-runtime identity repair now respects that deadline. Explicit non-force CLI identity repair still runs immediately. Direct serving-manager proof uses repeated real Validation: 64/64 focused Memory Core sibling tests passed (148.79s wall); the final CLI/search suite passed 4/4 (16.49s wall). Final The PR body now carries the current problem, behavior, and evidence. Please review this head against the revised proof. |
411a5b4 to
94ccf0c
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Why: failed shadow rebuilds could retry on every search, sessions-only recovery could retain an expired streak, and the cooldown could silently discard queued session updates. A thrown deferred pass could also poison the next sync outcome. What: keep a process-local cooldown and deferred failure outcome through detached maintenance; settle sessions-only retries; preserve explicit CLI repair; admit targeted session updates without selecting unrelated full rebuilds; clear a deferred marker when a sync throws. Evidence: queued-session regression failed before the repair and passes for both force modes through the published SQLite index; ledger regression failed before the catch reset and now passes. Focused suites 7/7 and 45/45 passed, changed-file gate passed, and fresh independent review found no actionable issue.
94ccf0c to
2fcddff
Compare
|
@clawsweeper re-review The P1 queued-session finding is repaired at head The new queue-boundary regression waits for an in-flight failed rebuild, submits a session update through Validation: 7/7 cooldown/ledger tests (39.44 seconds wall), 45/45 neighboring recovery and queue tests (73.13 seconds wall), extension typechecks, and the full changed-file gate passed. Fresh independent review found no remaining actionable issue. This is isolated real-manager/SQLite proof with synthetic workspace data; no live Gateway or credentials were used, so the original sustained-load latency claim remains unverified on a real installation. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* fix(memory): back off failed full reindexes Why: failed shadow rebuilds could retry on every search, sessions-only recovery could retain an expired streak, and the cooldown could silently discard queued session updates. A thrown deferred pass could also poison the next sync outcome. What: keep a process-local cooldown and deferred failure outcome through detached maintenance; settle sessions-only retries; preserve explicit CLI repair; admit targeted session updates without selecting unrelated full rebuilds; clear a deferred marker when a sync throws. Evidence: queued-session regression failed before the repair and passes for both force modes through the published SQLite index; ledger regression failed before the catch reset and now passes. Focused suites 7/7 and 45/45 passed, changed-file gate passed, and fresh independent review found no actionable issue. * fix(memory): preserve deferred outcomes across publication scope * style(memory): format reindex cooldown condition * fix(memory): advance backoff after explicit rebuild failures * style(memory): clear backoff lint findings * fix(memory): preserve keyword bootstrap through retry cooldown * fix(memory): honor backoff during automatic provider recovery * docs(memory): separate rebuild cooldown from chunk retention --------- Co-authored-by: Peter Steinberger <[email protected]>
Retain the remaining raw-byte behavior from local8039fc5195d on upstreamf91bca9546f5. The host fs-safe append option recognizes leadingLF only; a proposed delta beginning withCR orCRLF must not receive an extraLF. Apply the same separator decision in sandbox writes and provenance contentAfter without changing replay rejection, source authority or path guards. Do not replay the old aggregate maintenance/routing patch: upstream#168123 owns duplicate-note rejection,openclaw#138786 reindex backoff,openclaw#168471 and8fc0987fb08 Gateway CLI recall routing,openclaw#168860/openclaw#171322 worker-owned memory publication and admission. Raw proposed Markdown remains verbatim; no prefix stripping or normalized-offset mapping is retained. Proof: four actual host/sandbox wrapper cases fail before the repair, then24tests pass including replay rejection, authority revocation and exact provenance/disk bytes forCRLF,CR,indentation,hard-break spaces and non-BMP text. Targeted agents-root types,scoped lint,format andline-cap pass; fresh independentP0-P2 review scoped-clean. Full candidate build,Doctor andactivation remain separate gates. Related:openclaw#125309. Local-Feature: memory-append-raw-separators Semantic-Source: 39a740d Upstream-Tracking: openclaw#125309 Drop-When: Upstream host/sandbox append and provenance preserve leading CR and CRLF bytes. Rebase-Base: ed9d493
Retain the remaining raw-byte behavior from local8039fc5195d on upstreamf91bca9546f5. The host fs-safe append option recognizes leadingLF only; a proposed delta beginning withCR orCRLF must not receive an extraLF. Apply the same separator decision in sandbox writes and provenance contentAfter without changing replay rejection, source authority or path guards. Do not replay the old aggregate maintenance/routing patch: upstream#168123 owns duplicate-note rejection,openclaw#138786 reindex backoff,openclaw#168471 and8fc0987fb08 Gateway CLI recall routing,openclaw#168860/openclaw#171322 worker-owned memory publication and admission. Raw proposed Markdown remains verbatim; no prefix stripping or normalized-offset mapping is retained. Proof: four actual host/sandbox wrapper cases fail before the repair, then24tests pass including replay rejection, authority revocation and exact provenance/disk bytes forCRLF,CR,indentation,hard-break spaces and non-BMP text. Targeted agents-root types,scoped lint,format andline-cap pass; fresh independentP0-P2 review scoped-clean. Full candidate build,Doctor andactivation remain separate gates. Related:openclaw#125309. Local-Feature: memory-append-raw-separators Semantic-Source: 39a740d Upstream-Tracking: openclaw#125309 Drop-When: Upstream host/sandbox append and provenance preserve leading CR and CRLF bytes. Rebase-Base: ed9d493
Retain the remaining raw-byte behavior from local8039fc5195d on upstreamf91bca9546f5. The host fs-safe append option recognizes leadingLF only; a proposed delta beginning withCR orCRLF must not receive an extraLF. Apply the same separator decision in sandbox writes and provenance contentAfter without changing replay rejection, source authority or path guards. Do not replay the old aggregate maintenance/routing patch: upstream#168123 owns duplicate-note rejection,openclaw#138786 reindex backoff,openclaw#168471 and8fc0987fb08 Gateway CLI recall routing,openclaw#168860/openclaw#171322 worker-owned memory publication and admission. Raw proposed Markdown remains verbatim; no prefix stripping or normalized-offset mapping is retained. Proof: four actual host/sandbox wrapper cases fail before the repair, then24tests pass including replay rejection, authority revocation and exact provenance/disk bytes forCRLF,CR,indentation,hard-break spaces and non-BMP text. Targeted agents-root types,scoped lint,format andline-cap pass; fresh independentP0-P2 review scoped-clean. Full candidate build,Doctor andactivation remain separate gates. Related:openclaw#125309. Local-Feature: memory-append-raw-separators Semantic-Source: 39a740d Upstream-Tracking: none (no upstream issue or PR tracks CR-led append separators); related openclaw#125309 (closed completed 2026-10-24, memory-maintenance scope) Drop-When: Upstream host/sandbox append and provenance preserve leading CR and CRLF bytes. Rebase-Base: 0220489
What Problem This Solves
Failed full memory rebuilds can retry on every search, repeatedly hitting an unavailable local embedding server while the published index is still usable.
User Impact
Automatic full-rebuild retries wait 30 seconds after failure, double the delay on repeated failures, and cap it at 30 minutes. Searches keep reading the published index. Queued session updates can publish against a valid index during cooldown, and explicit CLI repair remains immediate. A successful rebuild resets the process-local schedule.
Optional-provider failures still permit the first distinct keyword-only publication. If that publication also fails, subsequent attempts honor its deadline. Automatic provider recovery requests a full rebuild without bypassing cooldown when the separate provider-probe cache expires.
Why This Change Was Made
The existing retry state carries the deadline and failed generation kind through detached maintenance. Each sync pass returns its outcome through the existing ledger, so deferred or targeted work cannot erase an outstanding rebuild failure. The full-rebuild failure owner advances the schedule once per failed attempt, including explicit retries. Worker-owned publication, semantic-index protection, and the one-shot revision-conflict retry are preserved.
The PR retains @Grynn's original commit and removes the separate deferred-manager API, mutable ledger marker, and overlapping recovery tests. Production is +128/-34 (net +94), tests/support +257/-23, and docs +6/-0: +391/-57 overall, reduced from +441/-26. The production growth supplies retry timing and per-pass outcomes at the existing owners; no schema or public configuration is added.
Main through
bc8f693df3aee184c65626f7e9c9c58889c51a8bis merged, including query-based health probes and EmbeddingGemma format-upgrade selection and metadata.Fixes #138775
Evidence
Real Ollama
nomic-embed-textis exercised through an isolated Gateway on port 19228 and itsPOST /tools/invokememory_searchendpoint. A logging proxy injects HTTP 400 only for a synthetic document's embedding; embedding caching is disabled.provider: "none"anddebug.embeddingBootstrap.degradedTo: "keyword-only"while document embeddings failed. After restoration, retrieval usedprovider: "openai", modelnomic-embed-text, and vector score 0.703926. The adapter routed to real Ollama/v1; two failed document requests covered startup/background and the later bootstrap.Session updates use the canonical session SDK and are checked through memory retrieval after successful rebuild recovery. The earlier optional
sessions_historylookup did not resolve the synthetic session and is not passing proof. New turns are not claimed searchable during the incompatible-index cooldown.Live entry point:
pnpm openclaw --profile memory-sync-backoff gateway run --port 19228 --bind loopback --auth none, with isolatedOPENCLAW_STATE_DIRandOPENCLAW_CONFIG_PATH, followed by the Gateway tool endpoint. This tests memory indexing and retrieval with real local embeddings. Runtime proof used source headf42ffe85a73099c91227826bb2842da783fb7ba2, Ollama 0.40.2, and Node 26.11.1. Final head55c30ff66dcc7180d5424e781300810fe00c40c4changes only the placement of the same cooldown documentation so it composes cleanly with the separately reviewed session-append fix; runtime evidence is reused for that prose-only delta.Validation
The missing/older-identity regressions failed on main at the second search (expected one embedding attempt, observed two; 203.89 seconds wall). Review also exposed keyword-bootstrap suppression and an automatic optional-provider force call bypassing the longer deadline. Those paths were reproduced before correction; the latter made a third request before the 60-second deadline (expected two; 177.77 seconds wall).
Integrated head: 88/88 tests passed in five files, 905.54 seconds wall, using
node scripts/run-vitest.mjs <files> --maxWorkers=1: backoff, FTS-only reindex, provider lifecycle, search upgrades, and index identity. This includes required/optional exponential schedules, first/background bootstrap, failed keyword publication, queued session publication, and the new EmbeddingGemma upgrade path.The preceding eight-file run passed 115/115, including all six failures from the first CI cycle: late shadow recovery, worker overload, redaction recovery, detached rebuild warnings, and bootstrap/close behavior. Wall time was 1696.61 seconds.
Final batch test-execution cost: backoff 90.00 seconds; FTS-only reindex 52.64 seconds. These use the real manager and SQLite publication workers to catch lost retry state and blocked publication; a timer-only unit test cannot cover those handoffs. The clock is mocked, with no added sleeps, polling, or per-test Gateway boots. Shared-host load and worker compilation contributed to wall time; batch transform/import/setup accounted for roughly half the run.
Scoped lint passed (739.86 seconds, including package declarations); production/test type lanes passed (28.73/35.97 seconds). Max-lines, line-cap, assertion-safety, test-timeout-race, test-mock-exports, config-docs, and plugin-inventory checks passed. Formatting and
git diff --checkpassed.Full
pnpm buildpassed in 3716.53 seconds under Node 26.11.1. The first run compiled successfully but failed CLI metadata after 3300.10 seconds because concurrent host package maintenance removed a library needed by its older Node process; the normal recovery rebuilt under the current Node version. Tests used Node 26.10. No cache validation was bypassed. The successful build printed an unrelated UI startup-size diagnostic; this PR changes no UI code.Fresh independent Codex review: scoped-clean through P2 on final head
55c30ff66dcc7180d5424e781300810fe00c40c4, with no accepted/actionable findings.Final exact-head hosted checks: CI run 38033977577 passed (41 jobs succeeded, 26 skipped), and
openclaw/ci-gatepassed. The four changed-extension bundles took 199–247 seconds each (926 aggregate job-seconds, including setup and sibling tests; not an isolated cost for these regressions). ClawSweeper reviewed55c30ff66dcc7180d5424e781300810fe00c40c4: 5/6 for readiness, proof, and patch quality, with no findings or Before merge items.