Class: ClaudeMemory::Sweep::RecallTimestampRefresher
- Inherits:
-
Object
- Object
- ClaudeMemory::Sweep::RecallTimestampRefresher
- Defined in:
- lib/claude_memory/sweep/recall_timestamp_refresher.rb
Overview
Path B for #35 access-based staleness — sweep-derived rather than per-recall written. Scans activity_events from both stores, projects the most recent recall/context-injection touch per (scope, fact_id), and bulk-updates facts.last_recalled_at across both DBs.
Cross-DB by design: project DBs record activity_events for both project and global facts (a recall fired from a project context that returns global facts is logged in the project DB), so a per-store refresh would silently miss global facts entirely.
Lookback bounds keep the scan O(window), not O(history).
Constant Summary collapse
- DEFAULT_LOOKBACK_DAYS =
90- RECALL_EVENT_TYPES =
%w[recall hook_context].freeze
Instance Method Summary collapse
-
#initialize(manager, lookback_days: DEFAULT_LOOKBACK_DAYS) ⇒ RecallTimestampRefresher
constructor
A new instance of RecallTimestampRefresher.
-
#refresh! ⇒ Hash
Int, global: Int — count of facts updated per scope.
Constructor Details
#initialize(manager, lookback_days: DEFAULT_LOOKBACK_DAYS) ⇒ RecallTimestampRefresher
Returns a new instance of RecallTimestampRefresher.
22 23 24 25 |
# File 'lib/claude_memory/sweep/recall_timestamp_refresher.rb', line 22 def initialize(manager, lookback_days: DEFAULT_LOOKBACK_DAYS) @manager = manager @lookback_days = lookback_days end |
Instance Method Details
#refresh! ⇒ Hash
Returns Int, global: Int — count of facts updated per scope.
28 29 30 31 32 |
# File 'lib/claude_memory/sweep/recall_timestamp_refresher.rb', line 28 def refresh! cutoff = (Time.now.utc - @lookback_days * 86_400).iso8601 latest = collect_latest_per_fact(cutoff) apply_to_stores(latest) end |