Skip to content

fix(memory): preserve inline notes during MEMORY.md compaction - #164089

Merged
obviyus merged 5 commits into
openclaw:mainfrom
GoldArowana:fix/memory-promotion-inline-content
Nov 1, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
GoldArowana:fix/memory-promotion-inline-content

Conversation

@GoldArowana

@GoldArowana GoldArowana commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Related: #163900. Under MEMORY.md budget pressure, a promotion marker followed by a handwritten HTML comment can be mistaken for a completely generated block. The greedy marker regex consumes through the second closing delimiter, making that handwritten content eligible for deletion.

This keeps the existing permissive marker recognition for section boundaries, but uses a first-comment-bounded marker check when deciding whether the entire section is safe to delete. The two checks intentionally have different responsibilities: tightening section-boundary recognition would allow deletion of a generated prefix from a mixed section. The accepted line domain remains unchanged.

Contributor Credit and Ownership

Original contributor commits 2ac8d3ac3484 and f00cf7211efa, plus the contributor's main-merge commit 0cad931b130b, are preserved. Authorship maps to @GoldArowana; the merge uses GitHub's normal web-flow committer. No original maintainer repair commits or assignees were found. Linked #165245 concerns compaction observability, not this deletion bug. Held #164051 was left untouched.

Current main was integrated before proof because it had changed the owning module. No changes from the held PR were adopted.

Evidence

Real shipped CLI proof in secretless Linux Docker on Node 24.22.1:

  • Frozen current main: 87ba257f66d04d65772ce1e160c4cc9e872a21cd.
  • Candidate runtime build: 775a05671e3c381f850e86eededf0e87cea0bd16 (current main integrated).
  • Final head: 6b431a5ce43f759ca8774f019ca7d7ed99783a41; later changes only consolidate tests and document the behavior.
  • Each run used an isolated workspace, profile, config and SQLite/plugin state. A real daily note was staged through shipped memory rem-backfill --path <daily-note> --stage-short-term; no helper mocked the promotion store. Embeddings were disabled through the documented memory.search.provider: "none" FTS-only setting. No model credentials were used.
  • The actual writer action was:
openclaw --profile <isolated-profile> memory promote --apply --limit 1 --min-score 0 --min-recall-count 0 --min-unique-queries 0 --json

20 real apply runs, two per case on each ref:

Case Main, both runs Candidate, both runs
Over-budget promotion block with trailing handwritten HTML comment Deletes the handwritten comment and its enclosing old section Keeps the whole annotated section; reclaims a different clean generated section
Unannotated generated sections Oldest generated section reclaimed Same eligible section reclaimed
CRLF file with Unicode text and an embedded U+2028 marker separator File bytes unchanged File bytes unchanged
Embedded carriage return inside marker File bytes unchanged File bytes unchanged
Embedded U+2029 paragraph separator inside marker File bytes unchanged File bytes unchanged

The primary data-loss cases are successful writes, not no-op preservation: both refs report apply.applied: 1, append the new preference, and reclaim an existing generated section under the unchanged default prior-entry-loss bound. Candidate keeps HANDWRITTEN_KEEP café café 中文 🦞 exactly. The CRLF/separator controls execute the same apply command under budget pressure and report budget refusal rather than deleting protected bytes; their original buffers compare exactly equal afterward.

Actual MEMORY.md diff excerpts:

Main removes the annotated section:

-## Promoted From Short-Term Memory (2026-04-01)
-<!-- openclaw-memory-promotion:fixture-0 --> <!-- HANDWRITTEN_KEEP café café 中文 🦞 -->

Candidate instead removes a clean generated section, leaving that annotation intact:

-## Promoted From Short-Term Memory (2026-04-02)
-<!-- openclaw-memory-promotion:fixture-1 -->

Both diffs append the newly promoted sourced preference. Full before/after MEMORY.md files and unified diffs are retained with the proof. The primary fixture starts at 7,349 UTF-8 bytes: main ends at 6,448 bytes without the note, candidate at 6,499 bytes with it.

Focused regression: the existing mixed-block case now uses an annotated marker and verifies that the whole mixed section survives while the clean neighboring section is removed. Same final file on main: 1 intended failure / 12 passes (wrong section dropped); candidate: 13 passes. Existing heading, project grouping, budget/loss-bound and marker-only cases remain. Focused formatting passed.

Simplification retains the two necessary marker responsibilities and no additional parser or state. Whole-PR production +6/−1 (net +5; seven changed lines), tests 0 net, docs +2. The added duplicate unit setup is replaced by the strengthened existing case plus the shipped-CLI controls. No SDK, schema, config, loss limit or compaction policy expansion.

Compatibility and Merge Danger

Two-way door for the code: reverting restores prior classification without a migration. Deletions already made by an older build are not automatically restored. Blast radius is append-compaction eligibility for MEMORY.md promotion sections; generated-only reclamation stays available, while handwritten annotations make the entire section non-deletable.

Require a promotion marker to end at its first comment closing delimiter. Preserve mixed lines instead of pruning their enclosing section when the file exceeds its budget.

Related: openclaw#163900
@clawsweeper

clawsweeper Bot commented Oct 3, 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.

@GoldArowana
GoldArowana marked this pull request as ready for review October 3, 2026 06:28
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves promotion sections containing inline handwritten comments during MEMORY.md budget compaction.

Example: A promotion marker in the 2026-04-01 section is followed by <!-- HANDWRITTEN_KEEP café 中文 -->.

  • Before: Budget compaction accepts the combined comments as one generated marker and deletes the annotated section.
  • After: The annotated section survives, and a clean generated section is reclaimed instead.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow, correct data-preservation fix with shipped-CLI before/after evidence, an independent regression, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied Linux Docker output exercises the shipped memory promote --apply command with isolated workspace and SQLite state: both versions successfully append, while the candidate preserves the annotated section and reclaims a clean neighbor; clean-marker and separator controls support compatibility, and the final head leaves the tested production code unchanged.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Handwritten inline notes can disappear from durable memory when promotion compacts an oversized MEMORY.md.
Reason: The change restores the established mixed-content preservation contract without adding configuration, changing budgets, or broadening deletion.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current-main data-loss bug with a focused patch and credible shipped-CLI proof; no actionable code defects remain.

Priority: P1
Reviewed head: 6b431a5ce43f759ca8774f019ca7d7ed99783a41

Before merge

None.

Findings

None.

Agent review details

How this fits together

Memory Core's promotion writer passes existing MEMORY.md content, a new promotion section, and budget limits to the compactor, then publishes the complete result only if it fits.

flowchart TD
  A[Memory promotion CLI or dreaming] --> B[Promotion writer]
  C[Existing MEMORY.md] --> B
  B --> D[Budget compactor]
  D --> E[Preserve mixed sections]
  D --> F[Reclaim clean generated sections]
  E --> G[Final budget check and publication]
  F --> G
Loading

Technical review

Best possible solution:

Land the focused deletion-eligibility repair after required checks pass, preserving existing section boundaries and loss limits.

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

The greedy marker check and its publication caller establish the failure path, corroborated by supplied paired CLI output; this read-only review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete repair: tighten only deletion eligibility while retaining the existing boundary predicate, preventing the previously identified prefix-deletion regression.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Generated-block eligibility and mixed-content regression keeps the original intent (d952566: Preserve entire ambiguous or mixed promotion-shaped blocks while reclaiming genuinely generated blocks.)
  • Promotion subsection and Setext boundary recognition keeps the original intent (772235c: Separate user headings from generated content without splitting marker-backed generated subsections.)
  • Documented bounded append compaction keeps the original intent (fc0360d: Honor consuming agents' bootstrap budgets while preserving user content and enforcing prior-entry loss limits.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Yuval Dinodia: Raw commit d952566 adds extensions/memory-core/src/memory-budget.ts:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d95256638521; files: extensions/memory-core/src/memory-budget.ts)
  • Dallin Romney: Raw commit fc0360d adds extensions/memory-core/src/memory-budget.ts:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fc0360dab2e1; files: extensions/memory-core/src/memory-budget.ts)
  • Peter Steinberger: Raw commit e3fe108 adds extensions/memory-core/src/memory-budget.ts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e3fe108378f6; files: extensions/memory-core/src/memory-budget.ts)

PR surface

