Skip to content

SWF(perf): format today's date once per memory snapshot file - #1952

Merged
Fei2411 merged 1 commit into
devfrom
chore/shown-entries-today-once
Nov 21, 2026
Merged

Fei2411 merged 1 commit into
devfrom
chore/shown-entries-today-once

Conversation

@Fei2411

@Fei2411 Fei2411 commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

The memory snapshot now formats today's date once per MEMORY.md file instead of once per entry, which saves about 30% of a snapshot build at 4,800 entries with the same output.

Agent: Devin (Cognition)

Issue

Fixes # (none — Code Reaper's follow-up note on #1949)

What changed / 改了什么

shownEntries filtered out expired entries by calling today() (an Intl.DateTimeFormat format) for every entry in a MEMORY.md. It now computes day = today() once per call, the same change #1949 made for auto recall. One file's entries are now always checked against the same day, even across midnight.

shownEntries runs when a personal/team memory snapshot (bot-memory section) or a group memory snapshot is built: on a new Session, or when the snapshot is missing from history (for example after condensation). Ordinary turns reuse the frozen snapshot and don't run it, so this speeds up snapshot builds, not every turn. Auto recall and bot_recall are unchanged.

Changelog

none

How I checked it / 怎么验证的

Benchmark: full snapshot build. It uses the real runtime and test helpers. Personal = fresh bot-memory section render, own + team files, snapshot persisted. Group = memory pre-step emitting a group snapshot. 20% of entries expired. Each variant, size and path got 40 warmups + 240 measured calls, with before/after order alternating. Machine: macOS arm64 Apple M4 Pro VM, Node v24.22.3. Times are ms.

Path Entries Before median / p90 After median / p90 Saved (median)
Personal 100 0.585 / 0.853 0.520 / 0.818 0.07 (11%)
Personal 500 1.089 / 1.451 0.872 / 1.166 0.22 (20%)
Personal 4,800 7.438 / 9.490 4.811 / 6.428 2.63 (35%)
Personal 20,000 33.623 / 52.583 23.441 / 32.445 10.18 (30%)
Group 100 0.341 / 0.489 0.289 / 0.433 0.05 (15%)
Group 500 0.750 / 0.993 0.527 / 0.724 0.22 (30%)
Group 4,800 7.485 / 10.951 4.921 / 6.704 2.56 (34%)
Group 20,000 33.921 / 48.765 24.208 / 33.250 9.71 (29%)

Same output: the SHA-256 of the rendered snapshot matched before/after for every path and size, in every run (e.g. Personal 4,800 eb677be2…5c3d9, Group 4,800 ddbfe646…259a).

Regression test: a memory snapshot checks every entry in a file against the same day stubs the day formatter so the second call returns the next day. It asserts that both entries expiring that day are shown, that the expired one is not, and that the date is formatted once per file. On old dev it fails (The input did not match ... /Release checklist beta/); with this change it passes.

  • Memory test files: 164/164 pass
  • Full npm test not run (memory test files only)
  • node scripts/build-client.mjs --check: no client change
  • npm run lint exits 0, with no findings in the changed files
  • Smoke test not run (one-line change, covered by the snapshot unit tests)
  • Screenshot: no interface change

Try it: cd ds-bot && node --import ./test/harness-resolve.mjs --test test/memory.test.js

Checklist / 检查

  • One issue, one subject. / 只做一件事。
  • src/client/ changed → npm run build ran and client.js is committed. / 不适用
  • No keys, tokens or personal data, also in screenshots.
  • No AI tool as author or Co-authored-by.

Software Factory opened this PR for Lulu
Implemented in session Format today's date once in auto recall
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T09:36:54.581209Z abcb8a3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@Fei2411 Fei2411 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Reaper review — pass (comments only; reviewed head abcb8a3)

  • Change is correct: shownEntries hoists today() out of the per-entry isExpired filter, so each file in a snapshot is checked against one day. Same pattern as #1949 (merged); no other caller changes.
  • Test a memory snapshot checks every entry in a file against the same day asserts the expired entry stays out and the date is formatted once per shown file (calls === 2). Minor, non-blocking: the exact count ties the test to how many files a snapshot reads today; adding a file to the snapshot will need this number bumped.
  • Local: test/memory.test.js 147/147 pass; npm run lint no findings in changed files. CI green.
  • PR body has the Agent: Devin (Cognition) line.
  • Overlaps: no other open PR touches ds-bot/src/host/memory.js or test/memory.test.js.

Written by Devin

@Fei2411
Fei2411 merged commit 9f609e1 into dev Nov 21, 2026
15 checks passed
@Fei2411
Fei2411 deleted the chore/shown-entries-today-once branch November 21, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant