Class: ClaudeMemory::Dashboard::Trust
- Inherits:
-
Object
- Object
- ClaudeMemory::Dashboard::Trust
- Defined in:
- lib/claude_memory/dashboard/trust.rb
Overview
Sidebar data for the feed-first dashboard. Three things:
-
Moments this week + week-over-week delta — the headline value number. A moment is any meaningful activity event (recall hit, extraction, context injection, conflict detected). Ingest-only events don’t count because they’re not directly user-visible value.
-
“What memory knows about you” — up to 5 global facts rendered as plain English. This is the trust panel’s most compelling surface: users can sanity-check what’s being injected into their sessions.
-
Needs review — open conflicts plus facts that have gone stale (active but never recalled in the last N days). A single actionable count; the feed surfaces the individual items.
Constant Summary collapse
- WEEK_SECONDS =
7 * 86_400
- UTILIZATION_DAYS =
30- VALUE_EVENT_TYPES =
%w[hook_context recall store_extraction].freeze
Instance Method Summary collapse
-
#initialize(manager) ⇒ Trust
constructor
A new instance of Trust.
- #snapshot ⇒ Object
-
#utilization ⇒ Object
The ROI signal: of the facts Claude has extracted into memory over the last UTILIZATION_DAYS, how many has Claude actually used (appeared in any recall or context injection’s top_fact_ids)? Low ratios are themselves a signal — it means memory is accumulating knowledge but Claude isn’t reaching for it.
Constructor Details
#initialize(manager) ⇒ Trust
Returns a new instance of Trust.
24 25 26 |
# File 'lib/claude_memory/dashboard/trust.rb', line 24 def initialize(manager) @manager = manager end |
Instance Method Details
#snapshot ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/claude_memory/dashboard/trust.rb', line 28 def snapshot { weekly_moments: weekly_moments, fingerprint: fingerprint, needs_review: needs_review, utilization: utilization, feedback: feedback_summary } end |
#utilization ⇒ Object
The ROI signal: of the facts Claude has extracted into memory over the last UTILIZATION_DAYS, how many has Claude actually used (appeared in any recall or context injection’s top_fact_ids)? Low ratios are themselves a signal — it means memory is accumulating knowledge but Claude isn’t reaching for it. Anomalies worth surfacing honestly.
Shape: Int, used: Int, ratio_pct: Int, window_days: Int Both counts are scope-union (project + global) so the headline number reflects everything memory did, not just one store.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/claude_memory/dashboard/trust.rb', line 203 def utilization cutoff = (Time.now.utc - UTILIZATION_DAYS * 86_400).iso8601 extracted_pairs = extracted_fact_pairs(cutoff) used_pairs = used_fact_pairs(cutoff) extracted = extracted_pairs.size # "Used" counted against the extracted set — a fact used but not # extracted in this window (taught earlier, used now) is still # re-use worth recognizing; count it too. used_from_extracted = (used_pairs & extracted_pairs).size used_total = used_pairs.size ratio_pct = extracted.zero? ? 0 : ((used_from_extracted.to_f / extracted) * 100).round { extracted: extracted, used: used_total, used_from_extracted: used_from_extracted, ratio_pct: ratio_pct, window_days: UTILIZATION_DAYS } rescue Sequel::DatabaseError, JSON::ParserError => e ClaudeMemory.logger.debug("Trust#utilization failed: #{e.}") {extracted: 0, used: 0, used_from_extracted: 0, ratio_pct: 0, window_days: UTILIZATION_DAYS} end |