Skip to content

fix(memory): prevent session indexing starvation and retry stalled passes - #170719

Merged
steipete merged 2 commits into
mainfrom
dbasync/memqueue2
Oct 13, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/memqueue2

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Memory indexing can remain stale indefinitely during back-to-back turns because each idle transition resets the age of pending work. A handled embedding-provider fallback failure can also leave dirty sessions without a scheduled retry.

Related: #170404.

User Impact

Pending sessions become eligible in the next idle gap once their oldest change reaches five minutes. Failed passes retry after 1, 5, and 15 minutes; after that, fresh transcript or turn activity resumes retries. Running turns keep priority, and search/shutdown still do not force a flush.

Why This Change Was Made

The existing session queue remains the single owner. Preserve its oldest-pending timestamp across turns, keep its bounded eight-session groups and foreground yielding, and retain failed targets alongside updates arriving during a pass. Handled fallback failures and full-rebuild cooldown deferrals now notify the queue explicitly instead of looking like completed work. A provider switch requests the existing full-rebuild path so retries can replace the old embedding identity before targeted writes resume.

Accepted edge cases: a turn already running at the five-minute deadline delays indexing until an idle gap; a turn starting during indexing may overlap the current bounded group. Provider failures can extend freshness beyond five minutes. The existing full-rebuild cooldown can reach 30 minutes and outlast the bounded automatic retry series; pending work remains queued and fresh activity restarts retries. Coordinating those two cooldown deadlines is a P2 follow-up. No new fencing, admission checks, SQL, schema, or SDK surface.

Evidence

Fake-clock regressions cover back-to-back turns, overdue long-running turns, thrown-failure target retention, and handled-fallback backoff/exhaustion/activity recovery. The latter drives the existing targeted-sync failure handler and the real full-rebuild cooldown path. The old long-turn test now asserts the five-minute contract instead of restarting a quiet period.

Metric Before After
T1 calls in the changed scheduler/sync owner files 0 0
SQL statements / worker requests added per existing pass — 0 / 0
Warmed-turn measurement Not run Not run (compute-conservation behavior follow-up)

Retries intentionally schedule previously stranded background work; there is no claimed whole-workload reduction. No SQL harness, local suites, or remote lease: this is a scheduling-only follow-up. Basic changed-file formatting/lint and diff checks run locally; PR CI owns fake-clock tests, types, lint, Knip, Madge, and database ratchets. No update cell applies: no update, Doctor, migration/schema, plugin-loading, or service-lifecycle change.

Direct changed-file oxlint, oxfmt, and git diff --check passed. The type-aware lint wrapper timed out preparing SDK declarations on the loaded host; CI owns type-aware validation. Two Codex autoreview rounds: scoped clean through P2. Initial CI caught a one-millisecond drift in the new retry test after the simulated busy turn; the test now measures each expected delay from the observed attempt timestamp. Final-head changed-extension tests passed in CI run 38357588765: 76 seconds for the test step, 137 seconds for its job. The final-head CI run passed completely, including production/test types, type-aware lint, source contracts, additional boundaries, and database worker/dialect ratchets. No inherited-failure exception was needed. The local single-case replay was stopped after CI passed because worker preparation/imports consumed about 15 minutes on the loaded host; no local test pass is claimed. Diff: 5 files, production +58/-19 lines; tests +89/-4; docs +8/-3.

@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: S labels Oct 13, 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: f9e31f28cc

ℹ️ 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".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T06:39:43.127396Z 25f6247 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.

@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: 25f6247442

ℹ️ 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".

@steipete

Copy link
Copy Markdown
Contributor Author

The deferred-pass issue is fixed in 25f6247: the full-rebuild cooldown now explicitly requests a session queue retry, and the fake-clock regression exercises that path.

Follow-up for the remaining P2: the existing full-rebuild cooldown can reach 30 minutes and outlast the bounded 1/5/15-minute retry budget. Pending transcripts remain queued, and fresh activity restarts retries, as documented. Keep the requested retry series bounded; coordinating its deadline with the longer rebuild cooldown can be handled separately.

@steipete
steipete merged commit c08eebe into main Oct 13, 2026
100 of 102 checks passed
@steipete
steipete deleted the dbasync/memqueue2 branch October 13, 2026 06:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…sses (openclaw#170719)

Preserve the oldest pending session change across turn boundaries so overdue indexing can start in the next idle gap. Retain failed work and retry after 1, 5, and 15 minutes, while preserving foreground priority and existing bounded indexing groups.

Keep full-rebuild cooldown deferrals queued and request a full rebuild after an embedding-provider switch. Add fake-clock coverage and document freshness and retry limits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant