Skip to content

feat(review): --all-projects reviews every dbt project a PR touches in one run - #1773

Open
RaghwendraSingh wants to merge 5 commits into
feat/review-ai-focused-batchesfrom
feat/review-all-projects
Open

RaghwendraSingh wants to merge 5 commits into
feat/review-ai-focused-batchesfrom
feat/review-all-projects

Conversation

@RaghwendraSingh

@RaghwendraSingh RaghwendraSingh commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Changes since review: 1b5264f (review comments): an explicit --manifest outside every project is attributed or warned about, the merged verdict is the worst post-mode verdict, the merged envelope and AI state are built explicitly. 5e2440e (review feedback): --mode is not re-applied on merge, the merged scope carries the shared head (mixed heads fail), each project loads its own policy with documented fallbacks, --all-projects reviews dismiss per-project blocks for covered projects, and AI metadata is unioned.

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 #1772. altimate review --all-projects reviews every dbt project a PR touches in one run and posts one combined comment. Before, a monorepo PR needed one run per project.

What changed

  • multi-project.ts:
    • Collects the changed files once and finds every dbt_project.yml on the head side, skipping dbt_packages/, target/ and node_modules/.
    • Assigns each file to the deepest project that contains it.
    • Reviews each touched project in turn, with its own policy, layout and manifest.
  • One signed envelope:
    • Findings are merged and de-duplicated.
    • Verdict and tier: the most severe across projects.
    • The not-reviewed ledgers are unioned, so other projects' files are no longer "outside the project".
    • AI usage is summed.
    • Each project's root, verdict and AI state go in scope.projects / ai.projects.
  • With 0 or 1 touched projects, the single-project result is returned unchanged.
  • The summary adds "Reviewed N dbt projects" only when there are several.

Results

  • A private monorepo PR touching 5 dbt projects took 5 separate runs before. Now it takes 1 run with one comment.
  • Single-project PRs are unchanged (the flag is off by default).

How did you verify your code works?

  • bun test test/altimate/review: 754 pass.
  • bunx tsc --noEmit: clean.
  • New: test/altimate/review-all-projects.test.ts.

Cost side effects

None by default: --all-projects is opt-in. When used, the review runs once per touched dbt project, so any enabled AI-lane calls and opt-in dbt_prepare work scale with the number of touched projects (one run per project, as before, but now in one invocation). Single-project PRs are unchanged.

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


Summary by cubic

Adds altimate review --all-projects so a mono-repo PR touching multiple dbt projects is reviewed in one run and gets one combined comment. Previously, each project needed a separate review run.

New Features

  • Discovers every dbt_project.yml the PR touches (git listing uses -z, so non-ASCII directory names work), assigns each changed file to the deepest containing project, and reviews each with its own policy, layout, and manifest — each project sees only its own changed files plus files outside every project, so a credential-like file renamed in another project is still refused to its verifier. --manifest applies only to the project containing it; when it can't be attributed to a touched project, a warning says no project uses it.
  • Merges per-project results into one signed verdict: findings de-duplicated, most severe post-mode verdict and highest tier kept, AI usage summed with the worst project's state winning, and per-project detail in scope.projects / ai.projects. Shared envelope fields (manifestHash, policy) are kept only when every project agrees.
  • Policy precedence: the project's .altimate/review file, else the nearest ancestor's up to the repository root, read from the base branch; a sibling directory never lends its policy, and the invocation directory doesn't either once a project has its own. A PR-added project policy is diffed against the inherited policy it would replace.
  • Posts under a marker naming every covered project, so earlier per-project bot reviews are reconciled (dismissed when this run's verdict allows), and fails the run if projects were reviewed at different head commits.
  • Falls back to the existing single-project review when the PR touches zero or one project, and the summary adds "Reviewed N dbt projects" only when several were reviewed.

Written for commit 45795f6. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Nov 19, 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: 4a17fd5f-5649-4a5a-89bd-b070198162e8

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.

9 issues found across 8 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/verdict.ts">

<violation number="1" location="packages/opencode/src/altimate/review/verdict.ts:222">
P3: The per-project AI status bypasses the envelope's fixed AI-state contract by accepting any string. Use the same four-value enum as `ai.state` so malformed or unsupported project statuses cannot enter signed envelopes.</violation>
</file>

<file name="packages/opencode/test/altimate/review-all-projects.test.ts">

<violation number="1" location="packages/opencode/test/altimate/review-all-projects.test.ts:44">
P3: This suite leaks every synthetic git repository it creates. Track fixture roots and remove them in `afterEach` (including failed tests) so repeated CI and watch runs do not accumulate repositories.</violation>

<violation number="2" location="packages/opencode/test/altimate/review-all-projects.test.ts:49">
P2: The new discovery tests do not cover the required ignored directories. Add projects under `dbt_packages/`, `target/`, and `node_modules/`, then assert they are absent from discovered and reviewed roots.</violation>

<violation number="3" location="packages/opencode/test/altimate/review-all-projects.test.ts:166">
P2: The AI aggregation test never verifies addition across nonzero project lanes. Give both projects distinct nonzero calls, cost, and token counts, then assert their sums.</violation>
</file>

<file name="packages/opencode/src/altimate/review/format.ts">

<violation number="1" location="packages/opencode/src/altimate/review/format.ts:76">
P2: The project list is unbounded even though this renderer promises a character budget for the posted comment. With enough touched projects, this line alone can exceed 5,000 characters and the later finding-budget loop cannot trim it; cap the displayed roots and retain the full list in `scope.projects`.</violation>

<violation number="2" location="packages/opencode/src/altimate/review/format.ts:76">
P2: Project roots are repository-controlled strings, but this line inserts them raw into Markdown. A project directory containing a backtick or newline can break the summary's formatting or inject content; render each root with `codeSpan` (or otherwise escape Markdown) before joining them.</violation>
</file>

<file name="packages/opencode/src/altimate/review/git.ts">

<violation number="1" location="packages/opencode/src/altimate/review/git.ts:173">
P2: `--cached` includes tracked files deleted from the working tree, so a fully removed dbt project is still discovered and reviewed from a nonexistent `cwd`; filter the combined list to paths that still exist before discovering projects.</violation>
</file>

<file name="packages/opencode/src/cli/cmd/review.ts">

<violation number="1" location="packages/opencode/src/cli/cmd/review.ts:111">
P2: `--all-projects` can silently skip a dbt project deleted by the PR because discovery only scans the head tree. Discover projects from both head and merge-base, or retain base roots that own deleted paths.</violation>
</file>

<file name="packages/opencode/src/altimate/review/multi-project.ts">

<violation number="1" location="packages/opencode/src/altimate/review/multi-project.ts:118">
P2: `scopeToProject` supports custom `*-paths` outside a project root, but this passes every unassigned file to every project run. Shared-path files can therefore be reviewed repeatedly or remain marked outside after one project reviewed them; assign external layout files to their owning projects before constructing runs.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

findings: [shared],
tier: "lite",
mode: "gate",
ai: { state: "skipped", reason: "x", calls: 0 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The AI aggregation test never verifies addition across nonzero project lanes. Give both projects distinct nonzero calls, cost, and token counts, then assert their sums.

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/test/altimate/review-all-projects.test.ts, line 166:

<comment>The AI aggregation test never verifies addition across nonzero project lanes. Give both projects distinct nonzero calls, cost, and token counts, then assert their sums.</comment>

<file context>
@@ -0,0 +1,225 @@
+        findings: [shared],
+        tier: "lite",
+        mode: "gate",
+        ai: { state: "skipped", reason: "x", calls: 0 },
+        scope: { projectRoot: "a", notReviewed: [{ path: "b/models/x.sql", reason: "outside the dbt project (a)" }] },
+      }),
</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.

Partly fixed in 622f430: the new AI-state test sums nonzero calls across two lanes. Distinct nonzero tokens and cost are a low-priority follow-up.

await g(root, "config", "user.email", "t@test")
await g(root, "config", "user.name", "t")
await g(root, "config", "commit.gpgsign", "false")
const projects = ["proj_a", "proj_b", ...(opts.nested ? ["proj_a/integration_tests"] : [])]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The new discovery tests do not cover the required ignored directories. Add projects under dbt_packages/, target/, and node_modules/, then assert they are absent from discovered and reviewed roots.

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/test/altimate/review-all-projects.test.ts, line 49:

<comment>The new discovery tests do not cover the required ignored directories. Add projects under `dbt_packages/`, `target/`, and `node_modules/`, then assert they are absent from discovered and reviewed roots.</comment>

