Skip to content

fix(doctor): match timestamp-suffixed daily memory files in isShortTermMemoryPath (fixes #90896)#90907

Closed
zenglingbiao wants to merge 2 commits into
openclaw:mainfrom
zenglingbiao:fix/issue-90896-shortterm-memory-regex
Closed

fix(doctor): match timestamp-suffixed daily memory files in isShortTermMemoryPath (fixes #90896)#90907
zenglingbiao wants to merge 2 commits into
openclaw:mainfrom
zenglingbiao:fix/issue-90896-shortterm-memory-regex

Conversation

@zenglingbiao

@zenglingbiao zenglingbiao commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Aligns isShortTermMemoryPath() in the gateway doctor predicate with the memory-core short-term path contract. The regex now matches any slug suffix (-HHMM timestamps and -vendor-pitch descriptive slugs), fixing underreported dreaming stats. 2 files, +200/-1 lines.

Root Cause

The isShortTermMemoryPath() function in src/gateway/server-methods/doctor.ts used a strict regex at line 353 that only matched memory/YYYY-MM-DD.md. The memory-core short-term path contract at extensions/memory-core/src/short-term-promotion.ts:27 already accepts (?:-[^/]+)? (any non-slash suffix), covering both numeric timestamp suffixes (-HHMM) and llmSlug descriptive names (-vendor-pitch). The gateway predicate was out of sync with this contract, so entries with any suffix were filtered before the dreaming stats counters ran.

  • Invariant violated: isShortTermMemoryPath() should match the same path shapes that memory-core accepts as valid short-term memory files
  • Code path: doctor.memory.status → iterate recall store entries → isShortTermMemoryPath() filter (line 524) → entries with timestamp or slug suffixes are discarded → promotedToday, shortTermCount, promotedTotal underreported
  • Sibling audit: Memory-core SHORT_TERM_PATH_RE (short-term-promotion.ts:27): /(?:^|\/)memory\/(?:[^/]+\/)*(\d{4})-(\d{2})-(\d{2})(?:-[^/]+)?\.md$/ uses (?:-[^/]+)?. Also: session-corpus regex at doctor.ts:357 already handles multiple extensions (md|txt), and session-memory HOOK.md documents llmSlug output as YYYY-MM-DD-vendor-pitch.md.

Verification

pnpm test src/gateway/server-methods/doctor.test.ts
  • 2 test files, 62 tests passed (exit 0) — includes new regression test
  • pnpm build passes cleanly

Real behavior proof

Behavior or issue addressed: isShortTermMemoryPath() regex did not match daily memory files with any slug suffix (-HHMM timestamp or -vendor-pitch descriptive slug); now it does, matching the memory-core short-term path contract.

Real environment tested: Linux x86_64, Node v22.22.0, OpenClaw main @ f4a5e57, pnpm 11.2.2

Exact steps or command run after this patch:

pnpm test src/gateway/server-methods/doctor.test.ts

This runs the full doctor.memory.status gateway handler (not a copied regex snippet) against a populated recall store containing both timestamp-suffixed (memory/YYYY-MM-DD-HHMM.md) and slugged (memory/YYYY-MM-DD-vendor-pitch.md) entries with phase signals, and asserts the exact dreaming stat counts returned by the handler.

Evidence after fix:

 Test Files  2 passed (2)
      Tests  62 passed (62)
   Start at  19:01:39
   Duration  1.36s

The new regression test (counts timestamp-suffixed and slugged recall-store entries in dreaming stats) specifically validates:

  • memory/2026-06-04-1503.md (timestamp suffix) → counted as promoted entry, promotedToday=1 ✅
  • memory/2026-06-03-vendor-pitch.md (llmSlug suffix) → counted as promoted entry, promotedTotal=2 ✅
  • memory/2026-06-05-0930.md (timestamp suffix) → counted as short-term entry with correct signal counts ✅

Source: src/gateway/server-methods/doctor.ts:353 — regex changed from (?:-\d{4})? to (?:-[^/]+)? to match any slug suffix.

Observed result after fix: All 62 tests pass including the new regression test. The doctor.memory.status gateway handler (not a copied regex snippet) correctly counts both timestamp-suffixed and slugged recall-store entries. No regressions — plain YYYY-MM-DD.md paths continue to match.

What was not tested: End-to-end WebUI Dreams tab rendering with a live gateway and real recall store containing timestamp-suffixed/slugged entries.

Review Findings Addressed

  • [P2] Match the full short-term memory path contract — Fixed: changed regex from (?:-\d{4})? to (?:-[^/]+)? to accept any slug suffix, aligning with memory-core's SHORT_TERM_PATH_RE at extensions/memory-core/src/short-term-promotion.ts:27.
  • [P1] Add a focused regression test — Added: counts timestamp-suffixed and slugged recall-store entries in dreaming stats in src/gateway/server-methods/doctor.test.ts proves doctor.memory.status counts both -HHMM and -vendor-pitch entries.
  • [P1] Needs stronger real behavior proof — Provided: test output shows doctor.memory.status handler (not copied regex) processing a real recall store with timestamp and slugged entries.

Regression Test Plan

pnpm test src/gateway/server-methods/doctor.test.ts

The new counts timestamp-suffixed and slugged recall-store entries in dreaming stats test creates a populated recall store with both -HHMM timestamp and -vendor-pitch slugged paths and asserts exact dreaming stat counts through the full doctor.memory.status gateway handler.

Merge Risk

Low. The change aligns the gateway doctor predicate with the existing memory-core short-term path contract ((?:-[^/]+)? instead of (?:-\d{4})?). The memory-core module already creates and accepts entries with these path shapes — the doctor just couldn't count them. All previously matching paths continue to match. No API surface changes.

…rmMemoryPath regex

The regex only matched memory/YYYY-MM-DD.md, skipping files with
timestamp suffixes like memory/YYYY-MM-DD-HHMM.md. This caused
promotedToday, shortTermCount, and promotedTotal to show incorrect
values in the WebUI Dreams tab.

Update the regex to also match -HHMM timestamp suffixes, fixing
underreporting of dreaming recall store entries.

Fixes openclaw#90896
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime proof: supplied External PR includes structured after-fix real behavior proof. size: XS labels Jun 6, 2026
@clawsweeper

clawsweeper Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Current main now has the same-or-better fix by routing doctor.memory.status through memory-core’s canonical short-term stats loader, whose matcher accepts suffixed and nested daily memory paths, so this dirty PR branch no longer has unique code to land.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the current main implementation that uses memory-core as the single source of truth for short-term path filtering, and only reopen with a fresh narrow report if live Dreams status still undercounts after that refactor ships.

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

No current-main failure path is visible from source inspection: the old base had a gateway-local matcher mismatch, but current main delegates stats to memory-core’s suffix-aware matcher. I did not run tests because this was a read-only review.

Is this the best way to solve the issue?

Yes for current main: delegating to memory-core is the better fix because it removes the duplicate gateway path contract instead of widening one stale regex. The PR’s original patch was plausible on its base, but it is now obsolete.

Security review:

Security review cleared: The diff only changes TypeScript doctor logic and tests, with no dependency, workflow, secret, or supply-chain surface change.

AGENTS.md: found and applied where relevant.

What I checked:

  • Current main delegates doctor stats to memory-core: doctor.memory.status imports loadShortTermPromotionDreamingStats through the gateway lazy boundary and calls it for each resolved workspace instead of filtering recall entries with a gateway-local regex. (src/gateway/server-methods/doctor.ts:20, 66b91d78feb3)
  • Canonical matcher covers the requested paths: Memory-core’s SHORT_TERM_PATH_RE accepts memory/(subdirs/)YYYY-MM-DD(-suffix).md, and loadShortTermPromotionDreamingStats filters entries through isShortTermMemoryPath, so timestamp and descriptive slug suffixes are counted by the current stats path. (extensions/memory-core/src/short-term-promotion.ts:40, 66b91d78feb3)
  • Current coverage and docs support the contract: Current memory-core tests cover memory subdirectories, and user-facing hook docs describe timestamp and LLM-generated daily memory filenames that the canonical matcher accepts. (extensions/memory-core/src/short-term-promotion.test.ts:131, 66b91d78feb3)
  • Git-history provenance: git blame ties the current doctor delegation lines and memory-core matcher lines to commit 9fb8d87f91f8ca4d23b79034ce7465640e8b9da7, which is contained on current main. (src/gateway/server-methods/doctor.ts:20, 9fb8d87f91f8)
  • Release provenance: git tag --contains 9fb8d87f91f8ca4d23b79034ce7465640e8b9da7 returned no tags, and v2026.6.1 points at 2e08f0f4221f522b60423ed6ffd83427942b28de, so this is fixed on current main but not proven shipped in the latest release. (9fb8d87f91f8)
  • PR branch state: The provided live GitHub context reports the PR head 1c0a90c8f41b0690e6d51470ce54474b7f142731 as mergeableState: dirty; its diff edits the old gateway-local matcher that current main no longer uses. (src/gateway/server-methods/doctor.ts:350, 1c0a90c8f41b)

Likely related people:

  • vincentkoc: Current-main blame for the doctor memory-status delegation and memory-core matcher points to 9fb8d87f91f8ca4d23b79034ce7465640e8b9da7, authored by Vincent Koc. (role: recent area contributor; confidence: medium; commits: 9fb8d87f91f8, 2e08f0f4221f; files: src/gateway/server-methods/doctor.ts, extensions/memory-core/src/short-term-promotion.ts)
  • vignesh07: The memory-core dreaming promotion feature and original gateway Dreams status plumbing trace through 4c1022c73b3910ed68d0c4c72767e7465067c6a7 and f8c4777515cf929a895b59fba66cf373d3d55b73. (role: feature-history owner; confidence: medium; commits: 4c1022c73b39, f8c4777515cf; files: extensions/memory-core/src/short-term-promotion.ts, src/gateway/server-methods/doctor.ts, src/gateway/server-methods/doctor.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 66b91d78feb3; fix evidence: commit 9fb8d87f91f8, main fix timestamp 2026-06-07T10:26:59+02:00.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jun 6, 2026
…in isShortTermMemoryPath

Align the gateway doctor predicate with the memory-core short-term path
contract. The regex now matches any slug suffix (not just -HHMM numeric),
handling llmSlug output like memory/YYYY-MM-DD-vendor-pitch.md.

Add a focused regression test proving doctor.memory.status counts both
timestamp-suffixed (-HHMM) and slugged (-vendor-pitch) recall-store entries.

Fixes openclaw#90896
@zenglingbiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed all review findings:

  1. Full path contract: Changed regex from to to match any slug suffix, aligning with memory-core's
  2. Regression test: Added focused test that proves counts both and entries
  3. Real behavior proof: Test output runs the full gateway handler (not a copied regex) against a populated recall store with timestamp and slugged entries

@clawsweeper

clawsweeper Bot commented Jun 6, 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.

@zenglingbiao

Copy link
Copy Markdown
Contributor Author

The core-support-boundary CI failure is pre-existing and unrelated to this PR — the changed files are under src/ not extensions/. The lint:plugins:no-extension-test-core-imports check passes locally with these changes.

CI re-run requested.

@zenglingbiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-run

@clawsweeper

clawsweeper Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

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

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-run

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

@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 7, 2026
@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant