# lawref.ir_compat

*module*

Compat-чтение и миграция CLIR-документов 0.1 → 0.2 (DECISION-0001, WP-03).

Форма SymbolDecl.parameters определяется schemaVersion конверта (SPEC [§202](https://github.com/arxohq/law/blob/master/spec/SPEC.ru/28-part-xxvii-canonical-legal-ir.ru.md#202-common-node-fields),
DECISION-0001 п.5): law.core.ir/0.1 — TypeRef[], law.core.ir/0.2 — ParameterDecl[].
Смешение форм внутри документа запрещено semantic-правилом (не выразимо схемой) —
проверяется здесь. Позиционные `keys` при миграции остаются валидными: порядок и
длина массива параметров сохраняются (DECISION-0001 п.6).

## lawref.ir_compat.LEGACY_ARG_SEGMENT

*attribute* · *module attribute*

```python
LEGACY_ARG_SEGMENT = '/.legacy/arg/'
```

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

## lawref.ir_compat.V01

*attribute* · *module attribute*

```python
V01 = 'law.core.ir/0.1'
```

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

## lawref.ir_compat.V02

*attribute* · *module attribute*

```python
V02 = 'law.core.ir/0.2'
```

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

## lawref.ir_compat.V03

*attribute* · *module attribute*

```python
V03 = 'law.core.ir/0.3'
```

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

## lawref.ir_compat.V04

*attribute* · *module attribute*

```python
V04 = 'law.core.ir/0.4'
```

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

## lawref.ir_compat.V05

*attribute* · *module attribute*

```python
V05 = 'law.core.ir/0.5'
```

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

## lawref.ir_compat.check_envelope

*function*

```python
def check_envelope(document: dict) -> list[str]
```

Конвертная дискриминация: schemaVersion обязан соответствовать фактической форме.

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

## lawref.ir_compat.keys_invariant

*function*

```python
def keys_invariant(before: dict, after: dict) -> list[str]
```

Миграционный тест DECISION-0001 п.6: keys и арность параметров не изменились.

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

## lawref.ir_compat.parameters_form

*function*

```python
def parameters_form(document: dict) -> str
```

Фактическая форма параметров: '0.1' | '0.2' | 'empty'. Смешение — ValueError.

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

## lawref.ir_compat.upgrade

*function*

```python
def upgrade(document: dict) -> dict
```

0.1 → 0.2: ParameterDecl[] с позиционными legacy-ID (PATCH [§2.3](https://github.com/arxohq/law/blob/master/spec/addendum/PATCH-0.1.1-ONTOLOGY.ru.md#23-backward-compatibility)).

Имена аргументов в 0.1-форме утрачены (в этом и был дефект KZ-C2), поэтому
name = arg<i>, id = <symbol_id>/.legacy/arg/<i>, role отсутствует. Такие
символы нельзя экспортировать из core-production без явной миграции.
Инвариант: len(parameters) и порядок сохранены — `keys` остаются валидными.

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