Repository navigation
fix(memory-core): MEMORY.md compaction deletes user notes written under a promotion-style heading - #116180
Conversation
… user sections Budget compaction decided that a MEMORY.md section belonged to OpenClaw purely from its heading text, so a user-authored section under a heading that looks generated, such as "## Promoted From Short-Term Memory (2026-04-10)", was eligible for deletion once the file plus the new promotion exceeded memoryFileMaxChars. The rewrite succeeded silently and the atomic replace made the loss durable. A matching heading is now provisional: the block is classified as a promotion only when it structurally contains at least one "<!-- openclaw-memory-promotion:... -->" marker, which buildPromotionSection emits for every promoted candidate. Marker-free sections are preserved. Generated sections, including the multi-project shape whose markers sit under "### Global" and "### Project:" subsections, are still dropped oldest-first, so the size bound from openclaw#73691 is unchanged. Extends openclaw#116057, which made only subsection handling marker-aware and left the top-level heading classifier trusting presentation text.
|
Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 3:47 AM ET / 07:47 UTC. ClawSweeper reviewWhat this changesThe branch restricts MEMORY.md budget compaction to fully generated promotion blocks, adds unit and production-path regressions for mixed user content, and increases one cold-start citation test timeout. Merge readinessThis PR remains necessary: it addresses a real durable-memory data-loss path left after the earlier heading-boundary repair. The patch makes deletion ownership depend on the complete generated marker-and-bullet structure rather than a promotion-like heading or marker alone; no concrete correctness or security defect is evident in the proposed change, but its persisted-memory behavior should be revalidated on the current merge result before landing. Priority: P1 Review scores
Verification
How this fits togetherMemory Core promotes recalled short-term notes into a workspace’s durable MEMORY.md file and compacts older generated entries when that file reaches its size budget. This change sits at the ownership boundary that decides which stored sections may be deleted before the promotion writer rewrites the file. flowchart LR
A[Short-term recall candidates] --> B[Promotion writer]
B --> C[Existing MEMORY.md]
C --> D[Compaction ownership check]
D --> E[Preserve user or mixed blocks]
D --> F[Drop oldest generated blocks]
E --> G[Updated durable memory]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +34, Tests +163. Total +197 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Land the conservative grammar-based ownership rule after current-merge-result validation confirms mixed operator text survives and clean generated blocks remain compactable oldest-first. Do we have a high-confidence way to reproduce the issue? Yes, from source and the supplied production-path regression: seed an over-budget MEMORY.md containing a marker-backed generated entry followed by unheaded user prose, then execute the real recall, ranking, promotion, and write path. The reported before/after evidence shows the prior ownership rule could remove that user prose. Is this the best way to solve the issue? Yes. Requiring the complete writer-emitted grammar is the narrowest maintainable ownership rule: it preserves any block that could contain user text while retaining oldest-first compaction for clearly generated entries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a67ad03eea4b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Validate the complete marker-and-entry grammar before treating a promotion-shaped block as writer-owned. Preserve marker-only and mixed blocks so unheaded operator notes cannot be deleted during budget compaction. Co-authored-by: yetval <[email protected]>
|
Merged via squash.
|
…n-dedupe * origin/main: (25 commits) fix(qqbot): use Gateway timezone for reminders (#116294) test(openai): cover out-of-order named mark acks docs(openai): clarify cumulative playback marks test(openai): cover sustained unnamed mark acknowledgements fix(openai): preserve playback acknowledgement order test(openai): verify bounded playback acknowledgements fix(openai): bound realtime playback marks test(agents): mock incremental registry persistence (#116307) fix(memory-core): MEMORY.md compaction deletes user notes written under a promotion-style heading (#116180) feat(reply): annotate recent history images (#100866) chore(ios): refresh native i18n inventory fix(ios): isolate capability router handlers docs(ios): cut 2026.7.22 release notes docs(hooks): document validation responses test(qa): assert hook account rejection reasons fix(gateway): validate hook delivery accounts perf(gateway): bound prepared runtime startup work (#116261) fix(agents): prevent registry stalls during large fan-outs (#116286) fix(sqlite): preserve replaced snapshot targets on Windows (#116284) fix(ci): load frozen shard runner without repository fetch (#116273) ...
…er a promotion-style heading (openclaw#116180) * fix(memory-core): stop MEMORY.md compaction from deleting marker-free user sections Budget compaction decided that a MEMORY.md section belonged to OpenClaw purely from its heading text, so a user-authored section under a heading that looks generated, such as "## Promoted From Short-Term Memory (2026-04-10)", was eligible for deletion once the file plus the new promotion exceeded memoryFileMaxChars. The rewrite succeeded silently and the atomic replace made the loss durable. A matching heading is now provisional: the block is classified as a promotion only when it structurally contains at least one "<!-- openclaw-memory-promotion:... -->" marker, which buildPromotionSection emits for every promoted candidate. Marker-free sections are preserved. Generated sections, including the multi-project shape whose markers sit under "### Global" and "### Project:" subsections, are still dropped oldest-first, so the size bound from openclaw#73691 is unchanged. Extends openclaw#116057, which made only subsection handling marker-aware and left the top-level heading classifier trusting presentation text. * fix(memory-core): preserve mixed promotion blocks Validate the complete marker-and-entry grammar before treating a promotion-shaped block as writer-owned. Preserve marker-only and mixed blocks so unheaded operator notes cannot be deleted during budget compaction. Co-authored-by: yetval <[email protected]> * test(memory-core): allow cold citation startup --------- Co-authored-by: Vincent Koc <[email protected]>
…n-dedupe * origin/main: (25 commits) fix(qqbot): use Gateway timezone for reminders (openclaw#116294) test(openai): cover out-of-order named mark acks docs(openai): clarify cumulative playback marks test(openai): cover sustained unnamed mark acknowledgements fix(openai): preserve playback acknowledgement order test(openai): verify bounded playback acknowledgements fix(openai): bound realtime playback marks test(agents): mock incremental registry persistence (openclaw#116307) fix(memory-core): MEMORY.md compaction deletes user notes written under a promotion-style heading (openclaw#116180) feat(reply): annotate recent history images (openclaw#100866) chore(ios): refresh native i18n inventory fix(ios): isolate capability router handlers docs(ios): cut 2026.7.22 release notes docs(hooks): document validation responses test(qa): assert hook account rejection reasons fix(gateway): validate hook delivery accounts perf(gateway): bound prepared runtime startup work (openclaw#116261) fix(agents): prevent registry stalls during large fan-outs (openclaw#116286) fix(sqlite): preserve replaced snapshot targets on Windows (openclaw#116284) fix(ci): load frozen shard runner without repository fetch (openclaw#116273) ...
Related: #116057
What Problem This Solves
Budget compaction could silently delete durable operator notes from
MEMORY.mdwhen a top-level heading resembled generated promotion history. The original patch correctly rejected heading-only ownership, but one marker still claimed the entire accumulated block, including unheaded user prose after a generated entry.This is a shipped P1 data-integrity bug in
v2026.7.2-beta.5and remained present onmain.Best Fix
Compaction now treats a promotion-shaped block as OpenClaw-owned only when its complete nonblank body matches the grammar emitted by
buildPromotionSection:### Global/### Project:headings;<!-- openclaw-memory-promotion:... -->marker;-entry.Marker-free, marker-only, malformed, or mixed blocks are preserved whole. A marker authenticates its generated entry, not arbitrary trailing operator text. Genuine generated blocks remain eligible for oldest-first compaction.
User Impact
Durable notes survive budget pressure even when they use a promotion-style heading or sit unheaded after generated entries. No config, migration, schema, or operator action changes.
Evidence
Exact repaired head:
c976279982759d9ba7825c1f62f0541ad71c72c3.memory-budget.test.ts: 30 tests passed.short-term-promotion.test.ts: 85 tests passed.tbx_01kyryz9gy6xe62pw7d91pk5dn: 143 focused tests passed, including the cold citation startup regression.c9762799827merged into livemaincc570a74532ein Testboxtbx_01kys1qtmatt5nw3skv32m96z0.pnpm check:changedpassed on the same Testbox lease, including extension production/test typechecks, lint, format, ownership guards, deadcode, database-first, and import-cycle checks.Hosted exact-head CI run
30524117587is green, includingchecks-node-changed-3andopenclaw/ci-gate. Latest ClawSweeper review found no code defect; its current-merge-result rank-up move is satisfied by the proof above.Attribution
Original diagnosis and marker-ownership direction by @yetval. Maintainer repair preserves contributor ancestry and co-author credit.