Skip to content

feat(search): recency decay weighting + mempalace prune --stale-days CLI (#158) - #254

Merged
jphein merged 2 commits into
mainfrom
feat/recency-decay-prune-158
May 27, 2026
Merged

feat(search): recency decay weighting + mempalace prune --stale-days CLI (#158)#254
jphein merged 2 commits into
mainfrom
feat/recency-decay-prune-158

Conversation

@jphein

@jphein jphein commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements issue #158 — two derivative-store extensions that sit next to the verbatim record, neither of which mutates stored content.

1. Recency weighting in search (mempalace/recency.py)

  • search_memories applies a small, bounded distance shift based on a drawer's age: exponential decay (half-life based), so a fresh drawer is nudged up and the boost fades to half after one half-life.
  • Recall-preserving: capped at 0.03 cosine-distance units (below the weakest closet-boost rung), so it can reorder neighbours but never push a relevant drawer out of the result set — 100% recall is the design requirement.
  • A drawer with no parseable filed_at is treated as ageless (zero adjustment), never penalized.
  • Ships dark: gated by PALACE_RECENCY_BOOST (default off, =1 enables) so we A/B it on our own corpus before trusting it. Half-life tunable via PALACE_RECENCY_HALFLIFE_DAYS. Read live, daemon picks up the toggle without a restart.

2. mempalace prune --stale-days N CLI

  • Removes drawers older than N days from an optional --wing / --room scope.
  • Dry-run by default — because it destroys data on a time predicate rather than an explicit selection, nothing is deleted unless --confirm is passed.
  • Undated drawers are never pruned (we don't delete a drawer we can't date).
  • Age decided in Python (chromadb where= can't range-compare the ISO-timestamp string), then deletion by explicit id list — same probe-then-delete shape as purge.

Upstream tracking

Upstream tracks Weibull decay + a Tier-0 LLM rerank in MemPalace/mempalace#1032 (informational). The fork-side contribution is the independent prune CLI and the off-by-default recency knob.

Local-first

Fully on-device: no network, no external API, no telemetry.

Tests

20 new tests in tests/test_recency_prune.py (age parsing, recency adjustment math + recall preservation, searcher integration, prune CLI dry-run/confirm/undated/scope). README count 3404 → 3424. scripts/check-docs.sh exits 0.

🤖 Generated with Claude Code

jphein and others added 2 commits May 26, 2026 19:43
…CLI (#158)

Recency is an opt-in, recall-preserving ranking signal: a bounded
exponential-decay distance shift on drawer age (mempalace.recency),
gated off by default via PALACE_RECENCY_BOOST, half-life tunable via
PALACE_RECENCY_HALFLIFE_DAYS. The shift can reorder neighbours but is
capped so it never displaces a relevant drawer out of the result set.

`mempalace prune --stale-days N` removes drawers older than N days from
an optional wing/room scope. Dry-run by default; deletion requires
--confirm. Drawers with no parseable filed_at are treated as ageless
and are never pruned. Fully local — no network, no external API.

Upstream tracks Weibull decay in MemPalace#1032 (informational).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add fork-changes.yaml entry; regenerate FORK_CHANGELOG, README,
llms-full, and python-api docs. Bump README test count 3404 -> 3424.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 27, 2026 02:46
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jphein

jphein commented May 27, 2026

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jphein
jphein merged commit 433d23c into main May 27, 2026
11 of 13 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.

2 participants