Source +5, Tests 0, Docs +2. Total +7 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 3 3 0
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 11 4 +7

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: Current-main budget compaction can silently delete handwritten durable memory during an otherwise successful promotion.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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-10-03T06:34:58.661Z sha 2ac8d3a :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-03T10:56:29.652Z sha 2ac8d3a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T20:21:28.251Z sha f00cf72 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-04T01:25:47.027Z sha 0cad931 :: needs maintainer review before merge. :: none

Reviewed November 1, 2026, 9:24 AM ET / 14:24 UTC (Revision 5).

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes paired, synthetic before/after evidence through the real promotion writer for both inline-note cases and an all-clean control, actual published-file diffs, exact parameters (including the explicit fixture loss limit), a reproducible harness, focused-test wall times, and available CI timing. The head remains 2ac8d3ac34843ebeeb93182fbd6af3c94d8eaa7e.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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: 🦪 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 Oct 3, 2026
@obviyus

obviyus commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks @GoldArowana for fixing the inline-comment data-loss case and providing the writer evidence. While checking that compaction only becomes more conservative, I found two safety issues in 2ac8d3ac34843ebeeb93182fbd6af3c94d8eaa7e:

  1. The marker character domain widens. In memory-budget.ts:9, base's .* rejects CR, U+2028 and U+2029 inside a marker; the new [^\n] accepts all three. A secretless Node 24 Docker probe returned baseEligible=false, candidateEligible=true for each of these markers:

    `<!-- openclaw-memory-promotion:generated${separator}HANDWRITTEN keep -->`
    // separator: "\r", "\u2028", "\u2029"

    parseMemoryBlocks splits only on /\r?\n/, so each remains one parser line. With a promotion heading and following bullet, a previously protected block becomes eligible for deletion.

  2. Narrowing the marker also changes section boundaries. The same regex drives startsGeneratedPromotionSubsection (memory-budget.ts:87–98). This fixture exposes a second widening:

    ## Promoted From Short-Term Memory (2026-04-10)
    <!-- openclaw-memory-promotion:clean -->
    - generated content
    ### Global
    <!-- openclaw-memory-promotion:mixed --> <!-- my note: keep -->
    - handwritten bullet
    HANDWRITTEN separate line: keep this too.

    I executed the actual compactMemoryForBudget owner in secretless Docker with newSection: "x".repeat(500) and budgetChars: 100. The proof used Node's TypeScript stripping, omitted the unrelated SDK imports, and compared the old regex with a temporary dot-domain repair of this PR's regex. Base: droppedDates=[], entire input unchanged. Repaired candidate: droppedDates=["2026-04-10"], output starts at ### Global. The inline-comment marker has the same acceptance/rejection in the submitted and dot-repaired regexes; fixing the character domain alone therefore leaves this boundary problem. Base treats the section as mixed and preserves all of it, whereas the narrowed marker causes a split and permits deleting its formerly protected prefix. The handwritten suffix survives this particular case; the problem is widened deletion eligibility for the prefix.

Suggested repair shape: retain the original . character domain while rejecting an embedded closing delimiter, and separate subsection-boundary recognition from deletion eligibility so a stricter eligibility test cannot split a previously protected section into deletable pieces. Could you add regression coverage for all three separators and the subsection fixture, alongside the inline-note cases?

I have not pushed changes or run the full Gateway/live-provider acceptance flow; this is a data-safety handoff, not landing approval. Leaving the PR open for the follow-up.

@GoldArowana

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed reproduction. Both regressions are addressed in f00cf7211efa:

  • The deletion check uses the original dot character domain again, while still rejecting an embedded -->.
  • Section association and deletion eligibility now use separate predicates. Annotated markers continue to belong to their promotion section when handling ### Global, ### Project: ..., and Setext headings; the entire mixed section remains protected.

Added seven regressions for CR, U+2028, U+2029, both promotion subsection forms, and both Setext underline forms. The original two inline-note regressions remain in place.

I also exercised the production promotion writer with synthetic files and the default maxPriorEntryLossFraction=0.25, using budgets that allow the final write. Before the follow-up, all seven cases wrote successfully but removed the protected section or its prefix. After the fix, all seven preserve the full section, reclaim the adjacent clean section, append the new memory, and stay within the file budget. This is source-level writer proof, not a live Gateway or provider test.

Validation: 168 focused tests passed (including seven temporary writer-proof cases), the committed budget suite passes 38/38 in 8.786s process wall time, and all 28 selected check components passed. The PR body now contains the updated evidence and the reproducible writer fixture.

MoerAI added a commit to MoerAI/openclaw that referenced this pull request Oct 10, 2026
…on (openclaw#163900)

A marker line qualified a consolidation block for deletion when it merely started with a generated marker: the greedy .*--> in the lineage and promotion marker regexes accepted '<!-- openclaw-memory-lineage:key --> <!-- user note -->' as one generated comment, so budget compaction could drop a block holding a handwritten inline note. Deletion qualification now requires each marker line to be exactly one HTML comment, using the same single-comment predicate as openclaw#164089; boundary detection and entry counting keep the existing matcher.

Proof: built CLI memory promote --apply on an isolated workspace. The reviewed head dropped the annotated oldest consolidation section and its note; this commit keeps that section byte for byte and drops the next plain generated section instead.
@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 1, 2026
@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Related: #163900. Under MEMORY.md budget pressure, a promotion marker followed by a handwritten HTML comment can be mistaken for a completely generated block. The greedy marker regex consumes through the second closing delimiter, making that handwritten content eligible for deletion.

This keeps the existing permissive marker recognition for section boundaries, but uses a first-comment-bounded marker check when deciding whether the entire section is safe to delete. The two checks intentionally have different responsibilities: tightening section-boundary recognition would allow deletion of a generated prefix from a mixed section. The accepted line domain remains unchanged.

Contributor Credit and Ownership

Original contributor commits 2ac8d3ac3484 and f00cf7211efa, plus the contributor's main-merge commit 0cad931b130b, are preserved. Authorship maps to @GoldArowana; the merge uses GitHub's normal web-flow committer. No original maintainer repair commits or assignees were found. Linked #165245 concerns compaction observability, not this deletion bug. Held #164051 was left untouched.

Current main was integrated before proof because it had changed the owning module. No changes from the held PR were adopted.

Evidence

Real shipped CLI proof in secretless Linux Docker on Node 24.22.1:

  • Frozen current main: 87ba257f66d04d65772ce1e160c4cc9e872a21cd.
  • Candidate runtime build: 775a05671e3c381f850e86eededf0e87cea0bd16 (current main integrated).
  • Final head: 6b431a5ce43f759ca8774f019ca7d7ed99783a41; later changes only consolidate tests and document the behavior.
  • Each run used an isolated workspace, profile, config and SQLite/plugin state. A real daily note was staged through shipped memory rem-backfill --path <daily-note> --stage-short-term; no helper mocked the promotion store. Embeddings were disabled through the documented memory.search.provider: "none" FTS-only setting. No model credentials were used.
  • The actual writer action was:
openclaw --profile <isolated-profile> memory promote --apply --limit 1 --min-score 0 --min-recall-count 0 --min-unique-queries 0 --json

20 real apply runs, two per case on each ref:

Case Main, both runs Candidate, both runs
Over-budget promotion block with trailing handwritten HTML comment Deletes the handwritten comment and its enclosing old section Keeps the whole annotated section; reclaims a different clean generated section
Unannotated generated sections Oldest generated section reclaimed Same eligible section reclaimed
CRLF file with Unicode text and an embedded U+2028 marker separator File bytes unchanged File bytes unchanged
Embedded carriage return inside marker File bytes unchanged File bytes unchanged
Embedded U+2029 paragraph separator inside marker File bytes unchanged File bytes unchanged

The primary data-loss cases are successful writes, not no-op preservation: both refs report apply.applied: 1, append the new preference, and reclaim an existing generated section under the unchanged default prior-entry-loss bound. Candidate keeps HANDWRITTEN_KEEP café café 中文 🦞 exactly. The CRLF/separator controls execute the same apply command under budget pressure and report budget refusal rather than deleting protected bytes; their original buffers compare exactly equal afterward.

Actual MEMORY.md diff excerpts:

Main removes the annotated section:

-## Promoted From Short-Term Memory (2026-04-01)
-<!-- openclaw-memory-promotion:fixture-0 --> <!-- HANDWRITTEN_KEEP café café 中文 🦞 -->

Candidate instead removes a clean generated section, leaving that annotation intact:

-## Promoted From Short-Term Memory (2026-04-02)
-<!-- openclaw-memory-promotion:fixture-1 -->

Both diffs append the newly promoted sourced preference. Full before/after MEMORY.md files and unified diffs are retained with the proof. The primary fixture starts at 7,349 UTF-8 bytes: main ends at 6,448 bytes without the note, candidate at 6,499 bytes with it.

Focused regression: the existing mixed-block case now uses an annotated marker and verifies that the whole mixed section survives while the clean neighboring section is removed. Same final file on main: 1 intended failure / 12 passes (wrong section dropped); candidate: 13 passes. Existing heading, project grouping, budget/loss-bound and marker-only cases remain. Focused formatting passed.

Simplification retains the two necessary marker responsibilities and no additional parser or state. Whole-PR production +6/−1 (net +5; seven changed lines), tests 0 net, docs +2. The added duplicate unit setup is replaced by the strengthened existing case plus the shipped-CLI controls. No SDK, schema, config, loss limit or compaction policy expansion.

Compatibility and Merge Danger

Two-way door for the code: reverting restores prior classification without a migration. Deletions already made by an older build are not automatically restored. Blast radius is append-compaction eligibility for MEMORY.md promotion sections; generated-only reclamation stays available, while handwritten annotations make the entire section non-deletable.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@obviyus
obviyus merged commit 49600b5 into openclaw:main Nov 1, 2026
120 of 122 checks passed
@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Landed in 49600b5. Thanks @GoldArowana. memory promote no longer deletes handwritten notes in MEMORY.md.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…law#164089)

fix(memory): keep handwritten notes attached to promotion blocks in MEMORY.md

Fixes openclaw#163900.

When `openclaw memory promote --apply` had to make room in MEMORY.md, a greedy marker match treated a generated promotion block followed by a handwritten HTML comment as one generated block and deleted both, so the user's note was lost. Generated blocks with a handwritten annotation are now kept whole, and clean generated blocks are still reclaimed. Boundary recognition and deletion eligibility are now separate checks. CRLF and Unicode line-separator content is unchanged.

Evidence: built `memory promote --apply` on Node 24.22.1, 20 runs. On main, two runs deleted the handwritten comment; with this change, two runs kept the whole annotated section, reclaimed a clean generated section and appended the new promotion. Unannotated blocks stayed reclaimable. CRLF and Unicode separator controls were byte-identical. Details and MEMORY.md diffs: openclaw#164089 (comment).

Thanks @GoldArowana.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 8, 2026
fix(memory): keep handwritten notes attached to promotion blocks in MEMORY.md

Fixes #163900.

When `openclaw memory promote --apply` had to make room in MEMORY.md, a greedy marker match treated a generated promotion block followed by a handwritten HTML comment as one generated block and deleted both, so the user's note was lost. Generated blocks with a handwritten annotation are now kept whole, and clean generated blocks are still reclaimed. Boundary recognition and deletion eligibility are now separate checks. CRLF and Unicode line-separator content is unchanged.

Evidence: built `memory promote --apply` on Node 24.22.1, 20 runs. On main, two runs deleted the handwritten comment; with this change, two runs kept the whole annotated section, reclaimed a clean generated section and appended the new promotion. Unannotated blocks stayed reclaimable. CRLF and Unicode separator controls were byte-identical. Details and MEMORY.md diffs: #164089 (comment).

Thanks @GoldArowana.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 49600b5)

Release adaptation: Apply strict generated-block deletion eligibility to the release memory-budget owner; retain existing handwritten-prose coverage alongside inline-comment regression.

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 9, 2026
Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions.

Backport-of: 0a171b4 — Leizhen Zhang — fix(auto-reply): long punctuation runs stall abort-trigger detection (#184433)
Backport-of: 49600b5 — Long Jin — fix(memory): preserve inline notes during MEMORY.md compaction (#164089)
Backport-of: 982f3b1 — RoboClaw — fix(imessage): report Automation failures after Gateway updates (#186117)
Backport-of: 3f7ee38 — art22s — fix: require approval for dynamic shell predicates (#187884)

Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally.

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 9, 2026
Backport #164089. Keep annotated promotion sections intact while reclaiming clean generated sections.

Proof: 3 red regressions and 19 passing controls; 193 focused/sibling tests pass with one existing platform skip; all 10 static/type gates pass.
Real built CLI qualification remains blocked before domain execution by runtime-publication service inspection; no bypass or release qualification is claimed.

Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 9, 2026
* fix(gateway): publish node reapproval with committed pairing facts

Adapt main commit 94f180d to the extended-stable worker dispatcher, retaining cleanup admission and stale-session fencing.

Co-authored-by: RomneyDa <[email protected]>

* test(gateway): clarify CLI announcement tool-only phase

Keep exact token, barrier, and completion ordering assertions intact while explicitly excluding narration before the barrier.

Co-authored-by: RomneyDa <[email protected]>

* style(gateway): format node reapproval regression

Reflow the spy chain reported by hosted CI; no behavioral changes.

Co-authored-by: RomneyDa <[email protected]>

* test(secrets): decouple Telegram fixture from plugin discovery

Import the real public Telegram secret collector directly so collection does not depend on Gateway discovery environment. Exercise collection with bundled plugins disabled while retaining existing token assertions. Gateway timeout attribution remains unresolved; no production behavior or timeout changes.

Co-authored-by: RomneyDa <[email protected]>

* test(secrets): load Telegram fixture through public resolver

Replace the static extension import rejected by core type and boundary checks with the existing test public-artifact resolver. Keep the real collector in the Vitest module graph and preserve the disabled-discovery regression.

Independent source review accepted; local test, typecheck, build, install, and performance execution remain excluded by operator instruction. Hosted CI must validate the correction.

Co-authored-by: RomneyDa <[email protected]>

* style(secrets): format Telegram fixture import

Co-authored-by: RomneyDa <[email protected]>

* fix(ui): honor recovery holds before initial chat history

Keep drafting available while the existing send owner holds recovery or a retained initial turn. Restore Send when that hold clears without waiting for initial history or submitting the draft automatically.

Add renderer regressions for both holds and clarify the pre-history outbox contract. Controlled real-Gateway red/green evidence: 42523861169 / 42526889715. Diagnostic branch is not merged.

Co-authored-by: RomneyDa <[email protected]>

* fix(ui): preserve startup status presentation while holding send

Restore the existing connected startup/history status suppression without reopening Send admission. Extend both durable hold regressions to reject the duplicate composer status band. Existing cloud E2E assertions remain unchanged.

Co-authored-by: RomneyDa <[email protected]>

* fix(release): backport installer, service, path and telemetry repairs

Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions.

Backport-of: eb5d0cb — Javier MV — fix(install): keep the installed runtime private under umask 0002 (#186782)
Backport-of: b079019 — Sukhdeep — fix(daemon): Gateway repair stops the Gateway and fails when macOS denies the Trash (#189321)
Backport-of: 558e2f3 — YangManBOBO — fix(cli): compare gateway state dirs case-insensitively on Windows (#185917)
Backport-of: b7ce1c3 — Peter Steinberger — test(windows): keep ordinary CLI coverage in one partition
Backport-of: ba75cf7 — Juan Buhagiar Duijst — fix(diagnostics-otel): gateway stalls after model calls on large sessions with content capture on (#186666)

Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally.

Co-authored-by: RomneyDa <[email protected]>

* fix(release): preserve notes and harden messaging and exec approval

Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions.

Backport-of: 0a171b4 — Leizhen Zhang — fix(auto-reply): long punctuation runs stall abort-trigger detection (#184433)
Backport-of: 49600b5 — Long Jin — fix(memory): preserve inline notes during MEMORY.md compaction (#164089)
Backport-of: 982f3b1 — RoboClaw — fix(imessage): report Automation failures after Gateway updates (#186117)
Backport-of: 3f7ee38 — art22s — fix: require approval for dynamic shell predicates (#187884)

Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally.

Co-authored-by: RomneyDa <[email protected]>

* fix(release): retain sandbox, recovery lease and Matrix boundaries

Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions.

Backport-of: a19f1bf — Agustin Rivera — fix(agents): fail closed when sandboxed spawned children resolve CLI-backed models (#178742)
Backport-of: c9f3f82 — Peter Steinberger — fix(agents): release restart-recovery fences for killed runs (#181992)
Backport-of: dfb6454 — Leizhen Zhang — fix(matrix): crafted formatted_body stalls the Gateway in the mention check (#184432)

Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally.

Co-authored-by: RomneyDa <[email protected]>

* fix(config): preserve last-good state through writes and rollback

Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions.

Backport-of: 99418fc — weiqinl — fix(config): keep last-known-good when the observer flags the config as truncated (#152565)

Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally.

Co-authored-by: RomneyDa <[email protected]>

* fix(sessions): preserve history when relocating relative stores

Adapt approved source fixes to the September extended-stable owners. Preserve original APIs and custody; include review-driven regressions.

Backport-of: a64daf7 — Peter Steinberger — fix(sessions): resolve relative session stores against the state dir, not the working directory (#182444)

Validation: independent source review, exact patch/file identity and git diff --check. Runtime tests, types and builds deferred to authorized remote CI; not run locally.

Co-authored-by: RomneyDa <[email protected]>

* fix(release): repair September backport type contracts

Split terminal recovery actions into distinct discriminants without changing behavior. Use the branch-native Doctor import signature, checking held maintenance authority before and after the awaited import.

Validation: independent exact-diff source review, formatter and git diff --check passed. Local tests, typechecks and builds not run per operator restriction; fresh exact-head remote qualification required. Repairs CI 42643973970 attempt 1.

Co-authored-by: RomneyDa <[email protected]>

* fix(release): align backport regressions with September contracts

Preserve uncertain config-write outcomes while correcting branch-native fixture APIs and lint errors found by hosted CI.

Co-authored-by: RomneyDa <[email protected]>

* test(ci): separate Windows capacity from growing inventory

Keep package coverage and the five-job limit independent of a historical timing snapshot. Preserve the rounded capacity boundary and exercise the documented bounded-growth fallback with fixed estimates.

Co-authored-by: RomneyDa <[email protected]>

* test(node-host): keep launcher cleanup with its invoke owner

Wait for a positive launcher PID before probing liveness, and cancel through the existing invocation owner on every exit path. Never send SIGKILL to file-derived PID zero.

Co-authored-by: RomneyDa <[email protected]>

* test(release): observe owned Gateway reservation cleanup

Verify the real reservation closes before relaunch instead of rebinding an already-released port that another socket can acquire. Preserve all seven packaged startup recovery scenarios.

Co-authored-by: RomneyDa <[email protected]>

* test(release): capture native compiler busy-executable evidence

Preserve real API execution and errors while recording failure-only executable inode and writable descriptor metadata. Add a Linux kernel-path diagnostic regression; no retry or copy change.

Co-authored-by: RomneyDa <[email protected]>

* test(release): repair stability regression fixtures

Register CLI admission metadata through the runtime registry, observe the rollback health baseline, and preserve exact SQLite byte expectations.

Co-authored-by: RomneyDa <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…law#164089)

fix(memory): keep handwritten notes attached to promotion blocks in MEMORY.md

Fixes openclaw#163900.

When `openclaw memory promote --apply` had to make room in MEMORY.md, a greedy marker match treated a generated promotion block followed by a handwritten HTML comment as one generated block and deleted both, so the user's note was lost. Generated blocks with a handwritten annotation are now kept whole, and clean generated blocks are still reclaimed. Boundary recognition and deletion eligibility are now separate checks. CRLF and Unicode line-separator content is unchanged.

Evidence: built `memory promote --apply` on Node 24.22.1, 20 runs. On main, two runs deleted the handwritten comment; with this change, two runs kept the whole annotated section, reclaimed a clean generated section and appended the new promotion. Unannotated blocks stayed reclaimable. CRLF and Unicode separator controls were byte-identical. Details and MEMORY.md diffs: openclaw#164089 (comment).

Thanks @GoldArowana.

Co-authored-by: Ayaan Zaidi <[email protected]>

Release adaptation: Scoped deletion-eligibility regex and focused memory compaction regression. Later 22135bd only extracts promotion budget configuration; not required for marker recognition. Existing block boundaries and generated compaction retained.

(cherry picked from commit 49600b5)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit a98dbc01e5fb40463eeb273363d27126f476a8e9)
(cherry picked from commit b5fcf6104e402f16587372756587cbfb45c27fd7)
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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

2 participants