Repository navigation
Conversation
…earch A failed detached search-triggered maintenance run (for example a publish revision conflict while a full reindex was building under concurrent writes) restores the dirty generation on the serving manager. Because search-triggered sync is enabled by default with no cooldown or single-flight guard, the very next memory search could immediately launch another detached full rebuild that loses the same revision race, repeating forever. Each attempt rebuilds a multi-GB shadow database, spiking gateway memory usage and degrading responsiveness. Defer and coalesce these retries at the serving maintenance owner: a new gate single-flights concurrent search-triggered attempts into the in-flight one and defers retries behind an escalating cooldown (30s doubling up to 15 minutes) after a failure, resetting after a successful run. Dirty state stays owned by the serving manager so a later search still recovers once writes settle. Fixes openclaw#135754
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 12:04 AM ET / 04:04 UTC. ClawSweeper reviewWhat this changesThe branch adds a per-manager single-flight and exponential-cooldown gate for detached search-triggered Memory Core index maintenance, with regression coverage for failed, incomplete, and recovered maintenance. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 6 items remain Keep open: the retry gate addresses the reported relaunch path and fixes the prior resolved-but-dirty gap, but the PR would auto-close a broader issue it explicitly leaves partially unresolved and still lacks real behavior proof. Priority: P1 Review scores
Verification
How this fits togetherMemory Core serves agent memory searches from a SQLite-backed index. Searches can request detached maintenance to refresh a dirty index; this change decides whether a retry may start or must wait. flowchart LR
Search[Memory search] --> Serving[Serving index manager]
Serving --> Gate[Retry and single-flight gate]
Gate --> Maintenance[Detached maintenance manager]
Maintenance --> Publish[Publish refreshed index]
Maintenance --> Restore[Restore dirty generation]
Restore --> Gate
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +67, Tests +229. Total +296 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the serving-manager retry gate, change the broad issue reference to non-closing linkage, and attach a redacted post-fix runtime trace that shows conflict, suppression during cooldown, and later recovery. Do we have a high-confidence way to reproduce the issue? Yes, from source: a revision-conflict rebuild restores dirty retry state while each subsequent dirty search schedules detached maintenance. The review did not execute the external contributor’s branch. Is this the best way to solve the issue? Yes for the retry defect: the serving manager owns both the search trigger and retry state, while the existing publication conflict protection remains intact. The issue linkage and real-runtime proof still need correction. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4e36c68976a9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
A detached search maintenance can resolve while its manager stays dirty (for example a keyword-only provider fallback): the generation is restored to the serving manager and an incomplete reason is reported instead of throwing. The retry gate treated that as a success and reset its cooldown, so the next search could immediately relaunch a full rebuild. Count an incomplete outcome as a failure for the escalating cooldown, and reset the escalation only after an attempt fully clears the handed-off generation. Move the retry-gate regressions into a dedicated test file and add coverage driving the public search() path, including an end-to-end case where the real detached maintenance generation publishes new content without any maintenance-manager stub. Addresses review feedback for openclaw#135754
|
Thanks @LiuwqGit — I rechecked the reported write → search → detached full-reindex order on current Current Exact-main proof used real SQLite state and the public The anti-cheat check also passed: the existing privacy-purge race test still makes a stale full reindex fail when The proposed cooldown is also local to one manager, while command-line and Gateway memory searches use fresh transient managers. Its added tests do not cover that cross-manager surface or reproduce a real concurrent-write revision conflict. Closing this PR as superseded by the current-main coordination fix. #135754 stays open for its separate source-selection and deleted-archive concerns. |
What Problem This Solves
Under sustained concurrent writes to a single agent's memory index, a full reindex reliably loses its publish race ("Memory index changed while full reindex was building ... retry the full reindex"). The failed detached maintenance restores the dirty generation on the serving manager, and because search-triggered sync is enabled by default with no cooldown or single-flight guard, the very next memory search immediately launches another detached full rebuild — repeating forever with no backoff. Each attempt writes a fresh multi-hundred-MB shadow database, climbing gateway memory and degrading responsiveness (issue reports
memory pressure: level=warning,slow SQLite transaction hold, and WebSocket probe timeouts).Fixes #135754
Why This Change Was Made
syncPublishedIndexInBackgroundhanded the dirty generation to a new detached maintenance manager on every search, with no record of a recent failure and no coalescing of concurrent triggers.MemorySearchMaintenanceRetryGatesingle-flights concurrent search-triggered attempts into the in-flight one, and after a failure defers the next detached attempt behind an escalating cooldown (30 s doubling, capped at 15 min).sync.*knobs.rememberAcrossConversationsadding asessionssource on top ofsources: ["memory"], and deleted-archive indexing policy.User Impact
openclaw memory index --force, watcher, interval, targeted session syncs) are untouched — only search-triggered detached maintenance is gated.Evidence
Real environment tested: yes (local repo worktree; the suite exercises real SQLite databases through the extension harness, including an end-to-end case with no maintenance-manager stub that drives the public
search()API through a real detached maintenance generation)Exact steps or commands run after this patch:
Evidence after fix: five regressions pass, covering coalescing, failure cooldown, incomplete-outcome cooldown, real end-to-end publish, and search-driven cooldown recovery.
Observed result after fix: single-flight coalescing, failure and incomplete-outcome cooldowns, and later recovery all verified through the public
search()path.search(): a dirty serving manager's first search hands the generation to a detached maintenance manager; a failed attempt restores dirty state and the immediately following search acquires no new maintenance manager; after the cooldown a later search retries and clears dirty state plus the last sync error. The end-to-end case with no stubs shows the real detached generation publishing new content that becomes searchable.What was not tested: sustained multi-GB concurrent-write load was not reproduced locally; the retry scheduling behavior at the serving owner was verified from source. Full CI lanes (
pnpm test:extension memory-core,pnpm check:test-types) run on GitHub Actions.