langgoap.assert_expected_matches_declared

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_policy attribute:

  • None / absent (strict path) — require model.expected(state, action) == action.get_effects(state) exactly. Catches silent declared-effect typos in user-authored TransitionModel implementations.

  • Set, unbounded (max_relative_deviation is None) — skip the equality check, but require a non-empty reason so every opt-out carries at least a sentence of documentation.

  • Set, bounded — require |expected - declared| / max(|declared|, 1.0) ≤ max_relative_deviation for 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 raise rather than assert so the contract also holds under python -O.

Parameters:
Return type:

None