Skip to main content Switch to mobile version contextlift 0.3.1 GitHub-native Context CI for AI SQL agents, dbt semantic layers, and enterprise warehouses: lint cross-layer conflicts, prove SQL lift on sealed holdouts, and serve certified context over MCP.
pip install contextlift==0.3.1 Copy PIP instructions
CI for the context your SQL agent reads.
Rules, dbt metrics, semantic views, LookML: every change gets a verdict before it merges.
Quickstart · Docs & live verdict · How it decides · Install
Some context helps. Some does nothing. Some makes your agent worse. Each row is a paired run: same model, same questions, one context change. Every number is pinned by a test to a committed run.
uvx contextlift demo # no key, no cloud: canned answers, real SQL, the real paired test 1 Lint what you already have
2 minutes $0 no questions needed
$ contextlift lint --spec spec/ --dbt dbt/ --db warehouse.duckdb [REFUSE] invalid enum literal: 00-finance:1 [REFUSE] cross-layer metric conflict: Active ARR (dbt vs spec) 2 refusal(s). Fix these before paying for a round: each one was measured to cost more than it takes to fix. Your rule says 'ACTIVE', the warehouse holds 'active', and dbt counts trials as Active ARR while your spec does not. No model was called. lint reads Markdown rules, dbt, Snowflake Semantic Views, Apache Ossie and LookML. Run it as the contextlift-lint pre-commit hook, or on every pull request:
# .github/workflows/context.yml on: pull_request permissions: { contents: read, pull-requests: write } jobs: context: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: moutasemalakkad/context-lift@v0.3.1 # lints, comments on the PR, fails on a refusal with: { spec-dir: spec/, dbt-dir: dbt/ } 2 Prove a change on real SQL
10 minutes your warehouse any agent
Write down what the agent should know, and what a right answer looks like:
# spec/rules/00-finance.md - "Active ARR" -> SUM(subscriptions.mrr_usd) * 12 WHERE subscriptions.status = 'active' # golds.csv: a few dozen questions your users really ask, with the SQL that answers each id,question,gold_sql q1,What is active ARR?,SELECT SUM(mrr_usd) * 12 FROM subscriptions WHERE status = 'active' q2,How many trials are running?,SELECT COUNT(*) FROM subscriptions WHERE status = 'trial' Then run the same questions twice, once without the context and once with it:
export OPENAI_API_KEY="your-key" # or score two CSVs offline ($0) export CONTEXTLIFT_SIGN_KEY="$(openssl rand -hex 32)" # signs .contextlift/attestation.json contextlift init --db warehouse.duckdb # writes contextlift.yaml + schema/ contextlift round --runner openai:gpt-4.1 --target-lift 50 --budget 5 \ --out round.json --attestation-out .contextlift/attestation.json # two arms, one verdict contextlift bundle # .contextlift/verdict.html contextlift pr-summary --report round.json # the comment below Swap in anthropic:MODEL, gemini, any OpenAI-compatible server (--base-url: Ollama, vLLM) or your own agent (--runner command), or score two CSVs of answers you already have. Every query runs read-only and row-capped (with --db-role scoping on Postgres and Snowflake). A question set too small to decide is refused before the first paid call (~30 questions with --target-lift 50; default +6.9 needs ~60 reserved).
3 Serve what you proved
contextlift serve-mcp --spec spec/ --attestation .contextlift/attestation.json --require-signature A local stdio MCP server for Claude Code, Cursor or any MCP client: six tools over your spec, from get_metric to get_attestation_status, which verifies the round's sealed HMAC integrity and spec hash binding. Or compile the spec into the layer you already run:
contextlift compile --spec spec/ --target snowflake-yaml --attestation .contextlift/attestation.json # or dbt-yaml, ossie Three results that changed what we build, and every number behind the chart Sending everything beat perfect retrieval. Giving each question only its own sentence instead of all 22 KB scored -2.2 points across 450 questions (NOT PROVEN) and -8.6 points [-17.0, -0.8] on Toxicology: 7 fixed, 19 broke, p = 0.0290, REAL LOSS. Run
A BI model with no descriptions is not context. LookML read straight into rules: +2.0 points over 102 questions, p = 0.6875, NOT PROVEN. Looker's public project also says orders.id where the warehouse has orders.order_id. Run
Models almost never ask for more. Told to answer INSUFFICIENT rather than guess: 2 of 139 questions escalated, 1.4%. The run had no positive control, so it cannot tell a model that will not escalate from a prompt it ignores. Run
The headline row, recomputed offline from committed predictions with make example-bird (no key, no network):
paired ablation on 39 questions (execution accuracy) without context : 30.8% [18.6%, 46.4%] with context : 53.8% [38.6%, 68.4%] lift : +23.1% [+1.2%, +43.6%] (the two rates subtracted; 95% interval on the paired difference) context fixed : 12 questions context broke : 3 questions McNemar p : 0.0352 significant at 0.05 one repetition per arm: a single sample, not a measurement; run each arm again before quoting this ruling : REAL GAIN Every published result:
On BEAVER the worked examples came after hand-written rules scored -0.7 on the working set. Intervals are paired score intervals. results.json names the committed file and the test behind every row.
WITHDRAWN: an earlier worked-examples penalty on thelook was one schema, one model, one run, and a scoring bug: _cmd_classes graded 22 stored-answer hits as errors. Raw run in docs/evidence/classes-thelook-cost.txt, postmortem in docs/how-it-works.md#results.
pip install contextlift # zero dependencies: SQLite, lint, the stats, the verdict pip install "contextlift[duckdb,yaml]" # or [postgres] [snowflake] [databricks] [bigquery] [lookml] Warehouses DuckDB, SQLite, BigQuery. Postgres, Snowflake and Databricks in beta. Context Markdown rules, dbt schema.yml and manifest.json, Snowflake Semantic Views, Apache Ossie, LookML. Agents OpenAI, Anthropic, Gemini, Ollama or vLLM, your own CLI agent, or answers in a CSV.
Eight verbs complete one measurement: demo doctor gate split lint round bundle next. contextlift --help lists those eight. contextlift --help-all lists the rest, grouped.
Quickstart · How it works · CI setup · Warehouses & agents · CLI reference · Security · Contributing
src/context_lift/ is the package: 8 core verbs, every number on this page pinned by tests/ to a run in docs/evidence/ or examples/. make test runs green from a fresh clone, no credentials. Apache-2.0.
Released: Dec 4, 2026
Author/Maintainer: Moutasem Akkad
Both files in this release have provenance metadata.
View provenance details
Apache Software License (Apache-2.0)
bigquery ca catalog databricks dev duckdb gemini lookml postgres snowflake yaml
bigquery context-engineering data-engineering dbt duckdb mcp semantic-layer snowflake sql-evaluation text-to-sql
Development Status 4 - Beta
Intended Audience Developers
License OSI Approved :: Apache Software License
Operating System OS Independent
Programming Language Python :: 3
Scientific/Engineering :: Artificial Intelligence
Software Development :: Testing
Release files for contextlift 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 2.4 MB
Release files / contextlift-0.3.1.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Release files / contextlift-0.3.1-py3-none-any.whl
Security for contextlift 0.3.1
Both files in this release have been uploaded with provenance metadata.
With provenance contextlift-0.3.1.tar.gz Dec 4, 2026
With provenance contextlift-0.3.1-py3-none-any.whl Dec 4, 2026
Attestation for contextlift-0.3.1.tar.gz
Attestation for contextlift-0.3.1-py3-none-any.whl
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 4, 2026 2 release files Full provenance
Dec 3, 2026 2 release files Full provenance
Nov 13, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 4d99e05











