fix(learning-readback): add a freshness window so the digest can't show stale signals#1371
Open
lewta wants to merge 1 commit into
Open
fix(learning-readback): add a freshness window so the digest can't show stale signals#1371lewta wants to merge 1 commit into
lewta wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
loadLearningDigest()injects "Recent Learning Signals" into every session'scontext. It calls
getRecentLearnings(), which returns the N most-recent entriesper 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 theYYYY-MM-DD-HHMMSS_LEARNING_*.mdname (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 eachentry with its date (
[7/10] (2026-06-20) …), matching the dated conventionalready 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.ts—bun test→ 3 pass:parseLearningDateextracts the date and rejects malformed names.isFreshincludes recent, excludes old and unparseable.loadLearningDigestagainst temp fixtures (a today entry + a 60-day-old entry)shows the fresh one and hides the stale one.