CI setup and governance
Run contextlift automatically on pull requests to catch broken rules at $0, prove accuracy lift on real SQL before merging, post one idempotent PR comment, and seal every verdict with an HMAC-SHA256 integrity attestation.
GitHub Action (lint + gate + PR summary)
Drop this workflow into .github/workflows/context.yml. On every pull request touching your context files, it lints cross-layer definitions, posts or updates one summary comment, and fails the check on hard refusals or merge-policy violations:
name: Context CI
on:
pull_request:
paths:
- "spec/**"
- "dbt/**"
- "golds.csv"
permissions:
contents: read
pull-requests: write
jobs:
context-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: moutasemalakkad/context-lift@v0.3.0
with:
spec-dir: spec/
dbt-dir: dbt/
db-path: warehouse.duckdb
db-role: contextlift_ro
golds-csv: golds.csv
fail-on-refusal: "true"
Reusable workflow for full PR gates
This repository also ships a reusable workflow at .github/workflows/contextlift-pr-gate.yml that you can call with workflow_call across multiple domain repos:
jobs:
gate:
uses: moutasemalakkad/context-lift/.github/workflows/contextlift-pr-gate.yml@v0.3.0
with:
spec-dir: spec/
dbt-dir: dbt/
domain: finance
secrets: inherit
Key action.yml inputs
| Input | Purpose |
|---|---|
spec-dir, domain | Path to spec/ and optional domain scope (spec/domains/<name>). |
dbt-dir, snowflake-semantic, ossie-dir, lookml-dir | Semantic layer sources compared by the Cross-Layer Conflict Radar. |
db-path, db-role | Warehouse path/URI and read-only role for live enum checks, gate, and round. |
golds-csv | Gold set CSV for lint --golds, gate, and offline round. |
predictions-control, predictions-treatment | Offline baseline and candidate CSVs to run round inside CI at $0. |
attestation-out, otel-out | Paths for attestation.json and OpenTelemetry OTLP JSON export. |
post-comment, fail-on-refusal | Toggle idempotent PR commenting (<!-- contextlift-pr-summary -->) and exit-code gating. |
Pre-commit hooks (local developer loop)
Catch broken enum literals, conflicting definitions, and customer secrets before git commit. Add to .pre-commit-config.yaml:
repos:
- repo: https://github.com/moutasemalakkad/context-lift
rev: v0.3.0
hooks:
- id: contextlift-lint
args: ["--spec", "spec/", "--dbt", "dbt/"]
- id: contextlift-scan
Three hook IDs are published in .pre-commit-hooks.yaml:
contextlift-lint: free offline static lint and Cross-Layer Conflict Radar.contextlift-gate: validatesgolds.csvagainst a local database.contextlift-scan: scans staged files against customer secret patterns.
Declarative merge policy in contextlift.yaml
Add a policy: block to contextlift.yaml. Every contextlift round evaluates the policy automatically, writes the result into attestation.json, and exits non-zero when any rule is violated:
db: duckdb://warehouse.duckdb
spec: spec/
golds: golds.csv
workspace: .contextlift
timeout: 60
reps: 3
policy:
min_lift: 2.0
max_regressions: 0
require_holdout: true
require_lint_clean: true
require_leak_clean: true
allowed_verdicts:
- REAL GAIN
Generating PR comments manually
Combine saved JSON outputs from round (or ablate), lint, attribute, and gate into one Markdown or JSON summary:
contextlift lint --spec spec/ --dbt dbt/ --json > lint.json
contextlift pr-summary --report round.json --lint lint.json --format markdown --out pr_summary.md
pr-summary also accepts --tolerate-report FILE (strict vs projection-tolerant comparison), --attribution FILE (AST rule blame), --cost FILE, and --safety FILE.
Signed integrity attestations and hash chains
Every round --attestation-out (or workspace round) writes a deterministic attestation.json binding content_sha256, prev_attestation_sha256, arms.treatment_arm_id, hashes.spec_sha256, metrics, policy, and (in GitHub Actions) seal_metadata (signer and ci_run_url).
Sign with a symmetric CI secret (CONTEXTLIFT_SIGN_KEY or --sign-key) and verify before deployment:
export CONTEXTLIFT_SIGN_KEY="$CI_ATTESTATION_HMAC_KEY"
contextlift round --out round.json --attestation-out .contextlift/attestation.json
contextlift verify-attestation .contextlift/attestation.json \
--require-signature \
--prev previous_attestation.json
attestation.json is an HMAC-SHA256 integrity seal (tamper detection and audit chaining), not asymmetric PKI. See Security for the exact trust boundary.
OpenTelemetry export (export-otel)
Export any attestation.json or round.json into zero-SDK OpenTelemetry OTLP JSON for Datadog, Braintrust, MLflow, or Langfuse:
contextlift export-otel \
--input .contextlift/attestation.json \
--out otel_metrics.json \
--service-name finance-context-ci