# Contracts

Docs for TrueQuery 0.1.6. What a contract records, where it lives, and what a table without one costs you.

A contract says what a table is, before anyone writes code against it. Each one lives in `contracts/<name>.yaml`.

It records the grain (what one row means), the keys, the columns with their units, freshness, personal-data flags and the owner, where they're known. This one is from the demo shop:

```yaml
table: fx_rates
grain: one row per (rate_date, currency)
keys:
  - [rate_date, currency]
columns:
  rate_date: {unit: date}
  currency: {unit: ISO code}
  rate_to_usd: {unit: rate}
quirks: rate_to_usd varies daily (+-2%); join on the business date, never on today()/max date.
```

## Where they come from

`/truequery init` seeds contracts from any schema YAML you have. During a build, the agent writes or extends one before the code, citing your answers.

A grain nobody has confirmed is marked `TODO`, and the agent calls that contract a draft whenever it cites it.

## What they change

The agent reads them for context, and the checker uses declared keys. A table with none shows up on the receipt's **No contract** line, so you can see where the agent had to assume.
