Skip to content

feat(review): wider AI lane input, ai: switches in config, and the measured lane configuration on by default - #1836

Open
RaghwendraSingh wants to merge 34 commits into
feat/review-all-projectsfrom
feat/review-finder-defects
Open

RaghwendraSingh wants to merge 34 commits into
feat/review-all-projectsfrom
feat/review-finder-defects

Conversation

@RaghwendraSingh

@RaghwendraSingh RaghwendraSingh commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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. ai in .altimate/review.yml accepts true/false or an object (enabled plus coverage, contextCard, focused, otherFiles, pythonFiles, verify). resolveAiSwitches picks each switch from its env variable first (1/true/on/yes on, 0/false/off/no off; 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.ts resolves 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 under ai: fails the config load, so a typo such as enable: false cannot leave the lane running.
  • Other project files reach the AI lane (otherFiles). Changed other/analysis files inside the project root (.sql, .yml, .yaml) get their own quota of 8. Python files are not among them: they go through pythonFiles only, so pythonFiles: false stops 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-projects each 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, has pythonFiles: 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.
  • Coverage notes. ai.unsent lists only files the deterministic lanes also checked (including other YAML 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.
  • 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 to 0.

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_files no longer counts outside-project Python files the AI lane reviewed; they are counted in the new ai_reviewed_outside_files. Dashboards that trend out_of_scope_files will 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, outOfScopeFiles and out_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 1 keep working. 0, false, off and no mean off. Before this PR any value other than 1 meant off; now a value that is none of these spellings is ignored with a warning and the config or default applies.
  • Issue dbt PR review: precision, coverage and AI verifier stack #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 .py files 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 .py files 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-ai envelope 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; unknown ai: 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 to 0. 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

RaghwendraSingh and others added 7 commits November 25, 2026 01:52
…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>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bdd955c8-9d2f-45ee-8444-32c3b20ea585

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/docs/usage/dbt-pr-review.md Resolved
*/
export const AI_SWITCH_DEFAULTS: AiSwitches = {
coverage: true,
contextCard: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Comment thread docs/docs/usage/dbt-pr-review.md Resolved
@kilo-code-bot

kilo-code-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The incremental range c8181d7..d25b745 is a single comment line in a test file. The old text described the opposite condition; the new text matches the value, which is true when the temp directory's file system is case-sensitive (the probe is not found under its upper-case name), and that is what test.skipIf(caseSensitiveTmp) at line 129 needs. No other changes in the range.

Files Reviewed (1 file)
  • packages/opencode/test/altimate/review-ai-system-prompt.test.ts - 0 issues
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 outside the dbt project reason prefix) is resolved: every call site now uses isOutsideProjectReason in verdict.ts, with a test that pins the predicate to the regex it replaced. The incremental diff also corrects the docs to say the warning is printed when the AI lane is enabled, and replaces the vacuous early return in the case-variant test with test.skipIf.

Files Reviewed (7 files, incremental diff f2171af..c8181d7)
  • docs/docs/usage/dbt-pr-review.md - 0 issues
  • packages/opencode/src/altimate/review/format.ts - 0 issues
  • packages/opencode/src/altimate/review/multi-project.ts - 0 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 0 issues
  • packages/opencode/src/altimate/review/verdict.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-system-prompt.test.ts - 0 issues
  • packages/opencode/test/altimate/review-all-projects.test.ts - 0 issues

Previous review (commit f2171af)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 2849 The outside the dbt project reason prefix is matched by an inline regex here, duplicating OUTSIDE_PROJECT_RE in multi-project.ts; a wording change in run.ts:554 would silently zero the outOfScopeFiles correction.
Files Reviewed (9 files, incremental diff e9589ed..f2171af)
  • docs/docs/usage/dbt-pr-review.md - 0 issues
  • packages/opencode/src/altimate/review/diff-filter.ts - 0 issues
  • packages/opencode/src/altimate/review/multi-project.ts - 0 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 1 issue
  • packages/opencode/src/altimate/review/trusted-file.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-python-files.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-switches.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-system-prompt.test.ts - 0 issues
  • packages/opencode/test/altimate/review-scope-diff.test.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit e9589ed)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/diff-filter.ts 352 A reviewed rename-out is subtracted from scope.outOfScopeFiles (envelope, PR comment and out_of_scope_files telemetry undercount) although its head path was never counted; the same omission leaves a moved-out Python file the lane did not review in no coverage ledger. Count the head path as outside in this branch.

SUGGESTION

File Line Issue
docs/docs/usage/dbt-pr-review.md 644 Docs promise a warning for any invalid switch value, but run.ts:376 now suppresses it when the AI lane is off, and it is written once per value per process.
packages/opencode/test/altimate/review-ai-python-files.test.ts 290 The new describe adds a fourth byte-identical copy of the git/write helpers (also at 224-232, 395-403, 482-490); hoist one module-scope pair.
Files Reviewed (10 files, incremental diff 4ceacf0..e9589ed)
  • docs/docs/usage/dbt-pr-review.md - 1 issue
  • packages/opencode/src/altimate/review/ai-review.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-switches.ts - 0 issues
  • packages/opencode/src/altimate/review/diff-filter.ts - 1 issue
  • packages/opencode/src/altimate/review/multi-project.ts - 0 issues
  • packages/opencode/src/altimate/review/run.ts - 0 issues
  • packages/opencode/src/altimate/review/trusted-file.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-python-files.test.ts - 1 issue
  • packages/opencode/test/altimate/review-ai-switches.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-system-prompt.test.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 4ceacf0)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/trusted-file.ts 40 Only the resolved target is checked, so a path inside the checkout that the PR turns into a symlink to an outside file is accepted; the PR can still supply the system prompt.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/ai-switches.ts 69 !!WARNED.add(warning) is always true (Set.add returns the Set); the last conjunct is dead and obscures the once-per-value logic.
packages/opencode/test/altimate/review-ai-python-files.test.ts 478 The test clears ambient review env but not ALTIMATE_REVIEW_AI_DRYRUN; dry run wins over replay and makes both assertions fail when it is exported.
Files Reviewed (17 files)
  • docs/docs/usage/dbt-pr-review.md - 0 issues
  • packages/opencode/src/altimate/review/ai-replay.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-review.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-switches.ts - 1 issue
  • packages/opencode/src/altimate/review/multi-project.ts - 0 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 0 issues
  • packages/opencode/src/altimate/review/run.ts - 0 issues
  • packages/opencode/src/altimate/review/telemetry.ts - 0 issues
  • packages/opencode/src/altimate/review/trusted-file.ts - 1 issue
  • packages/opencode/src/altimate/review/verdict.ts - 0 issues
  • packages/opencode/src/altimate/telemetry/index.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-other-files.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-python-files.test.ts - 1 issue
  • packages/opencode/test/altimate/review-ai-replay.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-switches.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-system-prompt.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-verify.test.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit d767de1)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 2681 The otherFiles comment still lists .py, but AI_OTHER_EXTENSIONS no longer accepts it, so the comment contradicts the code. The config schema, docs and ai-other-files.ts header were updated for that change; this comment was missed.
packages/opencode/src/altimate/review/ai-review.ts 989 AI_ONLY_KINDS over-filters kind other: orchestrate.ts:2339 marks every .yml file of kind other as checked by the dbt_patterns lane, so when the other quota keeps one from the model it appears in neither ai.unsent (filtered here) nor scope.notReviewed (ledger skips otherChecked/touched). The PR description says those files stay in the "Not reviewed" ledger.
packages/opencode/src/altimate/review/ai-review.ts 1058 failedFiles is not carried through replay: replayFindings copies only state/reason/model/tokens/cost/calls, so a replayed partially-failed envelope comes back as state: "ok" without failedFiles and orchestrate.ts:2803 treats every recomputed sent path as reviewed.
Files Reviewed (15 files)
  • docs/docs/usage/dbt-pr-review.md - 0 issues
  • packages/opencode/src/altimate/review/ai-context-card.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-other-files.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-review.ts - 2 issues
  • packages/opencode/src/altimate/review/ai-verify.ts - 0 issues
  • packages/opencode/src/altimate/review/config.ts - 0 issues
  • packages/opencode/src/altimate/review/multi-project.ts - 0 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 1 issue
  • packages/opencode/src/altimate/review/run.ts - 0 issues
  • packages/opencode/src/altimate/review/verdict.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-defaults.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-other-files.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-python-files.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-switches.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-verify.test.ts - 0 issues

The 8 findings from the previous review at e7f27d7 were re-checked against d767de1 and are resolved (outside-project added lines now reach the verifier, the stderr wording defers coverage to the ledger, ai.unsent no longer claims deterministic checks for AI-only kinds, the stderr override is restored in finally, the extra-kinds ledger/note split matches, the reason covers both ai: off forms, the unused aiVerifyEnabled is gone, and the other-files test now has more models than the quotas plus spare).

Fix these issues in Kilo Cloud

Previous review (commit e7f27d7)

Status: 8 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 4
SUGGESTION 4
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/orchestrate.ts 2708 Findings on outside-project .py files are verified against an empty addedLines set: AiVerifyEvidence.addedLines is built from input.changedFiles only (line 2766) and outside files are passed solely as aiOutsideFiles, so extractFeatures sets targetsUnchangedCode = true for their added lines and triage drops them with rule unchanged_code unless the model verdict is confirmed (ai-verify.ts:493-499). With verify now on by default this silently discards a large share of the AI-only findings the PR adds. Fix: build the map from [...input.changedFiles, ...(input.aiOutsideFiles ?? [])].
packages/opencode/src/altimate/review/run.ts 382 The stderr coverage counts subtract every outside .py file before the filters that decide whether the lane sends it (Python quota 6, exclude globs, mayHoldCredentials/holdsCredentials, and the tier, which has no ai_review lane at trivial). The run can therefore print 0 changed file(s) outside the dbt project were not reviewed while those files were reviewed by no lane; the envelope is corrected later through aiReviewedOutside, so only the report is wrong. Apply the same predicates here or word the line as an upper bound.
packages/opencode/src/altimate/review/ai-review.ts 953 Passing budget.coverage as extra lets other/analysis and python_file entries into plan.unsent when their quota is exceeded, and runAiReview records them in ai.unsent. format.ts:301-309 renders that list as "the deterministic checks still ran on them", which is false for these kinds (nothing but the AI lane reads them), while the same paths also appear in scope.notReviewed — one comment then claims a file was both checked and not reviewed. Exclude the extra-quota kinds from ai.unsent or give them their own note/ledger wording.
packages/opencode/test/altimate/review-ai-python-files.test.ts 251 process.stderr.write is restored only on the success path. Every assertion from lines 235-250 runs with the wrapper installed, so a failing assertion (or a throwing reviewPullRequest) leaks it into the rest of the bun test process. Move the restore into the existing finally.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/ai-switches.ts 51 Env precedence over the ai: config means a PR can override the base-branch policy through its own (PR-editable) workflow env, contradicting the config.ts comment that these switches are read from base "so a PR cannot change them for itself". Either let the base config win when enabling a switch or state that these are workflow-controlled.
packages/opencode/src/altimate/review/ai-review.ts 13 aiVerifyEnabled is now unused production code: after removing it from this import and ai-replay.ts, only its own unit test calls it. Delete it, or make it the single env reader that switchOn delegates to.
packages/opencode/src/altimate/review/run.ts 373 The disabled reason names only ai: false, but aiLaneEnabled also returns false for the new ai: { enabled: false } form, so the stderr line, ai.reason and PR comment misquote the user's file.
packages/opencode/test/altimate/review-ai-other-files.test.ts 217 The "does not lend spare to the existing buckets" test cannot detect that regression: the empty macro/test/yml buckets already lift the model bucket from 12 to all 14 models, so off.sent is 14 and on.sent.length === off.sent.length + 8 holds even if spare wrongly included otherQuota. Use more models than the four quotas plus spare (e.g. 40 against a 30-file capacity).
Files Reviewed (18 files)
  • docs/docs/usage/dbt-pr-review.md - 0 issues (quotas 12/8/4/6/8/6, env names and default-on wording match the code)
  • packages/opencode/src/altimate/review/ai-other-files.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-python-files.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-replay.ts - 0 issues
  • packages/opencode/src/altimate/review/ai-review.ts - 2 issues
  • packages/opencode/src/altimate/review/ai-switches.ts - 1 issue
  • packages/opencode/src/altimate/review/ai-verify.ts - 0 issues (budget/timeout demotion, triage, retriage and status counts checked)
  • packages/opencode/src/altimate/review/config.ts - 0 issues
  • packages/opencode/src/altimate/review/multi-project.ts - 0 issues
  • packages/opencode/src/altimate/review/orchestrate.ts - 1 issue
  • packages/opencode/src/altimate/review/run.ts - 2 issues
  • packages/opencode/src/altimate/review/verdict.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-defaults.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-other-files.test.ts - 1 issue
  • packages/opencode/test/altimate/review-ai-python-files.test.ts - 1 issue
  • packages/opencode/test/altimate/review-ai-switches.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-system-prompt.test.ts - 0 issues
  • packages/opencode/test/altimate/review-ai-verify.test.ts - 0 issues

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.

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 50.8K · Output: 3.6K · Cached: 404K

Review guidance: REVIEW.md from base branch feat/review-all-projects

RaghwendraSingh and others added 3 commits November 25, 2026 15:57
…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>
@RaghwendraSingh RaghwendraSingh changed the title feat(review): defect-focused AI finder input: other changed files, Python files, measured defaults feat(review): wider AI lane input, ai: switches in config, and the measured lane configuration on by default Nov 25, 2026
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Re the kilo summary comment (#1836 (comment)):

  • WARNING orchestrate.ts:2708 (outside files verified against empty addedLines): ✅ Fixed in 3148c95ac4: the verifier's addedLines and the suggestion validation are built from the in-scope files plus aiOutsideFiles. Test the verifier sees the added lines of outside-project files fails if reverted.
  • WARNING run.ts:382 (stderr count before the lane's filters): ✅ Fixed in 3148c95ac4: the second line is now worded as an upper bound ("offered to the AI review only, when that lane runs; the result lists any it did not review"). The envelope ledger stays exact. The new text is asserted in AI dry run: ai.input lists the outside .py file….
  • WARNING ai-review.ts:953 (ai.unsent claims deterministic checks for AI-only kinds): ✅ Fixed in 3148c95ac4: other/analysis and python_file entries over their quota are no longer recorded in ai.unsent. They stay in the "Not reviewed" ledger, so no comment claims a file was both checked and not reviewed. Test Python files over their quota are not in ai.unsent (the coverage ledger has them) fails if reverted.
  • WARNING review-ai-python-files.test.ts:251 (stderr restore): ✅ Fixed in 3148c95ac4 (same as cubic 4691094923).
  • SUGGESTION ai-switches.ts:51 (env precedence over base-branch config): Not changed (behaviour). The env variables belong to whoever controls the CI workflow, and a PR that can edit the workflow can already change or skip the review step. Letting the base config win over env would remove the operator's per-job override and would not close that gap. The config.ts comment now says the base-branch read protects the policy file, and that env overrides are the operator's CI setting, not repository policy (d767de1196).
  • SUGGESTION ai-review.ts:13 (aiVerifyEnabled unused): ✅ Fixed in d9114be28e: removed. Its test now checks switchOn("verify", undefined, env), which keeps the same env-only semantics.
  • SUGGESTION run.ts:373 (disabled reason): ✅ Fixed in 3148c95ac4 (same as cubic 4691094961).
  • SUGGESTION review-ai-other-files.test.ts:217 (spare test cannot detect the regression): ✅ Fixed in 3148c95ac4: the test uses 40 models against a capacity of 30, so a spare that counted otherQuota would send more models. Test default quota is 8 and does not lend spare to the existing buckets fails if that regression is introduced.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// `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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 hkaltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 becomes error, so runAiVerify does not mark the batch stopped and 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: otherQuota and pythonQuota exist only inside the coverage block. With ai: { coverage: false }, other/Python files go through selectAiFiles under the 20-file cap, ranked last. Mention "(with coverage)" in the docs and comments.

Raised by: lead

  • packages/opencode/src/altimate/review/orchestrate.ts:2681 — Stale .py in otherFiles comment: isAiOtherFile accepts only .sql/.yml/.yaml; Python goes through pythonFiles. Drop /.py from the comment.

Raised by: lead, Claude

  • packages/opencode/src/altimate/review/ai-review.ts:214 — Unreachable .py branch in fenceOf: Only other/analysis kinds reach this line and isAiOtherFile never admits .py; Python files get their fence from FENCE. 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 records ai.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 at ai-review.ts:33,44,60,66,741,946, orchestrate.ts:293 and verdict.ts:272,288,292 still describe coverage, focused batches and the verifier as opt-in =1 features. 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: outOfScopeFiles now excludes outside files the AI lane reviewed, so this telemetry value means something different after this change. Note it, or add a separate ai_reviewed_outside count.

Raised by: Claude

prRenames,
aiOutsidePython: outsidePythonPending,
})
if (env.ai?.state === "ok" || (env.ai?.input ?? []).some((r) => unassignedPaths.has(r.path))) outsidePythonPending = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = false

