Skip to content

fix(memory): prevent note metadata from becoming durable memory - #148190

Closed
gisk0 wants to merge 2 commits into
openclaw:mainfrom
gisk0:fix/memory-frontmatter-promotion
Closed

gisk0 wants to merge 2 commits into
openclaw:mainfrom
gisk0:fix/memory-frontmatter-promotion

Conversation

@gisk0

@gisk0 gisk0 commented Sep 14, 2026 •

Copy link
Copy Markdown

Related: #148186

What Problem This Solves

TL;DR: Prevents durable memory from learning YAML bookkeeping fields when a managed promotion candidate points into a note's frontmatter. Note metadata is excluded while body citations keep their original line numbers.

Managed memory promotion could persist note metadata such as status: active as durable memory when a candidate resolved inside leading YAML frontmatter.

User Impact

Memory promotion no longer learns leading note metadata, while YAML-looking conversation text in the session corpus remains eligible. Existing indexes rebuild through the current chunking-version upgrade path; no user action is required.

Implementation

  • Markdown Core owns the single frontmatter delimiter/normalization grammar.
  • Memory indexing reuses that extractor through the plugin SDK boundary, strips complete leading frontmatter, and remaps chunks to original source line numbers.
  • Promotion rehydration independently rejects stale note candidates that land inside frontmatter, while preserving session-corpus behavior.
  • The memory chunking version forces existing v4 indexes to rebuild as v5.

Evidence

Validated on commit ddd4aaeb000e98fdd7a55cbc6aa04ee996bb69db:

  • Focused tests: 136/136 passed.
  • Production-path integration proof: 1/1 passed using the real memory manager, SQLite index metadata, and promotion path.
  • Proof output:
{"indexed":[{"startLine":8,"endLine":9,"text":"# 2026-09-05\nDurable body content."}],"metadataExcluded":true,"upgrade":{"from":4,"to":5},"promotion":{"applied":0,"rejectedAs":"source rehydration","durableMemoryContainsMetadata":false}}
  • oxfmt --check passed for all changed files.
  • git diff --check passed.
  • Both plugin-boundary guards passed.
  • Deterministic local autoreview reported no findings. A prior fresh-context semantic review of the identical behavioral patch also reported no findings.
  • Broader prior evidence on the identical behavioral patch: memory-core lane 1,747 passed with 4 platform skips; full build passed.
  • Local aggregate check:changed passed its first 11 gates, then the repository's doctor-contract Vitest subprocess hit two 15-minute no-output cutoffs and exited 143. No code diagnostic was emitted; no third retry was started. PR CI is authoritative for the exact pushed SHA.

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The PR excludes leading YAML metadata from note indexing and memory promotion while preserving body citation lines and YAML-looking session content.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair has useful regression coverage, but incomplete upgrade handling and test-only runtime evidence limit readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Merge readiness

⛔ Blocked before merge - 7 items remain

This remains useful work for the paired open issue. The shared-parser correction is complete, but the existing-index blocker remains, a line-ending defect also needs repair, and contributor runtime proof is still required.

Priority: P2
Reviewed head: ddd4aaeb000e98fdd7a55cbc6aa04ee996bb69db

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: the captured output comes from a Vitest fixture exercising the real manager, SQLite, and promotion entrypoint, rather than an installed after-fix setup. Provide redacted terminal output or logs covering fresh indexing, contaminated version-5 upgrade, metadata rejection, and the session-corpus control; screenshots or recordings also count when they show those results. Remove secrets and private details. Update the PR body to trigger review, or ask a maintainer to comment @clawsweeper re-review. Existing-state compatibility is independently insufficient because the fixture starts with filtered rows.
  • Invalidate indexes built before frontmatter filtering (P1) - The base and shipped release already use chunking version 5, and this patch leaves that revision unchanged. Existing version-5 indexes therefore remain valid, and unchanged notes are skipped by hash comparison, leaving metadata-containing chunks recallable after upgrade. Advance the revision and verify replacement of genuinely contaminated version-5 rows; lowering metadata on an already-filtered index does not cover this case. This prior blocker remains unfixed.
  • Normalize rehydration lines consistently with frontmatter extraction (P2) - For ---\rstatus: active\r---\rDurable body content., extraction normalizes CR line endings and indexing cites the body at line 4. Rehydration still splits with /\r?\n/, leaving one raw line; relocation selects that line and this new guard rejects it as frontmatter. Normalize both paths consistently so valid body candidates remain promotable. This was discovered late on the same head reviewed previously.
  • Resolve merge risk - Existing-state compatibility needs verification using metadata-containing pre-fix version-5 rows, unchanged source files, and automatic rebuild.
  • Resolve merge risk - The branch has merge conflicts; resolution must retain current main's workspace-reader behavior and receive refreshed validation.
  • Complete next step - Repair both findings, resolve the branch conflicts, and provide after-fix setup and existing-index upgrade evidence before merge.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Invalidate indexes built before frontmatter filtering — extensions/memory-core/src/memory/manager-index-preparation.ts:46-48
  • [P2] Normalize rehydration lines consistently with frontmatter extraction — extensions/memory-core/src/short-term-promotion-rehydrate.ts:337-341
