Skip to content

ADR-0144: trust a community cache hit, check one in fifty - #401

Merged
jeffcrouse merged 1 commit into
mainfrom
feat/adr-0144-trust-cache-hits
Oct 4, 2026
Merged

jeffcrouse merged 1 commit into
mainfrom
feat/adr-0144-trust-cache-hits

Conversation

@jeffcrouse

Copy link
Copy Markdown
Member

Builds ADR-0144 (accepted 2026-10-02).

What changes in run_track_features

  • features_path() → hit / hit (sampled) / local. is_sampled_hit() is deterministic from the fingerprint (SHA-256, mod HIT_SAMPLE_RATE = 50), so every installation samples the same tracks.
  • hit: cached features + deep scalars stored; precompute_shared never called; cached analysis_detail stored if the cache had it, otherwise left NULL for the backfill phase.
  • hit (sampled): decoded and analysed; cache values stay primary; local values → local_features, disagreements → feature_confidence; not contributed (point 2).
  • local (miss, or a lookup that failed): unchanged, still contributed.
  • Logs Features path for <title>: <path>; the task result carries features_path (point 5).

Found while building — recorded in the ADR's Implementation block

  • The cache's section analysis was discarded: fetched into analysis_detail, then reset to None by the "always run local" block and recomputed. A hit with cached detail therefore still decoded the track. Now kept.
  • Point 1 said hits are written as community_cache:recording/:hash "as today"; that is ADR-0119's embedding path. The features path is fingerprint-only and writes community_cache, and still does.
  • The MCP tool text naming ReccoBeats is corrected (the ADR's follow-up).

Tests. tests/test_features_cache_trust.py (8): the sample rule (deterministic, ~2%), and run_track_features end-to-end on the test DB with outside services faked and the decoder recording calls — trusted hit decodes nothing, cached detail kept, hit without detail left NULL, sampled hit compared and not contributed, miss unchanged. 5 of 8 fail on main. Full backend suite: 2475 passed, 18 skipped.

To measure after release (the ADR's follow-ups): the Features path lines in Familiar Server's server.log give the hit rate and per-path times.

🤖 Generated with Claude Code

https://claude.ai/code/session_014hHXQAoTT1g8ATYHgVhGwb

…0144)

A features hit at the current FEATURES_VERSION is stored as it is and the
track is not decoded; one hit in fifty, chosen from the fingerprint, is also
analysed locally, its disagreements recorded and its result not contributed. A
miss or an unanswered lookup is analysed exactly as before. The worker logs
which path each track took.

Building it found the cache's section analysis was being discarded: fetched
into analysis_detail, then reset to None and recomputed by the next block, so
a hit with cached detail decoded the track anyway. It is now kept; a hit
without it is left to the backfill (point 3).

tests/test_features_cache_trust.py runs run_track_features against the test
database with the decoder rigged to record calls; five of its eight tests fail
on the replaced code. Full backend suite: 2475 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014hHXQAoTT1g8ATYHgVhGwb
@jeffcrouse
jeffcrouse merged commit 3d70a93 into main Oct 4, 2026
16 checks passed
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