Repository navigation
fix(review): failures are never clean: engine errors reported, per-file isolation, PII abstention, gate dismissal #1723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7ee8950
16b2789
7fad924
963264c
d3c0139
e1604be
7c18c60
a7ee9b3
8903344
d70753c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The shallow-checkout handling applies only to the CI-derived target branch, not to an explicit Prompt for AI agents |
||||||
| | `--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`. | | ||||||
|
|
@@ -203,7 +203,7 @@ jobs: | |||||
|
|
||||||
| | Input | How to produce it | Unlocks | | ||||||
| |---|---|---| | ||||||
| | Full git history of the PR's target branch | `actions/checkout` with `fetch-depth: 0` | Correct base: the diff starts at the merge-base with the PR's target branch. A target branch that is not fetched is an error, never a silent fallback to `main`. | | ||||||
| | 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. | | ||||||
|
|
@@ -319,6 +319,18 @@ rubric: | |||||
| highly sensitive PII column proven new when the base or the head cannot be | ||||||
| compiled, so the engine has nothing to compare (see the **PII** bullet under | ||||||
| "What the PR comment shows"). 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This sentence overstates the new default: proven-new Prompt for AI agents |
||||||
| pattern rule blocking, add its id to `rubric.blockingRules`. A blocking | ||||||
|
Comment on lines
+324
to
+325
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve the proven-new PII exception in the migration instructions. This paragraph says a pattern rule must be listed in
|
||||||
| 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 head SQL, the earlier block stays. A rerun also | ||||||
| clears a block only if it could check at least what the blocking run could: | ||||||
| a manifest, compiled base SQL (`target-base/`), and a manifest no older than | ||||||
| the changed files. If the run that found a lineage break had a manifest and | ||||||
| the rerun's `dbt compile` failed, the block stays; if neither run had one | ||||||
| (or neither compiled the base, the Action's default), a clean rerun clears it. | ||||||
|
|
||||||
| ### What the PR comment shows | ||||||
|
|
||||||
|
|
@@ -352,6 +364,37 @@ rubric: | |||||
| cannot follow (Jinja that builds the select list, lateral or scalar | ||||||
| subqueries, unusual syntax), or in a model whose output also takes a `*` or a | ||||||
| Jinja column list over a table, whose columns the SQL does not show. | ||||||
| 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, and so does a changed | ||||||
| model whose head or base version could not be read. SQL the engine cannot | ||||||
| parse in your dialect is not an engine failure: the affected checks abstain | ||||||
| on that model, and the model is listed as not fully verified (PII, structural | ||||||
| diff, dbt config diff, column lineage). A Python model is not listed for | ||||||
| these: the SQL checks cannot parse Python, so their abstention says nothing | ||||||
| about it. | ||||||
| - **The gate clears itself:** when a completed rerun on the PR's current head | ||||||
| no longer blocks, and could check at least what the blocking run could | ||||||
| (manifest, compiled base, fresh manifest; see above), 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. The run must also cover the whole PR: its | ||||||
| base comes from the PR's target branch (the Action's default), or an explicit | ||||||
| `base` whose merge-base is the target's current tip; a narrowed `base` (a | ||||||
| later PR commit) keeps the block. A blocking verdict softened to COMMENT by | ||||||
| `mode: comment` does not clear a block. Only reviews authored by a bot (or by | ||||||
| the token's own user) are dismissed. A blocking review posted before reviews | ||||||
| carried a project marker is never dismissed automatically, whichever project | ||||||
| runs: dismiss it by hand once. | ||||||
|
|
||||||
| ### Risk-tier path tokens | ||||||
|
|
||||||
|
|
@@ -422,8 +465,13 @@ run against the **same** warehouse (base-compiled vs head-compiled SQL): | |||||
| "database":"ANALYTICS","schema":"DBT_CI"} | ||||||
| ``` | ||||||
|
|
||||||
| When no connection resolves, the data-diff lane **skips silently** — the review | ||||||
| still runs every other lane. Data-diff never blocks on its own; it surfaces a | ||||||
| When no connection or driver is configured, the data-diff lane **skips | ||||||
| silently** — the review still runs every other lane. When a configured | ||||||
| connection fails (it cannot connect, the query fails, or it times out), that is | ||||||
| an engine error: the comment shows `data.diff failed (connection error)` (or | ||||||
| `query` / `timeout` / `unknown`), never the driver's message, which can quote | ||||||
| row values, and the run is neither approved nor allowed to clear an earlier | ||||||
| block until the diff runs. Data-diff never blocks on its own; it surfaces a | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: 'until the diff runs' is ambiguous. Say that a later run must complete the data-diff without error before it can approve or clear the block. Prompt for AI agents
Suggested change
|
||||||
| `warning` so a human confirms the data impact is intended. | ||||||
|
|
||||||
| > **Least privilege:** use a read-only CI role scoped to the schemas under review. | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,18 +70,7 @@ export function renderSummary(env: VerdictEnvelope, opts: RenderOptions = {}): s | |
| // the signed envelope's tierReasons[]; the summary shows the first 8. | ||
| if (env.tierReasons && env.tierReasons.length) { | ||
| const RENDER_CAP = 8 | ||
| // Pick an inline-code-span fence longer than any backtick run inside `r` | ||
| // so a path like `packages/…/foo`bar`.sql` cannot terminate the span | ||
| // (cubic-review P3). | ||
| const spans = env.tierReasons.slice(0, RENDER_CAP).map((r) => { | ||
| const runs = r.match(/`+/g) | ||
| const maxRun = runs ? Math.max(...runs.map((run) => run.length)) : 0 | ||
| const fence = "`".repeat(maxRun + 1) | ||
| // If the reason itself starts/ends with a backtick, pad with a space so | ||
| // the leading/trailing backtick isn't glued to the fence. | ||
| const pad = /^`|`$/.test(r) ? " " : "" | ||
| return `${fence}${pad}${r}${pad}${fence}` | ||
| }) | ||
| const spans = env.tierReasons.slice(0, RENDER_CAP).map(codeSpan) | ||
| // Whole reasons only, within the tier line's share of the budget. | ||
| const prefix = `> 🧭 **Tier: ${env.tier}** — ` | ||
| const shown = takeWhole(spans, budget(maxChars, TIER_SHARE) - prefix.length - 60, ", ") | ||
|
|
@@ -230,6 +219,18 @@ const BULLET_TITLE_MAX = 200 | |
| // BULLET_BODY_MAX, so a grouped bullet is no larger than a single one. | ||
| const BULLET_NAMES_MAX = 200 | ||
|
|
||
| /** `text` as one inline code span, so a reason quoting `@user`, backticks or | ||
| * `<!--` can neither ping anyone nor break the comment. The fence is longer | ||
| * than any backtick run inside `text`, so a path like `packages/…/foo`bar`.sql` | ||
| * cannot terminate the span (cubic-review P3); a leading or trailing backtick | ||
| * is padded with a space so it isn't glued to the fence. */ | ||
| function codeSpan(text: string): string { | ||
| const runs = text.match(/`+/g) | ||
| const fence = "`".repeat((runs ? Math.max(...runs.map((run) => run.length)) : 0) + 1) | ||
| const pad = /^`|`$/.test(text) ? " " : "" | ||
| return `${fence}${pad}${text}${pad}${fence}` | ||
| } | ||
|
|
||
| /** `clip`, never ending inside a code span: a span left open is cut back to | ||
| * its opening run. A span opens on a run of backticks and closes on the next | ||
| * run of the same length (a double-backtick span may hold a single backtick), | ||
|
|
@@ -331,26 +332,35 @@ function bulletsFor(items: Finding[], group: boolean): Array<{ text: string; cou | |
| export function coverageNotes(env: VerdictEnvelope, maxChars = Infinity): string[] { | ||
| const notes: string[] = [] | ||
| // Diagnostic reasons are clipped only in a budgeted comment; local output is whole. | ||
| const reasonOf = (text: string) => (maxChars === Infinity ? text : clip(text, 200)) | ||
| const clipReason = (text: string) => (maxChars === Infinity ? text : clip(text, 200)) | ||
| // Engine and unverified reasons quote engine error text: shown as code spans. | ||
| const reasonOf = (text: string) => codeSpan(clipReason(text)) | ||
| const undecided = env.findings.filter((f) => f.degraded).length | ||
| if (undecided) notes.push(`${undecided} finding(s) could not be decided by the engine and are marked _unverified_.`) | ||
| const unverified = env.scope?.unverified ?? [] | ||
| if (unverified.length) { | ||
| // One line per reason: models can lack the head compile or the base compile. | ||
| const byReason = new Map<string, string[]>() | ||
| for (const u of unverified) byReason.set(u.reason, [...(byReason.get(u.reason) ?? []), u.path]) | ||
| for (const [reason, paths] of byReason) { | ||
| const label = `${paths.length} model(s) not verified by the engine — ${reasonOf(reason)}` | ||
| // Whole paths only: at most 5, and within an even share of the notes budget. | ||
| const shown = takeWhole( | ||
| paths.slice(0, 5).map((p) => `\`${p}\``), | ||
| maxChars / (byReason.size + 1) - label.length - 30, | ||
| ", ", | ||
| ) | ||
| const more = paths.length > shown.length ? `${shown.length ? " and " : " "}${paths.length - shown.length} more` : "" | ||
| notes.push(`${label}:${shown.length ? " " : ""}${shown.join(", ")}${more}.`) | ||
| } | ||
| notes.push("Run `dbt compile` (and compile the base into `target-base/`) for equivalence and lineage checks.") | ||
| const byReason = new Map<string, string[]>() | ||
| for (const u of unverified) { | ||
| const paths = byReason.get(u.reason) | ||
| if (paths) paths.push(u.path) | ||
| else byReason.set(u.reason, [u.path]) | ||
| } | ||
| for (const [reason, paths] of byReason) { | ||
| const label = `${paths.length} model(s) not fully verified — ${reasonOf(reason)}` | ||
| const hint = /compiled SQL/.test(reason) | ||
| ? " Run `dbt compile` (and compile the base into `target-base/`) for equivalence and lineage checks." | ||
| : "" | ||
| // Whole paths only: at most 5, and within an even share of the notes budget. | ||
| const shown = takeWhole( | ||
| paths.slice(0, 5).map((p) => `\`${p}\``), | ||
| maxChars / (byReason.size + 1) - label.length - hint.length - 30, | ||
| ", ", | ||
| ) | ||
| const more = paths.length > shown.length ? `${shown.length ? " and " : " "}${paths.length - shown.length} more` : "" | ||
| notes.push(`${label}:${shown.length ? " " : ""}${shown.join(", ")}${more}.${hint}`) | ||
| } | ||
| if (env.engineErrors?.length) { | ||
| const list = env.engineErrors.map((e) => `${e.method} ×${e.count} (${reasonOf(e.reason)})`).join("; ") | ||
| notes.push(`Some engine checks failed and did not run: ${list}. This verdict is not a clean approval.`) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The engine-failure note is the last-added note before the scope notes, so in a busy PR the notes budget can cut it. The reader then sees only a generic '+N more' line and not that engine checks failed. Emit the engineErrors note before the unverified groups so Prompt for AI agents |
||
| } | ||
| if (env.scope?.outOfScopeFiles) | ||
| notes.push(`${env.scope.outOfScopeFiles} changed file(s) outside the dbt project were not reviewed.`) | ||
|
|
@@ -367,7 +377,7 @@ export function coverageNotes(env: VerdictEnvelope, maxChars = Infinity): string | |
| } | ||
| if (env.ai && env.ai.state !== "ok") { | ||
| const what = { skipped: "skipped", timeout: "timed out", error: "failed" }[env.ai.state] | ||
| notes.push(`Advisory AI review ${what}${env.ai.reason ? `: ${reasonOf(env.ai.reason)}` : ""}.`) | ||
| notes.push(`Advisory AI review ${what}${env.ai.reason ? `: ${clipReason(env.ai.reason)}` : ""}.`) | ||
| } | ||
| // Whole notes within the budget; the rest are counted. | ||
| const lines = takeWhole( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit automatic history fetching to CI runs without
--base.In a shallow checkout,
--base origin/mainstill fails if Git cannot find a merge-base locally. The explicit flag path exits before the automatic fetch. State that CI target auto-detection fetches history, and keepfetch-depth: 0as the guidance for explicit bases.Also applies to: 206-206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right: the automatic fetch applies to CI target detection without
--base; an explicit--basestill needsfetch-depth: 0. Carried into the follow-up PR that closes this stack.