Skip to content

fix(review): a readable PR comment: diff-anchored inline comments, no reposts, grouped rules, size budget, new-only PII, no portability noise - #1721

Open
RaghwendraSingh wants to merge 6 commits into
fix/review-ci-experiencefrom
fix/review-noise
Open

RaghwendraSingh wants to merge 6 commits into
fix/review-ci-experiencefrom
fix/review-noise

Conversation

@RaghwendraSingh

@RaghwendraSingh RaghwendraSingh commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1792
Stacked on #1720, which is stacked on #1719; merge in that order.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On a real dbt repo the review comment was mostly noise:

  • Reposts: nearly half of the bot's inline comments were the same comment re-posted on a later push.
  • Repeated rules: four generic rules made up most on-diff findings, emitted once per model.
  • Size: summaries ran to tens of thousands of characters.
  • Broken anchors: inline comments were anchored to compiled-SQL line numbers, so a single line outside the diff got a 422 and every inline comment was lost.

Fixes:

  • Anchors: a finding keeps its line only if that line is a head-side line inside the file's diff hunks. Engine lint on compiled SQL no longer sets raw-file lines. Anything unanchorable stays in the summary.
  • No reposts: each inline comment carries <!-- altimate-finding:<id> -->. The id is the existing fingerprint (rule, file, model, column — no line), so moving code doesn't change it. On rerun, findings already on the PR are skipped. A non-blocking rerun with nothing new only updates the summary, with no new "Reviewed with comments" entry. Blocking verdicts always post.
  • Grouping: the same rule (title minus model name, backticked names blanked) on 3+ models becomes one bullet listing the models.
  • Budget: the posted summary is capped at about 5K characters, most severe first. A count says what was left out; the envelope keeps everything. CLI and agent-tool output are uncapped.
  • PII: the fallback flags only columns the change newly exposes, as the docs already promise. Behavior change: a touched model that already exposed email no longer gets a critical (blocking in gate mode) finding. The test that asserted the old behavior is inverted, and four fixtures whose fake detector returned PII for any SQL are now SQL-aware.
  • Portability: cross-engine advice from the regex catalog ("isn't portable") is dropped once the engine is known from the manifest adapter or dialect. portability: true turns it back on for multi-adapter packages. Core's dialect-aware check (a function missing on your engine) is unchanged.

Follow-up after an adversarial review (commit 9370266050):

  • Portability is now an explicit per-rule tag (portability: { worksOn? }) instead of matching the comment text. The text match was dropping BigQuery's legacy-SQL warning ("use Standard SQL") on BigQuery projects.
  • Advice is kept when the construct fails on your engine. With a known engine, portability advice is dropped only when that engine supports the construct. DISTINCT ON on Snowflake or GROUP BY alias on SQL Server stays, because it errors there.
  • Moved files are named in the comment, with a caveat that folder-level dbt_project.yml config (+schema, +materialized) can still change how they build.
  • No more "lint-only" label for runs without model files (yml-only changes, pure moves).
  • Tests: suppression is checked in both directions (Postgres drops DISTINCT ON advice, Snowflake keeps it), plus the legacy-SQL case and the move note.

How did you verify your code works?

  • New test/altimate/review-noise.test.ts (13 tests):
    • hunk line parsing (blank context lines, ++ SQL lines, headers)
    • anchoring and the compiled-SQL line drop
    • fingerprint markers and dedup
    • telemetry for a skipped review
    • grouping thresholds and backticked names
    • budget with a 200-finding envelope
    • portability suppression on a real catalog rule
  • 1,872 tests across the review files and release gates pass. bun typecheck is clean.

Cost side effects

Two extra GitHub API list calls per --post (review comments and reviews, paginated), plus one extra local PII detection per modified model on the fallback path. No model calls, warehouse queries or cloud resources.

Screenshots / recordings

N/A (CLI).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

🤖 Generated with Claude Code


Summary by cubic

Fixes the dbt PR review comment so it is readable instead of noisy: inline comments now land on lines that exist in the diff, findings already on the PR are not re-posted on later pushes, repeated rules are grouped, and the posted summary respects a ~5,000-character budget (local CLI and agent output stay complete).

Behavior changes

  • Inline comments land only on head-side lines inside the PR's diff hunks, so compiled-SQL findings stay in the summary without a line; files GitHub lists without a patch (large diffs) keep their inline comments via the existing 422 fallback, and a positioning 422 now retries once with only the comments on files whose hunks are known before dropping them all.
  • PII: only columns the change newly exposes are flagged; both regex PII rules and the broad fallback reconcile against the compiled base's exposed columns (by output alias and source column, and by treating pure reindents as no-op), so a reindented PII line no longer gets a critical (gate-blocking) finding — nor hides a genuinely new column on another line. When the base SQL can't be compiled, PII findings are non-blocking warnings that may predate the PR.
  • Grouping counts distinct models and normalizes the message: the same rule and message on 3+ models is one bullet; different messages, or several findings of one rule on the same model, stay separate.
  • Cross-engine portability advice is an explicit catalog-rule tag, hidden once a single engine is known from the manifest adapter or dialect (a construct that would fail on the project's own engine is kept), re-enabled for multi-adapter packages via portability: true in review.yml.
  • A non-blocking rerun with nothing new that matches this bot's latest review headline only updates the summary — a prior "Changes requested" still posts. Files moved without edits are called out, and yml-only or pure-move runs are no longer labeled lint-only.

Written for commit b8022af. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 44baf047-2911-4c5f-9ea2-76c0f155ef21

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

}
const out: Array<{ text: string; count: number }> = []
for (const g of groups.values()) {
if (g.length >= GROUP_MIN) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Grouping threshold counts findings, not models

g.length >= GROUP_MIN collapses on the number of findings, but the documented contract (the GROUP_MIN comment at line 42 and the new docs/docs/usage/dbt-pr-review.md text) is "the same rule on three or more models". Because ruleTitle() blanks backticked names, three findings for different columns of one model (m: column \a` has no description, `b`, `c`) collapse into one bullet reading 3 findings across 1 model(s): `m`that keeps onlyg[0]'s body. These findings carry no startLine (qualityLane`/AI are the only line producers), so the summary is their only surface — the other two columns vanish from the PR comment entirely.

Gate the collapse on distinct models (names.length >= GROUP_MIN) and keep per-finding bullets within a single model, or list each merged finding's column/title in the grouped bullet. There is also no test for the one-model case (review-noise.test.ts only covers 3-4 distinct models).

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.

Fixed in 4726770. Grouping now requires GROUP_MIN distinct models, so several findings of one rule on the same model (criticals included) stay separate bullets. Test added.

}
if (hidden) {
lines.push(
`> … ${hidden} more finding(s) not shown to keep this comment short — the full list is in the verdict envelope ` +

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The --output artifact this points at does not exist for the bundled action

github/review/action.yml builds its args from --mode/--manifest/--severity/--cwd/--base/--head/--post only — it never passes --json or --output, so an action user who hits the 5K budget has no --output artifact to open, and renderSummary is the only rendering they see. The uncapped list does reach the step log (the CLI writes renderSummary(env, { maxChars: Infinity }) to stdout), and the envelope is written only for an explicit CLI --output. Point readers at the job log or at altimate review --json --output <file> instead of an artifact the action never creates.

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: low priority, tracked. The note should point to the job log or altimate review --json --output <file>.

suppressPortability?: boolean
}

const PORTABILITY_RE = /portab|dialect[ -]specific|non-?standard|n't standard|not standard|standard sql/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Duplicate portability regex

This literal is byte-identical to the isPortability regex inside the twin-dedup pass at line 1467, and the two already differ in what they test (${f.title} ${f.body} here vs f.body there). A future tweak to one (new catalog phrasings) will silently leave the other behind, so isCatalogPortability would drop a finding the dedup pass no longer recognises as portability — or vice versa. Hoist a single module-level PORTABILITY_RE and reuse it in both places.

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.

Fixed at this PR's head: suppression now keys off the evidence.result.portability tag.

* whole batch of inline comments.
*/
export function anchorToDiff(findings: Finding[], files: ChangedFile[]): Finding[] {
const lines = new Map(files.map((f) => [f.path, commentableLines(f.diff)]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Parses every changed file's diff even when nothing needs a line

commentableLines is run over all ChangedFile.diff values up front, but only findings that already carry a startLine need their file parsed — and the only producers are qualityLane (non-Jinja SQL) and the AI lane. On a wide PR this is an extra full pass over every hunk of every changed file in memory. Build the set lazily for the files that actually have an anchored finding:

const lines = new Map(
  [...new Set(findings.filter((f) => typeof f.startLine === "number").map((f) => f.file))].map((p) => [
    p,
    commentableLines(files.find((f) => f.path === p)?.diff),
  ]),
)

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.

Not changing: parsing the changed files' diffs costs a few milliseconds compared with the engine lanes. Revisit if profiling shows otherwise.

@kilo-code-bot

kilo-code-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 8 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 5
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/rule-catalog.ts 154 New. selectItemColumns only recovers an AS alias from the same added line, so a PII column formatted as c.ssn / as tax_ref on the next line gets alias: undefined. Since detectPii reports output aliases, a non-reindent edit of that line (the table-alias rename the new test covers, or adding a cast) still leaves both twins: 3 marts -> 3 critical pii_into_mart and a gate block on PII the PR did not add.
packages/opencode/src/altimate/review/format.ts 134 Carried. An over-budget bullet is skipped with continue without advancing used, so a long critical body can be hidden while shorter warning/suggestion bullets still render, contradicting "critical findings come first".
packages/opencode/src/altimate/review/orchestrate.ts 1416 Carried. The base-exposure filter still compares output names only (basePiiColumnsByFile comes from detectPii, which prefers query_targets). Removing masking from an already-named column (md5(email) AS email -> email) is classified as pre-existing and dropped, the twin suppression drops the fallback for the same alias, and the precise lane only looks at newly introduced targets, so nothing reports it.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 1414 New. isReindented is position-blind: a PII line moved from an intermediate CTE into the final select (same normalized text, same file) is treated as a pure reindent and both twins are dropped although the model now exposes the column. In the degraded path (no detectPii/lineage) the twins are the only PII detectors, so the new exposure is reported nowhere.
packages/opencode/src/altimate/review/orchestrate.ts 1496 Carried. The downgraded regex PII twins keep a title/body that states a PII column "was added", with no "may predate the PR" caveat, and they do not set degraded, so the summary renders no _unverified_ marker even though confidence is now unknown.
packages/opencode/src/altimate/review/post-github.ts 138 Carried. inlineSkippedAsPosted runs inlineComments a second time to count, rebuilding every comment body; one filtering pass suffices.
packages/opencode/src/altimate/review/format.ts 150 Carried. The 5K-budget note points at "the action's --output artifact", but github/review/action.yml never passes --output/--json; point at the job log or CLI --output instead.
packages/opencode/src/altimate/review/rule-catalog.ts 1831 Carried. portability: {} on interval-string-literal suppresses the advice on every known engine, including BigQuery/MySQL where the string form is invalid; list the engines that accept it so it still fires where it is a real error.
Files Reviewed (7 files)
  • packages/opencode/src/altimate/review/dbt-patterns.ts - no new issues (per-token PII findings reconcile with base exposure before dedupe)
  • packages/opencode/src/altimate/review/orchestrate.ts - 1 new, 2 carried
  • packages/opencode/src/altimate/review/post-github.ts - 1 carried (the verified-only 422 retry now keeps inline comments on known files, so the patchless-file drop is addressed)
  • packages/opencode/src/altimate/review/rule-catalog.ts - 1 new, 1 carried
  • packages/opencode/src/altimate/review/format.ts - 2 carried (unchanged in this commit, re-verified at HEAD)
  • packages/opencode/test/altimate/review-noise.test.ts - no issues
  • packages/opencode/test/altimate/review.test.ts - no issues

Re-verified against b8022af95: the alias reindent (same-line AS, renamed table alias), the every-token emission (ssn, passport), the pure-reindent drop, and the verified-only 422 retry are covered by new tests and work as described. The previous patchless-file finding is resolved. The two new findings are the same-line-only alias recovery and the position-blind reindent shortcut; the masking-removal, budget-skip, twin-wording, second-pass, --output, and interval items remain.

Fix these issues in Kilo Cloud

Previous Review Summaries (6 snapshots, latest commit 8003a3a)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8003a3a)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 4
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 1284 The base-exposure filter compares output aliases, so removing masking from an already-named column (md5(email) AS email → email) is classified as pre-existing and dropped; the twin suppression drops the regex fallback for the same alias, and on a tier without semantic_change no lane reports it.
packages/opencode/src/altimate/review/post-github.ts 133 A file GitHub lists without a patch is now treated as "unknown hunks" and attempted. One anchor outside the diff in such a file 422s the batch, and the fallback drops inline comments for every file; the un-posted comment never enters posted, so every push re-attempts it and adds another identical event-only review entry. filter((f) => f.patch) also turns a known empty patch into "unknown".
packages/opencode/src/altimate/review/format.ts 134 An over-budget bullet is skipped with continue without advancing used, so a long critical body can be hidden while shorter warning/suggestion bullets still render - contradicting "critical findings come first".

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 1479 The downgraded regex PII twins keep a body that states a PII column "was added", with no "may predate the PR" caveat and no degraded flag, unlike piiLane; the summary renders no _unverified_ marker, so the qualification the docs promise never reaches the comment.
packages/opencode/src/altimate/review/post-github.ts 138 inlineSkippedAsPosted runs inlineComments a second time to count, rebuilding every comment body; one filtering pass suffices.
packages/opencode/src/altimate/review/format.ts 150 The 5K-budget note points at "the action's --output artifact", but github/review/action.yml never passes --output/--json; point at the job log or CLI --output instead.
packages/opencode/src/altimate/review/rule-catalog.ts 1764 portability: {} on interval-string-literal suppresses the advice on every known engine, including BigQuery/MySQL where the string form is invalid; list the engines that accept it so it still fires where it is a real error.
Files Reviewed (7 files)
  • packages/opencode/src/altimate/review/dbt-patterns.ts - no new issues (per-line PII findings reconcile correctly with base exposure before dedupe)
  • packages/opencode/src/altimate/review/format.ts - 2 issues (1 carried forward)
  • packages/opencode/src/altimate/review/orchestrate.ts - 2 issues (1 carried forward)
  • packages/opencode/src/altimate/review/post-github.ts - 2 issues (1 new, 1 carried forward)
  • packages/opencode/src/altimate/review/rule-catalog.ts - 1 issue (carried forward)
  • packages/opencode/test/altimate/review-noise.test.ts - no issues
  • packages/opencode/test/altimate/review.test.ts - no issues

Re-verified against 8003a3af9: the per-column select-pii-columns reconciliation, the base-unknown downgrade for both regex twins, the per-line pii_into_mart emission, and the patchless-file inline path are covered by new tests and work as described. The select-pii-columns finding from the previous review is resolved. Two new findings are reported inline; the budget-skip, --output, redundant-second-pass, alias/masking and interval items remain unresolved.

Fix these issues in Kilo Cloud

Previous review (commit c7a166b)

Status: 6 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 4
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 1284 The base-exposure filter compares output aliases, so removing masking from an already-named column (md5(email) AS email → email) is treated as pre-existing and dropped; the new twin suppression drops the regex fallback for the same alias, and on a trivial tier (or without semantic_change) no lane reports it.
packages/opencode/src/altimate/review/format.ts 134 An over-budget bullet is skipped with continue without advancing used, so a long critical body can be hidden while shorter warning/suggestion bullets still render — contradicting "critical findings come first".

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 1219 The comment claims "the regex twins" no longer report base-exposed columns, but only pii_into_mart consults basePiiColumnsByFile; select-pii-columns still flags a whitespace-only ssn reindent in a mart.
packages/opencode/src/altimate/review/post-github.ts 137 inlineSkippedAsPosted runs inlineComments a second time to count, rebuilding every comment body; one filtering pass suffices.
packages/opencode/src/altimate/review/format.ts 150 The 5K-budget note points at "the action's --output artifact", but github/review/action.yml never passes --output/--json; point at the job log or CLI --output instead.
packages/opencode/src/altimate/review/rule-catalog.ts 1745 portability: {} suppresses the interval '1 day' advice on every known engine, including BigQuery/MySQL where the string form is invalid; list the engines that accept it so it still fires where it is a real error.
Files Reviewed (8 files)
  • docs/docs/usage/dbt-pr-review.md - no new issues
  • packages/opencode/src/altimate/review/format.ts - 2 issues (1 carried forward)
  • packages/opencode/src/altimate/review/orchestrate.ts - 2 issues
  • packages/opencode/src/altimate/review/post-github.ts - 1 issue
  • packages/opencode/src/altimate/review/rule-catalog.ts - 1 issue (carried forward)
  • packages/opencode/src/altimate/review/run.ts - no new issues
  • packages/opencode/test/altimate/review-noise.test.ts - no new issues
  • packages/opencode/test/altimate/review.test.ts - no new issues

Re-verified the previous findings against c7a166b2e: the base-unknown PII gate, the timestamp worksOn split, the anchor stripping, and the grouping regression are fixed. Three issues are newly reported inline; the budget-skip and --output/interval items above remain unresolved from the earlier review.

Fix these issues in Kilo Cloud

Previous review (commit 0b216f2)

Status: 8 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 5
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/format.ts 133 An over-budget bullet is skipped with continue without advancing used, so a long critical body can be hidden while shorter warning/suggestion bullets still render — contradicting "critical findings come first".
packages/opencode/src/altimate/review/orchestrate.ts 1077 The base-unknown PII downgrade emits one warning per column; three such warnings reach warningPatternThreshold and still return REQUEST_CHANGES, despite the comment/docs calling them non-blocking.
packages/opencode/src/altimate/review/orchestrate.ts 1313 The new-only PII filter compares output aliases, so removing masking from an already-named column (md5(email) AS email → email) yields no finding at all; the fallback used to report it as a critical, and no other lane covers SQL-level masking removal.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/format.ts 183 The grouped bullet counts all findings but renders only g[0]'s body; a second finding of the same rule on an already-listed model (for example a second PII column) disappears from the summary, which is its only surface.
packages/opencode/src/altimate/review/format.ts 149 The 5K-budget note points at "the action's --output artifact", but github/review/action.yml never passes --output/--json; point at the job log or CLI --output instead.
packages/opencode/src/altimate/review/orchestrate.ts 261 anchorToDiff parses the diff of every changed file even though only files with an anchored finding need a line set.
packages/opencode/src/altimate/review/rule-catalog.ts 1745 portability: {} suppresses the interval '1 day' advice on every known engine, including BigQuery/MySQL where the string form is invalid; list the engines that accept it so it still fires where it is a real error.
packages/opencode/src/altimate/review/rule-catalog.ts 1755 The date-plus-int regex also matches _at/_dt timestamps, but worksOn lists Postgres; timestamp + integer errors on Postgres, so tagging it as supported suppresses a real error.
Files Reviewed (12 files)
  • docs/docs/usage/dbt-pr-review.md - no new issues
  • packages/opencode/src/altimate/review/config.ts - no issues
  • packages/opencode/src/altimate/review/format.ts - 3 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 3 issues
  • packages/opencode/src/altimate/review/post-github.ts - no new issues
  • packages/opencode/src/altimate/review/rule-catalog.ts - 2 issues
  • packages/opencode/src/altimate/review/run.ts - no new issues
  • packages/opencode/src/altimate/review/telemetry.ts - no issues
  • packages/opencode/src/altimate/tools/dbt-pr-review.ts - no issues
  • packages/opencode/src/cli/cmd/review.ts - no issues
  • packages/opencode/test/altimate/review-noise.test.ts - no new issues
  • packages/opencode/test/altimate/review.test.ts - no new issues

Re-verified the five findings from the previous review against 0b216f2c4; all still reproduce and their inline comments remain active. Three new issues were found on the last commits and are reported inline.

Fix these issues in Kilo Cloud

Previous review (commit 27be2b0)

Status: 5 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 4
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 1313 The new-only PII filter compares output aliases, so removing masking from an already-named column (md5(email) AS email → email) yields no finding at all; the fallback used to report it as a critical, and no other lane covers SQL-level masking removal.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/format.ts 183 The grouped bullet counts all findings but renders only g[0]'s body; a second finding of the same rule on an already-listed model (for example a second PII column) disappears from the summary, which is its only surface.
packages/opencode/src/altimate/review/rule-catalog.ts 1745 portability: {} suppresses the interval '1 day' advice on every known engine, including BigQuery/MySQL where the string form is invalid; list the engines that accept it so it still fires where it is a real error.
packages/opencode/src/altimate/review/format.ts 149 The 5K-budget note points at "the action's --output artifact", but github/review/action.yml never passes --output/--json; point at the job log or CLI --output instead.
packages/opencode/src/altimate/review/orchestrate.ts 261 anchorToDiff parses the diff of every changed file even though only files with an anchored finding need a line set.
Files Reviewed (12 files)
  • docs/docs/usage/dbt-pr-review.md - no issues
  • packages/opencode/src/altimate/review/config.ts - no issues
  • packages/opencode/src/altimate/review/format.ts - 2 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 2 issues
  • packages/opencode/src/altimate/review/post-github.ts - no issues
  • packages/opencode/src/altimate/review/rule-catalog.ts - 1 issue
  • packages/opencode/src/altimate/review/run.ts - no issues
  • packages/opencode/src/altimate/review/telemetry.ts - no issues
  • packages/opencode/src/altimate/tools/dbt-pr-review.ts - no issues
  • packages/opencode/src/cli/cmd/review.ts - no issues
  • packages/opencode/test/altimate/review-noise.test.ts - no issues
  • packages/opencode/test/altimate/review.test.ts - no issues

Re-verified against 27be2b034. The branch was rebased onto an updated base, but the PR's own content is identical to the previously reviewed tree: git diff 4726770..HEAD reports only packages/opencode/test/altimate/adversarial.test.ts, which is not in this PR's diff (gh pr diff 1721), so it was not re-reviewed here. All five findings above still reproduce on current HEAD and already have inline comments; no new inline comments were added.

Previous review (commit 4726770)

Status: 5 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 4
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 1313 The new-only PII filter compares output aliases, so removing masking from an already-named column (md5(email) AS email → email) yields no finding at all; the fallback used to report it as a critical, and no other lane covers SQL-level masking removal.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/format.ts 183 The grouped bullet counts all findings but renders only g[0]'s body; a second finding of the same rule on an already-listed model (different column) disappears from the summary, which is its only surface.
packages/opencode/src/altimate/review/rule-catalog.ts 1745 portability: {} suppresses the interval '1 day' advice on every known engine, including BigQuery/MySQL where the string form is invalid; list the engines that accept it so it still fires where it is a real error.
packages/opencode/src/altimate/review/format.ts 149 (carried, still open) The 5K-budget note points at "the action's --output artifact", but github/review/action.yml never passes --output/--json; point at the job log or CLI --output instead.
packages/opencode/src/altimate/review/orchestrate.ts 261 (carried, still open) anchorToDiff parses the diff of every changed file even though only files with an anchored finding need a line set.
Files Reviewed (12 files)
  • docs/docs/usage/dbt-pr-review.md - no issues
  • packages/opencode/src/altimate/review/config.ts - no issues
  • packages/opencode/src/altimate/review/format.ts - 2 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 2 issues
  • packages/opencode/src/altimate/review/post-github.ts - no issues
  • packages/opencode/src/altimate/review/rule-catalog.ts - 1 issue
  • packages/opencode/src/altimate/review/run.ts - no issues
  • packages/opencode/src/altimate/review/telemetry.ts - no issues
  • packages/opencode/src/altimate/tools/dbt-pr-review.ts - no issues
  • packages/opencode/src/cli/cmd/review.ts - no issues
  • packages/opencode/test/altimate/review-noise.test.ts - no issues
  • packages/opencode/test/altimate/review.test.ts - no issues

Verified against 4726770f917619915a798549ee9dac4b4286d6b6. Grouping by distinct models and the tag-based portability switch now match the documented contract; the two carried items were re-checked and are still present. git invocations are blocked in this sandbox, so the review used gh pr diff (full PR diff) instead of the incremental range.

Previous review (commit 10e47c5)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/format.ts 175 Grouping collapses on finding count, not distinct models — same-rule findings on different columns of one model merge into one bullet that keeps only the first body, and these findings have no line so the summary is their only surface.
packages/opencode/src/altimate/review/format.ts 148 "the action's --output artifact" does not exist: github/review/action.yml never passes --json/--output, so users who hit the 5K budget have no artifact to open (the full list is only in the step log).

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 213 PORTABILITY_RE duplicates the identical regex at line 1467, already diverging in scope (title+body vs body).
packages/opencode/src/altimate/review/orchestrate.ts 253 anchorToDiff parses the diff of every changed file instead of only files with an anchored finding.
Files Reviewed (11 files)
  • docs/docs/usage/dbt-pr-review.md - docs match the new behavior, no issues
  • packages/opencode/src/altimate/review/config.ts - optional portability flag, no issues
  • packages/opencode/src/altimate/review/format.ts - 2 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 2 issues
  • packages/opencode/src/altimate/review/post-github.ts - no issues (dedup/skip logic checked against HEAD; reviewSkipped only affects the COMMENT event)
  • packages/opencode/src/altimate/review/run.ts - no issues (dialectKnown preserves prior dialect resolution)
  • packages/opencode/src/altimate/review/telemetry.ts - no issues
  • packages/opencode/src/altimate/tools/dbt-pr-review.ts - uncapped output, correct
  • packages/opencode/src/cli/cmd/review.ts - uncapped output, correct
  • packages/opencode/test/altimate/review-noise.test.ts - no issues; the one-model grouping case is untested (see format.ts:175)
  • packages/opencode/test/altimate/review.test.ts - PII behavior inversion matches the documented change

Verified against 10e47c53a2dee859400b4433bc4aed2addb96937. The diff-anchoring, fingerprint dedup, and PII base-side comparison are consistent with their producers: the only startLine writers are qualityLane (now gated on raw-vs-compiled identity) and the AI lane, and runner.detectPii returns core's pii_columns output aliases, so comparing head against base output columns is a like-for-like check. No unbounded cost added (two paginated GitHub list calls per post plus one local core check per modified model).

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 212.9K · Output: 68.1K · Cached: 4.3M

Review guidance: REVIEW.md from base branch fix/review-ci-experience

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

6 issues found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. 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. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/opencode/src/altimate/review/post-github.ts">

<violation number="1" location="packages/opencode/src/altimate/review/post-github.ts:65">
P1: `BOT_REVIEW_RE` classifies `Changes requested` as non-blocking. After a gate run requests changes, a clean rerun can hit this guard and return without resolving the old blocking review; track review state and dismiss or resolve that review before skipping.</violation>
</file>

<file name="packages/opencode/test/altimate/review-noise.test.ts">

<violation number="1" location="packages/opencode/test/altimate/review-noise.test.ts:175">
P3: This test does not verify the claimed severity ordering: `toContain` passes regardless of where `m0` appears. Assert that a critical finding appears before a suggestion (and, ideally, that all three critical findings are shown) so a renderer regression cannot pass.</violation>
</file>

<file name="packages/opencode/src/altimate/review/format.ts">

<violation number="1" location="packages/opencode/src/altimate/review/format.ts:149">
P3: The bundled action does not pass `--output`, so this artifact is never created; point readers to the job log or explicit `altimate review --json --output <file>` usage.</violation>

<violation number="2" location="packages/opencode/src/altimate/review/format.ts:160">
P2: This normalization misses findings whose producer puts the model or filename outside a `model: ` prefix, so the promised cross-model grouping fails for rules such as removed-test findings. Group by a stable rule identity or normalize those producer-specific location fields before building the key.</violation>
</file>

<file name="packages/opencode/src/altimate/review/run.ts">

<violation number="1" location="packages/opencode/src/altimate/review/run.ts:322">
P2: Unrecognized manifest adapters are treated as known and suppress all catalog portability findings by default. Restrict automatic suppression to dialects recognized by `ADAPTER_DIALECT`, while keeping explicit `dialect` overrides authoritative.</violation>
</file>

<file name="packages/opencode/src/altimate/review/orchestrate.ts">

<violation number="1" location="packages/opencode/src/altimate/review/orchestrate.ts:253">
P3: Build `commentableLines` sets only for files with findings carrying `startLine`; this eagerly parses every changed diff even when no inline comment can be emitted.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

}

/** Headline of a review this bot posted (see verdictHeadline). */
const BOT_REVIEW_RE = /(Approved|Reviewed with comments|Changes requested)\b.*\((trivial|lite|full) tier/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: BOT_REVIEW_RE classifies Changes requested as non-blocking. After a gate run requests changes, a clean rerun can hit this guard and return without resolving the old blocking review; track review state and dismiss or resolve that review before skipping.

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 packages/opencode/src/altimate/review/post-github.ts, line 65:

<comment>`BOT_REVIEW_RE` classifies `Changes requested` as non-blocking. After a gate run requests changes, a clean rerun can hit this guard and return without resolving the old blocking review; track review state and dismiss or resolve that review before skipping.</comment>

<file context>
@@ -54,8 +54,16 @@ export interface PostResult {
 }
 
+/** Headline of a review this bot posted (see verdictHeadline). */
+const BOT_REVIEW_RE = /(Approved|Reviewed with comments|Changes requested)\b.*\((trivial|lite|full) tier/
+
 export async function postGitHubReview(env: VerdictEnvelope, target: GitHubTarget): Promise<PostResult> {
</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.

Fixed later in #1723 (dismissReview).

Comment thread docs/docs/usage/dbt-pr-review.md Resolved
* blanked, so the same rule on different models/columns shares a key. */
function ruleTitle(f: Finding): string {
const t = f.model && f.title.startsWith(`${f.model}: `) ? f.title.slice(f.model.length + 2) : f.title
return t.replace(/`[^`]*`/g, "`…`")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This normalization misses findings whose producer puts the model or filename outside a model: prefix, so the promised cross-model grouping fails for rules such as removed-test findings. Group by a stable rule identity or normalize those producer-specific location fields before building the key.

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 packages/opencode/src/altimate/review/format.ts, line 160:

<comment>This normalization misses findings whose producer puts the model or filename outside a `model: ` prefix, so the promised cross-model grouping fails for rules such as removed-test findings. Group by a stable rule identity or normalize those producer-specific location fields before building the key.</comment>

<file context>
@@ -115,7 +109,90 @@ export function renderSummary(env: VerdictEnvelope): string {
+ *  blanked, so the same rule on different models/columns shares a key. */
+function ruleTitle(f: Finding): string {
+  const t = f.model && f.title.startsWith(`${f.model}: `) ? f.title.slice(f.model.length + 2) : f.title
+  return t.replace(/`[^`]*`/g, "`…`")
+}
+
</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: low priority, tracked. Group by ruleKey/catalog rule id.

// analyzed as the snowflake default — wrong-dialect portability suppression).
if (!config.dialect) config.dialect = (await detectDialect(manifestAbs)) ?? "snowflake"
const detectedDialect = config.dialect ? undefined : await detectDialect(manifestAbs)
const dialectKnown = !!config.dialect || !!detectedDialect

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Unrecognized manifest adapters are treated as known and suppress all catalog portability findings by default. Restrict automatic suppression to dialects recognized by ADAPTER_DIALECT, while keeping explicit dialect overrides authoritative.

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 packages/opencode/src/altimate/review/run.ts, line 322:

<comment>Unrecognized manifest adapters are treated as known and suppress all catalog portability findings by default. Restrict automatic suppression to dialects recognized by `ADAPTER_DIALECT`, while keeping explicit `dialect` overrides authoritative.</comment>

<file context>
@@ -318,7 +318,9 @@ export async function reviewPullRequest(opts: ReviewPullRequestOptions): Promise
   // analyzed as the snowflake default — wrong-dialect portability suppression).
-  if (!config.dialect) config.dialect = (await detectDialect(manifestAbs)) ?? "snowflake"
+  const detectedDialect = config.dialect ? undefined : await detectDialect(manifestAbs)
+  const dialectKnown = !!config.dialect || !!detectedDialect
+  if (!config.dialect) config.dialect = detectedDialect ?? "snowflake"
 
</file context>
Suggested change
const dialectKnown = !!config.dialect || !!detectedDialect
const dialectKnown = !!config.dialect || (!!detectedDialect && Object.values(ADAPTER_DIALECT).includes(detectedDialect))

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.

Fixed later in #1724.

const env = buildEnvelope({ findings: many, tier: "full", mode: "comment" })
const md = renderSummary(env)
expect(md.length).toBeLessThanOrEqual(SUMMARY_BUDGET_CHARS)
expect(md).toContain("m0: distinct issue number 0")

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 test does not verify the claimed severity ordering: toContain passes regardless of where m0 appears. Assert that a critical finding appears before a suggestion (and, ideally, that all three critical findings are shown) so a renderer regression cannot pass.

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 packages/opencode/test/altimate/review-noise.test.ts, line 175:

<comment>This test does not verify the claimed severity ordering: `toContain` passes regardless of where `m0` appears. Assert that a critical finding appears before a suggestion (and, ideally, that all three critical findings are shown) so a renderer regression cannot pass.</comment>

<file context>
@@ -0,0 +1,235 @@
+    const env = buildEnvelope({ findings: many, tier: "full", mode: "comment" })
+    const md = renderSummary(env)
+    expect(md.length).toBeLessThanOrEqual(SUMMARY_BUDGET_CHARS)
+    expect(md).toContain("m0: distinct issue number 0")
+    expect(md).toMatch(/… \d+ more finding\(s\) not shown/)
+    // Local output is complete.
</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: low priority, tracked. Assert indexOf(critical) < indexOf(suggestion).

if (hidden) {
lines.push(
`> … ${hidden} more finding(s) not shown to keep this comment short — the full list is in the verdict envelope ` +
"(`altimate review --json`, or the action's `--output` artifact).",

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: The bundled action does not pass --output, so this artifact is never created; point readers to the job log or explicit altimate review --json --output <file> usage.

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 packages/opencode/src/altimate/review/format.ts, line 149:

<comment>The bundled action does not pass `--output`, so this artifact is never created; point readers to the job log or explicit `altimate review --json --output <file>` usage.</comment>

<file context>
@@ -115,7 +109,90 @@ export function renderSummary(env: VerdictEnvelope): string {
+  if (hidden) {
+    lines.push(
+      `> … ${hidden} more finding(s) not shown to keep this comment short — the full list is in the verdict envelope ` +
+        "(`altimate review --json`, or the action's `--output` artifact).",
+      "",
+    )
</file context>
Suggested change
"(`altimate review --json`, or the action's `--output` artifact).",
"(`altimate review --json`, or the job log; use `--output <file>` when running the CLI directly).",

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: low priority, tracked (same as the kilo thread).

* whole batch of inline comments.
*/
export function anchorToDiff(findings: Finding[], files: ChangedFile[]): Finding[] {
const lines = new Map(files.map((f) => [f.path, commentableLines(f.diff)]))

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: Build commentableLines sets only for files with findings carrying startLine; this eagerly parses every changed diff even when no inline comment can be emitted.

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 packages/opencode/src/altimate/review/orchestrate.ts, line 253:

<comment>Build `commentableLines` sets only for files with findings carrying `startLine`; this eagerly parses every changed diff even when no inline comment can be emitted.</comment>

<file context>
@@ -206,6 +206,57 @@ export interface OrchestrateInput {
+ * whole batch of inline comments.
+ */
+export function anchorToDiff(findings: Finding[], files: ChangedFile[]): Finding[] {
+  const lines = new Map(files.map((f) => [f.path, commentableLines(f.diff)]))
+  return findings.map((f) => {
+    if (typeof f.startLine !== "number") return f
</file context>
Suggested change
const lines = new Map(files.map((f) => [f.path, commentableLines(f.diff)]))
const filesNeedingLines = new Set(findings.filter((f) => typeof f.startLine === "number").map((f) => f.file))
const lines = new Map(
files.filter((f) => filesNeedingLines.has(f.path)).map((f) => [f.path, commentableLines(f.diff)]),
)

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.

Not changing (see the kilo thread).

@kilo-code-bot

kilo-code-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

Kilo Code Review could not run — your account is out of credits.

Add credits or switch to a free model to enable reviews on this change.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4 issues found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. 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. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/opencode/test/altimate/review-noise.test.ts">

<violation number="1" location="packages/opencode/test/altimate/review-noise.test.ts:262">
P3: This test does not exercise the “not a lint-only run” behavior it names. Build the envelope through the moved-only review path, or add an assertion backed by a fixture that would fail if that path sets `degraded` or renders the lint-only banner.</violation>
</file>

<file name="packages/opencode/src/altimate/review/rule-catalog.ts">

<violation number="1" location="packages/opencode/src/altimate/review/rule-catalog.ts:1715">
P2: `portability: {}` suppresses the PIVOT/UNPIVOT warning for every known engine, even though this rule provides no verified support set. Populate `worksOn` with verified engines or retain portability findings when support is unknown so engine-specific failures are not hidden.</violation>

<violation number="2" location="packages/opencode/src/altimate/review/rule-catalog.ts:1888">
P2: Add DuckDB to `worksOn`; otherwise the new single-engine suppression still reports `FETCH FIRST` as non-portable on a dialect that supports it.</violation>
</file>

<file name="packages/opencode/src/altimate/review/format.ts">

<violation number="1" location="packages/opencode/src/altimate/review/format.ts:221">
P2: This note incorrectly claims every unchanged move has SQL that was not re-reviewed. `movedUnchangedFiles` also counts unchanged renames of YAML and other files, so the summary is misleading for those moves; describe unchanged content generically or restrict the counter to model files.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

"PIVOT/UNPIVOT is dialect-specific",
"`PIVOT`/`UNPIVOT` syntax varies by warehouse and is hard to test; consider conditional aggregation.",
{ added: /\b(pivot|unpivot)\s*\(/i },
{ added: /\b(pivot|unpivot)\s*\(/i, portability: {} },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: portability: {} suppresses the PIVOT/UNPIVOT warning for every known engine, even though this rule provides no verified support set. Populate worksOn with verified engines or retain portability findings when support is unknown so engine-specific failures are not hidden.

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 packages/opencode/src/altimate/review/rule-catalog.ts, line 1715:

<comment>`portability: {}` suppresses the PIVOT/UNPIVOT warning for every known engine, even though this rule provides no verified support set. Populate `worksOn` with verified engines or retain portability findings when support is unknown so engine-specific failures are not hidden.</comment>

<file context>
@@ -1703,7 +1712,7 @@ const STYLE: Rule[] = [
     "PIVOT/UNPIVOT is dialect-specific",
     "`PIVOT`/`UNPIVOT` syntax varies by warehouse and is hard to test; consider conditional aggregation.",
-    { added: /\b(pivot|unpivot)\s*\(/i },
+    { added: /\b(pivot|unpivot)\s*\(/i, portability: {} },
     { add: "from t pivot(sum(x) for k in ('a'))" },
     { add: "sum(case when k='a' then x end)" },
</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: low priority, tracked. Add a verified worksOn list.

Comment on lines +221 to +222
`${env.scope.movedUnchangedFiles} file(s) moved without edits; their SQL was not re-reviewed. ` +
"Folder-level config in `dbt_project.yml` (`+schema`, `+materialized`, `+tags`) can still change where and how a moved model builds.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This note incorrectly claims every unchanged move has SQL that was not re-reviewed. movedUnchangedFiles also counts unchanged renames of YAML and other files, so the summary is misleading for those moves; describe unchanged content generically or restrict the counter to model files.

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 packages/opencode/src/altimate/review/format.ts, line 221:

<comment>This note incorrectly claims every unchanged move has SQL that was not re-reviewed. `movedUnchangedFiles` also counts unchanged renames of YAML and other files, so the summary is misleading for those moves; describe unchanged content generically or restrict the counter to model files.</comment>

<file context>
@@ -216,6 +216,11 @@ export function coverageNotes(env: VerdictEnvelope): string[] {
     notes.push(`${env.scope.outOfScopeFiles} changed file(s) outside the dbt project were not reviewed.`)
+  if (env.scope?.movedUnchangedFiles)
+    notes.push(
+      `${env.scope.movedUnchangedFiles} file(s) moved without edits; their SQL was not re-reviewed. ` +
+        "Folder-level config in `dbt_project.yml` (`+schema`, `+materialized`, `+tags`) can still change where and how a moved model builds.",
+    )
</file context>
Suggested change
`${env.scope.movedUnchangedFiles} file(s) moved without edits; their SQL was not re-reviewed. ` +
"Folder-level config in `dbt_project.yml` (`+schema`, `+materialized`, `+tags`) can still change where and how a moved model builds.",
`${env.scope.movedUnchangedFiles} file(s) moved without edits; their unchanged contents were not re-reviewed. ` +
"For moved models, folder-level config in `dbt_project.yml` (`+schema`, `+materialized`, `+tags`) can still change where and how they build.",

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.

Not changing: wording nit.

"FETCH FIRST portability",
"`FETCH FIRST n ROWS` isn't supported everywhere; `LIMIT` (with ORDER BY) is more portable.",
{ added: /fetch\s+first\s+\d+/i },
{ added: /fetch\s+first\s+\d+/i, portability: { worksOn: ["postgres", "snowflake", "oracle", "trino"] } },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Add DuckDB to worksOn; otherwise the new single-engine suppression still reports FETCH FIRST as non-portable on a dialect that supports it.

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 packages/opencode/src/altimate/review/rule-catalog.ts, line 1888:

<comment>Add DuckDB to `worksOn`; otherwise the new single-engine suppression still reports `FETCH FIRST` as non-portable on a dialect that supports it.</comment>

<file context>
@@ -1876,7 +1885,7 @@ const MISC: Rule[] = [
     "FETCH FIRST portability",
     "`FETCH FIRST n ROWS` isn't supported everywhere; `LIMIT` (with ORDER BY) is more portable.",
-    { added: /fetch\s+first\s+\d+/i },
+    { added: /fetch\s+first\s+\d+/i, portability: { worksOn: ["postgres", "snowflake", "oracle", "trino"] } },
     { add: "fetch first 10 rows only" },
     { add: "limit 10" },
</file context>
Suggested change
{ added: /fetch\s+first\s+\d+/i, portability: { worksOn: ["postgres", "snowflake", "oracle", "trino"] } },
{ added: /fetch\s+first\s+\d+/i, portability: { worksOn: ["postgres", "snowflake", "oracle", "trino", "duckdb"] } },

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: low priority, tracked. The engine list will be verified before extending worksOn.


describe("moved files", () => {
test("moves are named in the comment with the folder-config caveat, and are not a lint-only run", async () => {
const env = buildEnvelope({

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 test does not exercise the “not a lint-only run” behavior it names. Build the envelope through the moved-only review path, or add an assertion backed by a fixture that would fail if that path sets degraded or renders the lint-only banner.

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 packages/opencode/test/altimate/review-noise.test.ts, line 262:

<comment>This test does not exercise the “not a lint-only run” behavior it names. Build the envelope through the moved-only review path, or add an assertion backed by a fixture that would fail if that path sets `degraded` or renders the lint-only banner.</comment>

<file context>
@@ -227,9 +248,24 @@ describe("portability noise", () => {
+
+describe("moved files", () => {
+  test("moves are named in the comment with the folder-config caveat, and are not a lint-only run", async () => {
+    const env = buildEnvelope({
+      findings: [],
+      tier: "trivial",
</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: low priority, tracked. Drive it through runReview.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. 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. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/opencode/test/altimate/review.test.ts">

<violation number="1" location="packages/opencode/test/altimate/review.test.ts:2144">
P2: This stub classifies every lineage target as `Email`, including `customer_id`, so the test can pass without reporting the intended `email` PII column. Return only `email` here, or assert that a finding identifies `email`.</violation>
</file>

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

]
},
async classifyPii(columns) {
return columns.map((column) => ({ column, classification: "Email", confidence: 0.95 }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This stub classifies every lineage target as Email, including customer_id, so the test can pass without reporting the intended email PII column. Return only email here, or assert that a finding identifies email.

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 packages/opencode/test/altimate/review.test.ts, line 2144:

<comment>This stub classifies every lineage target as `Email`, including `customer_id`, so the test can pass without reporting the intended `email` PII column. Return only `email` here, or assert that a finding identifies `email`.</comment>

<file context>
@@ -2127,6 +2127,41 @@ describe("orchestrate", () => {
+        ]
+      },
+      async classifyPii(columns) {
+        return columns.map((column) => ({ column, classification: "Email", confidence: 0.95 }))
+      },
+    }
</file context>
Suggested change
return columns.map((column) => ({ column, classification: "Email", confidence: 0.95 }))
return columns.filter((column) => column === "email").map((column) => ({ column, classification: "Email", confidence: 0.95 }))

const basePii = new Set(
(await input.runner.detectPii(currentCtx.engineOldSql, dialect)).columns.map((c) => c.toLowerCase()),
)
fallbackPii = fallbackPii.filter((col) => !basePii.has(col.toLowerCase()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Comparing output column names drops masking removal

detectPii returns the exposed output aliases (runner.ts prefers query_targets), not the expression behind them. A base select md5(email) as email … and a head select email … both report the alias email, so this filter classifies the head column as pre-existing and removes it — but the change removed the mask, which is exactly what pii_exposure is documented to cover (finding.ts:42: "PII column newly exposed / masking removed"). Before this PR the fallback surfaced that as a critical; now nothing else does, because the diff-scoped lane only looks at columns newly introduced by lineage (here the target email exists on both sides) and the catalog masking-removed rule only matches apply_masking/mask_column/masking_policy. Keep the column visible when the base and head aliases match but their values may differ — e.g. downgrade to a non-blocking warning like the baseUnknown path instead of dropping it.

const more = names.length > 8 ? ` (+${names.length - 8} more)` : ""
out.push({
text:
`- **${ruleTitle(g[0])}** — ${g.length} findings across ${names.length} model(s): ${shown}${more} \n` +

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: A grouped bullet still hides extra findings on an already-listed model

Grouping keys on ruleTitle(), which blanks backticked names, so it also merges several findings of one rule on the same model. When such a group reaches 3+ models this bullet renders only g[0]'s title and body while the header counts all g.length findings. Example: grain column a_id lacks not_null on A/B/C plus grain column d_id lacks not_null on A becomes one bullet that never names d_id. Those findings have no startLine (missingGrainTestLane sets none), so the summary is their only surface. When g.length > names.length, list each merged finding's column/title in the bullet (or keep same-model findings as their own bullets) instead of keeping only the first body.

"string interval literal portability",
"`interval '1 day'` literal syntax differs across warehouses; prefer dateadd/date_add functions.",
{ added: /interval\s+'\d+\s*\w+'/i },
{ added: /interval\s+'\d+\s*\w+'/i, portability: {} },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: portability: {} suppresses this rule on every known engine

With no worksOn, isSuppressiblePortability drops the finding for any dialect, so this rule is never shown once the engine is known. But interval '1 day' is not accepted everywhere — BigQuery and MySQL take an integer part (INTERVAL 1 DAY), so the regex matches SQL that genuinely errors there. That contradicts the PR's own rule that advice is kept when the construct fails on the project's engine. Declare the engines that accept the string form (e.g. worksOn: ["postgres", "snowflake", "redshift", "duckdb"]) so the rule still fires on the engines where it is a real error.

RaghwendraSingh and others added 3 commits November 21, 2026 13:14
… reposts, grouped rules, size budget, new-only PII, no portability noise

- Inline comments only on head-side lines inside the file's diff hunks;
  engine findings computed on compiled SQL no longer carry raw-file lines.
  Anything else moves to the summary instead of 422-ing the whole batch.
- Each inline comment carries `<!-- altimate-finding:<id> -->` (the
  line-independent fingerprint); a rerun skips findings already on the PR,
  and a non-blocking rerun with nothing new only updates the summary.
- The same rule on 3+ models collapses into one bullet listing the models.
- The posted summary has a ~5K-character budget, most severe first, with a
  count of what was left out (the envelope keeps everything); CLI and agent
  tool output stay complete.
- The PII fallback flags only columns the change newly exposes, not columns
  the base already surfaced.
- Cross-engine portability advice from the regex catalog is dropped once the
  engine is known (`portability: true` in review.yml re-enables it for
  multi-adapter packages); core's dialect-aware check is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s on the project's own engine; moved files are named

- catalog rules carry `portability: { worksOn? }` instead of the comment text being matched: `bq-legacy-sql` ("use Standard SQL") was being dropped on BigQuery projects
- with a known engine, portability advice is dropped only when that engine supports the construct; `DISTINCT ON` on Snowflake or `GROUP BY alias` on SQL Server stays, because it errors there
- files moved without edits are named in the comment, with the caveat that folder-level `dbt_project.yml` config can still change how they build
- a run with no model files (yml-only, pure moves) is no longer labeled lint-only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…me-model grouping

- PII lanes: when a modified model's base SQL can't be compiled, the head's
  PII columns can't be told apart from pre-existing ones. Both the
  `schema.detect_pii` fallback and the diff-scoped classifier now report them
  as non-blocking warnings (with a note) instead of blocking criticals. Docs
  state the caveat.
- Summary grouping counts distinct models, so several findings of one rule on
  the same model stay separate bullets instead of collapsing into the first.
- Tests for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
let headed = false
for (const b of bullets) {
const cost = b.text.length + 1 + (headed ? 0 : heading.join("\n").length + 2)
if (used + cost > maxChars) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A critical bullet that exceeds the budget is skipped while later, smaller bullets still render

When a bullet does not fit, the loop does hidden += b.count; continue without changing used, so every later bullet is still considered and a short warning/suggestion can fit after a critical was dropped. A single long critical body is realistic: columnBreakageLane joins every removed column and its downstream models into detail (orchestrate.ts:582-592), easily exceeding the whole 5K budget. The posted comment can then show suggestions while omitting a critical, contradicting the "Critical findings come first" promise in docs/docs/usage/dbt-pr-review.md:291 (and the hidden notice does not say a critical was hidden).

Stop rendering once a bullet of a given severity overflows (e.g. break, and skip lower severities when a higher-severity finding was hidden), so the visible set stays ordered by severity.

const col = p.column.toLowerCase()
const highConfidence = p.confidence >= 0.9
const severity: Severity = highExposureLayer && highConfidence && !lowRiskClass ? "critical" : "warning"
const severity: Severity = highExposureLayer && highConfidence && !lowRiskClass && !baseUnknown ? "critical" : "warning"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A base-unknown PII "warning" still blocks the gate at three columns

baseUnknown downgrades the finding to warning, but computeIdealVerdict returns REQUEST_CHANGES as soon as there are rubric.warningPatternThreshold (default 3) non-unknown warnings (verdict.ts:63-66). clampSeverity keeps the medium/high confidence set here, and this lane emits one finding per column (loop at line 1070), so a modified marts/ model with an uncompiled base exposing email, phone and ssn produces three warnings and blocks — exactly the outcome the new comment ("never blocking") and docs/docs/usage/dbt-pr-review.md:303 ("non-blocking warnings") say is avoided. The fallback piiLane also emits a single finding for the whole column set, so the two paths disagree for the same baseUnknown state.

Emit one aggregated finding per model like piiLane, or mark these findings confidence: "unknown" (excluded from the warning-pattern count) so an unverifiable base cannot gate.

"integer arithmetic on a date",
"`date + 7` (bare int) isn't portable and is ambiguous (days? seconds?); use dateadd/interval.",
{ added: /\b\w*(date|_at|_dt)\b\s*[+\-]\s*\d+\b/i },
{ added: /\b\w*(date|_at|_dt)\b\s*[+\-]\s*\d+\b/i, portability: { worksOn: ["postgres", "redshift", "snowflake", "duckdb", "oracle"] } },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: worksOn lists Postgres, but the regex also matches timestamp arithmetic that errors there

The pattern matches _at/_dt identifiers as well as date-like ones (\b\w*(date|_at|_dt)\b\s*[+\-]\s*\d+), while the worksOn list describes date arithmetic. Postgres defines date + integer but has no timestamp + integer operator, so created_at + 7 is an error on Postgres; tagging postgres as a supporting engine makes isSuppressiblePortability drop the finding there, hiding a real error — the opposite of the PR's "advice is kept when the construct fails on the project's own engine".

Split the date and timestamp cases (a date-only pattern plus this tag, and an untagged timestamp rule), or leave the tag off this rule until worksOn can express both.

@hkaltai hkaltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: changes requested. Panel: lead + Codex + Claude (independent reviewers). Tests pass locally (131 in the two review test files). Anchoring, fingerprint dedupe, and tag-based portability suppression look solid; the grouping defect below is the blocker.

Counts: 0 critical, 1 major, 5 minor, 3 nits.

Missing tests: mocked-Octokit tests for postGitHubReview (skip path, prior blocking review, listing failure, positioning fallback); grouping with differing bodies, mixed degraded/verified groups, and more than 8 models; orchestrator-level PII tests for the twin and warning-threshold cases; suppressPortability derivation in run.ts.

Also noted (no action required): uncapped rendering still limits grouped bullets to 8 model names (the body of the grouping finding covers this); the budget counts only finding bullets, so very long coverage notes or paths can push a summary past about 5K characters; runDegraded no longer marks nothing-reviewable runs as lint-only, which shifts the telemetry degraded value (reasonable, but not mentioned in the PR body).

Nits

  • post-github.ts:59-61: reviewSkipped doc says "previous non-blocking altimate review" but the code also matches blocking ones. Fix the comment or the code (see the inline finding).
  • orchestrate.ts:1307: (the docs promise "newly expose") points at docs wording. Prefer: "the fallback reports only columns the base did not already expose".
  • format.ts:120: const overflowReserve = 220 has no explanation; note it covers the "... N more" line. Also ruleTitle is really a normalized grouping key (groupKeyTitle), and GROUP_MIN reads better as GROUP_MIN_MODELS.
  • docs/docs/usage/dbt-pr-review.md (portability example): the comment says "default off once the engine is known", but an explicit portability: false also applies when the engine is unknown (falls back to the snowflake dialect). Leave the key commented out in the example.

function bulletsFor(items: Finding[]): Array<{ text: string; count: number }> {
const groups = new Map<string, Finding[]>()
for (const f of items) {
const key = `${f.category}|${ruleTitle(f)}`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MAJOR] Grouping merges findings with different bodies and shows only the first body

const key = `${f.category}|${ruleTitle(f)}`

The group key is category plus title with the model: prefix removed and backticked names blanked. The body is not part of the key. The quality lane titles findings ${model}: ${issue.rule} and puts the detail in the message (its own ruleKey includes the message so that distinct instances stay distinct). When 3+ models hit the same core rule with different messages, bulletsFor collapses them into one bullet that prints only g[0].body.

Failure scenario (reproduced by two reviewers): three sql_quality warnings titled a|b|c: dialect-unsupported-function with bodies for ILIKE, QUALIFY, IFF render as one bullet "3 findings across 3 model(s): a, b, c" followed only by the ILIKE text. Models b and c are wrongly attributed ILIKE; the QUALIFY/IFF details, per-finding file:line, and the _unverified_ marker are lost. This also happens in the uncapped CLI and agent-tool output, which the docs say is never truncated.

Suggested fix: include the normalized body (backticks blanked) in the group key, or group only rule-catalog findings whose bodies are static; keep _unverified_ when any member is degraded; do not group when maxChars === Infinity, or list each member's location.

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.

Good catch. The group key now includes the body with backticked names blanked (format.ts:177), so ILIKE/QUALIFY/IFF stay as three bullets with their own file:line. A grouped bullet keeps _unverified_ if any member is degraded, and uncapped CLI/agent output doesn't group at all (format.ts:130). Tests: "one rule with different messages per model is not merged into the first message", "a grouped bullet keeps unverified when any member is degraded", "more than eight models: ..." in review-noise.test.ts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — format.ts:177 now puts the blanked body in the group key; :190-191 shows a body verbatim only when all members match and :193 keeps _unverified_ if any member is degraded; uncapped output is not grouped (:130). Tests "one rule with different messages per model...", "keeps unverified...", and the eleven-model case fail when the fix is reverted. Residual nit only: blankNames blanks any backticked span (see review body).

const basePii = new Set(
(await input.runner.detectPii(currentCtx.engineOldSql, dialect)).columns.map((c) => c.toLowerCase()),
)
fallbackPii = fallbackPii.filter((col) => !basePii.has(col.toLowerCase()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] Regex PII twins still produce a critical for a pre-existing column

fallbackPii = fallbackPii.filter((col) => !basePii.has(col.toLowerCase()))

The broad fallback now drops base-exposed columns, but the regex twin pii_into_mart is reconciled separately and is not told about them. Reproduced by one reviewer: a whitespace-only edit of the line ssn in models/marts/m.sql (identical base and head output columns) removes the broad finding but pii_into_mart survives as critical, giving REQUEST_CHANGES. That contradicts the "newly exposed only" behavior for any reindent/reformat of a PII line in a mart.

Suggested fix: carry the base-exposed column set into the twin reconciliation (the token is already recovered via PII_TOKEN_RE) and suppress twins for those columns.

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.

Fixed. The base's PII columns are now worked out whenever there's a compiled base, and the pii_into_mart twin is dropped when its token is one of them (orchestrate.ts:1431). Covered by "a reindented PII line the base already exposed raises no regex twin" in review.test.ts, with a control case where the base didn't have ssn.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Partially fixed — orchestrate.ts:1431 now drops pii_into_mart when the base exposes the token and the regression test covers it. But the sibling select-pii-columns twin still fires for the same reindented line (3 such models give REQUEST_CHANGES by my reproduction), and with raw Jinja on both sides pii_into_mart is still critical because the base set is never populated. See the new inline comment at orchestrate.ts:1431.

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.

The select-pii-columns twin is now reconciled against the base as well, and the uncompiled path no longer stays critical. See 8003a3a and the reply on orchestrate.ts:1431.

const col = p.column.toLowerCase()
const highConfidence = p.confidence >= 0.9
const severity: Severity = highExposureLayer && highConfidence && !lowRiskClass ? "critical" : "warning"
const severity: Severity = highExposureLayer && highConfidence && !lowRiskClass && !baseUnknown ? "critical" : "warning"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] "Non-blocking" PII warnings still count toward the warning-pattern threshold

const severity: Severity = highExposureLayer && highConfidence && !lowRiskClass && !baseUnknown ? "critical" : "warning"

With an unavailable compiled base the finding is downgraded to warning, but it keeps its confidence, so computeIdealVerdict counts it toward warningPatternThreshold. Reproduced by one reviewer: a modified model with email, ssn, phone_number and no compiled base gives zero critical, three warnings, and REQUEST_CHANGES. The PR text calls these non-blocking.

Suggested fix: mark these findings as unknown confidence (or otherwise exclude them from the warning-pattern count), and add an orchestrator-level test.

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.

Agreed. When the base can't be compiled, both PII lanes now set confidence: "unknown" (orchestrate.ts:1050 and :1079), so computeIdealVerdict leaves them out of the warning count. Test: "PII warnings without a compiled base never add up to a block" (email + ssn + phone_number, no base, verdict isn't REQUEST_CHANGES).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Partially fixed — the classify lane (orchestrate.ts:1050) and fallback lane (:1079) now use confidence: "unknown" and the test covers the classify lane (the fallback lane has no test: reverting it to medium keeps everything green). The regex select-pii-columns warning stays high confidence and still counts toward the warning threshold (3 reindented models -> REQUEST_CHANGES). See the new inline comment at orchestrate.ts:1431.

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.

Both regex twins now use confidence: "unknown" when there is no compiled base, and the fallback lane has its own test. See 8003a3a.

octo.paginate(octo.rest.pulls.listReviews, { owner, repo, pull_number: prNumber, per_page: 100 }),
])
posted = postedFindingIds(reviewComments.map((c) => c.body))
priorBotReview = reviews.some((r) => BOT_REVIEW_RE.test(r.body ?? ""))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] The "skip a new review" rule also triggers after a blocking review

priorBotReview = reviews.some((r) => BOT_REVIEW_RE.test(r.body ?? ""))

BOT_REVIEW_RE matches Changes requested as well, and is not filtered by author, while the doc comment says the skip is for a previous non-blocking review. Scenario: push 1 gets REQUEST_CHANGES; push 2 fixes the critical and has no new inline comments, so no review is submitted and the newest altimate timeline entry still says "Changes requested" (only the edited summary shows the improvement).

Suggested fix: look only at the latest review by this bot, and skip only when its headline equals the current verdictHeadline(env) (or at least was not "Changes requested").

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.

Changed so it only looks at this bot's own latest review (the author comes from the summary comment we just upserted). It skips only if that review's headline is exactly the current verdictHeadline(env) (post-github.ts:119-143), so a prior "Changes requested" always gets a fresh review. Doc comment updated. Added mocked-Octokit tests under describe("postGitHubReview"): skip path, prior blocking review, other author, listing failure, 422 fallback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — post-github.ts:111-143 takes only this bot's own latest review (author from the upserted summary comment) and skips only when its body equals the current verdictHeadline(env); a prior "Changes requested" posts a fresh review. A mocked two-run round trip with the actual posted body also skipped correctly. Tests cover matching headline, prior blocking review, and another author.

// project that runs on one known engine. Core's dialect-aware check (a
// function missing on THIS engine) is a real error and is kept.
if (input.suppressPortability) findings = findings.filter((f) => !isSuppressiblePortability(f, dialect))
findings = anchorToDiff(findings, input.changedFiles)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] Diff anchoring strips line numbers from the whole envelope, not just the posted inline set

findings = anchorToDiff(findings, input.changedFiles)

A catalog or AI finding on line 40 of a model whose hunk covers lines 10-16 loses startLine in --json, the --output artifact, the CLI summary and the agent tool, although the location is correct for the file. Local consumers lose the location.

Suggested fix: keep startLine in the envelope and filter by commentable lines only when building inline comments in inlineComments/postGitHubReview.

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.

Done. anchorToDiff is gone, so startLine stays in the envelope, --json and the summary. inlineComments takes an optional map of commentable lines (format.ts:302), and postGitHubReview builds it from the PR's file patches (post-github.ts:131). If that listing fails, the existing 422 fallback still covers it. Tests: "a line outside the diff is not posted inline but keeps its location in the envelope" and "inline comments go only to lines inside the PR diff".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — anchorToDiff is gone from runReview, startLine stays in the envelope/--json/summary, and the filter is applied only when building inline comments (format.ts:302-313, post-github.ts:128-137). Tests cover an off-diff line staying in the envelope and inline comments going only to diff lines. One side effect is raised as a new minor at post-github.ts:132 (files without a patch).

"integer arithmetic on a date",
"`date + 7` (bare int) isn't portable and is ambiguous (days? seconds?); use dateadd/interval.",
{ added: /\b\w*(date|_at|_dt)\b\s*[+\-]\s*\d+\b/i },
{ added: /\b\w*(date|_at|_dt)\b\s*[+\-]\s*\d+\b/i, portability: { worksOn: ["postgres", "redshift", "snowflake", "duckdb", "oracle"] } },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] date-plus-int worksOn is too broad for the _at branch of the pattern

{ added: /\b\w*(date|_at|_dt)\b\s*[+\-]\s*\d+\b/i, portability: { worksOn: ["postgres", "redshift", "snowflake", "duckdb", "oracle"] } },

The pattern also matches timestamp columns such as updated_at + 1. date + int works on Postgres, but timestamp + integer does not. On a Postgres project select updated_at + 1 used to get the suggestion; now it is suppressed even though the SQL fails on the project's own engine, which is the case the tag is meant to keep.

Suggested fix: split the rule so the _at (timestamp) variant has no or a much shorter worksOn.

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.

Split it up. date-plus-int now matches only date/_dt, and the _at case is a new timestamp-plus-int rule with worksOn: ["oracle"] (rule-catalog.ts:1762), so it stays on Postgres, Snowflake and DuckDB. Test: "integer arithmetic on a timestamp is kept on Postgres; on a date it is not".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — rule-catalog.ts splits the rule: date-plus-int matches only date/_dt, and the new timestamp-plus-int has worksOn: ["oracle"], so updated_at + 1 keeps its suggestion on Postgres/Snowflake/DuckDB. Test "integer arithmetic on a timestamp is kept on Postgres; on a date it is not" covers it.

… quiet, review skip and inline anchoring tightened

- Summary grouping keys on the normalized body too, so one rule with
  different messages per model is no longer merged into the first message.
  A grouped bullet keeps `_unverified_` when any member is degraded and
  shows the body with names blanked when members differ only by name.
  Uncapped output (`maxChars: Infinity`) never groups. Renamed `ruleTitle`
  to `groupKeyTitle` and `GROUP_MIN` to `GROUP_MIN_MODELS`.
- PII: the base's exposed PII columns are computed whenever a compiled base
  exists and suppress both the broad fallback and the `pii_into_mart` regex
  twin, so a reindented `ssn` line in a mart no longer blocks.
- PII findings without a compiled base carry `unknown` confidence, so they
  no longer count toward `warningPatternThreshold`.
- `postGitHubReview` skips a new review only when this bot's latest review
  (author taken from the summary comment) has the same headline as the
  current verdict; a prior "Changes requested" no longer suppresses it.
  Octokit is injectable for tests.
- Findings keep `startLine` in the envelope; inline comments are filtered to
  commentable lines from the PR's file patches (`commentableLines` moved to
  `format.ts`, `anchorToDiff` removed).
- `date-plus-int` split: the `_at` timestamp variant is `timestamp-plus-int`
  with `worksOn: ["oracle"]`, so it is kept on Postgres/Snowflake/DuckDB.
- `shouldSuppressPortability` extracted from `run.ts`; docs example leaves
  `portability` commented out and explains explicit values.
- Tests: grouping (differing bodies, mixed degraded, blanked names, more
  than eight models), mocked-Octokit `postGitHubReview` (skip, prior
  blocking review, other author, diff filtering, listing failure, 422
  fallback), orchestrator PII (base-exposed twin, no-base warnings),
  timestamp rule, portability derivation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Review-body nits: All three are in. The reviewSkipped doc now matches the code (post-github.ts:66). The PII comment reads "The fallback reports only columns the base did not already expose." (orchestrate.ts:1283). overflowReserve has a note saying it's for the "... N more" line, and I renamed ruleTitle to groupKeyTitle and GROUP_MIN to GROUP_MIN_MODELS. In the docs example portability is now commented out, and the text says an explicit value applies even when the engine is unknown. I also pulled the run.ts derivation into shouldSuppressPortability and added a test for it ("unset follows whether the engine is known; an explicit value always wins").

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 8 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. 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. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/opencode/test/altimate/review-noise.test.ts">

<violation number="1" location="packages/opencode/test/altimate/review-noise.test.ts:365">
P2: This mock never exercises a second API page, so the new no-repost and inline-anchoring tests cannot catch a regression from paginated listings to first-page-only requests. Add multi-page responses and assert that page-two markers, fingerprints, and files affect the result.</violation>
</file>

<file name="packages/opencode/src/altimate/review/format.ts">

<violation number="1" location="packages/opencode/src/altimate/review/format.ts:177">
P2: This delimiter-concatenated grouping key is ambiguous when a title or body contains `|`, so distinct findings can collapse into one bullet. Build the grouped key from a structured tuple instead of concatenating unescaped text.</violation>
</file>

<file name="docs/docs/usage/dbt-pr-review.md">

<violation number="1" location="docs/docs/usage/dbt-pr-review.md:296">
P3: The grouping condition is normalized, not literal: `format.ts` blanks model/column names before comparing titles and bodies, so messages that differ only by those names are grouped. Document the normalized-message behavior to match the posted summary.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

throw new Error("listing failed")
}
const octo = {
paginate: async (fn: (p: unknown) => unknown, p: unknown) => fn(p),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This mock never exercises a second API page, so the new no-repost and inline-anchoring tests cannot catch a regression from paginated listings to first-page-only requests. Add multi-page responses and assert that page-two markers, fingerprints, and files affect the result.

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 packages/opencode/test/altimate/review-noise.test.ts, line 365:

<comment>This mock never exercises a second API page, so the new no-repost and inline-anchoring tests cannot catch a regression from paginated listings to first-page-only requests. Add multi-page responses and assert that page-two markers, fingerprints, and files affect the result.</comment>

<file context>
@@ -278,3 +344,147 @@ describe("moved files", () => {
+      throw new Error("listing failed")
+    }
+    const octo = {
+      paginate: async (fn: (p: unknown) => unknown, p: unknown) => fn(p),
+      rest: {
+        issues: {
</file context>

for (const f of items) {
// The body is part of the key: one rule with different messages (e.g. a
// dialect check naming different functions) is different findings.
const key = group ? `${f.category}|${groupKeyTitle(f)}|${blankNames(oneLine(f.body))}` : f.id

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This delimiter-concatenated grouping key is ambiguous when a title or body contains |, so distinct findings can collapse into one bullet. Build the grouped key from a structured tuple instead of concatenating unescaped text.

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 packages/opencode/src/altimate/review/format.ts, line 177:

<comment>This delimiter-concatenated grouping key is ambiguous when a title or body contains `|`, so distinct findings can collapse into one bullet. Build the grouped key from a structured tuple instead of concatenating unescaped text.</comment>

<file context>
@@ -153,19 +154,27 @@ export function renderSummary(env: VerdictEnvelope, opts: RenderOptions = {}): s
-    const key = `${f.category}|${ruleTitle(f)}`
+    // The body is part of the key: one rule with different messages (e.g. a
+    // dialect check naming different functions) is different findings.
+    const key = group ? `${f.category}|${groupKeyTitle(f)}|${blankNames(oneLine(f.body))}` : f.id
     const g = groups.get(key)
     if (g) g.push(f)
</file context>
Suggested change
const key = group ? `${f.category}|${groupKeyTitle(f)}|${blankNames(oneLine(f.body))}` : f.id
const key = group ? JSON.stringify([f.category, groupKeyTitle(f), blankNames(oneLine(f.body))]) : f.id

Comment on lines +296 to +297
three or more models is one bullet listing the models. Local CLI output lists
every finding with its location.

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: The grouping condition is normalized, not literal: format.ts blanks model/column names before comparing titles and bodies, so messages that differ only by those names are grouped. Document the normalized-message behavior to match the posted summary.

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 296:

<comment>The grouping condition is normalized, not literal: `format.ts` blanks model/column names before comparing titles and bodies, so messages that differ only by those names are grouped. Document the normalized-message behavior to match the posted summary.</comment>

<file context>
@@ -291,13 +292,15 @@ rubric:
-- **Repeated rules are grouped:** the same rule on three or more models is one
-  bullet listing the models.
+- **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
</file context>
Suggested change
three or more models is one bullet listing the models. Local CLI output lists
every finding with its location.
three or more models are grouped when their normalized rule/message matches; model and column names are ignored. Local CLI output lists every finding with its location.

: currentCtx.pii
findings.push(...piiLane(currentCtx.file, fallbackPii))
// The fallback reports only columns the base did not already expose.
fallbackPii = fallbackPii.filter((col) => !basePii.has(col.toLowerCase()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Comparing output aliases hides masking removal on an already-exposed column

basePii comes from detectPii(engineOldSql), and detectPii returns the exposed output aliases (runner.ts:239-248 prefers query_targets), not the expression behind them. A base select md5(email) as email … and a head select email … both report email, so the head column is filtered out here even though this change removed the mask — which is exactly what pii_exposure is documented to cover (finding.ts:42: "PII column newly exposed / masking removed"). The new twin suppression below (pii_into_mart, line 1431) drops the regex fallback for the same alias, and the diff-scoped lane only looks at newly introduced targets (email exists on both sides), so on tiers without semantic_change (trivial, or a reviewers list without it) nothing is reported at all. Compare the base vs head exposure expression/masking instead of only the alias, or downgrade to a non-blocking warning instead of dropping the column.

const diffScopedPiiFindingFiles = new Set<string>()
const classifiedPiiColumnsByFile = new Map<string, Set<string>>()
// Per file: PII columns the compiled base already exposed. Neither the broad
// fallback nor the regex twins report these (this PR did not expose them).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: select-pii-columns is not covered by the base-exposure suppression

This comment says "the regex twins" no longer report base-exposed columns, but only pii_into_mart consults basePiiColumnsByFile (line 1431). The sibling select-pii-columns branch (lines 1437-1441) returns true whenever diffScopedPiiFindingFiles is empty, which is exactly the reindent/whitespace case the precise lane reports nothing for. So a whitespace-only edit of + ssn still emits a "PII columns selected" warning for a column the base already exposed. Either carry the matched column on select-pii-columns and apply the same base-exposed check, or narrow this comment to pii_into_mart.

/* fall back to the positioning retry below */
}
const comments = inlineComments(env, posted, commentable)
result.inlineSkippedAsPosted = inlineComments(env, new Set(), commentable).length - comments.length

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Redundant second inlineComments pass just to count

This rebuilds every inline comment body (one template string per finding) and re-reads commentable solely to compute inlineSkippedAsPosted, which is all − comments. A single pass over env.findings (commentable line && posted.has(id)) gives the same number without constructing the bodies twice, and makes the "already on the PR" meaning explicit.

@hkaltai hkaltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: changes requested. Panel: lead + Codex + Claude (independent reviewers, fresh sessions), re-review at c7a166b (previous review at 0b216f2). The grouping blocker and four of the five minors are fixed with regression tests (145 tests in the two review files pass; typecheck clean). One PII item is only partly fixed and is still reproducible, so I'm keeping the request.

Counts (open): 0 critical, 2 major, 1 minor (+ the body items below), nits listed at the end.

Status of prior findings

Prior item Status
MAJOR grouping ignores body Fixed (body in the key, _unverified_ kept, uncapped output not grouped). Residual nit below.
MINOR pii_into_mart on pre-existing column Partially fixed: pii_into_mart is now dropped, but the sibling select-pii-columns still fires (see new inline comment)
MINOR non-blocking PII warnings count toward threshold Partially fixed: classify and fallback lanes are unknown now; the regex select-pii-columns warning is still high and counts
MINOR skip-review after Changes requested Fixed
MINOR anchoring strips envelope lines Fixed
MINOR date-plus-int too broad Fixed (split into timestamp-plus-int)
Body: grouped names cap in uncapped output Fixed (uncapped output no longer groups)
Body: size budget covers only bullets Not fixed (still minor; reproduced a 6.8K summary with no findings, only five long coverage-note paths; the no-findings early return skips the budget)
4 prior nits (doc comment, docs promise comment, overflowReserve/renames, docs portability example) All fixed

Missing tests: reindented PII line across 3 models asserting no pii_exposure findings at all (the current test only checks no pii_into_mart / no critical); a fallback-lane (schema.detect_pii) test for confidence: "unknown" (changing line 1079 back to "medium" keeps every test green); listFiles entry with no patch; a twin case where a base-exposed column precedes a newly added one.

Nits

  • format.ts:157-159 (blankNames): s.replace(/`[^`]*`/g, "`…`") blanks every backticked span, not only model/column names, so findings that differ only in a backticked SQL token would still merge into one bullet. I could not reproduce this with real core output (the lint messages I could inspect do not backtick function names), so it is a nit, not a blocker. Consider blanking only the model/column names, or renaming the helper.
  • PR description is stale: it still says a finding keeps its line only if it is inside the diff (the envelope now keeps it; only inline posting filters), and the non-blocking rerun rule now also needs the same headline as the bot's last review.
  • orchestrate.ts:1079: the fallback-lane confidence: "unknown" has no test (see Missing tests).
  • post-github.ts lastBotHeadline holds the whole review body, not only the headline; fine today, but lastBotReviewBody would be accurate.
  • Splitting timestamp-plus-int changes the fingerprint for _at findings, so those inline comments repost once after upgrade (expected, worth a line in the PR description).

if (token && classifiedPiiColumnsByFile.get(f.file)?.has(token)) return false
// A column the base already exposed (e.g. a reindented `ssn` line) is
// not newly exposed by this PR.
if (token && basePiiColumnsByFile.get(f.file)?.has(token)) return false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MAJOR] A reindented PII line the base already exposed still blocks (sibling select-pii-columns twin, and the uncompiled path)

if (token && basePiiColumnsByFile.get(f.file)?.has(token)) return false

The base-exposure check only covers pii_into_mart. The select-pii-columns twin (the branch just below, diffScopedPiiFindingFiles.has(f.file)) is suppressed only when a precise detector emitted a finding, so for a file whose base and head expose the same columns it survives as warning / high. The PR states PII is flagged only for newly exposed columns.

Reproduced by me (and independently by both external reviewers) by adding a probe test next to the new "reindented PII line" test, same runner/fixtures:

  • 3 mart models, each a whitespace-only edit of the existing ssn line, default reviewers, gate mode: REQUEST_CHANGES with 3 x warning/high/select-pii-columns (the warning-pattern threshold is hit). One model alone gives a single non-blocking warning.
  • Same single model, but raw Jinja on both sides (no compiled artifacts, the documented "base can't be compiled" path): REQUEST_CHANGES with critical/high/pii_into_mart + warning/high/select-pii-columns. basePiiColumnsByFile is never populated there, so nothing suppresses the twin and nothing marks it uncertain. The docs and the author's earlier reply both say this path is reported as non-blocking.

The new regression test misses this because it asserts only !pii_into_mart, no critical, and verdict !== REQUEST_CHANGES for a single file with compiled SQL.

Suggested fix: apply the same base-exposure reconciliation to select-pii-columns (keep the matched column(s) in the catalog evidence, drop the finding when all are in the base set), and when hasOldSide && !engineOldSql downgrade both twins to warning with confidence: "unknown" like the other two lanes. Extend the test to three models and to the uncompiled case, asserting no pii_exposure finding / no REQUEST_CHANGES.

Related (minor, same spot): dbt-patterns.ts builds the twin from the first matching added line only, so a reindented base column followed by a genuinely new passport line gets the twin suppressed on the first token and the new high-risk column drops from critical to a warning (reproduced by one reviewer with pinned dbt_patterns + core failure; the default broad fallback still catches it). Either pass the base set into the detector or emit one finding per hit.

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.

Fixed in 8003a3a.

  • select-pii-columns now keeps its matched columns in evidence.result.columns (new capturesColumns flag, rule-catalog.ts:114 and :1224). The merge step drops it when the compiled base already exposed all of them (orchestrate.ts:1437).
  • When the base can't be compiled (hasOldSide && !engineOldSql), both pii_into_mart and select-pii-columns become warning with confidence: "unknown", the same as the classify and fallback lanes (orchestrate.ts:1471).
  • Related minor: detectPiiIntoMart now emits one finding per added PII line (dbt-patterns.ts:305). A reindented base ssn no longer hides a new passport. The findings share a fingerprint, so dedupe keeps the most severe one that survives suppression.

Tests in test/altimate/review.test.ts:

  • "a reindented PII line the base already exposed raises no regex twin": now three mart models, default and pinned dbt_patterns, gate mode. Asserts no pii_exposure finding and no REQUEST_CHANGES. A control case asserts both twins still fire when the base lacked ssn.
  • "a new PII column next to a reindented base one keeps its own critical twin": passport stays critical.
  • "without a compiled base the regex PII twins are unknown-confidence warnings that never block": raw Jinja on both sides, three models. Asserts no critical and no REQUEST_CHANGES.
  • "the broad PII fallback without a compiled base is an unknown-confidence warning": fails if orchestrate.ts:1079 is reverted to medium.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Partially fixed — at 8003a3a the reproductions I raised pass: a reindented plain or qualified ssn across 3 marts gives no pii_exposure findings (gate, reviewers [] and ["dbt_patterns"]), raw Jinja on both sides gives unknown-confidence warnings that do not block, and a new column on its own line next to a reindented base one keeps its critical twin (orchestrate.ts:1431-1440, rule-catalog.ts:114-123, tests in review.test.ts "reindented PII line…"). But both twins still compare the source token with basePiiColumnsByFile, which holds output aliases (runner.ts:240-247). Reindenting c.ssn as tax_ref (or c.email as contact) in 3 marts with the real core engine still gives REQUEST_CHANGES. See the new inline comment.

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.

The remaining part (source token vs output alias) is fixed in b8022af. See the reply on the new inline comment. The alias reindent repro (c.ssn as tax_ref / c.email as contact in 3 marts, gate, reviewers [] and ["dbt_patterns"]) is now a test and gives no PII findings and no REQUEST_CHANGES. One change to an existing test: "without a compiled base the regex PII twins are unknown-confidence warnings that never block" now uses an added ssn line. A pure reindent is now dropped outright, even with raw Jinja on both sides.

let commentable: Map<string, Set<number>> | undefined
try {
const files = await octo.paginate(octo.rest.pulls.listFiles, { owner, repo, pull_number: prNumber, per_page: 100 })
commentable = new Map(files.map((f) => [f.filename, commentableLines(f.patch)]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] Files with no patch from listFiles lose all inline comments

commentable = new Map(files.map((f) => [f.filename, commentableLines(f.patch)]))

GitHub omits patch for large or binary-like diffs. commentableLines(undefined) returns an empty set, so every finding in such a file is filtered out of the inline set even on lines that are in the PR diff. The removed anchorToDiff used the local full diff and did not have this gap; the large model rewrites that most need inline comments are the ones affected. The summary still lists them, but inlineSkippedAsPosted and telemetry do not show the drop.

Suggested fix: add only files that have a patch to the map and treat a missing entry as unknown (attempt the comment and rely on the existing 422 fallback), or fall back to the local ChangedFile.diff for those files.

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.

Fixed in 8003a3a. post-github.ts:133 now adds only files that have a patch to the map. In inlineComments (format.ts:314), a file with no entry counts as unknown, so its comments are attempted and the existing 422 fallback handles a miss. Test: "a file GitHub lists without a patch keeps its inline comments" (test/altimate/review-noise.test.ts:435), using a mocked listFiles that returns one file without patch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — post-github.ts:133 now keeps only files with a patch in the map and format.ts:314 attempts lines of files with no entry; regression at review-noise.test.ts:435 fails if the filter is reverted. One residual (new MINOR below): a positioning 422 caused by a patchless-file line makes the fallback drop every inline comment, including the verified ones.

…e comments on patchless files

- `select-pii-columns` now carries its matched columns on
  `evidence.result.columns` (new `capturesColumns` catalog flag) and is dropped
  when the compiled base already exposed every one of them
- `pii_into_mart` emits one finding per added PII line, so a reindented base
  column no longer hides a genuinely new high-risk column on another line
  (shared fingerprint: dedupe keeps the most severe survivor)
- without a compiled base (raw Jinja on the old side) both twins are reported
  as `warning` with `confidence: "unknown"`, like the other PII lanes, so they
  never block or count toward the warning-pattern threshold
- `postGitHubReview` maps only files that have a `patch`; a file GitHub lists
  without one (large diff) has unknown hunks and its inline comments are
  attempted, relying on the existing 422 fallback

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 7 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. 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. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/opencode/src/altimate/review/post-github.ts">

<violation number="1" location="packages/opencode/src/altimate/review/post-github.ts:133">
P2: Filtering patchless files makes a missing PR path indistinguishable from a listed file with unknown hunks. `inlineComments` then submits stale or non-head paths, and one such 422 drops every inline comment in the batch; preserve every listed filename with an explicit unknown-patch marker and exclude paths absent from a successful listing.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

let commentable: Map<string, Set<number>> | undefined
try {
const files = await octo.paginate(octo.rest.pulls.listFiles, { owner, repo, pull_number: prNumber, per_page: 100 })
commentable = new Map(files.filter((f) => f.patch).map((f) => [f.filename, commentableLines(f.patch)]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Filtering patchless files makes a missing PR path indistinguishable from a listed file with unknown hunks. inlineComments then submits stale or non-head paths, and one such 422 drops every inline comment in the batch; preserve every listed filename with an explicit unknown-patch marker and exclude paths absent from a successful listing.

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 packages/opencode/src/altimate/review/post-github.ts, line 133:

<comment>Filtering patchless files makes a missing PR path indistinguishable from a listed file with unknown hunks. `inlineComments` then submits stale or non-head paths, and one such 422 drops every inline comment in the batch; preserve every listed filename with an explicit unknown-patch marker and exclude paths absent from a successful listing.</comment>

<file context>
@@ -125,11 +125,12 @@ export async function postGitHubReview(
   try {
     const files = await octo.paginate(octo.rest.pulls.listFiles, { owner, repo, pull_number: prNumber, per_page: 100 })
-    commentable = new Map(files.map((f) => [f.filename, commentableLines(f.patch)]))
+    commentable = new Map(files.filter((f) => f.patch).map((f) => [f.filename, commentableLines(f.patch)]))
   } catch {
     /* fall back to the positioning retry below */
</file context>

@hkaltai hkaltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: changes requested. Panel: lead + Codex + Claude (independent fresh sessions), re-review at 8003a3a (previous review at c7a166b). The three reproductions are fixed for the plain case, but an aliased PII column still blocks, which I reproduced with the real engine. 149/149 tests in the two review files pass.

Open: 0 critical, 1 major, 3 minor (2 inline, 1 body-only), nits below.

Status of prior findings

Prior item Status
MAJOR select-pii-columns / uncompiled path on reindented PII Partially fixed: 3 marts reindent (plain and c.-qualified) gives no findings; raw Jinja both sides gives non-blocking unknown warnings; new column on its own line next to a reindented base one keeps its critical. Still blocks for aliased columns (new MAJOR)
MAJOR first-hit-only dbt-patterns twin hides a new column Fixed for separate lines (one finding per line). Same-line case remains (new MINOR)
MINOR patchless listFiles entry loses inline comments Fixed, with a residual collateral-422 loss (new MINOR)
Body: size budget covers only bullets Not fixed (MINOR): format.ts:112-115 no-findings return is unbudgeted and coverageNotes is uncapped; an empty envelope with five long unverified paths renders 6,835 chars vs the 5,000 budget. Cap/budget the header, notes and footer
Nit: PR description stale Fixed (description now matches)
Nit: missing fallback-lane unknown test Fixed (reverting to "medium" fails it)
Nit: blankNames over-blanking Not fixed (still a nit)
Nit: lastBotHeadline name Not fixed (still a nit)
Nit: one-time repost after timestamp-plus-int split Not fixed (not documented)

Regression tests: each fix in the delta has a test that fails when it is reverted (verified by mutation by both external reviewers).

Nits

  • post-github.ts:128-130: comment says patchless files "rely on the 422 fallback"; that fallback drops all inline comments (see the MINOR).
  • orchestrate.ts:1425: "pii_into_mart carries the matched column in result.line" is imprecise: it carries the whole line and only the first PII token is used.
  • dbt-patterns.ts:316: "each carries its own column" overstates for lines with several columns.
  • format.ts:159 (blankNames): s.replace(/`[^`]*`/g, "`…`") blanks every backticked span; consider blankBacktickedSpans or blanking only model/column names.
  • post-github.ts:111,122 lastBotHeadline holds the whole body; lastBotReviewBody is accurate.
  • timestamp-plus-int changes the fingerprint for _at findings, so those inline comments repost once after upgrade; worth a line in the PR description.
  • Design note, not a finding: with raw Jinja on the old side and no compiled base, a genuinely new ssn/passport in a mart is now a non-blocking unknown warning (previously critical). That is deliberate and documented; consider a raw-text check of the old side (token absent from old raw SQL means new) to keep the block for clearly new columns.
  • Missing tests: alias reindent with a runner returning output aliases; same-line multi-column; patchless file plus 422; empty-findings summary over budget.

// `select-pii-columns` keeps its matched columns: drop it when the base
// already exposed every one of them.
const columns: string[] = (f.evidence?.result as any)?.columns ?? []
const basePii = basePiiColumnsByFile.get(f.file)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MAJOR] A reindented PII column written with an alias still blocks (both regex twins)

const basePii = basePiiColumnsByFile.get(f.file)
if (columns.length && basePii && columns.every((c) => basePii.has(c))) return false

Both twins compare the source token found on the line (ssn, email) with basePiiColumnsByFile, which comes from runner.detectPii and holds the output aliases (runner.ts:240-247: "SELECT email AS contact ... prefer the aliases"). The new tests use a fake detectPii that returns source names (sql.includes(c)), so they never see this.

Reproduction against the real orchestrator and the real altimate-core engine (Snowflake manifest): base and head both select c.customer_id, c.email as contact, c.ssn as tax_ref from customers c, a whitespace-only reindent of c.ssn as tax_ref in 3 marts, gate mode, reviewers [] and ["dbt_patterns"]. Real detectPii returns ["tax_ref","contact"], so ssn is not in the base set: 3 x critical pii_into_mart + 3 x select-pii-columns -> REQUEST_CHANGES. Reindenting c.email as contact gives 6 high-confidence warnings -> REQUEST_CHANGES via the warning-pattern threshold. Control with plain c.ssn -> APPROVE. Aliasing PII in marts is routine in dbt, and this is exactly the noise (a whitespace-only PR blocked by PII it did not add) the PR exists to remove. Codex and Claude both reproduced it independently, and so did I.

Suggested fix: also reconcile the as <alias> target from the line (result.line / captured lines) against the base set, or drop a twin whose whitespace-normalised added line appears verbatim among the removed lines / in the base SQL. Make the test runner return output aliases like the real one and add the alias reindent case.

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.

Fixed in b8022af. Both twins now pair each PII token with the AS alias of its select item (selectItemColumns, rule-catalog.ts:145). A token counts as already exposed when the base output has its alias or its source column (isBaseExposed, orchestrate.ts:1419). We match on either one because the base exposing tax_ref built from ssn means that PII was already in the output, and a renamed alias doesn't expose anything new. As a fallback that doesn't depend on detection, a twin is also dropped when its comment- and whitespace-normalised line appears among the file's removed lines (isReindented, orchestrate.ts:1407). The test runner's detectPii/columnLineage now return output aliases the way runner.ts does. New tests in review.test.ts:

  • "a reindented aliased PII column in three marts raises no twin and does not block": c.ssn as tax_ref and c.email as contact, across 3 marts, gate, reviewers [] and ["dbt_patterns"], no pii_exposure findings and no REQUEST_CHANGES
  • "an aliased PII line whose alias the base exposes raises no twin even when not a pure reindent": alias path only (c. → cust.), with a control where adding the line keeps both twins and pii_into_mart stays critical
  • "a pure reindent drops the regex twins even when base PII detection misses the column": reindent path only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — real altimate-core engine (Snowflake, customers schema), 3 marts, gate mode, reviewers [] and ["dbt_patterns"]: reindent of c.ssn as tax_ref and of c.email as contact, now gives no PII findings and APPROVE (both were REQUEST_CHANGES at 8003a3a). Unaliased/qualified reindent, quoted-alias, cast-alias and reindent-plus-comment variants also pass, and a genuinely new aliased ssn/passport stays critical. The fix introduces a separate over-suppression, raised as a new MAJOR at orchestrate.ts:1421.

const s = stripComments(l)
if (rule.unless?.test(s)) continue
const col = rule.added?.exec(s)?.[1]
if (col) cols.add(col.toLowerCase())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] A new PII column on the same line as a base column is dropped by both regex twins

const col = rule.added?.exec(s)?.[1]
if (col) cols.add(col.toLowerCase())

capturedColumns keeps only the first capture per line, and pii_into_mart only uses the first PII token on the line (orchestrate.ts:1431). For - ssn / + ssn, passport with base ssn, both resolve to ssn, which the base exposes, so both are suppressed and passport is reported by neither (reviewers ["dbt_patterns"], classifier returning nothing: no PII findings, APPROVE; at c7a166b a select-pii-columns warning was still emitted, so this round narrowed recall). Only MINOR because with default reviewers the core classifier / broad fallback reports the new column; it bites when the classifier misses a column, which is what the regex twins are for.

Suggested fix: use a global match in both places, collect every PII token per line, suppress only when all are in the base, and emit one finding per new token. Add a same-line test.

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.

Fixed in b8022af. capturedColumns (rule-catalog.ts:176) and pii_into_mart (dbt-patterns.ts:320) now collect every PII token on the line instead of only the first. select-pii-columns is suppressed only when every item is base-exposed or reindented (orchestrate.ts:1459). pii_into_mart emits one finding per token, carrying column/alias. These share a fingerprint, so dedupe keeps the most severe. Test: "a new PII column on the same line as a base-exposed one keeps its twins" (- ssn / + ssn, passport keeps a critical pii_into_mart for passport, and the both-in-base control reports nothing).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — real engine: - c.ssn as tax_ref / + c.ssn as tax_ref, c.passport as travel_doc with only ssn in the base keeps a critical pii_into_mart for passport (reviewers ["dbt_patterns"]). Regression test at review.test.ts ("a new PII column on the same line…") fails when token collection is reverted to first-hit. Residual literal-parsing edge raised as a new MINOR.

let commentable: Map<string, Set<number>> | undefined
try {
const files = await octo.paginate(octo.rest.pulls.listFiles, { owner, repo, pull_number: prNumber, per_page: 100 })
commentable = new Map(files.filter((f) => f.patch).map((f) => [f.filename, commentableLines(f.patch)]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] One patchless file can now cost every inline comment

commentable = new Map(files.filter((f) => f.patch).map((f) => [f.filename, commentableLines(f.patch)]))

Lines of patchless files are now sent in the same createReview batch as verified lines. If GitHub rejects one of them with a positioning 422, the fallback (post-github.ts ~166-189) re-posts with no comments at all, so valid comments on normal files that the previous code kept are lost too (mocked API: first attempt has known.sql:3 and big.sql:900, the retry has neither). Patch is omitted precisely for very large diffs, where line resolution is least reliable.

Suggested fix: on a positioning 422, retry once with only the comments on files whose hunks are known before falling back to none; add a test with a patchless file plus a 422.

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.

Fixed in b8022af. On a positioning 422, postGitHubReview now retries once with only the comments on files whose hunks are known (post-github.ts:186). It falls back to an event-only review only if that retry also fails. Test in review-noise.test.ts: "a positioning 422 with a patchless file retries with the verified comments first". The first attempt has known.sql:3 and big.sql:900, and the retry keeps known.sql:3. A second 422 then gives an event-only review. (Restacking surfaced one gap: a successful retry skipped dismissing stale blocking reviews; #1723 now calls dismissStale() on that path too.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Fixed — post-github.ts:186-202 retries once with only verified-file comments before the event-only fallback; the review-noise.test.ts test fails if the retry is removed or resends every comment. Nit: the retry's exception is discarded, so a non-positioning failure there leaves postError unset if the event-only post then succeeds.

…p verified inline comments on a 422

- `pii_into_mart` and `select-pii-columns` now pair each PII token with its
  select item's `AS` alias (`selectItemColumns`) and suppress it when the base
  exposes either the alias or the source column, since `detectPii` reports
  output aliases (`c.ssn as tax_ref` -> `tax_ref`)
- both twins also drop a line whose comment/whitespace-normalised text is among
  the file's removed lines (pure reindent), independent of base PII detection
- both twins collect every PII token on a line, not just the first: `ssn, passport`
  with a base-exposed `ssn` still reports `passport`; `pii_into_mart` emits one
  finding per token (shared fingerprint, so dedupe keeps the most severe)
- `postGitHubReview`: on a positioning 422, retry once with only the comments on
  files whose hunks are known before falling back to an event-only review
- the test runner's `detectPii`/`columnLineage` fakes return output aliases like
  the real runner; the raw-Jinja test uses an added line, since a pure reindent
  is now dropped outright

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4 issues found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. 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. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/opencode/src/altimate/review/post-github.ts">

<violation number="1" location="packages/opencode/src/altimate/review/post-github.ts:198">
P3: When the verified-only retry succeeds, this returns `inlineFellBack: true` even though some inline comments were posted. The CLI therefore tells users that comments fell back to summary-only; distinguish partial fallback from total fallback in `PostResult` and update the status text.</violation>
</file>

<file name="packages/opencode/src/altimate/review/rule-catalog.ts">

<violation number="1" location="packages/opencode/src/altimate/review/rule-catalog.ts:129">
P1: `selectItemColumns` parses quoted SQL text as commas and `AS` aliases, so a literal containing a PII word can become an extra finding or a real alias can be mismatched during base reconciliation. Mask quoted strings/identifiers before splitting and alias extraction, while preserving the original text for token matching.</violation>
</file>

<file name="packages/opencode/src/altimate/review/orchestrate.ts">

<violation number="1" location="packages/opencode/src/altimate/review/orchestrate.ts:1410">
P1: This comparison ignores the line's hunk or position, so a real move can suppress the only regex PII finding when the precise classifier misses the column. Restrict reindent matching to the corresponding diff location or verify the base output structurally before suppressing the finding.</violation>
</file>

<file name="packages/opencode/src/altimate/review/dbt-patterns.ts">

<violation number="1" location="packages/opencode/src/altimate/review/dbt-patterns.ts:320">
P2: `selectItemColumns` scans through `FROM`, so `email from ssn` produces PII columns `email` and `ssn` even though `ssn` is the source relation. The spurious sensitive token can survive suppression and create a critical block; stop token extraction at the top-level `FROM`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

let depth = 0
let start = 0
for (let i = 0; i < s.length; i++) {
if (s[i] === "(") depth++

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: selectItemColumns parses quoted SQL text as commas and AS aliases, so a literal containing a PII word can become an extra finding or a real alias can be mismatched during base reconciliation. Mask quoted strings/identifiers before splitting and alias extraction, while preserving the original text for token matching.

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 packages/opencode/src/altimate/review/rule-catalog.ts, line 129:

<comment>`selectItemColumns` parses quoted SQL text as commas and `AS` aliases, so a literal containing a PII word can become an extra finding or a real alias can be mismatched during base reconciliation. Mask quoted strings/identifiers before splitting and alias extraction, while preserving the original text for token matching.</comment>

<file context>
@@ -110,16 +112,75 @@ export function ruleMatches(rule: Rule, input: RuleInput): boolean {
+  let depth = 0
+  let start = 0
+  for (let i = 0; i < s.length; i++) {
+    if (s[i] === "(") depth++
+    else if (s[i] === ")") depth = Math.max(0, depth - 1)
+    else if (s[i] === "," && depth === 0) {
</file context>

const isReindented = (file: string, line: string) => {
let removed = removedLinesByFile.get(file)
if (!removed) {
removed = new Set(splitDiff(ctxByPath.get(file)?.file.diff).removed.map(normalizeSelectLine).filter(Boolean))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: This comparison ignores the line's hunk or position, so a real move can suppress the only regex PII finding when the precise classifier misses the column. Restrict reindent matching to the corresponding diff location or verify the base output structurally before suppressing the finding.

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 packages/opencode/src/altimate/review/orchestrate.ts, line 1410:

<comment>This comparison ignores the line's hunk or position, so a real move can suppress the only regex PII finding when the precise classifier misses the column. Restrict reindent matching to the corresponding diff location or verify the base output structurally before suppressing the finding.</comment>

<file context>
@@ -1405,6 +1401,25 @@ export async function runReview(input: OrchestrateInput): Promise<VerdictEnvelop
+  const isReindented = (file: string, line: string) => {
+    let removed = removedLinesByFile.get(file)
+    if (!removed) {
+      removed = new Set(splitDiff(ctxByPath.get(file)?.file.diff).removed.map(normalizeSelectLine).filter(Boolean))
+      removedLinesByFile.set(file, removed)
+    }
</file context>

// each carries its column, `AS` alias and line in `result` so the orchestrator
// can suppress a base-exposed column without hiding a new one beside it. They
// share a fingerprint, so dedupe keeps the most severe survivor.
return hits.flatMap((hit) => selectItemColumns(hit, PII_RE)).map(({ column, alias, line }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: selectItemColumns scans through FROM, so email from ssn produces PII columns email and ssn even though ssn is the source relation. The spurious sensitive token can survive suppression and create a critical block; stop token extraction at the top-level FROM.

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 packages/opencode/src/altimate/review/dbt-patterns.ts, line 320:

<comment>`selectItemColumns` scans through `FROM`, so `email from ssn` produces PII columns `email` and `ssn` even though `ssn` is the source relation. The spurious sensitive token can survive suppression and create a critical block; stop token extraction at the top-level `FROM`.</comment>

<file context>
@@ -313,14 +313,14 @@ const detectPiiIntoMart: Detector = (c) => {
+  // each carries its column, `AS` alias and line in `result` so the orchestrator
+  // can suppress a base-exposed column without hiding a new one beside it. They
+  // share a fingerprint, so dedupe keeps the most severe survivor.
+  return hits.flatMap((hit) => selectItemColumns(hit, PII_RE)).map(({ column, alias, line }) => {
     // Highly-sensitive identifiers (SSN/financial/passport/DOB) into a broadly-read
     // marts layer are critical; softer PII (email/phone/name) is a warning.
</file context>

body: reviewBody,
comments: verified,
})
result.reviewId = r.data.id

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: When the verified-only retry succeeds, this returns inlineFellBack: true even though some inline comments were posted. The CLI therefore tells users that comments fell back to summary-only; distinguish partial fallback from total fallback in PostResult and update the status text.

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 packages/opencode/src/altimate/review/post-github.ts, line 198:

<comment>When the verified-only retry succeeds, this returns `inlineFellBack: true` even though some inline comments were posted. The CLI therefore tells users that comments fell back to summary-only; distinguish partial fallback from total fallback in `PostResult` and update the status text.</comment>

<file context>
@@ -180,6 +180,27 @@ export async function postGitHubReview(
+          body: reviewBody,
+          comments: verified,
+        })
+        result.reviewId = r.data.id
+        return result
+      } catch {
</file context>

@hkaltai hkaltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: changes requested. Panel: lead + Codex + Claude (independent fresh sessions), re-review at b8022af (previous review at 8003a3a). All three prior inline findings are fixed and every reproduction requested now behaves as intended on the real altimate-core engine, but the alias fix over-suppresses a genuinely new PII exposure. 154/154 tests in the two review files pass.

Open: 0 critical, 1 major, 3 minor inline, 1 minor body-only, nits below.

Real-engine reproductions at b8022af (Snowflake, customers schema, gate mode, reviewers [] and ["dbt_patterns"])

Case Result
c.ssn as tax_ref reindent, 3 marts APPROVE, no PII findings (was REQUEST_CHANGES)
c.email as contact reindent, 3 marts APPROVE, no PII findings (was REQUEST_CHANGES)
Unaliased ssn / c.ssn reindent, 3 marts APPROVE
Raw Jinja both sides, reindent (plain and aliased) APPROVE
New passport on its own line beside reindented ssn Reported (classifier warning)
New passport on the same line as ssn Reported (classifier warning); c.ssn as tax_ref, c.passport as travel_doc keeps critical pii_into_mart for passport
Genuinely new aliased ssn / passport Still critical, REQUEST_CHANGES (no over-suppression here)
Base c.email as contact -> head c.ssn as contact Zero PII findings, COMMENT / APPROVE: MAJOR over-suppression (inline)
Raw Jinja on old side, genuinely new ssn Non-blocking warning/unknown (design note, unchanged)

Status of prior findings

Prior item Status
MAJOR aliased reindent of PII still blocks Fixed (but see the new MAJOR the fix introduces)
MINOR same-line multiple PII columns Fixed; literal-parsing edge is a new MINOR
MINOR patchless file 422 drops all inline comments Fixed (post-github.ts:186, test in review-noise.test.ts)
MINOR body-only: size budget not enforced on the no-findings path, coverageNotes uncapped Not fixed: format.ts is untouched by this commit; the early return at format.ts:113-115 is unbudgeted and coverageNotes (format.ts:219) has no cap (a zero-finding summary with long unverified paths rendered 6,434 to 6,835 chars vs the 5,000 budget). Cap or budget the header, notes and footer.
Nit: PR description stale; missing fallback-lane unknown test; imprecise comments at orchestrate.ts:1425 and dbt-patterns.ts:316 Fixed
Nit: blankNames over-blanking (format.ts:159); lastBotHeadline name (post-github.ts:111); undocumented one-time repost after the timestamp-plus-int fingerprint change Not fixed (nits)
Design note: raw Jinja on the old side downgrades a new PII column to non-blocking Unchanged and deliberate; consider treating a token absent from old raw SQL as new

Regression tests: each fix in the delta has a test that fails when reverted (mutation-checked by both external reviewers). Untested: the classifier alias check at orchestrate.ts:1452; same alias with a different source; aliased CTE move; literals; quoted/implicit aliases.

Nits

  • post-github.ts:199-202: the verified-only retry's exception is discarded, so a 422 -> 503 -> successful event-only sequence returns postError: undefined. Record it.
  • post-github.ts:128-130/PR description: patchless files "keep inline comments via the 422 fallback" is inaccurate; the retry is what keeps verified ones and drops theirs.
  • orchestrate.ts:1419: isBaseExposed (name match) and isReindented (equal removed line) promise more than they check; the comment "a rename of an exposed column re-exposes nothing new" also describes the unsafe same-alias case.
  • rule-catalog.ts capturesColumns changed from boolean to RegExp; columnTokenRe would say what it holds.
  • normalizeSelectLine is case-sensitive (C.SSN vs c.ssn); harmless.
  • pii_into_mart findings for different columns share a fingerprint, so dedupe keeps one and the title never names the column (pre-existing).

// itself (a rename of an exposed column re-exposes nothing new).
const isBaseExposed = (file: string, item: { column: string; alias?: string }) => {
const basePii = basePiiColumnsByFile.get(file)
return !!basePii && (basePii.has(item.column) || (!!item.alias && basePii.has(item.alias)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MAJOR] An alias the base already exposes hides a different, newly exposed PII source column

return !!basePii && (basePii.has(item.column) || (!!item.alias && basePii.has(item.alias)))

isBaseExposed treats the line's output alias as proof the column was already exposed, whatever source the base built that alias from. That is right when the source stays and the alias changes; it is wrong when the alias stays and the source changes.

Reproduction (real altimate-core engine, Snowflake, customers schema, gate mode): base c.email as contact, head c.ssn as contact (also c.email as customer_key -> c.ssn as customer_key). Reviewers []: COMMENT with zero PII findings. Reviewers ["dbt_patterns"]: APPROVE with zero findings. The broad detect_pii lane and the classifier compare output names only, so they see contact on both sides; the two regex twins were the only detectors left, and both are now suppressed. Claude and Codex reproduced the same result independently, and both report REQUEST_CHANGES at 8003a3a. A genuinely new SSN in a mart is silently approved, which is the over-suppression the fix must not introduce.

Suggested fix: count an alias as exposed only when the base built it from the same column (build an alias -> source-columns map from the old side, e.g. selectItemColumns over the base SQL or columnLineage), otherwise fall through to the twin. Add a swap test (same alias, different PII source) that expects a critical pii_into_mart.

removedLinesByFile.set(file, removed)
}
const normalized = normalizeSelectLine(line)
return !!normalized && removed.has(normalized)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] An equal removed line anywhere in the file counts as a reindent

return !!normalized && removed.has(normalized)

The match ignores position and query scope. Real engine: c.ssn as tax_ref removed from an intermediate CTE and added to the final select (base output only customer_id, head output adds tax_ref) -> with reviewers ["dbt_patterns"] both twins vanish and the result is APPROVE. Default reviewers still catch it through the broad detect_pii lane (critical), which limits the severity.

Suggested fix: keep a line as a reindent only when its select item's output name is also in the base set, or preserve the finding when scope equivalence is unknown. Add an aliased CTE-move test.

// → `y`), which also holds when the line runs on into `from …`.
let flat = item
while (/\([^()]*\)/.test(flat)) flat = flat.replace(/\([^()]*\)/g, " ")
const alias = /\bas\s+["`]?([A-Za-z_][\w$]*)/i.exec(flat)?.[1]?.toLowerCase()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] Alias parsing misses quoted-with-space and implicit aliases, so a non-whitespace edit of an already-exposed aliased column still blocks

const alias = /\bas\s+["`]?([A-Za-z_][\w$]*)/i.exec(flat)?.[1]?.toLowerCase()

"Tax Ref" parses as tax (the engine reports Tax Ref), and c.ssn tax_ref (no AS) yields no alias. Real engine: c.ssn as "Tax Ref" -> cust.ssn as "Tax Ref", and c.ssn tax_ref -> cust.ssn tax_ref, each give a critical pii_into_mart and REQUEST_CHANGES under both reviewer settings although the base already exposes the column. Pure reindents are fine (isReindented). A line wrapped as c.ssn / as tax_ref is also missed.

Suggested fix: parse a quoted alias up to its closing quote, accept a trailing bare identifier as an implicit alias, and parse the whole select item across lines.

let flat = item
while (/\([^()]*\)/.test(flat)) flat = flat.replace(/\([^()]*\)/g, " ")
const alias = /\bas\s+["`]?([A-Za-z_][\w$]*)/i.exec(flat)?.[1]?.toLowerCase()
for (const m of item.matchAll(global)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MINOR] String-literal contents are collected as PII column tokens

for (const m of item.matchAll(global)) {

Collecting every regex token now also matches inside literals. Real engine: - email / + email, 'passport' as kind exposes no new PII, yet both reviewer configurations emit a critical pii_into_mart for passport and REQUEST_CHANGES. At 8003a3a this change produced no PII finding. topLevelItems likewise splits on commas inside literals (email || ',' || phone_number as contact).

Suggested fix: blank single-quoted literals before splitting and matching (as dbt-patterns.ts does with stripLiterals), and add a negative control next to the same-line multi-column test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants