Skip to content

feat(ruvector-calyx): association-native memory layer (ADR-272)#628

Draft
ruvnet wants to merge 4 commits into
mainfrom
claude/ruvector-association-native-mqege2
Draft

feat(ruvector-calyx): association-native memory layer (ADR-272)#628
ruvnet wants to merge 4 commits into
mainfrom
claude/ruvector-association-native-mqege2

Conversation

@ruvnet

@ruvnet ruvnet commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Tracks #627. Implements ADR-272: Association-Native Memory Layer (Calyx-inspired).

What

Adds crates/ruvector-calyx, an independent clean-room Rust implementation of the Calyx association-native architecture pattern mapped onto RuVector. One input becomes a constellation — the same object measured through many frozen lenses, each stored as a distinct typed slot that is never flattened — and relationships are derived between slots, grounded against anchors, gated fail-closed, and recorded in a replayable provenance ledger.

The four verbs (measure → count → differentiate → compose) wired in CalyxEngine:

Module Calyx concept Role
constellation Constellation / no-flatten multi-slot record + lossy flatten() baseline + fail-closed insert validation
lens Registry content-addressed LensManifest (name/version/kind/dims)
loom Loom cross-lens agreement + informative-disagreement detection
assay Assay per-lens signal density (MI bits per µs of cost)
fusion Sextant weighted Reciprocal Rank Fusion
ledger Lodestar + Ledger grounding anchors + FNV hash-chained, replayable provenance
ward Ward fail-closed guard with structured refusal reasons
anneal Anneal reversible simulated-annealing lens-weight (lens-routing) optimizer
engine the four verbs end-to-end with ledger logging

Dependency-free (inline SplitMix64 PRNG), MIT OR Apache-2.0, registered in the workspace.

Why

Calyx validates the "memory is the moat" thesis at the data layer and composes with MetaHarness Darwin Mode (route lenses, not just models). See #627 for the full review and ADR-272 for the design + mapping.

Verification

Deterministic calyx-bench vs single-embedding RAG on an adversarial multi-lens corpus — all ADR-272 acceptance targets PASS:

Metric single-embedding calyx result
Grounded accuracy 6.7% 99.2% +92.5 pp (≥+15) ✓
Recall@10 51.7% 100.0% +48.3 pp (≥+10) ✓
Unsupported claims 172 0 −100% (≥−50%) ✓
Replayability n/a 180/180 100% ✓
Anneal Δu +46.2 (reversible)
  • cargo test -p ruvector-calyx → 20 passing
  • cargo clippy → clean
  • cargo run --release -p ruvector-calyxBENCHMARK PASSED

The large margins come from an adversarial corpus engineered to expose the flattening failure (within-topic single-embedding accuracy is near the 1/20 chance floor by construction); they demonstrate the mechanism and direction, not a claim about a specific real dataset. Production validation (ADR-267) is tracked in #627.

Notes for review

🤖 Generated with claude-flow


Generated by Claude Code

claude and others added 2 commits June 30, 2026 23:08
Add crates/ruvector-calyx, an independent clean-room implementation of the
Calyx association-native architecture pattern mapped onto RuVector:

- Constellation: one object, many typed lens slots, never flattened
- LensManifest: content-addressed (name/version/kind/dims) measurement lineage
- Loom: cross-lens agreement + informative-disagreement detection
- Assay: per-lens signal density (mutual-information bits per µs of cost)
- Sextant/fusion: weighted Reciprocal Rank Fusion across lenses
- Lodestar/Anchor: grounding (accepted-answer/passed-test/sensor/citation/reward)
- Ward: fail-closed guard with structured refusal reasons
- Ledger: FNV hash-chained, replayable provenance
- Anneal: reversible simulated-annealing lens-weight (lens-routing) optimizer
- CalyxEngine: the four verbs (measure/count/differentiate/compose) wired

Dependency-free (inline SplitMix64 PRNG), MIT OR Apache-2.0.

Deterministic benchmark (calyx-bench) vs single-embedding RAG, all ADR-272
acceptance targets PASS: grounded accuracy 6.7%->99.2% (+92.5pp),
unsupported claims 172->0 (-100%), recall@10 51.7%->100% (+48.3pp),
replayability 180/180, anneal utility +46.2 with reversible reverts.

