# lawref

*module*

lawref — исполняемая спецификация Law DSL (оракул; FND [§5.2](https://github.com/arxohq/law/blob/master/spec/FOUNDATION.ru.md#52-lawref--исполняемая-спецификация-python)).

Правила пакета: только stdlib Decimal/Fraction на семантическом пути (никакого
float — enforce: verify/ci/gates/repo/check_lawref_determinism.py); каждая семантическая функция
несёт ссылку на § SPEC в docstring; итерация — только по отсортированным ключам.
Стартовая база в legacy/ (run_kz_corpus, build_kz_corpus_ir, validate_package)
переносится в модули по условиям FND [§5.2](https://github.com/arxohq/law/blob/master/spec/FOUNDATION.ru.md#52-lawref--исполняемая-спецификация-python), до переноса — не импортируется.

## lawref.CounterfactualError

*class*

```python
class CounterfactualError(ValueError)
```

Bases: `ValueError`

Re-exported from: `lawref.counterfactual`

Stable machine-readable counterfactual input/search failure.

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/counterfactual.py#L26-L32)

### lawref.CounterfactualError.code

*attribute* · *instance attribute*

```python
code = code
```

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/counterfactual.py#L31-L31)

### lawref.CounterfactualError.message

*attribute* · *instance attribute*

```python
message = message
```

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/counterfactual.py#L32-L32)

## lawref.evaluate_counterfactual

*function*

```python
def evaluate_counterfactual(ir: dict, case: dict, input_: dict, options: dict | None = None, external_snapshots: list[dict] | None = None) -> dict
```

Re-exported from: `lawref.counterfactual`

Evaluate all candidates through the first complete successful tier.

Options внутренних прогонов [§186](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/26-part-xxv-proof-graph-and-explanations.ru.md#186-counterfactual) берутся из ``case["options"]``, если
вызывающий не назвал свои: DECISION-0111 [§2.2](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/01-part-i-audit.ru.md#22-четырёхзначной-логики-самой-по-себе-недостаточно) объявляет ``case.options``
ЕДИНСТВЕННЫМ местом семантических опций, а `EvaluationRequest.build`
затирает их переданным словарём. До errata E-0135 (06.09.2026) умолчание
``{}`` молча выбрасывало выбор прочтения [§152](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/21-part-xx-interpretations-and-theories.ru.md#152-interpretation) и календарь дела: кандидаты
считались в мире без опций, а `caseHash` входа — по делу с ними.

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/counterfactual.py#L221-L386)

## lawref.verify_counterfactual_result

*function*

```python
def verify_counterfactual_result(ir: dict, case: dict, input_: dict, claimed: dict, options: dict | None = None, external_snapshots: list[dict] | None = None) -> None
```

Re-exported from: `lawref.counterfactual`

Replay and verify the complete canonical certificate and solution set.

[View source](https://github.com-arxohq/arxo-io/law/blob/2edc2b92ce22b52e03f4081d2769a58229684379/engines/lawref/lawref/counterfactual.py#L389-L398)

**Modules**

- `lawref.a3`
- `lawref.a3_io`
- `lawref.amend`
- `lawref.amend_enum`
- `lawref.amend_guards`
- `lawref.amend_profile`
- `lawref.applicability`
- `lawref.approvals`
- `lawref.argmap`
- `lawref.ask`
- `lawref.authoring`
- `lawref.calendar`
- `lawref.canon`
- `lawref.cases`
- `lawref.cert`
- `lawref.compose`
- `lawref.conformance`
- `lawref.context`
- `lawref.core_cli`
- `lawref.counterfactual`
- `lawref.delegation`
- `lawref.diagnostics`
- `lawref.divergence`
- `lawref.entrenchment`
- `lawref.evaluator`
- `lawref.expansion`
- `lawref.export`
- `lawref.fuzz`
- `lawref.goals`
- `lawref.hashing`
- `lawref.i18n`
- `lawref.impact`
- `lawref.ir_compat`
- `lawref.lawtest`
- `lawref.layers`
- `lawref.loophole`
- `lawref.measure`
- `lawref.migrate`
- `lawref.mutate`
- `lawref.normstatic`
- `lawref.official_text`
- `lawref.population`
- `lawref.population_bank`
- `lawref.population_bind`
- `lawref.population_distribution`
- `lawref.population_replay`
- `lawref.process`
- `lawref.profiles`
- `lawref.public_main`
- `lawref.query`
- `lawref.reanchor`
- `lawref.resolver`
- `lawref.resources`
- `lawref.revision`
- `lawref.scenario`
- `lawref.schemas`
- `lawref.screen`
- `lawref.semdiff`
- `lawref.std_generated`
- `lawref.std_registry`
- `lawref.term_sugar`
- `lawref.textpattern`
- `lawref.unit_declarations`
- `lawref.units`
- `lawref.values`
- `lawref.verbalize`
