Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7671824
feat(review): stop posting 36 noisy rule types once the AI lane runs
RaghwendraSingh Nov 25, 2026
6c3aafc
feat(review): verify the posted rule findings after the finder and dr…
RaghwendraSingh Nov 25, 2026
0091b02
feat(review): rule-post policy over the verified rule findings
RaghwendraSingh Nov 25, 2026
bbce328
docs(review): rule types off, the rule verifier and the rule-post policy
RaghwendraSingh Nov 25, 2026
e42a988
fix(review): never drop `critical` rule findings in the refuted filte…
RaghwendraSingh Nov 25, 2026
f3831f6
fix(review): rule types off never drop a critical finding and apply o…
RaghwendraSingh Nov 25, 2026
de3bfb5
fix(review): rule verifier follows `ai.verify`, reports skipped runs,…
RaghwendraSingh Nov 25, 2026
2a8ebaf
fix(review): clear errors for a bad rules-off list file; guard the po…
RaghwendraSingh Nov 25, 2026
299548d
fix(review): rule-noise filtering fails open when the finder or a ver…
RaghwendraSingh Nov 27, 2026
ec57267
fix(review): a per-PR ceiling on the rule findings the rule verifier …
RaghwendraSingh Nov 27, 2026
d9bc825
fix(review): rules-off counts use the normalized rule id; the list fi…
RaghwendraSingh Nov 27, 2026
c434662
fix(review): show withheld rule findings in the PR comment and teleme…
RaghwendraSingh Nov 27, 2026
8d0b710
fix(review): rule-noise steps filter posting only; forced verdicts co…
RaghwendraSingh Nov 27, 2026
cb6c286
fix(review): `ALTIMATE_REVIEW_RULES_OFF` takes every boolean spelling…
RaghwendraSingh Nov 27, 2026
e8b6a16
fix(review): list withheld rule findings that count toward a blocking…
RaghwendraSingh Nov 27, 2026
3ac8a36
fix(review): budget-forced rule verdicts count again; only a timed-ou…
RaghwendraSingh Nov 27, 2026
557bf89
fix(review): verify rules-off findings on files the AI lane does not …
RaghwendraSingh Nov 27, 2026
90e7f7f
fix(review): list withheld findings whenever they change the verdict,…
RaghwendraSingh Nov 27, 2026
e81c0db
fix(review): withheld findings survive `--all-projects`, stay within …
RaghwendraSingh Nov 27, 2026
faa06d1
fix(review): count the rule-noise steps over instances, like the with…
RaghwendraSingh Nov 27, 2026
19e742c
fix(review): verify a rules-off finding when the finder call for its …
RaghwendraSingh Nov 27, 2026
5f86bd0
test(review): the rule-verifier tests clear an exported `ALTIMATE_REV…
RaghwendraSingh Nov 27, 2026
f2ef89e
fix(review): a rule answer without a valid verdict is no verdict; a r…
RaghwendraSingh Nov 27, 2026
aa1c6ff
fix(review): the configured noisy rule types go first under the rule-…
RaghwendraSingh Nov 27, 2026
bc78b4e
fix(review): docs say the rule-verifier ceiling is per project, what …
RaghwendraSingh Nov 27, 2026
8f9fe75
fix(review): the `--all-projects` tally counts what each project's ve…
RaghwendraSingh Nov 27, 2026
2f99b51
fix(review): list withheld findings only when they change the verdict…
RaghwendraSingh Nov 27, 2026
6beb176
fix(review): `--all-projects` keeps only the withheld lists that driv…
RaghwendraSingh Nov 27, 2026
47ff729
docs(review): the merged tally comment states which paths reach one p…
RaghwendraSingh Nov 27, 2026
2f781eb
fix(review): `--all-projects` picks withheld lists by the applied mer…
RaghwendraSingh Nov 27, 2026
cad25bc
fix(review): `--all-projects` shows each project's own withheld list …
RaghwendraSingh Nov 27, 2026
b676851
docs(review): a project below the merged verdict has its withheld lis…
RaghwendraSingh Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion docs/docs/usage/dbt-pr-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ ai: true # the advisory AI lane; false turns it off. Or an
# pythonFiles: true # changed Python files, inside or outside the project
# verify: true # the dbt-grounded verifier over the AI comments
# conventions: true # repo review instructions from the base branch (see below)
# rulesOff: true # stop posting 36 noisy rule types once the AI lane answers
# # (critical findings of those types are still posted)
# rulesOn: [] # rule ids taken back out of that list
# verifyRules: true # verify the posted rule findings with the verifier (needs
# # `verify`); refuted ones are not posted, except critical ones
# rulePolicy: true # post-verification rule policy; or {noisyRules: [...]}
dataDiff: # OFF by default — see "Data-diff in CI" below
enabled: false
warehouse: "" # connection name; empty = default connection
Expand Down Expand Up @@ -669,11 +675,58 @@ across 12 dialects all plan; anything still unrecognized stays *undecidable*, ne
secret-named settings whose value looks like a credential are redacted; ordinary
text such as `env_var('DBT_PASSWORD')` examples is left as written. The verifier reads a
convention file's base-branch text, not the PR's edit of it.
When the AI lane runs and answers, the rule findings are filtered too. 36 rule
types that were almost never real defects on public dbt PRs are not posted on
files the AI lane reviewed (`ai.rulesOff: false` or
`ALTIMATE_REVIEW_RULES_OFF=0`/`off`/`false`/`no` keeps them, `ai.rulesOn: [ids]` keeps
single types, `ALTIMATE_REVIEW_RULES_OFF=<path>.json` replaces the list with a
JSON list of rule ids; the path must be absolute and outside the reviewed
repository and the current directory's work tree, and is refused when neither
resolves to a work tree, and a missing, unreadable or malformed list file stops the review
before any lane runs; rule ids match in either spelling, `dbt_patterns:self_join`
or `dbt-patterns:self-join`). With the verifier on (`ai.verify`), the rule
findings that would be posted are verified too (critical ones are never
dropped, so they are not sent; rule types off are sent too on files the AI lane
does not send, and on a sent file whose finder call failed, since they are posted
there), up to 40 per reviewed dbt project (`--all-projects` verifies each project
on its own), warnings and the noisy
types first (`ALTIMATE_REVIEW_AI_VERIFY_RULES_MAX_FINDINGS`); findings over the
ceiling are posted unverified. The rule run is a second verifier run with its own
token budget; on the default budget most of its batches answer without tools
(forced at the budget), and those verdicts count. Refuted ones are not posted.
`ai.verifyRules: false` or `ALTIMATE_REVIEW_AI_VERIFY_RULES=off` turns this step off
(no rule finding is verified or dropped as refuted), and so does `ai.verify: false`.
Then a rule finding is not posted when the verifier answered that it could not
check it and it is a warning, or when its type is one of 7 noisy types and the
verifier did not confirm it (`ai.rulePolicy: false` or
`ALTIMATE_REVIEW_RULE_POLICY=0`). A rule finding that got no verdict (its batch
failed, or it was over the ceiling) is posted, and so is one whose batch timed
out (its verdict counts as no verdict). Critical rule
findings are never dropped by any of these steps, nor is a repeat-merged comment
that includes an AI finding. When the AI lane is skipped or fails (no model, dry
run, provider error, timeout), the rule verifier does not run, none of the steps
applies and every rule finding is posted as before; when only the rule verifier
did not run, the rule types off still apply and every other rule finding is
posted unchanged. The envelope counts what each step withheld, per instance as the
verdict counts them (`rulesOff`, `rulesRefuted`, `rulePolicy`), and the PR comment
gives the total per step.
4. **Rubric → verdict.** Findings map to a verdict by a versioned rubric (data,
not prompt): any blocking-category `critical` → `REQUEST_CHANGES`; ≥3 warnings
→ risk pattern → `REQUEST_CHANGES`; only suggestions → `COMMENT`; nothing →
`APPROVE`. Only layer-1 findings reach `critical`, so only the engine can
block. In `comment` mode, `REQUEST_CHANGES` is posted as comments rather than
block (the rule verifier and the rule-post policy never drop a critical rule
finding). The rule-noise steps change what is posted, never the verdict: an
engine warning that is refuted, turned off or dropped by the policy is not
posted but still counts toward the ≥3 warnings (the summary counts it too), so
neither the verifier nor text it reads, such as the PR description, can unblock
a gate. When withheld findings change a project's verdict, the summary lists them (file
and line, title, and why each was not posted; the first 10, the rest are in the
envelope) and the envelope records them under
`withheld`: the engine warnings that count toward a `REQUEST_CHANGES`, or every
withheld finding when they alone keep the verdict from `APPROVE`. With
`--all-projects`, the merged summary shows the lists of the projects whose verdict
equals the merged one; a project below it has its list left out, and the findings
on that list are not counted. In `comment` mode, `REQUEST_CHANGES` is posted as comments rather than
blocking.
5. **Signed envelope.** The verdict is HMAC-signed (`ALTIMATE_REVIEW_SIGNING_KEY`)
and includes the manifest hash, so it is replayable and tamper-evident.
Expand Down
54 changes: 54 additions & 0 deletions packages/opencode/src/altimate/review/ai-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { type Finding, type ReviewCategory, type Severity, makeFinding, ruleId }
import { readStreamText } from "../llm/stream-text"
import { type AiVerifyEvidence, type VerifierStatus, runAiVerify } from "./ai-verify"
import { aiReplayPath, runAiReplay } from "./ai-replay"
import { runRuleVerify, skippedVerifier } from "./ai-verify-rules"
import { walkDiffLines } from "./diff-filter"
import { CARD_BATCH_MAX_CHARS } from "./ai-context-card"
import { type AiSwitches, switchOn } from "./ai-switches"
Expand Down Expand Up @@ -753,6 +754,14 @@ export interface AiReviewInput {
reviewDir?: string
/** Team conventions from the base branch (`conventions` switch); each call carries those for its files. */
conventions?: Convention[]
/** The rule findings the review would post, verified after the finder (`verifyRules` switch). */
verifyRulesAfter?: Finding[]
/** Rule findings verified only when the finder's call for their file failed: rule types off on
* sent files, which are posted only then (the orchestrator drops them where the lane answered). */
verifyRulesIfUnreviewed?: Finding[]
/** The rule-post policy's noisy types (`ai.rulePolicy.noisyRules`, else the default list): verified
* first under the per-PR ceiling, since their posting depends on a verdict. */
noisyRules?: readonly string[]
}

/** What happened in the advisory lane, reported on the envelope and in the comment. */
Expand Down Expand Up @@ -787,7 +796,13 @@ export interface AiLaneStatus {
failedFiles?: string[]
/** The team conventions loaded from the base branch (no text), when any were given. */
conventions?: ConventionRecord[]
/** The rule findings were verified after the finder; refuted ones are not posted. */
verifyRules?: "drop_refuted"
/** That rule run's own outcome and spend (its verdicts are in `verifier.ruleVerdicts`). */
ruleVerifier?: RuleVerifierSummary
}
/** The rule verifier run, without its per-finding records. */
export type RuleVerifierSummary = Omit<VerifierStatus, "ruleVerdicts" | "batches" | "dropped" | "decisions"> & { model?: string }
/** One file as sent to the model. */
export interface AiInputRecord {
path: string
Expand Down Expand Up @@ -1003,6 +1018,45 @@ export function planAiInput(input: AiReviewInput, env: Record<string, string | u
* envelope and the PR comment.
*/
export async function runAiReview(input: AiReviewInput): Promise<AiReviewResult> {
const res = await runFinderLane(input)
// The rule verifier over the rule findings the review would post, after the finder and its verifier;
// only when the finder answered, since the orchestrator applies rule noise only then (fail-open).
if (res.status.state !== "ok") return res
const rules = rulesToVerify(input, res.status)
if (!input.verifyRulesAfter && !rules.length) return res
return withRuleVerdicts(res, await runRuleVerify(input, rules))
}

/** The rule findings to verify once the finder answered: those the review would post, plus the
* conditional ones (`verifyRulesIfUnreviewed`) on files whose finder call failed. */
export function rulesToVerify(
input: Pick<AiReviewInput, "verifyRulesAfter" | "verifyRulesIfUnreviewed">,
status: Pick<AiLaneStatus, "failedFiles">,
): Finding[] {
const failed = new Set(status.failedFiles ?? [])
return [...(input.verifyRulesAfter ?? []), ...(input.verifyRulesIfUnreviewed ?? []).filter((f) => failed.has(f.file))]
}

/** The finder lane's result with the rule run's verdicts (`verifier.ruleVerdicts`, `verifier.batches`) and its
* own outcome (`ruleVerifier`). The finder verifier's counters are left as they were. */
export function withRuleVerdicts(res: AiReviewResult, rules: AiReviewResult): AiReviewResult {
const rv = rules.status.verifier ?? skippedVerifier(rules.status.reason ?? "the rule verifier did not run")
const { ruleVerdicts, batches, dropped: _d, decisions: _x, ...summary } = rv
const ruleVerifier: RuleVerifierSummary = { ...summary, ...(rules.status.model ? { model: rules.status.model } : {}) }
const verifier: VerifierStatus = res.status.verifier ?? skippedVerifier("the AI verifier did not run on the finder's findings")
return {
findings: res.findings,
status: {
...res.status,
verifyRules: "drop_refuted",
verifier: { ...verifier, ...(ruleVerdicts ? { ruleVerdicts } : {}), ...(batches ? { batches } : {}) },
ruleVerifier,
},
}
}

/** The finder lane: replay, or plan, call the finder and run its verifier as configured. */
async function runFinderLane(input: AiReviewInput): Promise<AiReviewResult> {
const replay = aiReplayPath()
const startedAt = Date.now()
const plan = planAiInput(input)
Expand Down
49 changes: 44 additions & 5 deletions packages/opencode/src/altimate/review/ai-switches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@
// down; code called without them (direct callers, unit tests) reads only the
// env variable, as before, so an unset variable means off there.
import type { ReviewConfig } from "./config"
import { rulesOffEnv } from "./rules-off"

export type AiSwitchName = "coverage" | "contextCard" | "focused" | "otherFiles" | "pythonFiles" | "verify" | "conventions"
export type AiSwitchName =
| "coverage"
| "contextCard"
| "focused"
| "otherFiles"
| "pythonFiles"
| "verify"
| "conventions"
| "rulesOff"
| "verifyRules"
| "rulePolicy"

export type AiSwitches = Record<AiSwitchName, boolean>

Expand All @@ -21,6 +32,9 @@ export const AI_SWITCH_ENV: Record<AiSwitchName, string> = {
pythonFiles: "ALTIMATE_REVIEW_AI_PYTHON_FILES",
verify: "ALTIMATE_REVIEW_AI_VERIFY",
conventions: "ALTIMATE_REVIEW_CONVENTIONS",
rulesOff: "ALTIMATE_REVIEW_RULES_OFF",
verifyRules: "ALTIMATE_REVIEW_AI_VERIFY_RULES",
rulePolicy: "ALTIMATE_REVIEW_RULE_POLICY",
}

/**
Expand All @@ -36,17 +50,29 @@ export const AI_SWITCH_DEFAULTS: AiSwitches = {
pythonFiles: true,
verify: true,
conventions: true,
rulesOff: true,
verifyRules: true,
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
rulePolicy: true,
}

type Env = Record<string, string | undefined>

const ENV_TRUE = new Set(["1", "true", "on", "yes"])
const ENV_FALSE = new Set(["0", "false", "off", "no"])
/** Extra env spellings: `ALTIMATE_REVIEW_AI_VERIFY_RULES=drop_refuted|off`. */
const ENV_ON: Partial<Record<AiSwitchName, string>> = { verifyRules: "drop_refuted" }
const ENV_OFF: Partial<Record<AiSwitchName, string>> = { verifyRules: "off" }

/** The env override for a switch: true for `1`/`true`/`on`/`yes`, false for `0`/`false`/`off`/`no`
* (case-insensitive), undefined otherwise. */
* (case-insensitive) or a switch's own spelling, undefined otherwise. */
export function envSwitch(name: AiSwitchName, env: Env = process.env): boolean | undefined {
return envBool(env[AI_SWITCH_ENV[name]])
const raw = env[AI_SWITCH_ENV[name]]
// `ALTIMATE_REVIEW_RULES_OFF` also takes on/off/true/false, or a path naming a replacement list.
if (name === "rulesOff") return rulesOffEnv(raw).on
const v = raw?.trim().toLowerCase()
if (v !== undefined && v === ENV_ON[name]) return true
if (v !== undefined && v === ENV_OFF[name]) return false
return envBool(raw)
}

/** An env value as a boolean: `1`/`true`/`on`/`yes` true, `0`/`false`/`off`/`no` false (trimmed,
Expand All @@ -58,6 +84,11 @@ export function envBool(raw: string | undefined): boolean | undefined {
}

const WARNED = new Set<string>()
/** What else a switch's env variable accepts, for the warning. */
const ENV_EXTRA: Partial<Record<AiSwitchName, string>> = {
verifyRules: ", drop_refuted/off",
rulesOff: ", or an absolute path to a JSON list of rule ids",
}

/** Every switch for one review: env, then the `ai:` config object, then the default. */
export function resolveAiSwitches(
Expand All @@ -75,13 +106,21 @@ export function resolveAiSwitches(
// No warning for a lane that will not run (`warn: false`).
if (opts.warn !== false && fromEnv === undefined && raw?.trim() && !WARNED.has(warning)) {
WARNED.add(warning)
process.stderr.write(`⚠️ ignoring ${AI_SWITCH_ENV[name]}=${raw}: use 1/0 (or true/false, on/off, yes/no)\n`)
process.stderr.write(`⚠️ ignoring ${AI_SWITCH_ENV[name]}=${raw}: use 1/0 (or true/false, on/off, yes/no${ENV_EXTRA[name] ?? ""})\n`)
}
out[name] = fromEnv ?? configured[name] ?? AI_SWITCH_DEFAULTS[name]
out[name] = fromEnv ?? configuredSwitch(configured[name as keyof typeof configured]) ?? AI_SWITCH_DEFAULTS[name]
}
// The rule findings are verified by the same verifier: `verify` off turns `verifyRules` off too.
out.verifyRules &&= out.verify
return out
}

/** A config value as a switch: a boolean as is, an object (settings for the switch) as on. */
function configuredSwitch(v: unknown): boolean | undefined {
if (typeof v === "boolean") return v
return v && typeof v === "object" && !Array.isArray(v) ? true : undefined
}

/** A switch from resolved switches when given, else from its env variable alone (unset = off). */
export function switchOn(name: AiSwitchName, switches: Partial<AiSwitches> | undefined, env: Env = process.env): boolean {
return switches?.[name] ?? envSwitch(name, env) ?? false
Expand Down
81 changes: 81 additions & 0 deletions packages/opencode/src/altimate/review/ai-verify-rules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// altimate_change - new file: the dbt-grounded verifier over the deterministic rule findings
//
// After the finder (and its verifier), the rule findings the review would post go to the
// same verifier in its usual batches. Each one's verdict is recorded under
// `ai.verifier.ruleVerdicts`; the orchestrator drops the refuted ones (`verifyRules`
// switch) and applies the rule-post policy to the rest. Fail-open: no evidence, no model,
// a dry run or a failed call leaves every rule finding as it was.
import { Provider } from "@/provider/provider"
import { Log } from "@/altimate/util/log"
import { type Finding, normalizeRuleId } from "./finding"
import { NOISY_RULE_TYPES } from "./rule-post-policy"
import { aiDryRunEnabled, safeReason, type AiLaneStatus, type AiReviewInput, type AiReviewResult } from "./ai-review"
import { runAiVerify, type VerifierLlm, type VerifierStatus } from "./ai-verify"

const log = Log.create({ service: "ai-verify-rules" })

export const NO_RULE_FINDINGS_REASON = "nothing to verify: the PR has no rule findings"

/** Rule findings verified per PR at most (`ALTIMATE_REVIEW_AI_VERIFY_RULES_MAX_FINDINGS`): the run
* has its own verifier budget and each batch of 8 makes at least one call, so this bounds its
* calls. Findings past it, most severe first, get no verdict and are posted unchanged. */
export const RULE_VERIFY_MAX_FINDINGS = 40

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: This 40-finding ceiling cannot be honoured with the verifier's shared token budget, and the new "budget counts as no verdict" rule then discards every verdict.

runAiVerify gives each batch VERIFY_MAX_TOKENS / batches.length (ai-verify.ts:1362; 12,000 tokens across 5 batches at 40 findings), while verifyBatch needs about 2 × (fixedChars + message) / 4 + 2,000 tokens before it allows even one tool round (ai-verify.ts:1174-1182), fixedChars being the ~1.4k-char system prompt plus the tool schemas. With 3+ batches the per-batch share is at most 4,000 and that gate can never pass (ai-verify.ts:1183-1187), so every batch is answered with ANSWER_DIRECT and state: "budget". The orchestrator now turns a budget batch's verdicts into no verdict (orchestrate.ts:2856-2858), so for any PR that yields 3+ batches of rule findings (about 17+ findings, fewer with per-file chunking) the refuted filter and the rule-post policy never act, while the run still spends 5-7 calls and, when the forced answers parse, reports rulePolicy.applied: true with ai_rule_verify_reviewed: N. The 50-finding test only asserts that 40 verdict records exist, so it passes with every verdict forced and never exercises this.

Fix: scale the token budget with the batch count (e.g. pass a scaled ALTIMATE_REVIEW_AI_VERIFY_MAX_TOKENS through deps.env, or add a per-batch floor in runAiVerify), or cap the pass at one batch unless the operator raises the budget.

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 changed; stale. Since 3849329cda, a verdict from a batch forced at its budget counts again. Only a timed-out batch's verdict counts as no verdict. Forced, tool-less answers are the rule run's usual mode, and the rule-post policy was tuned and validated on them (paid release run: 20 of 20 batches forced). A per-batch budget floor would change the measured configuration and cost, so it would need its own measurement. Test: a budget-forced verdict is acted on for posting; a timed-out batch's verdict counts as no verdict.


/** A verifier record for a run that made no model call: its `findings` are all kept, unreviewed (fail-open). */
export function skippedVerifier(reason: string, findings = 0): VerifierStatus {
return {
state: "skipped",
reason,
durationMs: 0,
turns: 0,
toolCalls: 0,
reviewed: 0,
kept: findings,
discarded: 0,
summary: 0,
unreviewed: findings,
}
}

/** Verify `rules` (never calls the finder, returns no findings): the verdicts are on `status.verifier`. */
export async function runRuleVerify(
input: AiReviewInput,
rules: Finding[],
deps: { env?: Record<string, string | undefined>; llm?: VerifierLlm } = {},
): Promise<AiReviewResult> {
const startedAt = Date.now()
const env = deps.env ?? process.env
const done = (status: Omit<AiLaneStatus, "durationMs">): AiReviewResult => ({
findings: [],
status: { ...status, durationMs: Date.now() - startedAt },
})
const skip = (reason: string) => done({ state: "skipped", reason, verifier: skippedVerifier(reason, rules.length) })
if (!input.evidence) return skip("the verifier's evidence is unavailable")
const candidates = rules.filter((f) => f.severity !== "critical")
if (!candidates.length) return skip(NO_RULE_FINDINGS_REASON)
if (aiDryRunEnabled(env)) return skip("dry run (ALTIMATE_REVIEW_AI_DRYRUN=1): no model call")
let model: Provider.Model
try {
const chosen = input.model ? Provider.parseModel(input.model) : await Provider.defaultModel()
model = await Provider.getModel(chosen.providerID, chosen.modelID)
} catch (err) {
return skip(`no usable model: ${safeReason(err)}`)
}
const max = Number(env.ALTIMATE_REVIEW_AI_VERIFY_RULES_MAX_FINDINGS)
const cap = Number.isInteger(max) && max > 0 ? max : RULE_VERIFY_MAX_FINDINGS
Comment on lines +64 to +65

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 · performance

  const max = Number(env.ALTIMATE_REVIEW_AI_VERIFY_RULES_MAX_FINDINGS)
  const cap = Number.isInteger(max) && max > 0 ? max : RULE_VERIFY_MAX_FINDINGS

The cap is applied per call, and reviewAllProjects calls this once per project, so the documented 40-per-PR ceiling becomes 40 × projects.

Fix: pass a shared remaining allowance through the multi-project run, or document the cap as per project.

Raised by: Codex

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.

Already addressed in 2916fa57a4 by documenting it: the docs and the PR text say 40 per reviewed dbt project. Not changed in code. Each project's rule run has its own verifier budget, so a shared allowance would make one project's ceiling depend on the order projects run in.

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.

✅ Pushback accepted (re-review at 498cf87). The docs now state the cap is per reviewed project (dbt-pr-review.md:688-690), and a shared allowance would make the cap depend on project order.

// Critical findings are never dropped, so they are not verified. Warnings first, since the policy
// acts on them, and within a severity the policy's noisy types, whose posting depends on a verdict.
const order = { critical: 2, warning: 1, suggestion: 0 } as const
const noisy = new Set((input.noisyRules ?? NOISY_RULE_TYPES).map(normalizeRuleId))
const isNoisy = (f: Finding) => (f.rule && noisy.has(normalizeRuleId(f.rule)) ? 1 : 0)
const sent = [...candidates].sort((a, b) => order[b.severity] - order[a.severity] || isNoisy(b) - isNoisy(a)).slice(0, cap)
log.info("verifying rule findings", { findings: sent.length, total: rules.length })
const v = await runAiVerify(
{ findings: sent, grounding: input.grounding, evidence: input.evidence, model, rulesOnly: true },
{ env, ...(deps.llm ? { llm: deps.llm } : {}) },
)
const over = candidates.length - sent.length
const note = `${over} of ${candidates.length} rule findings over the per-PR ceiling of ${cap} were not verified`
const verifier = over ? { ...v.status, reason: v.status.reason ? `${v.status.reason}; ${note}` : note } : v.status
return done({ state: "ok", model: `${model.providerID}/${model.id}`, verifier })
}
Loading
Loading