Skip to content

Knowledge density scoring: surface high-signal sessions first #62

Description

@ashu17706

What

Score sessions by knowledge density and use it as a recall ranking signal. High-density sessions (decisions made, bugs fixed, code committed) should rank above low-density sessions (exploration, Q&A, back-and-forth) when recall scores are close.

Signal sources (all already in smriti tables)

Signal Table Weight
Tool calls with success smriti_tool_usage +1 per tool
File operations (writes) smriti_file_operations +2 per write
Git commits smriti_git_operations +3 per commit
Errors resolved smriti_errors +2 per resolved error
Session tags (decision/*, bug/fix) smriti_session_tags +5 per quality tag
Session cost (proxy for depth) smriti_session_costs log-scaled

Schema addition

ALTER TABLE smriti_session_meta ADD COLUMN density_score REAL DEFAULT 0;

Computed on ingest, recomputed by smriti enrich --density.

Recall integration

In recallMemories(), final score = relevance * 0.8 + density_normalized * 0.2. Configurable via SMRITI_DENSITY_WEIGHT env var (default 0.2, set 0 to disable).

Why

Two sessions with equal relevance scores are not equal. A session where you fixed a critical bug and committed a fix is worth more than a session where you explored an idea and abandoned it. The sidecar tables already capture this signal — we just don't use it in ranking.

No LLM calls needed. Purely structural. Ships before Phase 3.

Acceptance Criteria

  • density_score computed on all new ingests
  • smriti enrich --density backfills existing sessions
  • Density factored into recallMemories() final ranking
  • smriti show <id> --density explains the score breakdown
  • Weight configurable via env var, 0 = disable

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions