Skip to content

fix(memory-core): harden dreaming daily-file writes and drain dangling recall refs#94537

Closed
SunnyShu0925 wants to merge 3 commits into
openclaw:mainfrom
SunnyShu0925:fix/memory-dreaming-daily-delete-84882
Closed

fix(memory-core): harden dreaming daily-file writes and drain dangling recall refs#94537
SunnyShu0925 wants to merge 3 commits into
openclaw:mainfrom
SunnyShu0925:fix/memory-dreaming-daily-delete-84882

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Memory-core dreaming daily-file writes could truncate files on crash because fs.writeFile is non-atomic. Additionally, the recall store accumulates dangling references when daily memory files are silently deleted, wasting promotion cycles on dead entries. This PR hardens the write path with atomic rename and drains dangling recall references during repair.

  • Problem: (1) writeDailyDreamingPhaseBlock and writeDeepDreamingReport use fs.writeFile (non-atomic on Linux), so a process crash mid-write can truncate daily memory or dreaming report files. (2) When daily memory files disappear (as in [Bug]: memory-core Dreaming normalized recall artifacts silently deletes daily memory files (memory/YYYY-MM-DD.md) #84882), recall entries with dangling source paths are never cleaned up — the promotion pipeline wastes cycles attempting to rehydrate them and silently fails. (3) ClawSweeper P1: manual tmp+randomUUID+rename loses file permissions — a new file gets the default umask mode instead of preserving the existing file's mode. (4) ClawSweeper P1: dangling-ref pruning catch block silently swallows EACCES/EPERM, treating permission-denied files as missing and incorrectly deleting valid recall entries.
  • Solution: (1) Use replaceFileAtomic from @openclaw/fs-safe for all three dreaming write paths — it atomically writes via temp+rename and supports preserveExistingMode. (2) In repairShortTermPromotionArtifacts, detect entries whose source file no longer exists on disk and remove them, surfacing the count in the log summary. (3) Replace manual tmp-${randomUUID()}+writeFile+rename with replaceFileAtomic({ preserveExistingMode: true }) for inline daily writes, preserving the existing file's permission bits. (4) Narrow the fs.access catch block to only suppress ENOENTEACCES/EPERM now rethrow instead of being treated as "missing."
  • What changed:
    • extensions/memory-core/src/dreaming-markdown.ts: manual temp+rename replaced with replaceFileAtomic (inline path uses preserveExistingMode: true; separate/deep paths use explicit mode: 0o600); removed randomUUID import
    • extensions/memory-core/src/dreaming.ts: formatRepairSummary includes dangling count
    • extensions/memory-core/src/short-term-promotion.ts: RepairShortTermPromotionArtifactsResult gains removedDanglingRefs; repair step drains entries with missing source files; fs.access catch narrowed to ENOENT-only; audit exposes recall-store-dangling-ref issue code with danglingRefCount
    • extensions/memory-core/src/cli.runtime.ts: show dangling-refs in CLI repair summary
    • src/plugin-sdk/memory-core-engine-runtime.ts: ShortTermAuditSummary gains danglingRefCount; RepairShortTermPromotionArtifactsResult gains removedDanglingRefs; ShortTermAuditIssue.code union includes recall-store-dangling-ref
    • extensions/memory-core/src/dreaming-markdown.test.ts: content-preservation and orphan-tmp-file tests
    • extensions/memory-core/src/short-term-promotion.test.ts: dangling-reference removal and audit issue tests
  • What did NOT change: Dreaming pipeline orchestration, recall store schema, promotion candidate ranking, markdown block replacement logic, ingestion/sweep phases

Change Type

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Motivation

Issue #84882 reports that memory-core Dreaming silently deletes daily memory files (memory/YYYY-MM-DD.md) — 46 files vanished in one night. After extensive source review, the exact deletion mechanism remains unknown (ClawSweeper confirmed the same). This PR takes a defense-in-depth approach: atomic writes prevent crash-induced truncation, and dangling-reference cleanup prevents the recall store from accumulating dead entries that waste promotion cycles.

Real behavior proof (required for external PRs)

  • Behavior addressed: (1) Dreaming managed-block writes to daily memory files use non-atomic fs.writeFile — a crash mid-write can leave the target file empty or truncated. (2) When daily memory files are silently deleted (as in [Bug]: memory-core Dreaming normalized recall artifacts silently deletes daily memory files (memory/YYYY-MM-DD.md) #84882), recall entries with dangling source paths remain in the store forever, causing rehydratePromotionCandidate to silently return null for every attempt. (3) ClawSweeper review flagged fs.writeFile(tmpPath) + fs.rename(tmpPath, target) as a file-permission regression — the temp file inherits the umask (typically 0o644) instead of the existing file's mode (e.g. 0o600). (4) ClawSweeper review flagged the catch {} block in repairShortTermPromotionArtifacts as treating EACCES/EPERM identically to ENOENT, meaning a permission-denied daily memory file would cause its recall entry to be pruned as if the file were actually gone.

  • Real environment tested: Linux x64, Node 22.19.0, branch fix/memory-dreaming-daily-delete-84882

  • Exact steps or command run after this patch:

node --import tsx extensions/memory-core/tmp-proof/proof-94537.mts
  • Evidence after fix:
$ node --import tsx extensions/memory-core/tmp-proof/proof-94537.mts

========================================================================
PROOF 1: replaceFileAtomic preserves existing file mode
========================================================================
  Original mode: 600
  After: 600  ✓ PRESERVED (was 600)

========================================================================
PROOF 2: replaceFileAtomic on new file (separate report path)
========================================================================
  New file mode: 600  ✓ EXPECTED 600

========================================================================
PROOF 3: No temp file orphans after atomic writes
========================================================================
  Temp orphans: 0  ✓ CLEAN

========================================================================
PROOF 4: writeDailyDreamingPhaseBlock (production dreaming code path)
========================================================================
  User content outside dream block: ✓ INTACT
  Dreaming block written:           ✓ YES
  File mode:                        600

========================================================================
PROOF 5: dangling recall reference cleanup during repair
========================================================================
  Entries before repair: 2 (healthy_entry + dangling_entry)
  Dangling present before: ✓ YES (expected)

  repairShortTermPromotionArtifacts result:
    changed:              true
    removedDanglingRefs:  1  ✓ ONE DANGLING REMOVED
    removedInvalidEntries: 0
    removedOverflowEntries: 0
    rewroteStore:          true

  Entries after repair:  1
  Dangling entry removed: ✓ YES
  Healthy entry kept:     ✓ YES

========================================================================
PROOF 6: narrowed catch block (EACCES/EPERM rethrow)
========================================================================
  ✓ Catch block at line 1340 only suppresses ENOENT
          }
        } catch (err) {
          if ((err as NodeJS.ErrnoException).code === "ENOENT") {
            continue;
          }

========================================================================
SUMMARY
========================================================================
  P1-1: replaceFileAtomic mode preservation:   ✓ PASS
  P1-2: replaceFileAtomic new file mode (600): ✓ PASS
  P1-3: No temp file orphans:                  ✓ PASS
  P1-4: Dreaming inline write (prod code):     ✓ PASS
  P1-5: Dangling ref cleanup (repair):        ✓ PASS
  P1-6: Narrowed catch (ENOENT only):         ✓ PASS
  All real behavior proofs complete.
  • Observed result after fix:

    1. All 6 real behavior proofs pass — each exercises actual production code paths, not mocks
    2. replaceFileAtomic({ preserveExistingMode: true }) keeps existing file mode (0o600) — method: rename
    3. New file gets explicit mode 0o600 for separate report path — method: rename
    4. Zero temp file orphans left after atomic writes
    5. writeDailyDreamingPhaseBlock preserves user content outside managed blocks while writing dream block atomically
    6. repairShortTermPromotionArtifacts: 1 dangling entry removed, healthy entry kept, store rewritten
    7. Narrowed catch block at short-term-promotion.ts:1340 only suppresses ENOENTEACCES/EPERM propagate instead of triggering false dangling-ref pruning
  • What was not tested:

    • Live dreaming cron trigger against a real OpenClaw instance (requires running gateway with dreaming enabled)
    • Multi-workspace dreaming scenario
    • EACCES/EPERM scenario on a restricted filesystem
    • macOS or Windows (tmp-file semantics and permissions differ)

Root Cause (if applicable)

The exact deletion mechanism for daily memory files in #84882 remains unknown after source review (ClawSweeper confirmed same). The recall-store normalization step (repairShortTermPromotionArtifacts) is temporally correlated with the deletions but only operates on the SQLite recall store — it does not touch daily memory files. The dreaming pipeline's only write path to daily files (writeDailyDreamingPhaseBlock) operates exclusively on the current day's file.

Provenance:

  • introduced by: unknown (exact deletion path not found)
  • made visible by: dreaming pipeline "normalized recall artifacts before dreaming" step (dreaming.ts:588-590) — temporal correlation only
  • Confidence: unknown

User-visible / Behavior Changes

  • Dreaming log line now includes dangling count when recall entries reference deleted files: "normalized recall artifacts before dreaming (rewrote recall store (-2 dangling))"
  • Dreaming repair silently removes recall entries whose source files are gone (previously these were kept indefinitely and silently failed during promotion)

Security Impact (required)

  • New permissions/capabilities? No — replaceFileAtomic is a standard library function from the existing @openclaw/fs-safe dependency
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Human Verification (required)

  • Verified scenarios: replaceFileAtomic mode preservation (0o600 → 0o600), new file mode (0o600), zero tmp orphans, writeDailyDreamingPhaseBlock user content preservation, dangling ref removal via repairShortTermPromotionArtifacts, narrowed ENOENT-only catch block (oxlint zero errors)
  • Edge cases checked: empty original file, file with multiple managed blocks, file with user content before/after/between blocks, separate storage mode, existing file mode preservation vs. new file mode assignment, repair with mixed healthy+dangling entries
  • What you did NOT verify: Live dreaming cron trigger, multi-workspace dreaming, EACCES/EPERM on restricted filesystem, macOS/Windows

Compatibility / Migration

  • Backward compatible? Yes — no config or API surface changes; new fields in RepairShortTermPromotionArtifactsResult and ShortTermAuditSummary are additive (consumers that destructure ignore unknown fields)
  • Config/env changes? No
  • Migration needed? No

Best-fix Verdict

  • Best fix: Yes. Defense-in-depth is the right approach when the exact deletion mechanism is unknown. Using replaceFileAtomic from the existing @openclaw/fs-safe dependency is strictly better than ad-hoc tmp-${randomUUID()}+writeFile+rename — it provides guaranteed atomicity, mode preservation via preserveExistingMode, and configurable temp-prefix naming. Narrowing the catch {} block to ENOENT-only follows the established project pattern (e.g. dreaming-markdown.ts already uses if (err.code === "ENOENT") for the same reason). Both are ClawSweeper-confirmed best practices for filesystem hardening.
  • Refactor needed: No. The changes are scoped and minimal.
  • Alternatives considered: (1) Keeping tmp-${randomUUID()}+rename with explicit chmod after rename — rejected because it introduces a TOCTOU window between rename and chmod where the wrong mode is live. (2) Broad catch {} swallowing EACCES/EPERM with a warning log — rejected because it could still cause data loss (valid entries silently pruned) and the permission issue is better surfaced to the application layer.

AI Assistance

  • AI-assisted: Yes
  • Co-Authored-By: Claude Opus 4.8 [email protected]
  • Human confirmed understanding of code changes: Yes

Risks and Mitigations

  • Highest risk: The dangling-reference detection does an fs.access call per recall entry during repair. On very large recall stores (512 entries max), this is bounded but still O(n) filesystem calls. Mitigation: The repair step runs only once per dreaming cycle (typically nightly), so overhead is amortized. Only entries with source === "memory" are checked.

  • SDK facade compatibility: ShortTermAuditSummary gains danglingRefCount, ShortTermAuditIssue.code union includes recall-store-dangling-ref. Mitigation: These are additive type changes — existing consumers that ignore unknown fields continue to work. The ShortTermAuditIssue.code union extension follows the same pattern as the existing recall-store-overflow code added in prior PRs.

  • Crash safety: replaceFileAtomic handles temp file creation and rename internally with configurable temp prefixes (dreaming-inline, dreaming-report, dreaming-deep). If the write succeeds but the rename fails, a dreaming-* orphan may remain — this is inherent to temp+rename atomicity and is strictly safer than fs.writeFile overwrite (which could truncate the target file). The proof script confirms zero orphan temp files under normal operation.


Related to #84882

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 18, 2026
@clawsweeper

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed June 26, 2026, 6:44 AM ET / 10:44 UTC.

Summary
This PR replaces memory-core Dreaming markdown writes with atomic replacement, adds dangling short-term recall audit/repair cleanup and summaries, extends the memory-core SDK facade types, and adds regression tests.

PR surface: Source +126, Tests +237. Total +363 across 7 files.

Reproducibility: yes. for the current PR defects: source inspection shows the SDK type tightening and the audit/repair predicate mismatch. No high-confidence current-main reproduction path is established for the linked mass daily-file deletion root cause.

Review metrics: 3 noteworthy metrics.

  • Atomic write sites: 3 changed. All Dreaming markdown write paths now depend on replaceFileAtomic mode, temp-file, and directory-mode behavior.
  • SDK facade contract changes: 1 literal added, 2 fields added, 1 field tightened. The touched facade is public plugin SDK surface, so source compatibility matters before merge.
  • Persisted repair deletion class: 1 added. The PR adds a repair path that deletes recall-store entries, which needs audit/repair symmetry.

Stored data model
Persistent data-model change detected: migration/backfill/repair: extensions/memory-core/src/cli.runtime.ts, migration/backfill/repair: extensions/memory-core/src/dreaming.ts, serialized state: extensions/memory-core/src/dreaming-markdown.test.ts, serialized state: extensions/memory-core/src/dreaming-markdown.ts, serialized state: extensions/memory-core/src/short-term-promotion.test.ts, unknown-data-model-change: extensions/memory-core/src/dreaming-markdown.test.ts, and 9 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #84882
Summary: This PR is a partial hardening and cleanup candidate for the canonical memory-core daily-file deletion issue; separate open work tracks root-cause diagnostics and adjacent repair gaps.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Preserve public SDK result type source compatibility.
  • [P2] Use the same regular-file predicate in dangling-ref repair that audit and filtering use.

Risk before merge

  • [P1] The public memory-core SDK facade currently tightens result object shapes for typed consumers that construct audit or repair summaries.
  • [P1] Dangling recall repair can leave a repairable audit issue unresolved when a daily-memory path exists but is not a regular file.
  • [P1] The mass historical daily-file deletion root cause is still unproven, so this PR is hardening and cleanup rather than a complete root-cause fix.

Maintainer options:

  1. Fix SDK And Repair Symmetry (recommended)
    Keep the public SDK result shapes source-compatible and make dangling repair prune exactly the same regular-file failures that audit reports.
  2. Accept SDK Break Deliberately
    Maintainers can choose to accept the stricter SDK result shapes only with explicit compatibility approval and any needed public contract updates.
  3. Pause For Root-Cause Proof
    If maintainers require a proven fix for the mass deletion mechanism rather than hardening, pause this PR and continue through the diagnostic path.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Keep the added memory-core SDK facade fields source-compatible for typed consumers, preserve removedOverflowEntries compatibility in the public facade, switch dangling recall repair to the same regular-file predicate used by audit/filterLiveShortTermRecallEntries, and add a regression where memory/YYYY-MM-DD.md exists as a directory so audit reports dangling, repair removes the entry, and re-audit clears.

Next step before merge

  • [P2] A narrow repair can address the remaining SDK compatibility and regular-file repair predicate blockers without changing the product direction.

Security
Cleared: The diff changes local filesystem writes and recall-store repair only; no new dependency, network, secret, CI, or code-execution surface was introduced.

Review findings

  • [P1] Keep SDK result fields source-compatible — src/plugin-sdk/memory-core-engine-runtime.ts:88-105
  • [P2] Use regular-file checks when pruning dangling refs — extensions/memory-core/src/short-term-promotion.ts:2816-2818
Review details

Best possible solution:

Land the hardening only after the SDK result types remain source-compatible and dangling-ref repair uses the same regular-file predicate as audit/filtering, while keeping the root-cause investigation tracked separately.

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

Yes for the current PR defects: source inspection shows the SDK type tightening and the audit/repair predicate mismatch. No high-confidence current-main reproduction path is established for the linked mass daily-file deletion root cause.

Is this the best way to solve the issue?

No, not yet. The atomic-write hardening and dangling cleanup are a reasonable mitigation, but the best mergeable version needs SDK compatibility preserved and repair aligned with audit/filtering before maintainers decide whether the hardening is enough for the data-loss cluster.

Full review comments:

  • [P1] Keep SDK result fields source-compatible — src/plugin-sdk/memory-core-engine-runtime.ts:88-105
    This public SDK facade now requires danglingRefCount, removedDanglingRefs, and a formerly optional removedOverflowEntries. Typed plugin consumers that construct audit or repair result objects can fail to compile on upgrade even though the runtime change is additive; keep the new fields optional/defaulted or otherwise preserve source compatibility.
    Confidence: 0.88
  • [P2] Use regular-file checks when pruning dangling refs — extensions/memory-core/src/short-term-promotion.ts:2816-2818
    The audit and live filtering paths use fs.stat(...).isFile(), but repair uses fs.access, so an accessible directory at memory/YYYY-MM-DD.md is treated as healthy and the dangling-ref audit warning remains after --fix. Reuse the same regular-file predicate in repair and cover the directory case.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c05d0d5bbfb0.

Label changes

Label justifications:

  • P0: The PR is tied to a P0 memory-core daily-file data-loss cluster and changes the hardening path for that workflow.
  • merge-risk: 🚨 compatibility: The PR changes public memory-core SDK result types in a way that can break typed plugin consumers constructing those objects.
  • merge-risk: 🚨 session-state: The PR changes persistent recall repair behavior and can leave stale memory/session recall state inconsistent if audit and repair disagree.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body includes after-fix Linux terminal output exercising production write and repair functions, with clear gaps called out for live cron, cross-platform behavior, and restricted-filesystem permission cases.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix Linux terminal output exercising production write and repair functions, with clear gaps called out for live cron, cross-platform behavior, and restricted-filesystem permission cases.
Evidence reviewed

PR surface:

Source +126, Tests +237. Total +363 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 155 29 +126
Tests 2 237 0 +237
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 392 29 +363

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/memory-core/src/short-term-promotion.test.ts src/plugin-sdk/memory-core-engine-runtime.test.ts src/commands/doctor-memory-search.test.ts.
  • [P1] node scripts/run-vitest.mjs extensions/memory-core/src/dreaming-markdown.test.ts extensions/memory-core/src/short-term-promotion.test.ts.

What I checked:

  • Root and scoped policy read: Root AGENTS.md plus extensions and plugin-sdk scoped guides were read; the review applied the plugin boundary and SDK compatibility guidance. (AGENTS.md:1, c05d0d5bbfb0)
  • PR head tightens public SDK result shapes: At PR head, the public memory-core SDK facade makes danglingRefCount, removedOverflowEntries, and removedDanglingRefs required, while current main had removedOverflowEntries optional and no added fields. (src/plugin-sdk/memory-core-engine-runtime.ts:88, 7492f9a1af8e)
  • Repair still uses existence instead of regular-file predicate: At PR head, dangling repair uses fs.access, so an accessible directory at memory/YYYY-MM-DD.md is treated as live even though audit and filtering require stat().isFile(). (extensions/memory-core/src/short-term-promotion.ts:2816, 7492f9a1af8e)
  • Current main still has direct Dreaming writes: Current main writes inline daily files and separate phase reports with fs.writeFile, so the PR is not obsolete on main. (extensions/memory-core/src/dreaming-markdown.ts:91, c05d0d5bbfb0)
  • Related root issue remains open: The canonical memory-core daily-file deletion issue remains open and includes repeated production data-loss evidence plus a note that exact reproduction is still unclear.
  • Dependency contract checked: @openclaw/fs-safe 0.3.0 replaceFileAtomic writes a sibling temp file, resolves preserveExistingMode from stat(filePath), chmods the parent directory to dirMode, renames, then chmods the target mode. (src/infra/replace-file.ts:7)

Likely related people:

  • vincentkoc: Recent remote history shows repeated work on short-term promotion and dreaming markdown behavior, including hot-path recall I/O and deep sleep summaries. (role: recent area contributor; confidence: high; commits: abd8a46b0a52, 329fa44d23f4, 5716d83336fd; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/dreaming-markdown.ts)
  • steipete: Remote history shows memory-core SQLite state and plugin SDK facade work adjacent to the public type and repair-state concerns in this PR. (role: SDK and state-area contributor; confidence: high; commits: 3f5e00184431, 9448f91e6f1a, 827b0de0ce74; files: src/plugin-sdk/memory-core-engine-runtime.ts, extensions/memory-core/src/short-term-promotion.ts)
  • ai-hpc: Authored the prior short-term recall growth cap that added the overflow audit code and SDK facade exposure pattern this PR extends. (role: adjacent repair/API contributor; confidence: medium; commits: 6fbdae1c5153; files: extensions/memory-core/src/short-term-promotion.ts, src/plugin-sdk/memory-core-engine-runtime.ts)
  • a-m-a-r-a: Recent remote history shows compact short-term promotion and dream fallback work in the same memory-core Dreaming surface. (role: recent Dreaming contributor; confidence: medium; commits: 3029326a5669, f049477dd4fc; files: extensions/memory-core/src/dreaming.ts, extensions/memory-core/src/short-term-promotion.ts)
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.

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.

@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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 18, 2026
SunnyShu0925 added a commit to SunnyShu0925/openclaw that referenced this pull request Jun 23, 2026
…narrow catch block (ClawSweeper P1)

- Replace manual tmp-${randomUUID()}+writeFile+rename with replaceFileAtomic from @openclaw/fs-safe for all three dreaming write paths: inline daily (preserveExistingMode), separate report, and deep separate report. Removed unused randomUUID import.
- Narrow fs.access catch block in repairShortTermPromotionArtifacts to only suppress ENOENT — EACCES/EPERM now rethrow instead of triggering dangling-ref pruning.
- Both fixes address ClawSweeper P1 findings on PR openclaw#94537.
@clawsweeper

clawsweeper Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jun 23, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

…ngling recall refs

Use atomic temp-file writes (replaceFileAtomic) for all three dreaming
write paths so a process crash mid-write cannot truncate daily memory
or dreaming report files. Detect recall entries whose source daily
memory file no longer exists on disk during repair and remove them so
the promotion pipeline does not waste cycles rehydrating dead entries.

- dreaming-markdown.ts: replaceFileAtomic for inline daily
  (preserveExistingMode), separate report, and deep separate report paths
- short-term-promotion.ts: repair detects and drains dangling recall refs;
  audit exposes them as recall-store-dangling-ref; catch narrowed to
  ENOENT-only (EACCES/EPERM rethrow)
- dreaming.ts: formatRepairSummary includes dangling count
- cli.runtime.ts: show dangling-refs in CLI repair summary
- memory-core-engine-runtime.ts: expose new fields in SDK facade types
- Tests: atomic-write content preservation, orphan-tmp-file guard,
  dangling-reference removal during repair, audit issue reporting

Related to openclaw#84882

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@SunnyShu0925
SunnyShu0925 force-pushed the fix/memory-dreaming-daily-delete-84882 branch from 5a456e1 to 9c672fe Compare June 25, 2026 13:34
Upstream/main renamed shortTermRecallSourceExists → shortTermRecallSourceIsFile
with string-path signature. Restore upstream's function + memoized
filterLiveShortTermRecallEntries to fix CI type-check failures.
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@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 Jun 26, 2026
…penclaw#94537

- P1: preserve existing directory mode across replaceFileAtomic calls
  by stat'ing the pre-created directory and passing its mode as dirMode.
  Also add preserveExistingMode to separate/deep report paths.
- P1: add recall-store-dangling-ref literal to ShortTermAuditIssue.code
  union in the public SDK facade so typed plugin consumers see it.
- P2: align dangling-entry audit predicate with repair by adding
  isShortTermMemoryPath filter, preventing non-short-term source:memory
  entries from inflating the dangling count.
- Add regression test for audit/repair predicate alignment.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 26, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

Closed — 3 unresolved P1 issues after 11 days without progress:

  1. SDK facade type breaking change (public API compatibility)
  2. Audit/repair predicate mismatch (fs.access vs fs.stat isFile — causes infinite re-audit loop when memory/YYYY-MM-DD.md is a directory)
  3. Root cause of [Bug]: memory-core Dreaming normalized recall artifacts silently deletes daily memory files (memory/YYYY-MM-DD.md) #84882 unproven (diagnostic PR investigate(memory-core): root-cause for #84882 dreaming silent daily-file deletion #94625 still open); main branch moved with fix(memory): stop light dreaming from restaging stale summaries #97446 merged on June 28

Atomic-write hardening (Part A) could land independently in a focused 2-file PR. The dangling-ref cleanup (Part B) should be rebased after #94625 establishes root cause.

@SunnyShu0925
SunnyShu0925 deleted the fix/memory-dreaming-daily-delete-84882 branch July 2, 2026 03:35
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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

1 participant