# lawref.population_replay

*module*

`population-replay` — воспроизведение одного документа отчёта
`population-impact` по пинам банка (DECISION-0271, proof по требованию).

Отчёт, собранный с `--no-store`, несёт только адреса документов
(`documentRef` — sha256 канонических байтов [§208](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/28-part-xxvii-canonical-legal-ir.ru.md#208-canonical-serialization)). Повтор — тот же `ask`
строки на той же стороне с тем же закреплённым запросом: пины сторон банка
(манифест, лок, `theoryHash`, `artifactHash`, ресурсы), понижение дела,
исполнение. Байты сверяются с `documentRef`; совпали — документ записан в
`--out` (если дан), код 0; разошлись — код 3 `POPULATION_REPLAY_MISMATCH`
(документ всё равно записывается для разбора); отказы подготовки — код 2.

## lawref.population_replay.FAILED

*attribute* · *module attribute*

```python
FAILED = 'POPULATION_REPLAY_FAILED'
```

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

## lawref.population_replay.MISMATCH

*attribute* · *module attribute*

```python
MISMATCH = 'POPULATION_REPLAY_MISMATCH'
```

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

## lawref.population_replay.MISMATCH_EXIT

*attribute* · *module attribute*

```python
MISMATCH_EXIT = 3
```

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

## lawref.population_replay.NO_DOCUMENT

*attribute* · *module attribute*

```python
NO_DOCUMENT = 'POPULATION_REPLAY_NO_DOCUMENT'
```

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

## lawref.population_replay.OK_EXIT

*attribute* · *module attribute*

```python
OK_EXIT = 0
```

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

## lawref.population_replay.QUERIES

*attribute* · *module attribute*

```python
QUERIES = ('measure', 'rank', 'size.adults', 'size.children')
```

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

## lawref.population_replay.REFUSED_EXIT

*attribute* · *module attribute*

```python
REFUSED_EXIT = 2
```

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

## lawref.population_replay.REPORT_INVALID

*attribute* · *module attribute*

```python
REPORT_INVALID = 'POPULATION_REPLAY_REPORT_INVALID'
```

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

## lawref.population_replay.TOOL

*attribute* · *module attribute*

```python
TOOL = 'population-replay'
```

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

## lawref.population_replay.USAGE

*attribute* · *module attribute*

```python
USAGE = 'POPULATION_REPLAY_USAGE'
```

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

## lawref.population_replay.USAGE_TEXT

*attribute* · *module attribute*

```python
USAGE_TEXT = 'python -m lawref population-replay --bank <bank.json> --report <report.json> --row <rowId> --side before|after [--query measure|rank|size.adults|size.children] [--out <файл>] [--lawc <бинарь>]'
```

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

## lawref.population_replay.ReplayRefusal

*class*

```python
class ReplayRefusal(Exception)
```

Bases: `Exception`

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

### lawref.population_replay.ReplayRefusal.code

*attribute* · *instance attribute*

```python
code = code
```

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

### lawref.population_replay.ReplayRefusal.message

*attribute* · *instance attribute*

```python
message = message
```

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

### lawref.population_replay.ReplayRefusal.line

*method*

```python
def line() -> str
```

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

## lawref.population_replay.document_ref

*function*

```python
def document_ref(core: dict, row_id: str, side: str, query: str) -> tuple[str, str]
```

(вид адреса, адрес) документа строки для стороны и запроса: `documentRef`
в полном режиме, `outcomeHash` в отчёте без proof (DECISION-0275,
`reportCore.proofMode = omitted`); отсутствие — отказ.

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

## lawref.population_replay.load_report

*function*

```python
def load_report(path: Path) -> dict
```

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

## lawref.population_replay.main

*function*

```python
def main(argv: list[str], lower=None, lower_root=None) -> int
```

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

## lawref.population_replay.query_of

*function*

```python
def query_of(bank: dict, query: str, side: str) -> tuple[dict, dict | None]
```

Запрос и мера (для проекции) по имени; rank/size — только сторона basis.

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

## lawref.population_replay.replay

*function*

```python
def replay(bank_path: Path, report_path: Path, row_id: str, side_label: str, query: str, lower, lower_root) -> tuple[bytes, str, str]
```

(канонические байты документа, его адрес, ожидаемый адрес из отчёта).
Адрес — `documentRef` документа либо, для отчёта без proof, `outcomeHash`
той же проекции [§5](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/02-part-ii-goals-and-scope.ru.md#5-главные-инварианты-дизайна) над полным документом повтора.

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