Skip to content

fix(memory): recover restored session freshness - #117548

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-memory-rollback-20260801
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-memory-rollback-20260801

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #117547

What Problem This Solves

Fixes an issue where memory startup catch-up would permanently miss changed session transcripts after a backup restore, filesystem copy, or SQLite rollback moved the transcript timestamp backward without changing its byte size.

Why This Change Was Made

Session file mtimes and SQLite updatedAt values are now equality fingerprints rather than monotonic clocks. Any mismatch marks the transcript as potentially dirty, while the content hash remains the authoritative reindex decision.

For hash-equal dirty sessions, the source-sync owner performs one atomic, session-only metadata convergence of memory_index_sources.mtime/size, guarded by source, path, and hash. It requires exactly one matched row; a concurrent missing or changed row falls through to normal full indexing. Clean hash-equal scans perform no write. Direct and deferred session paths share the same decision.

This does not change session storage, transcript rows, chunks, embeddings, schema versions, migrations, config, or provider behavior.

User Impact

Memory search now catches restored or rolled-back transcript changes without requiring a forced reindex. Restoring identical content also converges once instead of re-reading and rehashing that transcript on every future startup.

Evidence

The earlier changed gate also reached an unrelated current-main max-lines ratchet shrink requirement for ui/src/pages/agents/memory/dreaming.ts; no touched-file lane failed. The repo-native landing flow will validate the final head against the current base after exact-head hosted CI completes.

Release-note context: memory startup now detects restored session transcripts whose timestamps moved backward without repeatedly reprocessing unchanged content.

AI-assisted: yes. The implementation was independently reviewed, refined after owner-boundary review, and remotely validated with real SQLite state.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 18:05
@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. labels Aug 1, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 3:34 PM ET / 19:34 UTC.

ClawSweeper review

What this changes

The PR changes memory-core startup catch-up so restored file or SQLite timestamps that move backward are rechecked, while hash-equal session sources receive a one-time metadata refresh instead of a full reindex.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still skips a same-size restored session when its file or SQLite timestamp moves backward. The patch repairs the existing startup/source-sync path and has strong real-SQLite proof, but the protected maintainer label, behind base, and in-progress final checks require maintainer merge review.

Priority: P2
Reviewed head: 8616acbfd407a5746c0288f0e8a56b37eebb314a

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong real-state proof and focused owner-boundary coverage support the repair; only final base refresh and required CI remain before merge.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body documents before-and-after real-SQLite restart behavior for both file and SQLite sessions, including a one-time metadata update and a subsequent clean startup.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body documents before-and-after real-SQLite restart behavior for both file and SQLite sessions, including a one-time metadata update and a subsequent clean startup.
Evidence reviewed 6 items Current-main defect: At current main SHA 7c9794b5c65c9e28d6ae359f8924c86d82ab4abd, startup catch-up only marks a session dirty when its size changes or its timestamp is newer. A restored same-size transcript with an older timestamp is skipped.
Correct owner boundary: The PR changes the dirty predicate to timestamp inequality and places hash-equal metadata convergence in session source sync, where it can preserve chunks and embeddings while refreshing only mtime and size.
Direct and deferred paths share the decision: Both deferred batch processing and direct session indexing call the same hash-equality helper before deciding whether to skip or reindex a session source.
Findings None None.
Security None None.

How this fits together

Memory Core scans file-backed and SQLite session transcripts during startup, compares their fingerprints with memory_index_sources, and schedules potentially stale sessions for synchronization. Source sync then either reindexes changed content or preserves existing chunks and embeddings while refreshing only the stored fingerprint.

flowchart TD
  A[Restored session transcript] --> B[Startup fingerprint scan]
  B --> C{Size or timestamp differs?}
  C -->|No| D[Skip clean session]
  C -->|Yes| E[Session source sync]
  E --> F{Content hash changed?}
  F -->|Yes| G[Reindex transcript]
  F -->|No| H[Refresh stored fingerprint]
  G --> I[Fresh memory search]
  H --> I
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main, and the supplied GitHub context still has build-artifacts plus three changed-node checks in progress. Refresh the merge result and require those checks on the final head before landing.
  • Complete next step (P2) - The patch appears correct, but the protected maintainer label, stale base, and pending merge-result checks require a human merge decision rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +25, Tests +249. Total +274 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 28 3 +25
Tests 2 261 12 +249
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 289 15 +274

Review metrics

None.

Stored data model

Persistent data-model change detected: database schema: extensions/memory-core/src/memory/manager-sync-ops.startup-catchup.test.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-source-sync-ops.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-sync-ops.startup-catchup.test.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-source-sync-ops.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-sync-ops.startup-catchup.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh and land with final proof (recommended)
    Update the branch against current main, confirm the merge result retains the rollback regressions, and land after the remaining required checks pass.
  2. Pause for owner review
    Hold the PR if the merge update changes the session-source ownership or exposes a SQLite metadata concern outside the current proof.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, preserve the rollback source-sync tests, and require final merge-result CI before merge.

Technical review

Best possible solution:

Update the branch against current main, retain the single source-sync metadata-convergence path and its rollback regressions, then land once the final merge result and required checks pass.

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

Yes—current main has a direct source path: a same-size session with a timestamp below the indexed value fails the mtimeMs > indexedMtimeMs check and is never scheduled for startup catch-up. The PR also supplies real-SQLite restart evidence for file-backed and SQLite-backed variants.

Is this the best way to solve the issue?

Yes—the source-sync owner is the narrowest maintainable repair point because it can use the content hash to distinguish changed content from a harmless restored timestamp and refresh only derived fingerprint metadata.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 session-state: The patch changes startup reconciliation of persisted session-source freshness metadata, so the final rebased behavior needs merge-result proof.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Restored session content can remain stale in memory search until a forced reindex, but OpenClaw continues operating.
  • merge-risk: 🚨 session-state: The patch changes startup reconciliation of persisted session-source freshness metadata, so the final rebased behavior needs merge-result proof.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body documents before-and-after real-SQLite restart behavior for both file and SQLite sessions, including a one-time metadata update and a subsequent clean startup.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents before-and-after real-SQLite restart behavior for both file and SQLite sessions, including a one-time metadata update and a subsequent clean startup.

Evidence

What I checked:

Likely related people:

  • Gio Della-Libera: The session startup catch-up behavior appears to originate with the May 16, 2026 memory fix that introduced this path. (role: original feature author; confidence: high; commits: 8af2af24a53c; files: extensions/memory-core/src/memory/manager-session-sync-state.ts, extensions/memory-core/src/memory/manager-session-sync-ops.ts)

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-08-01T18:10:40.352Z sha d49a4380f5e80566eb66e31a36335a53193ca05a :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Aug 1, 2026
@steipete
steipete force-pushed the codex/autoqa-memory-rollback-20260801 branch from 72dcae7 to 8616acb Compare August 1, 2026 19:27
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 1, 2026
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 8616acbfd407a5746c0288f0e8a56b37eebb314a:

The branch is mergeable. Behind-main drift is unrelated and advisory; no further rebase is needed unless GitHub reports a conflict.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Aug 1, 2026
@steipete
steipete merged commit 165c968 into main Aug 1, 2026
99 of 103 checks passed
@steipete
steipete deleted the codex/autoqa-memory-rollback-20260801 branch August 1, 2026 19:39
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 1, 2026
* commit '81e392b7ff43bcdb7a3be50a99adf65c3b0141b5':
  fix(channels): preserve filters in offline status diagnostics (#117570)
  perf(gateway): separate startup maintenance timing (#117577)
  refactor(tests): deduplicate database-first guard fixtures (#117594)
  fix(cli): align sessions cleanup label summary by visible width (#117459)
  perf(gateway): skip empty session reconciliation (#117589)
  refactor(ui): consolidate cron form control rendering (#117576)
  fix(memory): recover restored session freshness (#117548)
  fix(ui): preserve Talk transcript surrogate bounds
  fix(ui): harden Talk transcript marker bounds
  test(ui): cover bounded realtime Talk entries
  fix(ui): bound realtime Talk conversation text
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* origin/main: (22 commits)
  refactor(ui): consolidate cron form control rendering (#117576)
  fix(memory): recover restored session freshness (#117548)
  fix(whatsapp): normalize future-proof QA poll and video note ingress (#117579)
  fix(perf): separate warm and first-device health probes (#117525)
  fix(ci): repair plugin prerelease validation (#117562)
  fix(tasks): sanitize every human task and flow detail (#117568)
  fix(feishu): cancel unread streaming-card error bodies before release (#117312)
  fix(status): honor explicit local RPC fallback timeouts (#117519)
  fix(ui): preserve Talk transcript surrogate bounds
  fix(tasks): validate notification policy before persistence (#117554)
  refactor: consolidate full release child workflows (#117385)
  refactor(policy): centralize doctor health-check descriptors (#117578)
  perf(gateway): mark recovery before model preparation (#117544)
  fix(ui): harden Talk transcript marker bounds
  test(openai): parse realtime websocket frames safely
  fix(openai): keep embedding identity stable across upgrades (#117557)
  fix(googlechat): drop invalid thread resource names before send (#108324)
  test(ui): cover bounded realtime Talk entries
  fix(ui): bound realtime Talk conversation text
  test(ui): cover reentrant Talk meter cleanup
  ...
pull Bot pushed a commit to zhenglee1984/openclaw that referenced this pull request Aug 1, 2026
* origin/main: (28 commits)
  refactor(ui): consolidate cron form control rendering (openclaw#117576)
  fix(memory): recover restored session freshness (openclaw#117548)
  fix(whatsapp): normalize future-proof QA poll and video note ingress (openclaw#117579)
  fix(perf): separate warm and first-device health probes (openclaw#117525)
  fix(ci): repair plugin prerelease validation (openclaw#117562)
  fix(tasks): sanitize every human task and flow detail (openclaw#117568)
  fix(feishu): cancel unread streaming-card error bodies before release (openclaw#117312)
  fix(status): honor explicit local RPC fallback timeouts (openclaw#117519)
  fix(ui): preserve Talk transcript surrogate bounds
  fix(tasks): validate notification policy before persistence (openclaw#117554)
  refactor: consolidate full release child workflows (openclaw#117385)
  refactor(policy): centralize doctor health-check descriptors (openclaw#117578)
  perf(gateway): mark recovery before model preparation (openclaw#117544)
  fix(ui): harden Talk transcript marker bounds
  test(openai): parse realtime websocket frames safely
  fix(openai): keep embedding identity stable across upgrades (openclaw#117557)
  fix(googlechat): drop invalid thread resource names before send (openclaw#108324)
  fix(skills): preserve profile in ClawHub command hints (openclaw#117555)
  fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556)
  fix(irc): strip markdown from outbound text (openclaw#112961)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (22 commits)
  refactor(ui): consolidate cron form control rendering (openclaw#117576)
  fix(memory): recover restored session freshness (openclaw#117548)
  fix(whatsapp): normalize future-proof QA poll and video note ingress (openclaw#117579)
  fix(perf): separate warm and first-device health probes (openclaw#117525)
  fix(ci): repair plugin prerelease validation (openclaw#117562)
  fix(tasks): sanitize every human task and flow detail (openclaw#117568)
  fix(feishu): cancel unread streaming-card error bodies before release (openclaw#117312)
  fix(status): honor explicit local RPC fallback timeouts (openclaw#117519)
  fix(ui): preserve Talk transcript surrogate bounds
  fix(tasks): validate notification policy before persistence (openclaw#117554)
  refactor: consolidate full release child workflows (openclaw#117385)
  refactor(policy): centralize doctor health-check descriptors (openclaw#117578)
  perf(gateway): mark recovery before model preparation (openclaw#117544)
  fix(ui): harden Talk transcript marker bounds
  test(openai): parse realtime websocket frames safely
  fix(openai): keep embedding identity stable across upgrades (openclaw#117557)
  fix(googlechat): drop invalid thread resource names before send (openclaw#108324)
  test(ui): cover bounded realtime Talk entries
  fix(ui): bound realtime Talk conversation text
  test(ui): cover reentrant Talk meter cleanup
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (28 commits)
  refactor(ui): consolidate cron form control rendering (openclaw#117576)
  fix(memory): recover restored session freshness (openclaw#117548)
  fix(whatsapp): normalize future-proof QA poll and video note ingress (openclaw#117579)
  fix(perf): separate warm and first-device health probes (openclaw#117525)
  fix(ci): repair plugin prerelease validation (openclaw#117562)
  fix(tasks): sanitize every human task and flow detail (openclaw#117568)
  fix(feishu): cancel unread streaming-card error bodies before release (openclaw#117312)
  fix(status): honor explicit local RPC fallback timeouts (openclaw#117519)
  fix(ui): preserve Talk transcript surrogate bounds
  fix(tasks): validate notification policy before persistence (openclaw#117554)
  refactor: consolidate full release child workflows (openclaw#117385)
  refactor(policy): centralize doctor health-check descriptors (openclaw#117578)
  perf(gateway): mark recovery before model preparation (openclaw#117544)
  fix(ui): harden Talk transcript marker bounds
  test(openai): parse realtime websocket frames safely
  fix(openai): keep embedding identity stable across upgrades (openclaw#117557)
  fix(googlechat): drop invalid thread resource names before send (openclaw#108324)
  fix(skills): preserve profile in ClawHub command hints (openclaw#117555)
  fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556)
  fix(irc): strip markdown from outbound text (openclaw#112961)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* commit '58213dd5389737ff100c6286d110921defeb76e8':
  fix(channels): preserve filters in offline status diagnostics (openclaw#117570)
  perf(gateway): separate startup maintenance timing (openclaw#117577)
  refactor(tests): deduplicate database-first guard fixtures (openclaw#117594)
  fix(cli): align sessions cleanup label summary by visible width (openclaw#117459)
  perf(gateway): skip empty session reconciliation (openclaw#117589)
  refactor(ui): consolidate cron form control rendering (openclaw#117576)
  fix(memory): recover restored session freshness (openclaw#117548)
  fix(ui): preserve Talk transcript surrogate bounds
  fix(ui): harden Talk transcript marker bounds
  test(ui): cover bounded realtime Talk entries
  fix(ui): bound realtime Talk conversation text
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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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]: Memory startup misses restored transcript timestamp rollback

1 participant