Skip to content

fix(memory): preserve session indexing during full reindex#39732

Merged
altaywtf merged 2 commits into
openclaw:mainfrom
upupc:fix/session-full-reindex-sync
Apr 1, 2026
Merged

fix(memory): preserve session indexing during full reindex#39732
altaywtf merged 2 commits into
openclaw:mainfrom
upupc:fix/session-full-reindex-sync

Conversation

@upupc

@upupc upupc commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix session-memory gating so full reindexes still rebuild session transcripts even when the sync reason is session-start or watch.

Problem

shouldSyncSessions() currently returns false for session-start and watch before checking needsFullReindex:

if (params?.force) return true;
const reason = params?.reason;
if (reason === "session-start" || reason === "watch") return false;
if (needsFullReindex) return true;

That means a full reindex triggered from those reasons can rebuild memory files while skipping session files entirely. In practice, this can clear previously indexed session transcripts and leave sources: ["memory", "sessions"] configured while sessions stays at 0 indexed files.

Fix

Reorder the checks so full reindexes always allow session syncing:

  • force => sync sessions
  • needsFullReindex => sync sessions
  • only skip session-start / watch for non-reindex incremental syncs

Tests

Added src/memory/manager.session-reindex.test.ts to verify:

  • session-start + needsFullReindex => true
  • watch + needsFullReindex => true
  • session-start + incremental => false
  • watch + incremental => false

Also ran:

pnpm exec vitest run src/memory/manager.session-reindex.test.ts src/memory/manager.atomic-reindex.test.ts

Both tests pass locally.

@greptile-apps

greptile-apps Bot commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug in shouldSyncSessions() where a full reindex triggered by session-start or watch would incorrectly skip rebuilding session transcripts, potentially leaving the sessions source at 0 indexed files despite being configured.

The fix is a minimal 3-line reorder: the needsFullReindex guard now runs before the session-start/watch early return, so full reindexes always include session syncing regardless of trigger reason. The four key combinations are covered by the new test file.

Confidence Score: 5/5

  • This PR is safe to merge — the change is minimal, well-reasoned, and covered by targeted tests.
  • The fix is a simple 3-line reorder that directly addresses the described bug. The logic change is clearly correct: needsFullReindex should be checked before reason-based early returns, and all four key behavioral combinations are validated by the new test. No regressions are introduced.
  • No files require special attention.

Last reviewed commit: 1ab2289

@altaywtf altaywtf self-assigned this Mar 29, 2026
@altaywtf altaywtf force-pushed the fix/session-full-reindex-sync branch from 1ab2289 to 2317f16 Compare March 29, 2026 16:54
@openclaw-barnacle openclaw-barnacle Bot added the extensions: memory-core Extension: memory-core label Mar 29, 2026
@altaywtf altaywtf force-pushed the fix/session-full-reindex-sync branch 2 times, most recently from 75028f6 to 4cd9d0d Compare April 1, 2026 10:03
@altaywtf altaywtf force-pushed the fix/session-full-reindex-sync branch from 4cd9d0d to 0dbaf5f Compare April 1, 2026 10:09
@altaywtf altaywtf merged commit d766bfc into openclaw:main Apr 1, 2026
8 checks passed
@altaywtf

altaywtf commented Apr 1, 2026

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @upupc!

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…39732)

Merged via squash.

Prepared head SHA: 0dbaf5f
Co-authored-by: upupc <12829489+upupc@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…39732)

Merged via squash.

Prepared head SHA: 0dbaf5f
Co-authored-by: upupc <12829489+upupc@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…39732)

Merged via squash.

Prepared head SHA: 0dbaf5f
Co-authored-by: upupc <12829489+upupc@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…39732)

Merged via squash.

Prepared head SHA: 0dbaf5f
Co-authored-by: upupc <12829489+upupc@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants