pub struct OperatorSet { /* private fields */ }Expand description
A set of deduction operators that compose via propagate-forward semantics.
An OperatorSet applies each operator in sequence to a hypothesis and evidence.
If an operator abstains, the abstention is recorded but does not prevent
subsequent operators from running on the best-known hypothesis so far.
Invariant: The result of apply_set is always ⊑ the input hypothesis (INV-PS-03).
Invariant: Operators and metadata are kept in lockstep registration order.
Implementations§
Source§impl OperatorSet
impl OperatorSet
Sourcepub fn register(self, op: Box<dyn Operator>, meta: OperatorMetadata) -> Self
pub fn register(self, op: Box<dyn Operator>, meta: OperatorMetadata) -> Self
Registers an operator with the set and returns self for chaining.
Panics if an operator with the same name is already registered.
Operator names must be unique to ensure the audit trail in SetOutcome.abstentions
unambiguously identifies each operator that abstains.
Sourcepub fn operator_names(&self) -> Vec<&str>
pub fn operator_names(&self) -> Vec<&str>
Returns the names of all registered operators in registration order.
Sourcepub fn iter_operators(&self) -> impl Iterator<Item = &dyn Operator>
pub fn iter_operators(&self) -> impl Iterator<Item = &dyn Operator>
Returns an iterator over references to the registered operators.
This allows proposers (e.g., lattice search) to invoke each operator
individually and collect refinements, rather than using the propagate-forward
semantics of apply_set.
Sourcepub fn apply_set(&self, h: &Hyp, e: &Evidence) -> SetOutcome
pub fn apply_set(&self, h: &Hyp, e: &Evidence) -> SetOutcome
Applies all operators in sequence, propagating refinements forward.
Algorithm:
- Start with
current_h = h.clone(). - For each operator (in registration order):
- Call
operator.apply(¤t_h, e). - If
Refined(h'): asserth' ⊑ current_h, then setcurrent_h = h'. - If
Abstain(r): record(operator_name, r)and leavecurrent_hunchanged.
- Call
- Return
SetOutcome { result: current_h, abstentions }.
Semantics: Abstention from one operator does not silence the next; each operator sees the best-known hypothesis so far. Final result ⊑ input always (OBL-PS-03).
§Safety
The refinement invariant (INV-PS-03) is checked via debug_assert! and only fires
in debug builds. In release builds, this invariant is unchecked; correctness depends
on each registered operator satisfying INV-PS-03 in its own implementation.
For clinical use, register only operators whose unit tests verify monotonicity.