feat(semantic-drift): streaming drift detection for agent vector memory (ADR-273) - #751
Draft
ruvnet wants to merge 1 commit into
Draft
feat(semantic-drift): streaming drift detection for agent vector memory (ADR-273)#751ruvnet wants to merge 1 commit into
ruvnet wants to merge 1 commit into
Conversation
…ariants Implements ADR-273. Adds `crates/ruvector-semantic-drift` with: - `WindowCentroidDetector`: O(d) update, ~10M updates/sec, 1 KB, detects drift at lag 500 - `ProjectionDriftDetector`: k=64 Rademacher projections, 251k updates/sec, 32 KB, lag 500 - `SentinelQueryDetector`: mean-all-sq-dist metric, 155 KB, lag 175 (fastest detection) All three pass acceptance test: 0 FP on 5k-vector baseline, detect 8σ shift within 2000 vectors. 18 unit tests passing. MCP-ready DriftEvent/DriftAction interface. Includes ADR-273 and research docs (README + gist) under docs/. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_018ATfyAmmTb6KtRVJTB9z4C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
crates/ruvector-semantic-drift— three complementary streaming drift detectors that let MCP tools and index maintenance loops detect when agent vector memory distributions have shifted, without requiring offline batch analysis or O(n²) computation.All three share a
DriftDetectortrait with apoll_event() -> Option<DriftEvent>method (O(1)) that returns aDriftAction(Observe / Compact / Rebuild) for direct consumption by index maintenance schedulers.Changes
Cargo.toml— addscrates/ruvector-semantic-driftto workspace memberscrates/ruvector-semantic-drift/— new crate (5 source files, 1 benchmark binary)src/lib.rs—DriftDetectortrait,DriftEvent,DriftAction, shareddatasetmodulesrc/centroid.rs—WindowCentroidDetectorsrc/projection.rs—ProjectionDriftDetector(Rademacher ±1/√d matrix)src/sentinel.rs—SentinelQueryDetector(mean-all-sq-dist, circular snapshot buffer)src/bin/benchmark.rs— acceptance benchmark: 5k baseline + 5k drifted 128-d vectorsdocs/adr/ADR-273-semantic-drift-ann.md— architecture decision recorddocs/research/nightly/2026-08-01-semantic-drift-ann/README.md— full research writeup with SOTA survey and design rationaledocs/research/nightly/2026-08-01-semantic-drift-ann/gist.md— public-facing articleBenchmark Results (x86_64 linux, rustc 1.94.1,
--release)Test plan
cargo test -p ruvector-semantic-drift)cargo run --release -p ruvector-semantic-drift --bin benchmark)Key design notes
Reference window freeze: All detectors only advance the reference window when the current window is stable (
score ≤ threshold). Without this, drifted windows become the new reference, scores drop to near-zero, andis_drifted()flickers rather than latching.Mean-all-distance over Jaccard top-k: The sentinel metric uses mean squared L2 distance to all snapshot vectors instead of Jaccard overlap of top-k neighbours. High-dimensional Gaussian data has a crowding effect (many near-equidistant neighbours) that makes Jaccard top-k rank-ordering noise-sensitive. Mean-all-distance has CoV ≈ 1/√n ≈ 2% for n=300.
Dimension-agnostic thresholds: Centroid distance is normalised by √dim, making threshold=0.10 work across any embedding dimension for unit-variance models.
Generated by Claude Code