Skip to content

fix(memory): keep rollbacks compatible after recall metadata upgrade - #116003

Merged
fuller-stack-dev merged 2 commits into
mainfrom
codex/fix-memory-schema-rollback
Jul 29, 2026
Merged

fuller-stack-dev merged 2 commits into
mainfrom
codex/fix-memory-schema-rollback

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Closes #116002

AI-assisted change.

What Problem This Solves

Fixes an issue where users rolling back after the memory recall metadata upgrade could have every registered agent database rejected by the prior binary, leaving the gateway in a persistent restart loop.

Why This Change Was Made

Recall metadata now lives in a new additive child table instead of changing the canonical memory_index_chunks table. Provenance writers remain explicit, the legacy chunk trigger is removed, and current-main databases are migrated transactionally without a schema-version bump. Older binaries can ignore the new tables during rollback.

User Impact

Operators can upgrade and roll back without manually repairing each agent database. Existing recall metadata, chunk rows, and provenance are preserved.

Evidence

  • Focused Vitest proof: 40 tests passed across memory schema, current-version migration, doctor repair, and memory publication.
  • Full changed-surface gate passed after the final patch: generated schema checks, SDK contracts, core/extension typechecks, lint, database guards, and import-cycle checks.
  • Real database proof: migrated a copy of the affected 2,040-chunk Wilfred database; chunk/provenance row counts were preserved, PRAGMA quick_check returned ok, foreign-key checks returned zero violations, and the prior deployed f2293566896f schema checker accepted the result.
  • Autoreview: clean after preserving the null-metadata reader contract; no accepted/actionable findings remain.
  • Duplicate search: no existing open PR or issue matched the rollback failure or proposed side-table repair.

Regression context: the inline metadata columns and provenance trigger landed in #114819.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core commands Command implementations size: XL maintainer Maintainer-authored PR labels Jul 29, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 1:03 PM ET / 17:03 UTC.

ClawSweeper review

What this changes

The branch moves recall metadata from the canonical memory chunk table into an additive SQLite child table, migrates existing inline metadata and provenance-trigger state, and updates memory reads, writes, publication, and doctor repair paths.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for maintainer review. It addresses the linked rollback restart-loop regression with a rollback-safe storage shape, has recorded real-database and prior-binary acceptance evidence, and should be revalidated on the refreshed merge result because it changes persistent agent-memory schema behavior.

Priority: P1
Reviewed head: d2fd18233b25e468a9e2637fe7e5e5c4d3d42b19

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong rollback-specific proof and a focused compatibility design support merge review; the final merge result still needs the recorded rollback proof refreshed against current main.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR records an after-fix migration of an affected copied database, preserved row counts, successful integrity and foreign-key checks, and acceptance by the cited prior deployed schema checker; redact database paths or other private details in any further posted artifacts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR records an after-fix migration of an affected copied database, preserved row counts, successful integrity and foreign-key checks, and acceptance by the cited prior deployed schema checker; redact database paths or other private details in any further posted artifacts.
Evidence reviewed 6 items Rollback-safe schema shape: The proposed schema restores memory_index_chunks to its prior ten-column canonical shape and places importance, triggers, and project key in memory_index_chunk_recall_metadata, an additive child table with a chunk foreign key.
Current runtime migration boundary: The agent-database migration detects legacy inline recall metadata or the former provenance trigger, performs the memory-owned migration, then revalidates the canonical agent schema before continuing.
Reader and writer coverage: The diff updates memory writers, publication, and recall readers to write and left-join the new child table, preserving null metadata behavior when rows are absent.
Findings None None.
Security None None.

How this fits together

Memory Core stores indexed chunks and recall metadata in each agent’s SQLite database. Gateway startup and doctor maintenance validate that database before the agent can run, while memory recall and publication consume the metadata after migration.

flowchart LR
  A[Existing agent database] --> B[Startup or Doctor]
  B --> C[Memory schema migration]
  C --> D[Canonical chunk table]
  C --> E[Additive recall metadata table]
  D --> F[Memory publication]
  E --> G[Recall ranking and curation]
  F --> H[Gateway startup]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - This is a persistent SQLite compatibility change: the branch must retain both current-version migration behavior and prior-binary acceptance after rebasing onto current main before merge.
  • Resolve merge risk (P1) - The PR head is behind the current main SHA, so the final merge result—not only the reviewed head—needs the focused migration and rollback acceptance proof.
  • Complete next step (P2) - A member-authored, maintainer-labeled persistent-schema change needs maintainer review of the refreshed merge result rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source +102, Tests +129, Generated -6, Other +1. Total +226 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 14 261 159 +102
Tests 7 376 247 +129
Docs 0 0 0 0
Config 0 0 0 0
Generated 2 15 21 -6
Other 1 1 0 +1
Total 24 653 427 +226

Review metrics

Metric Value Why it matters
Persistent schema contract 1 canonical table narrowed; 1 additive metadata table introduced; 1 legacy trigger removed These coupled persistent-state changes are the compatibility boundary that determines whether operators can safely roll back.

Stored data model

Persistent data-model change detected: database schema: packages/memory-host-sdk/src/host/memory-recall-metadata.test.ts, database schema: packages/memory-host-sdk/src/host/memory-schema-recall.ts, database schema: src/commands/doctor-agent-memory-schema.test.ts, database schema: src/state/openclaw-agent-schema.generated.ts, database schema: src/state/openclaw-agent-schema.sql, database schema: src/state/openclaw-agent-standing-intents-schema.test.ts, and 38 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Refresh rollback proof on the merge result (recommended)
    Rebase onto current main and rerun the focused current-schema migration plus prior-binary acceptance proof against the exact merge result before landing.
  2. Accept the recorded compatibility contract
    Merge only if maintainers accept the additive-table/no-version-bump contract and the refreshed required checks confirm the merge result preserves it.

Technical review

Best possible solution:

Land the additive child-table migration only after the current merge result proves that upgraded databases preserve recall/provenance data, validate under current code, and remain accepted by the referenced prior binary.

Do we have a high-confidence way to reproduce the issue?

Yes, from the supplied current-path evidence: create an agent database with the cited prior binary, initialize recall metadata with the regressing schema, then roll back to the prior schema validator; the linked issue reports the resulting startup rejection and restart loop.

Is this the best way to solve the issue?

Yes. Moving the optional recall fields into an additive child table is the narrowest compatible repair because it restores the old canonical chunk-table contract while retaining current recall metadata through explicit readers and writers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 814b9f6e36f3.

Labels

Label justifications:

  • P1: The linked regression can reject every affected agent database during rollback and leave the gateway in a restart loop.
  • merge-risk: 🚨 compatibility: The patch changes the on-disk agent SQLite shape specifically to support old-binary rollback behavior.
  • merge-risk: 🚨 session-state: Recall metadata and provenance are durable per-agent memory state that must survive migration intact.
  • merge-risk: 🚨 availability: Agent database validation occurs before gateway startup, so an invalid migration can prevent the gateway from running.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR records an after-fix migration of an affected copied database, preserved row counts, successful integrity and foreign-key checks, and acceptance by the cited prior deployed schema checker; redact database paths or other private details in any further posted artifacts.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR records an after-fix migration of an affected copied database, preserved row counts, successful integrity and foreign-key checks, and acceptance by the cited prior deployed schema checker; redact database paths or other private details in any further posted artifacts.

Evidence

What I checked:

  • Rollback-safe schema shape: The proposed schema restores memory_index_chunks to its prior ten-column canonical shape and places importance, triggers, and project key in memory_index_chunk_recall_metadata, an additive child table with a chunk foreign key. (packages/memory-host-sdk/src/host/memory-schema-recall.ts:4, d2fd18233b25)
  • Current runtime migration boundary: The agent-database migration detects legacy inline recall metadata or the former provenance trigger, performs the memory-owned migration, then revalidates the canonical agent schema before continuing. (src/state/openclaw-agent-db-schema.ts:95, d2fd18233b25)
  • Reader and writer coverage: The diff updates memory writers, publication, and recall readers to write and left-join the new child table, preserving null metadata behavior when rows are absent. (packages/memory-host-sdk/src/host/memory-recall-metadata.ts:24, d2fd18233b25)
  • Prior-binary acceptance proof: The PR discussion records migration of a copied affected 2,040-chunk database with preserved chunk and provenance counts, successful SQLite integrity checks, no foreign-key violations, and acceptance by the cited prior deployed schema checker at f2293566896f. (src/commands/doctor-agent-memory-schema.ts:1, d2fd18233b25)
  • Feature provenance: The rollback-sensitive inline metadata and provenance-trigger design originated with the merged memory redesign, which this PR explicitly names as regression context. (packages/memory-host-sdk/src/host/memory-schema-provenance.ts:1, 28630a9a6501)
  • Recorded product decision: The PR’s July 29, 2026 maintainer-context comment explicitly accepts the additive child-table compatibility contract without a schema-version bump and records the refreshed rollback proof. (d2fd18233b25)

Likely related people:

  • steipete: Introduced the merged provenance-gated memory redesign that added the recall metadata and provenance storage whose rollback contract this PR repairs. (role: feature introducer; confidence: high; commits: 28630a9a6501; files: packages/memory-host-sdk/src/host/memory-schema-recall.ts, packages/memory-host-sdk/src/host/memory-schema-provenance.ts, src/state/openclaw-agent-db-schema.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase or otherwise validate the exact current merge result, then rerun the focused migration and prior-binary acceptance proof.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-29T16:54:22.181Z sha b19b2268bcd5227101ccfd3a487dc44367b5d0d7 :: needs maintainer review before merge. :: none

@fuller-stack-dev
fuller-stack-dev force-pushed the codex/fix-memory-schema-rollback branch from b19b226 to d2fd182 Compare July 29, 2026 16:58
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 29, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Maintainer merge decision: accept the additive child-table compatibility contract without a schema-version bump. This follows the repository contract for additive tables and restores rollback compatibility by returning memory_index_chunks to its prior canonical shape.

ClawSweeper rank-up moves addressed on refreshed head d2fd18233b25e468a9e2637fe7e5e5c4d3d42b19:

  • Rebased onto current main (b7f014036fa9bd03f90ee2ad59db86a830e1c030).
  • Re-ran the prior-binary acceptance proof using the exact-head migration helpers on a copied affected database: 2,040 chunks and 2,040 provenance rows preserved; canonical 10-column chunk table restored; legacy trigger absent; PRAGMA quick_check = ok; zero foreign-key violations; prior deployed f2293566896f schema checker accepted the result.
  • The refreshed head also passes the focused version-1 migration regression and Kysely guardrail check.

The remaining step is completion of the refreshed GitHub merge gates.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Maintainer landing decision after the refreshed ClawSweeper review:

  • Reviewed and prepared exact head d2fd18233b25e468a9e2637fe7e5e5c4d3d42b19; all required hosted checks, including openclaw/ci-gate, are green.
  • Re-ran the focused exact-head migration and prior-binary acceptance proof after the rebase: the copied 2,040-chunk database retained chunk/provenance counts, passed SQLite integrity and FK checks, and the deployed f2293566896f validator accepted the restored 10-column canonical table.
  • Current main drift is confined to scripts/check-dependency-pins.{mjs,d.mts} and does not intersect the memory schema, migration, readers, writers, or proof path. I am therefore using the repository’s pinned --auto-merge path rather than repeatedly rebasing a fast-moving main.

I accept the additive child-table/no-version-bump compatibility contract and the remaining merge-result risk.

@fuller-stack-dev
fuller-stack-dev merged commit cf927f7 into main Jul 29, 2026
123 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the codex/fix-memory-schema-rollback branch July 29, 2026 17:19
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit to ZengWen-DT/openclaw that referenced this pull request Jul 29, 2026
* origin/main: (446 commits)
  fix(daemon): refuse duplicate launchd gateway managers (openclaw#97285)
  fix(memory-lancedb): share the recall cooldown with the auto-recall prompt-build hook (openclaw#112927)
  fix(test): isolate plugin install fixtures (openclaw#116008)
  fix(feishu): guard Object.assign against prototype pollution in webhook payload merge (openclaw#111729)
  fix(sms): isolate validated webhook quotas per sender (openclaw#104862)
  fix(sessions): recover deleted chats without endless retries (openclaw#115974)
  fix(restart): log errors from restart hook callbacks instead of swallowing (openclaw#108847)
  feat(ui): enable tool-loop detection from Labs (openclaw#115983)
  fix(telegram): catch unhandled rejections in webhook and ingress worker shutdown (openclaw#100998)
  fix(memory): keep rollbacks compatible after recall metadata upgrade (openclaw#116003)
  fix(ui): derive cron timezone suggestions (openclaw#115973)
  fix(scripts): bound dependency pin git lookups (openclaw#110570)
  fix(skills): preserve configless workshop apply upgrades (openclaw#115982)
  fix(gateway): cancel unread cron webhook bodies before SSRF release (openclaw#111236)
  fix(voice-call): pin Twilio webhook verification to the configured public path (openclaw#112800)
  fix(memory): make legacy session backfill rollback re-applicable (openclaw#116004)
  fix(security): fence external hook job name in isolated-agent prompts (openclaw#112501)
  fix(channels): mark durable webhook acceptance on Zalo, Google Chat, SMS, Feishu, Nextcloud Talk, and Synology Chat (openclaw#115586)
  fix(test): restore stdin TTY descriptors (openclaw#115985)
  fix(plugins): remove incorrect modifying hook timeout fallback in getClaimingHookTimeoutMs (openclaw#107996)
  ...

# Conflicts:
#	extensions/openai/realtime-quicksilver-wire.ts
vincentkoc added a commit to nvtoroy/openclaw that referenced this pull request Jul 29, 2026
* origin/main: (683 commits)
  fix(discord): bound webhook send body reads (openclaw#109076)
  fix(ui): preserve initials for missing user avatars (openclaw#115976)
  feat(ui): add provider icons to coding catalogs (openclaw#115956)
  fix(daemon): refuse duplicate launchd gateway managers (openclaw#97285)
  fix(memory-lancedb): share the recall cooldown with the auto-recall prompt-build hook (openclaw#112927)
  fix(test): isolate plugin install fixtures (openclaw#116008)
  fix(feishu): guard Object.assign against prototype pollution in webhook payload merge (openclaw#111729)
  fix(sms): isolate validated webhook quotas per sender (openclaw#104862)
  fix(sessions): recover deleted chats without endless retries (openclaw#115974)
  fix(restart): log errors from restart hook callbacks instead of swallowing (openclaw#108847)
  feat(ui): enable tool-loop detection from Labs (openclaw#115983)
  fix(telegram): catch unhandled rejections in webhook and ingress worker shutdown (openclaw#100998)
  fix(memory): keep rollbacks compatible after recall metadata upgrade (openclaw#116003)
  fix(ui): derive cron timezone suggestions (openclaw#115973)
  fix(scripts): bound dependency pin git lookups (openclaw#110570)
  fix(skills): preserve configless workshop apply upgrades (openclaw#115982)
  fix(gateway): cancel unread cron webhook bodies before SSRF release (openclaw#111236)
  fix(voice-call): pin Twilio webhook verification to the configured public path (openclaw#112800)
  fix(memory): make legacy session backfill rollback re-applicable (openclaw#116004)
  fix(security): fence external hook job name in isolated-agent prompts (openclaw#112501)
  ...

# Conflicts:
#	CHANGELOG.md
#	src/agents/tool-search-catalog.ts
#	src/agents/tool-search.test-support.ts
#	src/agents/tool-search.ts
vincentkoc added a commit to ryanrhughes/openclaw that referenced this pull request Jul 29, 2026
* commit 'e80fe942c8dae4b264acb2b501466224e842aa61':
  fix(gateway): stop start-time repair from retargeting managed services (openclaw#115935)
  fix(plugins): scope Codex relay with tool matchers (openclaw#109603)
  fix(discord): bound webhook send body reads (openclaw#109076)
  fix(ui): preserve initials for missing user avatars (openclaw#115976)
  feat(ui): add provider icons to coding catalogs (openclaw#115956)
  fix(daemon): refuse duplicate launchd gateway managers (openclaw#97285)
  fix(memory-lancedb): share the recall cooldown with the auto-recall prompt-build hook (openclaw#112927)
  fix(test): isolate plugin install fixtures (openclaw#116008)
  fix(feishu): guard Object.assign against prototype pollution in webhook payload merge (openclaw#111729)
  fix(sms): isolate validated webhook quotas per sender (openclaw#104862)
  fix(sessions): recover deleted chats without endless retries (openclaw#115974)
  fix(restart): log errors from restart hook callbacks instead of swallowing (openclaw#108847)
  feat(ui): enable tool-loop detection from Labs (openclaw#115983)
  fix(telegram): catch unhandled rejections in webhook and ingress worker shutdown (openclaw#100998)
  fix(memory): keep rollbacks compatible after recall metadata upgrade (openclaw#116003)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
…penclaw#116003)

* fix(memory): keep agent database rollbacks compatible

* fix(memory): satisfy rollback migration guards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: rolling back memory metadata upgrade prevents gateway startup

1 participant