Agent review details

How this fits together

Memory Core indexes workspace notes for recall and promotes selected recalled text into durable memory. Markdown Core supplies the shared frontmatter grammar used to distinguish note metadata from body content.

flowchart TD
  A[Workspace notes] --> B[Shared frontmatter extraction]
  B --> C[Body chunks with source lines]
  C --> D[SQLite recall index]
  D --> E[Promotion candidates]
  E --> F[Live source validation]
  F --> G[Durable memory or recorded rejection]
Loading

Technical review

Best possible solution:

Keep one shared frontmatter grammar, use consistent source-line normalization, and automatically rebuild affected existing indexes without operator intervention.

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

Yes, source establishes the paths: unchanged version-5 indexes skip rebuilding, and CR-separated notes disagree between indexing and rehydration. No contributor code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes, shared extraction with body-line preservation is the appropriate boundary, but index invalidation and consistent rehydration normalization are necessary to complete it.

Full review comments:

  • [P1] Invalidate indexes built before frontmatter filtering — extensions/memory-core/src/memory/manager-index-preparation.ts:46-48
    The base and shipped release already use chunking version 5, and this patch leaves that revision unchanged. Existing version-5 indexes therefore remain valid, and unchanged notes are skipped by hash comparison, leaving metadata-containing chunks recallable after upgrade. Advance the revision and verify replacement of genuinely contaminated version-5 rows; lowering metadata on an already-filtered index does not cover this case. This prior blocker remains unfixed.
    Confidence: 0.99
  • [P2] Normalize rehydration lines consistently with frontmatter extraction — extensions/memory-core/src/short-term-promotion-rehydrate.ts:337-341
    For ---\rstatus: active\r---\rDurable body content., extraction normalizes CR line endings and indexing cites the body at line 4. Rehydration still splits with /\r?\n/, leaving one raw line; relocation selects that line and this new guard rejects it as frontmatter. Normalize both paths consistently so valid body candidates remain promotable. This was discovered late on the same head reviewed previously.
    Confidence: 0.96
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against dd09da279cbd.

Merge-risk options

Maintainer options:

  1. Complete automatic index repair (recommended)
    Advance the chunking revision, verify contaminated version-5 rows are replaced automatically, and align rehydration line normalization with indexing.

Security

None.

Evidence

What I checked:

PR surface

Source +52, Tests +244. Total +296 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 98 46 +52
Tests 4 244 0 +244
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 342 46 +296

Review metrics

Metric Value Why it matters
Production and regression coverage production net +52 lines, tests +244 lines Production growth supports shared extraction and citation preservation, while the substantial regression coverage still misses contaminated version-5 upgrade input.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded memory-quality repair with concrete upgrade and citation defects.
  • merge-risk: 🚨 compatibility: Existing version-5 indexes will not automatically adopt the changed filtering without invalidation.
  • merge-risk: 🚨 session-state: Stale indexed metadata remains recallable, and inconsistent line normalization can reject legitimate promotion candidates.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Advance index invalidation, cover contaminated version-5 upgrade input, and repair CR-line rehydration.
  • Add redacted after-fix setup evidence for indexing, upgrade, promotion rejection, and the session-corpus control.
  • Resolve conflicts while preserving current main's workspace reader and refresh validation.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-14T11:05:14.416Z sha a0ee6d6 :: needs real behavior proof before merge. :: [P1] Reuse the shared frontmatter extraction owner
  • reviewed 2026-09-14T12:14:09.177Z sha ddd4aae :: needs real behavior proof before merge. :: [P2] Invalidate indexes built before frontmatter filtering
  • reviewed 2026-09-24T05:54:20.817Z sha ddd4aae :: needs real behavior proof before merge. :: [P1] Invalidate indexes built before frontmatter filtering
  • reviewed 2026-10-05T17:34:15.314Z sha ddd4aae :: needs real behavior proof before merge. :: [P1] Invalidate indexes built before frontmatter filtering

Reviewed October 5, 2026, 1:43 PM ET / 17:43 UTC (Revision 5).

@gisk0

gisk0 commented Sep 14, 2026

Copy link
Copy Markdown
Author

Fixed in ddd4aaeb000e98fdd7a55cbc6aa04ee996bb69db.

  • Moved delimiter/normalization ownership to the shared Markdown Core extractor and made memory-core reuse it through the plugin SDK boundary.
  • Added a production-path integration test using the real memory manager, SQLite index metadata, and promotion path.
  • Proof now shows body-only indexing at lines 8–9, automatic v4→v5 rebuild, and metadata promotion rejected as source rehydration.

The PR evidence section is updated with the exact proof output and validation results.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 24, 2026
@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label Oct 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S stale Marked as stale due to inactivity 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