Skip to content

research(nightly): mincut-memory-compaction — graph-cut guided agent working memory eviction#528

Draft
ruvnet wants to merge 2 commits into
mainfrom
research/nightly/2026-06-02-mincut-memory-compaction
Draft

research(nightly): mincut-memory-compaction — graph-cut guided agent working memory eviction#528
ruvnet wants to merge 2 commits into
mainfrom
research/nightly/2026-06-02-mincut-memory-compaction

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented Jun 2, 2026

Nightly Research: MinCut-Guided Agent Working Memory Compaction

Adds crates/ruvector-mincut-memory — a graph-cut guided agent memory compaction
primitive that answers the question every long-running AI agent faces:
when memory is full, what should be forgotten?

Includes

  1. Working Rust PoC: crates/ruvector-mincut-memory (18 tests, 0 failures)
  2. ADR: docs/adr/ADR-196-mincut-memory-compaction.md
  3. Research document: docs/research/nightly/2026-06-02-mincut-memory-compaction/README.md
  4. Public gist source: docs/research/nightly/2026-06-02-mincut-memory-compaction/gist.md
  5. Real benchmark results (two dataset sizes, all strategies PASS)

Three strategies, one trait

pub trait Compactor {
    fn compact(&self, store: &mut MemoryStore, target_size: usize) -> CompactionResult;
}
Strategy Eviction criterion Graph insight
AgeEvict Oldest by timestamp None (baseline)
CoherenceEvict Lowest mean edge weight Local neighbourhood
MinCutEvict Lowest weighted degree Global cut boundary

Real benchmark results

Hardware: x86-64 Linux 6.18 · Intel Celeron N4020 · rustc 1.94.1

N=500, D=32, 50% compaction:

Strategy Recall_b Recall_a Mean µs Edges_a Accept
AgeEvict 1.000 1.000 6 340 1 955 PASS
CoherenceEvict 1.000 0.980 6 807 3 114 PASS
MinCutEvict 1.000 1.000 6 562 3 629 PASS

N=1000, D=64, 50% compaction:

Strategy Recall_b Recall_a Mean µs Edges_a Accept
AgeEvict 1.000 1.000 51 859 759 PASS
CoherenceEvict 1.000 1.000 53 392 1 420 PASS
MinCutEvict 1.000 1.000 53 056 2 026 PASS

MinCutEvict retains 2.67x more graph edges than AgeEvict at N=1,000.

Ecosystem connections

  • ruvector-mincut — theoretical basis
  • ruvector-graph — graph storage integration path
  • mcp-gate — MCP memory_compact tool (next step)
  • rvAgent/rvagent-mcp — agent integration
  • ruvector-verified — witness log per compaction (next step)
  • ruFlo — scheduled compaction workflow (next step)

Run it

git checkout research/nightly/2026-06-02-mincut-memory-compaction
cargo build --release -p ruvector-mincut-memory
cargo test -p ruvector-mincut-memory
cargo run --release -p ruvector-mincut-memory

Research doc: docs/research/nightly/2026-06-02-mincut-memory-compaction/README.md
ADR: docs/adr/ADR-196-mincut-memory-compaction.md


Generated by Claude Code

claude added 2 commits June 2, 2026 07:24
Introduces crates/ruvector-mincut-memory — a graph-cut guided agent memory
compaction primitive for RuVector.

Three compaction strategies all implement a common Compactor trait:
- AgeEvict: evicts oldest entries by timestamp (baseline)
- CoherenceEvict: evicts entries with lowest mean graph edge weight
- MinCutEvict: evicts entries with lowest weighted degree (min-cut approximation)

Benchmark results (x86-64, N=500, D=32, 50% compaction, rustc 1.94.1):
- All three strategies: PASS (recall_after >= 0.60 x recall_before)
- MinCutEvict retains 2.67x more graph edges than AgeEvict at N=1000

18 unit tests, 0 failures. Build green with cargo build --release.
Zero external service dependencies. No Python. No tokio.
Research document at docs/research/nightly/2026-06-02-mincut-memory-compaction/README.md
includes full SOTA survey, 10-20 year thesis, two real benchmark runs,
memory math, failure modes, security considerations, ecosystem fit,
and 8 practical + 8 exotic applications.

ADR-196 documents the decision: why graph-cut compaction belongs in RuVector,
what API should survive into production, what remains behind a feature flag,
and what would make us reject this direction.
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