feat(cohomology): Dynamic Cohomological Error Correction — semantic syndrome, sparse repair, mincut containment (#669)#671
Draft
ruvnet wants to merge 1 commit into
Draft
Conversation
) Add crates/ruvector-cohomology implementing Phases 0-5 of the RFC: - Serializable restriction operators (identity/scale/projection/orthogonal/ bounded dense) with apply_transpose, norm bounds, canonical SHA-256 hashes, and boundary validation - replaces closure-based maps - Deterministic block-sparse coboundary assembled from both endpoint restrictions; matrix-free delta, delta^T, and weighted sheaf Laplacian - Affine syndrome engine: weighted least squares via matrix-free CG (minimum-norm gauge) with residual certificates; exact rank-revealing QR dense oracle; ranked support ordered on quantized energies - Harmonic subspace canonicalization via hashed-probe QR; LOBPCG for nullity/spectral gap (dominant power iteration is never used) - Group-sparse ADMM repair with per-edge cost policy (business/security/ latency/reversal), protected-edge authorization gating, and debias refit so the selected support cancels its contradiction exactly - Dynamic engine: bounded cell partition, all eight edit classes, dirty-cell estimates, exact flush() equivalent to batch assembly, epochs and deterministic edit receipts - Orthogonal transport (x_new = Q_new Q_old^T x_old, rho <- rho R^T) with cycle-consistency and coherent-negative-control guards for map updates - Mincut coupling: syndrome-to-tension conversion, deterministic Dinic quarantine boundary between contaminated seeds and healthy region, isolate-first/repair-first policies, signed intervention receipts; optional ruvector-mincut global cut behind the 'mincut' feature - Canonical witnesses: epochs, sorted ids, operator/observation/weight hashes, gauge+solver config, quantized values, SHA-256 seal Correct the H0/H1 semantics in prime-radiant obstruction docs (nontrivial H1 means unexplainable edge data, not absence of global sections - the zero section always exists for a linear sheaf) and record the decision in ADR-272. Tests: 29 across exact_small (dense-oracle agreement <= 1e-10, closed-form cycle syndrome), property (zero false certificates, flush==batch with identical witness hashes, repair vs exhaustive optimum), determinism (100 runs + permuted insertion order -> same hash), drift (frame updates leave energy invariant), adversarial (validation bombs, protected edges, Byzantine quarantine). Benches cover batch, dynamic edits, planted-cycle localization, repair, and mincut coupling. Closes #669 Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_017JAAahT1mcT1GahYxPDmaS
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.
Summary
Implements the RFC in #669: a new mathematical primitive
crates/ruvector-cohomologythat ingests a dynamic heterogeneous constraint graph (a cellular sheaf with affine edge observations), decides whether a globally coherent explanation exists, localizes the irreducible contradiction, emits a deterministic signed witness, proposes a cost-aware group-sparse repair or quarantine boundary, and verifies post-intervention syndrome energy — Phases 0–5 of the RFC.Definition-of-done loop (detect → localize → isolate → repair → verify → sign) is implemented end-to-end in
mincut_bridge::run_containmentand exercised in tests.Mathematical correction (Phase 0)
H⁰/H¹semantics: for a linear sheaf the zero section is always global, so nontrivialH¹means edge data unexplainable by any vertex assignment (H¹ = C¹/im δ), not "no global section exists" (H⁰ = ker δis the space of global sections). Fixed inprime-radiant/src/cohomology/obstruction.rsdocs and recorded in ADR-272.x* = argmin ‖W^{1/2}(δx − b)‖²,s = b − δx*(the weighted projection ofbonto(im δ)^{⊥_W}).What's in the crate
operatorLinearRestriction+RestrictionMap(identity/scale/projection/orthogonal/bounded-dense) withapply_transpose, sound norm bounds, canonical SHA-256 hashes, boundary validation before allocation — replaces closure-based mapsblock_sparseδ,δᵀ,δᵀWδassembled from both endpoint restrictions; dense assembly only for the oracleaffine,syndromeb, weightsW, minimum-norm gauge; production path = matrix-free CG with residual certificate; reference path = column-pivoted rank-revealing Householder QR (exact)harmonicrepair,solvers/admmc_e = α·business + β·security + γ·latency + η·reversal, protected edges immutable without explicit authorization, debias refit so the selected support cancels its contradiction exactlydynamic,partitionestimate(), exactflush()≡ batch, epochs + deterministic edit receipts, periodic partition rebuildtransportx_new = Q_new Q_oldᵀ x_old,ρ ← ρRᵀ), cycle-consistency defect, coherent-negative-control guard for map updatesmincut_bridgeτ_e = α‖s_e‖ + β·leverage + γ·uncertainty + ζ·severity), deterministic Dinic quarantine boundary (seeds vs healthy), isolate-first/repair-first policies, signed intervention receipts; optionalruvector-mincutglobal cut behind themincutfeaturewitnessDependencies:
serde,sha2,thiserroronly (plus optional in-workspaceruvector-mincut). All solvers are hand-rolled, deterministic, and matrix-free where it matters.Test results (29 tests, all passing; clippy-clean)
H⁰nullity via LOBPCG; oracle vs production witnesses agrees ⊥_W im δ;flush()≡ batch (energy + identical witness hash); repair localizes planted contradictions; ADMM objective within 10% of exhaustive optimumBench snapshot (
cargo bench -p ruvector-cohomology)estimate()~1.4µsNotes / follow-ups
Wper edge stalk is a straightforward extension)Closes #669
🤖 Generated with claude-flow
https://claude.ai/code/session_017JAAahT1mcT1GahYxPDmaS
Generated by Claude Code