pub struct SideConditionChecker<'a> { /* private fields */ }Expand description
Answers side-condition queries for plan rewrites.
Used by the certificate verifier and rewrite engine to check whether a rewrite is safe to apply.
Implementations§
Source§impl<'a> SideConditionChecker<'a>
impl<'a> SideConditionChecker<'a>
Sourcepub fn analysis(&self) -> &PlanAnalysis
pub fn analysis(&self) -> &PlanAnalysis
Returns the underlying analysis.
Sourcepub fn obligations_safe(&self, id: PlanId) -> bool
pub fn obligations_safe(&self, id: PlanId) -> bool
Check if a node’s children are obligation-safe (no cancel leaks).
Sourcepub fn cancel_safe(&self, id: PlanId) -> bool
pub fn cancel_safe(&self, id: PlanId) -> bool
Check if a node’s cancel behavior is safe (losers drained).
Sourcepub fn are_independent(&self, a: PlanId, b: PlanId) -> bool
pub fn are_independent(&self, a: PlanId, b: PlanId) -> bool
Check if two subtrees are independent (no shared mutable state).
Conservative: returns true only if neither subtree contains nodes that appear in the other’s reachable set. This is a structural check — it cannot detect aliased external state.
Sourcepub fn rewrite_preserves_obligations(
&self,
before: PlanId,
after: PlanId,
) -> bool
pub fn rewrite_preserves_obligations( &self, before: PlanId, after: PlanId, ) -> bool
Check if a rewrite from before to after preserves obligation safety.
Conservative: requires both the before and after nodes to be obligation-safe.
Sourcepub fn rewrite_preserves_cancel(&self, before: PlanId, after: PlanId) -> bool
pub fn rewrite_preserves_cancel(&self, before: PlanId, after: PlanId) -> bool
Check if a rewrite preserves cancel safety.
Sourcepub fn rewrite_preserves_budget(&self, before: PlanId, after: PlanId) -> bool
pub fn rewrite_preserves_budget(&self, before: PlanId, after: PlanId) -> bool
Check if a rewrite preserves budget monotonicity.
Sourcepub fn rewrite_preserves_deadline(&self, before: PlanId, after: PlanId) -> bool
pub fn rewrite_preserves_deadline(&self, before: PlanId, after: PlanId) -> bool
Check if a rewrite preserves deadline guarantees specifically.
This is a more focused check than rewrite_preserves_budget:
- If the original has no deadline, any deadline is acceptable
- If the original has a deadline, the rewritten must have one that is at least as tight
Sourcepub fn effective_deadline(&self, id: PlanId) -> Option<DeadlineMicros>
pub fn effective_deadline(&self, id: PlanId) -> Option<DeadlineMicros>
Returns the effective deadline for a node, if any.
Sourcepub fn deadline_within_tolerance(
&self,
before: PlanId,
after: PlanId,
tolerance_micros: u64,
) -> bool
pub fn deadline_within_tolerance( &self, before: PlanId, after: PlanId, tolerance_micros: u64, ) -> bool
Check if a rewrite does not worsen the deadline by more than a given amount.
Useful for allowing small deadline relaxations in exchange for other benefits.
Sourcepub fn rewrite_preserves_loser_drain(
&self,
before: PlanId,
after: PlanId,
) -> bool
pub fn rewrite_preserves_loser_drain( &self, before: PlanId, after: PlanId, ) -> bool
Returns true when a rewrite preserves the loser-drain property.
A rewrite is safe if it does not degrade cancel-safety (Safe → non-Safe) and does not introduce new obligation leak candidates on the cancel path.
Sourcepub fn rewrite_preserves_finalize_order(
&self,
before: PlanId,
after: PlanId,
) -> bool
pub fn rewrite_preserves_finalize_order( &self, before: PlanId, after: PlanId, ) -> bool
Returns true when a rewrite preserves the relative order of obligation-bearing children inside a Join node.
For Race/Timeout/Leaf rewrites this always returns true (no ordering
contract). Race → Join (e.g., DedupRaceJoin) is allowed because a
Race imposes no finalize ordering on its children; any ordering in the
resulting Join is valid.
Sourcepub fn rewrite_no_new_obligation_leaks(
&self,
before: PlanId,
after: PlanId,
) -> bool
pub fn rewrite_no_new_obligation_leaks( &self, before: PlanId, after: PlanId, ) -> bool
Returns true when a rewrite does not introduce new obligation leaks.
This checks three properties:
- Obligation safety does not degrade (safe → unsafe).
- The
all_paths_resolveflag does not become false. - The set of
leak_on_cancelobligations does not grow. - Previously
must_resolveobligations are not demoted to leak-or-reserve.
Sourcepub fn children_pairwise_independent(&self, children: &[PlanId]) -> bool
pub fn children_pairwise_independent(&self, children: &[PlanId]) -> bool
Check whether all children are pairwise independent.
Source§impl SideConditionChecker<'_>
impl SideConditionChecker<'_>
Sourcepub fn check_independence(&self, a: PlanId, b: PlanId) -> IndependenceResult
pub fn check_independence(&self, a: PlanId, b: PlanId) -> IndependenceResult
Check if two nodes are independent (can be safely reordered).
Two nodes are independent if:
- They don’t share any common descendants (structural independence)
- They don’t have data dependencies through obligations
- Reordering them doesn’t change observable behavior
This is a conservative analysis: if uncertain, returns Uncertain.
Sourcepub fn commutes(&self, a: PlanId, b: PlanId) -> bool
pub fn commutes(&self, a: PlanId, b: PlanId) -> bool
Check if two nodes commute (can be reordered without changing semantics).
This is an alias for check_independence with a clearer name for
users thinking in terms of commutativity.
Sourcepub fn compute_independence_relation(&self) -> IndependenceRelation
pub fn compute_independence_relation(&self) -> IndependenceRelation
Compute the independence relation for all leaf nodes in the DAG.
This builds a relation that can be used for Mazurkiewicz trace equivalence checking: two sequences are equivalent if one can be transformed into the other by commuting independent operations.
Sourcepub fn rewrite_valid_up_to_trace(&self, before: PlanId, after: PlanId) -> bool
pub fn rewrite_valid_up_to_trace(&self, before: PlanId, after: PlanId) -> bool
Check if a rewrite is valid up to Mazurkiewicz trace equivalence.
A rewrite is valid if:
- The structural transformation is correct
- The rewrite preserves the independence relation
- The observable behavior is preserved (up to reordering of independent operations)
This is useful for rewrites like Join[a, b] -> Join[b, a] where
the order doesn’t matter if a and b are independent.
Sourcepub fn reorderable_join_children(&self, children: &[PlanId]) -> Vec<Vec<usize>>
pub fn reorderable_join_children(&self, children: &[PlanId]) -> Vec<Vec<usize>>
Check if the children of a Join can be reordered.
Returns the indices of children that can be freely reordered (all pairs in the returned set are mutually independent).
Sourcepub fn trace_equivalence_hint(&self, id: PlanId) -> TraceEquivalenceHint
pub fn trace_equivalence_hint(&self, id: PlanId) -> TraceEquivalenceHint
Get a trace equivalence hint for a node.
Returns a summary of which operations can commute, useful for the rewrite engine to know when certain rewrites are safe.