ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
//! THE ENTRY's own claims: it carries what the fold computed, and carrying is not recomputing.

use super::Sighting;

/// **ALL THREE ARE READABLE, AND NONE IS DERIVED FROM ANOTHER.**
#[test]
fn a_sighting_carries_the_evidence_the_term_it_added_and_the_rank_behind_it() {
  let seen = Sighting::new(0.25, 3, "transcript");
  assert!((seen.contribution() - 0.25).abs() < f64::EPSILON);
  assert_eq!(seen.ordinal(), 3);
  assert_eq!(seen.seen(), &"transcript");
  assert_eq!(seen.into_components(), (0.25, 3, "transcript"));
}

/// **THE MAP CARRIES THE CONTRIBUTION ACROSS**, which is the wire face's move: an emitted union
/// variant maps a member's evidence into its schema shape, and the number the fold produced is not
/// something a mapping may produce a second version of.
#[test]
fn mapping_the_evidence_leaves_the_contribution_where_the_fold_put_it() {
  let mapped = Sighting::new(0.125, 7, 3_u32).map_seen(|rank| rank.to_string());
  assert!((mapped.contribution() - 0.125).abs() < f64::EPSILON);
  assert_eq!(
    mapped.ordinal(),
    7,
    "the map dropped the rank the fold carried"
  );
  assert_eq!(mapped.seen(), "3");
}

/// **THE CONTRIBUTION IS ONE TYPE HOWEVER MANY CURRENCIES MET.**
///
/// A member's SCORE is its engine's; the contribution is what the fold made of that member's RANK,
/// in the fold's own arithmetic. Two sightings over two currencies are compared here to say it: the
/// evidence types differ and the two contributions are the same `f64`, which is what lets one
/// ordering exist over a heterogeneous answer at all.
#[test]
fn two_currencies_contribute_in_one_arithmetic() {
  let deep: Sighting<f64> = Sighting::new(0.5, 1, 0.98_f64);
  let shallow: Sighting<f32> = Sighting::new(0.25, 2, 0.31_f32);
  assert!(deep.contribution() > shallow.contribution());
}

/// **THE ORDINAL IS THE INPUT AND THE CONTRIBUTION IS THE OUTPUT**, and the pin is that one cannot
/// be run backwards into the other — which is the whole of #296-L3's measurement.
///
/// Two sightings at the SAME rank with different contributions: legal, because the weight a parent
/// believed about each route differs and the weight never crosses the wire. A reader handed only the
/// contributions could not recover either rank, and a reader handed only the ranks could not
/// recover either contribution.
#[test]
fn the_rank_cannot_be_run_backwards_out_of_the_term_it_produced() {
  let heavy = Sighting::new(2.0 / 61.0, 1, "shots");
  let light = Sighting::new(0.5 / 61.0, 1, "subs");

  assert_eq!(heavy.ordinal(), light.ordinal(), "one rank, two beliefs");
  assert!(
    heavy.contribution() > light.contribution(),
    "the weight is what separates them, and it is not on the wire",
  );
}