Skip to content

Let popular-but-stale memories age out, and drop the janitor's second decay - #1686

Merged
currentbits merged 1 commit into
mainfrom
coder/memory-ranking-access-driven-decay-never-2c9d64
Oct 19, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/memory-ranking-access-driven-decay-never-2c9d64

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Memory ranking measured an entry's age from its last access, so every search hit made it young again. Heavily served entries never aged out, however stale they were. Ranking now measures age from when the entry was last written, and there is a single decay mechanism instead of two. Fixes #311.

Changes

  • Age counts from updated_at, not last_accessed_at. updated_at changes on a write, a supersede, or a citation line-number fix. Being served no longer resets the clock.
  • Recent access is a small bonus. An entry served in the last 30 days gets ×1.1 instead of a decay reset.
  • One decay. The janitor's access_count ×0.98 pass is gone, so a boot-time re-run can no longer double-decay. usage_boost is already capped at ×1.5, so an access count that only grows can't take over.
  • Optional staleAfterDays horizon on memory_store and memory_supersede (MCP and REST), stored in a new stale_after_days column. It's a step: full rank until the horizon passes, then the decay floor. A superseding entry inherits the horizon and its clock starts again. Entries without a horizon keep the existing gradual decay.

Verification

  • npm test in memory-server/: 246/246 pass, run with the live app's CODER_GUARDRAILS_PATH unset (with it inherited, 3 injection-scan tests fail; they aren't touched here).
  • New test: a 400-day-old entry served 50 times yesterday now ranks below an identical fresh entry. The old ranking put it first.
  • New test: with a 30-day horizon, an entry is at full rank at 29 days and at the floor at 31, and a superseding entry inherits the horizon.
  • The janitor's ×0.98 test is replaced by a check that repeat runs leave access_count unchanged.

Notes for reviewers

  • Search and bootstrap order will visibly change on existing data. Entries not rewritten in about 4 months but served a lot will drop. That's the intended fix.
  • A citation line-number fix (verifyAndHeal) bumps updated_at, so it also resets the decay. That's deliberate: a verified fact is still true.
  • Left out: listing entries past their horizon in memory_maintenance (offered as a follow-up), and as-of queries beyond the existing invalid_at.

🤖 Generated with Claude Code

…311)

rank_decay anchored on last_accessed_at, so every search hit reset an
entry's age and popular-but-stale facts never aged out. It now anchors on
updated_at (write, supersede, citation heal); recent access is a flat
x1.1 boost instead. The janitor's separate access_count *0.98 pass is gone,
so ranking owns the only decay and boot re-runs can't double-decay.

Entries can carry an optional staleAfterDays horizon: full rank until it
passes, then the decay floor. Supersede inherits it and restarts the clock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T08:10:19.375902Z c7380b3 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.

@currentbits
currentbits enabled auto-merge (squash) October 19, 2026 08:09

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7380b31b6

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

citations: z.array(citationSchema).optional(),
inclusion: inclusionMode.optional(),
globs: inclusionGlobs.optional(),
staleAfterDays: staleAfterDays.optional(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow clearing inherited freshness horizons

When superseding a horizon-bearing memory whose replacement should remain durable, an MCP client cannot clear the horizon: omission inherits the old value, while this schema rejects null before Memory.supersede can apply its explicit null-clearing behavior. Make the supersede field nullable so these entries do not unexpectedly fall to the decay floor after the inherited deadline.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit 72538e1 into main Oct 19, 2026
6 checks passed
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.

Memory ranking: access-driven decay never lets popular-but-stale entries age out

1 participant