langgoap.DivergencePolicy#

class DivergencePolicy(reason, kind='other', max_relative_deviation=None, extra=<factory>)[source]#

Declared divergence between expected() and declared effects.

Presence of this policy on a TransitionModel instance opts the model out of strict-equality enforcement and documents why, how far, and (optionally) how the divergence is configured.

Parameters:
  • reason (str)

  • kind (Literal['risk-averse', 'learned', 'hierarchical', 'other'])

  • max_relative_deviation (float | None)

  • extra (Mapping[str, Any])

reason#

Short human-readable label, required. Empty strings are rejected at conformance-check time so every opt-out carries at least one sentence of documentation.

Type:

str

kind#

Structured taxonomy slot consumed by the router. See DivergenceKind.

Type:

Literal[‘risk-averse’, ‘learned’, ‘hierarchical’, ‘other’]

max_relative_deviation#

Optional bound on |expected - declared| / max(|declared|, 1.0) for each numeric effect value. Boolean and string effects still require exact equality regardless of this bound. None means divergence is unbounded (only the reason documentation is enforced).

Type:

float | None

extra#

Implementation-specific configuration — e.g. CVaR alpha, pessimism weight, learned-model version hash. Opaque to the core library; read by implementations.

Type:

collections.abc.Mapping[str, Any]

__init__(reason, kind='other', max_relative_deviation=None, extra=<factory>)#
Parameters:
  • reason (str)

  • kind (Literal['risk-averse', 'learned', 'hierarchical', 'other'])

  • max_relative_deviation (float | None)

  • extra (Mapping[str, Any])

Return type:

None

Methods

__init__(reason[, kind, ...])

Attributes