# lawref.verbalize

*module*

B1 — вербализатор CLIR (WP-25 MVP; LAYERS-SURFACES [§3](https://github.com/arxohq/law/blob/master/spec/LAYERS-SURFACES.ru.md)).

Детерминированная **односторонняя** проекция CLIR в контролируемый русский
текст. Продукт — ревью-артефакт `.lawread.md`: юрист читает и утверждает текст,
а не код. Вербализация НЕ является официальным текстом и не имеет
семантической силы; расхождение утверждённого текста и семантики — всегда
дефект template pack (LS [§3.1](https://github.com/arxohq/law/blob/master/spec/LAYERS-SURFACES.ru.md#31-назначение-и-позиция)).

Контракт (LS [§3.2](https://github.com/arxohq/law/blob/master/spec/LAYERS-SURFACES.ru.md#32-архитектура-и-детерминизм)), проверяемый VER-векторами:

- чистая функция: ни сети, ни часов, ни внешних сервисов, ни LLM; одинаковые
  *(CLIR, язык, версия pack)* дают байтово одинаковый текст;
- вербализация получает content hash (sha256 байтов документа);
- **тотальность** (LS [§3.3](https://github.com/arxohq/law/blob/master/spec/LAYERS-SURFACES.ru.md#33-тотальность-и-честные-пробелы)): у каждого node kind либо шаблон, либо видимый
  маркер `⟦не вербализуется: … (LDC-E8201)⟧`. Молчаливый пропуск запрещён —
  он прячет семантику от утверждающего.

Формульный стиль — ступень (1) LS [§3.8](https://github.com/arxohq/law/blob/master/spec/LAYERS-SURFACES.ru.md#38-морфология-ru--kk): слоты стоят в именительном падеже и
кавычках; морфологические формы [§218.1](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/30-part-xxix-ux-dx-specification.ru.md#2181-grammatical-forms) используются, если метка их несёт, и
деградируют к `text`, если нет.

## lawref.verbalize.FORMS_FORMAT

*attribute* · *module attribute*

```python
FORMS_FORMAT = 'law.verb/0.2'
```

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

## lawref.verbalize.GAP_WHAT_KEYS

*attribute* · *module attribute*

```python
GAP_WHAT_KEYS: tuple[str, ...] = tuple(sorted(GAP_WHAT_RU))
```

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

## lawref.verbalize.GAP_WHAT_RU

*attribute* · *module attribute*

```python
GAP_WHAT_RU: dict[str, str] = {'node.kind': '{kind}', 'node.no_kind': 'узел без kind', 'term.unknown_shape': 'терм неизвестной формы', 'term.kind': 'терм {kind}', 'interval.unknown_shape': 'интервал неизвестной формы', 'formula.unknown_shape': 'формула неизвестной формы', 'formula.kind': 'формула {kind}', 'formula.status': 'статус {status}', 'formula.quantifier': 'квантор {quantifier}', 'formula.norm_template_ref': 'формула norm_template_ref', 'rule.scope': 'область применения правила', 'definition.part': 'происхождение из определения (§144)', 'external.effect': 'внешний канал {effect}', 'norm.no_payload': 'norm_template без payload', 'goal.unknown_shape': 'цель обязанности неизвестной формы', 'goal.kind': 'цель обязанности {kind}', 'effect.unknown_shape': 'правовой эффект неизвестной формы', 'effect.kind': 'правовой эффект {kind}', 'interpretation.selection': 'политика выбора толкования {selection}', 'revision.unknown_shape': 'операция поправки неизвестной формы', 'revision.op': 'операция поправки {kind}'}
```

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

## lawref.verbalize.SECTION_ORDER

*attribute* · *module attribute*

```python
SECTION_ORDER: list[tuple[str, str]] = [('source.section', 'source_work'), ('source.section', 'source_edition'), ('entrenchment.section', 'entrenchment'), ('revision.section', 'revision'), ('publication.section', 'publication'), ('fragment.section', 'fragment'), ('reference.section', 'reference'), ('interpretation.section', 'interpretation_group'), ('interpretation.section', 'interpretation'), ('entity.section', 'type_decl'), ('relation.section', 'symbol_decl'), ('function.section', 'function_decl'), ('external.section', 'external_decl'), ('assertion.section', 'assertion'), ('anchor.section', 'anchor'), ('query.section', 'query'), ('unit.section', 'unit_decl'), ('procedure.section', 'procedure'), ('stage.section', 'stage'), ('evidence_policy.section', 'evidence_policy'), ('temporal_policy.section', 'temporal_resolution_policy'), ('evidence.section', 'evidence_item'), ('support.section', 'support_edge'), ('closure.section', 'closure_policy'), ('calendar.section', 'calendar_snapshot'), ('deadline.section', 'deadline_policy'), ('rule.section', 'rule'), ('norm.section', 'norm_template'), ('priority.section', 'priority_rule'), ('constraint.section', 'constraint'), ('precedent.section', 'factor_vocabulary'), ('precedent.section', 'precedent_decl'), ('counterfactual.section', 'counterfactual_decl')]
```

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

## lawref.verbalize.SUPPORTED_PACK_FORMATS

*attribute* · *module attribute*

```python
SUPPORTED_PACK_FORMATS = ('law.verb/0.1', 'law.verb/0.2')
```

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

## lawref.verbalize.VERBALIZATION_GAP

*attribute* · *module attribute*

```python
VERBALIZATION_GAP = 'LDC-E8201'
```

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

## lawref.verbalize.PackError

*class*

```python
class PackError(ValueError)
```

Bases: `ValueError`

Дефект template pack: отсутствует обязательная фраза или поле.

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

## lawref.verbalize.load_pack

*function*

```python
def load_pack(path: str | Path) -> dict
```

Загрузка template pack. Pack — данные, а не код (LS [§3.2](https://github.com/arxohq/law/blob/master/spec/LAYERS-SURFACES.ru.md#32-архитектура-и-детерминизм)).

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

## lawref.verbalize.local_name

*function*

```python
def local_name(identifier: str) -> str
```

Локальное имя StableId: часть после `#`, у порождённых — с суффиксом.

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

## lawref.verbalize.render_atom

*function*

```python
def render_atom(ctx: _Ctx, literal: dict) -> str
```

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

## lawref.verbalize.render_formula

*function*

```python
def render_formula(ctx: _Ctx, formula: Any) -> str
```

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

## lawref.verbalize.render_node

*function*

```python
def render_node(ctx: _Ctx, node: dict) -> list[str]
```

Тело блока одной декларации: список абзацев (без заголовка).

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

## lawref.verbalize.render_term

*function*

```python
def render_term(ctx: _Ctx, term: Any) -> str
```

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

## lawref.verbalize.verbalize

*function*

```python
def verbalize(document: dict, pack: dict) -> dict
```

CLIR → ревью-документ `.lawread.md`.

Возвращает `{"text", "contentHash", "gaps"}`. `gaps` непуст — документ НЕ
ДОЛЖЕН допускаться к утверждению статусом выше `draft` (LS [§3.3](https://github.com/arxohq/law/blob/master/spec/LAYERS-SURFACES.ru.md#33-тотальность-и-честные-пробелы)).

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