mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 14:01:33 +00:00
* fix(memory-core): stop MEMORY.md compaction from deleting user headings parseMemoryBlocks segmented MEMORY.md only on "## ", so a user heading of any other level did not close the promotion section above it. The section ran on to the next "## " heading or EOF, and dropping it to fit the budget deleted the user text it had swallowed, with no backup and no diagnostic. Close the current block on any ATX heading, keeping the generator's own "### Global" and "### Project: <key>" subheadings inside the promotion body so multi-project sections stay droppable whole. * fix(memory-core): identify generated promotion subsections by their entry marker The first exception treated every "### Global" and "### Project: <key>" heading under a promotion block as dreaming-owned, so a user who wrote one of those headings themselves still lost it to compaction, which is the same data-loss class this change set out to fix. A generated subsection always leads with an openclaw-memory-promotion entry marker comment, so require that marker as the next non-blank line before treating the heading as part of the promotion body. User headings that collide with the generated names now terminate the block and survive. * fix(memory-core): recognize tab-delimited and empty ATX headings The heading detector required a literal ASCII space after the opening # sequence. CommonMark also allows a tab or end of line, so a user note starting with a tab-delimited heading stayed inside the promotion block above it and was deleted when compaction dropped that block. Accept a space, a tab, or end of line after the # sequence. The generated subsection pattern stays space-only because that is what buildPromotionSection emits, so a tab-delimited heading is user-authored and is preserved. * fix(memory-core): preserve Setext headings during compaction Setext headings were still absorbed into the generated promotion block above them, so dropping that block could silently delete durable user notes. Move the heading paragraph into a preserved block when its underline is encountered, while keeping marker-backed generated content compactable. * fix(memory-core): preserve indented ATX headings --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>