feat(review): wider AI lane input, `ai:` switches in config, and the measured lane configuration on by default
Β
RA
4d ago+2341+2341+0123456789012345678901234567890123456789-106-106-012345678901234567890123456789
Issue for this PR
Part of #1792
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Stacked on #1773. The first of three PRs that bring the AI lane to the configuration we measured. The next two are feat/review-conventions (repo review instructions) and feat/review-rule-noise (fewer noisy rule comments).
What changed
- One place for the switches.
aiin.altimate/review.ymlacceptstrue/falseor an object (enabledpluscoverage,contextCard,focused,otherFiles,pythonFiles,verify).resolveAiSwitchespicks each switch from its env variable first (1/true/on/yeson,0/false/off/nooff; an empty value counts as unset; any other value is ignored with a stderr warning, once per value per process), then the config, then the default.run.tsresolves them once and passes them down. Code called without switches (direct callers, tests) keeps reading the env variables only, as today. Every key is optional, so the default policy hash does not change. An unknown key underai:fails the config load, so a typo such asenable: falsecannot leave the lane running. - Other project files reach the AI lane (
otherFiles). Changedother/analysisfiles inside the project root (.sql,.yml,.yaml) get their own quota of 8. Python files are not among them: they go throughpythonFilesonly, sopythonFiles: falsestops every Python file. - Changed Python files reach the AI lane (
pythonFiles), inside or outside the project root, with their own quota of 6. Fixes for files outside the project:- A file the lane reviewed is no longer listed as "outside the dbt project" in
scope.notReviewed. It counts as reviewed only when the call that carried it answered: a lane error or timeout, or a failed call in a partly failed run (ai.failedFiles), keeps it listed. The same rule now applies to other/analysis files inside the project. - The verifier sees their added lines, so their findings are not triaged as comments on unchanged code.
- The stderr "were not reviewed" count leaves them out; a second line says they are offered to the AI lane when it runs and that the result lists any it did not review.
- Under
--all-projectseach file is offered to project after project until a lane takes it (the lane reviewed it, or it is in the input of a lane that answered or of a dry run, and no failed call carried it); a project whose lane is off in its policy, haspythonFiles: false, is not in its tier, errored, timed out or had no model passes it on. - Their findings on unchanged context lines are marked pre-existing, as for in-project files.
- A Python file renamed out of the project (scoped in as a deletion at its old path) is offered at its new path by the project it left. Its new path stays listed as "outside the dbt project" until the lane reviews it.
- A file the lane reviewed is no longer listed as "outside the dbt project" in
- Coverage notes.
ai.unsentlists only files the deterministic lanes also checked (includingotherYAML files a rule lane parsed); other/analysis and Python files over their quota that no rule lane read stay in the "Not reviewed" ledger instead. ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE=<file>replaces the finder's system prompt. An empty or unreadable file is an error, never a quiet fallback. It is env only, because a config key would point at a file the PR itself can edit, and the path must be absolute, and neither its realpath nor the path as named (each directory on it resolved) may be inside the reviewed repository (--cwd's git root), the current directory's work tree, or any work tree enclosing them; the refusal names the work tree it found (a home directory kept in git counts as one); it is refused when none resolves to a work tree, so a PR cannot supply the file, or point an in-checkout symlink at one, either (trustedFilePath, shared with the rules-off list in #1838). The default prompt stays the one in altimate-core.- Verifier fix. When the verifier stops before giving a verdict, on its budget or on its timeout, the AI findings it never got to now go to the summary instead of inline. Errors are unchanged, and the closed fail mode still discards them. The stop is recorded (
unreviewed_stopped) under either fail mode, and a timeout or error outside a batch records a decision per finding, so every outcome can be re-triaged offline. - Defaults (a separate commit that can be reverted alone). Coverage quotas, context cards, focused batches, other files, Python files and the AI verifier are on whenever the AI lane runs. Each can be turned off with
ai: { <switch>: false }or its env variable set to0.
How existing users are affected
- AI lane off (
--no-ai,ai: false, no model): no change. A test checks the envelope is identical. - AI lane on: more files reach the finder (quotas instead of a 20-file cap). Related files are reviewed together, which means about 3 finder calls per PR instead of 1. Every AI comment is checked by the verifier.
- Telemetry:
review_run.out_of_scope_filesno longer counts outside-project Python files the AI lane reviewed; they are counted in the newai_reviewed_outside_files. Dashboards that trendout_of_scope_fileswill show a step down (worth a release note). - A file of any type renamed out of the dbt project now counts as "outside the dbt project, not reviewed" (in
scope.notReviewed,outOfScopeFilesandout_of_scope_files), because this review did not look at its new path. This includes a model moved to another project during a single-project review. - Env switches already set to
1keep working.0,false,offandnomean off. Before this PR any value other than1meant off; now a value that is none of these spellings is ignored with a warning and the config or default applies. - Issue #1792 says the AI features are opt-in. With this PR they are on by default whenever the AI lane runs (the lane itself was already on by default with a model configured); the docs now say so and name the opt-outs.
Results
Measured with this stack plus the conventions and rule-noise PRs that follow it, using the defect-focused finder prompt through ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE. AI and rule comments were counted together.
- On 46 public dbt PRs the combined review raised 526 real bugs, against CodeRabbit's 437. 10% of our comments were wrong, against CodeRabbit's 14%.
- On 90 fresh public dbt PRs, counting distinct real bugs on the PRs each bot also reviewed:
- us 125, CodeRabbit 93
- us 227, Copilot 76
- us 189, Cursor Bugbot 56
- The verifier matters for precision. Without it, the finder with the wider input alone had 6.7% wrong comments, which is why the verifier is on by default here.
Caveats:
- The default finder prompt stays the core prompt until an altimate-core release ships the defect-focused one. Until then the env override gives the measured prompt.
- A few default-on rule changes from other branches were part of the measured build, so rule output differs slightly until those land.
- In the measured build, changed
.pyfiles inside the project went to the AI lane as other files, under the quota of 8. They now go as Python files under the quota of 6, so the finder's input differs on 7 of the 46 PRs and 7 of the 90 (on 3 of those PRs one or two.pyfiles are no longer sent, and other files get the room they used). The measured envelopes have no outside-project Python files, so the outside-file fixes do not change the results.
How did you verify your code works?
bun test test/altimate/review(packages/opencode): 1038 pass, 0 fail.bun run typecheck(packages/opencode,tsgo --noEmit): clean.- New tests cover: switch precedence and the env-only fallback; flags-off identity of the planner input, orchestrator input and envelope;
--no-aienvelope identity; quotas, scope and stderr for outside Python files; files kept in the ledger when the lane or their call failed; the next project taking outside Python files when the first project's lane is off; the multi-project merge; unknownai:keys; prompt override errors; and verifier budget and timeout demotion to the summary, with decisions recorded for re-triage.
Cost side effects
Yes, when the AI lane is on. The lane makes more model calls per PR, and their size grows with the number of changed files, up to fixed limits:
- Finder: about 3 calls per PR instead of 1, about 62k input and 8k output tokens per PR on average over 46 public dbt PRs. Capped by the per-kind file quotas (models 12, macros 8, tests 4, yml 6, other 8, Python 6) and the existing per-call character budget.
- AI verifier (now on by default): about 17k input and 2k output tokens per PR on average. Capped by its existing per-PR token, tool-output and round budgets.
- No warehouse queries or cloud resources.
- Every part can be turned off with
ai: { <switch>: false }or its env variable set to0. With the AI lane off, nothing changes.
Screenshots / recordings
Not a UI change.
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