Under --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 = false

More 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Comment on lines +29 to +36
export const AI_SWITCH_DEFAULTS: AiSwitches = {
coverage: true,
contextCard: true,
focused: true,
otherFiles: true,
pythonFiles: true,
verify: true,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR: 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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Comment on lines +926 to +932
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
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR: 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Comment on lines +41 to +44
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
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR: 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

RaghwendraSingh and others added 9 commits November 27, 2026 11:16
…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>
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Re @hkaltai's latest review on this PR, the points in the review text:

  • hkaltai 6058499173, outside-diff MINOR orchestrate.ts:2629 (outside-Python findings skip pre-existing classification): ✅ Fixed in 3db21a5128. cleanFindings now runs anchorByEvidence and markPreExisting over the in-scope files plus aiOutsideFiles. Test: a finding on a context line of an outside .py file is marked pre-existing.
  • Nit, ai-verify.ts:1095 (budget-forced unparsable answer is an error): not changed. An unparsable answer is a failed call whatever forced it. Under the open fail mode the findings stay inline, and the existing test documents that choice.
  • Nit, ai-review.ts:114 (quotas only with coverage): ✅ The docs say so in 2c627299c5: "with coverage off, one 20-file cap applies instead".
  • Nits, stale .py comment, fenceOf branch, default-envelope comment, opt-in =1 comments in ai-review.ts, orchestrate.ts and verdict.ts: ✅ All updated in 2c627299c5. Comments only.
  • Nit, telemetry out_of_scope_files changes meaning: ✅ Added ai_reviewed_outside_files in 2c627299c5, and the field doc for out_of_scope_files now says it leaves those files out.
  • Missing tests: added for the multi-project handoff with pythonFiles: false, the outside-Python context-line finding, non-1/0 env values, and relative or symlinked prompt files. Still missing: coverage: false with other/Python files on.

@hkaltai

hkaltai commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Nits (peer review, Claude + Codex)

  • run.ts:376: resolveAiSwitches(config) runs even when the lane is off (--no-ai / ai: false), so a bad value such as ALTIMATE_REVIEW_AI_VERIFY=maybe prints an "ignoring …" warning for a lane that won't run. Resolve the switches, or warn, only when aiOn.
  • telemetry.ts out_of_scope_files: its meaning changes (outside Python files the AI lane reviewed are no longer counted). Dashboards that trend it will show a step change. Mention this in the release notes.

Missing tests: a partly failed lane whose failed batch alone carried an outside Python file (outsideTaken); a Python file renamed across the project boundary.

RaghwendraSingh and others added 7 commits November 27, 2026 15:42
…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>
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Re @hkaltai's review text and nits comment:

  • Review body nit, run.ts:376 (warning when the lane is off): ✅ Fixed in c40cf424ab. resolveAiSwitches(..., { warn: false }) is used when --no-ai or ai: false applies; the resolved values are unchanged. Test: no warning when the AI lane is off (`--no-ai`, `ai: false`).
  • Review body nit, telemetry out_of_scope_files: the field doc and ai_reviewed_outside_files were added in round 2. The PR description now flags the step change for the release notes.
  • Missing tests: partly failed lane and cross-boundary rename, both added above.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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): ….

Comment thread docs/docs/usage/dbt-pr-review.md Outdated
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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[]) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 hkaltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +2880 to +2883
? {
...input.scope,
...(aiReviewedOutside.length && input.scope?.outOfScopeFiles !== undefined
? { outOfScopeFiles: Math.max(0, input.scope.outOfScopeFiles - aiReviewedOutside.length) || undefined }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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".

@hkaltai

hkaltai commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Nits, re-review at e9589ed (Claude + Codex)

  • Accepted limit, noted for follow-up: a Python file moved out of the project whose AI call fails (or that falls outside the Python quota) shows in neither part of the "Not reviewed" ledger, because only the old path's deletion is in scope. Seeding moved-out head paths into the coverage accounting would close this.
  • Missing test: an --all-projects run with a Python file renamed out of one project (assignToProjects by oldPath).

RaghwendraSingh and others added 4 commits November 27, 2026 19:06
…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>
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Re @hkaltai's nits comment:

Thanks. Both are done in 76c8f14915:

  • Moved-out Python file not in the ledger. This followed from the outOfScopeFiles fix. The head path of a rename out of the project is now listed as "outside the dbt project" and removed only when the AI lane reviews it. So a moved-out .py whose call fails, that is over the Python quota, or that the lane does not take (pythonFiles: false, --no-ai) is in the "Not reviewed" ledger. Under --all-projects the merge keeps it listed unless some lane reviewed it: a path a project was assigned but listed as outside counts as reviewed only through aiReviewedOutside. Tests: the lane does not take it (pythonFiles off): listed as outside the project, not reviewed and is offered to the AI lane at its new path (AI dry run), and stays listed as not reviewed.
  • --all-projects rename test. --all-projects (AI dry run): routed to the project it left, offered once, listed as not reviewed renames a/scripts/load.py → airflow/load.py with a second project changed. It checks that the file is offered once, that project a is credited with it, and that it stays listed. --all-projects: reviewed by the lane of the project it left, not listed covers the replayed-lane case.

One visible change: a file renamed out of the project now counts in outOfScopeFiles whatever its type, because its new path is outside the project and this review did not look at it.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/docs/usage/dbt-pr-review.md Outdated
`_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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
the AI lane runs). `ai: false` turns the whole lane off.
the AI lane is enabled). `ai: false` turns the whole lane off.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RaghwendraSingh RaghwendraSingh Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 hkaltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hkaltai

hkaltai commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Nit, round 3 at f2171af

  • The "outside the dbt project" reason prefix is now matched by three separate regexes (orchestrate.ts:2849, OUTSIDE_PROJECT_RE in multi-project.ts:32, and inline in format.ts:282), while the text is built at run.ts:554. If the wording changes, the count, the merge and the note will drift apart silently. Export one isOutsideProjectReason helper next to where the reason is built.

RaghwendraSingh and others added 3 commits November 27, 2026 20:11
…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>
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Re @hkaltai's nits comment:

Thanks, done in 86f22a2485. The prefix is now checked in one place, isOutsideProjectReason (verdict.ts). orchestrate.ts, format.ts and multi-project.ts call it instead of their own regexes. The regexes were identical, so nothing changes. It lives in verdict.ts, beside FAILED_FILE_REASON, not in run.ts where the reason string is built: run.ts imports orchestrate.ts, so importing it back would create a cycle. Its doc comment names both the run.ts reason and the merged one. A test compares it with the old regex over the current reason strings.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants