Repository navigation
feat(review): fewer wrong rule comments when the AI lane runs: rule types off, rule verifier, rule-post policy - #1838
Open
RaghwendraSingh wants to merge 32 commits into
Open
RaghwendraSingh wants to merge 32 commits into
RaghwendraSingh wants to merge 32 commits into
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Part of #1792
Type of change
What does this PR do?
Stacked on
feat/review-conventions. The last of three PRs. Once the AI lane got good, most of our wrong comments came from deterministic rule findings: on 46 public dbt PRs, 23% of rule comments were wrong against 4.3% of AI comments. This PR filters rule findings in three steps. All three run only when the AI lane ran and answered: with no model, a dry run, a provider error or a timeout every rule finding is posted as before.What changed
Rule types off.
NOISY_RULES_OFFinrules-off.tslists 36 rule types that were almost never real defects on public dbt PRs that the AI lane also reviewed. Their findings are not posted on files the AI lane reviewed (sent in a call that answered); on any other file they are posted. On those other files they go to the rule verifier like any other rule finding, and so does one on a sent file whose finder call failed.classify-pii:exposesis on the list for its warnings; a new high-confidence PII column in a mart is critical and still posts and blocks.ai.rulesOff: falseorALTIMATE_REVIEW_RULES_OFF=0(off,false) keeps all 36 types.ai.rulesOn: [ids]keeps single types. Rule ids match in either spelling (dbt_patterns:self_joinordbt-patterns:self-join).ALTIMATE_REVIEW_RULES_OFF=<path>replaces the list with a JSON list of rule ids. Only a value that looks like a path is read as a file; it must be absolute and outside the reviewed repository and the current directory's work tree, refused when neither resolves (a PR could otherwise choose the list), and a missing or malformed file stops the review.yes/nowork like for every other switch.Rule verifier. After the finder and the AI verifier, the rule findings that would be posted go through the same dbt-grounded verifier, in a mode that records a verdict per finding and does no triage. Refuted rule findings are not posted.
state: ok), and is on when the AI lane and the verifier are on;ai.verify: falseturns it off too. A skipped run reports every rule finding as kept and unreviewed.--all-projectsruns it per project), warnings first and, within a severity, the policy's noisy types (ai.rulePolicy.noisyRuleswhen set) (ALTIMATE_REVIEW_AI_VERIFY_RULES_MAX_FINDINGS); the rest get no verdict and are posted. An answer without a valid verdict counts as no verdict; a refutation without evidence counts asunverifiable. Critical rule findings and findings on credential-like paths are not sent.ai.verifyRules: falseorALTIMATE_REVIEW_AI_VERIFY_RULES=offturns it off.Rule-post policy.
rule-post-policy.tsholds the pure functiondropByRulePolicy(findings, verdictById, policy). After steps 1 and 2, a rule finding is not posted if either holds:unverifiableand its severity is warning;NOISY_RULE_TYPES) and its verdict is notconfirmed.Details:
ai.rulePolicy: falseorALTIMATE_REVIEW_RULE_POLICY=0turns it off.ai.rulePolicy: { noisyRules: [...] }replaces the list.AI findings are never dropped by any of the three steps, nor is a repeat-merged comment that includes an AI finding. Critical rule findings are never dropped by any of the three steps: they are posted and block as before. The three steps filter posting only: the verdict and the summary tally still count every rule finding, so a withheld engine warning keeps its blocking weight and neither the verifier nor author text it reads (the PR description) can unblock a gate. When withheld findings change the verdict, the summary lists them (file:line, title, why; the first 10) and the envelope records them as
withheld: the engine warnings that count toward a REQUEST_CHANGES the posted findings alone would not reach, or every withheld finding when they alone keep the verdict from APPROVE. When the finder lane fails or times out, none of the three steps applies. The PR comment gives the number of rule findings not posted per step, counted per instance like the verdict, andreview_runtelemetry carries the rule verifier's state, tokens and cost plus the drop counts. With the AI lane off nothing changes; tests check the envelope is identical.Envelope:
rulesOff: {rule: count}rulesRefutedrulePolicy: {applied, dropped: {unverifiable_high_sev, noisy_type_not_confirmed}}withheld[](only when withheld findings change the verdict): those findings, with the reasonai.verifyRulesandai.ruleVerifier(state and spend)ai.verifier.ruleVerdicts[]andai.verifier.batches[]All are summed across projects under
--all-projects(withheldis the projects' lists merged, and the mergedsummarycounts each project's withheld instances); rule verdicts'batchindexes are offset per project,ai.verifyRulesis set when any project verified, andai.ruleVerifier.modelis kept.Critical rule findings are exempt. Rules-off, the refuted filter and the rule-post policy all skip
criticalrule findings, so no step stops a critical rule finding from being posted or from blocking. They are not sent to the rule verifier. The docs say so next to "only the engine can block".Results
Caveats:
classify-pii:exposesfindings of every severity. On the 46 PRs every such finding was a warning, so exempting critical ones changes nothing there. On the 90 fresh PRs rules-off dropped 16 of them on 7 PRs; the envelopes keep only the count, so whether any was critical (and would now be posted) is not known without a rerun.How did you verify your code works?
bun test test/altimate/review(packages/opencode): 1167 pass, 0 fail.bun run typecheck(packages/opencode,tsgo --noEmit): clean.review-rules-off.test.ts: list shape; resolver (default, config,rulesOnin either spelling, env spellings and file, bad files); critical findings kept; orchestrator drop and counts with the finder's input unchanged; a skipped, failed or timed-out lane leaves the list unapplied; a merged AI+rule comment survives; AI lane off unchanged.review-ai-verify-rules.test.ts: switch spellings; rule-mode verdicts, batching and failure; skipped cases; call order finder → AI verifier → rule verifier; refuted findings dropped with the lane input otherwise unchanged; rule types off left out before verification.review-rule-post-policy.test.ts: both conditions and severities; critical findings kept by the policy and the refuted filter; missing verdicts; AI findings never dropped; custom list; the fail-open states; config and env; orchestrator drops and envelope counts; switches off and AI lane off unchanged.Cost side effects
Yes, one new model run per PR when the AI lane and the verifier are on: the rule verifier.
ai.verifyRules: falseorALTIMATE_REVIEW_AI_VERIFY_RULES=offturns it off.Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code