Repository navigation
Conversation
…VectorGraphAnalyzer RuVectorGraphAnalyzer::partition()/min_cut() always route through MinCutWrapper's BoundedInstance, the crate's subpolynomial *dynamic* algorithm built to amortize many incremental updates on a large graph. Used instead for one-shot queries on a static graph (as ADR-345's MincutGatedForgetting does), it pays that algorithm's per-query overhead with none of its intended benefit, producing the worse-than-quadratic latency ADR-345/346 measured (77ms at n=50 up to 11.4s at n=400, with a 69s outlier below the small-graph cutoff). The crate already has an exact, deterministic, polynomial global min-cut solver (algorithm::exact::minimum_cut, sparse Stoer-Wagner) used internally by DynamicMinCut::recompute_min_cut() on every update, but never reachable from RuVectorGraphAnalyzer. Add min_cut_exact()/ partition_exact() as new, additive methods that build a DynamicMinCut from the analyzer's current graph and reuse that existing solver. No existing method's signature or behavior changes. New regression tests verify the exact path's output against an independent O(2^n) brute-force enumeration and check determinism across repeated calls. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_014jSBnQSchfeheujndH7GAo
…tGatedForgetting Add a MincutBackend enum (BoundedInstance default, Exact) and an .exact() builder on MincutGatedForgetting, routing boundary-partition queries through ruvector-mincut's new RuVectorGraphAnalyzer:: partition_exact() instead of partition() when selected. mincut_trials is ignored under Exact (treated as 1): a deterministic global-optimum solver gains nothing from repeated calls, unlike BoundedInstance's heuristic search. Add two companion examples re-running ADR-345's exact scaling probe and acceptance benchmark (same topology, corpus, seed, and thresholds, unmodified) against the new backend for a direct, apples-to-apples comparison. The original ADR-345 artifacts are left untouched. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_014jSBnQSchfeheujndH7GAo
…kend
Documents the hypothesis, measured evidence (scaling probe and ADR-345's
unmodified acceptance benchmark re-run on both backends), and promotion
decision for RuVectorGraphAnalyzer::{min_cut_exact, partition_exact}:
the new backend is promoted as a general-purpose capability (97x-146,800x
faster, flips the Soft candidate's latency gate to PASS), while
MincutGatedForgetting itself remains not promoted for production use
(the bridge-survival effectiveness gate is unmet on both backends,
reconfirming it is independent of backend latency/exactness).
ADR-353 was already claimed by another in-flight nightly run on a
different branch (confirmed by scanning all remote branches); this uses
ADR-360 to avoid a numbering collision.
Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_014jSBnQSchfeheujndH7GAo
Pre-existing local helper-script updates (hook-handler safety checks, intelligence/memory masking, router keyword matching, statusline) staged by this session's startup tooling, unrelated to the mincut research change in this branch's other commits. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_014jSBnQSchfeheujndH7GAo
CI status: two failing checks, both pre-existing on
|
|
Follow-up: 🤖 Generated by claude-flow https://claude.ai/code/session_014jSBnQSchfeheujndH7GAo Generated by Claude Code |
CI status:
|
CI status:
|
Hypothesis
Two prior nightlies left
ruvector-mincutwith a named, open bottleneck.ADR-345 rejected an agent-memory compaction policy (
MincutGatedForgetting)built on
RuVectorGraphAnalyzer::partition()partly because that call was1,800-2,700x slower than its scalar baseline. ADR-346 fixed a separate
determinism bug in the same call and left the latency problem as explicit
future work, naming
DynamicMinCut(bypassingRuVectorGraphAnalyzer) asthe next thing to try.
Tracing the call graph found something more specific:
ruvector-mincutalready contains a complete, independent, polynomial-time exact global
min-cut solver (
algorithm::exact::minimum_cut, sparse Stoer-Wagner),already used internally by
DynamicMinCut::recompute_min_cut()— but neverreachable from
RuVectorGraphAnalyzer, which always routes throughMinCutWrapper'sBoundedInstance(the crate's subpolynomial dynamicalgorithm, built to amortize many incremental updates on a large graph, not
to answer one-shot queries on a static graph fast).
Given
RuVectorGraphAnalyzerwrapping a static graph, when queriedthrough new additive methods (
min_cut_exact,partition_exact) that reusethe existing exact solver instead of
BoundedInstance, then latency onADR-345's own unmodified scaling probe and acceptance benchmark should drop
enough to flip at least one of its two previously-failing latency gates,
while the solver remains exact and deterministic, subject to no public
API signature changes and the full existing test suites staying green.
Architecture
RuVectorGraphAnalyzer::min_cut_exact()/::partition_exact()(new,additive) clone the analyzer's
DynamicGraph, build aDynamicMinCut,and delegate to its existing exact solver.
min_cut()/partition()(
BoundedInstance-backed) are unchanged.MincutGatedForgettinggets aMincutBackendenum(
BoundedInstancedefault /Exact) and an.exact()builder.Files changed
crates/ruvector-mincut/src/integration/mod.rs— new methods.crates/ruvector-mincut/tests/exact_partition_tests.rs— new: brute-forcecorrectness check, determinism, edge cases.
crates/ruvector-agent-memory/src/graph_forget.rs—MincutBackend,.exact()builder, backend dispatch.crates/ruvector-agent-memory/examples/mincut_scaling_probe_exact.rs,mincut_gated_forgetting_bench_exact.rs— new companion probes, re-runningADR-345's exact topology/corpus/seed/thresholds unmodified except for the
backend swap. The original ADR-345 artifacts are untouched.
docs/adr/ADR-360-mincut-exact-partition-backend.md,docs/research/nightly/2026-10-13-mincut-exact-partition-backend/{README,gist}.md— full writeup.
(ADR-353 was already claimed by another in-flight nightly run on a
different branch — confirmed by scanning all 140
claude/focused-darwin-*remote branches — so this uses ADR-360 instead.)
Benchmark command and real results
cargo run --release -p ruvector-agent-memory --example mincut_scaling_probe_exact --features mincut-forget cargo run --release -p ruvector-agent-memory --example mincut_gated_forgetting_bench_exact --features mincut-forget cargo run --release -p ruvector-agent-memory --example mincut_gated_forgetting_bench --features mincut-forget # re-run, unmodifiedScaling probe (same ring k-NN graphs, k=8, as ADR-345's probe):
partition()/BoundedInstance)partition_exact)Acceptance benchmark (ADR-345's unmodified 84-memory corpus, seed=341):
Soft(old backend, re-run)Soft-Exact(new)Hard(old backend, re-run)Hard-Exact(new)Bridge-survival gap (the other ADR-345 gate, ≥15pp required): 0.0pp on
both backends, unchanged — strong evidence the effectiveness finding is
architectural (a global min cut doesn't track human-labeled bridges on
noisy data), not a latency/exactness artifact.
Darwin / Flywheel
Neither exists in this repository (
npx ruvector harness doctor --jsonfails, no
darwin/flywheelCLI anywhere in the workspace) — confirmedagain this run, consistent with every prior nightly. No automated evolution
loop; this PR's "evolution" is one manually-added backend variant,
directly comparable via the new
MincutBackendenum.Security review
min_cut_exact/partition_exacttake&self(stricter than the existing&mut selfcache-mutating methods) — read-only queries over a graph thecaller already owns. No new dependency, no new unsafe code, no new
serialization format, no change to any witness/signing path. Correctness
verified against an independent
O(2^n)brute-force enumeration, not just"it runs."
Main limitations
(n=800..6,400, exact-backend only) shows its own cost climbing to ~3.9s
by n=6,400. Not claimed to win at every scale, only at the scale ADR-345's
own corpus and probe tested.
MincutGatedForgetting-Hard-Exactstill fails its latency gate (132.6xvs. 100x), though much closer than before.
CommunityDetector/GraphPartitioner(the other two in-tree consumers ofRuVectorGraphAnalyzer) were not benchmarked or switched to the newbackend — flagged as next research.
Production recommendation
Promote
min_cut_exact/partition_exactas a general-purpose,additive capability — correct, deterministic, zero migration cost.
Do not promote
MincutGatedForgettingfor production compaction oneither backend — the mandatory bridge-survival effectiveness gate remains
unmet; this PR changes why it should stay rejected (evaluated properly,
answer is no) rather than reversing the rejection.
Test plan
cargo test --release -p ruvector-mincut— 695 passed, 0 failed, 25pre-existing ignored (lib + all integration test files + doctests)
cargo test --release -p ruvector-agent-memory --features mincut-forget— 81 passed, 0 failed (lib + all integration test files)
cargo clippy --release -p ruvector-mincut -p ruvector-agent-memory --features mincut-forget --all-targets— clean on touched filescargo fmt --check -p ruvector-mincut -p ruvector-agent-memory— cleanmincut_gated_forgetting_benchre-run to confirm no behavior change to the existing ADR-345 artifact🤖 Generated with claude-flow
https://claude.ai/code/session_014jSBnQSchfeheujndH7GAo
Generated by Claude Code