<file context>
@@ -0,0 +1,225 @@
+  await g(root, "config", "user.email", "t@test")
+  await g(root, "config", "user.name", "t")
+  await g(root, "config", "commit.gpgsign", "false")
+  const projects = ["proj_a", "proj_b", ...(opts.nested ? ["proj_a/integration_tests"] : [])]
+  for (const p of projects) {
+    await write(root, `${p}/dbt_project.yml`, `name: ${p.replace("/", "_")}\nversion: '1.0'\nprofile: x\n`)
</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.

Follow-up, together with r4627041814.


const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
const projects = env.scope?.projects ?? []
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The project list is unbounded even though this renderer promises a character budget for the posted comment. With enough touched projects, this line alone can exceed 5,000 characters and the later finding-budget loop cannot trim it; cap the displayed roots and retain the full list in scope.projects.

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/format.ts, line 76:

<comment>The project list is unbounded even though this renderer promises a character budget for the posted comment. With enough touched projects, this line alone can exceed 5,000 characters and the later finding-budget loop cannot trim it; cap the displayed roots and retain the full list in `scope.projects`.</comment>

<file context>
@@ -72,6 +72,8 @@ export function renderSummary(env: VerdictEnvelope, opts: RenderOptions = {}): s
 
   const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
+  const projects = env.scope?.projects ?? []
+  if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")
 
   if (env.summary.degraded) {
</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.

Follow-up: low priority, tracked. We'll cap it at RENDER_CAP with "+N more".


const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
const projects = env.scope?.projects ?? []
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Project roots are repository-controlled strings, but this line inserts them raw into Markdown. A project directory containing a backtick or newline can break the summary's formatting or inject content; render each root with codeSpan (or otherwise escape Markdown) before joining them.

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/format.ts, line 76:

<comment>Project roots are repository-controlled strings, but this line inserts them raw into Markdown. A project directory containing a backtick or newline can break the summary's formatting or inject content; render each root with `codeSpan` (or otherwise escape Markdown) before joining them.</comment>

<file context>
@@ -72,6 +72,8 @@ export function renderSummary(env: VerdictEnvelope, opts: RenderOptions = {}): s
 
   const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
+  const projects = env.scope?.projects ?? []
+  if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")
 
   if (env.summary.degraded) {
</file context>
Suggested change
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => codeSpan(p.root || ".")).join(", ")}`, "")

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.

Follow-up: low priority, tracked (codeSpan).

/** Tracked and untracked (not ignored) files in the working tree, repo-root relative; undefined when git can't list them. */
export async function listWorkingTreeFiles(cwd: string): Promise<string[] | undefined> {
try {
const out = await git(["ls-files", "--cached", "--others", "--exclude-standard", "--full-name"], cwd)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: --cached includes tracked files deleted from the working tree, so a fully removed dbt project is still discovered and reviewed from a nonexistent cwd; filter the combined list to paths that still exist before discovering projects.

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/git.ts, line 173:

<comment>`--cached` includes tracked files deleted from the working tree, so a fully removed dbt project is still discovered and reviewed from a nonexistent `cwd`; filter the combined list to paths that still exist before discovering projects.</comment>

<file context>
@@ -167,6 +167,16 @@ export async function listFilesAt(cwd: string, ref?: string): Promise<string[] |
+/** Tracked and untracked (not ignored) files in the working tree, repo-root relative; undefined when git can't list them. */
+export async function listWorkingTreeFiles(cwd: string): Promise<string[] | undefined> {
+  try {
+    const out = await git(["ls-files", "--cached", "--others", "--exclude-standard", "--full-name"], cwd)
+    return out.split("\n").filter(Boolean)
+  } catch {
</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.

Agreed, low priority (cubic, git.ts:173, --cached lists files deleted from the working tree). Leaving this for a follow-up PR rather than widening this one.

let env
try {
env = await reviewPullRequest({
const review = args.allProjects === true ? reviewAllProjects : reviewPullRequest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: --all-projects can silently skip a dbt project deleted by the PR because discovery only scans the head tree. Discover projects from both head and merge-base, or retain base roots that own deleted paths.

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/cli/cmd/review.ts, line 111:

<comment>`--all-projects` can silently skip a dbt project deleted by the PR because discovery only scans the head tree. Discover projects from both head and merge-base, or retain base roots that own deleted paths.</comment>

<file context>
@@ -100,7 +108,8 @@ export const ReviewCommand = cmd({
       let env
       try {
-        env = await reviewPullRequest({
+        const review = args.allProjects === true ? reviewAllProjects : reviewPullRequest
+        env = await review({
           ...prContext,
</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.

Follow-up: low priority, tracked. Discovering roots at the merge-base as well would cover it.

for (const root of touched) {
const own = byProject.get(root)!
process.stderr.write(`ℹ️ reviewing dbt project ${root || "."} (${own.length} changed file(s))\n`)
const env = await reviewPullRequest({ ...optsFor(root), changedFiles: [...own, ...unassigned], prFiles })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: scopeToProject supports custom *-paths outside a project root, but this passes every unassigned file to every project run. Shared-path files can therefore be reviewed repeatedly or remain marked outside after one project reviewed them; assign external layout files to their owning projects before constructing runs.

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/multi-project.ts, line 118:

<comment>`scopeToProject` supports custom `*-paths` outside a project root, but this passes every unassigned file to every project run. Shared-path files can therefore be reviewed repeatedly or remain marked outside after one project reviewed them; assign external layout files to their owning projects before constructing runs.</comment>

<file context>
@@ -0,0 +1,226 @@
+  for (const root of touched) {
+    const own = byProject.get(root)!
+    process.stderr.write(`ℹ️  reviewing dbt project ${root || "."} (${own.length} changed file(s))\n`)
+    const env = await reviewPullRequest({ ...optsFor(root), changedFiles: [...own, ...unassigned], prFiles })
+    runs.push({ root, paths: own.map((f) => f.path), env })
+  }
</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.

Follow-up: low priority, tracked. In the normal layout they're scoped out as outside each project and de-duplicated on merge; custom *-paths outside a root is the edge case.

calls: z.number().int().nonnegative().optional(),
/** Multi-project review (`--all-projects`): each project's AI lane state. */
projects: z
.array(z.object({ root: z.string(), state: z.string(), calls: z.number().int().nonnegative().optional() }))

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: The per-project AI status bypasses the envelope's fixed AI-state contract by accepting any string. Use the same four-value enum as ai.state so malformed or unsupported project statuses cannot enter signed envelopes.

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/verdict.ts, line 222:

<comment>The per-project AI status bypasses the envelope's fixed AI-state contract by accepting any string. Use the same four-value enum as `ai.state` so malformed or unsupported project statuses cannot enter signed envelopes.</comment>

<file context>
@@ -214,6 +217,10 @@ export const VerdictEnvelope = z.object({
       calls: z.number().int().nonnegative().optional(),
+      /** Multi-project review (`--all-projects`): each project's AI lane state. */
+      projects: z
+        .array(z.object({ root: z.string(), state: z.string(), calls: z.number().int().nonnegative().optional() }))
+        .optional(),
       /** Generator findings replayed from an earlier envelope: tokens, cost and calls are that run's. */
</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.

Fair nit; we'll tighten it to the lane-state enum in a follow-up. (cubic, verdict.ts:222, ai.projects[].state is z.string())


/** Two dbt projects (proj_a, proj_b), each with a model and a macro, plus a workflow file; returns the base sha. */
async function fixture(opts: { nested?: boolean } = {}): Promise<{ root: string; base: string }> {
const root = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), "review-all-projects-")))

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: This suite leaks every synthetic git repository it creates. Track fixture roots and remove them in afterEach (including failed tests) so repeated CI and watch runs do not accumulate repositories.

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/test/altimate/review-all-projects.test.ts, line 44:

<comment>This suite leaks every synthetic git repository it creates. Track fixture roots and remove them in `afterEach` (including failed tests) so repeated CI and watch runs do not accumulate repositories.</comment>

<file context>
@@ -0,0 +1,225 @@
+
+/** Two dbt projects (proj_a, proj_b), each with a model and a macro, plus a workflow file; returns the base sha. */
+async function fixture(opts: { nested?: boolean } = {}): Promise<{ root: string; base: string }> {
+  const root = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), "review-all-projects-")))
+  await g(root, "init", "-q", "-b", "main")
+  await g(root, "config", "user.email", "t@test")
</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.

Fair nit; we'll add cleanup in a follow-up.

const optsFor = (root: string): ReviewPullRequestOptions => ({
...opts,
cwd: path.join(gitRootReal, root),
manifestPath: root === manifestOwner ? manifestAbs : undefined,

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: --manifest is silently dropped whenever it does not resolve inside a discovered project root.

repoRel() returns undefined for a manifest outside the git root (the common CI shape --manifest "$RUNNER_TEMP/manifest.json"), and owningProject() returns undefined for a repo-level manifest that sits outside every project. In both cases manifestOwner is undefined, so root === manifestOwner is false for every project (including the "" root project) and every run falls back to auto-discovery. reviewPullRequest honours an absolute --manifest (run.ts:277-279), so adding --all-projects silently degrades every project to lint-only with no diagnostic. Pass the manifest through when only one project is touched, or warn/fail instead of ignoring it.

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 622f430: a manifest outside every project (CI's $RUNNER_TEMP/manifest.json) now goes to the touched project when the PR changes only one. When it can't be attributed (several touched projects, or it lies inside an untouched project), a warning says no project uses it. Previously each project silently fell back to lint-only. A test covers both cases.

const seenIds = new Set<string>()
const findings = envs.flatMap((e) => e.findings).filter((f) => !seenIds.has(f.id) && !!seenIds.add(f.id))

const mode = modeOverride ?? (envs.some((e) => e.mode === "gate") ? "gate" : first.mode)

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: Mixed per-project modes can turn a non-blocking project's findings into a blocking verdict.

mode is gate if any project uses gate, and the merged verdict is applyMode(max(idealVerdict), mode). A project whose own policy is the default comment already softened its REQUEST_CHANGES to COMMENT, but its idealVerdict is still REQUEST_CHANGES, so a sibling project configured gate promotes it back to a blocking REQUEST_CHANGES. Merge the post-mode per-project verdicts (envs.map((e) => e.verdict)) and keep applyMode out of the merge. The mergeProjectEnvelopes test only covers the both-gate case, so this is untested.

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 622f430: the merged verdict is the worst of the projects' post-mode verdicts, so a comment-mode project's REQUEST_CHANGES no longer blocks because a sibling uses gate mode. Each project's mode is recorded in scope.projects, with a mixed-mode test.

}

const merged: VerdictEnvelope = {
...first,

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: ...first leaves first-project-only fields in the signed merged envelope.

manifestHash (rendered in the comment footer, format.ts:118), policy (including posting, which drives the inline budget and silentWhenClean), scope.projectRoot, generatedAt and tierClassified are never overridden, so a multi-project verdict claims the first project's manifest hash, policy hash and posting policy for a run that used several manifests. That is misleading audit data in a signed artifact and changes how the merged comment is posted. Build the envelope explicitly (or clear these fields) and record per-project manifest/policy detail in scope.projects.

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 issue as r4626966398; fixed in 622f430.

cacheRead: a.cacheRead + b.cacheRead,
}))
: undefined
const base = ok ?? first

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: base = ok ?? first reports the merged AI lane as ok whenever any project succeeded, dropping a sibling project's error/timeout and its reason.

With proj_a error and proj_b ok, the merged envelope says state: "ok" with no reason; ai.projects[] keeps only state/calls, so the failure is unrecoverable from the signed envelope (the top-level events and format notices no longer show the AI lane degraded). Promote the worst state (error > timeout > skipped/ok) and keep the failing lane's reason, or add a per-project reason.

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 issue as r4626966388; fixed in 622f430.

*/

const PROJECT_FILE = /(^|\/)dbt_project\.ya?ml$/
const IGNORED_DIR = /(^|\/)(dbt_packages|target|node_modules)\//

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: IGNORED_DIR re-implements a subset of the existing skip list and is incomplete.

diff-filter.ts:13-23 (SKIP_DIR_PATTERNS, used by shouldReview) also excludes dbt_modules/, compiled/, run/, logs/ and .venv/. A committed dbt_modules/<pkg>/dbt_project.yml is therefore discovered as a project: its changed files are assigned to that phantom root instead of the enclosing project, they get their own review run (extra AI lane calls), and the summary lists vendored packages as reviewed dbt projects. Export and reuse SKIP_DIR_PATTERNS/shouldReview instead of keeping a second, divergent list.

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.

Follow-up: low priority, tracked. We'll reuse SKIP_DIR_PATTERNS from diff-filter.ts so vendored dbt_modules/ projects aren't discovered.

const manifestOwner = manifestRel !== undefined ? owningProject(manifestRel, roots) : undefined
const optsFor = (root: string): ReviewPullRequestOptions => ({
...opts,
cwd: path.join(gitRootReal, root),

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: Project roots are discovered from the head tree but each project's cwd is taken from the working tree.

With --head pointing at a ref that is not checked out (a documented CLI mode), a project added or renamed by the PR has no directory at path.join(gitRootReal, root). findDbtProject then returns undefined, so run.ts:312 computes projectRootRel = undefined and scopeToProject treats every file as in scope (the unassigned files, already passed to every project, get re-reviewed by this one) while dbtProjectName/dbtProjectLayout silently degrade. Verify the directory exists (or derive the layout from the ref) and pass the project root explicitly so scoping cannot collapse to undefined.

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.

Follow-up: low priority, tracked. This only happens with a --head that isn't checked out.

calls: z.number().int().nonnegative().optional(),
/** Multi-project review (`--all-projects`): each project's AI lane state. */
projects: z
.array(z.object({ root: z.string(), state: z.string(), calls: z.number().int().nonnegative().optional() }))

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: ai.projects[].state is z.string() while the parent ai.state (line 211) is z.enum(["ok", "skipped", "timeout", "error"]).

The weaker field lets a replayed or hand-built signed envelope carry an arbitrary project state, and any future switch on it silently falls through. Reuse the same enum.

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.

Fair nit; we'll tighten it to the lane-state enum in a follow-up. (kilo, same)


const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
const projects = env.scope?.projects ?? []
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")

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 project list is unbounded, unlike the other multi-entry renders (RENDER_CAP = 8 at line 96, LEDGER_MAX_PATHS = 30 at line 283).

On a monorepo with many (or long-named) projects this single fixed line can consume most of SUMMARY_BUDGET_CHARS (5,000), after which fit drops every finding bullet into the "N more finding(s)" notice. Cap the roots shown and append (+N more var); wrapping/escaping the roots like the rest of the renderer (codeSpan, ledger escaping) would also be safer.

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 as r4626966319; tracked.

// A relative --manifest resolves against --cwd, as in the single-project path.
const rel = await reviewAllProjects({ cwd: root, base, head: "HEAD", noAi: true, manifestPath: "proj_a/artifacts/manifest.json" })
expect(rel.manifestHash).toBeDefined()
expect((await run("proj_b")).manifestHash).toBeUndefined()

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 assertion cannot observe whether proj_b received the manifest.

The merged envelope's manifestHash is always the first project's, and for this call the first project is proj_a, which has no manifest — so the value is undefined whether or not the manifest was applied to proj_b. Both manifest bodies are also identical, so even a per-project check could not distinguish them. Assert on the owning project's own envelope (reviewPullRequest with that project's cwd + manifest) or expose manifestHash in scope.projects, and use distinct manifest contents. A mixed mode: comment + mode: gate case is also untested and is where the merge logic is wrong.

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 622f430: the manifest test now checks each project's manifestHash (and that the top level carries none when they differ), and a mixed comment/gate test was added.

@kilo-code-bot

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

Copy link
Copy Markdown

Code Review Summary

Status: 11 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 64 Carried. A rename across projects is assigned only to the new-path owner, so the deletion side is never reviewed. proj_a/models/x.sql -> proj_b/models/x.sql goes only to proj_b; scopeToProject would keep the proj_a side as a deletion if the file reached that run.
packages/opencode/src/altimate/review/multi-project.ts 139 Carried. The in-project sole-touched shortcut returns reviewPullRequest(inPlace) with the raw opts.manifestPath, skipping the attribution warning at 141-146. Running from proj_a with --manifest ../proj_b/target/manifest.json analyses proj_a against the proj_b manifest with no diagnostic.
packages/opencode/src/altimate/review/multi-project.ts 131 Carried (existing inline comment). Roots come from the head tree (discoverDbtProjects(gitRoot, opts.head)) while each run's cwd is a working-tree path; with an unchecked-out --head the project directory is missing, projectRootRel is undefined and scopeToProject treats every handed file as in scope.
packages/opencode/src/altimate/review/multi-project.ts 21 Carried (author: follow-up). IGNORED_DIR still re-implements a subset of SKIP_DIR_PATTERNS: dbt_modules/, compiled/, run/ and logs/ are missing, so a committed dbt_modules/<pkg>/dbt_project.yml becomes a phantom project with its own run, AI lane and summary entry.
packages/opencode/src/altimate/review/run.ts 287 Carried (active inline comments). A PR-added policy file in an ancestor directory between the reviewed project and the applied policy (e.g. dbt/.altimate/review.yml above dbt/a/dbt_project.yml) is dropped from policy.changedInPr: only opts.cwd is re-diffed, so the This PR changes the review policy note is missing for a file that governs the project after merge.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 105 New. The 0/1-touched paths build collected with collectChangedFiles (one git diff per changed file plus a base resolution) and then call reviewPullRequest without changedFiles (lines 117/139), which resolves the base and collects the whole PR again. On a large single-project PR that doubles the git work for a list only used to pick projects. Pass collected as changedFiles on those paths, or discover roots from a paths-only listing.
packages/opencode/src/altimate/review/multi-project.ts 309 Carried. A project's partial-failure reason is dropped: base is the first ok lane, while runAiReview can return state: ok with 1 of 3 calls failed: ..., so a clean sibling hides it and the coverage note in format.ts is never rendered.
packages/opencode/src/altimate/review/multi-project.ts 114 Carried. assignToProjects matches by directory containment only, while scopeToProject keeps configured *-paths that climb out of a project root. A PR touching only such a file yields touched.length === 0 (no project layout/policy/manifest, yet coveredProjects claims every root), and when reviewed through the unassigned extras it stays absent from runs[].paths, so the merged ledger keeps an outside entry and counts it in outOfScopeFiles.
packages/opencode/src/altimate/review/multi-project.ts 288 Carried (active inline comment). When posting policies differ, posting becomes undefined and postingPolicy() silently falls back to DEFAULT_POSTING_POLICY, discarding a stricter project's inlineBudget/inlineSeverityFloor/silentWhenClean.
packages/opencode/src/altimate/review/format.ts 79 Carried (author: follow-up). The project list is unbounded and interpolated raw, unlike every other path in this file (which uses codeSpan), and it is charged to the findings budget, so many/long roots can push every finding into the N more notice.
packages/opencode/src/altimate/review/verdict.ts 260 Carried (author: follow-up). ai.projects[].state is z.string() while ai.state is z.enum([ok, skipped, timeout, error]), so a replayed or hand-built signed envelope can carry an arbitrary project state.
Files Reviewed (10 files)
  • packages/opencode/src/altimate/review/multi-project.ts - 8 issues (1 new, 7 carried)
  • packages/opencode/src/altimate/review/run.ts - 1 issue (carried; policyFallbackDirs and the prRenames merge verified correct at this head)
  • packages/opencode/src/altimate/review/format.ts - 1 issue (carried)
  • packages/opencode/src/altimate/review/verdict.ts - 1 issue (carried)
  • packages/opencode/src/altimate/review/post-github.ts - clean (marker alternation, markerProjects round-trip, covered-set matching and bot-authorship checks verified)
  • packages/opencode/src/altimate/review/config.ts - clean (headPolicyChanges extraction keeps the previous semantics)
  • packages/opencode/src/altimate/review/git.ts - clean (-z listings and untrimmed stdout)
  • packages/opencode/src/altimate/review/index.ts - clean (no export collisions)
  • packages/opencode/src/cli/cmd/review.ts - clean (--all-projects dispatch)
  • packages/opencode/test/altimate/review-all-projects.test.ts - clean (temp-dir cleanup already tracked from the cubic thread)

No commits landed after the previous pass (HEAD 45795f6788), so every carried finding was re-verified against current code rather than assumed. Inline comments could not be posted: the sandbox rejected the atomic review call and its one retry before reaching GitHub, so all findings above are summary-only.

Fix these issues in Kilo Cloud

Previous Review Summaries (5 snapshots, latest commit 0daab2a)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 0daab2a)

Status: 10 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 5
SUGGESTION 5

Incremental pass at 0daab2a37c. The branch was rebased since the previous review (24e925aa9b is no longer an ancestor), so this pass re-verified the whole PR against current HEAD. The only genuinely new commit since the last pass — prRenames carrying every PR rename into each project's run, so a credential file renamed unedited in a sibling project is refused to this project's verifier — is correct: the full map is merged into renames, filtered for out-of-scope paths, and passed to the verifier evidence, whose credential screen already keys off input.prRenames (orchestrate.ts:2620-2628, 2669-2678). The earlier --mode, head-SHA, policy-ancestor and covered-project fixes also still hold. All ten findings below were re-verified in current code.

Inline comments could not be posted: the sandbox rejected both the atomic review call and its one retry before reaching GitHub, so every finding is detailed below.

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 64 New. A rename across two projects is assigned only to the new-path owner, so the deletion side is never reviewed. proj_a/models/x.sql -> proj_b/models/x.sql goes only to proj_b; a single-project run scoped to proj_a would review it as deleted (diff-filter.ts:346-349). A model moved out while proj_a still refs/configures it goes unflagged. Assign the file to the old-path owner too; scopeToProject already rewrites that side to a deletion.
packages/opencode/src/altimate/review/multi-project.ts 139 Still present. The in-place sole-project shortcut returns reviewPullRequest(inPlace), which keeps the raw opts.manifestPath, before the attribution warning at 141-146. cd proj_a && altimate review --all-projects --manifest ../proj_b/target/manifest.json silently analyses proj_a against the proj_b manifest (wrong nodes/dialect, no diagnostic). The fall-through at 147 is correct because it goes through optsFor() -> manifestFor().
packages/opencode/src/altimate/review/multi-project.ts 131 Still present. Roots come from the head tree (discoverDbtProjects(gitRoot, opts.head)) but each run's cwd is a working-tree path. With an unchecked-out --head, findDbtProject returns undefined, projectRootRel is undefined, and scopeToProject treats every handed file as in scope, while layout/project-name resolution degrades silently.
packages/opencode/src/altimate/review/multi-project.ts 21 Still present. IGNORED_DIR re-implements a subset of SKIP_DIR_PATTERNS (diff-filter.ts:13-23): dbt_modules/, compiled/, run/ and logs/ are missing, so a committed dbt_modules/<pkg>/dbt_project.yml is discovered as a phantom project (extra run, extra AI lane, appears in the covered set and in "Reviewed N dbt projects"). Reuse SKIP_DIR_PATTERNS.
packages/opencode/src/altimate/review/run.ts 287 Still present. A PR-added policy file in an ancestor directory between the reviewed project and the applied policy (e.g. dbt/.altimate/review.yml above dbt/a/dbt_project.yml) is dropped from policy.changedInPr: the loop at 277-280 overwrites each intermediate policyAt(dir) result and only opts.cwd is re-diffed, so the "This PR changes the review policy" note is missing for a file that governs the project after merge.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 309 New. A project's partial-failure reason is dropped. runAiReview can return state: "ok" with a reason ("1 of 3 calls failed: ...", ai-review.ts:962/970), but base is the first ok lane, so a clean sibling hides it and format.ts:297-299 never renders the "partly failed" coverage note. Prefer an ok lane that has a reason (or join the reasons).
packages/opencode/src/altimate/review/multi-project.ts 114 New consequence of a known edge. assignToProjects matches by directory containment only, while scopeToProject keeps a project's configured *-paths that climb out of its root (diff-filter.ts:312-314, 335-337). A PR touching only ../../dbt_macros/x.sql yields touched.length === 0: the zero-touch path runs with no project layout/policy/manifest yet coveredProjects claims every root. And when such a file is reviewed through the unassigned extras, it is absent from runs[].paths (197), so the merged ledger keeps another project's "outside the dbt project" entry for it and counts it in outOfScopeFiles although it was reviewed.
packages/opencode/src/altimate/review/multi-project.ts 288 Still present. When posting policies differ, posting becomes undefined and postingPolicy() silently falls back to DEFAULT_POSTING_POLICY (budget 10, floor warning, silentWhenClean), discarding a stricter project's inlineBudget/inlineSeverityFloor/silentWhenClean. Merge to the most restrictive combination.
packages/opencode/src/altimate/review/format.ts 79 Still present. The project list is unbounded and interpolated raw, unlike every other path in this file (which uses codeSpan). A root containing a backtick or newline breaks the Markdown, and the line is charged to the findings budget (used is seeded from lines at 157), so many/long roots can push every finding into the "N more" notice and exceed SUMMARY_BUDGET_CHARS. Cap it (like RENDER_CAP/LEDGER_MAX_PATHS) and use codeSpan.
packages/opencode/src/altimate/review/verdict.ts 260 Still present. ai.projects[].state is z.string() while ai.state (246) is z.enum(["ok","skipped","timeout","error"]); a hand-built or replayed signed envelope can carry an arbitrary project state. Reuse the enum.
Files Reviewed (10 files)
  • packages/opencode/src/altimate/review/multi-project.ts - 7 issues (3 new, 4 carried)
  • packages/opencode/src/altimate/review/run.ts - 1 issue (carried; the new prRenames path verified correct)
  • packages/opencode/src/altimate/review/format.ts - 1 issue (carried)
  • packages/opencode/src/altimate/review/verdict.ts - 1 issue (carried)
  • packages/opencode/src/altimate/review/post-github.ts - clean (marker encode/decode, capture-group indices and covered-set matching verified; the identity/author handling on lines 231/247 predates this PR)
  • packages/opencode/src/altimate/review/config.ts - clean (headPolicyChanges extraction verified)
  • packages/opencode/src/altimate/review/git.ts - clean (-z listings, untrimmed stdout)
  • packages/opencode/src/altimate/review/index.ts - clean (no export collisions)
  • packages/opencode/src/cli/cmd/review.ts - clean (--all-projects dispatch and gate path)
  • packages/opencode/test/altimate/review-all-projects.test.ts - clean (new policy, reconciliation and credential tests; spy restored in finally)

Previous review (commit 24e925a)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 4
SUGGESTION 3

Incremental pass at 24e925aa9b. This commit resolves each project's policy along its own ancestors up to the repo root (ancestorsUpToRoot), passes the fallback on every return path (zero-touched, in-place sole project, per project), and diffs a PR-added project policy against the inherited policy via headPolicyChanges; that logic and its tests check out (the --mode, head, reconciliation and AI-merge fixes also still hold). No new defects were introduced, and all seven findings below were re-verified against current code and remain.

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 139 The in-place sole-project shortcut calls reviewPullRequest(inPlace), which carries the raw opts.manifestPath, so it bypasses the manifest-attribution guard at 141-146: a --manifest owned by an untouched sibling project is silently applied to the touched one (wrong nodes/dialect, no diagnostic). The sibling return at 147 correctly uses manifestFor().
packages/opencode/src/altimate/review/multi-project.ts 131 Project roots are discovered from the head tree but each run's cwd is a working-tree path; with an unchecked-out --head, findDbtProject returns undefined, projectRootRel is undefined, and scopeToProject treats every handed file as in scope (plus layout/name degrade silently).
packages/opencode/src/altimate/review/multi-project.ts 21 IGNORED_DIR still re-implements a subset of SKIP_DIR_PATTERNS: dbt_modules/, compiled/, run/ and logs/ are missing, so a vendored dbt_modules/<pkg>/dbt_project.yml is discovered as a phantom project with its own review run and appears in "Reviewed N dbt projects". Reuse SKIP_DIR_PATTERNS.
packages/opencode/src/altimate/review/run.ts 285 A PR-added policy file in a non-project ancestor directory (e.g. dbt/.altimate/review.yml above dbt/a/dbt_project.yml) is dropped from policy.changedInPr: the fallback walk discards each intermediate policyAt(dir) result and only opts.cwd is re-diffed, so the summary's "This PR changes the review policy" note is missing even though that file governs the project after merge.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 287 When projects' posting policies differ, posting becomes undefined and postingPolicy() falls back to DEFAULT_POSTING_POLICY (budget 10, floor warning, silentWhenClean), discarding a stricter project's inlineBudget/inlineSeverityFloor/silentWhenClean. Merge to the most restrictive combination.
packages/opencode/src/altimate/review/format.ts 79 The "Reviewed N dbt projects" list is unbounded and inserted raw. Roots count against the render budget, so many/long roots can push every finding bullet into the "N more" notice; a root containing a backtick or newline breaks the Markdown. Cap the roots and use codeSpan.
packages/opencode/src/altimate/review/verdict.ts 260 ai.projects[].state is z.string() instead of the ai.state enum, so a hand-built or replayed signed envelope can carry an arbitrary project state.
Files Reviewed (10 files)
  • packages/opencode/src/altimate/review/multi-project.ts - 4 issues
  • packages/opencode/src/altimate/review/run.ts - 1 issue
  • packages/opencode/src/altimate/review/format.ts - 1 issue
  • packages/opencode/src/altimate/review/verdict.ts - 1 issue
  • packages/opencode/src/altimate/review/config.ts - clean (headPolicyChanges extraction re-verified)
  • packages/opencode/src/altimate/review/post-github.ts - clean (covered-set marker encode/decode re-verified)
  • packages/opencode/src/altimate/review/git.ts - clean (-z listings re-verified)
  • packages/opencode/src/altimate/review/index.ts - clean
  • packages/opencode/src/cli/cmd/review.ts - clean (--all-projects dispatch re-verified)
  • packages/opencode/test/altimate/review-all-projects.test.ts - clean (new ancestor-policy tests re-verified)

Fix these issues in Kilo Cloud

Previous review (commit a3689b6)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 4
SUGGESTION 3

Incremental pass at a3689b63b41. This pass adds the ancestor-policy fallback fix for --all-projects; the earlier mode, head, policy-inheritance and review-reconciliation fixes hold (verified against the current code). One new gap is in the new fallback walk; the other six findings are earlier ones re-verified as still present.

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/run.ts 285 New: a PR-added policy file in a non-project ancestor directory (e.g. dbt/.altimate/review.yml above dbt/a/dbt_project.yml) is dropped from policy.changedInPr. The fallback walk discards each intermediate policyAt(dir) result, and only opts.cwd is re-diffed, so the summary's "This PR changes the review policy" note is missing even though that file governs the project after merge.
packages/opencode/src/altimate/review/multi-project.ts 139 The single-touched shortcut still calls reviewPullRequest(inPlace) with the raw opts.manifestPath, skipping the manifest-attribution guard at 141-146, so a --manifest owned by an untouched project is applied to the sole touched project.
packages/opencode/src/altimate/review/multi-project.ts 131 Project roots are discovered from the head tree but each run's cwd is a working-tree path; with an unchecked-out --head, findDbtProject returns undefined and scopeToProject treats every changed file as in scope (duplicate/mis-attributed findings).
packages/opencode/src/altimate/review/multi-project.ts 21 IGNORED_DIR still re-implements a subset of SKIP_DIR_PATTERNS: dbt_modules/, compiled/, run/ and logs/ are missing, so a vendored dbt_modules/<pkg>/dbt_project.yml is discovered as a phantom project with its own review run. Reuse SKIP_DIR_PATTERNS.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 287 When projects' posting policies differ, posting becomes undefined and postingPolicy() falls back to DEFAULT_POSTING_POLICY (budget 10, floor warning, silentWhenClean), discarding a stricter project's inlineBudget/inlineSeverityFloor/silentWhenClean. Merge to the most restrictive combination.
packages/opencode/src/altimate/review/format.ts 79 The "Reviewed N dbt projects" list is unbounded and inserted raw. Roots count against the render budget, so many/long roots can push every finding bullet into the "N more" notice; a root containing a backtick or newline breaks the Markdown. Cap the roots and use codeSpan.
packages/opencode/src/altimate/review/verdict.ts 260 ai.projects[].state is z.string() instead of the ai.state enum, so a hand-built or replayed signed envelope can carry an arbitrary project state.
Files Reviewed (10 files)
  • packages/opencode/src/altimate/review/multi-project.ts - 4 issues
  • packages/opencode/src/altimate/review/run.ts - 1 issue
  • packages/opencode/src/altimate/review/format.ts - 1 issue
  • packages/opencode/src/altimate/review/verdict.ts - 1 issue
  • packages/opencode/src/altimate/review/post-github.ts - clean (marker encode/parse and covered-set reconciliation re-verified)
  • packages/opencode/src/altimate/review/config.ts - clean (headPolicyChanges extraction re-verified)
  • packages/opencode/src/altimate/review/git.ts - clean (-z listings re-verified)
  • packages/opencode/src/altimate/review/index.ts - clean
  • packages/opencode/src/cli/cmd/review.ts - clean
  • packages/opencode/test/altimate/review-all-projects.test.ts - clean

Previous review (commit 676c803)

Status: 6 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 3

Incremental pass: the branch was rebased onto a newer base, and 5e2440ec..HEAD changes no line of the nine files this PR touches (verified with git diff over the PR paths). The previous findings were re-verified against current HEAD; all six are still present. No new issues were introduced by the rebase.

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 124 The single-touched-project early return passes the raw opts.manifestPath, so a --manifest owned by an untouched project (run from inside the touched project) is applied to the wrong project; the "no reviewed project uses it" guard at 126-131 is skipped.
packages/opencode/src/altimate/review/multi-project.ts 116 Roots are discovered from the head tree but each run's cwd is a working-tree path; with an unchecked-out --head, findDbtProject returns undefined and scopeToProject treats every changed file as in scope (duplicate/mis-attributed findings).
packages/opencode/src/altimate/review/multi-project.ts 20 IGNORED_DIR still duplicates a subset of SKIP_DIR_PATTERNS (diff-filter.ts:13-23). .venv/venv/site-packages were added, but dbt_modules/ (plus compiled/, run/, logs/) is still missing, so a vendored dbt_modules/<pkg>/dbt_project.yml is discovered as a phantom project, gets its own review run and is listed in "Reviewed N dbt projects". Reuse SKIP_DIR_PATTERNS.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 272 When projects' posting policies differ, posting becomes undefined and postingPolicy() falls back to DEFAULT_POSTING_POLICY (budget 10, floor warning, silentWhenClean), discarding a stricter project's inlineBudget/inlineSeverityFloor/silentWhenClean. Merge to the most restrictive combination (min budget, max severity floor).
packages/opencode/src/altimate/review/format.ts 76 The project list is unbounded and inserted raw. Roots are counted in the render budget, so many/long roots can push every finding bullet into the "N more" notice; a root containing a backtick or newline breaks the Markdown. Cap the roots and use codeSpan.
packages/opencode/src/altimate/review/verdict.ts 260 ai.projects[].state is z.string() instead of the ai.state enum, so a hand-built or replayed signed envelope can carry an arbitrary project state.
Files Reviewed (9 files)
  • packages/opencode/src/altimate/review/multi-project.ts - 4 issues
  • packages/opencode/src/altimate/review/post-github.ts - clean (marker encode/parse and covered-set reconciliation re-verified)
  • packages/opencode/src/altimate/review/run.ts - clean (policyFallbackDirs precedence re-verified)
  • packages/opencode/src/altimate/review/verdict.ts - 1 issue
  • packages/opencode/src/altimate/review/format.ts - 1 issue
  • packages/opencode/src/altimate/review/git.ts - clean (-z listings re-verified)
  • packages/opencode/src/altimate/review/index.ts - clean
  • packages/opencode/src/cli/cmd/review.ts - clean
  • packages/opencode/test/altimate/review-all-projects.test.ts - clean

Fix these issues in Kilo Cloud

Previous review (commit 5e2440e)

Status: 6 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 3

Reviewed the incremental change 5470bfe8..5e2440ec (mode merge, head/SHA carry-through, policy fallback, coveredProjects reconciliation, AI/verifier merge). The two blocking findings from the last review are fixed: the merged scope now carries headSha/headParents (and throws when projects disagree), and mergeProjectEnvelopes no longer re-applies the raw --mode flag. Remaining issues below.

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 124 The single-touched-project early return uses the raw opts.manifestPath, so a --manifest owned by an untouched project (run from inside the touched project) is silently applied there; the "no reviewed project uses it" guard at 126-131 is skipped.
packages/opencode/src/altimate/review/multi-project.ts 116 Roots are discovered from the head tree but each run's cwd is a working-tree path; with an unchecked-out --head, findDbtProject returns undefined and scopeToProject treats every changed file as in scope (duplicate/attributed-to-wrong-project findings).
packages/opencode/src/altimate/review/multi-project.ts 20 IGNORED_DIR still duplicates a subset of SKIP_DIR_PATTERNS (diff-filter.ts:13-23). .venv/venv/site-packages were added, but dbt_modules/ is still missing, so a vendored dbt_modules/<pkg>/dbt_project.yml is discovered as a phantom project and listed in scope.projects / "Reviewed N dbt projects". Reuse SKIP_DIR_PATTERNS instead of a second list.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/review/multi-project.ts 272 When projects' posting policies differ, posting becomes undefined and postingPolicy() falls back to DEFAULT_POSTING_POLICY (budget 10, floor warning), discarding a stricter project's inlineBudget/inlineSeverityFloor/silentWhenClean. Merge to the most restrictive combination (min budget, max severity floor).
packages/opencode/src/altimate/review/format.ts 76 The project list is unbounded and inserted raw. Roots are counted in the render budget, so many/long roots can push every finding bullet into the "N more" notice; a root containing a backtick or newline breaks the Markdown. Cap the roots and use codeSpan.
packages/opencode/src/altimate/review/verdict.ts 260 ai.projects[].state is z.string() instead of the ai.state enum, so a hand-built or replayed signed envelope can carry an arbitrary project state.
Files Reviewed (9 files)
  • packages/opencode/src/altimate/review/multi-project.ts - 4 issues
  • packages/opencode/src/altimate/review/post-github.ts - clean (marker encode/parse and covered-set reconciliation verified)
  • packages/opencode/src/altimate/review/run.ts - clean (policyFallbackDirs precedence verified)
  • packages/opencode/src/altimate/review/verdict.ts - 1 issue
  • packages/opencode/src/altimate/review/format.ts - 1 issue
  • packages/opencode/src/altimate/review/git.ts - clean (-z listings verified)
  • packages/opencode/src/altimate/review/index.ts - clean
  • packages/opencode/src/cli/cmd/review.ts - clean
  • packages/opencode/test/altimate/review-all-projects.test.ts - clean

Fix these issues in Kilo Cloud

Additional previous summary content was truncated to keep this comment within platform limits.


Reviewed by deepseek-v4.1-flash-1017 · Input: 175.7K · Output: 58.7K · Cached: 3.5M

Review guidance: REVIEW.md from base branch feat/review-ai-focused-batches

@dev-punia-altimate dev-punia-altimate 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.

🤖 Code Review — OpenCodeReview (Gemini) — 5 finding(s)

  • 5 anchored to a line (posted inline when the comment stream is on)
  • 0 without a line anchor
All findings (full text)

1. packages/opencode/src/altimate/review/git.ts (L173-L174)

[🟠 MEDIUM] Using git ls-files without -z can cause bugs when file paths contain non-ASCII or special characters (like spaces or newlines). By default, Git enables core.quotePath, which encloses such paths in double quotes and C-style escapes them (e.g., folder-with-ümlaut/dbt_project.yml becomes "folder-with-\303\274mlaut/dbt_project.yml").

When the path ends with a double quote \", subsequent operations in multi-project.ts using regex like /(^|\/)dbt_project\.ya?ml$/ will fail to match because the string ends with a quote rather than yml.

To ensure robust path handling, it is highly recommended to use the -z flag and split by \0, which safely separates entries and disables git path quoting. (Note: A similar update would be beneficial for listFilesAt as well.)

Suggested change:

    const out = await git(["ls-files", "-z", "--cached", "--others", "--exclude-standard", "--full-name"], cwd)
    return out.split("\0").filter(Boolean)

2. packages/opencode/src/altimate/review/multi-project.ts (L70-L72)

[🟠 MEDIUM] The condition rel.startsWith("..") incorrectly matches valid file or directory names that begin with .. (e.g., ..foo), wrongly identifying them as being outside the git root. This causes valid files in the repository to be ignored.

Consider checking for exact match or directory separator to correctly identify paths outside the git root.

Suggested change:

  const rel = path.relative(gitRootReal, abs).replace(/\\/g, "/")
  if (rel === ".." || rel.startsWith("../") || path.isAbsolute(rel)) return undefined
  return rel

3. packages/opencode/src/altimate/review/multi-project.ts (L54-L55)

[🟠 MEDIUM] Inside the loop, byProject.set(root, [...(byProject.get(root) ?? []), f]) creates and spreads a new array for every file assigned to a project. This results in O(n^2) time complexity, which can cause significant performance degradation and high memory allocation when reviewing pull requests that touch a large number of files.

You should use .push() on an existing array to optimize this assignment.

Suggested change:

    if (root === undefined) {
      unassigned.push(f)
    } else {
      let filesForRoot = byProject.get(root)
      if (!filesForRoot) {
        filesForRoot = []
        byProject.set(root, filesForRoot)
      }
      filesForRoot.push(f)
    }

4. packages/opencode/src/altimate/review/multi-project.ts (L114-L120)

[🟠 MEDIUM] The await reviewPullRequest(...) calls are executed sequentially inside a for...of loop for each touched project. Since reviews involve network I/O or heavy computation, sequential execution unnecessarily blocks concurrency, leading to longer overall wait times for multi-project pull requests.

Consider using Promise.all to execute the project reviews concurrently.

Suggested change:

  const runs: ProjectRun[] = await Promise.all(
    touched.map(async (root) => {
      const own = byProject.get(root)!
      process.stderr.write(`ℹ️  reviewing dbt project ${root || "."} (${own.length} changed file(s))\n`)
      const env = await reviewPullRequest({ ...optsFor(root), changedFiles: [...own, ...unassigned], prFiles })
      return { root, paths: own.map((f) => f.path), env }
    })
  )

5. packages/opencode/src/altimate/review/multi-project.ts (L161-L163)

[🟠 MEDIUM] Unassigned files are passed to every project's review. If they fail verification, they will be returned in each project's envelope and subsequently duplicated by envs.flatMap without deduplication. This causes the final envelope to contain duplicated unverified file entries.

Consider deduplicating the unverified entries based on their path and reason.

Suggested change:

  const outsideCount = notReviewed.filter((n) => OUTSIDE_PROJECT.test(n.reason)).length
  const movedCount = envs.reduce((s, e) => s + (e.scope?.movedUnchangedFiles ?? 0), 0)
  const unverifiedRaw = envs.flatMap((e) => e.scope?.unverified ?? [])
  const unverified = [...new Map(unverifiedRaw.map((u) => [`${u.path}\0${u.reason}`, u])).values()]

Comment on lines +173 to +174
const out = await git(["ls-files", "--cached", "--others", "--exclude-standard", "--full-name"], cwd)
return out.split("\n").filter(Boolean)

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.

[🟠 MEDIUM] Using git ls-files without -z can cause bugs when file paths contain non-ASCII or special characters (like spaces or newlines). By default, Git enables core.quotePath, which encloses such paths in double quotes and C-style escapes them (e.g., folder-with-ümlaut/dbt_project.yml becomes "folder-with-\303\274mlaut/dbt_project.yml").

When the path ends with a double quote \", subsequent operations in multi-project.ts using regex like /(^|\/)dbt_project\.ya?ml$/ will fail to match because the string ends with a quote rather than yml.

To ensure robust path handling, it is highly recommended to use the -z flag and split by \0, which safely separates entries and disables git path quoting. (Note: A similar update would be beneficial for listFilesAt as well.)

Suggested change:

Suggested change
const out = await git(["ls-files", "--cached", "--others", "--exclude-standard", "--full-name"], cwd)
return out.split("\n").filter(Boolean)
const out = await git(["ls-files", "-z", "--cached", "--others", "--exclude-standard", "--full-name"], cwd)
return out.split("\0").filter(Boolean)

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.

Thanks, this is a real bug. Without -z, git C-quotes non-ASCII paths, so a dbt_project.yml under a directory like projé/ was never discovered. Fixed in 622f430: listWorkingTreeFiles and listFilesAt (as you suggested) both use -z and split on \0, with a test for a non-ASCII project directory on both the head tree and the working tree.

Comment on lines +70 to +72
const rel = path.relative(gitRootReal, abs).replace(/\\/g, "/")
if (rel.startsWith("..") || path.isAbsolute(rel)) return undefined
return rel

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.

[🟠 MEDIUM] The condition rel.startsWith("..") incorrectly matches valid file or directory names that begin with .. (e.g., ..foo), wrongly identifying them as being outside the git root. This causes valid files in the repository to be ignored.

Consider checking for exact match or directory separator to correctly identify paths outside the git root.

Suggested change:

Suggested change
const rel = path.relative(gitRootReal, abs).replace(/\\/g, "/")
if (rel.startsWith("..") || path.isAbsolute(rel)) return undefined
return rel
const rel = path.relative(gitRootReal, abs).replace(/\\/g, "/")
if (rel === ".." || rel.startsWith("../") || path.isAbsolute(rel)) return undefined
return rel

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.

Good catch, thanks. A directory named ..foo inside the repo was treated as outside it. Fixed in 622f430: the check is now rel === ".." || rel.startsWith("../").

Comment on lines +54 to +55
if (root === undefined) unassigned.push(f)
else byProject.set(root, [...(byProject.get(root) ?? []), f])

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.

[🟠 MEDIUM] Inside the loop, byProject.set(root, [...(byProject.get(root) ?? []), f]) creates and spreads a new array for every file assigned to a project. This results in O(n^2) time complexity, which can cause significant performance degradation and high memory allocation when reviewing pull requests that touch a large number of files.

You should use .push() on an existing array to optimize this assignment.

Suggested change:

Suggested change
if (root === undefined) unassigned.push(f)
else byProject.set(root, [...(byProject.get(root) ?? []), f])
if (root === undefined) {
unassigned.push(f)
} else {
let filesForRoot = byProject.get(root)
if (!filesForRoot) {
filesForRoot = []
byProject.set(root, filesForRoot)
}
filesForRoot.push(f)
}

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.

Thanks, that's fair. It's quadratic only in the number of changed files per project, so it doesn't matter in practice, but push is just as clear. We'll switch it in a follow-up cleanup.

Comment on lines +114 to +120
const runs: ProjectRun[] = []
for (const root of touched) {
const own = byProject.get(root)!
process.stderr.write(`ℹ️ reviewing dbt project ${root || "."} (${own.length} changed file(s))\n`)
const env = await reviewPullRequest({ ...optsFor(root), changedFiles: [...own, ...unassigned], prFiles })
runs.push({ root, paths: own.map((f) => f.path), env })
}

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.

[🟠 MEDIUM] The await reviewPullRequest(...) calls are executed sequentially inside a for...of loop for each touched project. Since reviews involve network I/O or heavy computation, sequential execution unnecessarily blocks concurrency, leading to longer overall wait times for multi-project pull requests.

Consider using Promise.all to execute the project reviews concurrently.

Suggested change:

Suggested change
const runs: ProjectRun[] = []
for (const root of touched) {
const own = byProject.get(root)!
process.stderr.write(`ℹ️ reviewing dbt project ${root || "."} (${own.length} changed file(s))\n`)
const env = await reviewPullRequest({ ...optsFor(root), changedFiles: [...own, ...unassigned], prFiles })
runs.push({ root, paths: own.map((f) => f.path), env })
}
const runs: ProjectRun[] = await Promise.all(
touched.map(async (root) => {
const own = byProject.get(root)!
process.stderr.write(`ℹ️ reviewing dbt project ${root || "."} (${own.length} changed file(s))\n`)
const env = await reviewPullRequest({ ...optsFor(root), changedFiles: [...own, ...unassigned], prFiles })
return { root, paths: own.map((f) => f.path), env }
})
)

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.

Thanks for the suggestion. We're keeping these sequential on purpose. Each project review starts its own AI lane (up to two concurrent model calls, plus the optional verifier's tool loop), so running projects in parallel would multiply concurrent LLM calls and rate-limit pressure by the number of projects. They also share the native dispatcher, and their stderr progress lines would interleave into an unreadable CI log. Wall time is usually dominated by the model calls, which already run concurrently within each project.

Comment on lines +161 to +163
const outsideCount = notReviewed.filter((n) => OUTSIDE_PROJECT.test(n.reason)).length
const movedCount = envs.reduce((s, e) => s + (e.scope?.movedUnchangedFiles ?? 0), 0)
const unverified = envs.flatMap((e) => e.scope?.unverified ?? [])

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.

[🟠 MEDIUM] Unassigned files are passed to every project's review. If they fail verification, they will be returned in each project's envelope and subsequently duplicated by envs.flatMap without deduplication. This causes the final envelope to contain duplicated unverified file entries.

Consider deduplicating the unverified entries based on their path and reason.

Suggested change:

Suggested change
const outsideCount = notReviewed.filter((n) => OUTSIDE_PROJECT.test(n.reason)).length
const movedCount = envs.reduce((s, e) => s + (e.scope?.movedUnchangedFiles ?? 0), 0)
const unverified = envs.flatMap((e) => e.scope?.unverified ?? [])
const outsideCount = notReviewed.filter((n) => OUTSIDE_PROJECT.test(n.reason)).length
const movedCount = envs.reduce((s, e) => s + (e.scope?.movedUnchangedFiles ?? 0), 0)
const unverifiedRaw = envs.flatMap((e) => e.scope?.unverified ?? [])
const unverified = [...new Map(unverifiedRaw.map((u) => [`${u.path}\0${u.reason}`, u])).values()]

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.

Thanks for looking at this. It turns out not to happen in the normal case: scope.unverified only ever holds a project's own in-scope models (orchestrate.ts ~1842-1889). The unassigned files every project receives are scoped out as "outside the dbt project" before any engine lane sees them, and the merge already de-duplicates those notReviewed entries. The one edge case is custom *-paths pointing outside a project root (cubic's r4626966425), which we're tracking; de-duplicating unverified by path is cheap extra hardening we may add with it.

@dev-punia-altimate

Copy link
Copy Markdown
Contributor

🤖 Code Review — OpenCodeReview (Gemini) — No Issues Found

No supported files changed.

@github-actions

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

scope: {
baseRef: first.scope?.baseRef,
baseSha: first.scope?.baseSha,
baseSource: first.scope?.baseSource,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CRITICAL: The rebuilt scope drops headSha, which permanently disables the stale-run guard for multi-project reviews.

postGitHubReview computes const onCurrentHead = !headSha || !commitId || headSha === commitId (post-github.ts:191-192) from env.scope?.headSha (verdict.ts:140). With the field absent, onCurrentHead is always true, so an older --all-projects run that finishes after a newer push can call dismissStale() and dismiss the newer run's CHANGES_REQUESTED block — the exact case the code comment says must never happen: "A run on an older push (its head is no longer the PR's head) never clears the block a newer push's run may have posted."

Every per-project envelope resolves the same head (run.ts:252, headSha at run.ts:486), so carry it through:

Suggested change
baseSource: first.scope?.baseSource,
headSha: first.scope?.headSha,

const env = await reviewPullRequest({ ...optsFor(root), changedFiles: [...own, ...unassigned], prFiles })
runs.push({ root, paths: own.map((f) => f.path), env })
}
return mergeProjectEnvelopes(runs, opts.mode)

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: Passing the raw --mode flag as modeOverride can soften the verdict that the base policy refused to relax.

reviewPullRequest ignores --mode comment when the base .altimate/review.yml sets mode: gate (run.ts:278-282), so each project envelope is mode: "gate" with a REQUEST_CHANGES verdict. mergeProjectEnvelopes(runs, opts.mode) then sets the merged mode back to "comment" and applyMode(...) rewrites that REQUEST_CHANGES into COMMENT, yielding a non-blocking verdict and exit code. That defeats the documented tighten-only guard (docs: --mode "cannot turn mode: gate into comment").

Each per-project verdict already has its own effective mode applied, so the override should be dropped (or derived from the envelopes) rather than taken from the raw flag:

Suggested change
return mergeProjectEnvelopes(runs, opts.mode)
return mergeProjectEnvelopes(runs)

source: all.map((p) => p.source).reduce((a, b) => (POLICY_SOURCE_RANK[b] > POLICY_SOURCE_RANK[a] ? b : a)),
hash: createHash("sha256").update(all.map((p) => p.hash).join("\n")).digest("hex").slice(0, 16),
changedInPr: changed.length ? changed : undefined,
posting: postings.every((x) => x === postings[0]) ? all[0].posting : undefined,

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: When projects' posting policies differ, the merged envelope records none, and postingPolicy() silently falls back to the permissive defaults.

postingPolicy(env) returns env.policy?.posting ?? DEFAULT_POSTING_POLICY (format.ts:388-389): inlineBudget: 10, inlineSeverityFloor: "warning", silentWhenClean: true. If one project opts out of inline comments (inlineBudget: 0) or raises its severity floor, a sibling at defaults makes posting undefined here and the stricter project's settings are discarded for the posted review. Merge to the most restrictive combination (lowest inlineBudget, highest inlineSeverityFloor) instead of dropping the policy.

@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from 31cb5c4 to ddc4333 Compare November 20, 2026 08:22
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from 622f430 to 5470bfe Compare November 20, 2026 08:23

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

Panel: lead + Codex + Claude (independent). All findings premise-checked against the code. Single-project path (0 or 1 project, run from inside it) is unchanged and the 10 new tests plus typecheck pass.

Counts: CRITICAL 0, MAJOR 3, MINOR 2, NIT 6.

Nits

  • multi-project.ts:17 const IGNORED_DIR = /(^|\/)(dbt_packages|target|node_modules)\// - without --head the working-tree listing includes untracked non-ignored files, so a .venv/.../site-packages/dbt/include/starter_project/dbt_project.yml is discovered as a project. Add .venv, venv, site-packages.
  • multi-project.ts:26-33 discoverDbtProjects lists the head side only: files of a project deleted wholesale by the PR end up "outside the dbt projects reviewed" and get no deletion check. Consider also discovering at the merge-base to assign deleted files.
  • multi-project.ts:289 const AI_STATE_RANK = ... is declared at the bottom of the file after its use; move it next to VERDICT_RANK/TIER_RANK.
  • multi-project.ts:154 comment "a comment-mode project never blocks" stops being accurate with the mode override; update together with the fix. The header comment (line 9-13) should say the policy now comes from the project directory.
  • multi-project.ts:21 OUTSIDE_PROJECT is a regex but OUTSIDE_ALL a string; consider OUTSIDE_PROJECT_RE. In mergeAi, the local worst holds a lane, not a state, and shadows the verdict-helper name used elsewhere.
  • Test gaps: CLI flag wiring (--all-projects selects reviewAllProjects), dbt_project.yaml and ignored-dir discovery, and listFilesAt with a non-ASCII directory (the -z change has no direct test); a merged envelope through postGitHubReview.

const seenIds = new Set<string>()
const findings = envs.flatMap((e) => e.findings).filter((f) => !seenIds.has(f.id) && !!seenIds.add(f.id))

const mode = modeOverride ?? (envs.some((e) => e.mode === "gate") ? "gate" : first.mode)

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] --mode override is re-applied after each project enforced the base policy

const mode = modeOverride ?? (envs.some((e) => e.mode === "gate") ? "gate" : first.mode)

reviewPullRequest deliberately ignores --mode comment when the base branch's policy says mode: gate (run.ts, "may only tighten"). The merge then applies the raw CLI flag again. Scenario: project A is gate with a critical finding (child verdict REQUEST_CHANGES), project B is comment, the PR-editable workflow passes --mode comment. Merged result is mode: comment, verdict COMMENT (while scope.projects[0].mode is still gate), so the CLI gate check passes and no blocking review is posted. Reproduced independently by two reviewers.

Fix: do not take modeOverride in the merge; use envs.some(e => e.mode === "gate") ? "gate" : "comment" with the worst post-mode verdict. Add a regression test.

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.

Agreed, fixed in 5e2440e. mergeProjectEnvelopes no longer takes the override. The merged mode is gate if any project ended up in gate, otherwise comment, and the verdict is the worst post-mode project verdict. Each project's mode already includes --mode, but only where reviewPullRequest allowed it to tighten the base policy. Regression tests:

  • a unit test: a gate project with a critical finding plus a comment project stays REQUEST_CHANGES in gate;
  • an end-to-end test: a repo whose base root policy says mode: gate, run with --mode comment, keeps proj_a in gate and the merged envelope in gate.

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 at 676c803 — multi-project.ts:172-173 no longer takes modeOverride; merged mode is derived from the children's post-mode modes. The end-to-end test (review-all-projects.test.ts:110, --mode comment against a base gate) keeps mode: gate and fails against the previous merge code. (The unit test at :280 would also pass on the old code, so the integration test is the real guard.)

scope: {
baseRef: first.scope?.baseRef,
baseSha: first.scope?.baseSha,
baseSource: first.scope?.baseSource,

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] Merged scope drops headSha, disabling the stale-run guard in the poster

baseSource: first.scope?.baseSource,

The merged scope copies baseRef/baseSha/baseSource but not headSha. post-github.ts:191-192 computes onCurrentHead = !headSha || !commitId || headSha === commitId, so a missing headSha is always "current". Scenario (gate mode): the run for push 1 finishes after push 2's blocking review was posted; with a single-project envelope it refuses to dismiss, with the merged envelope it dismisses the newer block and the PR becomes mergeable.

Fix: add headSha (and projectRoot handling, see below) to the merged scope; keep it only when all child heads agree and otherwise fail/handle explicitly. Assert in a test.

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 5e2440e. The merged scope carries headSha and headParents (the merge-commit parents from #1723), so the poster's reviewedPrHead guard works on merged envelopes. All projects are reviewed at one head. If they ever disagree (for example HEAD moved during a working-tree run), the merge throws instead of guessing. Tests: the end-to-end merged envelope has scope.headSha equal to HEAD; a unit test checks that both fields are carried and that different heads throw.

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 at 676c803 — merged scope carries headSha/headParents (multi-project.ts:234-235) and differing child heads throw. Probed through the poster: stale or unknown head keeps the earlier block; test at :296 fails without the fix.

root === manifestOwner || (manifestOwner === undefined && touched.length === 1) ? manifestAbs : undefined
const optsFor = (root: string): ReviewPullRequestOptions => ({
...opts,
cwd: path.join(gitRootReal, root),

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] Per-project cwd silently drops a repo-root .altimate/review.yml policy

cwd: path.join(gitRootReal, root),

reviewPullRequest loads the base policy from cwd only (loadReviewPolicy({ cwd: opts.cwd, ... })). optsFor moves cwd into the project directory, including on the single-touched-project path (reviewPullRequest(optsFor(touched[0]))). Scenario: a repo-root .altimate/review.yml with mode: gate, run from the repo root. Plain reviewPullRequest gives mode=gate, policy.source=base; reviewAllProjects gives mode=comment, policy.source=default. A mono-repo CI job that gates merges silently loses gating, severity and rule settings when --all-projects is added, with no warning.

Fix: fall back to the policy at opts.cwd/repo root when a project has none of its own (e.g. pass the resolved policy directory through the options), or at minimum warn when a root policy exists that no project uses. Add a test.

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.

Thanks, this would have silently ungated mono-repos. Fixed in 5e2440e. ReviewPullRequestOptions gains policyFallbackDirs, and --all-projects passes the invocation directory and then the repo root. The first directory with a policy file wins: the project's own .altimate/review file, else the invocation directory's, else the repo root's. Each is read from the base branch exactly as before, so a PR still cannot add a project-level file to loosen the root policy. If a PR does add one, it is listed in changedInPr. The precedence is documented in the multi-project.ts header. The test sets a root mode: gate policy and a proj_b mode: comment policy, and checks:

  • proj_a gets gate from the root policy;
  • proj_b gets comment from its own policy;
  • the single-touched-project path from the repo root gets mode: gate, policy.source: base.

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.

⚠️ Partially fixed at 676c803 — policyFallbackDirs (multi-project.ts:118, run.ts:264-281) restores the root policy when run from the repo root, and a PR-added project policy cannot loosen the base policy. But the shortcut at multi-project.ts:124 (and :102) still calls reviewPullRequest(opts) without fallbacks. Repro with a root mode: gate policy and one touched project: cwd=repo root gives gate/base, cwd=proj_a gives comment/default. See the new inline comment.

@RaghwendraSingh RaghwendraSingh Nov 23, 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.

The rest of this is done in 24e925a. Every return path now carries the fallback dirs, and the order is per project (nearest enclosing policy, up to the root), so it no longer depends on where the command runs. Details are in the replies on the three new inline threads.

movedUnchangedFiles: movedCount || undefined,
unverified: unverified.length ? unverified : undefined,
notReviewed,
projects: runs.map((r) => ({

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] Merged envelope has no projectRoot, so earlier per-project blocking reviews are never reconciled

projects: runs.map((r) => ({

The poster identifies prior bot reviews by the project=<root> marker (post-github.ts:97-102). The merged scope omits projectRoot while the single-project fallback keeps it, so the marker changes with the number of touched projects. Scenario: a previous run left a project=a CHANGES_REQUESTED review; a later --all-projects run touching A and B posts under the root marker and never dismisses it (and vice versa), so a fixed PR can stay blocked.

Fix: give the all-projects review a stable identity, and let it dismiss prior blocks for the projects it covers (keeping the completeness and head-SHA safeguards). Add a test.

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 5e2440e. Every --all-projects envelope now records scope.coveredProjects. That is every discovered project, because a project the PR does not touch has nothing to flag. This includes the single-touched-project paths, so a later run that touches fewer projects can still clear an earlier block.

  • Such envelopes post under a projects=<dir>,<dir> marker. Each root is URI-component-encoded, with . for the repo root.
  • The poster treats an earlier bot review as its own when every project its marker names is in the covered set.
  • So an all-projects run dismisses earlier project=a, project=b and projects=a,b blocks, but not project=c or projects=a,c. A plain single-project run still never touches a review that names other projects.

The completeness and head-SHA guards are unchanged. The test sends a merged envelope through postGitHubReview and asserts both the dismissals and the new marker.

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 at 676c803 — scope.coveredProjects plus a projects=<a>,<b> marker (post-github.ts:91-100,139-140). Marker round-trips for commas, spaces, percent signs, non-ASCII and the root; a single-project run never dismisses a review covering more projects; head/completeness safeguards still apply. Test at :346 fails with the old matcher.

const worst = lanes.reduce((a, b) => (AI_STATE_RANK[b.env.ai!.state] > AI_STATE_RANK[a.env.ai!.state] ? b : a))
const state = worst.env.ai!.state
const reason = worst.env.ai!.reason
const base = ok ?? first

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] AI coverage and verifier metadata keep only one project's values

const base = ok ?? first

...base carries one project's input, unsent and verifier; ai.projects only records state/reason/calls. Two projects each with one input file and verifier cost 2 merge to one input file and verifier cost 2, not two and 4, so coverage notes and verifier telemetry omit sibling activity.

Fix: union coverage records and sum verifier usage/counters, or attribute them per project in ai.projects.

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 5e2440e:

  • ai.input records and ai.unsent are now the union across projects.
  • ai.verifier sums usage (tokens, cost, duration) and counters (turns, tool calls, reviewed/kept/discarded/summary/unreviewed). Its state is the worst one, prefixed with that project's root. dropped (still capped at 20) and decisions are concatenated.

The test merges two projects that each have one input file and a verifier cost of 2, and gets two input records, cost 4 and the error state of the failing project.

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 at 676c803 — input/unsent are unioned and the verifier usage/counters summed (multi-project.ts:289-348); test at :314 checks two input records and cost 4, and fails on the old code.

@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from ddc4333 to 7b5bb4b Compare November 20, 2026 11:37
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from 5470bfe to 5e2440e Compare November 20, 2026 11:37
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Thanks Harish for the careful premise-checked review. All three MAJORs and both MINORs are fixed in 5e2440e ("fix(review): address review feedback: --all-projects mode, head, policy, reconciliation, AI merge"), each with a regression test. Details are in the threads.

Nits:

  • IGNORED_DIR now also skips .venv, venv and site-packages. A discovery test covers these and dbt_project.yaml.
  • AI_STATE_RANK moved next to VERDICT_RANK/TIER_RANK.
  • Renamed OUTSIDE_PROJECT to OUTSIDE_PROJECT_RE. In mergeAi, the local worst is now worstLane.
  • The line-154 comment and the module header are updated: the header documents where the policy comes from and its precedence.
  • Test gaps: a merged envelope now goes through postGitHubReview in a test.

Not in this commit:

  • Discovering projects at the merge-base as well, so a project deleted wholesale gets the deletion check. It changes file assignment, so I'd like to do it separately. Follow-up.
  • Tests for --all-projects CLI wiring and for listFilesAt with non-ASCII names. Existing coverage is discovery under projé/ in both the head tree and the working tree. Follow-up.

if (touched.length === 1) {
// Invoked from inside the touched project: exactly the single-project review.
const cwdRel = repoRel(gitRootReal, await canonical(opts.cwd))
if (cwdRel !== undefined && owningProject(cwdRel + "/", roots) === touched[0]) return covered(await reviewPullRequest(opts))

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: This early return bypasses the --manifest attribution guard added just below it.

manifestAbs/manifestOwner/manifestFor() are computed before this branch (lines 105-113), but the "belongs to , which this PR does not change" warning is emitted at lines 126-131 — after the return. So when the PR touches exactly one project and the CLI runs from inside it:

cd proj_a && altimate review --all-projects --manifest ../proj_b/target/manifest.json

touched == ["proj_a"], this branch returns reviewPullRequest(opts) with the raw opts.manifestPath, and proj_b's manifest is silently used to analyse proj_a — wrong nodes/dialect, no diagnostic. That contradicts the guard below, which is the only place the misattribution is reported.

Hoist the attribution check above this branch (it only needs manifestAbs and manifestFor), or pass manifestPath: manifestFor(touched[0]) here so a foreign manifest is dropped and warned about.

@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from 7b5bb4b to a2d91ce Compare November 21, 2026 09:45
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from 5e2440e to 676c803 Compare November 21, 2026 09:46

@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 676c803 (previous review at 5470bfe, since rebased: 04b5104). Panel: Claude + Codex + lead.

Request changes. Of the three prior MAJORs, two are fixed (--mode re-applied; stale-run guard) and one is partially fixed (repo-root policy). Both prior MINORs are fixed. 16/16 tests in review-all-projects.test.ts pass, and 7 of them fail on the previous code, so the fixes have regression tests.

Counts: CRITICAL 0, MAJOR 1 (open, prior #3 remainder), MINOR 2 (new), NIT 5. Replies posted in each prior thread.

Prior finding Status
--mode re-applied after per-project policy (MAJOR) Fixed
Merged scope drops headSha (MAJOR) Fixed
Repo-root policy ignored by per-project cwd (MAJOR) Partially fixed: root invocation works, invocation from inside the sole touched project still loses it (inline)
No projectRoot, prior blocks not reconciled (MINOR) Fixed (coveredProjects / projects= marker)
AI input/unsent/verifier keep one project (MINOR) Fixed
Prior nit Status
venv dirs in discovery Fixed, tested
AI_STATE_RANK placement, header/mode comments, OUTSIDE_PROJECT_RE, worstLane Fixed
Deleted-wholesale project not discovered (head-only discovery) Not fixed; safe for dismissal (not in coveredProjects)
Test gaps Merged envelope through the poster and dbt_project.yaml/ignored dirs now tested; CLI flag wiring and listFilesAt with non-ASCII still have no direct test

Nits

  • multi-project.ts:209-211 const heads = new Set(envs.map(...)) / throw: each project resolves opts.head ?? "HEAD" itself, so a head that moves mid-run fails only after all AI work is spent. Resolve the head once in reviewAllProjects and pass it down; the throw becomes an assertion.
  • multi-project.ts:327 if (present.length === 1) return present[0].v: the single verifier's reason lacks the root: prefix used in the multi case; also ai.replayed/ai.replayIncomplete come only from ...base, so a sibling's replayIncomplete: true is lost. OR them.
  • verdict.ts:162 coveredProjects is another new signed field: an older CLI that strips unknown keys will fail signature verification of such envelopes (same pre-existing pattern as projects); worth a changelog note.
  • multi-project.ts:96 const covered = (env) => ... shares its name with the covered Set in post-github.ts; consider withCovered. Likewise policyFallbackDirs becomes policyAncestorDirs if the ancestor fix above is taken.
  • Test: the unit test "a gate project's block survives the merge" (:280) also passes on the old code; keep the integration test as the guard, and add negative poster tests (merged envelope with headSha != PR head, or incomplete, must not dismiss) and a CLI wiring test for --all-projects.

if (touched.length === 1) {
// Invoked from inside the touched project: exactly the single-project review.
const cwdRel = repoRel(gitRootReal, await canonical(opts.cwd))
if (cwdRel !== undefined && owningProject(cwdRel + "/", roots) === touched[0]) return covered(await reviewPullRequest(opts))

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] Single-touched-project shortcut still drops the repo-root .altimate/review.yml (remainder of the earlier policy finding)

if (cwdRel !== undefined && owningProject(cwdRel + "/", roots) === touched[0]) return covered(await reviewPullRequest(opts))

This branch (and the zero-touched branch at line 102) calls reviewPullRequest(opts) without policyFallbackDirs, so the root policy is not consulted. Reproduced with a root .altimate/review.yml of mode: gate, one touched project, same base/head:

invocation dir result
repo root mode=gate, policy.source=base
proj_a mode=comment, policy.source=default

A workflow using --all-projects with working-directory: proj_a (or a PR touching one project today and two tomorrow) silently loses the gate, severity and rule settings, so a finding that should be REQUEST_CHANGES is downgraded to COMMENT. The added test only covers invocation from the repo root.

Fix: pass the same policyFallbackDirs (project ancestors up to the repo root) on every return path, and add a test invoking from inside the sole touched project.

@RaghwendraSingh RaghwendraSingh Nov 23, 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.

Good catch, fixed in 24e925a. Both shortcuts (multi-project.ts:117 with no touched project, :139 for the sole touched project) now pass policyFallbackDirs with the invocation dir's ancestors up to the repo root. New test review-all-projects.test.ts:134 runs from inside proj_a with a root mode: gate and gets gate/base on both paths. It fails on the old code.

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 at 24e925a — inPlace (multi-project.ts:102) carries policyFallbackDirs and is used on the zero-touched (:117) and sole-touched (:139) paths. Re-ran the repro on fresh repos: root mode: gate, one touched project, run from proj_a, proj_a/models, via a symlink, and with zero touched projects all give gate/base (old code: comment/default). Test review-all-projects.test.ts:134 fails on the pre-fix code.

...opts,
cwd: path.join(gitRootReal, root),
manifestPath: manifestFor(root),
policyFallbackDirs: [...new Set([opts.cwd, gitRootReal])],

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] Fallback order lets a sibling project's policy govern another project

policyFallbackDirs: [...new Set([opts.cwd, gitRootReal])],

The invocation directory is tried before the repo root for every project, not only for projects inside it. Setup: base root mode: gate, base proj_a/.altimate/review.yml mode: comment, PR touches proj_a and proj_b. From the repo root proj_b runs in gate; with cwd=proj_a, proj_b runs in comment with proj_a's policy hash, so its gating is silently off.

Fix: fall back along the project's own ancestor directories up to the repo root (nearest enclosing policy); use the invocation directory only when it is an ancestor of that project. Add a test invoking from a sibling project.

@RaghwendraSingh RaghwendraSingh Nov 23, 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.

Agreed, fixed in 24e925a. Each project now falls back only along its own ancestors up to the repo root (ancestorsUpToRoot, multi-project.ts:87,133), so the invocation dir only counts when it encloses the project. Test review-all-projects.test.ts:151 runs your setup from the root, proj_a and proj_b: proj_a stays comment and proj_b stays gate every time.

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 at 24e925a — each project now falls back along its own ancestors (ancestorsUpToRoot, multi-project.ts:133). Root gate + proj_a comment, PR touches both: from the root, proj_a and proj_b all give [proj_a: comment, proj_b: gate], top-level gate (old code from proj_a: proj_b=comment). Test :151 fails on the old code.

policy = await policyAt(dir)
}
// A policy file the PR adds next to the project would replace the fallback: list it too.
if (policyChangedHere.length && policy.changedInPr !== policyChangedHere)

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] A PR-added project policy that overrides an inherited one is diffed against defaults, not the inherited policy

if (policyChangedHere.length && policy.changedInPr !== policyChangedHere)

policyChangedHere was computed by policyAt(opts.cwd) against the default config. Scenario: base root policy is mode: gate; the PR adds proj_a/.altimate/review.yml with mode: comment. Nothing is reported (changedInPr empty, no stderr notice) because comment equals the default, yet once merged that file replaces the root policy for proj_a and turns gating off. The reverse also happens: an added file identical to the inherited policy is reported as a change.

Fix: when a fallback policy was applied, diff the PR's project file against the applied fallback config, and always flag a newly added project-level policy file that overrides an inherited one.

@RaghwendraSingh RaghwendraSingh Nov 23, 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 24e925a. When an inherited policy is applied, run.ts:279 diffs the PR's project file against that policy using the new headPolicyChanges (config.ts). Test review-all-projects.test.ts:167: adding proj_a mode: comment over the root gate now reports ["mode"], and an added file identical to the root policy reports nothing.

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.

⚠️ Mostly fixed at 24e925a — the project-directory case is fixed: base root gate + PR-added proj_a/.altimate/review.yml mode: comment now reports changedInPr: ["mode"] from the root and from inside either project, and an identical or semantically equal added file reports nothing (test :167 fails on old code). The same blind spot remains one level up: a policy file the PR adds in a directory between the project and the applied ancestor is not reported (see the new inline comment on run.ts:285).

@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from a2d91ce to 845f31a Compare November 23, 2026 08:39
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from 676c803 to a3689b6 Compare November 23, 2026 08:39
// no directory has one on the base branch).
const addedHere =
policy.source === "base" ? await headPolicyChanges(opts.cwd, policy.config) : policyHere.changedInPr
policy.changedInPr = [...new Set([...policy.changedInPr, ...addedHere])]

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: A PR-added policy file in a non-project ancestor directory is never reported in policy.changedInPr.

The fallback walk visits every ancestor between the reviewed project and the repo root, but each policyAt(dir) result is discarded unless it is the last non-default one. Scenario: project dbt/a has no policy of its own and the base root policy is mode: gate; the PR adds dbt/.altimate/review.yml with mode: comment. policyAt(<root>/dbt) returns source: "default" with changedInPr: ["mode"], the loop continues to the root, and this block only unions headPolicyChanges(opts.cwd, policy.config) (i.e. dbt/a's own file), so the dbt file's change is dropped. That file is not assigned to any project either (only dbt/a is a project root), so the merged envelope has no changedInPr, the "This PR changes the review policy" note is missing, and the file only shows up in the not-reviewed ledger — yet after merge it is exactly the file --all-projects resolution applies to dbt/a.

Diff the nearest visited directory that has a head-side policy file against the applied policy (not only opts.cwd), or union the changedInPr of every visited directory that has one.

@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from 845f31a to d8cfb39 Compare November 23, 2026 08:58
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from a3689b6 to aa6041d Compare November 23, 2026 08:58
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from d8cfb39 to b3247d1 Compare November 23, 2026 08:59
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from aa6041d to 24e925a Compare November 23, 2026 09:00

@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 24e925a (previous review at 676c803). Panel: Claude + Codex + lead.

Approving. All three prior findings reproduce as fixed on fresh repos at this head, no policy-gate bypass remains, and each fix has a regression test that fails on the pre-fix code (review-all-projects.test.ts 19/19 pass; the full review suite passes). One new MINOR (policy-change reporting only, not enforcement) and a few nits are left; none block.

Counts: CRITICAL 0, MAJOR 0, MINOR 1 (new), NIT 6.

Prior finding Status
MAJOR: single/zero-touched shortcut skipped repo-root policy Fixed (multi-project.ts:102,117,139; test :134)
MINOR: invocation dir tried before repo root, sibling inherits policy Fixed (ancestorsUpToRoot, :133; test :151)
MINOR: PR-added project policy diffed against defaults Fixed for the project dir (headPolicyChanges; test :167); intermediate-dir gap is the new MINOR
Prior nit Status
Deleted-wholesale project not discovered (head-only discovery) Not fixed (safe for dismissal; tracked)
CLI flag wiring test for --all-projects Not fixed
listFilesAt non-ASCII test Fixed (review-all-projects.test.ts:271)
Unit test "a gate project's block survives the merge" passes on old code Unchanged; the integration test is the guard
Head resolved per project, mismatch thrown after AI spend (multi-project.ts:225) Not fixed
Single verifier reason lacks root prefix; ai.replayed/replayIncomplete not OR-ed Not fixed
coveredProjects new signed field, changelog note Not fixed

Nits

  • multi-project.ts:102,117 const inPlace = { ...opts, policyFallbackDirs: ancestorsUpToRoot(...) }: on the zero-touched path the invocation directory's own policy still applies even when it is a sibling or non-project dir (run from services/ with a comment policy and root gate gives comment), contradicting the doc "A sibling directory's policy never applies, whichever directory the command runs from". Nothing is reviewed on that path so impact is nil; use the repo-root policy there or soften the doc. inPlace could be named fromInvocationDir.
  • config.ts:265 if (headText === appliedText) return [] / structuredClone(DEFAULT_REVIEW_CONFIG): when the PR deletes a project-level policy file and an ancestor policy exists, the change is measured against defaults instead of the policy inherited afterwards. Root gate + base proj_a mode: gate, severityThreshold: warning deleted by the PR reports ["mode","severityThreshold"] although nothing effective changes. Compare against the next ancestor's config when the head file is missing.
  • multi-project.ts:17 "whichever directory the command runs from": the single-project shortcut still lets a project-level policy under the invocation dir (e.g. proj_a/models) win over the project's ancestor policy; document or align.
  • Tests: no test for --all-projects CLI parsing/dispatch (the boolean-flags test omits it), a PR-added intermediate-directory policy, nested-project policy inheritance, or running from a non-project subdirectory.
  • multi-project.ts:93-96 const covered = (env) => ... shares its name with the covered Set in post-github.ts; consider withCovered.
  • verdict.ts coveredProjects: older CLIs that strip unknown signed keys fail verification of such envelopes; worth a changelog line.

// no directory has one on the base branch).
const addedHere =
policy.source === "base" ? await headPolicyChanges(opts.cwd, policy.config) : policyHere.changedInPr
policy.changedInPr = [...new Set([...policy.changedInPr, ...addedHere])]

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] A policy file the PR adds in a directory between the project and the applied ancestor is not reported in changedInPr

const addedHere =
  policy.source === "base" ? await headPolicyChanges(opts.cwd, policy.config) : policyHere.changedInPr
policy.changedInPr = [...new Set([...policy.changedInPr, ...addedHere])]

While the fallback loop walks up, policy is replaced by each ancestor's result, which discards the intermediate directory's changedInPr; headPolicyChanges is then called only for opts.cwd. Reproduced by Claude and Codex on fresh repos: base root policy mode: gate, projects at services/proj_a and services/proj_b, the PR adds services/.altimate/review.yml with mode: comment. Both projects correctly stay gated, but changedInPr is absent (no stderr notice, nothing in the envelope), although once merged the added file silently turns gating off for both. Same when no base policy exists and the PR adds services/.altimate/review.yml. Editing an existing intermediate policy is reported correctly. This is not an enforcement bypass (the base policy still applies), only the audit trail from the earlier finding, one directory higher.

Fix: for every directory skipped on the way up ([cwd, ...policyFallbackDirs] before the applied one) add headPolicyChanges(dir, policy.config), or resolve the effective head policy across the whole ancestor chain and diff it against the applied one. Add a regression test with a PR-added services/.altimate/review.yml.

@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from b3247d1 to 140737c Compare November 23, 2026 10:38
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from 24e925a to 0daab2a Compare November 23, 2026 10:38
@RaghwendraSingh

Copy link
Copy Markdown
Contributor Author

Heads-up: one small commit added on top after rebasing onto #1772's latest fix: 0daab2a. In --all-projects mode each project's review now gets every rename in the PR (prRenames), so a credential file renamed in another project is refused to this project's verifier too. Test: "a credential file another project renames unedited is refused to this project's verifier" in review-all-projects.test.ts.

RaghwendraSingh and others added 5 commits November 23, 2026 18:57
A mono-repo PR can change several dbt projects; until now the review only
covered the project found from `--cwd` and listed every other project's
files as "outside the dbt project".

- `reviewAllProjects` (new `multi-project.ts`) collects the changed files
  once, discovers every `dbt_project.yml` at the head side (skipping
  `dbt_packages/`, `target/`, `node_modules/`), and assigns each file to the
  deepest project containing it. Each touched project is reviewed
  sequentially with `reviewPullRequest` (its own policy, layout and
  manifest auto-discovery; `--manifest` applies only to the project that
  contains it), seeing only its own files plus files outside every project.
- The results merge into one signed envelope: findings concatenated and
  de-duplicated by id, the most severe verdict and highest tier, summary
  recomputed, the not-reviewed ledger unioned (other projects' files are no
  longer "outside"), engine errors combined, AI usage summed, and per-project
  roots/verdicts/AI states in `scope.projects` / `ai.projects`.
- With 0 or 1 touched projects the single-project envelope is returned.
- `altimate review --all-projects` wires it into the CLI; the summary adds a
  "Reviewed N dbt projects" line only when more than one was reviewed.
- `reviewPullRequest` gains an optional `prFiles` (the full PR file list when
  `changedFiles` is a subset); the default path is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…envelope, AI state, path listing

- An explicit `--manifest` outside every project (CI `$RUNNER_TEMP/manifest.json`)
  now goes to the touched project when the PR touches only one; when it can't be
  attributed (several touched projects, or it belongs to an untouched one) a
  warning says no project uses it instead of silently degrading to lint-only.
- Merged verdict: the worst of each project's post-mode verdict, so a
  comment-mode project's REQUEST_CHANGES no longer blocks because a sibling uses
  gate mode. `scope.projects[]` records each project's `mode`.
- Merged envelope is built explicitly instead of spreading the first project:
  `manifestHash` and `policy` are kept only when every project agrees (otherwise
  `policy` carries the least-trusted source, a combined hash, the union of
  `changedInPr` and a shared posting policy); `scope.projectRoot` is dropped; each
  project's `manifestHash` and `policyHash` go in `scope.projects[]`;
  `tierClassified` is the highest classified tier.
- Merged AI state is the worst project state (`error` > `timeout` > `ok` >
  `skipped`) with that project's reason, so a sibling's failure is not hidden by
  another project's `ok`; `ai.projects[]` carries each `reason`.
- `listFilesAt` / `listWorkingTreeFiles` use `-z`, so `dbt_project.yml` under
  non-ASCII directory names is discovered (git C-quoted those paths).
- `repoRel` rejects only `..` and `../…`, not in-repo names such as `..foo`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cy, reconciliation, AI merge

- Mode: the merge no longer re-applies `--mode`; each project's mode already
  carries it only where it tightens the base policy, so a gate project's block
  survives a PR-editable `--mode comment`
- Head: the merged scope carries the shared `headSha` / `headParents` (the
  poster's stale-run guard); projects reviewed at different heads fail the run
- Policy: each project loads its own `.altimate/review` file, else the
  invocation directory's, else the repository root's (new
  `policyFallbackDirs`, read from the base branch); precedence documented in the
  module header
- Reconciliation: `--all-projects` envelopes record `scope.coveredProjects`
  (every discovered project) and post under a `projects=<dir>,...` marker; the
  poster treats an earlier bot review as its own when every project it names is
  covered, so per-project blocks are dismissed (completeness and head guards
  unchanged)
- AI metadata: input records and unsent files are unioned; verifier usage and
  counters are summed with the worst state and its project's reason
- Nits: discovery skips `.venv`, `venv`, `site-packages`; `AI_STATE_RANK`
  moved up; `OUTSIDE_PROJECT_RE`; `worstLane`; comments updated
- Tests for each, including a merged envelope through `postGitHubReview`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… ancestors

- every return path of `reviewAllProjects` passes `policyFallbackDirs`, so the
  repo-root `.altimate/review.yml` applies when invoked from inside the sole
  touched project (and when no project is touched)
- per project, fall back to the nearest policy above the project up to the repo
  root; the invocation directory no longer lends a sibling project its policy
- when an inherited policy was applied, diff a PR-added project policy file
  against that policy (`headPolicyChanges`), so a file that would loosen it is
  listed in `changedInPr` and one identical to it is not
- tests for invocation from the sole touched project, from a sibling project,
  and for a PR-added project policy over an inherited one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ch project's verifier

In `--all-projects` mode each project's run gets only its own changed files,
so the `prRenames` map `runReview` uses to refuse credential-like files was
built from that subset. A credential file renamed unedited in a sibling
project (e.g. `proj_b/profiles.yml` -> `proj_b/settings.txt`) kept its new,
innocuous name in `prFiles` and was readable by the other project's verifier.

- `ReviewPullRequestOptions.prRenames`: every rename in the PR (new -> old)
  when `changedFiles` is a subset; merged into the run's `prRenames` map
- `reviewAllProjects` passes it from the full collected file list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-ai-focused-batches branch from 140737c to a7fe84b Compare November 23, 2026 13:29
@RaghwendraSingh
RaghwendraSingh force-pushed the feat/review-all-projects branch from 0daab2a to 45795f6 Compare November 23, 2026 13:29

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.

3 participants