Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
93db870
feat(review): resolve the AI lane's switches once, from env, `ai:` co…
RaghwendraSingh Nov 24, 2026
01f81bc
feat(review): send other changed project files to the AI lane (`other…
RaghwendraSingh Nov 24, 2026
373bd3e
feat(review): send changed Python files to the AI lane (`pythonFiles`…
RaghwendraSingh Nov 24, 2026
35c93a3
feat(review): `ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE` replaces the fi…
RaghwendraSingh Nov 24, 2026
84608a4
fix(review): AI findings the verifier left unreviewed on budget go to…
RaghwendraSingh Nov 24, 2026
e3c5b2d
feat(review): the measured AI lane configuration on by default
RaghwendraSingh Nov 24, 2026
e7f27d7
fix(review): AI findings left unreviewed by a verifier timeout also g…
RaghwendraSingh Nov 25, 2026
3148c95
fix(review): AI-only files count as reviewed only when their call ans…
RaghwendraSingh Nov 25, 2026
d9114be
fix(review): record the verifier's stopped and failed findings for re…
RaghwendraSingh Nov 25, 2026
d767de1
fix(review): unknown keys under `ai:` fail the config load
RaghwendraSingh Nov 25, 2026
3db21a5
fix(review): hand outside-project Python files on per file under `--a…
RaghwendraSingh Nov 27, 2026
fcb133b
fix(review): refuse a system-prompt file inside the git work tree
RaghwendraSingh Nov 27, 2026
9d5ab27
fix(review): AI switch env values accept common boolean spellings; ot…
RaghwendraSingh Nov 27, 2026
229b4ca
fix(review): list over-quota `other` files a rule lane checked in `ai…
RaghwendraSingh Nov 27, 2026
efe08b0
fix(review): carry `ai.failedFiles` through an AI replay
RaghwendraSingh Nov 27, 2026
2c62729
fix(review): state the default-on AI parts and their cost; drop stale…
RaghwendraSingh Nov 27, 2026
051d0ec
fix(review): check the system-prompt file against the reviewed reposi…
RaghwendraSingh Nov 27, 2026
f8220e7
fix(review): a lane that did not answer leaves outside Python files p…
RaghwendraSingh Nov 27, 2026
4ceacf0
fix(review): the system-prompt file tests pass a temp repository as t…
RaghwendraSingh Nov 27, 2026
7aaafff
fix(review): trusted files check every enclosing work tree and the na…
RaghwendraSingh Nov 27, 2026
161aecd
test(review): the outside-project handoff test clears an exported `AL…
RaghwendraSingh Nov 27, 2026
0f0657c
fix(review): make the once-per-value switch warning explicit; documen…
RaghwendraSingh Nov 27, 2026
6cc6ea7
fix(review): `--all-projects` passes on an outside Python file that o…
RaghwendraSingh Nov 27, 2026
0d01d45
fix(review): a Python file renamed out of the dbt project is offered …
RaghwendraSingh Nov 27, 2026
c40cf42
fix(review): no ignored-value warning for AI switches when the lane i…
RaghwendraSingh Nov 27, 2026
e9589ed
fix(review): a refused trusted file names the work tree it was found …
RaghwendraSingh Nov 27, 2026
76c8f14
fix(review): a file renamed out of the dbt project counts as outside …
RaghwendraSingh Nov 27, 2026
0df0c64
fix(review): a trusted file is refused when its symlink chain passes …
RaghwendraSingh Nov 27, 2026
a4284af
test(review): `--no-ai` suppresses the ignored-value warning end to e…
RaghwendraSingh Nov 27, 2026
f2171af
fix(review): the trusted-file symlink walk is canonical, so a case-va…
RaghwendraSingh Nov 27, 2026
86f22a2
refactor(review): one `isOutsideProjectReason` predicate for the outs…
RaghwendraSingh Nov 27, 2026
f0f439e
test(review): the case-variant work-tree test is skipped visibly on a…
RaghwendraSingh Nov 27, 2026
c8181d7
docs(review): the ignored-value warning is printed when the AI lane i…
RaghwendraSingh Nov 27, 2026
d25b745
test(review): the `caseSensitiveTmp` comment says what the value means
RaghwendraSingh Nov 28, 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
45 changes: 41 additions & 4 deletions docs/docs/usage/dbt-pr-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,17 @@ dialect: snowflake
# several adapters (`postgres__x`, `snowflake__x`) still gets advice
# on constructs one of those adapters lacks. Set true to see all of it.
reviewers: [] # empty = risk-tier defaults; or pin lanes
ai: true # the advisory AI lane; false turns it off. Or an object, all keys
# optional and on by default; an unknown key fails the load
# (see "AI reviewer lane" below):
# ai:
# enabled: true
# coverage: true # per-kind file quotas and hunk excerpts instead of a 20-file cap
# contextCard: true # dbt manifest context with each changed model
# focused: true # related files reviewed together in a few calls on larger PRs
# otherFiles: true # other/analysis files inside the project (.sql/.yml/.yaml)
# pythonFiles: true # changed Python files, inside or outside the project
# verify: true # the dbt-grounded verifier over the AI comments
dataDiff: # OFF by default — see "Data-diff in CI" below
enabled: false
warehouse: "" # connection name; empty = default connection
Expand Down Expand Up @@ -611,10 +622,36 @@ across 12 dialects all plan; anything still unrecognized stays *undecidable*, ne
runs **after** the deterministic lanes, grounded in their findings, and adds
advisory contextual comments (intent, naming, business logic, test coverage).
It sees every changed dbt file, not only models: macros, singular data tests,
snapshots, schema/source yml, seeds (diff only) and project config, each
labeled with its role, with models first under the 20-file cap.
Findings are clamped to ≤ warning and never block. Skipped (clean degrade) if
no model is available.
snapshots, schema/source yml, seeds (diff only) and project config, plus other
changed project files (analyses, CI and config yml, scripts) and changed Python
files anywhere in the repository, each labeled with its role, under per-kind
quotas (models 12, macros 8, tests 4, yml 6, other 8, Python 6; with `coverage`
off, one 20-file cap applies instead). Related files
are reviewed together, with manifest context where a manifest has facts for the
file, and a dbt-grounded verifier then checks every AI comment against the code:
refuted ones are dropped; unverifiable cross-file and speculative ones go to the
summary, as do ones the verifier did not reach before its budget or timeout;
unverifiable local comments with a valid evidence line stay inline (the rest are
dropped). Findings are clamped to ≤ warning
and never block. Skipped (clean degrade) if no model is available. Every part is
on by default, so with a model configured the default review makes more model
calls than the finder alone (the verifier, and more files per PR): more tokens and
wall time per review. Each part can be turned off under `ai:` in
`.altimate/review.yml` (for example `ai: { verify: false }`) or with its env
variable set to `0` (`ALTIMATE_REVIEW_AI_COVERAGE`, `_CONTEXT_CARD`, `_FOCUSED`,
`_OTHER_FILES`, `_PYTHON_FILES`, `_VERIFY`); `1` turns one on. `true`/`false`,
`on`/`off` and `yes`/`no` are accepted too; an empty value counts as unset, and
any other value is ignored (with a warning, printed once per value and only when
the AI lane is enabled). `ai: false` turns the whole lane off.
`ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE=<file>` replaces the finder's system
prompt. The path must be absolute and outside the repository checkout (for
example under `$RUNNER_TEMP`); a file inside the reviewed repository or the
current directory's git work tree (or any work tree around them), a symlink to
one, or a path whose resolution passes through a symlink inside one (also from
an outside alias) is refused, since a PR could change it, and so is any file
when neither resolves to a work tree. The error names the work tree it found;
note that a home directory that is itself a git repository (dotfiles kept in
git) is such a work tree, so files anywhere under it are refused.
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 →
Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/src/altimate/review/ai-context-card.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// altimate_change - new file: dbt manifest context card for the AI lane
//
// Opt-in (`ALTIMATE_REVIEW_AI_CONTEXT_CARD=1`, needs a manifest): each file
// On by default in `reviewPullRequest` (the `contextCard` switch; opt out with
// `ai: { contextCard: false }` or `ALTIMATE_REVIEW_AI_CONTEXT_CARD=0`; needs a manifest): each file
// sent to the AI reviewer carries a short block of manifest facts the diff does
// not show — materialization and keys, parents and children, declared columns
// and their tests, sibling models; for a macro, its callers and adapter variants.
Expand Down
24 changes: 24 additions & 0 deletions packages/opencode/src/altimate/review/ai-other-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// altimate_change - new file: other changed project files for the AI lane
//
// With the `otherFiles` switch (`ALTIMATE_REVIEW_AI_OTHER_FILES`), changed files of kind
// `other` or `analysis` inside the dbt project root also go to the AI lane, under their own
// coverage quota (`ALTIMATE_REVIEW_AI_QUOTA_OTHER`), after the existing kinds. No rule lane
// reads them. Off, the lane's input is unchanged. `.py` files are not among them: Python
// files reach the lane only through the `pythonFiles` switch (ai-python-files.ts), under
// the Python quota, so turning that switch off stops every Python file.

/** Kinds the switch adds. */
export const AI_OTHER_KINDS: ReadonlySet<string> = new Set(["other", "analysis"])
/** Extensions the switch accepts. */
export const AI_OTHER_EXTENSIONS = [".sql", ".yml", ".yaml"]
/** Default coverage quota for the added files. */
export const AI_OTHER_FILES_QUOTA = 8

/** A changed file the switch adds: other/analysis kind, not deleted, allowed extension. */
export function isAiOtherFile(f: { path: string; status: string; kind?: string }): boolean {
return (
AI_OTHER_KINDS.has(f.kind ?? "") &&
f.status !== "deleted" &&
AI_OTHER_EXTENSIONS.some((ext) => f.path.toLowerCase().endsWith(ext))
)
}
19 changes: 19 additions & 0 deletions packages/opencode/src/altimate/review/ai-python-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// altimate_change - new file: changed Python files for the AI lane
//
// With the `pythonFiles` switch (`ALTIMATE_REVIEW_AI_PYTHON_FILES`), every changed,
// non-deleted `.py` file in the repository (inside or outside the dbt project root) that the
// lane does not already send goes to the AI lane, under its own coverage quota
// (`ALTIMATE_REVIEW_AI_QUOTA_PYTHON`), after the existing kinds. Files outside the project
// root reach the orchestrator only for the AI lane (`OrchestrateInput.aiOutsideFiles`); no
// rule lane reads them. Off, the lane's input is unchanged.
import { shouldReview } from "./diff-filter"

/** Kind the added files carry in the AI lane. */
export const AI_PYTHON_KIND = "python_file"
/** Default coverage quota for the added files. */
export const AI_PYTHON_FILES_QUOTA = 6

/** A changed file the switch adds: `.py`, not deleted, not a build or vendored path. */
export function isAiPythonFile(f: { path: string; status: string }): boolean {
return f.status !== "deleted" && f.path.toLowerCase().endsWith(".py") && shouldReview(f.path)
}
9 changes: 6 additions & 3 deletions packages/opencode/src/altimate/review/ai-replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { Provider } from "@/provider/provider"
import { Log } from "@/altimate/util/log"
import { Finding, ReviewCategory, makeFinding, ruleId } from "./finding"
import type { AiLaneStatus, AiReviewInput, AiReviewResult } from "./ai-review"
import { aiVerifyEnabled, runAiVerify, type VerifierStatus } from "./ai-verify"
import { runAiVerify, type VerifierStatus } from "./ai-verify"
import { switchOn } from "./ai-switches"
import { modelNameFromPath } from "./orchestrate"

const log = Log.create({ service: "ai-replay" })
Expand Down Expand Up @@ -43,6 +44,7 @@ const ReplayEnvelope = z.object({
tokens: Tokens.optional(),
cost: z.number().optional(),
calls: z.number().optional(),
failedFiles: z.array(z.string()).optional(),
verifier: z
.object({
discarded: z.number().optional(),
Expand Down Expand Up @@ -70,7 +72,7 @@ const ReplayEnvelope = z.object({

export interface ReplayedLane {
findings: Finding[]
/** The stored generator status: state, reason, model, tokens, cost, calls. */
/** The stored generator status: state, reason, model, tokens, cost, calls, failed files. */
status: Omit<AiLaneStatus, "durationMs" | "verifier">
/** Problems found while rebuilding (findings that could not be recovered). */
warnings: string[]
Expand All @@ -94,6 +96,7 @@ export function replayFindings(raw: unknown): ReplayedLane {
...(ai.tokens ? { tokens: ai.tokens } : {}),
...(ai.cost !== undefined ? { cost: ai.cost } : {}),
...(ai.calls !== undefined ? { calls: ai.calls } : {}),
...(ai.failedFiles?.length ? { failedFiles: ai.failedFiles } : {}),
replayed: true,
}
const warnings: string[] = []
Expand Down Expand Up @@ -189,7 +192,7 @@ export async function runAiReplay(input: AiReviewInput, path: string): Promise<A

let findings = lane.findings
let verifier: VerifierStatus | undefined
if (input.evidence && aiVerifyEnabled()) {
if (input.evidence && switchOn("verify", input.switches)) {
let model: Awaited<ReturnType<typeof Provider.getModel>>
try {
const chosen = input.model ? Provider.parseModel(input.model) : await Provider.defaultModel()
Expand Down
Loading
Loading