feat(ruvector-calyx): association-native memory layer (ADR-272)#628
Draft
ruvnet wants to merge 4 commits into
Draft
feat(ruvector-calyx): association-native memory layer (ADR-272)#628ruvnet wants to merge 4 commits into
ruvnet wants to merge 4 commits into
Conversation
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
9 tasks
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inCalyxEngine:constellationflatten()baseline + fail-closed insert validationlensLensManifest(name/version/kind/dims)loomassayfusionledgerwardannealengineDependency-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-benchvs single-embedding RAG on an adversarial multi-lens corpus — all ADR-272 acceptance targets PASS:cargo test -p ruvector-calyx→ 20 passingcargo clippy→ cleancargo run --release -p ruvector-calyx→BENCHMARK PASSEDNotes for review
🤖 Generated with claude-flow
Generated by Claude Code