Skip to content

refactor(memory): simplify provenance and dreaming flows - #131318

Merged
steipete merged 2 commits into
mainfrom
codex/memory-provenance-cleanup-20260827
Aug 28, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/memory-provenance-cleanup-20260827

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130451, #131179, #131248.

What Problem This Solves

Maintainer-requested cleanup of the recent memory provenance work. The deletion safeguards are necessary, but repeated store plumbing, parameter forwarding, and phase orchestration made the surrounding code larger and harder to follow.

Why This Change Was Made

Reuse the existing bounded distinct-value merger, share recall/phase store I/O, remove normalization already performed by the store reader, and centralize light/REM outcome and error handling. Pass each prepared index entry directly into its locked commit and remove the forwarding-only index methods.

The workspace locks, synchronous index transaction, tombstone checks, file-snapshot validation, and shadow-publication revision checks retain their existing scope and order. Retry evidence and consolidation-history cleanup from the newer repairs are untouched.

Production: +291 / −426 (net −135 lines) across seven files. Tests: unchanged. Documentation: two corrected references to SQLite-backed dreaming state.

User Impact

No intended runtime behavior, public API, configuration, schema, retention, or migration change. Dreaming documentation now describes where machine state actually lives.

Evidence

  • Before cleanup: 266 tests passed in seven focused memory files.
  • After cleanup: 386 tests passed in 13 files, including pending-embedding deletion races, stale file/shadow publication, partial-purge retry, consolidation history, short-term repair/retention, backfill, narrative cleanup, source-wide batching, multimodal indexing, and FTS-only indexing.
  • Fresh Codex autoreview: no actionable findings at the default P0 threshold.
  • Exact-head CI passed on 3838707ee977d7a3eb4465ef12465d24f40eb1a2.
  • All 12 real built-CLI commands and behavior assertions passed with fresh isolated state: index/search, replace/reindex, absence of stale content, backfill/staging, repeat staging without duplicate candidates, and rollback preserving curated memory.
  • CLI proof used the CI build at c5f642a0126de8bb9d4df755e4a3d5943c86e5d3, whose parent is the exact PR head and whose touched sources and dependency manifests match. Provider none exercises real local FTS and SQLite behavior; this is not live-model proof. No mocks or operator Gateway changes.
  • The supplementary local node scripts/check-changed.mjs run also passed (completed after merge): production/test extension typechecks, extension/script lint, formatting, boundary/dependency guards, assertion baseline, three unused-export scans, five doctor-contract tests, storage/media/runtime-loader guards, and zero runtime import cycles.

The initial broad check caught the obsolete assertion-baseline entry after two casts were removed; the entry is now pruned. The first CLI fixture used an unsupported memory.search.sync field and correctly failed config validation; the fixture was corrected before the complete 12-command run. Neither correction changed runtime behavior.

@clawsweeper

clawsweeper Bot commented Aug 28, 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 size: L maintainer Maintainer-authored PR labels Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 00:34
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 8:42 PM ET / August 28, 2026, 00:42 UTC.

ClawSweeper review

What this changes

The PR removes duplicated memory provenance, dreaming-phase, and indexing plumbing while correcting documentation to describe SQLite-backed dreaming state.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: no introduced correctness or security defect was found, but this unmerged maintainer PR still needs its exact-head CI and promised CLI smoke before normal landing review.

Priority: P3
Reviewed head: 3838707ee977d7a3eb4465ef12465d24f40eb1a2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A clean, net-reducing refactor with preserved safety boundaries and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored behavior-neutral refactor, so the external-contributor real-behavior gate does not apply; its exact-head verification remains pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored behavior-neutral refactor, so the external-contributor real-behavior gate does not apply; its exact-head verification remains pending.
Evidence reviewed 7 items Preserved index publication boundary: The refactor retains the workspace lock, current-file snapshot recheck, session tombstone recheck, and synchronous SQLite transaction before publishing index rows.
Shared phase orchestration: The new helper preserves the enabled/limit gate, runs light before REM, records the same outcome statuses, and records phase-specific failures before rethrowing.
Existing race coverage: Existing tests exercise both light and REM publication against a concurrent forget operation, and separate index tests cover pending embedding, tombstone, and stale-file publication paths.
Findings None None.
Security None None.

Live Verification

Command: pnpm build && pnpm openclaw --help

Result: FAIL (failed) — step 1 expect_output Usage: openclaw [options] [command]: expected terminal output was not visible within 30 seconds: "Usage: openclaw [options] [command]"

[failure]
expected terminal output was not visible within 30 seconds: "Usage: openclaw [options] [command]"

[command 1 combined output]
$ node --import ./scripts/tsx.mjs scripts/build-all.mts
[build-all] plugins:assets:build
$ node --import ./scripts/tsx.mjs scripts/bundled-plugin-assets.mts --phase build
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 118.52 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[build-all] plugins:assets:build done in 2.01s
[build-all] tsdown-ai
[PLUGIN_TIMINGS] Your build spent significant time in plugins. Here is a breakdown:
  - tsdown:deps (48%)
  - rolldown-plugin-dts:fake-js (21%)
  - rolldown-plugin-dts:generate (18%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

[tsdown-build] invocation 1/1 finished in 4.1s
[build-all] tsdown-ai done in 4.72s
[build-all] tsdown-packages
[tsdown-build] invocation 1/1 finished in 19.7s
[build-all] tsdown-packages done in 20.3s
[build-all] tsdown-unified

Assertions:

  • FAIL expect_output: Usage: openclaw [options] [command]

How this fits together

Memory Core records recall and provenance state for workspace and session content, then uses it during dreaming, search, and forget operations. The refactor stays inside the memory plugin’s state, locking, and index-publication paths.

flowchart LR
A[Workspace and session content] --> B[Memory indexing]
B --> C[SQLite-backed provenance state]
C --> D[Light and REM dreaming]
D --> E[Dream diary and reports]
C --> F[Search and forget]
G[Memory plugin configuration] --> B
G --> D
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI still has active lanes, and the PR body says its built-CLI smoke result will be added before merge.
  • Complete next step (P2) - No discrete repair is indicated; wait for normal exact-head verification rather than opening an automated fix lane.
Agent review details

Security

None.

PR surface

Source -135, Docs 0, Other -1. Total -136 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 7 291 426 -135
Tests 0 0 0 0
Docs 1 2 2 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 9 293 429 -136

Review metrics

Metric Value Why it matters
Production versus test delta production +291/-426 (net -135); docs +2/-2; tests +0/-0; safety baseline -1 The code reduction consolidates existing paths rather than adding a new runtime or configuration surface.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/dreaming-narrative.ts, unknown-data-model-change: extensions/memory-core/src/dreaming-phases.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-store.ts, vector/embedding metadata: extensions/memory-core/src/dreaming-narrative.ts, vector/embedding metadata: extensions/memory-core/src/dreaming-phases.ts, and 4 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the single in-plugin storage, phase, and prepared-index paths, then merge after exact-head CI and a narrow built-CLI smoke confirm the behavior-neutral refactor.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the single in-plugin storage, phase, and prepared-index paths, then merge after exact-head CI and a narrow built-CLI smoke confirm the behavior-neutral refactor.

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

Not applicable: this PR does not claim a new user-visible defect; existing deterministic race tests cover the retained memory-publication invariants.

Is this the best way to solve the issue?

Yes: removing forwarding-only wrappers and sharing the existing store and phase flow is the cleanest owner-local simplification while retaining the locking and transaction boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a behavior-neutral maintainability refactor with no demonstrated user-facing regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored behavior-neutral refactor, so the external-contributor real-behavior gate does not apply; its exact-head verification remains pending.

Label justifications:

  • P3: This is a behavior-neutral maintainability refactor with no demonstrated user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored behavior-neutral refactor, so the external-contributor real-behavior gate does not apply; its exact-head verification remains pending.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the introduced refactor and the immediately preceding merged memory provenance repairs covering these owner boundaries. (role: recent memory provenance and dreaming owner; confidence: high; commits: 81c7f0511e1f, 5153f254953b, 61a47996d5bc; files: extensions/memory-core/src/memory/manager-embedding-ops.ts, extensions/memory-core/src/dreaming-phases.ts, extensions/memory-core/src/short-term-promotion-store.ts)
  • synth: Recent REM-phase normalization work is in the same dreaming-phase owner module. (role: adjacent REM-phase contributor; confidence: medium; commits: d30fe18038; files: extensions/memory-core/src/dreaming-phases.ts)

Rank-up moves

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

  • Complete exact-head CI and add the promised built-CLI smoke result, with any private details redacted.

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
steipete merged commit 2026a7b into main Aug 28, 2026
233 checks passed
@steipete
steipete deleted the codex/memory-provenance-cleanup-20260827 branch August 28, 2026 01:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…1318)

* refactor(memory): simplify provenance and dreaming flows

* chore(memory): prune removed assertion baseline
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: memory-core Extension: memory-core maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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