## io.Contract


What a sink records with each commit: which plan produced the data,


Usage

``` python
io.Contract(
    view,
    plan,
    sources,
    epoch,
    not_null,
    checks,
    unique,
    digests=dict(),
    cursors=dict(),
    table_ids=dict(),
    format=CONTRACT_FORMAT
)
```


from which source versions, and what it proved about every row.

[DeltaSource.contract()](io.DeltaSource.md#sverify.io.DeltaSource.contract) and [IcebergSource.contract()](io.IcebergSource.md#sverify.io.IcebergSource.contract) read it back.


## Attributes


`view: str`  
The stored node's name.

`sources: dict[str, int]`  
The version of every source table the state was computed from.

`not_null: list[str]`  
Columns the node proves NOT NULL: stated in `ensures` (`_.col.notnull()`), or shown never NULL by its proved report (`Report.not_null`).

`unique: list[list[str]]`  
Column sets the node proves unique.

`cursors: dict[str, Any]`  
The cursor of every source that can restore its table from one ([Source.restore](io.Source.md#sverify.io.Source.restore)), at its version in `sources`.

`table_ids: dict[str, str]`  
The id of every source table that has one (a Delta table's `metaData.id`), at its version in `sources`.


## Methods

| Name | Description |
|----|----|
| [from_json()](#from_json) | A contract from what [to_json](Report.to_json.md#sverify.Report.to_json) wrote, by this version of sverify |
| [to_json()](#to_json) | The contract as JSON, as sinks store it. |

------------------------------------------------------------------------


#### from_json()


A contract from what [to_json](Report.to_json.md#sverify.Report.to_json) wrote, by this version of sverify


Usage

``` python
from_json(text)
```


or an earlier one. Keys this version does not know, which a later 1.x version may add, are left out.


##### Parameters


`text: str`  
The JSON [to_json](Report.to_json.md#sverify.Report.to_json) wrote.


##### Returns


`Contract`  
The contract.


##### Raises


`ValueError`  
The record's [format](io.Contract.md#sverify.io.Contract.format) is newer than this version reads.


------------------------------------------------------------------------


#### to_json()


The contract as JSON, as sinks store it.


Usage

``` python
to_json()
```


##### Returns


`str`  
A JSON object with the contract's fields, keys sorted, in the

format of `sverify/schemas/sink-contract.schema.json`.
