Skip to content

fix(memory): preserve rotated recall and simplify consolidation - #137967

Merged
steipete merged 3 commits into
mainfrom
codex/memory-deslop-harder
Sep 4, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/memory-deslop-harder

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Active Memory could report no relevant memory after a SQLite session rotation because it treated the returned canonical session key as a filename. Recall audit also reported the current time instead of the saved update time.

This fixes both bugs and removes duplicate memory implementation paths, building on #137894.

Why This Change Was Made

Recall now reads canonical transcript targets and validated successors directly. Dreaming returns consolidation decisions; the host already owns sourced document composition and locked application, so generating a second full document was redundant. Embedding completions update failure state synchronously in their owner, replacing copied reducer state and a Promise mutex. The remaining cleanup removes duplicate retries, wiki metadata projection, and unused private host helpers.

User Impact

Recall evidence and unavailable-memory warnings survive session rotation; audit timestamps reflect saved state. Consolidation emits less model output. Timeout recovery, optional transcript exports, archives, provider fallback, sourced entries, project boundaries and raw/compiled wiki ranking remain supported.

Net −999 lines: production +223/−982 (−759); tests/support +576/−818 (−242); docs +8/−6. No configuration/default, public SDK, schema, migration, stored-format or retention changes.

Evidence

  • 1,433 selected tests passed, including the final 1,093-test/63-file run, all 214 Active Memory cases, 70 indexing cases and 58 host corpus/ownership cases.
  • Both bug regressions failed on the actual pre-fix implementation. The rotated marker case passed while the canonical-key successor lost the unavailable-memory context; the audit returned the current timestamp instead of its saved timestamp.
  • Full macOS and Linux builds; full changed-file gates, including types, lint, SDK/boundary and storage guards; zero unused exports and runtime import cycles.
  • Real OpenAI memory index/search/status with no fallback; both LanceDB/OpenAI live tests passed.
  • Real isolated consolidation added and merged sourced facts, preserved unrelated entries, and verified DREAMS counts and the persisted audit timestamp. Model decisions occupied 216 characters.
  • Fifteen wiki CLI commands across all five modes preserved raw/compiled ranking, scores, snippets and claim/evidence metadata.
  • Real Gateway: mock-provider Active Memory on/off comparison, ordered search/get evidence, reply context and helper-session cleanup; live-provider preference store/recall.
  • Independent Codex P0–P2 reviews found no actionable defects. Runtime identity contracts were checked directly in both OpenClaw and Codex source.
  • Final-head CI passed on attempt 2. The first run timed out in an unchanged Gateway teardown fixture; its same-head retry passed.

Live proof used an isolated Blacksmith Testbox; the lease is stopped. Test fixture repairs close cached SQLite handles, reset queued one-shot mocks, and coordinate the existing clocks with actual start/write boundaries. Timeout budgets and behavior assertions remain intact.

Data compatibility proof

Addressing ClawSweeper's compatibility request: flagged consumers do not change the stored data model.

Surface Preserved contract and proof
SQLite/session state src/state and src/sessions, including schemas, versions, openers, migrations and transcript storage, are byte-identical to base 3b710e4b75c. Recall changes which existing validated identity it reads. Both real SQLite rotation forms pass.
Recall/dreaming stores short-term-promotion-store.ts only exports its existing reader; namespaces, version, records, metadata and writer are unchanged. Canonical short-term-promotion-apply.ts is identical to base. Live seeded-state add/merge preserves unrelated entries and the saved audit timestamp.
Model response The smaller consolidation response is transient model output. The existing host still writes sourced MEMORY/DREAMS artifacts with project, lineage, size/loss and locked-revalidation checks.
Wiki/LanceDB Compilation/cache and LanceDB store owners are identical to base. Only read-side field projection changes; CLI equivalence and live persisted-store operations passed.
Batch/host helpers Failure accounting is process-local. Removed exports have no production callers and are explicitly private-local-only. Canonical archive ingestion and ownership tests remain.

git diff --exit-code verified the named unchanged owners against base. There are no new tables, columns, indexes, serializers, schema versions or persistence policies, so no migration is required.

Two separate follow-ups are recorded: invalid plugin config can appear as an unknown CLI command (src/plugins/cli.ts); an intermittent teardown stall in server-plugins.lifecycle.test.ts:185 needs shutdown-stage diagnostics if it recurs. Neither required a speculative production patch in this memory refactor.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: memory-wiki extensions: active-memory size: XL maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 06:09
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 5:09 AM ET / 09:09 UTC.

ClawSweeper review

What this changes

Repairs Active Memory recall after canonical SQLite session rotation, preserves stored recall-audit timestamps, and consolidates memory implementation paths around validated host-owned operations.

Merge readiness

⛔ Blocked before merge - 1 item remains

Pass: the patch follows the canonical SQLite transcript identity and moves consolidation composition to the existing locked owner; no introduced correctness or security defect was identified.

Priority: P2
Reviewed head: 32c2fd64343cd988a7ac742ffc780c820d0b7e01

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The patch is a coherent net-negative owner-boundary refactor with focused regression coverage and submitted real-environment evidence.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The changed production owners are exercised by focused rotation and promotion regressions, and the submitted PR evidence links real Testbox, native LanceDB, and Gateway/channel after-fix runs; local execution was intentionally not performed during this read-only review.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed production owners are exercised by focused rotation and promotion regressions, and the submitted PR evidence links real Testbox, native LanceDB, and Gateway/channel after-fix runs; local execution was intentionally not performed during this read-only review.
Evidence reviewed 9 items Rotated-session owner path: The introduced path accepts either a SQLite marker or the exact canonical subagent session key plus returned session ID, and adds a successor source only when it differs from the original session.
Runtime identity contract: The embedded runner reports the canonical session key as sessionFile, while transcript access resolves the authoritative stored session by agent and session ID rather than a physical path.
Rotation regressions: Focused Active Memory coverage exercises both a returned canonical session key and a SQLite marker after rotation, including the unavailable-memory outcome.
Findings None None.
Security None None.

How this fits together

Active Memory launches a bounded helper run whose transcript evidence becomes context for the next agent turn. Memory Core later promotes validated recall evidence into long-term MEMORY.md; this change keeps both flows on their canonical state owners.

flowchart LR
  A[User turn] --> B[Active Memory recall]
  B --> C[SQLite transcript identity]
  C --> D[Recall evidence and context]
  D --> E[Short-term promotion]
  E --> F[Dreaming consolidation plan]
  F --> G[Validated MEMORY.md update]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -759, Tests -242, Docs +2, Other 0. Total -999 across 34 files.

View PR surface stats
Area Files Added Removed Net
Source 20 223 982 -759
Tests 11 576 818 -242
Docs 2 8 6 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 34 808 1807 -999

Review metrics

Metric Value Why it matters
Production versus test delta production +223/-982; tests/support +577/-819; docs +8/-6 The broad cleanup is net-negative in production code while retaining focused owner-boundary and regression coverage.

Stored data model

Persistent data-model change detected: serialized state: extensions/active-memory/transcript.ts, serialized state: extensions/memory-wiki/src/query.ts, unknown-data-model-change: extensions/active-memory/transcript.ts, unknown-data-model-change: extensions/memory-core/src/dreaming-consolidation.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-embedding-ops.ts, unknown-data-model-change: extensions/memory-core/src/short-term-promotion-artifacts.ts, and 13 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep the canonical transcript-target and host-composed consolidation flow, with the focused rotation, audit, project-isolation, and bounded-output regressions retained.

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

Yes. The source establishes a deterministic canonical-session-key successor path, and focused Active Memory and short-term-promotion regressions cover it; this review did not execute the suite.

Is this the best way to solve the issue?

Yes. Reusing session-target identity and the existing locked document composer removes the filename path and avoids accepting model-authored replacement memory.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed production owners are exercised by focused rotation and promotion regressions, and the submitted PR evidence links real Testbox, native LanceDB, and Gateway/channel after-fix runs; local execution was intentionally not performed during this read-only review.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The changed production owners are exercised by focused rotation and promotion regressions, and the submitted PR evidence links real Testbox, native LanceDB, and Gateway/channel after-fix runs; local execution was intentionally not performed during this read-only review.

Label justifications:

  • P2: This repairs bounded memory correctness and audit behavior without evidence of an urgent default-path outage.
  • 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 (linked_artifact): The changed production owners are exercised by focused rotation and promotion regressions, and the submitted PR evidence links real Testbox, native LanceDB, and Gateway/channel after-fix runs; local execution was intentionally not performed during this read-only review.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owners are exercised by focused rotation and promotion regressions, and the submitted PR evidence links real Testbox, native LanceDB, and Gateway/channel after-fix runs; local execution was intentionally not performed during this read-only review.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • tzy-17: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-04T06:50:39.786Z sha 178027f :: blocked before merge. :: none

@clawsweeper clawsweeper Bot removed 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. labels Sep 4, 2026
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review final head 32c2fd64343cd988a7ac742ffc780c820d0b7e01. An older publisher retry replaced the completed review for 178027f2283 with a stale-head marker. The only subsequent code change is the test clock fix; production bytes are unchanged. All local changed gates, 1,433 selected tests, live memory flows, and final-head CI (attempt 2) passed. The PR body now includes explicit compatibility proof for the unchanged canonical storage owners and schemas.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

The remaining compatibility checklist item is covered by the PR body's Data compatibility proof table. I checked the flagged readers against base 3b710e4b75c: session schemas/openers/migrations, canonical promotion application, wiki compilation/cache storage, and LanceDB storage are unchanged. The short-term store change only exports its existing reader. The smaller consolidation response is transient model output; the existing locked host writer owns the persisted artifacts.

The real seeded-state add/merge run preserved unrelated entries and the saved audit timestamp, and both canonical-key and SQLite-marker session rotation cases passed. This is a consumer/owner refactor with unchanged tables, serializers, versions, and persistence semantics, so no migration is needed. No rank-up item remains unaddressed; final-head CI is green.

@steipete
steipete merged commit a72ff7a into main Sep 4, 2026
323 of 327 checks passed
@steipete
steipete deleted the codex/memory-deslop-harder branch September 4, 2026 09:18
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…claw#137967)

* refactor(memory): simplify recall and consolidation owners

* test(memory): isolate recall state and timeout clocks

* test(memory): await callback transcript before timing out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: active-memory extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: memory-wiki maintainer Maintainer-authored PR 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: 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.

1 participant