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 QUESTION side of the fusion tree: the resolution chain a route's question walks, and the
//! participation rule that chain decides.

/// The question ONE ROUTE is asked, by the ruled precedence: **the route's own > this tier's > the
/// parent's**.
///
/// ```text
/// MediaFuseQuestion { question: "harbour at dusk",       ← the parent's
///   scenes: TranscriptFuseQuestion { question: None,     ← this tier's — silent, so it inherits
///     body: None,                                     ← this route's — silent, so it inherits
///     captions: Some("sunset"),                       ← this route's own, and it WINS
///   },
/// }
/// ```
///
/// # It is the OPTIONS chain's mirror, and deliberately so
///
/// The knobs resolve *override > tier default > declaration* and the question resolves *route >
/// tier > parent*: one shape, so a caller who has learned where to put a floor already knows where
/// to put a question. What differs is the terminator. A floor's chain ENDS in the declaration's own,
/// which cannot be missing, so a floor always resolves; a question's chain can end in nothing at
/// all, and that absence is load-bearing rather than an error — see the participation rule below.
///
/// # THE PARTICIPATION RULE
///
/// A route enters its parent's fold **iff it has a resolvable question**. `None` from this walk is
/// not an empty query and not a refusal: the route is STRUCTURALLY ABSENT from that request, exactly
/// as a route the client disabled is. That is what makes raw-coordinate multi-route fusion
/// expressible — each vector route is fed in its OWN space, a route nobody gave coordinates for and
/// which has no text road simply does not run, and reciprocal rank fusion merges whatever did.
///
/// It is also why the chain is written over an OWNED-OR-BORROWED question generically rather than
/// over a `String`: a fulltext route's currency is text, a vector route's is a point in its own
/// space, and the two never meet. `Q` is whichever one this route speaks.
///
/// # Borrowed through, never cloned
///
/// [`FloorSpec::resolve_vector`](super::FloorSpec::resolve_vector)'s posture: a question whose
/// currency is an expensive shape — a set of coordinates, say — costs the resolution nothing, and
/// the caller decides whether the winner is ever copied.
///
/// # Deeper than three tiers
///
/// The tree recurses and this function does not: a four-deep route resolves by applying it at each
/// level on the way down, each call's answer becoming the next call's `parent`. Three parameters
/// rather than a fold over a slice, because three is what the LAW says and a slice would have made
/// the precedence an argument's order rather than a signature's.
#[inline]
#[must_use]
pub fn asked<'a, Q: ?Sized>(
  own: Option<&'a Q>,
  tier: Option<&'a Q>,
  parent: Option<&'a Q>,
) -> Option<&'a Q> {
  own.or(tier).or(parent)
}

/// Whether a route ENTERS its parent's fold: it is walked, and it has a question to walk with.
///
/// Both halves, because the two absences are different facts a caller states in different places —
/// `enabled` is the parent's word about the edge ([`Route::enabled`](super::Route::enabled)), and a
/// resolvable question is the request's word about the subject. Either one missing is the same
/// outcome, and stating them together is what keeps a caller from checking one and forgetting the
/// other.
#[inline]
#[must_use]
pub fn participates<Q: ?Sized>(enabled: bool, question: Option<&Q>) -> bool {
  enabled && question.is_some()
}

#[cfg(test)]
mod tests;