Skip to content

Phase 3: GeodesicRigidityProjector and RationalWorldlineProjector — new IndexScore projectors #16

Description

@Mec-iS

Parent macro-issue: #12
Depends on: #15 (Phase 2)

Goal

Implement two new IndexScoreProjector trait implementations that slot into IndexScorePhase alongside the existing TauModeScore, FeatureSpectralScore, and friends — with zero changes to the pipeline structure.

Both projectors consume the GeodesicIndex built in Phase 2 and emit scores that expose manifold curvature and worldline deviation as first-class signals.


Projector 1: GeodesicRigidityProjector

Semantic

Measures how much an item's neighbourhood violates TQF collinearity. A low score means the item sits on or near a rational geodesic (smooth, stable manifold region). A high score flags a locally curved or noisy region where the spectral signal is less reliable.

Algorithm

For item x with k-nearest neighbours {n₁, …, n_k}:

  1. For each pair (n_i, n_j) with i < j, form the triple (x, n_i, n_j).
  2. Compute Q₁ = Q(x, n_i), Q₂ = Q(x, n_j), Q₃ = Q(n_i, n_j).
  3. TQF residual: R = |(Q₁+Q₂+Q₃)² − 2(Q₁²+Q₂²+Q₃²)|
  4. Score = mean(R) normalised by the 99th-percentile R over the corpus → [0, 1].

Config

pub struct GeodesicRigidityConfig {
    /// Number of neighbour pairs to sample per item. Default: all C(k,2) pairs.
    pub max_pairs: Option<usize>,
    /// Normalisation percentile. Default: 99.
    pub norm_percentile: f32,
}

Use cases

  • OOD detection: Items with unusually high rigidity score are in curved manifold pockets — candidates for OOD flagging alongside TauModeScore.
  • Laplacian coarsening: During graph coarsening, prefer to merge nodes with low rigidity score (they lie on geodesics and can be safely collapsed).
  • Wiring diagnostics: Corpus-level rigidity distribution reveals whether the embedding manifold is globally smooth or patchy.

Projector 2: RationalWorldlineProjector

Semantic

Designed for BioChain, discrete-physics, and metamaterial environments where items are expected to follow known rational geodesics (e.g., stoichiometric trajectories, lattice paths, simulation worldlines). Items that deviate from their expected geodesic receive an elevated anomaly score — without any floating-point drift accumulation.

Algorithm

At index time:

  1. Load GeodesicIndex (from Phase 2).
  2. For each item x, find the nearest certified geodesic triple (i, j, k) from the GeodesicIndex.
  3. Compute the projection of x onto the line segment [i, j] in quadrance terms:
    proj = i + t*(j - i),  t = Q(i,x) / Q(i,j)  (clamped to [0,1])
    worldline_quadrance(x) = Q(x, proj)
    
  4. Store worldline_quadrance per item in the index.

At query time:

Return worldline_quadrance(x) as the score. No recomputation needed on warm index.

Config

pub struct RationalWorldlineConfig {
    /// Maximum number of geodesic candidates to search per item. Default: 5.
    pub geodesic_candidates: usize,
    /// If true, use the integer quadrance path (requires QuadranceRational mode). Default: false.
    pub exact_rational: bool,
}

Use cases

  • BioChain anomaly detection: Metabolic or genomic state vectors that drift off expected reaction pathways get a non-zero worldline score in real-time, without accumulated floating-point error.
  • Simulation trajectory validation: Physics sim items that leave their expected worldline (lattice path, geodesic) are flagged immediately.
  • Complement to TauModeScore: High λ (high Dirichlet energy) + high worldline quadrance → the item is both spectrally rough and off-trajectory — strong anomaly signal.

Trait implementation

Both projectors implement the existing trait:

impl IndexScoreProjector for GeodesicRigidityProjector {
    fn project(&self, item: &EmbeddingVector, ctx: &IndexContext) -> f32;
    fn name(&self) -> &'static str { "geodesic_rigidity" }
    fn requires_geodesic_index(&self) -> bool { true }
}

impl IndexScoreProjector for RationalWorldlineProjector {
    fn project(&self, item: &EmbeddingVector, ctx: &IndexContext) -> f32;
    fn name(&self) -> &'static str { "rational_worldline" }
    fn requires_geodesic_index(&self) -> bool { true }
}

IndexContext gains a geodesic_index: Option<&GeodesicIndex> field (None if WiringMode::Standard).


Tests

  • Unit — rigidity on lattice: All items in a regular integer lattice must score near 0.0.
  • Unit — rigidity on random: Mean rigidity score on random Gaussian cloud > 0.5.
  • Unit — worldline on geodesic: Item placed exactly on a certified geodesic must score 0.0.
  • Unit — worldline off geodesic: Item displaced by known quadrance d must score d (within float tolerance).
  • Integration — CVE: GeodesicRigidityScore distribution is right-skewed (Shapiro-Wilk p < 0.01 for normality rejection); logged percentile breakdown.
  • Serialisation: Both projectors serialise and deserialise correctly; warm-index scores are bit-exact.
  • Benchmark: Combined overhead of both projectors vs. TauModeScore alone < 5 % on a warm CVE index.

Acceptance criteria

  • GeodesicRigidityProjector implemented, tested, and registered in IndexScorePhase.
  • RationalWorldlineProjector implemented, tested, and registered in IndexScorePhase.
  • IndexContext extended with geodesic_index: Option<&GeodesicIndex>.
  • Both projectors gated behind WiringMode::TqfAnnotated (no-op / zero score when WiringMode::Standard).
  • CVE integration test passes with logged score distributions.
  • All previous phase regression tests still pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions