Skip to content

fix(memory): avoid gateway crash loops on legacy index conflicts - #108652

Merged
steipete merged 1 commit into
mainfrom
codex/memory-sidecar-conflict-recovery
Jul 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/memory-sidecar-conflict-recovery

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #107220

What Problem This Solves

Fixes an issue where upgrades from the legacy Memory Core sidecar could leave Doctor and Gateway readiness in a permanent retry loop when stale metadata, chunk, cache, vector, or FTS rows collided with the current per-agent index.

Why This Change Was Made

Memory index tables are derived search state, so a same-identity mismatch now keeps the canonical per-agent row, rolls back the attempted sidecar merge, and archives the stale sidecar. Structural failures remain separate: orphan vector rows, incompatible vector dimensions, invalid schemas, and database setup failures still retain the sidecar and report a retryable warning.

This preserves the useful non-conflicting merge path while making the canonical-wins rule consistent across every derived index table.

User Impact

Affected operators can run Doctor or restart the Gateway normally without manually moving memory/main.sqlite. Canonical memory index rows remain intact, and repeated Doctor runs are idempotent.

Evidence

  • Focused Memory Core migration suite: 36/36 tests passed, covering metadata, chunk, cache, vector-row, and FTS collisions plus vector-dimension and orphan-reference negative cases.
  • Live operator flow on Blacksmith Testbox: released-state fixture, openclaw doctor --fix --yes --non-interactive, canonical SQLite before/after assertion, second Doctor run, Gateway start, and /readyz response {"ready":true,"failing":[]}. Run
  • Changed extension lanes passed: formatting, production and test typechecks, lint, Plugin SDK baseline, plugin boundaries, database-first guard, runtime-sidecar loader guard, and import-cycle check. Run
  • Fresh Codex autoreview returned no findings twice at 0.90 confidence.

AI-assisted: yes. I reviewed the ownership boundary, current and shipped behavior, related fixes, SQLite conflict/transaction contracts, tests, and the live operator path.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S maintainer Maintainer-authored PR labels Jul 16, 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: a70b051dc0

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

if (err instanceof LegacyMemoryRowsConflictError && err.tableName === "files") {
// Memory index rows are derived from canonical memory sources. Keep the
// current per-agent index and let normal sync rebuild any stale entries.
if (err instanceof LegacyMemoryDerivedRowsConflictError) {

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 Rebuild stale FTS rows before archiving

When the legacy sidecar conflicts only in fts (for example, the canonical chunk row matches but memory_index_chunks_fts.text is stale), this broad catch makes the sidecar archive-ready. The savepoint rollback discards the legacy FTS copy, ensureMemoryIndexSchema only backfills FTS when the table is empty, and searchKeyword reads from memory_index_chunks_fts, so keyword recall can stay wrong until a full/manual reindex instead of being repaired by doctor.

Useful? React with 👍 / 👎.

Comment thread CHANGELOG.md Outdated
@@ -41,6 +41,7 @@ Docs: https://docs.openclaw.ai

### Fixes

- **Memory Core legacy index recovery:** keep canonical per-agent search-index rows when stale legacy metadata, chunk, cache, vector, or FTS rows collide, archive the derived sidecar, and preserve retry warnings for structural vector errors so upgrades no longer leave Doctor and Gateway readiness in a permanent retry loop. Fixes #107220. Thanks @liewjiajun.

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.

P1 Badge Remove normal-fix changelog entry

Root AGENTS.md says CHANGELOG.md is release-only and “Do not edit for normal PRs, direct main fixes, or ship it; release generation owns it.” This is a normal Memory Core fix, so adding an Unreleased entry here creates release-note churn that the generator has to undo; please keep this context in the PR/body metadata instead.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/memory-sidecar-conflict-recovery branch from 84aefe3 to 5017beb Compare July 16, 2026 06:16
@steipete
steipete force-pushed the codex/memory-sidecar-conflict-recovery branch from 5017beb to 914f525 Compare July 16, 2026 06:21
@steipete
steipete merged commit 863443f into main Jul 16, 2026
84 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/memory-sidecar-conflict-recovery branch July 16, 2026 06:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
steipete added a commit that referenced this pull request Jul 18, 2026
Backport #108652 for the 2026.7.1 correction release.
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Jul 26, 2026
Backport openclaw#108652 for the 2026.7.1 correction release.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
Backport openclaw#108652 for the 2026.7.1 correction release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2026.7.1 gateway crash-loop: legacy memory sidecar meta/chunks conflicts are fatal while files conflicts auto-resolve

1 participant