Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6bff4b2
fix(review): an honest PR comment: real lint-only banner, AI lane sta…
RaghwendraSingh Nov 12, 2026
82f738a
fix(review): address review comments: credential redaction in AI-lane…
RaghwendraSingh Nov 20, 2026
868bfc9
fix(review): address review feedback: AI parse failure, explicit mode…
RaghwendraSingh Nov 20, 2026
bf972de
test(review): build the fake credential fixture at runtime
RaghwendraSingh Nov 20, 2026
7dcb5b4
fix(review): a readable PR comment: diff-anchored inline comments, no…
RaghwendraSingh Nov 12, 2026
1aa22e2
fix(review): portability advice is an explicit tag, kept when it fail…
RaghwendraSingh Nov 13, 2026
0b216f2
fix(review): address review comments: PII without a compiled base, sa…
RaghwendraSingh Nov 20, 2026
c7a166b
fix(review): grouping keeps distinct messages, base-exposed PII stays…
RaghwendraSingh Nov 23, 2026
8003a3a
fix(review): reconcile both regex PII twins with the base, keep inlin…
RaghwendraSingh Nov 23, 2026
b8022af
fix(review): reconcile PII twins by output alias and every token, kee…
RaghwendraSingh Nov 23, 2026
ff68fc9
fix(review): verdict trust: only the engine blocks, policy from the b…
RaghwendraSingh Nov 12, 2026
cce5adf
fix(review): address review comments: workflow flags cannot relax bas…
RaghwendraSingh Nov 20, 2026
0c00d07
fix(review): address review feedback: `blockingRules` spelling, origi…
RaghwendraSingh Nov 20, 2026
209bf5f
fix(review): failures are never clean: engine errors reported, per-fi…
RaghwendraSingh Nov 12, 2026
27dbe72
fix(review): a failed run never clears a block; shallow CI checkouts …
RaghwendraSingh Nov 13, 2026
c74fe41
fix(review): address review comments: engine `success:false`, per-fil…
RaghwendraSingh Nov 20, 2026
d56624d
fix(review): address review feedback: PII abstention keeps the block,…
RaghwendraSingh Nov 20, 2026
fd6608d
fix(review): address re-review: not-compiled models, PR-head dismissa…
RaghwendraSingh Nov 20, 2026
8da50d7
fix(review): dismiss stale blocking reviews after a successful partia…
RaghwendraSingh Nov 23, 2026
74efbea
feat(review): consumers outside dbt, contract vs `SELECT`, engine-awa…
RaghwendraSingh Nov 13, 2026
efbc048
fix(review): contract check opt-in and non-blocking, no division matc…
RaghwendraSingh Nov 13, 2026
0a4aa12
fix(review): address review comments: consumer lists with `--head`, n…
RaghwendraSingh Nov 20, 2026
82b58fe
fix(review): address review feedback: `TableNotFound` read from `kind…
RaghwendraSingh Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/reference/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ We collect the following categories of events:
| `activation_job_selected` / `first_job_completed` | Which activation job the user started and, where observable, finished. In onboarding, completion is reported only for the job that was actually selected, so the two form a coherent pair. `first_job_completed` is also sent once per workspace for each machine and Altimate instance, for the first turn in a linked project, or in a session pinned to a workspace by the IDE extension, that had a tool call that didn't fail and ended `completed`. `origin` says which: `onboarding` or `workspace`. **Derived** — see the note below. |
| `first_prompt_sent` | The user's first typed message in an onboarding session, and the first typed message in a linked project or a session pinned to a workspace, once per workspace for each machine and Altimate instance. A slash command sent as a command, as the TUI and `run` send it, is excluded, so the hidden `/onboard-connect` submission does not count. The VS Code chat sends a command as its expanded text, so there a command counts. A subagent's prompt never counts. `origin` says which rule sent it: `onboarding` for an onboarding session's first typed prompt, bound or not, and `workspace` for the workspace's row. So a later prompt in an onboarding session, after its project was linked, is a `workspace` row. |
| `onboarding_abandoned` | The CLI exited during a first run without connecting. `last_stage` is the furthest point reached: `started`, `model_picker`, `provider_setup`, `altimate_base_confirm`, or `gateway_auth`. (`connected` is a funnel position but never a `last_stage` — reaching it means the run completed, which is not an abandonment.) Only emitted for a genuine first run — opening `/connect` as an existing user does not enter the funnel, and abandonment after setup completes is out of scope by definition. Emitted on the exit path under a bounded flush, so the measured rate is a lower bound — see [Delivery & Reliability](#delivery--reliability). |
| `review_run` | A dbt/SQL review completed or failed — `invocation` (`cli` for `altimate-code review`, `tool` for the `dbt_pr_review` tool), status, duration, and on success the verdict, the pre-gating verdict, mode, risk tier, and finding counts by severity and by category. No file paths, model or column names, finding titles or bodies, SQL, diff content, or repository/branch/PR names. |
| `review_run` | A dbt/SQL review completed or failed — `invocation` (`cli` for `altimate-code review`, `tool` for the `dbt_pr_review` tool), status, duration, and on success the verdict, the pre-gating verdict, mode, risk tier, finding counts by severity and by category, `degraded` (lint-only: no reviewable files, or no changed model resolved against a manifest; an undecidable finding alone no longer sets it), `undecided` (findings the engine could not decide), `unverified_models` (models without compiled SQL), `ai_state` and `ai_duration_ms` (the advisory AI lane's outcome), `base_source` (where the review base came from, e.g. `flag` or `default_branch`) and `out_of_scope_files` (changed files outside the dbt project). No file paths, model or column names, finding titles or bodies, SQL, diff content, or repository/branch/PR names. |
| `review_post_outcome` | Whether a review was published to GitHub — `not_requested`, `not_attempted`, `target_unresolved`, `full`, `partial`, or `summary_failed`, plus duration. Emitted on the **CLI path only** — the `dbt_pr_review` tool completes reviews but never publishes, so a `review_run` with `invocation: tool` has no post event and that is not a failure. Within the CLI path there is exactly one per **completed** review: a review that failed emits `review_run: failed` and no post event, so absence there means the review failed rather than that an event was lost. `not_attempted` is publication requested but never reached (a bad `--output` path, a stdout write error). No repository, PR, or comment content. |
| `rule_proposal_shown` | A proposed rule was raised: shown as a card, or stored for `learn proposals` when no attached client shows cards (`stored`), or raised again for the same wording (`repeat`) — what raised it (`remember`, `shown_rule`, `recurrence`), the kind of change, whether it is a "Save as" choice, linked/owner, the buttons offered, whether it weakens verification, evidence session count, whether it came from a correction, how many paths it applies to, and its length. The card id is random. No rule text, quotes, paths or globs. |
| `rule_proposal_answered` | A card was answered or closed (`send`, `approve`, `approve_anyway`, `edit`, `dismiss`, `save_local`, `save_memory`, `expired`, `closed`) — `ok` or why it did not go through (`busy`, `not_available`, `verification_flagged`, `invalid_text`, `refused` by the workspace, `failed`), what happened (`sent`, `queued`, `approved`, `approve_failed`, `approve_retry`, `target_changed`, `exists`, `dismissed`, `saved_memory_project`, `saved_memory_global`, `saved_local`, or `saved_unanswered` when a card the person asked for closed unanswered and was saved as before cards), wording edits so far, and time since the card was shown. No rule text. |
Expand Down
145 changes: 142 additions & 3 deletions docs/docs/usage/dbt-pr-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Options:

| Flag | Description |
|------|-------------|
| `--base <ref>` | Base git ref. Defaults to the pull request's target branch in CI (GitHub `pull_request.base.ref` or `GITHUB_BASE_REF`, GitLab `CI_MERGE_REQUEST_TARGET_BRANCH_NAME`), else the remote default branch. Always reduced to the merge-base with the head, so commits the base gained after the PR branched are never reviewed. In CI, a target branch that is not fetched is an error (use `fetch-depth: 0`). |
| `--base <ref>` | Base git ref. Defaults to the pull request's target branch in CI (GitHub `pull_request.base.ref` or `GITHUB_BASE_REF`, GitLab `CI_MERGE_REQUEST_TARGET_BRANCH_NAME`), else the remote default branch. Always reduced to the merge-base with the head, so commits the base gained after the PR branched are never reviewed. In CI, a shallow checkout is handled: the target branch is fetched and the history deepened until the merge-base is found. If that fails (no `origin`, no access), the review stops with an error rather than diffing against another branch. |
| `--head <ref>` | Head git ref. Omit to review the working tree. |
| `--manifest <path>` | Path to the compiled `manifest.json`. When omitted, the reviewer walks up from the current directory to find the nearest `dbt_project.yml` and uses its adjacent `target/manifest.json`; the discovered path is logged to stderr. |
| `--mode comment\|gate` | `comment` never blocks; `gate` exits non-zero on `REQUEST_CHANGES`. |
Expand Down Expand Up @@ -199,6 +199,38 @@ jobs:
# model_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
```

