Skip to content

fix(learning-readback): add a freshness window so the digest can't show stale signals#1371

Open
lewta wants to merge 1 commit into
danielmiessler:mainfrom
lewta:fix/learning-digest-staleness-guard
Open

fix(learning-readback): add a freshness window so the digest can't show stale signals#1371
lewta wants to merge 1 commit into
danielmiessler:mainfrom
lewta:fix/learning-digest-staleness-guard

Conversation

@lewta

@lewta lewta commented Jun 20, 2026

Copy link
Copy Markdown

Problem

loadLearningDigest() injects "Recent Learning Signals" into every session's
context. It calls getRecentLearnings(), which returns the N most-recent entries
per category (ALGORITHM / SYSTEM) — but with no date shown and no age cutoff.

So when a category is quiet, the digest surfaces weeks-old entries as though they
were current, with nothing to signal their age. In a real install this presented
signals from 18+ days prior at session start, indistinguishable from today's.

Fix

  • parseLearningDate(filename) — extracts the timestamp from the
    YYYY-MM-DD-HHMMSS_LEARNING_*.md name (single source of truth).
  • isFresh(filename, maxAgeDays, now?) — true only within the window;
    unparseable names are treated as not-fresh (a signal we can't date is not shown
    as current).
  • getRecentLearnings() now filters by a 21-day freshness window and stamps each
    entry with its date ([7/10] (2026-06-20) …), matching the dated convention
    already used by loadFailurePatterns().

No change when entries are recent; a quiet category now correctly shows fewer (or
no) entries rather than stale ones.

Testing evidence

Releases/v5.0.0/.claude/hooks/tests/learning-readback.test.tsbun test → 3 pass:

  • parseLearningDate extracts the date and rejects malformed names.
  • isFresh includes recent, excludes old and unparseable.
  • loadLearningDigest against temp fixtures (a today entry + a 60-day-old entry)
    shows the fresh one and hides the stale one.

loadLearningDigest() showed the N most-recent entries per category with no date
and no age cutoff, so a quiet category surfaced weeks-old signals as if current.
Add parseLearningDate()/isFresh(), apply a 21-day freshness window, and stamp
each entry with its date so staleness is always visible. Adds unit tests for the
date helpers and a behavioral test (fresh shown, stale hidden) using temp fixtures.
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