Skip to content

fix(memory): make legacy session backfill rollback re-applicable - #116004

Merged
steipete merged 2 commits into
mainfrom
fix/memory-backfill-journalless-rollback
Jul 29, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/memory-backfill-journalless-rollback

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where session-backfill entries staged before the rewind journal existed could still become a one-way rollback. Rollback removed the staged memories and diary entries, but retained their ingestion cursors, so preview and re-apply both returned zero.

Why This Change Was Made

Rollback now distinguishes complete journal coverage from legacy or mixed-era state. A complete, agent-scoped baseline keeps the precise journal rewind path. If removed artifacts are not fully covered, rollback resets only that agent's session-ingestion cursors and seen hashes, forcing safe re-enumeration on the next preview/apply. Successful rollback records a clean per-agent baseline so later journaled rollbacks return to the precise path.

The change is AI-assisted and was reviewed through the repository autoreview workflow until no accepted or actionable findings remained.

User Impact

Rollback is unconditionally re-applicable for session backfills: legacy-only, mixed legacy+journal, and current journaled state all converge. Operators do not need a flag or config change; the first legacy recovery may re-enumerate the agent's transcript corpus, while later covered rollbacks stay precise.

Evidence

  • Real copied-install reproduction before this follow-up: rollback removed 74 pre-journal staged rows, then preview and re-apply both returned zero.
  • Focused post-rebase proof: node scripts/run-vitest.mjs extensions/memory-core/src/session-backfill.test.ts extensions/memory-core/src/session-backfill-gateway.test.ts extensions/memory-core/src/cli.test.ts — 100 tests passed.
  • New regressions cover journal-absent legacy state, mixed legacy plus later journal rows, precise rewind after a clean baseline, cross-agent baseline isolation, and the valid agent id archive without touching another agent's archived scopes.
  • Final changed-file gate passed all formatting, dead-code, extension typecheck, lint, database-first storage, and import-cycle lanes on Blacksmith Testbox (run 30471885518).
  • Final autoreview: clean, no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: M maintainer Maintainer-authored PR labels Jul 29, 2026
@steipete
steipete marked this pull request as ready for review July 29, 2026 16:51
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. 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. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 29, 2026, 12:55 PM ET / 16:55 UTC.

ClawSweeper review

What this changes

The PR makes session-backfill rollback reset an affected agent's legacy ingestion cursors and seen hashes when rewind-journal coverage is incomplete, then records a clean baseline for later precise rollbacks.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

Keep this PR open for manual memory-core review. The proposed repair targets a real persistent-session failure mode and has focused regression coverage in the PR body, but it changes stored per-agent ingestion state and does not include after-fix copied-install evidence showing that legacy and mixed-era workspaces can re-apply safely.

Priority: P2
Reviewed head: bbe08c5fd74cb13c49fe6b9448f176b93222c859

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and backed by targeted regressions, but real after-fix behavior proof for its persistent-state recovery path is still missing.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR reports a real copied-install failure before the fix, but its after-fix evidence is tests and CI rather than a real legacy or mixed-era workspace run showing successful preview and re-apply; redact private data in any added transcript or logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR reports a real copied-install failure before the fix, but its after-fix evidence is tests and CI rather than a real legacy or mixed-era workspace run showing successful preview and re-apply; redact private data in any added transcript or logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Persistent-state repair surface: The branch changes rollback after staged memory and diary artifacts are removed: it checks rewind coverage, conditionally resets the selected agent's ingestion state, and writes a baseline afterward.
Focused regression coverage supplied: The PR body reports coverage for journal-absent legacy state, mixed legacy and journaled rows, later precise rewind, cross-agent isolation, and an agent named archive.
Protected maintainer handling: The PR carries the repository's maintainer label, so conservative cleanup should not close it automatically while the memory-state behavior and upgrade proof need a human review.
Findings None None.
Security None None.

How this fits together

Memory Core stages information from agent session transcripts and records ingestion state so later backfill runs do not process the same content again. The rollback path removes staged memory artifacts and must also restore or reset the corresponding per-agent ingestion state so preview and re-apply can find the transcript again.

flowchart LR
  A[Agent session transcripts] --> B[Session backfill]
  B --> C[Staged memories and diary entries]
  B --> D[Per-agent ingestion cursors and seen hashes]
  C --> E[Rollback request]
  D --> E
  E --> F{Complete rewind journal coverage?}
  F -->|Yes| G[Precise journal rewind]
  F -->|No| H[Reset affected agent state]
  G --> I[Re-applicable backfill]
  H --> I
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR reports a real copied-install failure before the fix, but its after-fix evidence is tests and CI rather than a real legacy or mixed-era workspace run showing successful preview and re-apply; redact private data in any added transcript or logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Resetting persistent ingestion cursors and seen hashes is upgrade-sensitive: the branch needs copied-workspace evidence that a legacy or mixed rollback re-enumerates only the intended agent's prior transcript content.
  • Resolve merge risk (P1) - The PR body does not yet show an after-fix real run with a successful preview and re-apply result; focused tests and CI are supplemental evidence for this stored-state behavior.
  • Complete next step (P2) - A protected maintainer-labeled PR that changes persistent session state needs owner review and after-fix copied-workspace proof rather than automated repair or cleanup.
Agent review details

Security

None.

PR surface

Source +96, Tests +167. Total +263 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 113 17 +96
Tests 1 168 1 +167
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 281 18 +263

Review metrics

Metric Value Why it matters
Persistent state paths 2 state paths changed The rollback now changes both rewind-journal handling and per-agent ingestion state, so upgrade behavior matters beyond ordinary deletion logic.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/memory-core/src/session-backfill.test.ts, serialized state: extensions/memory-core/src/session-backfill-lifecycle.ts, serialized state: extensions/memory-core/src/session-backfill.test.ts, serialized state: extensions/memory-core/src/session-backfill.ts, unknown-data-model-change: extensions/memory-core/src/session-backfill-lifecycle.ts, unknown-data-model-change: extensions/memory-core/src/session-backfill.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Add copied-workspace recovery proof (recommended)
    Show a redacted after-fix run where legacy-only and mixed journal state roll back, preview candidates again, and re-apply only for the selected agent.
  2. Accept the state-reset behavior with owner sign-off
    A memory-core owner may accept the fallback after confirming that re-enumeration of the selected agent's historical transcript is the intended upgrade behavior.

Technical review

Best possible solution:

Retain the agent-scoped fallback only if a copied legacy and mixed-era workspace demonstrates that rollback, preview, and re-apply converge without cross-agent re-ingestion, then land it with the focused regression suite.

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

No—this review has a concrete reported copied-install failure path, but no independently observed current-head run proving the before-and-after behavior.

Is this the best way to solve the issue?

Unclear—the agent-scoped reset is a plausible bounded recovery path, but the best fix still needs after-fix copied-workspace proof across legacy and mixed journal state before persistent-state behavior can be accepted.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded repair for a session-backfill rollback that can leave affected operators unable to re-apply staged memory data.
  • add merge-risk: 🚨 compatibility: Existing legacy and mixed-era workspaces can take a newly introduced cursor-reset fallback during rollback.
  • add merge-risk: 🚨 session-state: The patch writes and deletes per-agent ingestion cursors and seen hashes that determine which transcript content is processed.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports a real copied-install failure before the fix, but its after-fix evidence is tests and CI rather than a real legacy or mixed-era workspace run showing successful preview and re-apply; redact private data in any added transcript or logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a bounded repair for a session-backfill rollback that can leave affected operators unable to re-apply staged memory data.
  • merge-risk: 🚨 compatibility: Existing legacy and mixed-era workspaces can take a newly introduced cursor-reset fallback during rollback.
  • merge-risk: 🚨 session-state: The patch writes and deletes per-agent ingestion cursors and seen hashes that determine which transcript content is processed.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports a real copied-install failure before the fix, but its after-fix evidence is tests and CI rather than a real legacy or mixed-era workspace run showing successful preview and re-apply; redact private data in any added transcript or logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Persistent-state repair surface: The branch changes rollback after staged memory and diary artifacts are removed: it checks rewind coverage, conditionally resets the selected agent's ingestion state, and writes a baseline afterward. (extensions/memory-core/src/session-backfill.ts:539, bbe08c5fd74c)
  • Focused regression coverage supplied: The PR body reports coverage for journal-absent legacy state, mixed legacy and journaled rows, later precise rewind, cross-agent isolation, and an agent named archive. (extensions/memory-core/src/session-backfill.test.ts:563, bbe08c5fd74c)
  • Protected maintainer handling: The PR carries the repository's maintainer label, so conservative cleanup should not close it automatically while the memory-state behavior and upgrade proof need a human review.
  • Real-proof gap: The supplied copied-install observation describes the failing pre-fix rollback; the reported post-change evidence is focused tests and a changed-file gate, not an after-fix real workspace transcript showing re-preview and re-apply. (bbe08c5fd74c)

Likely related people:

  • steipete: Authored both commits on this focused memory-core rollback repair and is the only concrete history signal available in the supplied PR context. (role: recent area contributor; confidence: medium; commits: f2835a0ba925, bbe08c5fd74c; files: extensions/memory-core/src/session-backfill-lifecycle.ts, extensions/memory-core/src/session-backfill.ts, extensions/memory-core/src/session-backfill.test.ts)

Rank-up moves

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

  • Add redacted copied-workspace output showing rollback followed by nonzero preview and successful re-apply for legacy and mixed state.
  • Have a memory-core reviewer confirm the selected-agent reset cannot re-ingest another agent's cursor scope.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up moves addressed for head bbe08c5fd74cb13c49fe6b9448f176b93222c859:

  • Redacted copied-workspace after-fix run — skipped for host safety. The prior 12k-session copied-install setup unexpectedly rewrote and interrupted the operator's live LaunchAgent during Doctor, so reusing that environment would cross the same live-host boundary. The bounded replacement proof applies real session state through the CLI executor, removes only journal rows to create the legacy shape, proves rollback → nonzero preview → hash-identical re-apply, and separately covers mixed legacy+journal state.
  • Memory Core owner confirmation — satisfied by operator ruling and focused isolation proof. This work order explicitly freezes the fallback: incomplete coverage resets the selected agent's ingestion state, with approximately 10-second re-enumeration accepted on the real 11k-file corpus. Regressions prove another agent's live/archive scopes and clean-baseline marker survive, including the valid agent id archive.
  • Current evidence: exact-head CI run 30472669186 is green with zero failed jobs; focused post-rebase proof is 100/100; the changed-file gate and final autoreview are clean.

No config, flag, or selective rollback mode is added.

@steipete
steipete merged commit 841bfcd into main Jul 29, 2026
156 of 166 checks passed
@steipete
steipete deleted the fix/memory-backfill-journalless-rollback branch July 29, 2026 17:08
@steipete

Copy link
Copy Markdown
Contributor 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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
…nclaw#116004)

* fix(memory): reset legacy backfill cursors on rollback

* fix(memory): track complete backfill rewind baselines
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 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant