Repository navigation
feat(review): wider AI lane input, ai: switches in config, and the measured lane configuration on by default - #1836
RaghwendraSingh wants to merge 34 commits into
Conversation
…nfig and defaults - `ai` in `.altimate/review.yml` takes `true`/`false` or an object: `enabled` plus optional `coverage`, `contextCard`, `focused`, `otherFiles`, `pythonFiles`, `verify`; every key is optional so the default policy hash is unchanged - `ai-switches.ts`: `resolveAiSwitches` gives each switch from its env variable (`1` on, `0` off), then the config object, then the product default (all off in this commit) - `run.ts` resolves the switches once and passes them to the orchestrator and the AI lane; `aiInputBudget`, the verifier check and the replay verifier read them, and fall back to the env variable alone when called without them - tests: precedence, env-only fallback, budget, config forms and policy hash Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Files` switch) - with `ai.otherFiles` / `ALTIMATE_REVIEW_AI_OTHER_FILES=1`, changed `other` and `analysis` files inside the dbt project root (`.sql`, `.yml`, `.yaml`, `.py`, not deleted, not credential-like) go to the AI lane after the supporting files, with their head content - under coverage they take their own quota, `ALTIMATE_REVIEW_AI_QUOTA_OTHER` (default 8), selected apart and appended after the existing buckets; existing quotas, spare and order are unchanged - sections get a label and a fence by extension; the `ai.input` row carries the kind - a file the lane sent is no longer listed as "not a dbt model/macro/test/yml/seed file" - off (the default in this commit), the lane's input and the ledger are unchanged - tests: off unchanged, on adds allowed files, quota, deleted, disallowed and out-of-root files left out, ledger, resolved switches over env, a finding on an added file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… switch) - with `ai.pythonFiles` / `ALTIMATE_REVIEW_AI_PYTHON_FILES=1`, every changed `.py` file (not deleted, not a build or vendored path, not excluded, not credential-like) that the lane does not already send goes to it after every other file, as kind `python_file`, inside or outside the dbt project root - files outside the project root reach the orchestrator as `aiOutsideFiles`, read by the AI lane only; under coverage they take their own quota, `ALTIMATE_REVIEW_AI_QUOTA_PYTHON` (default 6); existing quotas, spare and order are unchanged - an outside file the lane sent and reviewed (the lane answered) is not listed as "outside the dbt project" in `scope.notReviewed`; it is recorded in `scope.aiReviewedOutside` and `outOfScopeFiles` drops by one; if the lane failed it stays listed - the stderr "were not reviewed" count leaves out the outside files the AI lane takes; a second line counts them - `--all-projects`: outside files go to the first touched project's AI lane only (`aiOutsidePython`), and the merge treats a path any project's AI lane reviewed as reviewed - off (the default in this commit), the lane's input and the scope are unchanged - tests: off unchanged, inside and outside files, quota, no double add with other files, scope after an ok and a failed lane, stderr lines, multi-project merge and a two-project dry run with the file in one project's input Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nder's system prompt - the finder prompt still comes from the compiled core; when the variable names a file, its text replaces the core prompt for every finder call (the test-gap addition still applies) - an unreadable or empty file is an error reported as the lane's state, never a silent fallback to the core prompt - env only: a `.altimate/review.yml` key would point at a file the PR can edit - tests: core prompt when unset, file text when set without asking core, empty and missing files are errors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the summary - when a verifier batch answers early on its token or tool-output budget (`budget` state), the findings it gave no verdict for were kept inline, unverified; under the open fail mode they now go to the summary (`verification.decision: summary`, rule `unreviewed_stopped`), counted under `summary` - a batch that finished normally keeps an omitted finding as before; timeouts and errors are unchanged; the closed fail mode still discards - `retriage` replays the new rule from recorded decisions - tests: budget demotion and inline eligibility, normal batch unchanged, closed fail mode Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- coverage quotas and hunk excerpts, manifest context cards, focused batches, other project
files, Python files and the AI verifier are now on whenever the AI lane runs; measured
together, this configuration found more real defects per PR with fewer wrong comments
than the opt-in pieces alone
- each one is opt-out with `ai: { <switch>: false }` in `.altimate/review.yml` (read from
the base branch) or its env variable set to `0`; `1` still turns one on
- with the AI lane off (`--no-ai`, `ai: false`, no model) nothing changes
- docs: the `ai:` object and what the lane now reads
- tests: defaults and opt-outs, flags-off identity (planner and orchestrator input and
envelope equal the env-only path), `--no-ai` envelope identical with every switch on or off
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o to the summary - a verifier batch that times out leaves its findings without a verdict, like one that answers early on the budget; under the open fail mode they now go to the summary (`verification.decision: summary`, rule `unreviewed_stopped`) instead of inline - the same applies when the deadline hits before any batch ran (graph gathering): every finding goes to the summary, counted under `summary` - errors are unchanged (open keeps, closed discards); the closed fail mode still discards - tests: batch timeout and timeout before any batch demote to the summary, closed fail mode discards on a timeout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
2 issues found across 18 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/run.ts">
<violation number="1" location="packages/opencode/src/altimate/review/run.ts:390">
P2: This message says the outside Python files "go to the AI review only", but the AI lane is skipped when the tier is `trivial`. A PR that changes only outside-project `.py` files is classified `trivial` because the in-scope list is empty, so they are never sent. Say the files go to the AI lane when it runs, or make the tier include them.</violation>
</file>
<file name="packages/opencode/src/altimate/review/ai-switches.ts">
<violation number="1" location="packages/opencode/src/altimate/review/ai-switches.ts:31">
P3: These defaults enable context cards and verification for `reviewPullRequest`, but their module comments still describe both features as opt-in. Update those comments to reflect the default and opt-out settings.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| */ | ||
| export const AI_SWITCH_DEFAULTS: AiSwitches = { | ||
| coverage: true, | ||
| contextCard: true, |
There was a problem hiding this comment.
P3: These defaults enable context cards and verification for reviewPullRequest, but their module comments still describe both features as opt-in. Update those comments to reflect the default and opt-out settings.
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/ai-switches.ts, line 31:
<comment>These defaults enable context cards and verification for `reviewPullRequest`, but their module comments still describe both features as opt-in. Update those comments to reflect the default and opt-out settings.</comment>
<file context>
@@ -0,0 +1,58 @@
+ */
+export const AI_SWITCH_DEFAULTS: AiSwitches = {
+ coverage: true,
+ contextCard: true,
+ focused: true,
+ otherFiles: true,
</file context>
There was a problem hiding this comment.
✅ Fixed in d9114be28e: the module comments in ai-verify.ts and ai-context-card.ts now say both are on by default in reviewPullRequest and name how to opt out. Comments only.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The incremental range Files Reviewed (1 file)
Previous Review Summaries (6 snapshots, latest commit c8181d7)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit c8181d7)Status: No Issues Found | Recommendation: Merge The previous finding (the duplicated Files Reviewed (7 files, incremental diff f2171af..c8181d7)
Previous review (commit f2171af)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (9 files, incremental diff e9589ed..f2171af)
Fix these issues in Kilo Cloud Previous review (commit e9589ed)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (10 files, incremental diff 4ceacf0..e9589ed)
Fix these issues in Kilo Cloud Previous review (commit 4ceacf0)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (17 files)
Fix these issues in Kilo Cloud Previous review (commit d767de1)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (15 files)
The 8 findings from the previous review at Fix these issues in Kilo Cloud Previous review (commit e7f27d7)Status: 8 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (18 files)
Note: inline review comments could not be published from this sandbox (the review-write command form requires piped stdin, which this environment blocks), so every finding is listed above with its file and line. Reviewed by deepseek-v4.1-flash-1017 · Input: 50.8K · Output: 3.6K · Cached: 404K Review guidance: REVIEW.md from base branch |
…wered; Python files go through `pythonFiles` only
- `.py` is no longer an `otherFiles` extension: in-project Python files reach the AI lane
only through `pythonFiles`, under the Python quota, so `pythonFiles: false` stops them all
- `runAiReview` reports `ai.failedFiles` (files only in calls that failed while others
answered); the coverage ledger keeps other/analysis/Python files listed as not reviewed
when the lane errored, timed out or failed for their call, instead of when it was sent
- `ai.unsent` no longer lists other/analysis/Python files over their quota: nothing but
the AI lane reads them, so they stay in the "Not reviewed" ledger instead of being
described as checked by the deterministic lanes
- the verifier and suggestion validation see the added lines of outside-project files, so
their findings are no longer triaged as `unchanged_code`
- `--all-projects`: outside-project Python files are offered to the next project while a
project's AI lane does not run or take them (off in its policy, a tier without the lane)
- run.ts: the disabled reason covers both `ai: false` and `ai: { enabled: false }`; the
outside-Python stderr line says the files are offered to the lane when it runs
- tests: in-project .py not sent by `otherFiles` alone; lane error/timeout/partial failure
keep files in the ledger (in and outside the project); outside-file added lines reach
the verifier; the next project takes the files when the first's policy turns the lane
off; Python files over quota are not in `ai.unsent`; stderr restored in `finally`; the
spare test uses more models than the quotas can take
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-triage under either fail mode
- `triage` records `unreviewed_stopped` for a finding left without a verdict by a timeout or
budget under the closed fail mode too (still discarded), so `retriage` with open knobs
moves it to the summary instead of keeping it
- the failure path of `runAiVerify` (timeout before or outside a batch, unexpected error)
now records a `VerifierDecision` per finding; features not yet computed are computed
without the graph's model names
- remove the unused `aiVerifyEnabled` (the `verify` switch replaced it); the module
comments of the verifier and context cards describe them as on by default, opt-out
- tests: closed-mode stopped rule and its re-triage, decisions on a timeout before any
batch ran, `switchOn("verify")` env-only semantics
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- the `ai:` object is a `z.strictObject`, so a typo such as `ai: { enable: false }` fails
the load and names the key instead of leaving the lane running
- the config comment says env overrides are the operator's CI setting, not repository policy
- docs: verifier routing as `triage()` does it (refuted dropped; unverifiable cross-file,
speculative and unreached go to the summary; plausible local ones stay inline), manifest
context where available, `otherFiles` extensions, unknown `ai:` keys
- tests: unknown key rejected; the object form's policy hash; the flags-off baseline clears
ambient `ALTIMATE_REVIEW_AI_*` variables
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ai: switches in config, and the measured lane configuration on by default
|
Re the kilo summary comment (#1836 (comment)):
|
There was a problem hiding this comment.
All reported issues were addressed across 15 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| const supporting = reviewable.filter( | ||
| (f) => AI_SUPPORTING_KINDS.has(f.kind) && f.status !== "deleted" && !mayHoldCredentials(f.path), | ||
| ) | ||
| // `otherFiles`: other/analysis files inside the project root (.sql/.yml/.yaml/.py), after the supporting files. |
There was a problem hiding this comment.
SUGGESTION: This comment still lists .py under otherFiles, but AI_OTHER_EXTENSIONS no longer accepts .py (ai-other-files.ts:13): Python files now reach the lane only through the pythonFiles block below. The config schema, docs and ai-other-files.ts header were updated for that change; this comment was missed.
| // `otherFiles`: other/analysis files inside the project root (.sql/.yml/.yaml/.py), after the supporting files. | |
| // `otherFiles`: other/analysis files inside the project root (.sql/.yml/.yaml), after the supporting files. |
There was a problem hiding this comment.
✅ Fixed in 2c627299c5. The comment now lists .sql/.yml/.yaml. The unreachable .py branch in fenceOf is gone too. Comment and dead code only.
| const dryRun = aiDryRunEnabled() | ||
| // Recorded only when an opt-in switch changed or inspects the input, so the default envelope is unchanged. | ||
| // Files only the AI lane reads are not "checked by the deterministic lanes"; the ledger lists them. | ||
| const unsent = plan.unsent.filter((f) => !AI_ONLY_KINDS.has(f.kind ?? "")).map((f) => f.path) |
There was a problem hiding this comment.
SUGGESTION: Kind other is not AI-only, so this filter over-drops. orchestrate.ts:2339 marks every .yml file of kind other as checked by the dbt_patterns lane (checkedOther → otherChecked + touch), so when the other quota keeps such a file from the model it is in neither ai.unsent (filtered here) nor scope.notReviewed (the ledger skips otherChecked/touched files): it disappears from the report entirely. The PR description says those files stay in the "Not reviewed" ledger instead. Filtering only the kinds no rule lane reads (analysis, python_file), or passing the deterministic lanes' checked paths down from the orchestrator, keeps both lists accurate.
There was a problem hiding this comment.
✅ Same fix as 4694825418, in 229b4cad3a. I passed the deterministic lanes' checked paths down rather than filtering by kind, because other YAML is the kind that both a rule lane and the AI lane read. Same test.
| state: "ok", | ||
| model: modelLabel, | ||
| ...(reason ? { reason } : {}), | ||
| ...(failedFiles.length ? { failedFiles } : {}), |
There was a problem hiding this comment.
SUGGESTION: failedFiles is not carried through replay. replayFindings (ai-replay.ts:91) copies only state/reason/model/tokens/cost/calls into the replayed status, so a partially failed envelope replayed with ALTIMATE_REVIEW_AI_REPLAY comes back as state: "ok" without failedFiles. orchestrate.ts:2803 then treats every path in the recomputed aiSentPaths as reviewed, so the files its failed calls never carried are reported as covered. Copying the field into ReplayedLane["status"] keeps the replay envelope's coverage consistent with the live one.
There was a problem hiding this comment.
✅ Fixed in efe08b06db. The replay schema reads ai.failedFiles and replayFindings copies it into the replayed status, so the ledger keeps those files listed as not reviewed. Test: a partly failed lane keeps its failed files, so the ledger still lists them (review-ai-replay.test.ts).
hkaltai
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Reviewers: lead + Sol 6.1 (Codex) + Claude. One convergence round: both external reviewers asked for corrections to the synthesis (fix wording for the multi-project handoff, severity of the verifier parse/budget item, a duplicate folded in); all were applied and no blocking finding remains disputed.
Blocking:
--all-projects: outside-project Python files are dropped when an earlier project's lane answers without taking them (multi-project.ts:169).
Also (minor): the sub-switches now default on, which is intended but contradicts the "opt-in" wording in #1792, so update the issue or docs and note the added model cost; prompt-file override can point into the PR checkout; outside-Python findings skip pre-existing classification; env values other than 1/0 now mean on.
Missing tests: multi-project handoff when the first project's lane answers with pythonFiles: false or takes only some files; outside-Python context-line finding with the verifier off; non-1/0 env values; coverage: false with other/Python files on; relative or symlinked prompt file.
Scope vs ticket: findings. The work fits the coverage and AI-lane goals, but the intended default-on flip needs the ticket's opt-in statement updated; the prompt override and outside-project Python support are not listed in the ticket.
Findings outside the diff hunks
packages/opencode/src/altimate/review/orchestrate.ts:2629— MINOR: Outside-Python AI findings skip pre-existing classification
out = markPreExisting(anchorByEvidence(out, input.changedFiles), input.changedFiles)cleanFindings runs markPreExisting(anchorByEvidence(out, input.changedFiles), input.changedFiles). Outside-project Python files are not in input.changedFiles (only validateSuggestions gets the combined list), so markPreExisting returns their findings unmarked. A finding on an unchanged context line of such a file can post inline when the verifier is off or fails, while the same finding on an in-project file would be marked pre-existing.
Suggested fix: use the combined list here too:
const scoped = [...input.changedFiles, ...(input.aiOutsideFiles ?? [])]
out = markPreExisting(anchorByEvidence(out, scoped), scoped)Raised by: Codex
Nits
packages/opencode/src/altimate/review/ai-verify.ts:1095— Budget-forced unparsable answer is an error, not a stop: When the budget forces an answer (state = "budget"at line 1069) and it does not parse, the state becomeserror, sorunAiVerifydoes not mark the batchstoppedand findings stay inline under the open fail mode. The existing test encodes this as intentional; consider whether a budget stop should win here and document the choice.
Raised by: lead
packages/opencode/src/altimate/review/ai-review.ts:114— Other/Python quotas apply only with coverage on:otherQuotaandpythonQuotaexist only inside thecoverageblock. Withai: { coverage: false }, other/Python files go throughselectAiFilesunder the 20-file cap, ranked last. Mention "(withcoverage)" in the docs and comments.
Raised by: lead
packages/opencode/src/altimate/review/orchestrate.ts:2681— Stale .py in otherFiles comment:isAiOtherFileaccepts only.sql/.yml/.yaml; Python goes throughpythonFiles. Drop/.pyfrom the comment.
Raised by: lead, Claude
packages/opencode/src/altimate/review/ai-review.ts:214— Unreachable .py branch in fenceOf: Onlyother/analysiskinds reach this line andisAiOtherFilenever admits.py; Python files get their fence fromFENCE. Remove the branch.
return p.endsWith(".yml") || p.endsWith(".yaml") ? "yaml" : "sql"Raised by: lead, Claude
packages/opencode/src/altimate/review/ai-review.ts:987— Stale comment about the default envelope: With the switches on by default, the default envelope now recordsai.input/ai.unsent, so "so the default envelope is unchanged" is no longer true. Reword.
Raised by: Claude
packages/opencode/src/altimate/review/ai-review.ts:33— Comments still describe switches as opt-in / =1: Comments atai-review.ts:33,44,60,66,741,946,orchestrate.ts:293andverdict.ts:272,288,292still describe coverage, focused batches and the verifier as opt-in=1features. Refer to the switch names and their default-on, opt-out behaviour.
Raised by: Claude
packages/opencode/src/altimate/review/telemetry.ts:132— out_of_scope_files telemetry changes meaning:outOfScopeFilesnow excludes outside files the AI lane reviewed, so this telemetry value means something different after this change. Note it, or add a separateai_reviewed_outsidecount.
Raised by: Claude
| prRenames, | ||
| aiOutsidePython: outsidePythonPending, | ||
| }) | ||
| if (env.ai?.state === "ok" || (env.ai?.input ?? []).some((r) => unassignedPaths.has(r.path))) outsidePythonPending = false |
There was a problem hiding this comment.
MAJOR: Outside-Python handoff cleared by a project that did not take the files
if (env.ai?.state === "ok" || (env.ai?.input ?? []).some((r) => unassignedPaths.has(r.path))) outsidePythonPending = falseUnder --all-projects, outsidePythonPending is cleared whenever a project's AI lane state is ok, even if that project never received the outside-project Python files (its policy has ai: { pythonFiles: false }, so run.ts gives it an empty aiOutsideFiles, or exclusions/tier dropped them). Later projects with pythonFiles on get aiOutsidePython: false, so those files are never reviewed. This contradicts the stated behaviour ("the first project whose AI lane runs and takes them") and makes coverage depend on project order.
Suggested fix: drop the unconditional state === "ok" disjunct and clear only on evidence the files were taken (keep ai.input, which also covers dry runs, and add scope.aiReviewedOutside):
const took = (env.ai?.input ?? []).some((r) => unassignedPaths.has(r.path)) ||
(env.scope?.aiReviewedOutside ?? []).some((p) => unassignedPaths.has(p))
if (took) outsidePythonPending = falseMore robust: pass the still-unreviewed outside paths instead of a boolean, so a partial take neither duplicates nor drops files. Add a test where the first project's lane answers with pythonFiles: false.
Raised by: lead, Codex, Claude
There was a problem hiding this comment.
✅ Fixed in 3db21a5128. The boolean is gone. reviewAllProjects now keeps the set of outside-project Python files that no lane has taken yet and passes it to each project as aiOutsidePaths (this replaces aiOutsidePython in run.ts). A file leaves the set only when it shows up in that project's ai.input or scope.aiReviewedOutside. A lane that answers without taking the file (for example ai: { pythonFiles: false }, its quota or exclusions) passes it on. A partial take passes on only the files it did not take. Since f8220e794b, a file counts as taken from a project's ai.input only when that lane answered or it is a dry run. A lane that errored, timed out or had no model records its input without reviewing it, so those files go to the next project (outsideTaken). Test: error, timeout or no model: its input stays pending; ok, dry run or reviewed: taken. Test: the first project's lane answers with \pythonFiles: false`: the next project's lane reviews the file(review-ai-python-files.test.ts). It uses a replayed lane so the state isok` with no model call, and it fails on the pushed head.
| export const AI_SWITCH_DEFAULTS: AiSwitches = { | ||
| coverage: true, | ||
| contextCard: true, | ||
| focused: true, | ||
| otherFiles: true, | ||
| pythonFiles: true, | ||
| verify: true, | ||
| } |
There was a problem hiding this comment.
MINOR: Sub-switch defaults now on: issue #1792 still says the AI features are opt-in
export const AI_SWITCH_DEFAULTS: AiSwitches = {
coverage: true,
contextCard: true,
focused: true,
otherFiles: true,
pythonFiles: true,
verify: true,
}The base already had ai: true by default; this PR also turns on all six sub-switches (coverage, contextCard, focused, otherFiles, pythonFiles, verify). That matches the PR's stated intent, but issue #1792 still says "All AI features are opt-in; the default review adds no model calls". For any repo with a model configured, the default review now makes more model calls (verifier plus wider input), which raises cost and latency.
Suggested fix: update the issue/docs so the default is stated accurately, and call out the cost change in the release notes / review.yml docs, including how to opt out (ai: { verify: false, ... } or the ALTIMATE_REVIEW_AI_*=0 env variables).
Raised by: lead, Codex, Claude (severity adjusted: the default-on behaviour is intended)
There was a problem hiding this comment.
✅ Docs fixed in 2c627299c5. The AI-lane paragraph now says every part is on by default, that this means more model calls (the verifier and more files per PR, so more tokens and wall time), and how to opt out: ai: { verify: false }, env 0, or ai: false. The PR description now says the same and points out the conflict with #1792. I have not edited issue #1792. That needs its owner, or a comment from us once the PR is final.
| export async function finderSystemPrompt(env: Record<string, string | undefined> = process.env): Promise<string | undefined> { | ||
| const file = env.ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE | ||
| if (file) { | ||
| const text = await readFile(file, "utf8") | ||
| if (!text.trim()) throw new Error(`ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE is empty: ${file}`) | ||
| return text | ||
| } |
There was a problem hiding this comment.
MINOR: System-prompt override can read a PR-controlled file
export async function finderSystemPrompt(env: Record<string, string | undefined> = process.env): Promise<string | undefined> {
const file = env.ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE
if (file) {
const text = await readFile(file, "utf8")
if (!text.trim()) throw new Error(`ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE is empty: ${file}`)
return text
}The override is env-only so a PR cannot change it, but readFile(file) resolves a relative path against the current directory (the PR checkout in CI) and follows symlinks. An operator who sets ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE=.github/review-prompt.md lets any PR rewrite the finder's system prompt. The docs do not warn about this.
Suggested fix: require an absolute path and reject one whose realpath is inside the git work tree; document that the file must live outside the checkout (e.g. $RUNNER_TEMP). Optionally keep the path out of the envelope reason.
Raised by: lead, Codex, Claude
There was a problem hiding this comment.
✅ Fixed in fcb133bfcd. ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE must now be an absolute path. Its realpath, with symlinks followed, must not be inside the git work tree of the current directory, which is the PR checkout in CI. Otherwise the review refuses the file and the lane reports an error instead of using it. The error messages no longer echo the path, and the docs say to keep the file outside the checkout (for example under $RUNNER_TEMP). Tests: a relative path is refused: it would resolve inside the PR checkout and a file inside the git work tree, or a symlink to one, is refused (review-ai-system-prompt.test.ts). Tightened in 051d0ecd20. The shared trustedFilePath helper (new trusted-file.ts) checks the realpath against two work trees: the reviewed repository (the --cwd git root, passed down as reviewDir) and the process's current directory. It finds each work tree by walking up to a .git entry, with no git call, so safe.directory cannot hide it. When neither directory resolves to a work tree, the file is refused. The prefix test now treats <repo>/..p.md as inside, and the file read is the realpath that was checked. Tests: a file whose name starts with \..` inside the review's repository is refused, fails closed when neither the review's directory nor the process's resolves to a work treeandrunReview hands the lane the review's repository. The prompt-file tests pass a temporary git repository as the review directory (4ceacf0`), so they do not depend on running inside a checkout.
| export function envSwitch(name: AiSwitchName, env: Env = process.env): boolean | undefined { | ||
| const v = env[AI_SWITCH_ENV[name]] | ||
| return v === "1" ? true : v === "0" ? false : undefined | ||
| } |
There was a problem hiding this comment.
MINOR: Env values other than 1/0 now fall through to on
export function envSwitch(name: AiSwitchName, env: Env = process.env): boolean | undefined {
const v = env[AI_SWITCH_ENV[name]]
return v === "1" ? true : v === "0" ? false : undefined
}Before this PR each switch was === "1", so any other value (false, off, empty) meant off. envSwitch now returns undefined for those, and resolveAiSwitches falls back to the default true. A workflow that disabled a switch with =false silently gets it on. This is a compatibility change rather than a break of the new documented 1/0 contract.
Suggested fix: accept common boolean spellings (true/false/on/off/yes/no), or write a stderr warning when a set value is ignored; document the accepted values.
Raised by: lead
There was a problem hiding this comment.
✅ Fixed in 9d5ab27f5a. envSwitch reads 1/true/on/yes as on and 0/false/off/no as off, trimmed and case-insensitive, so =false turns a switch off again. Any other non-empty value is ignored: resolveAiSwitches writes a stderr warning that names the variable, then the config or the default applies. An empty value counts as unset. The warning is written once per value per process (f8220e794b), not once per project under --all-projects; test the warning for one value is written once per process, not once per project. The docs list the accepted values. Tests: common boolean spellings are accepted, so \=false` still turns a switch offanda value that is not a boolean is ignored with a warning naming the variable(review-ai-switches.test.ts). Changed expectation: the wiring test in review-ai-verify.test.ts asserted thatALTIMATE_REVIEW_AI_VERIFY=true leaves the verifier off. It now asserts on, which is the change this thread asked for, and checks an unrecognized value (maybe`) for off.
…ll-projects`; classify their findings pre-existing
- `reviewAllProjects` keeps the set of outside-project Python files no lane
has taken yet and passes it as `aiOutsidePaths`. A file leaves the set only
when it is in a project's `ai.input` or `scope.aiReviewedOutside`, so a
project whose lane answers without taking it (`ai: { pythonFiles: false }`,
quota, exclusions) no longer clears the handoff for later projects.
- `run.ts`: `aiOutsidePython?: boolean` becomes `aiOutsidePaths?: string[]`.
- `cleanFindings` runs `anchorByEvidence`/`markPreExisting` over the in-scope
files plus `aiOutsideFiles`, so a finding on an unchanged context line of an
outside-project file is marked pre-existing like an in-project one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ALTIMATE_REVIEW_AI_SYSTEM_PROMPT_FILE` must be an absolute path, and its realpath (symlinks followed) must not be inside the git work tree of the current directory, which in CI is the PR checkout. A relative path such as `.github/review-prompt.md` would otherwise let any PR rewrite the finder's system prompt. The error messages no longer echo the path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hers warn Before the switches were resolved together, any value other than `1` meant off, so a workflow with `ALTIMATE_REVIEW_AI_VERIFY=false` would now get the default (on). `envSwitch` now reads `1`/`true`/`on`/`yes` as on and `0`/`false`/`off`/`no` as off (trimmed, case-insensitive). Any other non-empty value is ignored with a stderr warning from `resolveAiSwitches` naming the variable, and the config or default applies. The wiring test that expected `true` to leave the verifier off now expects it on (that is the requested change) and checks an unrecognized value instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….unsent` `runAiReview` dropped every other/analysis/Python file from `ai.unsent` because the coverage ledger lists files only the AI lane reads. But the `dbt_patterns` lane parses changed `other` YAML files (`otherChecked`), and the ledger skips those, so one the other quota kept from the model was reported nowhere. The orchestrator now passes `otherChecked` as `checkedPaths`, and such files stay in `ai.unsent`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`replayFindings` copied only state, reason, model, tokens, cost and calls, so a partly failed envelope replayed with `ALTIMATE_REVIEW_AI_REPLAY` came back without `failedFiles` and the ledger counted the files its failed calls carried as reviewed. The replay schema and status now keep the field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… opt-in comments
- Docs: every AI part is on by default and adds model calls; how to opt
out (`ai: { verify: false }`, env `0`, `ai: false`); accepted env
spellings; quotas apply with `coverage` (one 20-file cap without it);
the system-prompt file must be absolute and outside the checkout.
- Comments that still described coverage, focused batches, context cards
and the verifier as opt-in `=1` features now name their switches.
- `fenceOf`: drop the unreachable `.py` branch (Python files take their
fence from `FENCE`); the `otherFiles` comment no longer lists `.py`.
- Telemetry: `ai_reviewed_outside_files`, since `out_of_scope_files` now
leaves out outside-project files the AI lane reviewed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tory and fail closed
The check used `gitRepoRoot(process.cwd())`: a review run with `--cwd` from
outside the repository, or where git refuses the directory
(`safe.directory`), skipped it, and `<repo>/..p.md` passed the prefix test.
`trustedFilePath` (new `trusted-file.ts`, shared with the rules-off list in
the next PR) requires an absolute path, resolves its realpath and refuses it
when it is inside the review's repository (`reviewDir`, the `--cwd` git root
passed through `OrchestrateInput` and `AiReviewInput`) or the process's
work tree. Work trees are found by walking up to a `.git` entry, with no
git call. When neither resolves, the file is refused. The prefix test is
`rel === ".." || rel.startsWith(".." + sep)`, and the checked realpath is
the one read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ending; warn once per value - `outsideTaken`: a project takes outside-project Python files when it reviewed them (`scope.aiReviewedOutside`), or when they are in its input and its lane answered or it is a dry run. A lane that errored, timed out or had no model recorded its input without reviewing it, so the files are offered to the next project. - The "ignoring <var>=<value>" warning is written once per value per process, not once per project under `--all-projects`. - `envBool` exports the boolean env parsing for other switches to reuse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he review directory The tests that read a prompt file relied on the test process running inside a git checkout (the fail-closed check needs a work tree). They now pass a temporary git repository as `reviewDir`, so they pass wherever they run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re @hkaltai's latest review on this PR, the points in the review text:
|
|
Nits (peer review, Claude + Codex)
Missing tests: a partly failed lane whose failed batch alone carried an outside Python file ( |
…med path, not only the realpath `trustedFilePath` had three gaps: - It stopped at the nearest `.git`, so with the review directory and the process both inside a nested checkout, a file elsewhere in the enclosing PR checkout was accepted. `workTreesOf` now returns every enclosing work tree. - It compared only the realpath, so a path inside the checkout that the PR turns into a symlink (or a linked directory) to an outside file was accepted. The realpath of every directory on the named path is now checked too. - A missing file threw a raw ENOENT that did not name the variable. The error now names it and keeps the errno `code`. Tests (review-ai-system-prompt.test.ts): `a path inside the work tree is refused even when it is a symlink to a file outside`, `a nested checkout does not hide the enclosing work tree`, `a missing file is an error naming the variable`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TIMATE_REVIEW_AI_DRYRUN` Dry run returns before replay, so with `ALTIMATE_REVIEW_AI_DRYRUN=1` in the environment the lane was skipped and the test failed. The key is now cleared with the other ambient variables; the file's `KEYS` restore it afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t that an empty value is unset `!!WARNED.add(warning)` was always true; the set is now updated in the branch body. No behaviour change. The docs now say an empty switch value counts as unset, which is what `envBool` does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nly a failed call carried `outsideTaken` claimed every path in a lane's `ai.input` once the lane state was `ok`, but a partly failed lane is `ok` with the failed calls' files in `ai.failedFiles`. An outside Python file sent only in a failed call was removed from the pending set and never offered to the next project. Those files now stay pending (outside dry runs, which make no call). Test (review-ai-python-files.test.ts): `a partly failed lane: a file only a failed call carried stays pending`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to the AI lane at its new path `scopeToProject` keeps a rename that leaves the project as a deletion at the old path, so the surviving file was neither in scope nor in `outOfScopePaths`, and edits made with the move got no AI review. `scopeToProject` now reports the head paths of such renames (`movedOutPaths`), and `reviewPullRequest` offers them to the AI lane with the other outside Python files. Under `--all-projects` the file is assigned to the project it left, so that project offers it, whatever other projects took. Test (review-ai-python-files.test.ts): `a Python file renamed out of the dbt project is offered to the AI lane at its new path (AI dry run)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s off
`run.ts` resolved the switches even with `--no-ai` or `ai: false`, so a bad
value such as `ALTIMATE_REVIEW_AI_VERIFY=maybe` printed an "ignoring …"
warning for a lane that would not run. `resolveAiSwitches` takes
`{ warn: false }`, which `run.ts` passes when the lane is off; the resolved
values are unchanged.
Test (review-ai-switches.test.ts): `no warning when the AI lane is off
(`--no-ai`, `ai: false`)`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inside `trustedFilePath` now refuses with "is inside the git work tree <tree>", so a work tree the operator did not expect is visible; the file path itself is still not echoed. The docs 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. Test (review-ai-system-prompt.test.ts): `a nested checkout does not hide the enclosing work tree` now checks that the error names the enclosing tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re @hkaltai's review text and nits comment:
|
There was a problem hiding this comment.
All reported issues were addressed across 10 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| if (f.oldPath && inside !== oldInside) { | ||
| const { oldPath, similarity: _similarity, ...rest } = f | ||
| inScope.push(inside ? { ...rest, status: "added" } : { ...rest, path: oldPath, status: "deleted" }) | ||
| if (!inside) movedOutPaths.push(f.path) |
There was a problem hiding this comment.
WARNING: The moved-out head path is not counted as outside the project, so the coverage numbers and the ledger disagree with it.
outOfScopePaths (and with it scoped.outOfScope, scope.notReviewed, format.ts:283 and telemetry out_of_scope_files) excludes this path, but run.ts:385-389 now puts it in aiOutsideFiles. orchestrate.ts:2813-2814 builds aiReviewedOutside from every aiOutsideFiles path, and :2882-2883 subtracts that length from scope.outOfScopeFiles; a reviewed rename-out is therefore subtracted although it was never added. With one genuinely unreviewed outside file plus one reviewed rename-out, max(0, 1 - 1) = 0 turns into undefined, so the signed envelope, the PR comment and telemetry report no skipped outside file while run.ts:389 (correctly) still prints 1.
The same omission hides a moved-out .py that the lane does not review (--no-ai, pythonFiles: false, the Python quota of 6, excludeGlobs, mayHoldCredentials, a trivial tier): it is in neither outOfScopePaths nor scope.notReviewed, and being python_file it is also filtered out of ai.unsent (ai-review.ts:1003), so it lands in no ledger at all — while run.ts:399 promises the result lists any file the lane did not review.
Both symptoms are fixed by counting the head path as outside the project in this branch:
if (!inside) {
movedOutPaths.push(f.path)
outOfScopePaths.push(f.path)
}scoped.outOfScope, the aiOutsideFiles subtraction, the ledger and telemetry then agree, and the movedOut disjunct in run.ts:386 is still needed (only to bypass the offered set under --all-projects). Worth a test with one reviewed rename-out plus one unreviewed outside file.
There was a problem hiding this comment.
✅ Fixed in 76c8f14915 as you suggested: the head path goes into outOfScopePaths as well as movedOutPaths. The movedOut term in run.ts stays, so the file is offered under --all-projects. runReview also lowers outOfScopeFiles only by reviewed paths that the scope listed as outside. Tests: reviewed by the lane next to an unreviewed outside file: the outside count stays 1, the lane does not take it (pythonFiles off): ….
| 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. `ai: false` turns the whole lane off. |
There was a problem hiding this comment.
SUGGESTION: The warning is no longer unconditional. run.ts:376 now calls resolveAiSwitches(config, process.env, { warn: aiOn }), and ai-switches.ts:74 suppresses the warning when the lane is off (--no-ai, ai: false); it is also written only once per value per process. Mention both so this paragraph matches the new gate.
| any other value is ignored with a warning. `ai: false` turns the whole lane off. | |
| any other value is ignored (a warning is printed only when the AI lane runs, once per value). `ai: false` turns the whole lane off. |
There was a problem hiding this comment.
✅ Fixed in a4284af985: "any other value is ignored (with a warning, printed once per value and only when the AI lane runs)".
| }) | ||
|
|
||
| describe("a Python file renamed out of the dbt project", () => { | ||
| const git = (cwd: string, ...args: string[]) => |
There was a problem hiding this comment.
SUGGESTION: This is a fourth byte-identical copy of the git/write helpers (the others are at lines 224-232, 395-403 and 482-490). Hoisting one module-scope pair above the first describe removes ~27 duplicated lines; the repeated three-key env-clearing loop (254, 318, 422, 519) could likewise move into one beforeEach.
There was a problem hiding this comment.
✅ Fixed in 76c8f14915. One module-scope pair replaces the four copies. I left the env-clearing loops alone: they clear different keys per test.
hkaltai
left a comment
There was a problem hiding this comment.
Re-review at e9589ed (Claude + Codex, independent; findings checked against the code).
Both minor findings are fixed, and the cited tests exercise the fixes. Still requesting changes only for the default-on scope question: #1792 still says the AI features are opt-in, and there is no sign-off from the issue owner yet (see that thread). There is one new minor regression from the rename fix, inline. Nits are in a separate comment.
| ? { | ||
| ...input.scope, | ||
| ...(aiReviewedOutside.length && input.scope?.outOfScopeFiles !== undefined | ||
| ? { outOfScopeFiles: Math.max(0, input.scope.outOfScopeFiles - aiReviewedOutside.length) || undefined } |
There was a problem hiding this comment.
MINOR · logic error (regression from the rename fix)
? {
...input.scope,
...(aiReviewedOutside.length && input.scope?.outOfScopeFiles !== undefined
? { outOfScopeFiles: Math.max(0, input.scope.outOfScopeFiles - aiReviewedOutside.length) || undefined }Moved-out Python files now go into aiOutsideFiles and so into aiReviewedOutside, but outOfScopeFiles (from scoped.outOfScope) never counted them, because the old path is in scope as a deletion. Example: rename dbt/scripts/load.py → airflow/load.py and edit README.md. Then outOfScopeFiles = 1 - 1 → undefined. The "N changed file(s) outside the dbt project were not reviewed" note disappears and out_of_scope_files telemetry reports 0, while README.md was not reviewed. run.ts:389 already corrects this for the stderr notice, but not here.
Fix: subtract only reviewed paths that are in outOfScopePaths (or record moved-out files separately). Test: a reviewed rename plus one non-Python outside file should keep outOfScopeFiles === 1.
Raised by: Claude, Codex
There was a problem hiding this comment.
✅ Fixed in 76c8f14915, both ways you suggested. scopeToProject now adds the head path of a rename out of the project to outOfScopePaths, so the count, the ledger and telemetry include it. runReview lowers outOfScopeFiles only by reviewed files that the scope listed as outside the project. Your example (dbt/scripts/load.py → airflow/load.py plus an edited README.md, with the lane answering) now gives outOfScopeFiles === 1, the note is shown, and out_of_scope_files is 1. Tests: reviewed by the lane next to an unreviewed outside file: the outside count stays 1 (end to end with a replayed lane) and a reviewed file the outside count did not include does not lower it (runReview).
There was a problem hiding this comment.
✅ Fixed (round 3, f2171af). Moved-out head paths are now in outOfScopePaths (diff-filter.ts:354-357), and only reviewed paths listed as outside are subtracted (orchestrate.ts:2846-2851, :2888-2889). Tests: "reviewed by the lane next to an unreviewed outside file: the outside count stays 1" and "a reviewed file the outside count did not include does not lower it".
|
Nits, re-review at
|
…it, so coverage counts agree - `scopeToProject` adds the head path of a rename out of the project to `outOfScopePaths` as well as `movedOutPaths`. The ledger lists it as outside the project until the AI lane reviews it, so a moved-out `.py` the lane skips, fails on, or leaves out by quota is no longer missing from every ledger. - `runReview` lowers `outOfScopeFiles` only by reviewed files that the scope listed as outside the project. A reviewed rename next to an unreviewed `README.md` keeps the count at 1, so the note and `out_of_scope_files` telemetry match the stderr notice. - `--all-projects`: a path assigned to a project but listed by it as outside (a rename out of it) counts as reviewed only when a lane reviewed it. - `outsideTaken` doc: files carried only by failed calls. - Tests: single-project dry run, replayed lane and `pythonFiles` off for a moved-out `.py`; `--all-projects` dry run and replayed lane; a reviewed file the count did not include; `movedOutPaths` pinned in the cross-project rename test. The `git`/`write` helpers in review-ai-python-files.test.ts are hoisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…through the work tree `trustedFilePath` checked the realpath and the realpath of each directory on the named path. An outside alias that resolves through a link inside the work tree and back out kept all of those outside, so a PR could still choose which outside file was loaded. `resolutionChain` now follows the path one component at a time, through every link target, and each visited path is checked. A chain that cannot be followed (a loop, a missing component) is refused. Tests: `an outside alias that resolves through a link in the work tree and back out is refused` (absolute and relative links), `a symlink loop is refused`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd; docs match - review-ai-switches.test.ts: the unit test is renamed to what it checks (`warn: false`), and a `reviewPullRequest` test shows `--no-ai` writes no warning while the same value with the lane on does. - Docs: the ignored-value warning is printed once per value and only when the AI lane runs; the trusted-file paragraph covers a symlink chain through the work tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…riant path cannot slip past the work tree On a case-insensitive file system `resolutionChain` recorded paths in the typed case while work-tree roots are realpaths, so `/…/REPO/link/f` or an outside alias whose target spells the work tree in another case was accepted. The walk now resolves each directory to its realpath before taking the next component, and `trustedFilePath` refuses a file when the walk does not end at its realpath. Test: `a work tree spelled in another case (case-insensitive file systems) is still found` (in-tree link named through the other spelling, and an outside alias whose target uses it; skipped on case-sensitive file systems). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re @hkaltai's nits comment: Thanks. Both are done in
One visible change: a file renamed out of the project now counts in |
There was a problem hiding this comment.
1 issue found across 9 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="docs/docs/usage/dbt-pr-review.md">
<violation number="1" location="docs/docs/usage/dbt-pr-review.md:645">
P3: `resolveAiSwitches` warns whenever `aiOn` is true, before model resolution, so missing-model runs still warn. Say “when the AI lane is enabled” instead.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| `_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 runs). `ai: false` turns the whole lane off. |
There was a problem hiding this comment.
P3: resolveAiSwitches warns whenever aiOn is true, before model resolution, so missing-model runs still warn. Say “when the AI lane is enabled” instead.
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 645:
<comment>`resolveAiSwitches` warns whenever `aiOn` is true, before model resolution, so missing-model runs still warn. Say “when the AI lane is enabled” instead.</comment>
<file context>
@@ -641,15 +641,17 @@ across 12 dialects all plan; anything still unrecognized stays *undecidable*, ne
`on`/`off` and `yes`/`no` are accepted too; an empty value counts as unset, and
- any other value is ignored with a warning. `ai: false` turns the whole lane off.
+ any other value is ignored (with a warning, printed once per value and only when
+ the AI lane runs). `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
</file context>
| the AI lane runs). `ai: false` turns the whole lane off. | |
| the AI lane is enabled). `ai: false` turns the whole lane off. |
There was a problem hiding this comment.
✅ Valid, fixed in c8181d7553: "only when the AI lane is enabled". run.ts passes warn: aiOn to resolveAiSwitches. aiOn is set from --no-ai and ai: in the policy before a model is resolved, so a run without a model still warns.
| // `outOfScopeFiles` drops only the reviewed files it counted (listed as outside the project). | ||
| const reviewedCountedOutside = new Set( | ||
| (input.scope?.notReviewed ?? []) | ||
| .filter((n) => aiReviewedSet.has(n.path) && /^outside the dbt project/.test(n.reason)) |
There was a problem hiding this comment.
SUGGESTION: The "outside the dbt project" reason prefix is now matched in four places: OUTSIDE_PROJECT_RE (multi-project.ts:32), multi-project.ts:241/249, and here as an inline regex. The subtraction therefore silently depends on the exact wording run.ts:554 builds (outside the dbt project (${root})). Replaying the wording — or passing an already-merged scope whose reason is OUTSIDE_ALL — makes reviewedCountedOutside 0 while the ledger entries are still dropped, and scope.outOfScopeFiles/out_of_scope_files regress to the overcount this PR just fixed, with no test failing (the unit test builds the reason string by hand). Export one predicate next to OUTSIDE_PROJECT_RE and reuse it here.
There was a problem hiding this comment.
✅ Fixed in 86f22a2485. Every match now calls one predicate, isOutsideProjectReason in verdict.ts: orchestrate.ts (the reviewedCountedOutside count), format.ts (the out-of-scope note) and the three matches in multi-project.ts (OUTSIDE_PROJECT_RE is gone). All five call sites used the same /^outside the dbt project/ before, so behaviour is unchanged. The merged outside the dbt projects reviewed reason matches too, as it did. I put the predicate in verdict.ts, next to FAILED_FILE_REASON, rather than in run.ts or multi-project.ts. run.ts imports orchestrate.ts, and multi-project.ts imports run.ts, so orchestrate.ts importing either would create an import cycle. Test: isOutsideProjectReason › "accepts exactly what the /^outside the dbt project/ matches it replaced accepted" (review-all-projects.test.ts). It covers the run.ts reasons for a root and a nested project, the merged reason, and reasons that must not match (other ledger reasons, different case, a leading space). For each one it compares the predicate with the old regex.
hkaltai
left a comment
There was a problem hiding this comment.
Re-review (round 3) at f2171af (Claude + Codex, independent; findings checked against the code).
Approving. The default-on scope finding is resolved: the issue owner updated #1792, which now describes the measured configuration as on by default with per-part opt-outs, and AI_SWITCH_DEFAULTS matches it. The outOfScopeFiles regression is fixed on both sides (diff-filter.ts:354-357, orchestrate.ts:2846-2851), and the tests cover your rename + README.md example. The moved-out failure ledger is closed as well. Neither reviewer found a new defect. One nit is in a separate comment.
|
Nit, round 3 at
|
…ide-project reason The "outside the dbt project" reason prefix was matched by the same regex in `orchestrate.ts`, `format.ts` and three times in `multi-project.ts`. All now call `isOutsideProjectReason` in `verdict.ts` (beside `FAILED_FILE_REASON`, which every caller already imports, so no import cycle through `run.ts`). It accepts exactly what the regex accepted. Test: `isOutsideProjectReason accepts exactly what the regex matches it replaced accepted` (run.ts reasons, the merge's `outside the dbt projects reviewed`, and reasons that must not match). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… case-sensitive file system The test returned early, and so passed, where the upper-case spelling of the work tree does not exist. It is now `test.skipIf` on a probe of the temp directory's file system (a probe directory looked up under its upper-case name), and asserts that the other spelling resolves when it runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s enabled `resolveAiSwitches` gets `warn: aiOn`, which is set before a model is resolved, so a run without a model still warns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re @hkaltai's nits comment: Thanks, done in |
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
The comment described the opposite condition: the value is `true` when the temp directory's file system is case-sensitive, which is what `skipIf` needs. Co-Authored-By: Claude <noreply@anthropic.com>
Issue for this PR
Part of #1792
Type of change
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) andfeat/review-rule-noise(fewer noisy rule comments).What changed
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.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.pythonFiles), inside or outside the project root, with their own quota of 6. Fixes for files outside the project: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.--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.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 feat(review): fewer wrong rule comments when the AI lane runs: rule types off, rule verifier, rule-post policy #1838). The default prompt stays the one in altimate-core.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.ai: { <switch>: false }or its env variable set to0.How existing users are affected
--no-ai,ai: false, no model): no change. A test checks the envelope is identical.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).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.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.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.Caveats:
.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.--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:
ai: { <switch>: false }or its env variable set to0. With the AI lane off, nothing changes.Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code