langgoap.assert_expected_matches_declared#
- assert_expected_matches_declared(model, *, state, action)[source]#
Enforce the
expected()/ declared-effects contract.Dispatches on the model’s
divergence_policyattribute:None / absent (strict path) — require
model.expected(state, action) == action.get_effects(state)exactly. Catches silent declared-effect typos in user-authoredTransitionModelimplementations.Set, unbounded (
max_relative_deviation is None) — skip the equality check, but require a non-emptyreasonso every opt-out carries at least a sentence of documentation.Set, bounded — require
|expected - declared| / max(|declared|, 1.0) ≤ max_relative_deviationfor every numeric effect value. Boolean and string values still require exact equality; only numeric values are bound-relaxed, because flipping a boolean flag is a categorical change, not a bounded perturbation.
- Raises:
ValueError – when the model diverges from the declared effects (or an opt-out carries no reason). A plain
raiserather thanassertso the contract also holds underpython -O.- Parameters:
model (TransitionModel)
state (Mapping[str, Any])
action (ActionSpec)
- Return type:
None