20 unit tests pass; clippy clean. Registered in workspace members.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01BGHbMLXRVRDj4j2oyivZG2
…date 1)

route → calibrate first: calibration before speed, because HNSW can hide bad
retrieval and calibration tells you where speed/graph work even matters.

- calibrate.rs: per-query confidence (margin, cross-lens agreement, grounding/
  source density, contradiction), histogram Calibrator (reliability map),
  Expected Calibration Error, abstention precision/recall
- routing.rs: cheapest-first incremental lens consultation with calibrated
  early-stop / escalate / abstain; min_lenses_to_answer corroboration gate
  ("don't trust a lone lens"); RoutingMode {BruteForce, Static, Adaptive};
  Witness log per decision (lenses, tops, signals, confidence, reason, cost)
- calyx-routing-bench: brute-force vs static vs adaptive on 160+80 queries
  (50/50 train/test; calibrator fit on train only)

Adaptive strictly dominates brute-force. Acceptance (adaptive vs brute), PASS:
accuracy loss -6.2pp (adaptive higher), cost -51.6%, latency -51.6%,
ECE 0.000, abstention precision 100%.

32 unit tests pass; clippy clean. ADR-272 Update 1 documents the result.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01BGHbMLXRVRDj4j2oyivZG2
claude and others added 2 commits July 1, 2026 03:39
…greement search, ledger-learned routing (ADR-272 Update 2)

Three capabilities beyond recombining known techniques:

A. conformal.rs — conformal risk control (Angelopoulos et al. 2022) over the
   cross-lens agreement score. calibrate() picks an abstention threshold with a
   distribution-free, finite-sample guarantee: confident-wrong-answer rate ≤ α.
   Replaces the hand-tuned guard's uncontrolled 11.3% risk. Monte-Carlo
   validation (200 splits) confirms mean test risk ≤ α at α ∈ {0.01,0.05,0.10}.

B. disagreement.rs — find_conflicts(lens_a, lens_b): rank records by cross-lens
   disagreement (1 - Jaccard of per-lens neighbourhoods; or query-relative
   sim gap). A query a single-embedding store cannot express. Planted-conflict
   retrieval precision 100% (6/6).

C. ledger_policy.rs — offline first-visit Monte-Carlo control over exploratory
   witness trajectories learns a stop/continue routing policy from the ledger.
   Learned policy beats both fixed baselines (utility 0.661 vs 0.620/-0.057):
   bails after one lens on likely-unanswerable queries and abstains.

New bin calyx-novel-bench demonstrates all three (all acceptance PASS).
31 lib tests pass; clippy clean. ADR-272 Update 2 documents results + honesty
note (synthetic benchmarks; real-corpus validation still the research bar).

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01BGHbMLXRVRDj4j2oyivZG2
…converter (ADR-272 Update 3)

Separate lens production (models/GPU/network, offline once) from the association
layer (pure Rust). Real embeddings are precomputed and serialized; the crate
loads vectors + ground truth with zero deps (ann-benchmarks pattern).

- corpus.rs: dependency-free .calyx v1 binary format + std::io loader — lens
  manifests, records (slots + anchors), queries with relevance ground truth
  (n_relevant==0 = unanswerable, so conformal risk is meaningful). Round-trip
  tested.
- calyx-real-bench: loads a .calyx (or synthesizes a CodeSearchNet-shaped
  stand-in and round-trips it), reports MRR@10/Recall@1,10/nDCG@10 for
  single-lens vs fusion, conformal abstention risk, and code↔doc disagreement.
- tools/build_codesearchnet.py: the one model/network step — code lens (joint
  NL↔code model), doc lens (text model), hashed-token lexical lens, docstrings
  as queries, held-out golds as unanswerable. Emits byte-exact .calyx.

Stand-in (synthetic, clearly labelled — not a real-data claim): fusion beats
best single lens by +0.288 MRR; conformal risk ≤ α; stale-docstring disagreement
100% precision.

33 lib tests pass; clippy clean. ADR-272 Update 3 documents methodology + how to
produce real numbers.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01BGHbMLXRVRDj4j2oyivZG2
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