Skip to content

fix(memory): skip placeholder short-term promotions#82028

Closed
MonkeyLeeT wants to merge 9 commits into
openclaw:mainfrom
MonkeyLeeT:codex/fix-memory-placeholder-promotions
Closed

fix(memory): skip placeholder short-term promotions#82028
MonkeyLeeT wants to merge 9 commits into
openclaw:mainfrom
MonkeyLeeT:codex/fix-memory-placeholder-promotions

Conversation

@MonkeyLeeT

@MonkeyLeeT MonkeyLeeT commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a shared short-term promotion guard for markdown placeholder/skeleton snippets.
  • Apply it when loading the recall store, recording recall/grounded candidates, ranking, applying, and rehydrating promotion candidates.
  • Add regression coverage for marker-only snippets, heading-only scaffolding, normalized marker-plus-heading placeholders, stale stored placeholders, trailing-colon scaffold headings, and inline heading bullets with durable payloads, including concise and localized heading text.

Fixes #80582.

Verification

  • node scripts/run-vitest.mjs extensions/memory-core/src/short-term-promotion.test.ts -- --runInBand
  • node scripts/run-vitest.mjs extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/short-term-promotion.test.ts -- --runInBand
  • CI=true pnpm exec oxfmt --check --threads=1 extensions/memory-core/src/short-term-promotion.ts extensions/memory-core/src/short-term-promotion.test.ts
  • git diff --check

Real behavior proof

Behavior addressed: Short-term promotion could treat markdown placeholders like -, plain heading-only scaffolding like ## Tagesnotizen ## Entscheidungen, trailing-colon scaffold headings like ## Notes:, and previously persisted normalized marker-plus-heading snippets like - ## Entscheidungen as durable memory candidates, allowing empty daily-note scaffolding to rank and eventually append to MEMORY.md. The guard also preserves list-wrapped heading content with durable body text, including localized non-colon headings such as - ## 修复备份轮换.

Real environment tested: Local filesystem-backed OpenClaw memory workspace on macOS, using PR head 519ee06236eca61c78764f59fa1837157efb37bf. The standalone Node run created real temp files under memory/, wrote memory/.dreams/short-term-recall.json, called the production rankShortTermPromotionCandidates and applyShortTermPromotions functions from extensions/memory-core/src/short-term-promotion.ts, and checked the resulting MEMORY.md filesystem state.

Exact steps or command run after this patch: From the repo root, ran node --import tsx - with a standalone script that seeds temp workspaces with persisted short-term recall entries whose snippets are ## Tagesnotizen ## Entscheidungen, ## Notes:, - ## Entscheidungen, and - ## 修复备份轮换, then invokes production ranking and apply paths with thresholds set to zero.

Evidence after fix: Copied terminal output from that real temp-workspace run:

$ node --import tsx -
{"name":"headingOnly","snippet":"## Tagesnotizen ## Entscheidungen","ranked":0,"applied":0,"memoryExists":false,"memoryIncludesSnippet":false}
{"name":"headingWithColon","snippet":"## Notes:","ranked":0,"applied":0,"memoryExists":false,"memoryIncludesSnippet":false}
{"name":"markerHeading","snippet":"- ## Entscheidungen","ranked":0,"applied":0,"memoryExists":false,"memoryIncludesSnippet":false}
{"name":"durableLocalized","snippet":"- ## 修复备份轮换","ranked":1,"applied":1,"memoryExists":true,"memoryIncludesSnippet":true}

Observed result after fix: Heading-only scaffolding, trailing-colon scaffold headings, and normalized marker-plus-heading placeholders ranked zero candidates, applied zero promotions, and did not create MEMORY.md. The durable localized non-colon inline heading bullet - ## 修复备份轮换 ranked, applied once, created MEMORY.md, and appeared in the resulting memory file.

What was not tested: I did not run a full live dreaming cron cycle against a private real workspace; the user-reported failure shape is covered with filesystem-backed promotion fixtures and the standalone temp-workspace OpenClaw promotion run above rather than private memory contents.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 15, 2026
@clawsweeper

clawsweeper Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • 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.

Summary
The PR adds a memory-core guard to reject markdown skeleton short-term promotion snippets during store normalization, candidate recording, ranking, apply/rehydration, with focused regression tests.

Reproducibility: yes. Current main has a source-level reproduction path because non-empty markdown placeholders pass the existing empty/dreaming-contamination filters into ranking/apply; I did not run tests because this review is read-only.

PR rating
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Summary: The proof is strong and the patch is close, but the current predicate has a concrete P2 correctness gap around trailing-colon template headings.

Rank-up moves:

  • Fix the trailing-colon skeleton-heading case and add focused coverage.
  • Have a maintainer confirm the known-heading pruning contract before merge.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

Real behavior proof
Sufficient (terminal): The PR body includes terminal output from a real filesystem-backed temp workspace on the PR head showing placeholder candidates skipped and a durable localized heading written to MEMORY.md.

Risk before merge

  • The current head still permits known template headings with trailing colons, such as '## Notes:', to pass the skeleton guard and promote into MEMORY.md.
  • The guard intentionally prunes persisted short-term entries matching the skeleton heuristic on the next normalization/write path, so maintainers should accept that session-state behavior before merge.
  • The proof covers filesystem-backed ranking/apply paths, not a full private live dreaming cron cycle.

Maintainer options:

  1. Fix trailing-colon skeleton labels (recommended)
    Add colon stripping and tests for known template headings such as '## Notes:' while preserving durable headings like '## Decision: Move backups to S3'.
  2. Accept the pruning contract after repair
    After the colon hole is fixed, maintainers can merge if they agree that known empty daily-note headings should be removed from stored short-term promotion state.
  3. Pause for memory semantics
    If known-heading pruning is not the intended memory contract, pause this branch and replace it with a narrower marker-only placeholder filter.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add ':' to normalizeMarkdownSkeletonHeadingBody punctuation cleanup, add regression coverage that known skeleton headings with trailing colons such as '## Notes:' and '- ## Decisions:' are unpromotable, and keep durable headings like '## Decision: Move backups to S3' promotable.

Next step before merge
A narrow predicate and test repair can address the blocking finding; maintainers still need to accept the session-state pruning semantics before merge.

Security
Cleared: The diff only changes memory-core filtering logic and colocated tests, with no dependency, workflow, package metadata, secret-handling, or code-execution surface changes.

Review findings

  • [P2] Strip colons from known skeleton heading labels — extensions/memory-core/src/short-term-promotion.ts:337
Review details

Best possible solution:

Centralize the promotion guard, strip trailing colons from known skeleton labels with regression coverage, and merge only after maintainers accept pruning known template headings from persisted short-term state.

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

Yes. Current main has a source-level reproduction path because non-empty markdown placeholders pass the existing empty/dreaming-contamination filters into ranking/apply; I did not run tests because this review is read-only.

Is this the best way to solve the issue?

No, not quite. The centralized guard is the right shape, but the current predicate misses trailing-colon known skeleton headings, so a narrow normalization/test repair is needed before merge.

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from a real filesystem-backed temp workspace on the PR head showing placeholder candidates skipped and a durable localized heading written to MEMORY.md.
  • add rating: 🦐 gold shrimp: Current PR rating is 🦐 gold shrimp because proof is 🦞 diamond lobster, patch quality is 🦐 gold shrimp, and The proof is strong and the patch is close, but the current predicate has a concrete P2 correctness gap around trailing-colon template headings.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body includes terminal output from a real filesystem-backed temp workspace on the PR head showing placeholder candidates skipped and a durable localized heading written to MEMORY.md.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a focused memory-quality bug fix with limited blast radius, but it affects durable MEMORY.md promotion behavior.
  • merge-risk: 🚨 session-state: The PR changes which persisted short-term recall entries survive normalization, ranking, and apply/rehydration.
  • rating: 🦐 gold shrimp: Current PR rating is 🦐 gold shrimp because proof is 🦞 diamond lobster, patch quality is 🦐 gold shrimp, and The proof is strong and the patch is close, but the current predicate has a concrete P2 correctness gap around trailing-colon template headings.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body includes terminal output from a real filesystem-backed temp workspace on the PR head showing placeholder candidates skipped and a durable localized heading written to MEMORY.md.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from a real filesystem-backed temp workspace on the PR head showing placeholder candidates skipped and a durable localized heading written to MEMORY.md.

Full review comments:

  • [P2] Strip colons from known skeleton heading labels — extensions/memory-core/src/short-term-promotion.ts:337
    normalizeMarkdownSkeletonHeadingBody does not remove :, so ## Notes: normalizes to notes: and misses MARKDOWN_SKELETON_HEADING_BODIES. That leaves common daily-note template headings promotable through the new guard; include : in the punctuation cleanup and add a regression case for trailing-colon skeleton labels while preserving durable Decision: headings.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.89

Acceptance criteria:

  • node scripts/run-vitest.mjs extensions/memory-core/src/short-term-promotion.test.ts -- --runInBand
  • CI=true pnpm exec oxfmt --check --threads=1 extensions/memory-core/src/short-term-promotion.ts extensions/memory-core/src/short-term-promotion.test.ts
  • git diff --check

What I checked:

Likely related people:

  • vignesh07: Authored the merged weighted short-term promotion flow that introduced the ranking/apply surface this PR modifies. (role: feature introducer; confidence: high; commits: 4c1022c73b39; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/short-term-promotion.test.ts)
  • mbelinky: Authored merged REM preview/replay and grounded backfill changes that expanded the short-term promotion and grounded candidate paths touched here. (role: recent area contributor; confidence: high; commits: 79348f73c8b6, e8209e4cf9b8; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/short-term-promotion.test.ts)
  • gumadeiras: Authored the merged dreaming self-ingestion guard, the closest existing contamination-filtering precedent in this promotion pipeline. (role: adjacent filtering contributor; confidence: medium; commits: 0c4e0d703023; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/short-term-promotion.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against c8a35c4645dc.

@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-memory-placeholder-promotions branch from c36f825 to 56ca6dc Compare May 15, 2026 05:34
@MonkeyLeeT MonkeyLeeT changed the title [codex] fix memory placeholder short-term promotions fix(memory): skip placeholder short-term promotions May 15, 2026
@MonkeyLeeT
MonkeyLeeT marked this pull request as ready for review May 15, 2026 05:50
@MonkeyLeeT

Copy link
Copy Markdown
Contributor Author

Codex review: needs real behavior proof before merge.

Summary The PR adds a shared memory-core predicate to reject markdown placeholder short-term promotion snippets across store load, recording, ranking, relocation, apply, and rehydration paths, with focused regression tests.

Reproducibility: yes. Current main has a source-level reproduction path because non-empty markdown placeholders can pass the existing empty/dreaming-contamination filters and relocation can match structurally meaningless snippets.

Real behavior proof Needs real behavior proof before merge: Needs contributor action: add terminal/live output, a recording, or redacted logs from a real memory workspace or live promotion path; update the PR body to trigger re-review, or ask a maintainer for @clawsweeper re-review if it does not.

Next step before merge This active draft contributor PR needs contributor-supplied real behavior proof and normal PR readiness handling rather than an automated repair branch.

Security Cleared: The diff only changes memory-core filtering logic and colocated tests, with no new dependencies, workflow changes, package metadata changes, secrets handling, or code-execution surface.

Review details

Added real behavior proof

@MonkeyLeeT

Copy link
Copy Markdown
Contributor Author

@hxy91819 PTAL thanks!

@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-memory-placeholder-promotions branch 2 times, most recently from e85b15e to 4e8b549 Compare May 15, 2026 15:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e8b549f86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/memory-core/src/short-term-promotion.ts Outdated
@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-memory-placeholder-promotions branch from 18d74b6 to be5a837 Compare May 16, 2026 05:16
@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-memory-placeholder-promotions branch 2 times, most recently from 705b245 to a7a7e7e Compare May 17, 2026 16:45
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:data-loss Can lose, corrupt, or silently drop user/session/config data. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. labels May 17, 2026
@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-memory-placeholder-promotions branch from a7a7e7e to 8b3146c Compare May 18, 2026 15:18
@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. and removed impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. impact:data-loss Can lose, corrupt, or silently drop user/session/config data. labels May 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 18, 2026
@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. and removed 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. labels May 18, 2026
@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-memory-placeholder-promotions branch from e0788a9 to 6c49f02 Compare May 21, 2026 23:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c49f02b48

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/memory-core/src/short-term-promotion.ts Outdated
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 22, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f9bf5f323

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +345 to +346
if (/:\s*\S/.test(headingBody) || headingWords.length >= 4) {
return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow concise heading snippets to be promoted

isMarkdownSkeletonSnippet currently classifies heading lines as placeholders unless they contain a colon or at least 4 words, so concise but durable notes like ## API keys rotated or - ## VPN outage fix are treated as unpromotable. Because isUnpromotableShortTermSnippet now gates store normalization, recording, ranking, and apply paths, these legitimate short-term memories are silently dropped and never make it into MEMORY.md.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f3c21510a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/memory-core/src/short-term-promotion.ts Outdated
@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 22, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 545febdb1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


function normalizeMarkdownSkeletonHeadingBody(raw: string): string {
return raw
.replace(/[-*+>`_[\](){}|~.,;!?]+/g, " ")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Strip trailing colons from skeleton heading labels

In normalizeMarkdownSkeletonHeadingBody, the punctuation cleanup omits :, so a placeholder heading like ## Notes: normalizes to notes: instead of notes and misses MARKDOWN_SKELETON_HEADING_BODIES; isMarkdownSkeletonSnippet then treats it as promotable content. Because this guard now gates store normalization, recording, ranking, and apply paths, common template headings with trailing colons can still be promoted into MEMORY.md, which undermines the placeholder filter this commit introduces.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026
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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory: skip markdown placeholder snippets during short-term promotion

1 participant