Skip to content

research: S-T mincut namespace routing for agent memory vector search - #808

Open
ruvnet wants to merge 4 commits into
mainfrom
research/nightly/2026-08-08-namespace-merge-mincut
Open

research: S-T mincut namespace routing for agent memory vector search#808
ruvnet wants to merge 4 commits into
mainfrom
research/nightly/2026-08-08-namespace-merge-mincut

Conversation

@ruvnet

@ruvnet ruvnet commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds crates/ruvector-namespace-merge — a zero-dependency Rust proof-of-concept for principled multi-namespace routing in agent memory vector search
  • Implements S-T mincut (Edmonds-Karp max-flow) over a namespace similarity graph to identify the coherent semantic cluster of namespaces a query belongs to
  • Key algorithmic fix: relative per-query normalisation of cosine similarities makes routing invariant to absolute cosine magnitude across dimensionalities and noise levels
  • Adds ADR-298 and nightly research README + gist

Changes

New crate: ruvector-namespace-merge

Three routing strategies sharing a NamespaceRouter trait:

Strategy Mechanism Recall@10 Dist ops vs AllSearch
AllSearch Scan everything 1.000 100%
CentroidFilter Skip if cosine(q, centroid) < threshold 0.945 38%
MinCutRoute S-T flow partition on namespace similarity graph 0.985 41%

Flow network (per query, N namespaces):

  • S → nsᵢ capacity = round(q_sim_norm[i] × 10000) — query affinity
  • nsᵢ → T capacity = round((1 − q_sim_norm[i]) × 10000) — inclusion cost
  • nsᵢ ↔ nsⱼ capacity = round(inter_sim[i,j] × 10000) — cohesion penalty

After Edmonds-Karp max-flow, the source-side reachable set in the residual graph = namespaces to search.

Benchmark results (64-dim, noise=0.30, 300 queries)

Variant          Mean(µs)  p95(µs)   QPS      Recall   NS searched  Dist ops
AllSearch           133.7     157     7,481    1.0000      5.00        2500
CentroidFilter       49.7      63    20,125    0.9453      1.91         957
MinCutRoute          54.2      68    18,449    0.9853      2.05        1025

MinCutRoute: 98.5% recall at 41% of AllSearch's distance computations, 2.47× faster.

Tests

6/6 pass:

  • all_search_recall_one — AllSearch recall vs itself = 1.0
  • centroid_filter_high_recall — recall ≥ 0.75 at threshold=0.20
  • mincut_route_searches_fewer_ns_than_all — recall ≥ 0.70, ns < total
  • flow_unit_two_cluster_query — direct flow unit test
  • flow::tests::test_simple_max_flow — max-flow correctness
  • flow::tests::test_source_side — source-side BFS correctness

Docs

  • docs/adr/ADR-298-namespace-merge-mincut.md — decision record with context, alternatives, failure modes, security, migration path
  • docs/research/nightly/2026-08-08-namespace-merge-mincut/README.md — full research document
  • docs/research/nightly/2026-08-08-namespace-merge-mincut/gist.md — public summary

Test plan

  • cargo test -p ruvector-namespace-merge — all 6 tests pass
  • cargo run --release --bin benchmark — all acceptance criteria pass
  • cargo fmt --check -p ruvector-namespace-merge — no formatting issues
  • Review ADR-298 for architectural coherence with existing ADRs (especially ADR-026 tiered routing, ADR-297 ACRP)
  • Consider wiring MinCutRoute into ruvector-agent-memory query path (Phase 2 per ADR-298)

Generated by Claude Code

claude and others added 4 commits August 8, 2026 07:53
…uting

Implements principled multi-namespace routing for agent memory vector
search. Three strategies: AllSearch (baseline), CentroidFilter (cosine
threshold), MinCutRoute (Edmonds-Karp flow partition). Key fix: relative
q_sim normalisation makes routing invariant to absolute cosine magnitude.

Benchmark results (64-dim, noise=0.30, 300 queries):
- MinCutRoute: recall=0.985, dist_ops=41% of AllSearch, 2.47x faster
- CentroidFilter: recall=0.945, dist_ops=38% of AllSearch

All 6 tests pass (2 unit + 4 integration).

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_018TDPrG478FdN2hcbX2Axd5
Documents the S-T mincut namespace routing decision: context (N namespace
fan-out problem), decision (relative-normalised flow formulation), benchmark
evidence, failure modes, security considerations, migration path, and open
questions.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_018TDPrG478FdN2hcbX2Axd5
…erge-mincut

Full research document covering: problem statement, 2026 SOTA survey, 10-20
year thesis, ecosystem fit, architecture, benchmark methodology, real results,
failure modes, security/WASM/MCP implications, practical and exotic
applications, deep research notes, and production layout.

Public gist summary at docs/research/nightly/2026-08-08-namespace-merge-mincut/gist.md.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_018TDPrG478FdN2hcbX2Axd5
@ruvnet
ruvnet marked this pull request as ready for review August 8, 2026 22:33
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.

2 participants