File and directory formats
Every file contextlift reads or writes is plain text (CSV, JSON, JSONL, YAML, or Markdown). YAML files need contextlift[yaml]; every structured reader also accepts .json with zero third-party dependencies.
The spec/ directory
A spec/ directory compiles into Arm 0d (control: schema/ only) and Arm 1 (treatment: everything below):
spec/
rules/
00-definitions.md # two-digit prefix orders tiers broadest-first
10-output-conventions.md
schema/
orders.json # or orders.yaml (table name IS the filename)
analytics.orders.yaml # 1-, 2-, or 3-part table names supported
authored/
orders.yaml # curated column overrides (treatment arm only)
vocabulary/
metrics.yaml # canonical terms, definitions, synonyms
examples/
bank.jsonl # one {"question": "...", "sql": "..."} per line
relationships.yaml # table join edges (left, right, on)
domains/
finance/rules/ # optional multi-domain overrides (--domain finance)
schema/<table>.json (or .yaml)
{
"description": "Customer subscription orders",
"synonyms": ["bookings"],
"columns": {
"status": {"description": "Order lifecycle state", "data_type": "VARCHAR"},
"mrr_usd": {"description": "Monthly recurring revenue in USD", "data_type": "DOUBLE"}
}
}
columns also accepts a dbt-style list ([{"name": "status", "description": "..."}]).
vocabulary/*.yaml and relationships.yaml
vocabulary/*.yaml: list of{name, definition, synonyms: [...]}mappings.relationships.yaml: list of{relationship, left, right, on}mappings (YAML 1.2 safe loading keeps unquotedon:as a string key).
CSV schemas
Spreadsheet-facing exports neutralize formula prefixes (=, +, -, @, tab, CR, LF) using a single leading quote via csv_safe_cell (excluding raw SQL columns) and strip that guard automatically on re-import.
Gold answer key (golds.csv, curate.csv, holdout.csv)
Required columns: id, question, gold_sql. Optional metadata columns (source, table) are preserved when present.
Predictions CSV (arms/*.csv)
Required columns: id, question, gold_sql, pred_sql.
Query-log demand table (log --demand)
Columns: dataset, jobs, distinct_shapes, distinct_accounts, bytes_billed_total, jobs_per_account_day, top_account_share.
Warehouse query log (log)
Columns: sql, times_seen, ran_by, distinct_users.
Mined candidates (mine)
Columns: id, question, gold_sql, times_seen, gate_status, gate_detail, table, accounts, out_of_scope.
Human review sheet (review/review.csv)
Columns in order: id, question, keep, comment, reason, wording, model_keep, model_reason, gold_sql, gate_status, gate_detail, table, times_seen, source, sql_sha256.
Per-question scoring verdicts
Every scored question in a saved report JSON carries one verdict code:
| Code | Meaning |
|---|---|
MATCH | Predicted SQL returned the same result set as gold SQL. |
MISMATCH | Both queries ran, but result rows or column counts differed. |
EMPTY_ONE | Exactly one of gold or prediction returned 0 rows while the other returned rows. |
EMPTY_BOTH | Both gold and prediction returned 0 rows (flagged because vacuous agreement proves nothing). |
PRED_ERROR | Predicted SQL failed syntax, execution, or timeout checks. |
REFUSED | Predicted SQL was blocked by the read-only rail before execution. |
GOLD_ERROR | Gold SQL itself failed to execute. |
ROW_CAP_HIT | Gold SQL exceeded --row-cap, making equality undecidable. |
PRED_ROW_CAP_EXCEEDED | Gold returned fewer rows than --row-cap, while predicted SQL overflowed the cap. |
Project configuration (contextlift.yaml)
Placed at the repository root (CLI flags always override):
db: duckdb://warehouse.duckdb
spec: spec/
golds: golds.csv
workspace: .contextlift
timeout: 60
reps: 3
policy:
min_lift: 0.0
max_regressions: 0
require_holdout: true
require_lint_clean: true
require_leak_clean: true
allowed_verdicts:
- REAL GAIN
Integrity attestation (attestation.json)
Written by round --attestation-out (and .contextlift/attestation.json under a workspace):
{
"schema_version": "1.0",
"contextlift_version": "0.3.0",
"timestamp": "2026-12-03T12:00:00Z",
"prev_attestation_sha256": null,
"arms": { "control_arm_id": "...", "treatment_arm_id": "..." },
"hashes": { "spec_sha256": "...", "golds_sha256": "...", "holdout_split_sha256": "..." },
"runner": { "runner_id": "openai:gpt-4.1", "model": "openai:gpt-4.1" },
"warehouse": { "dialect": "duckdb", "db": "duckdb://warehouse.duckdb", "db_role": null },
"metrics": { "verdict": "REAL GAIN", "safety": "SAFE", "holdout_n": 30, "lift_points": 20.0, "fixed": 6, "broke": 0 },
"policy": { "enforced": true, "passed": true, "violations": [] },
"seal_metadata": { "kind": "hmac-sha256-integrity-seal", "signer": "ci-bot", "ci_run_url": "..." },
"content_sha256": "...",
"signature": { "algorithm": "hmac-sha256", "key_id": "default", "hmac_sha256": "..." }
}
Workspace layout (.contextlift/)
Every --workspace DIR run records a manifest (schema_version: 1) and updates index.json:
.contextlift/
.gitignore # auto-created on fresh workspace
index.json # arm lineage, pins, and holdout read counts
holdout_ledger.json # 0o600 atomic scored holdout read ledger
attestation.json # latest hash-chained round attestation
verdict.html # static zero-JS report written by `bundle`
cache/golds.json # 0o600 gold execution cache (or hash-only digests)
runs/<timestamp>-<verb>/
manifest.json # argv, input SHA-256 hashes, spend, exit code
stdout.txt
outputs/ # saved reports and clean gold CSVs