### What the review needs (and what each input unlocks)

| Input | How to produce it | Unlocks |
|---|---|---|
| The PR's target branch and the merge-base | Fetched automatically from `origin` when the checkout is shallow; `fetch-depth: 0` avoids the extra fetches | Correct base: the diff starts at the merge-base with the PR's target branch. When it can't be fetched, the review stops with an error, never a silent fallback to `main`. |
| `target/manifest.json` | `dbt compile` (or `dbt parse` for lint + lineage only) | Blast radius, lineage breakage, tiering. Without it the run is lint-only. |
| `target/compiled/…` | `dbt compile` | Engine checks on the head (lint, grade, PII, grain). |
| `target-base/compiled/…` | Compile the base ref into `target-base/` (below) | Equivalence proofs and column-breakage for modified models. |
| `target/catalog.json` | `dbt docs generate` | Complete warehouse columns for column-lineage breakage. |

Compiling the base (optional, for equivalence and column-breakage):

```yaml
- name: Compile the base into target-base/
run: |
# The review diffs against the merge-base, not the target branch tip.
git worktree add ../base "$(git merge-base "origin/${{ github.base_ref }}" HEAD)"
(cd ../base && dbt deps && dbt compile --target-path "$GITHUB_WORKSPACE/target-base")
```

With `project_dir`, compile from that folder and write next to its own
`target/`: `(cd ../base/<project_dir> && dbt deps && dbt compile --target-path "$GITHUB_WORKSPACE/<project_dir>/target-base")`.

**Monorepos:** set `project_dir` to the folder holding `dbt_project.yml`. Only
changes inside it are reviewed, `manifest_path` is resolved relative to it, and
changes elsewhere are counted in the comment.

**What the comment tells you it could not check:** findings the engine could not
decide, models without compiled SQL, files outside the project, and whether the
advisory AI lane ran, was skipped, timed out or failed (with the reason). The
same facts are in the envelope (`scope`, `ai`) and the `review_run` telemetry.

### Model & credentials for the advisory lane

The deterministic engine (lineage, equivalence, PII, grade, lint — the only layer
Expand Down Expand Up @@ -232,6 +264,9 @@ mode: comment # comment | gate
severityThreshold: suggestion
manifestPath: target/manifest.json
dialect: snowflake
# portability: true # cross-engine advice. Unset: off once the engine is known
# (configured or detected). An explicit value applies even when
# the engine is unknown. Set true for multi-adapter packages.
reviewers: [] # empty = risk-tier defaults; or pin lanes
dataDiff: # OFF by default — see "Data-diff in CI" below
enabled: false
Expand All @@ -241,16 +276,110 @@ exclude:
riskTierPathTokens: # OFF by default — see "Risk-tier path tokens" below
finops: [preset:finops] # promote any FinOps-named path to `full` tier
pii: [ssn, email, phone] # or supply your own case-insensitive tokens
allowForceTier: true # set false in gate CI: --force-tier is then rejected
checkContractColumns: false # opt-in: new columns missing from an enforced contract (CI that doesn't run `dbt build`)
consumerColumnLists: [] # OFF by default — see "Consumers outside dbt" below
rubric:
blockOn: [lineage_breakage, contract_violation, pii_exposure, semantic_change]
warningPatternThreshold: 3
blockingRules: [] # catalog rule ids allowed to block (default: engine only)
thresholds:
warehouseCostMinRows: 1000000
exclusions:
allowSelectStarInStaging: true
skipNonProdModels: true
```

### Which policy applies, and what can block

- **The base branch's `.altimate/review.yml` applies.** The file is read from the
commit the PR branched from, so a PR cannot relax the rules it is reviewed
under (switch to `comment` mode, drop a `blockOn` category, exclude its own
paths). If the PR edits the file, the comment lists the changed settings; they
take effect after merge. The applied policy's hash is signed into the envelope
(`policy`). The action's `mode` and `severity_threshold` inputs (`--mode`,
`--severity`) can only tighten a base policy: they cannot turn `mode: gate`
into `comment` or raise its severity threshold. Other workflow steps are still
PR-editable, so protect `.github/` with CODEOWNERS or branch rules.
- **Only the deterministic engine blocks.** Findings carry an `origin`:
`engine` (AST, lineage, manifest, equivalence, data-diff), `catalog` (pattern
rules) or `ai`. Only `engine` findings count toward REQUEST_CHANGES. A pattern
rule you trust can be allowed to block by naming its id in
`rubric.blockingRules`. The advisory AI lane never blocks.
- **Upgrading a `gate` setup.** Before this policy, any critical finding in a
`blockOn` category could block, including pattern rules such as the regex
PII check. Now pattern-rule findings comment but don't block. To keep a
pattern rule blocking, add its id to `rubric.blockingRules`. A blocking
review is dismissed only by a later run that completed: when an engine call
or a file failed, a check (such as PII) could not analyse a model, or a
changed model had no compiled SQL, the earlier block stays.

### Consumers outside dbt

A column removed or renamed can break readers the dbt DAG doesn't show. With a
manifest, the review reports:

- **Exposures and contracts.** Removing a column from a model that has
`exposures` (dashboards, apps, ML) or an enforced contract names those
consumers and suggests a deprecation period or a new model version.
Downstream dbt models that select the column are reported separately, with
the models named.
- **Contract vs `SELECT` (opt-in).** A new column missing from an enforced
contract fails `dbt build`, so this is off by default. Turn it on with
`checkContractColumns: true` when CI runs only `dbt parse` or `dbt compile`.
A column the PR declares in a changed yml counts as declared even when the
manifest predates the PR. It comments; it never blocks.
- **Explicit column lists (opt-in).** Some projects copy a model's columns
into code outside dbt: an export or reverse-ETL script, a feature list, an
API schema. Name those files and the list's pattern, and when a PR adds or
removes a model's columns, each matching list must follow.

```yaml
consumerColumnLists:
- files: "exports/**/*.py" # repo-relative glob
pattern: "COLUMNS\\s*=\\s*\\[([^\\]]*)\\]" # first capture group = the list
model: fct_orders # omit: files that mention the model
```

### What the PR comment shows

- **One summary comment**, updated in place on every push, capped at about
5,000 characters. Critical findings come first; anything that does not fit is
counted, and the full list is always in the verdict envelope
(`altimate review --json`). Local CLI output is never truncated.
- **Repeated findings are grouped:** the same rule with the same message on
three or more models is one bullet listing the models. Local CLI output lists
every finding with its location.
- **Inline comments only on lines of the PR's diff.** Findings computed on
compiled SQL, or on unchanged lines, stay in the summary.
- **No re-posting on reruns:** each inline comment carries the finding's
fingerprint, so a push does not repeat findings already on the PR, and a
non-blocking rerun with nothing new and the same headline as the bot's last
review only updates the summary.
- **PII:** flagged only for PII columns the change newly exposes, not for
columns the base already surfaced. That comparison needs the base version's
SQL; when it can't be compiled, PII columns are reported as non-blocking
warnings that may predate the PR. A model the PII check could not analyse is
listed as not fully verified.
- **Failures are never a clean pass:** if an engine check fails, a file's
review fails, a check could not analyse a model, or a changed model has no
compiled head SQL (its engine and PII checks were skipped), the comment names
it and an otherwise clean verdict becomes COMMENT, never APPROVE (envelope
`engineErrors` and `scope.unverified`); a real blocking finding still
blocks. A project reviewed without `dbt compile` (parse-only) therefore never
gets APPROVE for a changed Jinja model. A failure on one file marks that file
unverified and the rest of the PR is still reviewed. SQL the engine cannot
parse in your dialect is not an engine failure: the affected checks abstain
on that model (a PII abstention still marks it not fully verified).
- **The gate clears itself:** when a completed rerun on the PR's current head
no longer blocks, the earlier blocking altimate review for the same dbt
project is dismissed after the new review is posted (needs
`pull-requests: write`). "Current head" means the reviewed commit is the PR
head, or the merge commit a `pull_request` checkout builds from it
(`refs/pull/N/merge`). When either the reviewed commit or the PR head cannot
be determined, the block stays. Only reviews authored by a bot (or by the
token's own user) are dismissed.

### Risk-tier path tokens

Named categories under `riskTierPathTokens` promote any diff touching a matching
Expand Down Expand Up @@ -356,8 +485,9 @@ reviewer does **not** re-implement Jinja — it consumes dbt's own compiled outp
from `target/compiled/<project>/…` (HEAD) and `target-base/compiled/…` (BASE),
produced by `dbt compile`. To enable full equivalence verdicts, compile both
the base and head refs in CI (the base into `target-base/`, the Recce
convention). Without compiled SQL the engine lanes fall back to raw and stay
*undecidable* (never fabricated) — the `dbt-patterns` lane still runs.
convention). A model without compiled SQL is never sent to the engine as raw
Jinja: it is listed as **not verified** (with the reason) in the comment and in
the envelope's `scope.unverified`, and the `dbt-patterns` lane still runs.

## What it checks — deterministic rule catalog

Expand All @@ -372,6 +502,15 @@ The deterministic rules group into four families:
cartesian (`JOIN` without a condition), `NOT IN (… NULL)`, sum-of-a-ratio,
non-portable dialect functions, integer-multiplication overflow, PK-aware
join fan-out, timezone-in-hash-key.
- **Engine-dependent rules read an adapter table.** Where behavior differs by
engine, a rule checks the project's adapter (from the manifest or `dialect`)
instead of assuming one. Example: `int / int` (and `count(…) / count(…)`)
truncates on Postgres, Redshift, Trino/Athena and SQL Server, so it is a
correctness finding there. On Snowflake, BigQuery, Databricks and DuckDB it is
only portability advice, shown for packages (`portability: true`).
- **dbt unit tests.** A unit test whose `given` inputs are all `rows: []` is
reported: it either never tests the model's logic, or expects rows the model has nothing to

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This says every empty-input unit test is reported, but the rule only checks newly added or changed tests with inline dict fixtures; unchanged and CSV/SQL-fixture tests are skipped. Document that scope to avoid promising findings the reviewer will not emit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/docs/usage/dbt-pr-review.md, line 487:

<comment>This says every empty-input unit test is reported, but the rule only checks newly added or changed tests with inline `dict` fixtures; unchanged and CSV/SQL-fixture tests are skipped. Document that scope to avoid promising findings the reviewer will not emit.</comment>

<file context>
@@ -448,6 +477,15 @@ The deterministic rules group into four families:
+  correctness finding there. On Snowflake, BigQuery, Databricks and DuckDB it is
+  only portability advice, shown for packages (`portability: true`).
+- **dbt unit tests.** A unit test whose `given` inputs are all `rows: []` is
+  reported: it either never tests the model's logic, or expects rows the model has nothing to
+  build from.
 - **dbt config / Jinja (`DBT0xx`).** A core **minijinja** parser reads
</file context>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: nit, tracked. The docs will narrow the unit-test scope.

build from.
- **dbt config / Jinja (`DBT0xx`).** A core **minijinja** parser reads
`{{ config(...) }}` and the model body: incremental model without an
`is_incremental()` guard, `merge`/`delete+insert` without a `unique_key`,
Expand Down
8 changes: 7 additions & 1 deletion github/review/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ inputs:
description: "comment (never blocks) | gate (blocks the merge on REQUEST_CHANGES)"
required: false
default: "comment"
project_dir:
description: "Directory of the dbt project (the one holding dbt_project.yml), relative to the repository root. Only changes inside it are reviewed — set it in a monorepo. `manifest_path` is resolved relative to it."
required: false
default: "."
manifest_path:
description: "Path to the compiled dbt manifest.json. Run `dbt compile` before this step for the full (non-degraded) verdict."
description: "Path to the compiled dbt manifest.json, relative to `project_dir`. Run `dbt compile` before this step for the full (non-degraded) verdict; `dbt docs generate` (catalog.json) and a base compile into `target-base/` enable column-lineage breakage and equivalence proofs."
required: false
default: "target/manifest.json"
severity_threshold:
Expand Down Expand Up @@ -170,6 +174,7 @@ runs:
# from `${{ }}` would be a shell-injection vector. Build an arg array instead.
env:
IN_MODE: ${{ inputs.mode }}
IN_PROJECT_DIR: ${{ inputs.project_dir }}
IN_MANIFEST: ${{ inputs.manifest_path }}
IN_SEVERITY: ${{ inputs.severity_threshold }}
IN_BASE: ${{ inputs.base }}
Expand All @@ -181,6 +186,7 @@ runs:
ALTIMATE_REVIEW_SIGNING_KEY: ${{ inputs.signing_key }}
run: |
args=(--mode "$IN_MODE" --manifest "$IN_MANIFEST" --severity "$IN_SEVERITY")
[[ -n "$IN_PROJECT_DIR" && "$IN_PROJECT_DIR" != "." ]] && args+=(--cwd "$IN_PROJECT_DIR")
[[ -n "$IN_BASE" ]] && args+=(--base "$IN_BASE")
[[ -n "$IN_HEAD" ]] && args+=(--head "$IN_HEAD")
[[ "$IN_POST" == "true" ]] && args+=(--post)
Expand Down
Loading
Loading