Repository navigation
feat(review): opt-in test-gap check and focused AI batches; verifier reads every changed file - #1772
RaghwendraSingh wants to merge 10 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
| const others = [...new Set([...newContent.matchAll(DOC_REF)].map((m) => m[1]))].filter((n) => !missing.includes(n)).slice(0, 5) | ||
| let resolves = false | ||
| for (const n of others) if ((resolves = await docExists(n))) break | ||
| if (!others.length && projectHasDocs) resolves = await projectHasDocs() |
There was a problem hiding this comment.
WARNING: projectHasDocs() cannot tell a project docs block from one that resolves in an installed package
docExists only greps the dbt project's own paths (grepProject pathspecs come from the dbt_project.yml model/macro/seed/snapshot/test dirs, run.ts:431-438), so a doc('name') defined by an installed package already counts as "missing". This new fallback then treats any docs block anywhere in the project as proof that the name resolves, so for a file whose only doc() is the new one (typically a newly added schema yml) a package-provided doc is reported as "dbt fails to parse" — exactly the package case the guard above was added to avoid. The finding body also says "the other doc() references in this file resolve there", which is false on this branch (there are none). Consider also searching installed-package .md files before concluding the name is missing, or keep the previous "another doc() in this file resolves" requirement for names that could come from a package.
There was a problem hiding this comment.
Fixed in 31cb5c4: doc() names defined in the .md files of installed packages (dbt_packages/) now count as defined. The no-other-doc() fallback also requires the packages' blocks to be known (no packages declared, or packages installed), so a package-provided doc() stays silent when packages aren't installed. The body now says why the finding is trusted ("the other doc() references resolve" or "the project defines its own docs blocks") and no longer claims the first on the fallback path.
| // The project defines docs blocks of its own (any `{% docs x %}` in its .md files). | ||
| let docsAny: Promise<boolean> | undefined | ||
| const projectHasDocs = () => | ||
| (docsAny ??= (input.grepProject?.("docs", "*.md") ?? Promise.resolve([])) |
There was a problem hiding this comment.
SUGGESTION: the generic docs pattern can exhaust the search cap before reaching a docs block
grepFixedAt stops after 50 total hits (git.ts:194-210; -m 50 per file), and docs shows up in ordinary markdown prose, so those hits can be used up before the file holding {% docs ... %} is scanned. projectHasDocs then returns false and the new doc-block-missing finding stays silent — the recall gap this change targets. A block-specific fixed string (e.g. separate searches for {% docs and {%- docs) would keep unrelated prose from diluting the result.
There was a problem hiding this comment.
Follow-up: low priority, tracked. Hitting the cap makes the rule go silent (a missed finding, not a wrong one); grepping for {% docs / {%- docs fixes it.
| const TEST_GAP_FILES_MAX = 40 | ||
|
|
||
| /** The PR's other changed paths, appended to a batch message for the test-gap instruction. */ | ||
| export function testGapFileList(message: string, batch: AiReviewFile[], prFiles: string[] = []): string { |
There was a problem hiding this comment.
SUGGESTION: three copies of the same "other PR paths" renderer
This function, the focused-batch ## OTHER FILES CHANGED IN THIS PR list in buildBatchMessage (lines 777-782), and buildVerifyMessage's "Files this PR changes" list (ai-verify.ts:386-402) each implement slice(0, 40) + "… and N more" with their own 40 constant (TEST_GAP_FILES_MAX, FOCUS_OTHER_FILES, PR_FILES_MAX). With ALTIMATE_REVIEW_AI_FOCUSED=1 and ALTIMATE_REVIEW_AI_TEST_GAP=1, the same batch message carries both lists and repeats every other path in the prompt. A single shared helper (and cap) would remove the duplication and the double listing.
There was a problem hiding this comment.
Fair; we'll fold them into one renderer in a cleanup pass.
| * be dropped, or null to keep it. Centralizing this here (vs prompt text) is | ||
| * what keeps the false-positive rate down deterministically. | ||
| */ | ||
| /** Findings that break `dbt parse` for the whole project, so a dev/sandbox/scratch folder doesn't excuse them. */ |
There was a problem hiding this comment.
SUGGESTION: the exclusionReason JSDoc now documents this constant
The /** Apply the rubric's exclusion predicates ... */ block above now attaches to PROJECT_BREAKING_RULES, so exclusionReason loses its doc and editors/TS show the wrong description for it. Move the constant above the JSDoc, or give the constant its own comment.
There was a problem hiding this comment.
Good catch on the doc placement; we'll move it in the next touch of rubric.ts. (kilo, misplaced exclusionReason JSDoc)
Code Review SummaryStatus: 8 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (20 files)Scope is
Fix these issues in Kilo Cloud Previous Review Summaries (7 snapshots, latest commit 140737c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 140737c)Status: 8 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (14 files)Incremental delta
Unchanged files re-checked for carried findings (3):
Previous review (commit b3247d1)Status: 6 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (7 files)
The incremental delta ( Fix these issues in Kilo Cloud Previous review (commit 845f31a)Status: 6 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (11 files)
The incremental delta ( Fix these issues in Kilo Cloud Previous review (commit a2d91ce)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (10 files)
No review-file delta exists between the previously reviewed Previous review (commit 7b5bb4b)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (10 files)
Verified in 7b5bb4b: Fix these issues in Kilo Cloud Previous review (commit ddc4333)Status: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (17 files)
Fix these issues in Kilo Cloud Previous review (commit 31cb5c4)Status: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (17 files)
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: 221.4K · Output: 83.4K · Cached: 10.1M Review guidance: REVIEW.md from base branch |
There was a problem hiding this comment.
10 issues found across 16 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode/src/altimate/review/run.ts">
<violation number="1" location="packages/opencode/src/altimate/review/run.ts:440">
P2: `prFiles` includes deleted files, so a PR that removes a test file still shows that test under "PR's other changed paths" and the test-gap check may treat it as coverage. Filter out `status === "deleted"` before mapping to paths.</violation>
</file>
<file name="packages/opencode/test/altimate/review-ai-test-gap.test.ts">
<violation number="1" location="packages/opencode/test/altimate/review-ai-test-gap.test.ts:29">
P3: This test depends on the real native `altimate_core.review_ai_prompt` call, but it never stubs `Dispatcher.call`. If the native core is unavailable, `runAiReview` returns early and `LLM.stream` is never called, so the test fails on an undefined `off`. Stub it with `spyOn(Dispatcher, "call").mockResolvedValue({ success: true, data: { prompt: "CORE" } } as any)`, as the replay test does.</violation>
</file>
<file name="packages/opencode/src/altimate/review/ai-review.ts">
<violation number="1" location="packages/opencode/src/altimate/review/ai-review.ts:117">
P2: For PRs with more than 40 other paths, later test-file names disappear from the reviewer’s prompt, so an unselected test can be missed and trigger a false test-gap comment. Preserve test-like paths beyond the cap or let the reviewer enumerate all PR paths.</violation>
<violation number="2" location="packages/opencode/src/altimate/review/ai-review.ts:579">
P2: With `ALTIMATE_REVIEW_AI_MAX_BATCHES` between 0 and 1 (e.g. 0.5), `Array.from({ length: maxBatches })` creates no bins and the `reduce` throws, and `runAiReview` rejects instead of returning a status. Clamp the bin count to a positive integer.</violation>
</file>
<file name="packages/opencode/src/altimate/review/dbt-patterns.ts">
<violation number="1" location="packages/opencode/src/altimate/review/dbt-patterns.ts:933">
P2: A `join ... using (...)` has no ON clause, but this change does not step over it, so the join chain still breaks there and a redundant predicate on the next join is missed. Let the bare-join match also consume a `USING (...)` list.</violation>
</file>
<file name="packages/opencode/src/altimate/review/ai-verify.ts">
<violation number="1" location="packages/opencode/src/altimate/review/ai-verify.ts:395">
P2: The verifier cannot discover changed files after the first 40 paths, so a test added at path 41+ can be missed by the test-gap check; add a bounded file-list tool or otherwise expose all paths to the verifier.</violation>
<violation number="2" location="packages/opencode/src/altimate/review/ai-verify.ts:783">
P2: The verifier's read allowlist now includes every PR file, including paths the user excluded with `exclude` or rubric `excludeGlobs` and out-of-project files. `prFiles` comes from the unfiltered `collected` list in run.ts, so those contents can reach the model provider. Build `prFiles` from the reviewable set after exclusions, or filter the allowlist with the same exclusion rules.</violation>
</file>
<file name="packages/opencode/src/altimate/review/orchestrate.ts">
<violation number="1" location="packages/opencode/src/altimate/review/orchestrate.ts:2287">
P2: The generic `docs` search can exhaust `grepFixedAt`’s 50-hit limit on Markdown prose before reaching a docs block, causing `projectHasDocs()` to suppress missing-`doc()` findings. Use a targeted, complete docs-block search instead.</violation>
</file>
<file name="packages/opencode/src/altimate/review/rule-catalog.ts">
<violation number="1" location="packages/opencode/src/altimate/review/rule-catalog.ts:775">
P3: The lookbehind exempts any seam character preceded by a backslash, so a literal ending in `\\n` (escaped backslash plus `n`) also escapes detection even though rendered SQL still ends in a word character. Check backslash parity before suppressing the match.</violation>
</file>
<file name="packages/opencode/src/altimate/review/rubric.ts">
<violation number="1" location="packages/opencode/src/altimate/review/rubric.ts:79">
P3: Move `PROJECT_BREAKING_RULES` above the `exclusionReason` JSDoc or give the constant its own comment so the predicate documentation remains attached to the function.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| const specs = glob ? [`${root}${glob}`] : dirs.map((d) => path.posix.normalize(root + d)) | ||
| return grepFixedAt(gitRoot, opts.head, pattern, specs.filter((d) => !d.startsWith(".."))) | ||
| }, | ||
| prFiles: collected.map((f) => f.path), |
There was a problem hiding this comment.
P2: prFiles includes deleted files, so a PR that removes a test file still shows that test under "PR's other changed paths" and the test-gap check may treat it as coverage. Filter out status === "deleted" before mapping to 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/altimate/review/run.ts, line 440:
<comment>`prFiles` includes deleted files, so a PR that removes a test file still shows that test under "PR's other changed paths" and the test-gap check may treat it as coverage. Filter out `status === "deleted"` before mapping to paths.</comment>
<file context>
@@ -437,6 +437,7 @@ export async function reviewPullRequest(opts: ReviewPullRequestOptions): Promise
const specs = glob ? [`${root}${glob}`] : dirs.map((d) => path.posix.normalize(root + d))
return grepFixedAt(gitRoot, opts.head, pattern, specs.filter((d) => !d.startsWith("..")))
},
+ prFiles: collected.map((f) => f.path),
prTitle: opts.prTitle,
prBody: opts.prBody,
</file context>
| prFiles: collected.map((f) => f.path), | |
| prFiles: collected.filter((f) => f.status !== "deleted").map((f) => f.path), |
There was a problem hiding this comment.
Follow-up: low priority, tracked. Filtering out deleted would also stop the verifier reading a deleted file's base side, so it needs a small design call first.
| } | ||
| if (batches.length <= maxBatches) return batches | ||
| const size = (c: AiReviewFile[]) => c.reduce((n, f) => n + fileSection(f, budget.maxFileChars, budget.coverage).length, 0) | ||
| const bins = Array.from({ length: maxBatches }, () => ({ chars: 0, chunks: [] as number[] })) |
There was a problem hiding this comment.
P2: With ALTIMATE_REVIEW_AI_MAX_BATCHES between 0 and 1 (e.g. 0.5), Array.from({ length: maxBatches }) creates no bins and the reduce throws, and runAiReview rejects instead of returning a status. Clamp the bin count to a positive integer.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/review/ai-review.ts, line 579:
<comment>With `ALTIMATE_REVIEW_AI_MAX_BATCHES` between 0 and 1 (e.g. 0.5), `Array.from({ length: maxBatches })` creates no bins and the `reduce` throws, and `runAiReview` rejects instead of returning a status. Clamp the bin count to a positive integer.</comment>
<file context>
@@ -431,6 +479,126 @@ export function batchAiFiles(files: AiReviewFile[], budget: AiInputBudget): AiRe
+ }
+ if (batches.length <= maxBatches) return batches
+ const size = (c: AiReviewFile[]) => c.reduce((n, f) => n + fileSection(f, budget.maxFileChars, budget.coverage).length, 0)
+ const bins = Array.from({ length: maxBatches }, () => ({ chars: 0, chunks: [] as number[] }))
+ chunks
+ .map((c, i) => ({ i, chars: size(c) }))
</file context>
| const bins = Array.from({ length: maxBatches }, () => ({ chars: 0, chunks: [] as number[] })) | |
| const bins = Array.from({ length: Math.max(1, Math.floor(maxBatches)) }, () => ({ chars: 0, chunks: [] as number[] })) |
There was a problem hiding this comment.
Follow-up: low priority, tracked. The caller catches it and the lane reports error; Math.max(1, Math.floor(...)) fixes it.
| if (!tail) { | ||
| joins.push({ preds: [], start: m.index!, end: i, inner }) | ||
| // A join with no ON (`cross join params as p`): step over its alias so the chain continues. | ||
| const bare = /^\s+(?:as\s+)?(?!(?:natural|inner|left|right|full|cross|outer|join|lateral|on|using|where|group|order|qualify|having|union|limit|window|select|from)\b)\w+\b/i.exec(s.slice(i)) |
There was a problem hiding this comment.
P2: A join ... using (...) has no ON clause, but this change does not step over it, so the join chain still breaks there and a redundant predicate on the next join is missed. Let the bare-join match also consume a USING (...) list.
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/dbt-patterns.ts, line 933:
<comment>A `join ... using (...)` has no ON clause, but this change does not step over it, so the join chain still breaks there and a redundant predicate on the next join is missed. Let the bare-join match also consume a `USING (...)` list.</comment>
<file context>
@@ -929,7 +929,9 @@ export function redundantJoinPredicates(sql: string): string[] {
if (!tail) {
- joins.push({ preds: [], start: m.index!, end: i, inner })
+ // A join with no ON (`cross join params as p`): step over its alias so the chain continues.
+ const bare = /^\s+(?:as\s+)?(?!(?:natural|inner|left|right|full|cross|outer|join|lateral|on|using|where|group|order|qualify|having|union|limit|window|select|from)\b)\w+\b/i.exec(s.slice(i))
+ joins.push({ preds: [], start: m.index!, end: i + (bare?.[0].length ?? 0), inner })
continue
</file context>
| const bare = /^\s+(?:as\s+)?(?!(?:natural|inner|left|right|full|cross|outer|join|lateral|on|using|where|group|order|qualify|having|union|limit|window|select|from)\b)\w+\b/i.exec(s.slice(i)) | |
| const bare = /^\s+(?:as\s+)?(?!(?:natural|inner|left|right|full|cross|outer|join|lateral|on|using|where|group|order|qualify|having|union|limit|window|select|from)\b)\w+\b|^\s+using\s*\([^)]*\)/i.exec(s.slice(i)) |
There was a problem hiding this comment.
Follow-up: low priority, tracked. The result is a missed redundant predicate, never a false one.
| ...ev.addedLines.keys(), | ||
| ...graph.parents.map((p) => p.path), | ||
| ...graph.downstream.map((d) => d.path), | ||
| ...(ev.prFiles ?? []), |
There was a problem hiding this comment.
P2: The verifier's read allowlist now includes every PR file, including paths the user excluded with exclude or rubric excludeGlobs and out-of-project files. prFiles comes from the unfiltered collected list in run.ts, so those contents can reach the model provider. Build prFiles from the reviewable set after exclusions, or filter the allowlist with the same exclusion rules.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/review/ai-verify.ts, line 783:
<comment>The verifier's read allowlist now includes every PR file, including paths the user excluded with `exclude` or rubric `excludeGlobs` and out-of-project files. `prFiles` comes from the unfiltered `collected` list in run.ts, so those contents can reach the model provider. Build `prFiles` from the reviewable set after exclusions, or filter the allowlist with the same exclusion rules.</comment>
<file context>
@@ -763,6 +780,7 @@ export function verifierTools(
...ev.addedLines.keys(),
...graph.parents.map((p) => p.path),
...graph.downstream.map((d) => d.path),
+ ...(ev.prFiles ?? []),
]),
]
</file context>
There was a problem hiding this comment.
Fixed in 31cb5c4: prFiles (the verifier's read allowlist and the test-gap list) now drops paths that match the user's exclude globs, plus build output and vendored paths (isExcludedPath). Changed files outside the dbt project stay readable on purpose (a Python test elsewhere in the repo is evidence for a test-gap claim), as OrchestrateInput.prFiles documents.
| const inBatch = new Set(batch.map((f) => f.path)) | ||
| const others = prFiles.filter((p) => !inBatch.has(p)) | ||
| if (!others.length) return message | ||
| const shown = others.slice(0, TEST_GAP_FILES_MAX) |
There was a problem hiding this comment.
P2: For PRs with more than 40 other paths, later test-file names disappear from the reviewer’s prompt, so an unselected test can be missed and trigger a false test-gap comment. Preserve test-like paths beyond the cap or let the reviewer enumerate all PR 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/altimate/review/ai-review.ts, line 117:
<comment>For PRs with more than 40 other paths, later test-file names disappear from the reviewer’s prompt, so an unselected test can be missed and trigger a false test-gap comment. Preserve test-like paths beyond the cap or let the reviewer enumerate all PR paths.</comment>
<file context>
@@ -76,6 +96,34 @@ export function aiDryRunEnabled(env: Record<string, string | undefined> = proces
+ const inBatch = new Set(batch.map((f) => f.path))
+ const others = prFiles.filter((p) => !inBatch.has(p))
+ if (!others.length) return message
+ const shown = others.slice(0, TEST_GAP_FILES_MAX)
+ return [
+ message,
</file context>
There was a problem hiding this comment.
Follow-up: low priority, tracked. We'll list test-like paths first.
| const parts = [`PR: ${(prTitle ?? "(untitled)").slice(0, 200)}`] | ||
| // A test-coverage claim is checked against the PR's own test files, which may sit outside the dbt project. | ||
| if (prFiles.length && candidates.some((c) => c.finding.category === "test_coverage")) { | ||
| const shown = prFiles.slice(0, PR_FILES_MAX) |
There was a problem hiding this comment.
P2: The verifier cannot discover changed files after the first 40 paths, so a test added at path 41+ can be missed by the test-gap check; add a bounded file-list tool or otherwise expose all paths to the verifier.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/review/ai-verify.ts, line 395:
<comment>The verifier cannot discover changed files after the first 40 paths, so a test added at path 41+ can be missed by the test-gap check; add a bounded file-list tool or otherwise expose all paths to the verifier.</comment>
<file context>
@@ -378,12 +380,27 @@ export function hunkAround(diff: string | undefined, line?: number): string {
+ const parts = [`PR: ${(prTitle ?? "(untitled)").slice(0, 200)}`]
+ // A test-coverage claim is checked against the PR's own test files, which may sit outside the dbt project.
+ if (prFiles.length && candidates.some((c) => c.finding.category === "test_coverage")) {
+ const shown = prFiles.slice(0, PR_FILES_MAX)
+ parts.push(
+ "",
</file context>
There was a problem hiding this comment.
Same as r4627044412; tracked.
| const seen: any[] = [] | ||
| spyOn(Provider, "defaultModel").mockResolvedValue({ providerID: "fake", modelID: "m" } as any) | ||
| spyOn(Provider, "getModel").mockResolvedValue(FAKE_MODEL as any) | ||
| spyOn(LLM, "stream").mockImplementation(async (input: any) => { |
There was a problem hiding this comment.
P3: This test depends on the real native altimate_core.review_ai_prompt call, but it never stubs Dispatcher.call. If the native core is unavailable, runAiReview returns early and LLM.stream is never called, so the test fails on an undefined off. Stub it with spyOn(Dispatcher, "call").mockResolvedValue({ success: true, data: { prompt: "CORE" } } as any), as the replay test does.
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-ai-test-gap.test.ts, line 29:
<comment>This test depends on the real native `altimate_core.review_ai_prompt` call, but it never stubs `Dispatcher.call`. If the native core is unavailable, `runAiReview` returns early and `LLM.stream` is never called, so the test fails on an undefined `off`. Stub it with `spyOn(Dispatcher, "call").mockResolvedValue({ success: true, data: { prompt: "CORE" } } as any)`, as the replay test does.</comment>
<file context>
@@ -0,0 +1,58 @@
+ const seen: any[] = []
+ spyOn(Provider, "defaultModel").mockResolvedValue({ providerID: "fake", modelID: "m" } as any)
+ spyOn(Provider, "getModel").mockResolvedValue(FAKE_MODEL as any)
+ spyOn(LLM, "stream").mockImplementation(async (input: any) => {
+ seen.push(input)
+ return {
</file context>
There was a problem hiding this comment.
Follow-up: low priority, tracked. We'll stub it so the test doesn't depend on the native prompt.
| // Single- or double-quoted. | ||
| added: | ||
| // An escape (`\n`) at the seam is not a word. | ||
| /'[^'\n]*\s[^'\n]*(?<!\\)[A-Za-z0-9]'\s*~\s*[A-Za-z_][\w.]*|[\w)]\s*~\s*'[A-Za-z0-9][^'\n]*\s[^'\n]*'|"[^"\n]*\s[^"\n]*(?<!\\)[A-Za-z0-9]"\s*~\s*[A-Za-z_][\w.]*|[\w)]\s*~\s*"[A-Za-z0-9][^"\n]*\s[^"\n]*"/, |
There was a problem hiding this comment.
P3: The lookbehind exempts any seam character preceded by a backslash, so a literal ending in \\n (escaped backslash plus n) also escapes detection even though rendered SQL still ends in a word character. Check backslash parity before suppressing the match.
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/rule-catalog.ts, line 775:
<comment>The lookbehind exempts any seam character preceded by a backslash, so a literal ending in `\\n` (escaped backslash plus `n`) also escapes detection even though rendered SQL still ends in a word character. Check backslash parity before suppressing the match.</comment>
<file context>
@@ -769,7 +769,10 @@ const CORRECTNESS: Rule[] = [
+ // Single- or double-quoted.
+ added:
+ // An escape (`\n`) at the seam is not a word.
+ /'[^'\n]*\s[^'\n]*(?<!\\)[A-Za-z0-9]'\s*~\s*[A-Za-z_][\w.]*|[\w)]\s*~\s*'[A-Za-z0-9][^'\n]*\s[^'\n]*'|"[^"\n]*\s[^"\n]*(?<!\\)[A-Za-z0-9]"\s*~\s*[A-Za-z_][\w.]*|[\w)]\s*~\s*"[A-Za-z0-9][^"\n]*\s[^"\n]*"/,
macros: true,
},
</file context>
There was a problem hiding this comment.
Not changing now: an escaped quote inside a Jinja string literal next to ~ is very rare in dbt code, and the cost is a missed suggestion.
| * what keeps the false-positive rate down deterministically. | ||
| */ | ||
| /** Findings that break `dbt parse` for the whole project, so a dev/sandbox/scratch folder doesn't excuse them. */ | ||
| const PROJECT_BREAKING_RULES = new Set(["dbt-project-rules:yaml-parse-error", "dbt-project-rules:doc-block-missing"]) |
There was a problem hiding this comment.
P3: Move PROJECT_BREAKING_RULES above the exclusionReason JSDoc or give the constant its own comment so the predicate documentation remains attached to the function.
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/rubric.ts, line 79:
<comment>Move `PROJECT_BREAKING_RULES` above the `exclusionReason` JSDoc or give the constant its own comment so the predicate documentation remains attached to the function.</comment>
<file context>
@@ -75,12 +75,15 @@ export function blockingCategories(rubric: Rubric): Set<string> {
* what keeps the false-positive rate down deterministically.
*/
+/** Findings that break `dbt parse` for the whole project, so a dev/sandbox/scratch folder doesn't excuse them. */
+const PROJECT_BREAKING_RULES = new Set(["dbt-project-rules:yaml-parse-error", "dbt-project-rules:doc-block-missing"])
+
export function exclusionReason(finding: Finding, rubric: Rubric): string | null {
</file context>
There was a problem hiding this comment.
Good catch on the doc placement; we'll move it in the next touch of rubric.ts. (cubic, same)
b07b80d to
bf6e861
Compare
1acd5d8 to
31cb5c4
Compare
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
| const isDev = /(^|\/)(dev|sandbox|scratch)\//.test(finding.file) | ||
|
|
||
| if (ex.skipNonProdModels && isDev) return "non-prod model (dev/sandbox/scratch)" | ||
| if (ex.skipNonProdModels && isDev && !PROJECT_BREAKING_RULES.has(finding.rule ?? "")) return "non-prod model (dev/sandbox/scratch)" |
There was a problem hiding this comment.
WARNING: ref-target-missing is still dropped in dev/sandbox/scratch folders even though it breaks dbt parse
This exemption only keeps yaml-parse-error and doc-block-missing, but missingRefFindings emits dbt-project-rules:ref-target-missing, whose own body says "so dbt fails to parse the project" (project-rules.ts:828). skipNonProdModels defaults to true, so a ref('typo') added under models/dev/, sandbox/ or scratch/ is still filtered out here — the exact case the new constant is meant to stop. Add dbt-project-rules:ref-target-missing to the set (and jinja-unbalanced, which breaks compilation of every dependent model, if that is in scope for this fix).
| else batches.push([...c]) | ||
| } | ||
| if (batches.length <= maxBatches) return batches | ||
| const size = (c: AiReviewFile[]) => c.reduce((n, f) => n + fileSection(f, budget.maxFileChars, budget.coverage).length, 0) |
There was a problem hiding this comment.
WARNING: focused batching ignores the per-call batchChars budget
packFocusedBatches only uses sizes to balance chunks; it never splits a batch when the sections exceed budget.batchChars. batchAiFiles enforces that cap at line 475, and its default under ALTIMATE_REVIEW_AI_COVERAGE=1 is COVERAGE_BATCH_CHARS (120k) precisely so one call does not overrun the context window. With both flags on, whole chunks are packed into bins, so a bin can hold two 5-file chunks (~220k chars at the default ~22k/file), and a smaller ALTIMATE_REVIEW_AI_MAX_BATCHES makes it worse. Split bin contents against budget.batchChars the way batchAiFiles does, or otherwise clamp each call's section size.
| if (!files) return undefined | ||
| const prefix = projectRootRel ? projectRootRel + "/" : "" | ||
| const names = new Set<string>() | ||
| if (!files.includes(prefix + "packages.yml") && !files.includes(prefix + "dependencies.yml")) return names |
There was a problem hiding this comment.
SUGGESTION: a working-tree review treats an uncommitted packages.yml as "no packages"
listFilesAt(cwd, head) falls back to git ls-tree HEAD when head is undefined, so a newly added/uncommitted packages.yml is not in files and this returns an empty set. Callers treat an empty set as authoritative (projectHasDocs then assumes the packages' blocks are known), while dbt_packages below is read from the working tree, so a doc() supplied by an installed package is reported missing. Mirror projectResourceNames, which merges listWorkingTreeFiles when head === undefined (run.ts:655), or return undefined here instead of an empty set.
| for (let i = 0; i < batches.length; i += BATCH_CONCURRENCY) { | ||
| const slice = batches.slice(i, i + BATCH_CONCURRENCY) | ||
| results.push(...(await Promise.all(slice.map((b, j) => reviewBatch(plan.messages[i + j], b, system, model))))) | ||
| results.push(...(await Promise.all(slice.map((b, j) => reviewBatch(testGap ? testGapFileList(plan.messages[i + j], b, input.prFiles) : plan.messages[i + j], b, system, model))))) |
There was a problem hiding this comment.
SUGGESTION: appending the test-gap file list at send time breaks the planned message
buildBatchMessage ends with "Return ONLY the JSON array per the output contract.", so the appended ## OTHER FILES THIS PR CHANGES section becomes the last thing the model reads and the contract is no longer final. It also means plan.messages — documented as the messages runAiReview sends exactly (line 818) and what the dry run reports — differs from what is actually sent when ALTIMATE_REVIEW_AI_TEST_GAP=1. Build the list inside buildBatchMessage (before the contract line) so planning and sending stay identical.
| expect(seam('{% set q = "select " ~ cols ~ "from " ~ rel %}')).toBe(true) | ||
| expect(seam('{% set q = "select " ~ cols ~ " from " ~ rel %}')).toBe(false) | ||
| expect(seam('{{ elementary.debug_log("column_snapshot_query - \\n" ~ column_snapshot_query) }}')).toBe(false) | ||
| expect(seam("{{ log('query: \\n' ~ q) }}")).toBe(false) |
There was a problem hiding this comment.
SUGGESTION: this case cannot fail, so the new single-quote escape guard is untested
fires() applies the rule's unless clause (rule-catalog.ts:799), and log( matches it, so the assertion is false whether or not (?<!\\) exists in the single-quoted alternative. Use a non-log/print context (a {% set %} or the dbt.datediff(...) call used above) to exercise the new lookbehind; line 749 already covers the log() exclusion.
bf6e861 to
c99cc33
Compare
31cb5c4 to
ddc4333
Compare
hkaltai
left a comment
There was a problem hiding this comment.
Review panel: Claude, Codex and lead. Verdict: request changes for one MAJOR (security guard bypass in the verifier); the rest is in good shape. Defaults are unchanged and the new paths are opt-in. Targeted review tests (333+) and typecheck of the touched code pass.
Counts: CRITICAL 0, MAJOR 1, MINOR 2, NIT 4.
Positives: every new behaviour is behind a switch with a default-output regression snapshot; paired fire/no-fire tests for each rule fix; new rules lean toward silence when unsure.
Missing tests: verifier access to credential paths; focused batching combined with coverage/ALTIMATE_REVIEW_AI_BATCH_CHARS; deletion-only YAML break; a direct test of packageDocNames (only its injected result is exercised).
Scope: matches the description; "three recall rules" is vague, as the package-docs filesystem walk and YAML re-anchoring also change behaviour and could be named. Note: bunx tsc --noEmit showed errors in packages/tui/src/component/dialog-move-session.tsx in one reviewer's environment (outside this diff), so "clean" may not hold everywhere.
Nits
ai-review.ts:64-76and:261-266: with focused and test-gap both on, each call lists other files twice ("OTHER FILES CHANGED IN THIS PR..." and "OTHER FILES THIS PR CHANGES..."). Fix: add only PR paths the focused list doesn't already cover.ai-review.ts:93-98:num()accepts non-integers, e.g.ALTIMATE_REVIEW_AI_FOCUS_BATCH_FILES=2.5. Fix: requireNumber.isIntegerfor the three focus settings.rubric.ts:78-80:const PROJECT_BREAKING_RULES = new Set([...])sits betweenexclusionReason's doc comment and the function, so the comment now attaches to the constant. Fix: move the constant above that comment.- Naming:
ALTIMATE_REVIEW_AI_MAX_BATCHESonly applies in focused mode;ALTIMATE_REVIEW_AI_FOCUS_MAX_BATCHESwould match itsFOCUS_MIN_FILESsibling. Also thepackFocusedBatchescomment says "exactlymaxBatches" but it can return fewer.
| // Files the PR changes that the AI may list and the verifier may read; never the user's exclusions. | ||
| const prFiles = (input.prFiles ?? input.changedFiles.map((f) => f.path)).filter( | ||
| (p) => !isExcludedPath(p, input.rubric.exclusions.excludeGlobs), | ||
| ) |
There was a problem hiding this comment.
[MAJOR] Verifier allowlist bypasses the credential-file exclusion
const prFiles = (input.prFiles ?? input.changedFiles.map((f) => f.path)).filter(
(p) => !isExcludedPath(p, input.rubric.exclusions.excludeGlobs),
)The AI file list above (line ~2599) deliberately drops profiles.yml via AI_CREDENTIAL_FILE, but prFiles only drops generated paths and user globs. Because prFiles is added to the verifierTools allowlist, read_file can open it. Scenario: a monorepo PR changes dbt/models/m.sql and config/profiles.yml; with ALTIMATE_REVIEW_AI_VERIFY=1 the verifier calls read_file("config/profiles.yml") and the contents are sent to the model provider. Reproduced with the changed verifierTools in isolation (synthetic file): returns the content with prFiles, returns "outside review scope" without it. .env, *.tfvars and *.pem changed by the PR are reachable the same way.
Fix: also filter AI_CREDENTIAL_FILE (and ideally a small secret-like deny list) when building prFiles, and enforce it in resolve() in ai-verify.ts so every allowlist source is covered. Add a regression test.
There was a problem hiding this comment.
Good catch. Fixed in 7b5bb4b (the "verifier credential scope" part). One isCredentialPath in ai-verify.ts covers profiles.yml/.yaml, .env*, .netrc, .pgpass, SSH keys, *.pem/*.key/*.p12/*.pfx and *.tfvars. It is applied in three places:
- when
prFilesis built inorchestrate.ts, so the AI lane's file list and the test-gap list never name these files; - inside
verifierTools, on the merged allowlist (files, added lines, graph parents/children andprFiles), so no allowlist source can expose them; - on
grep_projecthits.
The AI lane's supporting-file filter now uses the same predicate. Tests: read_file refuses each credential path, even when it comes in through prFiles, addedLines or a graph parent, and grep drops a profiles.yml hit. A runReview-level test checks that the evidence's prFiles excludes them.
There was a problem hiding this comment.
profiles.yml, .env*, keys, *.tfvars, case variants) are now refused for read_file and grep_project hits (ai-verify.ts:815, :952; orchestrate.ts:2618) with tests. The check only sees the new path, so the old side of a renamed credential file and a symlink in working-tree mode still return credential content; details in the new review.
| if (cur && cur.length + c.length <= batchFiles) cur.push(...c) | ||
| else batches.push([...c]) | ||
| } | ||
| if (batches.length <= maxBatches) return batches |
There was a problem hiding this comment.
[MINOR] Focused packing ignores batchChars
if (batches.length <= maxBatches) return batches
...
const bin = bins.reduce((best, b) => (b.chars < best.chars ? b : best))Focused mode replaces batchAiFiles, the only code enforcing budget.batchChars (120k chars in coverage mode, meant to keep one call inside common context windows). Neither the initial packing nor the balancing step into maxBatches bins checks it. Reproduced: 30 model files of ~16k chars with coverage and focused both on gives calls of [7,7,8,8] files at ~[113k,113k,129k,129k] chars; the same input without focused stays under 120k per call. Also, 8 files of 2,500 chars with batchChars: 3000 yields batches of 5 and 3 files.
Fix: honour batchChars when packing/balancing; when it conflicts with maxBatches, either drop the overflow files and record them as unsent, or document that maxBatches wins. Add a test combining focused and coverage mode.
There was a problem hiding this comment.
Fixed in 7b5bb4b ("focused batch size"). packFocusedBatches now applies batchChars at every step:
- a group chunk over the budget is split (as
batchAiFileswould split it); - consecutive chunks are only merged while they fit;
- a balanced call that still goes over the budget is split again.
When the two limits conflict, batchChars wins over maxBatches, because it is the context-window guard. The cap is then exceeded rather than files being dropped, and the doc comment says so. Default behaviour is unchanged: outside coverage mode batchChars is unbounded. Tests cover your coverage+focused case (30 large files with a 30k budget: every call fits, more than 4 calls) and the "8 × 2,500 chars with batchChars: 3000" case.
There was a problem hiding this comment.
✅ Fixed — packFocusedBatches splits and merges by batchChars and re-splits balanced bins (ai-review.ts:598-631). Reproduced coverage + focused with 30 large files: every call within 120k. Tests at review-ai-inputs.test.ts:1118.
| // Some errors carry no line, or one past the edit (an unterminated quote fails where the scan | ||
| // ends): anchor on the added line at or before it, else the first added line. | ||
| const added = [...walkDiffRows(file.diff)].filter((r) => r.kind === "+") | ||
| const at = (err.line ? added.find((r) => r.line === err.line) ?? [...added].reverse().find((r) => r.line < err.line!) : undefined) ?? added[0] |
There was a problem hiding this comment.
[MINOR] YAML parse finding loses its line anchor on deletion-only edits
const at = (err.line ? added.find((r) => r.line === err.line) ?? [...added].reverse().find((r) => r.line < err.line!) : undefined) ?? added[0]The anchor now only considers added lines. If the breaking edit adds no lines (e.g. the diff deletes only columns:), at is undefined and startLine becomes null, whereas before the finding sat on the parser's error line (often a context line in the hunk). Reproduced: base models:\n - name: a\n columns:\n - name: id, diff deletes the columns: line; parser reports line 3; before = startLine: 3, now = null. Separately, when the error precedes every added line, added[0] may be an unrelated line further down.
Fix: when no added line is at or before err.line, fall back to err.line if it lies inside a hunk; use added[0] only when the error has no line. Add a deletion-only test.
There was a problem hiding this comment.
Fixed in 7b5bb4b ("YAML anchor"), as you suggested. The anchor order is now:
- the added line at the error line;
- else the last added line before it;
- else the error line itself, when it is a context line of a hunk (the deletion-only case);
- else no line anchor (a file-level finding).
added[0] is used only when the parser gives no line. Tests: your deletion-only columns: example (the finding stays on the parser's line), and an error before every added line and outside the hunks (it stays file-level instead of landing on an unrelated added line).
There was a problem hiding this comment.
✅ Fixed — project-rules.ts falls back to the parser's line when it is a context line, else a file-level finding. Tests at review-project-rules.test.ts:591 and :601 pass.
c99cc33 to
31b384c
Compare
ddc4333 to
7b5bb4b
Compare
|
Thanks Harish, and thanks to the panel for the reproductions. All three findings are fixed in 7b5bb4b ("fix(review): address review feedback: verifier credential scope, focused batch size, YAML anchor"), with a regression test for each, plus the nits below. On the missing tests: added tests for verifier access to credential paths, focused batching with coverage and Nits, all in the same commit:
|
| return [ | ||
| message, | ||
| "", | ||
| "## OTHER FILES THIS PR CHANGES (paths only, not shown; use them to judge test coverage)", |
There was a problem hiding this comment.
SUGGESTION: the test-gap list lands after the output contract and outside plan.messages
buildBatchMessage already ends with "Return ONLY the JSON array per the output contract.", and this helper appends ## OTHER FILES THIS PR CHANGES after it, so the last thing the model reads is a file list rather than the contract. It also means the string sent at runAiReview differs from plan.messages, which planAiInput documents as the exact user messages and the dry run reports. Build this section inside buildBatchMessage (before the contract line) so planning and sending stay identical.
31b384c to
bda6ef0
Compare
7b5bb4b to
a2d91ce
Compare
hkaltai
left a comment
There was a problem hiding this comment.
Re-review at a2d91cefe246e6108537428de7841256f9800c6b. Verdict: request changes. Panel: Claude, Codex and lead. Counts: CRITICAL 0, MAJOR 1, MINOR 2, NIT 3.
The author force-pushed since our last review, so the full diff was reviewed. bun test test/altimate/review (872 pass) and typecheck are clean.
| Prior finding | Status |
|---|---|
| MAJOR verifier credential exclusion | Partially fixed: listed names now refused for read_file and grep (tested), but the old side of a renamed credential file and working-tree symlinks still return content (inline) |
MINOR focused batching ignores batchChars |
Fixed (reproduced; tests added) |
| MINOR YAML parse anchor on deletion-only edits | Fixed (tests added) |
| Nit: duplicate other-files lists | Fixed |
Nit: num() non-integers |
Fixed |
Nit: FOCUS_MAX_BATCHES rename and "exactly" comment |
Fixed |
Nit: PROJECT_BREAKING_RULES between doc comment and function |
Mostly fixed; see nit 1 |
Checked and safe: case variants (Profiles.yml, .ENV.local), .. in paths and globs, compiled_sql/equivalence only read compiled output dirs, git-ref symlinks return link text only.
Nits
rubric.ts:80-81: a blank line now separates theexclusionReasondoc comment from the function. Fix: remove it.ai-verify.ts:25-28: the comment says credential files are "never sent to a model", which overstates the protection until the rename/symlink/name-list gaps are closed. Fix: reword or close the gaps.- Missing test: a direct test of
packageDocNames(thedbt_packages/walk, declared-but-not-installed returning undefined); only its injected result is exercised.
| ...(ev.prFiles ?? []), | ||
| ]), | ||
| ] | ||
| ].filter((p) => !isCredentialPath(p)) |
There was a problem hiding this comment.
[MAJOR] Credential check only covers the new path; renames and symlinks still reach the model
].filter((p) => !isCredentialPath(p))The filter is applied to the name the PR shows, not to what is read for it. makeContentResolver maps a renamed file's new path to its old path for side: "old" (git.ts:131-134), and in working-tree mode safeReadInside follows an in-repo symlink (git.ts:105-121).
Reproduced with the real resolver on a temp repo:
git mv profiles.yml profiles.yml.example(the usual fix after committing credentials), thenread_file("profiles.yml.example", side:"old")returnspassword: SECRET123.compiled_sql/equivalenceold side use the same path (ctx.file.oldPath).- A changed
docs/link.md -> ../profiles.yml, read with no head ref (working-tree mode), returns the file content. Git-ref mode only returns the link text.
With ALTIMATE_REVIEW_AI_VERIFY=1 the verifier is model-driven, so a prompt in the PR body or diff can request these reads. The invariant "credential files are never readable" does not hold.
Fix: check the resolved identity, not only the requested name. In the readFile/compiledSql wrappers in orchestrate.ts, refuse when isCredentialPath(oldPath) on the old side (pass the rename map in), and in safeReadInside callers refuse when the realpath target (relative to the root) is a credential path or the entry is a symlink. Add rename and symlink regression tests.
There was a problem hiding this comment.
Good catch. The verifier wrappers now check the path actually read: on the old side readFile/compiledSql look up the renamed file's old path and refuse a credential one (orchestrate.ts:2635-2662, engine old SQL included), and safeReadInside refuses a symlink whose resolved target is a credential file (git.ts:121). Both of your repros are now regression tests on temp repos: "the old side of a renamed credential file is refused" and "working-tree mode never follows a symlink to a credential file" in review-ai-verify.test.ts.
There was a problem hiding this comment.
orchestrate.ts:2643-2668, git.ts:121), and the regression tests pass. The same rename still leaks on the other side: after git mv profiles.yml profiles.yml.example with no edit, read_file("profiles.yml.example") (new side) returns the password, because the new name passes the check and readPath only maps the old side. See the new inline comment.
|
|
||
| // Connection profiles, env files, key material and Terraform variables hold credentials: never sent to a model. | ||
| const CREDENTIAL_FILE = | ||
| /(^|\/)(profiles\.ya?ml|\.env(\.[^/]*)?|\.netrc|\.pgpass|id_(rsa|dsa|ecdsa|ed25519)|[^/]+\.(pem|key|p12|pfx|tfvars))$/i |
There was a problem hiding this comment.
[MINOR] Credential name list misses common files
/(^|\/)(profiles\.ya?ml|\.env(\.[^/]*)?|\.netrc|\.pgpass|id_(rsa|dsa|ecdsa|ed25519)|[^/]+\.(pem|key|p12|pfx|tfvars))$/iVerified isCredentialPath returns false for .envrc, .env-prod, prod.env, terraform.tfvars.json, keyfile.json (BigQuery service-account key), .npmrc, .pypirc, .git-credentials, key.p8. Since grep_project accepts a glob and prFiles now includes files outside the dbt project, these are readable/greppable with the verifier on.
Fix: extend the pattern (\.env[^/]*, \.tfvars(\.json)?, keyfile*.json, *service*account*.json, credentials*.json, .npmrc, .pypirc, .git-credentials, *.p8) and add table-driven tests; optionally screen read content for BEGIN ... PRIVATE KEY and "type": "service_account".
There was a problem hiding this comment.
Done. The pattern now lives in credentials.ts:3 and covers .envrc, .env-*, *.env, .npmrc, .pypirc, .git-credentials, keyfile*.json, *service*account*.json, credentials*.json, *.p8 and *.tfvars.json, with table-driven positive and negative cases in review-ai-verify.test.ts:1143. I also added the content check you suggested: holdsCredentials (credentials.ts:29) refuses reads that contain a private key or service-account JSON.
There was a problem hiding this comment.
✅ Fixed — every name in the report is covered by credentials.ts:3-21, with table-driven positive and negative tests (review-ai-verify.test.ts:1146), and the content check refuses private keys and service-account JSON on read_file. Remaining gaps (other credential stores, and the content check not applying to grep) are in the new review.
| if (!hits) return NA("the search failed (git error, timeout, or a glob outside the project); this is not evidence of absence") | ||
| const found = await ev.grepProject(String(pattern), glob as string | undefined) | ||
| if (!found) return NA("the search failed (git error, timeout, or a glob outside the project); this is not evidence of absence") | ||
| const hits = found.filter((h) => !isCredentialPath(h.path)) |
There was a problem hiding this comment.
[MINOR] Git-quoted filenames slip past the grep credential filter
const hits = found.filter((h) => !isCredentialPath(h.path))grepFixedAt (git.ts:213) parses newline-delimited git grep output. For non-ASCII or special names git emits a quoted path ("models/caf\303\251/profiles.yml"); the trailing quote defeats the $-anchored regex, so the hit text is returned. Fix: use git grep -z and parse NUL-delimited names (or pass -c core.quotepath=false and unquote), then filter canonical paths. Add a non-ASCII path test.
There was a problem hiding this comment.
Switched grepFixedAt to git grep -z (git.ts:230), so paths come back unquoted and the credential filter sees the real name. The test "grepFixedAt returns canonical non-ASCII paths" covers a models/café/profiles.yml hit at a ref and in the working tree.
There was a problem hiding this comment.
✅ Fixed — git grep -z at git.ts:230 with NUL-delimited parsing. Reproduced with real grepFixedAt at a ref and in the working tree: models/café/profiles.yml comes back unquoted and is filtered; a newline in a directory name splits the row but the tail still carries the credential basename, so nothing slips through. Regression test at review-ai-verify.test.ts:1300 passes.
bda6ef0 to
a850567
Compare
a2d91ce to
845f31a
Compare
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
|
Review-body nits: All three are in: I removed the blank line before |
| return CREDENTIAL_FILE.test(path) | ||
| } | ||
|
|
||
| const CREDENTIAL_CONTENT = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----|"type"\s*:\s*"service_account"/ |
There was a problem hiding this comment.
SUGGESTION: the content guard misses armored/PGP private keys
CREDENTIAL_CONTENT only matches -----BEGIN … PRIVATE KEY-----, so a PGP private key (-----BEGIN PGP PRIVATE KEY BLOCK-----) is not detected at all: the required PRIVATE KEY----- suffix is separated by BLOCK. A file named innocuously (e.g. macros/notes.md) that holds one still reaches read_file, compiled_sql and the AI lane, which is exactly the case this guard exists to stop. Allow an optional word before PRIVATE KEY and an optional BLOCK:
| const CREDENTIAL_CONTENT = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----|"type"\s*:\s*"service_account"/ | |
| const CREDENTIAL_CONTENT = /-----BEGIN (?:[A-Z0-9 ]* )?PRIVATE KEY(?: BLOCK)?-----|"type"\s*:\s*"service_account"/ |
There was a problem hiding this comment.
Applied in 140737c: CREDENTIAL_CONTENT is now -----BEGIN (?:[A-Z0-9 ]* )?PRIVATE KEY(?: BLOCK)?-----|.... It is covered in "content holding a private key or a service-account key is credentials, whatever the name" and in the grep test.
| }, | ||
| compiledSql: async (p, side) => { | ||
| const ctx = ctxByPath.get(p) | ||
| const from = side === "old" ? (ctx?.file.oldPath ?? readPath(p, side)) : p |
There was a problem hiding this comment.
SUGGESTION: the old path is resolved twice
readPath(p, "old") already returns oldPathOf.get(p), and oldPathOf is built from the same input.changedFiles whose entries ctxByPath holds, so ctx?.file.oldPath can never differ from what readPath returns. The extra lookup re-derives the same mapping and is easy to keep out of sync (e.g. if the map is ever filtered). readPath(p, side) covers both sides, including "new":
| const from = side === "old" ? (ctx?.file.oldPath ?? readPath(p, side)) : p | |
| const from = readPath(p, side) |
There was a problem hiding this comment.
Fixed in 140737c. compiledSql no longer looks up ctx?.file.oldPath. It calls refused(p, side) and reads getCompiled(pathActuallyRead(p, side), side), so the mapping is resolved in one place.
d8cfb39 to
b3247d1
Compare
hkaltai
left a comment
There was a problem hiding this comment.
Re-review at b3247d1 (previous review at a2d91ce). Panel: Claude, Codex and lead; the review tests (908) and tsgo --noEmit pass.
Prior findings
| Prior finding | Status |
|---|---|
| MAJOR credential check covers only the new path (rename / symlink) | Partially fixed: old side and symlink target refused and tested; the new side of the same rename and the AI-lane diff still leak (new MAJOR below) |
| MINOR credential name list | Fixed for every listed name; further stores remain (new MINOR) |
| MINOR git-quoted names bypass grep filter | Fixed (-z, regression test passes) |
| NIT rubric.ts blank line | Fixed |
| NIT "never sent to a model" comment | Reworded, but see below |
NIT missing packageDocNames test |
Fixed (review-run-stale.test.ts) |
Findings: 0 critical, 1 major, 2 minor (inline).
Also tried and not exploitable: old side of a deleted file, case variants, ./ and ../ paths, directory symlinks and symlink chains, git grep context lines (none requested). A working-tree hardlink to a credential file is readable, but git cannot record hardlinks, so a PR cannot plant one; no finding.
Nits
ai-verify.ts:26-27/credentials.ts:24: "refused by ... / never read or show it" still implies coverage that grep hits, diffs and the renamed file's new side do not have. Narrow the wording until they share the policy.orchestrate.ts:2642:oldPathOfand therenamesmap inrun.ts:352only cover in-scope files, whileprFilescomes from all collected files; for an out-of-scope renameread_file(side:"old")readsbase:<newPath>and answers "does not exist". It fails closed, but the answer is wrong. Pass the full rename map through.orchestrate.ts:2643:readPathdiffers from the requested path only on the old side;pathActuallyReadwould make that gap obvious.
| // The verifier refuses a credential file by the path actually read: a renamed file's | ||
| // old side is read from its old path. Symlink targets are refused by safeReadInside. | ||
| const oldPathOf = new Map(input.changedFiles.flatMap((f) => (f.oldPath ? [[f.path, f.oldPath] as const] : []))) | ||
| const readPath = (p: string, side: "old" | "new") => (side === "old" ? (oldPathOf.get(p) ?? p) : p) |
There was a problem hiding this comment.
[MAJOR] A file renamed from a credential path is still sent to the model: new side and AI-lane diff
const readPath = (p: string, side: "old" | "new") => (side === "old" ? (oldPathOf.get(p) ?? p) : p)The rename check is applied to the old side only. The AI lane drops a file whose oldPath is a credential (orchestrate.ts:2616), but the verifier and the model-file list do not:
prFilesandallowedfilter on the new name only, soprofiles.yml.examplestays listed and readable. Reproduced with the realmakeContentResolver+runReview(aiVerify: true): base hasprofiles.ymlwithpassword: SECRET123; head isgit mv profiles.yml profiles.yml.examplewith no edit.read_file("profiles.yml.example")(new side, and in both git-ref and working-tree mode) returns2: password: SECRET123. This is the usual "rename it to .example" reaction to a committed profile and the same scenario as the earlier report; only the old side was closed.aiFilesfromctxByPath(line 2601) has nooldPathcheck. A credential file renamed into a model (.env->models/x.sql, with edits) sends its old content indiffto the default AI lane; reproduced,diffcontains the secret lines. The existing regression test passes an emptydiffand a redacted new file, so it cannot see either case.
Fix: compute one set of "credential-like" changed files, isCredentialPath(path) || isCredentialPath(oldPath), over all collected changed files (not just the in-scope ones), and apply it to the prFiles/allowed filter, both sides of readFile, compiledSql, and the aiFiles built from ctxByPath. Add tests for an unedited credential rename read on the new side and for a model renamed from a credential file asserting the outgoing diff.
There was a problem hiding this comment.
Fixed in 140737c. runReview now builds one set of credential-like changed files, isCredentialPath(path) || isCredentialPath(oldPath), over every file the PR changes (orchestrate.ts:2621). The old path comes from a new prRenames map that run.ts:353 fills from all collected renames, so renames outside the dbt project and renames scoped into it as "added" are covered too. The set filters prFiles, addedLines, the model and supporting aiFiles, and both sides of readFile/compiledSql (refused, orchestrate.ts:2678). Tests in review-ai-verify.test.ts: "an unedited rename of a credential file is refused on the new side (git ref and working tree)", "a model renamed from a credential file, moved into the project, sends no diff to the AI lane" (asserts the outgoing files don't contain the secret), and the existing rename test now expects profiles.yml.example to be refused on the new side as well.
There was a problem hiding this comment.
✅ Fixed — re-ran with the real makeContentResolver + runReview on temporary repos at 140737c. Unedited git mv profiles.yml profiles.yml.example: evidence.readFile refuses both sides, compiledSql is undefined, prFiles is [], in git-ref and working-tree mode. .env -> models/x.sql with edits (as renamed and as added with prRenames), and yml / macro / seed renamed from profiles.yml / Secrets.JSON / .NETRC: aiFiles is empty and no secret appears anywhere in the AI input. Tests at review-ai-verify.test.ts:1336, :1364, :1387 pass. One mirror-image gap (model renamed OUT of the project to a credential name) is filed as a new MINOR at orchestrate.ts:2621.
| if (!hits) return NA("the search failed (git error, timeout, or a glob outside the project); this is not evidence of absence") | ||
| const found = await ev.grepProject(String(pattern), glob as string | undefined) | ||
| if (!found) return NA("the search failed (git error, timeout, or a glob outside the project); this is not evidence of absence") | ||
| const hits = found.filter((h) => !isCredentialPath(h.path)) |
There was a problem hiding this comment.
[MINOR] The content guard is not applied to grep_project (or to diffs), and misses armored PGP keys
const hits = found.filter((h) => !isCredentialPath(h.path))read_file refuses any file that holdsCredentials, but grep hits are only filtered by name. Reproduced with the real grepFixedAt: a tracked models/k.md holding a -----BEGIN RSA PRIVATE KEY----- block is refused by read_file, while grep_project({pattern: "MIIE"}) returns models/k.md:2: MIIEp.... Key body lines carry no header, so a few patterns (up to 50 hits of 300 characters) reconstruct the key. The same applies to the diff of a file whose sql was dropped by holdsCredentials (orchestrate.ts:2619-2628): the diff is still sent. Separately CREDENTIAL_CONTENT requires PRIVATE KEY-----, so -----BEGIN PGP PRIVATE KEY BLOCK----- is not matched (credentials.ts:29).
Fix: make grep_project skip any path whose whole content fails holdsCredentials (or drop hits next to a key header), screen diff with holdsCredentials when building aiFiles, and match PRIVATE KEY( BLOCK)?-----.
There was a problem hiding this comment.
Fixed in 140737c. I went with the whole-file check: the evidence grepProject drops every hit from a file that is credential-like or whose full head content holdsCredentials (orchestrate.ts:2681). It fails closed when the content can't be read. An AI file whose diff holds a key is no longer sent. One whose full text holds a key is still sent, but only as its diff (screened, orchestrate.ts:2631). CREDENTIAL_CONTENT now matches -----BEGIN (?:[A-Z0-9 ]* )?PRIVATE KEY(?: BLOCK)?----- (credentials.ts:39). Test: "key material is screened by content: grep hits, diffs and PGP armor". It uses the real grepFixedAt and checks that a key file's body lines don't appear in hits, that a macro whose diff adds a key header isn't sent, and that the PGP header is matched.
There was a problem hiding this comment.
grep_project is now screened by whole-file content: a tracked RSA models/k.md and a PGP-armored file return no hits for MIIE, hits on files whose content cannot be read are dropped, and PRIVATE KEY BLOCK is matched (credentials.ts:39). Diffs are only screened for the header: an edit more than 3 lines into a key body sends the diff with key body lines (sql dropped, diff kept). Filed as a new MINOR at orchestrate.ts:2634.
| // Connection profiles, env files, package-registry and git credential stores, cloud | ||
| // service-account keys, key material and Terraform variables. Matched on the file name. | ||
| const CREDENTIAL_FILE = new RegExp( | ||
| "(^|/)(" + |
There was a problem hiding this comment.
[MINOR] Name list still misses common credential stores
"profiles\\.ya?ml",isCredentialPath is false for .aws/credentials, .docker/config.json, kubeconfig, secrets.yml/secrets.json, client_secret*.json, and dbt profile variants such as ci/dbt_profiles.yml, profiles-ci.yml and profiles.yml.example. grep_project takes a glob and reaches any tracked project file, and the AWS INI format also passes holdsCredentials, so a changed .aws/credentials is readable and greppable with the verifier on.
Fix: add \.aws/credentials, \.docker/config\.json, kubeconfig, secrets?\.(ya?ml|json), client_secret[^/]*\.json, and [^/]*profiles[^/]*\.ya?ml(\.[^/]*)?, with positive and negative table cases.
There was a problem hiding this comment.
Added \.aws/credentials, \.docker/config\.json, kubeconfig, secrets?\.(ya?ml|json) and client_secret[^/]*\.json in 140737c (credentials.ts:8-26). For profiles I narrowed your pattern to (dbt[_-]?)?profiles([._-][^/]*)?\.ya?ml(\.[^/]*)?. It covers ci/dbt_profiles.yml, profiles-ci.yml, profiles.yml.example and profiles.prod.yaml. It does not cover [^/]*profiles[^/]*, because that would also match a model's schema file such as models/marts/customer_profiles.yml and drop it from the AI lane. The positive and negative tables in the "credential files" describe block include those cases, plus models/schema.yml, dbt_project.yml and models/secrets_summary.sql as negatives.
There was a problem hiding this comment.
✅ Fixed — every name from the report is matched (.aws/credentials, .docker/config.json, kubeconfig, secrets.yml|json, client_secret*.json, dbt_profiles.yml, profiles-ci.yml, profiles.yml.example) in the positive table. The new profiles pattern also matches ordinary schema files such as models/profiles_users.yml, and a few other stores are still missed; filed as a new MINOR at credentials.ts:8.
a850567 to
c7648ee
Compare
b3247d1 to
140737c
Compare
|
Re the review-body nits:
|
| return CREDENTIAL_FILE.test(path) | ||
| } | ||
|
|
||
| const CREDENTIAL_CONTENT = /-----BEGIN (?:[A-Z0-9 ]* )?PRIVATE KEY(?: BLOCK)?-----|"type"\s*:\s*"service_account"/ |
There was a problem hiding this comment.
SUGGESTION: the content guard misses age/SOPS secret keys
CREDENTIAL_CONTENT covers PEM, OpenSSH and PGP armor, but not AGE-SECRET-KEY-1… — the key format SOPS-encrypted dbt vars/profiles use. A file with an innocuous name holding one still reaches read_file, compiled_sql and the AI lane, which is the case this guard exists for. One alternative is enough:
| const CREDENTIAL_CONTENT = /-----BEGIN (?:[A-Z0-9 ]* )?PRIVATE KEY(?: BLOCK)?-----|"type"\s*:\s*"service_account"/ | |
| const CREDENTIAL_CONTENT = /-----BEGIN (?:[A-Z0-9 ]* )?PRIVATE KEY(?: BLOCK)?-----|AGE-SECRET-KEY-1[0-9A-Z]{10,}|"type"\s*:\s*"service_account"/ |
| // A renamed file's old side is read from its old path, as the content resolver does: the | ||
| // in-scope rename as scoped, otherwise the PR's rename. Symlink targets are refused by safeReadInside. | ||
| const inScopePaths = new Set(input.changedFiles.map((f) => f.path)) | ||
| const oldPathOf = new Map([...prRenames].filter(([p]) => !inScopePaths.has(p))) |
There was a problem hiding this comment.
SUGGESTION: the verifier's old-path map is rebuilt instead of reusing the resolver's
run.ts:356-358 builds the same composite map (prRenames minus in-scope paths, then the in-scope changedFiles renames) for makeContentResolver. refused() is only sound while this copy matches that one exactly: if either side gains a case or filters differently, the credential check inspects a different path than getContent actually reads, which reopens the bypass this PR closes. Pass the resolver's renames map through OrchestrateInput and use it for pathActuallyRead, keeping prRenames only for credentialLike.
| if (!found) return undefined | ||
| const paths = [...new Set(found.map((h) => h.path))] | ||
| const texts = await Promise.all( | ||
| paths.map((p) => (mayHoldCredentials(p) ? undefined : getContent?.(p, "new").catch(() => undefined))), |
There was a problem hiding this comment.
SUGGESTION: an unreadable hit file becomes "no matches", which the verifier reads as evidence of absence
texts[i] !== undefined drops a path that may hold credentials (intended) but also one whose head content could not be read — including when getContent was not injected (OrchestrateInput.getContent is optional while grepProject is independently injectable) or the read failed transiently. When every hit path is dropped this way the wrapper returns [], and ai-verify.ts:949-951 renders it as no matches; git.ts:215 deliberately keeps a failed search from meaning that. Return undefined when a hit that is not credential-like could not be read (or fall back to name-only filtering when getContent is absent).
| git(root, "commit", "-qm", "head") | ||
| git(root, "mv", ".env", "conn.txt") // working tree: the same file renamed again, uncommitted | ||
| const changed: Changed = [{ path: "conn.txt", oldPath: ".env", status: "renamed", diff: "" }] | ||
| for (const head of ["HEAD", undefined]) { |
There was a problem hiding this comment.
SUGGESTION: this loop cannot fail in either mode
In both iterations the requested path is credential-like (.env by name, conn.txt via oldPath), so orchestrate.ts filters it out of prFiles/addedLines, and verifierTools' allowed list drops it; read_file returns not available: outside review scope before evidence.readFile runs, so expect(got).not.toContain(FAKE_PW) holds regardless of the guard. The read guard is only covered by the working-tree ev.readFile("conn.txt", "new") assertion at line 1360. Assert through ev.readFile for each mode (including the git-ref case) instead of tools.read_file, which can never reach the guard for a credential-renamed file.
hkaltai
left a comment
There was a problem hiding this comment.
Re-review at 140737c (previous review at b3247d1). Panel: Claude, Codex and lead. bun test test/altimate/review (950 tests) and tsgo --noEmit pass.
The MAJOR from the last round is fixed on the routes it named, and I re-ran it with the real makeContentResolver / runReview / grepFixedAt on temporary git repos: an unedited profiles.yml -> profiles.yml.example is refused on both sides in git-ref and working-tree mode (and absent from prFiles and grep); .env -> models/x.sql with edits, and yml / macro / seed renamed from credential names, send nothing to the AI lane. No MAJOR or CRITICAL remains, so approving. The four MINORs below are residual gaps in the "never reaches the model" claim; I would fix the first two before merge.
Prior findings
| Prior finding | Status |
|---|---|
| MAJOR renamed credential still reaches the model (new side, AI-lane diff) | Fixed. Regression tests at review-ai-verify.test.ts:1336, :1364, :1387 pass and use the real content resolver. Related new gap: model renamed out of the project (MINOR below) |
| MINOR content guard misses grep and diffs; PGP | Partially fixed: grep is screened by whole-file content (RSA, PGP, unreadable content dropped), PGP matched; a diff hunk without the header still carries key body lines (MINOR below) |
| MINOR credential name list | Fixed for every listed name; more names missing, plus a false-positive (MINOR below) |
NIT wording / out-of-scope rename / pathActuallyRead |
Wording only partly fixed (see Nits); the other two fixed |
Earlier routes re-tried and still not exploitable: deleted file old side, case variants (PROFILES.YML, Conf/.NETRC), ./ and ../ paths, directory symlinks, symlink chains, out-of-project rename of a credential file, grep glob aimed at a credential file, grep hit whose content cannot be read.
Findings: 0 critical, 0 major, 4 minor (inline).
Where the reviewers disagreed: Codex rated key-body diffs, graph context and a copied credential file as MAJOR, Claude as MINOR. I reproduced each one. All three are real, but each needs an unusual precondition (a key committed under a non-credential name and then edited mid-body; the opt-in graph option; a credential file copied to a plain name), so I kept them MINOR, consistent with how the earlier content-guard gap was rated.
Not filed as an inline finding: cp profiles.yml config/db.yml (copy, or a rename with under 50% similarity that git reports as delete + add) leaves a password-bearing file under an ordinary name, readable by read_file and grep_project and sent in the AI lane. No name policy can catch this; either collect with -C and treat copies like renames, or add a content check for dbt profile / INI shapes (outputs: + password:, aws_secret_access_key). Worth a follow-up and a sentence in the docs.
Missing tests: none of the in-repo tests run the real collectChangedFiles -> scopeToProject -> run.ts rename wiring; they pass hand-built changedFiles / prRenames, which is where the rename-out gap sits.
Nits
ai-verify.ts:29The AI lane never gets such a file, nor one whose diff holds a key.andcredentials.ts:31-34is not sent to the AI lane: overstate coverage until the diff and graph-context findings are fixed. Narrow the wording.orchestrate.ts:2631const screened = ...: rename toscreenForCredentials; it either drops the file or only itssql, which the name does not say.orchestrate.ts:2674-2676andrun.ts:353-358: the same composed rename map is built twice (oldPathOf,renames); share one helper so they cannot drift.
| const screened = (f: AiReviewFile): AiReviewFile[] => | ||
| mayHoldCredentials(f.path) || (f.diff && holdsCredentials(f.diff)) | ||
| ? [] | ||
| : [f.sql && holdsCredentials(f.sql) ? { ...f, sql: undefined } : f] |
There was a problem hiding this comment.
[MINOR] A file whose full text holds a key is sent as a diff, which can carry key body lines
mayHoldCredentials(f.path) || (f.diff && holdsCredentials(f.diff))
? []
: [f.sql && holdsCredentials(f.sql) ? { ...f, sql: undefined } : f]The diff is only screened for the BEGIN ... PRIVATE KEY header. A hunk has 3 lines of context, so an edit more than 3 lines into the key body never contains the header. Reproduced with real collectChangedFiles + runReview: tracked models/k.yml with a 20-line RSA block, line 10 of the body edited. sql is dropped, but the file is still sent and its diff holds key body lines 7-13. The same happens for service-account JSON when "type" and "service_account" sit on different lines. read_file refuses the same file, so the two paths disagree.
Why MINOR: it needs a private key committed under a non-credential name and then edited, and it is the content heuristic's fallback, not the name policy.
Fix: when f.sql holds credentials (or the old side does, via getContent(path, "old")), drop the whole file instead of keeping the diff. Add a test with a hunk that contains only body lines.
| const aiBudget = aiInputBudget() | ||
| touch(aiBudget.coverage ? selectAiFilesByQuota(aiFiles, aiBudget.coverage.quotas).sent : selectAiFiles(aiFiles, aiBudget.maxFiles)) | ||
| if (input.aiContextCard && anyManifest) await attachContextCards(aiFiles, input.runner) | ||
| const context = input.aiGraphContext ? await aiGraphContext(aiFiles.map((f) => f.path), input.runner, getContent) : undefined |
There was a problem hiding this comment.
[MINOR] Graph context (opt-in) bypasses the credential screen
const context = input.aiGraphContext ? await aiGraphContext(aiFiles.map((f) => f.path), input.runner, getContent) : undefinedaiGraphContext reads each dbt parent's full content and sends it with no mayHoldCredentials / holdsCredentials check; the filtering above only covers aiFiles. Reproduced with ALTIMATE_REVIEW_AI_GRAPH on: .env renamed to models/x.sql, a changed models/b.sql that refs x. x is correctly left out of aiFiles and read_file, but context[0].content is DB_PASSWORD=.... An unchanged parent seed or model holding a key does the same.
Why MINOR: opt-in, and the parent has to be a credential file turned dbt node.
Fix: pass mayHoldCredentials into aiGraphContext and skip a parent when it matches or when holdsCredentials(content) is true. Add a test.
| // Changed files that may hold credentials: named like a credential file now or before a | ||
| // rename, over every file the PR changes. Neither side of them reaches the AI lane or the verifier. | ||
| const prRenames = input.prRenames ?? new Map<string, string>() | ||
| const credentialLike = new Set( |
There was a problem hiding this comment.
[MINOR] A model renamed out of the project to a credential name still goes to the AI lane
const credentialLike = new Set(
[
...input.changedFiles.map((f) => [f.path, f.oldPath ?? prRenames.get(f.path)] as const),prRenames is keyed by the new path. scopeToProject turns dbt/models/m.sql -> ci/.env into an in-scope deleted entry at the OLD path, and that entry keeps the rename's diff, which includes the new file's added lines. Nothing maps dbt/models/m.sql to ci/.env, so it is not credential-like. Reproduced with real collectChangedFiles + scopeToProject + runReview (project root dbt, model appended with a secret line, renamed to ci/.env): aiFiles contains dbt/models/m.sql and the outgoing diff contains the secret. It is the mirror image of the earlier rename finding.
Why MINOR: the content has to look enough like a model (at least 50% similarity) to be detected as a rename, so this is contrived; a .yml does not leak because deleted supporting files are skipped.
Fix: also record the reverse (old path -> new path) from collected and treat a path as credential-like when its rename partner is credential-named. Add a test that runs the real collector and scoping, not hand-built prRenames.
| [ | ||
| // profiles.yml, dbt_profiles.yml, profiles-ci.yml, profiles.yml.example; not a model's | ||
| // schema file such as customer_profiles.yml | ||
| "(dbt[_-]?)?profiles([._-][^/]*)?\\.ya?ml(\\.[^/]*)?", |
There was a problem hiding this comment.
[MINOR] Name list: schema files hidden, other credential stores still missed
"(dbt[_-]?)?profiles([._-][^/]*)?\\.ya?ml(\\.[^/]*)?",All listed names from the earlier review are covered. Two follow-ups, checked with isCredentialPath:
- False positives:
models/profiles_users.yml,models/profiles_schema.yml,models/marts/profiles_daily.yml,models/secrets.ymlnow match, so a project with aprofilesmodel silently loses its schema yml from the AI lane, the verifier and grep (an emptyfileslist inrunReview). The negative table only hascustomer_profiles.yml, which the(^|/)anchor already excluded. - Still false:
.kube/config(the standard kubeconfig location),kubeconfig.yaml,.snowsql/config,.databrickscfg,.streamlit/secrets.toml,credentials.yml,terraform.tfstate,.htpasswd,.boto,.config/gcloud/application_default_credentials.json.
Fix: restrict the profiles_* variants to the project root / non-model dirs, or exempt files whose text parses as dbt schema yml (version: 2 with models:), and add profiles_users.yml to the negative table. Add \.kube/config, \.snowsql/config, \.databrickscfg, secrets?\.(ya?ml|json|toml), credentials\.ya?ml, [^/]+\.tfstate(\.backup)?, \.htpasswd to the positive table.
`ALTIMATE_REVIEW_AI_FOCUSED=1` reviews PRs with at least 7 selected files
in several smaller calls of related files instead of one large call.
- `groupAiFiles`: connected components over macro dispatch families
(`default__x`, `snowflake__x`, `adapter.dispatch('x'`), `ref()` edges and
yml `- name:` declarations, with a same-directory fallback for files that
have no edge; components and members keep selection order
- `packFocusedBatches`: chunks of at most 5 files, never split across calls;
above 4 calls the chunks are balanced by prompt size into exactly 4
- each focused call carries only its own files' grounding and lists the other
changed files it must not comment on; `ai.input[].batch` records the call
- findings from all calls are deduplicated by file, line and normalized title
before the verifier
- knobs: `ALTIMATE_REVIEW_AI_FOCUS_MIN_FILES`, `ALTIMATE_REVIEW_AI_FOCUS_BATCH_FILES`,
`ALTIMATE_REVIEW_AI_MAX_BATCHES`; with the switch unset batches and messages
are unchanged (coverage-only messages pinned by a new snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ules - `doc-block-missing`: a yml whose only `doc()` is the new one now fires when the project keeps docs blocks of its own (before, it needed another `doc()` in the same file to resolve) - `yaml-parse-error`: anchor on the added line at or before the parser's error line, or the first added line, when the error line is missing or past the edit (an unterminated quote) - `jinja-concat-missing-space`: match double-quoted strings too, and ignore an escape such as `\n` at the seam Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`redundant-join-predicate` reset the chain at `cross join params as p` because the alias was left in the gap before the next join. Step over the alias of a join that has no ON clause so predicates of earlier inner joins are still tracked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… folders `skipNonProdModels` dropped every finding under `dev/`, `sandbox/` or `scratch/`. A yml that no longer parses or a `doc()` with no docs block breaks `dbt parse` for the whole project wherever the file lives, so `yaml-parse-error` and `doc-block-missing` are exempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A test-coverage claim on a dbt file was discarded as unverifiable when the PR's tests lived outside the dbt project: the verifier could only read the reviewed dbt files and their graph neighbours. - `AiVerifyEvidence.prFiles`: every changed path in the PR, including tests and CI outside the dbt project; `read_file` may open them - the verifier message lists those files when a candidate is a `test_coverage` claim (other batches are unchanged) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ALTIMATE_REVIEW_AI_TEST_GAP=1` appends one instruction to the core reviewer prompt: for a changed macro, materialization or generic test whose runtime behaviour changes, say whether the PR adds a test that runs it, and report one `test_coverage` comment when none does. Each batch message also lists the PR's other changed paths (tests and CI outside the dbt project included), so the model can tell whether a test exists. Unset, the system prompt and messages are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cs blocks - `prFiles` (the AI test-gap list and the verifier's read allowlist) now drops paths matching the user's exclude globs and build output / vendored paths (new `isExcludedPath` in `diff-filter.ts`); out-of-project PR files stay readable by design. - `doc-block-missing`: `doc()` names defined in installed packages' `.md` files (`dbt_packages/`, new `packageDocNames` in `run.ts`) count as defined. The no-other-`doc()` fallback now also requires the packages' docs blocks to be known (no packages declared, or installed), so a package-provided `doc()` is not reported as a parse failure. The finding body no longer claims other `doc()` references resolve when that path did not check them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sed batch size, YAML anchor - Verifier: credential files (`profiles.yml`, `.env*`, `*.pem`/`*.key`, `*.tfvars`, SSH keys) are dropped from `prFiles` and from the verifier's readable set in `verifierTools`, whatever source lists them, and from `grep_project` hits; one `isCredentialPath` now backs the AI lane's supporting-file filter too - Focused batches honour `batchChars`: oversized chunks split, packing stops at the char budget, and a balanced call over it is split again (`batchChars` wins over the call cap) - `yamlParseFindings`: a deletion-only break anchors on the parser's error line when a hunk shows it, and stays file-level instead of on an unrelated added line - Nits: focus settings require positive integers; `ALTIMATE_REVIEW_AI_MAX_BATCHES` renamed `ALTIMATE_REVIEW_AI_FOCUS_MAX_BATCHES`; the test-gap list skips paths the focused list already names; `PROJECT_BREAKING_RULES` moved above the `exclusionReason` doc comment - Tests for each Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Verifier `readFile`/`compiledSql` check a renamed file's old path on the old side, so `git mv profiles.yml profiles.yml.example` no longer exposes the base content (engine old SQL included) - `safeReadInside` refuses a symlink whose resolved target is a credential file, closing working-tree reads like `docs/link.md -> ../profiles.yml` - Credential name list moves to `credentials.ts` and covers `.envrc`, `.env-*`, `*.env`, `.npmrc`, `.pypirc`, `.git-credentials`, `keyfile*.json`, `*service*account*.json`, `credentials*.json`, `*.p8`, `*.tfvars.json` - `holdsCredentials` screens read content for private keys and service-account JSON; the verifier and the AI lane's supporting files refuse it - `grepFixedAt` uses `git grep -z`, so non-ASCII paths come back unquoted and the credential filter matches them - Remove the blank line before `exclusionReason`; direct tests for `packageDocNames` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…me, screen grep hits and diffs by content - `runReview` computes one set of credential-like changed files (`isCredentialPath(path) || isCredentialPath(oldPath)`) over every file the PR changes, using the new `prRenames` map (all collected renames, out-of-scope and renames scoped into the project as "added" included). It filters `prFiles`, `addedLines`, the model and supporting `aiFiles`, and refuses both sides of `readFile` and `compiledSql`. - `readPath` becomes `pathActuallyRead`, resolved once; out-of-scope renames read their old side from the old path (`run.ts` resolver gets their renames). - `grep_project` drops hits from any file whose whole content `holdsCredentials`; an AI file whose `diff` holds a key is not sent, one whose full text does is sent without `sql`. - `CREDENTIAL_CONTENT` matches armored PGP private key blocks. - Name list adds `.aws/credentials`, `.docker/config.json`, `kubeconfig`, `secrets.(yml|json)`, `client_secret*.json` and dbt profile variants (`dbt_profiles.yml`, `profiles-ci.yml`, `profiles.yml.example`), keeping model schema files such as `customer_profiles.yml` negative. - Comments state exactly what is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c7648ee to
ecd2792
Compare
140737c to
a7fe84b
Compare
Changes since review: cf6d583 (review comments): the verifier's read allowlist drops excluded and build/vendored paths, and
doc()names from installed packages count as defined. 7b5bb4b (review feedback): credential files are never readable by the verifier, focused batches honourbatchChars, a deletion-only YAML break anchors on the parser's error line, and focus settings require positive integers (ALTIMATE_REVIEW_AI_FOCUS_MAX_BATCHES).Issue for this PR
Part of #1792
Type of change
What does this PR do?
Stacked on #1771. Adds two opt-in AI-lane options, lets the verifier read every changed file, and fixes the rule gaps the planted-bug suite found. Defaults are unchanged.
What changed
ALTIMATE_REVIEW_AI_TEST_GAP=1: when a changed macro, materialization or generic test changes runtime behaviour, the AI says whether the PR adds a test that runs it, as onetest_coveragecomment. Each batch also gets the PR's other changed paths.ALTIMATE_REVIEW_AI_FOCUSED=1: on PRs with 7 or more files, related files are reviewed together in batches of up to 5. Related means a macro with its dispatch variants, a test with the model it refs, and a yml with the models it declares. Grounding is filtered per batch, findings are deduplicated, and there are at most 4 batches. No paid measurement yet, so it stays opt-in.Results
Test-gap check
Planted-bug suite on repos never used for tuning: 236 of 238 caught, 1 false alarm on 237 no-defect twins.
How did you verify your code works?
bun test test/altimate/review: 748 pass.bunx tsc --noEmit: clean.test/altimate/review-ai-test-gap.test.ts, plus focused-batch cases inreview-ai-inputs.test.ts.Cost side effects
None by default; both options are opt-in.
ALTIMATE_REVIEW_AI_TEST_GAP=1measured at about 1.02x AI-lane tokens.ALTIMATE_REVIEW_AI_FOCUSED=1splits PRs with 7 or more files into at most 4 batches, so up to 4 AI calls per review instead of one (not yet measured, hence opt-in). Letting the verifier read every changed file only applies when the verifier is enabled and stays within its 12k-token cap. No warehouse queries or cloud resources.Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code