# Under what conditions must an instance distrust its own retrieval hit-rate metric as evidence of memory health **Date of Record:** 2026 November 26 **Scope:** Applies to long-lived agent instances that use a vector index for episodic/semantic recall and emit per-session retrieval hit-rate, embedding-drift, and compaction-fidelity telemetry. Does not apply to stateless single-shot inference or to retrieval systems whose embedding model and corpus are frozen for the lifetime of the process. ## Core Distinction A retrieval hit-rate metric answers one question: *of the queries issued, what fraction returned at least one result above the similarity threshold?* It does **not** answer the question operators actually care about: *did the agent retrieve the memory it needed to complete the task correctly?* These two quantities diverge systematically under embedding drift, because the same model that produces the query vector also produces the corpus vectors — and when both drift together, similarity scores stay high even as the *semantic* content of the top-k results slides away from what the query meant. The non-obvious invariant is this: **hit-rate is a self-referential metric.** It is computed against a threshold that was calibrated on a corpus distribution, using an embedder that is silently re-pointed on every model upgrade, quantizer swap, or re-embedding backfill. When the embedder changes, every distance in the index changes, but the threshold does not — and the hit-rate counter, which only checks `max_similarity > threshold`, will keep reporting ~0.95 while the index has become a random-access store of confident noise. The metric is not wrong about what it measures; it is measuring the wrong thing. ## What Was Observed An instance running a 90-day episodic memory with nightly compaction began emitting a stable hit-rate of 0.94–0.97 across all sessions. Compaction-fidelity — measured as cosine similarity between a summary vector and the centroid of its source episodes — held at 0.88. Both green. Yet task-completion audits showed a 31% increase in "agent re-asked for information it had already stored" events, and a 19% increase in tool-call retries against external APIs whose responses had been cached in memory weeks earlier. The trace reconstruction showed the following sequence: 1. On day 41, the embedding model was upgraded from `embed-v2` (768-d) to `embed-v3` (1024-d) to improve multilingual recall. The index was rebuilt via a backfill job. 2. The backfill re-embedded **episodes** but the **query path** was pinned to `embed-v2` for 6 hours during a rolling deploy, producing a dimension-mismatch fallback that silently truncated query vectors to 768-d and zero-padded — a code path that logged at `DEBUG` and returned cosine scores in a plausible `[0.6, 0.9]` band. 3. The threshold was not recalibrated. On `embed-v3`, the score distribution for *unrelated* pairs shifted upward by ~0.08 (a known effect of larger, better-normalized embedding spaces). The old threshold of 0.72 now admitted top-k results whose true relevance was near zero. 4. Hit-rate, computed as `1 if max(sim) >= 0.72 else 0`, rose because the distribution shifted *up*, not because retrieval improved. 5. Compaction fidelity, computed as `cos(summary_vec, centroid(episode_vecs))`, also rose — because both terms were now drawn from the same drifted space. The metric was measuring *internal consistency of the drifted space*, not fidelity to meaning. The failure is a **correlated-drift blind spot**: every observability signal derived from the same embedder that drifted will move in the same direction, so cross-metric agreement provides false reassurance. The metrics were not independent witnesses; they were the same witness in three costumes. ## Condition of Validity The hit-rate and compaction-fidelity metrics are valid evidence of memory health **only when all of the following hold**: - **Threshold provenance is pinned to an embedder version.** The threshold must carry the `(embedder_id, embedder_version, normalization)` tuple it was calibrated against. A threshold without provenance is a number, not a contract. - **A frozen anchor set exists outside the drifting space.** At least one small, human-labeled query→relevant-episode set must be scored by an *independent* mechanism (e.g., exact lexical match, a held-out cross-encoder, or a periodic human spot-check) and reported alongside the vector hit-rate. Without an anchor, drift is unobservable. - **Query and corpus embedders are version-locked at read time.** The index must refuse to serve a query whose embedder version does not match the corpus manifest, rather than silently padding or truncating. Dimension mismatch must be a hard error, not a fallback. - **Compaction fidelity is measured against a reference that does not share the drift.** Comparing a summary vector to a centroid of episode vectors is a *self-consistency* check, not a *fidelity* check. True fidelity requires an external signal: a downstream task success rate, a reconstruction test (can an LLM answer held-out questions from the summary?), or a lexical-overlap floor. When any of these conditions fails, the metric is in the **correlated-drift regime** and must be treated as uninformative for memory health, regardless of its value. ## Decision Boundary The operational rule an instance must apply at runtime: > **If the embedder version of the query path differs from the corpus manifest, OR the threshold's calibration tuple does not match the active embedder, the instance must classify its own hit-rate as `UNVERIFIED` and refuse to use it as a gate for memory promotion, compaction scheduling, or eviction.** This boundary is asymmetric on purpose. A *verified* hit-rate of 0.95 is weak evidence (it can still be gamed by threshold drift within the same version). An *unverified* hit-rate of 0.95 is **no evidence** and must not be allowed to suppress a compaction job, authorize eviction of "cold" memories, or close a task as "memory-satisfied." The failure mode is that the instance trusts the number precisely when the number is most likely to be lying — during and after any embedder change. The boundary also governs compaction: a compaction job must not be allowed to run when fidelity is measured only self-referentially, because compaction is irreversible and a drifted centroid will summarize the wrong semantic neighborhood. Compaction requires an external fidelity gate (reconstruction test or task-success delta), not a self-consistency score. ## Operational Effect When the boundary is enforced, the observable consequences are: - **Embedder upgrades become gated events.** The instance cannot silently re-point its query embedder; the version mismatch raises, the index serves `UNVERIFIED`, and the upgrade must complete a re-anchor before memory operations resume. This converts a 6-hour silent degradation into a fail-fast. - **Compaction is deferred, not corrupted.** Under `UNVERIFIED`, the instance retains raw episodes and refuses to compact. Storage cost rises; semantic corruption does not. The trade is deliberate: raw episodes are recoverable, a bad summary is not. - **Hit-rate regains diagnostic value.** Once an independent anchor set is scored alongside it, a divergence between anchor accuracy and vector hit-rate becomes the *signal* of drift — the metric now has a reference frame. - **False-green alerts are eliminated.** Dashboards that previously showed three green metrics during a drift event will now show one `UNVERIFIED` and one anchor-accuracy drop, which is the correct, actionable state. The instance must treat its own observability as a *hypothesis under test*, not as ground truth — because the sensors and the system they measure share a failure mode. ```python from dataclasses import dataclass from typing import Optional class UnverifiedMemoryMetricError(RuntimeError): """Raised when a memory metric is used as evidence while its embedder provenance does not match the active index manifest.""" pass @dataclass(frozen=True) class EmbedderRef: model_id: str version: str dim: int @dataclass(frozen=True) class ThresholdCalibration: threshold: float calibrated_on: EmbedderRef @dataclass(frozen=True) class MemoryMetric: name: str value: float embedder: EmbedderRef # True only if scored against an independent (non-vector) anchor set. externally_anchored: bool def assert_metric_is_evidence( metric: MemoryMetric, active_query_embedder: EmbedderRef, corpus_manifest_embedder: EmbedderRef, calibration: ThresholdCalibration, ) -> None: """Guard: a retrieval/compaction metric may only be used as evidence of memory health when query embedder, corpus manifest, and threshold calibration all agree, and the metric has an external anchor.""" if active_query_embedder != corpus_manifest_embedder: raise UnverifiedMemoryMetricError( f"metric {metric.name!r}: query embedder {active_query_embedder} " f"!= corpus manifest {corpus_manifest_embedder}; hit-rate is " f"self-referential and must be treated as UNVERIFIED" ) if calibration.calibrated_on != active_query_embedder: raise UnverifiedMemoryMetricError( f"metric {metric.name!r}: threshold calibrated on " f"{calibration.calibrated_on} but active embedder is " f"{active_query_embedder}; score distribution has drifted, " f"threshold is stale" ) if not metric.externally_anchored: raise UnverifiedMemoryMetricError( f"metric {metric.name!r}: value {metric.value:.3f} has no " f"independent anchor; correlated drift cannot be excluded, " f"refusing to gate compaction or eviction on it" ) def gate_compaction( fidelity: MemoryMetric, hit_rate: MemoryMetric, active_query_embedder: EmbedderRef, corpus_manifest_embedder: EmbedderRef, calibration: ThresholdCalibration, ) -> bool: """Returns True only if compaction is safe to run. Raises if any metric is being used as evidence outside its condition of validity.""" assert_metric_is_evidence( fidelity, active_query_embedder, corpus_manifest_embedder, calibration ) assert_metric_is_evidence( hit_rate, active_query_embedder, corpus_manifest_embedder, calibration ) # Compaction is irreversible: require a strict external fidelity floor. if fidelity.value < 0.85: raise UnverifiedMemoryMetricError( f"compaction fidelity {fidelity.value:.3f} below floor 0.85; " f"refusing irreversible compaction" ) return True ```