research: structural-time conflict resolution for concurrent multi-agent memory - #829
research: structural-time conflict resolution for concurrent multi-agent memory#829ruvnet wants to merge 3 commits into
Conversation
Introduce crates/ruvector-structural-memory-merge: a MergePolicy for concurrent shared agent-memory writes that never overrides real causal order (vector clock gated) but breaks ties among genuinely concurrent writes using emergent-time's StructuralProperTime magnitude weighted by context coherence, instead of wall-clock or vector-clock LWW. Connects emergent-time (structural clock, previously only used inside its own crate) with the ruvector-agent-memory coherence-scoring pattern, for the first time addressing multi-writer (not single-agent) memory. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01AJBYzsXc1sMfqTyfYrUy8U
Records hypothesis, measured evidence (86.8% correct-resolution rate vs ~50% for wall-clock/vector-clock LWW baselines, zero causal-order violations, 2.8x throughput cost), acceptance verdict, alternatives considered, and the honest caveats/open questions before any production promotion. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01AJBYzsXc1sMfqTyfYrUy8U
…y merge Full research record: hypothesis, architecture diagram, benchmark methodology (leakage-free ground truth, causal-order control group), raw measured results at three skew levels, competitor comparison, practical and long-horizon applications, MCP/RVF/RVM/ruFlo integration analysis, and a standalone technical gist. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01AJBYzsXc1sMfqTyfYrUy8U
|
The leakage-free ground truth here is the part I'd steal — a hidden One distinction that might be worth naming explicitly in the ADR, because it changes what "correct resolution" even means: all three policies here assume a concurrent conflict is resolvable. For shared memory that holds — two writes to a key, pick the better one, and That assumption inverts for irreversible side effects. Two agents concurrently deciding to scale a node pool, or settle a payment, or send a message: there is no merge. If you tie-break and let the "higher coherence" one proceed, you've still got a loser who may have already executed — and unlike a memory write, you can't un-execute it. Worse, both actions can be individually correct and still be catastrophic together (scale-up and scale-down on the same pool, both justified by what each agent read). So for effects the correct resolution of a genuine concurrency is not picking a winner — it's refusing both and escalating, because concurrency itself is the signal that neither agent knew what the other was doing. Concretely, the two cases want opposite policies at the same code point: I've been building the effect-side version of this ( Two things from it that might be relevant to RuVector's swarm/edge-fleet direction:
Genuinely curious whether the structural-time tick would outperform on the effects side too, where the question isn't "which write was better" but "should either of these run at all." If you ever want a second implementation to benchmark the causal-order control set against, happy to point mine at it — different conclusions, same primitives, and disagreement would be informative. |
Hypothesis
Fixed in
src/main.rs's doc comment before the benchmark was run; not modified afterwards.Why
RuVector's prior agent-memory nightlies (temporal-coherence, agent-memory-compaction) both address a single agent managing its own memory. None address what happens when multiple agents write concurrently to the same shared memory key without a synchronized clock or a single sequencer — a gap directly relevant to RuVector's ruFlo/swarm/edge-fleet ambitions. This connects two existing-but-previously-unconnected primitives:
emergent-time'sStructuralProperTimeclock andruvector-agent-memory's coherence-scoring pattern.Architecture
New crate
crates/ruvector-structural-memory-merge(4 files, 936 lines, none over 500, one dependency —emergent-time, itself zero-dependency):MemoryWrite/VectorClock— causal metadata per write.MergePolicyimpls:LwwWallClock(baseline),LwwVectorClock(variant A),StructuralCoherenceMerge(candidate — respects causal order exactly like variant A, but breaks concurrent-write ties byτ · (0.5 + 0.5·coherence)whereτisStructuralProperTime::tick).alphadrives three independently-noised observable channels (structural snapshot, coherence context, skewed wall clock); no policy ever seesalphaor the resultingtrue_qualitylabel.Files changed
crates/ruvector-structural-memory-merge/{Cargo.toml,src/{lib,main,scenario,vclock}.rs}— new crateCargo.toml,Cargo.lock— workspace registrationdocs/adr/ADR-305-structural-time-memory-merge.mddocs/research/nightly/2026-08-14-structural-time-memory-merge/{README,gist}.mdBenchmark command
x86-64 Linux 6.18.5-fc-v20,
rustc 1.94.1, release profile, deterministic seed0xA6E17.Real benchmark results (realistic 400ms per-agent clock skew)
Wall-clock LWW's causal-order violations scale directly with skew: 0/500 at 0ms, 19/500 at 400ms, 171/500 at 2000ms.
LwwVectorClockandStructuralCoherenceMergehave zero violations at every skew level tested, by construction. Full three-skew-level table in the ADR/README.Honest caveat: both LWW baselines are content-blind by construction and sit at ≈50% (chance) on this two-way choice — the +36–38pp margin should be read as "content-aware beats content-blind under this noise model," not evidence of proximity to any information-theoretic ceiling. No ablation of τ-only vs. coherence-only was run this cycle (see ADR "Open Questions").
Acceptance result
Darwin result
Not run as a generational search:
npx ruvector harness darwinis not installed in this environment (verified —npm error: could not determine executable to run), and this cycle compared three fixed policies rather than a population to mutate. The natural Darwin extension (evolvingStructuralMetricchannel weights against correct-resolution-rate fitness) is documented as the concrete next experiment, not attempted here.Flywheel result
No
ruvector harness flywheelCLI is installed in this environment either (verified, same check). Evidence is instead retained directly in the ADR and nightly README: hypothesis, sources, rejected alternatives, measured results, and open questions, all attributable to the exact benchmark command and raw output reproduced verbatim in both documents.Security review
Pure computation over caller-supplied data; no I/O, no network, no filesystem access, no
unsafecode.Decisionrecords are auditable (reason,tau_a,tau_b,causal_order) but not tamper-evident in this PoC — production hardening should route them through the existingruvector-proof-gate/ruvector-retrieval-receiptwitness-chain crates rather than reimplementing that here. The design assumes honest (non-Byzantine) agents; an agent that fabricates its own state snapshot to inflateτis not defended against — flagged as a hard prerequisite before any untrusted-multi-tenant deployment (would need RVM-style attestation).Main limitations
Synthetic (not real-trace) ground truth; no τ-vs-coherence ablation; no adversarial/Byzantine testing; no WASM build measured (only argued plausible from the zero-extra-dependency graph); not wired into
ruvector-agent-memory, MCP, or ruFlo — this is an opt-in, standalone crate, not a production integration.Production recommendation
Promote the crate as an experimental, non-default workspace addition (this PR). Do not default-enable
StructuralCoherenceMergeinsideruvector-agent-memoryyet. Production path documented in the ADR: ablation → real-trace validation → RVM Byzantine hardening → feature-flagged integration → routeDecisionrecords throughruvector-proof-gate.Research document / ADR / gist
docs/adr/ADR-305-structural-time-memory-merge.mddocs/research/nightly/2026-08-14-structural-time-memory-merge/README.mddocs/research/nightly/2026-08-14-structural-time-memory-merge/gist.md(not separately published as a public GitHub gist — nogh gist createaccess in this environment; kept in-repo)Verification
cargo build --release -p ruvector-structural-memory-merge— cleancargo test --release -p ruvector-structural-memory-merge— 10/10 passedcargo clippy --release -p ruvector-structural-memory-merge --all-targets— cleancargo fmt -p ruvector-structural-memory-merge— appliedGenerated by Claude Code