judgevet.domain.policy_evaluation
Status: draft.
judgevet.domain.policy_evaluation
Strict typed policy evaluation over shared pure comparison functions.
The CLI compatibility bridge shares these comparisons while retaining its historical answer checks. Public evaluation validates required scalars against snapshotted question constraints and returns complete ordered reports.
Examples:
from judgevet.domain.answers import NoulAnswer
from judgevet.domain.questions import Noul
from judgevet.domain.policy_rules import NoulRule, Policy
from judgevet.domain.policy_validation import validate_policy
from judgevet.domain.policy_evaluation import evaluate_policy
policy = validate_policy(Policy((NoulRule("q", 0.5),)), {"q": Noul()})
assert evaluate_policy(policy, {"q": NoulAnswer(0.5)}).passed
See Also
- judgevet.domain.policy_validation: Validated policy construction.
- judgevet.domain.policy_reports: Immutable report types.
compare_rule(rule, answer)
Compute shared predicates for an already checked answer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule
|
Rule
|
Typed rule. |
required |
answer
|
Answer
|
Matching answer variant. |
required |
Returns:
| Type | Description |
|---|---|
RuleReport
|
One immutable report with comparison details. |
Raises:
| Type | Description |
|---|---|
PolicyAnswerError
|
If the answer does not match the rule type. |
evaluate_policy(policy, answers)
Evaluate every rule in order; unmet predicates return failed reports.
Only selected answer scalars are checked. Probability distributions and legend metadata remain the answer types' responsibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
ValidatedPolicy
|
Validated immutable policy. |
required |
answers
|
Mapping[str, Answer]
|
Typed answers keyed by question name. |
required |
Returns:
| Type | Description |
|---|---|
PolicyReport
|
Every rule outcome with a derived aggregate verdict. |
Raises:
| Type | Description |
|---|---|
PolicyDefinitionError
|
If policy is not validated. |
PolicyAnswerError
|
If required answers are missing or invalid. |