contextlift

CLI reference

Global options accepted before or after any command:

Core verbs (contextlift --help)

Eight verbs complete one end-to-end measurement:

VerbWhat it does
demoRun an offline 30-second end-to-end measurement on SQLite with canned predictions and zero API keys.
doctorCheck installed extras (postgres, snowflake, databricks, bigquery, duckdb, yaml, lookml), credentials, and explain refusals (--explain).
gateAudit a gold answer key against 16 defect classes and 4 warnings; save golds_clean.csv (--clean-out).
splitCreate a deterministic hash-based curate.csv / holdout.csv split and ID lists.
lintRefuse written context defects, live enum mismatches (--db, --db-role), and cross-layer conflicts (--dbt, --snowflake-semantic, --ossie, --lookml) at $0.
roundRun a paired control-vs-treatment evaluation with pre-flight power/leak/lint gates, sealed holdout tracking, merge policy enforcement, and signed attestation.json.
bundleBuild a self-contained, zero-JavaScript verdict.html report for the pinned comparison.
nextInspect --workspace and print the single next command to run with resolved paths.

Everyday workflow verbs

Diagnose and improve context

VerbPurpose
classesPrice and measure each context class (rules, schema, terms, examples) separately.
attributeRank which context rules or terms explain fixed and broken questions via SQL AST comparison.
historyTrack one question across every round to see when it broke or recovered.
bisectBinary-search a rule set to confirm which exact rule caused a regression.
triageGroup failing questions by error shape (ROW_COUNT, COLUMN_COUNT, EMPTY_RESULT, REFUSED, DID_NOT_RUN, TIMEOUT, WRONG_VALUES, UNCLASSIFIED).
worklistPrioritize which failing context item to edit first.
climbTrack accuracy across rounds against the same baseline, guarded by a noise floor.
suggestPropose lint- and leak-screened rule patches strictly from working-set (curate) failures.

Build and curate gold sets

VerbPurpose
initDetect local SQLite/DuckDB/dbt assets, introspect starter spec/schema/*.json, and write contextlift.yaml.
reviewPrepare a review sheet, run optional cross-family --draft triage, render offline Steward HTML (--html), import SQL-hash-verified decisions.json, and compile golds.csv.
ingest-failuresConvert production agent failure JSONL into a PII-redacted review.csv (merges without clobbering existing rows unless --force).
draft-rulesDraft business rules from one triage failure bucket, citing its curate questions.
rewrite-questionsRedraft natural-language question wording for existing golds without touching the warehouse.
audit-goldsInspect question clarity and answer-key alignment on an existing gold CSV.
curate-examplesBuild a leak- and template-twin-checked worked-example bank (--pool disjoint from --targets).
build-examplesBuild a spec/examples/bank.jsonl worked-example bank strictly from the working half of a gold set.
context-writeInstall a human-reviewed draft into context/rules.md with version history.
estate-shapeReport table concentration, question redundancy, and split shared-ground stats (free).
doc-coverageCount what fraction of candidate or gold queries read documented datasets (free).
resolvable-liftCompute exact McNemar resolvable lift floors and sample-size requirements (free).

Ask, score, compile, serve, and govern

VerbPurpose
generateGenerate SQL predictions for one arm (--reps 3, optional --retry --db, --context-per-question).
scoreGrade a predictions CSV against gold SQL and save a reusable JSON report (--save-report).
ablatePaired comparison of two scored arms (--without-report / --with-report), printing lift, Tango CI, McNemar p, and verdict.
armsInspect the compiled Arm 0d and Arm 1 hashes and payload sizes for a spec/.
leakVerify that held-out questions and gold SQL do not appear inside a context file or bundle.
importRegister externally produced predictions as a tracked arm in --workspace.
semanticConvert LookML, dbt, or Ossie models into starter rules and candidate questions.
compileCompile a spec/ into snowflake-yaml, dbt-yaml, or ossie with honest certification headers (--sign-key, --require-signature).
serve-mcpServe a certified Arm and attestation status over zero-dependency JSON-RPC 2.0 stdio MCP (--require-signature, --require-certified).
schemaExport CREATE TABLE DDL text for prompt runners.
profileBuild a value dictionary of distinct categorical column values.
indexRebuild index.json from recorded run folders under --workspace.
pinOverride the default baseline or candidate arm in --workspace (`pin baselinecandidate ID`).
shareExport allowlisted, leak-scanned summary counts and metrics (no customer SQL or text).
scanScan staged diffs, history (--all), commit ranges (--since), or tracked files (--tree) for secrets using built-in + custom patterns.
pr-summaryRender one Markdown or JSON pull-request comment from saved round/ablate, lint, attribute, cost, and safety outputs.
verify-attestationVerify content hash, HMAC-SHA256 signature (--require-signature), and hash chain (--prev) on attestation.json.
export-otelExport an attestation.json, round.json, or ablate.json into OpenTelemetry OTLP JSON.

Troubleshooting and refusal decoder

contextlift fails closed by design. Common refusals and their fixes:

Symptom or exit messageCause and fix
untrusted command in contextlift.yamlrunner.command or clarifier_cmd came from a config file. Inspect the YAML first, then pass --trust-config (or pass --command on the CLI).
INVALID on resolvable_liftHoldout split is too small for --target-lift (6 unanimous flips is the floor for p < 0.05). Add questions or set --target-lift 50 for a pilot run.
refused: ... --db-role is not supportedBigQuery and Databricks drivers cannot enforce SQL session role switching. Use a scoped IAM principal or PAT/SP instead of --db-role.
attestation is unsigned / certified: falseCertification requires a verified HMAC-SHA256 signature (CONTEXTLIFT_SIGN_KEY / --sign-key), unmodified spec/, REAL GAIN, and passing policy:.
sql_sha256 mismatch on --import-decisionsA candidate row's gold_sql changed after the steward approved it. Re-generate steward_review.html and obtain fresh sign-off.
refusing private/metadata --base-urlSSRF guard blocked a metadata, link-local, RFC1918, or 3xx-redirecting host. Pass --allow-private-endpoint only for trusted internal VPC proxies.
policy: exit code 2 before round startsUnknown key or non-numeric threshold in contextlift.yaml policy:. Fix the YAML key name or type; run contextlift doctor --explain for live cloud refusals.
Appendix: BigQuery query mining, Knowledge Catalog, and routing verbs (15 verbs)
VerbPurpose
logPull BigQuery INFORMATION_SCHEMA.JOBS_BY_PROJECT demand tables (--demand) or filtered query logs.
mineMine candidate gold questions round-robin across tables from query logs.
draft-contextDraft starter per-table Markdown docs from warehouse metadata (no LLM, no row reads).
mine-contextExtract candidate column descriptions and rules from query history.
catalog-pushPush reviewed docs, rules, and examples into Google Cloud Knowledge Catalog with read-back verification (--dry-run first).
catalog-pullPull served table documentation from Knowledge Catalog into local files.
catalog-listList tables in a Knowledge Catalog entry group (dataset.table per line).
catalog-routeRoute questions through Knowledge Catalog search and write per-question context JSON.
catalog-rollbackRestore previous catalog descriptions captured by spec-push --previous-out.
spec-pushPush a structured spec/ directory into Knowledge Catalog (--dry-run plans and checks drift).
eval-roomGenerate DDL for an undocumented BigQuery evaluation view room so Arm 0d is truly bare.
sentinelPlant a synthetic fact in a catalog and test whether the agent reads it.
spec-schemaGenerate spec/schema/*.yaml files from BigQuery INFORMATION_SCHEMA.
routing-gateAudit a routing answer key for concentration, missing catalog tables, or duplicate IDs.
score-routingGrade table-routing predictions against gold tables (with optional --catalog snap).