Repository navigation
feat(review): give the AI finder the repo's review instructions from the base branch - #1837
RaghwendraSingh wants to merge 18 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
|
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
There was a problem hiding this comment.
1 issue found across 17 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/git.ts">
<violation number="1" location="packages/opencode/src/altimate/review/git.ts:179">
P2: `lsTreeAtRef` drops `.cursor/rules` files whose paths contain non-ASCII characters, quotes, tabs or backslashes. Without `-z`, git C-quotes those paths, so the `.mdc` filter in `loadConventions` rejects them and they never load. Add `-z` and split on NUL, as `listFilesAt` does. (Based on your team's feedback about listing git trees with `ls-tree -r -z`.)</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| const out = await git(["ls-tree", "-r", "--full-tree", "--name-only", ref, "--", `:(top)${dir.replace(/\/+$/, "")}/`], cwd) | ||
| return out.split("\n").filter(Boolean) |
There was a problem hiding this comment.
P2: lsTreeAtRef drops .cursor/rules files whose paths contain non-ASCII characters, quotes, tabs or backslashes. Without -z, git C-quotes those paths, so the .mdc filter in loadConventions rejects them and they never load. Add -z and split on NUL, as listFilesAt does.
(Based on your team's feedback about listing git trees with ls-tree -r -z.)
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 179:
<comment>`lsTreeAtRef` drops `.cursor/rules` files whose paths contain non-ASCII characters, quotes, tabs or backslashes. Without `-z`, git C-quotes those paths, so the `.mdc` filter in `loadConventions` rejects them and they never load. Add `-z` and split on NUL, as `listFilesAt` does.
(Based on your team's feedback about listing git trees with `ls-tree -r -z`.) </comment>
<file context>
@@ -173,6 +173,16 @@ export async function gitRepoRoot(cwd: string): Promise<string | undefined> {
+/** Tracked files under the repo-relative directory `dir` at `ref`, repo-root relative (recursive); undefined when git can't list them. */
+export async function lsTreeAtRef(cwd: string, ref: string, dir: string): Promise<string[] | undefined> {
+ try {
+ const out = await git(["ls-tree", "-r", "--full-tree", "--name-only", ref, "--", `:(top)${dir.replace(/\/+$/, "")}/`], cwd)
+ return out.split("\n").filter(Boolean)
+ } catch {
</file context>
| const out = await git(["ls-tree", "-r", "--full-tree", "--name-only", ref, "--", `:(top)${dir.replace(/\/+$/, "")}/`], cwd) | |
| return out.split("\n").filter(Boolean) | |
| const out = await git(["ls-tree", "-r", "-z", "--full-tree", "--name-only", ref, "--", `:(top)${dir.replace(/\/+$/, "")}/`], cwd) | |
| return out.split("\0").filter(Boolean) |
There was a problem hiding this comment.
✅ Fixed in 56b56a644b: lsTreeAtRef is removed. The base commit is listed once with listFilesAt, which runs git ls-tree -r -z, and filtered to .cursor/rules/ under each scope, so paths come through verbatim. Test showAtRef + listFilesAt at the merge base read the base versions and the base Cursor rules loads .cursor/rules/naïve rule.mdc and fails if reverted.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Optional cleanup only; safe to merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (7 files)
Incremental review of Fix these issues in Kilo Cloud Previous Review Summaries (5 snapshots, latest commit adf9818)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit adf9818)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (22 files)
Fix these issues in Kilo Cloud Previous review (commit 23b8b52)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (22 files)
Fix these issues in Kilo Cloud Previous review (commit 3e14ea4)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (23 files)
Fix these issues in Kilo Cloud Previous review (commit c549962)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (17 files)
Fix these issues in Kilo Cloud Previous review (commit f964dbe)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (17 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 90.9K · Output: 18.2K · Cached: 1.2M Review guidance: REVIEW.md from base branch |
f964dbe to
c549962
Compare
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
Re the kilo summary comment (#1837 (comment)):
|
hkaltai
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Reviewers: lead + Sol 6.1 (Codex) + Claude. Convergence: one round. Both Codex and Claude returned CHANGES NEEDED on accuracy only. Their corrections were applied, and no blocking finding remains disputed.
Blocking (MAJOR):
- Convention grouping deletes folded findings. They are lost from the envelope and never posted on re-push, because the fingerprint dedup ignores the body. Title-only identity also merges distinct issues.
- Unbounded concurrent
git showfan-out. The loader probes paths the base listing already rules out. A spawn failure aborts the whole review, deterministic lanes included. - Convention text skips the credential screen that every other AI-lane input goes through.
Also: 9 MINOR (dedupe-by-length, total-cap eviction order, symlinked CLAUDE.md, root-only .altimate/review.md, fenced # in CONTRIBUTING, per-call budget crowd-out, quoted-glob frontmatter, verifier evidence, multi-project ai.conventions merge).
Missing tests:
- Re-review grouping with an already-posted lead.
- Distinct same-title findings.
- Credential-bearing conventions.
- Many changed directories.
- A symlinked
CLAUDE.md. - A project-level
.altimate/review.md. - Equal-length CodeRabbit entries.
- Total and per-call budget pressure.
- Fenced CONTRIBUTING comments.
- Multi-quoted frontmatter globs.
reviewPullRequestwhen the base read fails.- Multi-project merge.
Scope vs ticket: clean. The PR fits the AI-lane work in #1792 and supersedes #1774's loader. conventions is on by default with the AI lane, which follows the stack's existing defaults.
Nits
docs/docs/usage/dbt-pr-review.md:644— Docs leave the scope of .claude/CLAUDE.md ambiguous: The docs (and the PR description) list.claude/CLAUDE.mdapart from the "at the root and in each changed path's directories" group. This reads as root-only, butSCOPED_FILESlooks it up in every ancestor scope.
Suggested fix: move it into the scoped group.
Raised by: lead, Claude
packages/opencode/src/altimate/review/ai-review.ts:998— Stale comment: the default envelope now changes: The comment says recording happens only for opt-in switches, "so the default envelope is unchanged".conventionsis on by default and addsai.conventionswhenever the base has instruction files.
Suggested fix: name ai.conventions as the default-on exception.
Raised by: lead
packages/opencode/src/altimate/review/ai-switches.ts:29— Comment contradicts PR description about measurement: The comment says conventions are on by default "outside that measurement". The PR description says the measured configuration included conventions.
Suggested fix: make the two agree.
Raised by: lead, Claude
packages/opencode/test/altimate/review-conventions.test.ts:103— PR number in a test name:"the files #1774 read (...) are all covered"refers to another PR by number. Once that PR is dropped, as planned, the reference means nothing.
Suggested fix: describe the behaviour, for example "REVIEW.md, .altimate/REVIEW.md and nested AGENTS.md/CLAUDE.md are loaded".
Raised by: lead, Claude
packages/opencode/src/altimate/review/ai-switches.ts:22— Env variable breaks the ALTIMATE_REVIEW_AI_ naming*: Every other switch isALTIMATE_REVIEW_AI_<NAME>, and the docs list them under that prefix. Optional consistency suggestion:ALTIMATE_REVIEW_AI_CONVENTIONS, optionally also accepting the current name. It is cheap to change before release.
Raised by: lead, Claude
packages/opencode/src/altimate/review/conventions.ts:260— Generic helper nameplain:plainbuilds a whole-file convention, and the name does not say so. SuggestwholeFileConvention.
Raised by: lead, Claude
| for (const idx of groups.values()) { | ||
| const files = new Set(idx.map((i) => findings[i].file)) | ||
| if (files.size < 2) continue | ||
| const lead = idx.reduce((a, b) => (SEVERITY_ORDER[findings[b].severity] > SEVERITY_ORDER[findings[a].severity] ? b : a)) | ||
| // The first finding on each file other than the lead's. | ||
| const folded = new Map<string, number>() | ||
| for (const i of idx) if (findings[i].file !== findings[lead].file && !folded.has(findings[i].file)) folded.set(findings[i].file, i) | ||
| replace.set(lead, { | ||
| ...findings[lead], | ||
| body: `${findings[lead].body}\n\nThe same applies to: ${[...folded.keys()].map((p) => `\`${p}\``).join(", ")}.`, | ||
| }) | ||
| for (const i of folded.values()) drop.add(i) | ||
| } |
There was a problem hiding this comment.
MAJOR: Convention grouping deletes folded findings
for (const idx of groups.values()) {
const files = new Set(idx.map((i) => findings[i].file))
if (files.size < 2) continue
const lead = idx.reduce((a, b) => (SEVERITY_ORDER[findings[b].severity] > SEVERITY_ORDER[findings[a].severity] ? b : a))
// The first finding on each file other than the lead's.
const folded = new Map<string, number>()
for (const i of idx) if (findings[i].file !== findings[lead].file && !folded.has(findings[i].file)) folded.set(findings[i].file, i)
replace.set(lead, {
...findings[lead],
body: `${findings[lead].body}\n\nThe same applies to: ${[...folded.keys()].map((p) => `\`${p}\``).join(", ")}.`,
})
for (const i of folded.values()) drop.add(i)
}groupConventionFindings removes every folded finding from the result and keeps only the lead, whose body gains "The same applies to: …". This causes several problems:
- Re-review loss:
fingerprint(finding.ts) excludes the body, and the poster skips fingerprints already on the PR. Suppose A was posted in run 1. On a later push, file C is folded into A, but A is not re-posted, so C never appears inline. - Envelope loss: folded findings are missing from
env.findings(SARIF, audit, replay diffs). Their line, body andsuggestionare also lost, so the reader has no location on the other files. - Loose identity: the key is only the cited convention path plus the title with the file's names stripped. Two distinct issues with the same generic title (for example "Wrong aggregation") on different files are merged, and the second explanation disappears.
- Unstable lead: the lead is chosen by model severity, which is not stable across runs. A later run can pick a different lead and post a near-duplicate comment.
Suggested fix: keep folded findings in the envelope with a marker such as groupedInto: <leadId>, and collapse them only in the inline and summary renderer. Post a newly folded file on its own when the lead is already posted. Pick the lead deterministically (severity, then path). Keep file:line for each folded instance. Require a tighter identity before folding (for example, the same category as well).
Raised by: Claude, Codex, lead
There was a problem hiding this comment.
✅ Fixed in 8a194fa399, along the lines you suggested. Folded findings now stay in the envelope, in place and unchanged except for a new optional groupedInto: <lead id>. They keep their line, body and suggestion for SARIF, audit and replay. format.ts collapses them: a folded finding gets no inline comment and no summary line of its own while its lead is inline-eligible and not yet on the PR. The lead's comment carries the folded findings' markers, so the next run counts them as posted. Once the lead is on the PR, a newly folded file is posted on its own. The lead is picked deterministically: severity, then path, then line. The grouping key now includes the category, so the same generic title in two categories is not folded. Replay strips groupedInto and the lead's "The same applies to" line before grouping again. Tests: folded findings stay with their own line and point at the lead, the lead is picked by severity, then path: the same whatever order the model returned, the same generic title in different categories is not folded, first run: one comment on the lead, carrying the folded findings' markers; the summary lists the lead only, and re-review: a file newly folded into an already-posted lead is posted on its own. Changed expectations: four round 1 grouping tests asserted that folded findings were removed. They now assert the findings are kept with groupedInto. Follow-up in 3e3275ada0. The list of folded files is now its own part of the comment, added after the 600-character body clamp. Before, a long lead body could cut the list while the folded markers still counted those files as posted. mergeRepeats keeps groupedInto on a merged comment only when every member shares it, so a distinct finding merged with a folded one stays visible. When a lead is merged, the findings folded into it are pointed at the merged id, so they stay collapsed. Replay strips the folded-files line wherever it sits in the body. Tests: a lead body over the clamp still lists the folded files in its comment, mergeRepeats keeps groupedInto only when every member shares it, a lead merged with a sibling: folded findings follow it to the merged comment and replay strips the folded-files line even when text follows it.
| const baseFiles = input.listBase ? await input.listBase() : [] | ||
| const scopes = scopesOf(input.changedPaths) | ||
| const plain = (path: string, source: ConventionSource, scope: string, text: string | undefined): Convention[] => | ||
| text?.trim() ? [{ path, source, scope, text: cut(text.trim(), CONVENTION_FILE_CHARS) }] : [] | ||
|
|
||
| let altimatePath = ".altimate/review.md" | ||
| let altimate = await read(altimatePath) | ||
| if (altimate === undefined) altimate = await read((altimatePath = ".altimate/REVIEW.md")) | ||
| const scoped = await Promise.all( | ||
| scopes.flatMap((scope) => SCOPED_FILES.map(async ([name, source]) => plain(join(scope, name), source, scope, await read(join(scope, name))))), | ||
| ) |
There was a problem hiding this comment.
MAJOR: Unbounded concurrent git show fan-out; failures abort the whole review
const baseFiles = input.listBase ? await input.listBase() : []
const scopes = scopesOf(input.changedPaths)
const plain = (path: string, source: ConventionSource, scope: string, text: string | undefined): Convention[] =>
text?.trim() ? [{ path, source, scope, text: cut(text.trim(), CONVENTION_FILE_CHARS) }] : []
let altimatePath = ".altimate/review.md"
let altimate = await read(altimatePath)
if (altimate === undefined) altimate = await read((altimatePath = ".altimate/REVIEW.md"))
const scoped = await Promise.all(
scopes.flatMap((scope) => SCOPED_FILES.map(async ([name, source]) => plain(join(scope, name), source, scope, await read(join(scope, name))))),
)Promise.all(scopes.flatMap(scope => SCOPED_FILES.map(... read(...)))) starts 4 × |scopes| git show processes at once. git() is a plain execFile with no limit. A PR touching around 150 directories starts about 600 processes, which can hit EMFILE/EAGAIN (macOS defaults to ulimit -n 256). A spawn error does not match showAtRef's "does not exist" check, so it is rethrown. The loader is fail-loud and is awaited in reviewPullRequest before the orchestrator, so this AI-only input then aborts the deterministic review too. Most of these reads are wasted: baseFiles (the full ls-tree) is already loaded on line 258 and shows that the paths do not exist.
Suggested fix:
const exists = input.listBase ? new Set(baseFiles) : undefined
const readIf = (p: string) => (exists && !exists.has(p) ? Promise.resolve(undefined) : read(p))Also bound concurrency (around 8). Optionally, report loader failures through the AI lane status instead of throwing, so that the orchestrator's rule "a failed AI lane must never fail the review" holds.
Raised by: lead, Claude
There was a problem hiding this comment.
✅ Fan-out fixed in 905e091494. With the base listing, only paths it holds are read, and all reads go through a limiter of 8 at a time. A PR touching 150 directories now reads only the instruction files that exist. Tests: many changed directories: only paths in the base listing are read, at most 8 at a time and without a listing the reads are still bounded to 8 at a time. I kept fail-loud on a real git error, for the reason given in round 1: the base-policy read of the same commit fails the review the same way, so a fallback here would only cover a commit that becomes unreadable between two reads. The spawn-error case you describe came from the fan-out, which is now bounded.
| const plain = (path: string, source: ConventionSource, scope: string, text: string | undefined): Convention[] => | ||
| text?.trim() ? [{ path, source, scope, text: cut(text.trim(), CONVENTION_FILE_CHARS) }] : [] |
There was a problem hiding this comment.
MAJOR: Convention text bypasses the credential-content screen
const plain = (path: string, source: ConventionSource, scope: string, text: string | undefined): Convention[] =>
text?.trim() ? [{ path, source, scope, text: cut(text.trim(), CONVENTION_FILE_CHARS) }] : []The orchestrator screens every other model input in the AI lane with holdsCredentials or isCredentialPath: diffs, SQL, grep hits and verifier reads. Convention documents read from the base commit go into the finder message unscreened. An instruction file that embeds a key or service-account JSON would be sent to the model. Reading from the base commit stops a PR from changing the text, but does not make its contents safe to transmit.
Suggested fix: drop any document for which holdsCredentials(text) is true, before parsing or truncating it. Optionally, record the omission.
Raised by: Codex
There was a problem hiding this comment.
✅ Fixed in 905e091494. Every base read goes through holdsCredentials before it is parsed or cut. A document that holds a private key or a service-account key is skipped for every source (scoped files, CodeRabbit, Cursor, CONTRIBUTING), so it never reaches the model. The omission is not recorded in the envelope. Test: a document holding a private key or a service-account key is never loaded. The remaining text is also redacted (a138b1cb8e, narrowed in 3e14ea4f78). The shared redactSecrets mangled ordinary guidance, so a convention-specific redactor now matches only shapes that prose does not have: provider-prefixed tokens (ghp_, github_pat_, glpat-, xox?-, sk-, AIza, npm_), AWS key ids, URL userinfo with a password, and a secret-named key whose value looks like a credential (12 or more characters, no template or placeholder, mixed character classes, high entropy). Tests: prose, env_var examples, md5 and long paths are left as written, real credentials are redacted and tokens, passwords and AWS key ids are redacted before the text is loaded. The per-file cap test keeps its original fixture.
| for (const c of all) { | ||
| const key = `${c.path}|${(c.globs ?? []).join(",")}|${c.text.length}` | ||
| if (seen.has(key) || c.text.length > left) continue | ||
| seen.add(key) |
There was a problem hiding this comment.
MINOR: Dedupe key uses text length, dropping distinct entries
for (const c of all) {
const key = `${c.path}|${(c.globs ?? []).join(",")}|${c.text.length}`
if (seen.has(key) || c.text.length > left) continue
seen.add(key)The key ${path}|${globs}|${text.length} treats two .coderabbit.yaml path_instructions entries with the same glob and equal-length but different text (for example, both cut to 4,000 characters) as duplicates, and silently drops the second. No source can legitimately produce an exact duplicate.
Suggested fix: key on the full text (or a hash of it), or remove the dedupe.
Raised by: lead, Codex, Claude
There was a problem hiding this comment.
✅ Fixed in 905e091494. The key is now path, globs and the full text. Test: two .coderabbit.yaml entries with the same glob and equal-length text are both kept.
| ...cursor, | ||
| ...plain(".cursorrules", "cursorrules", "", cursorrules), | ||
| ...plain(".github/copilot-instructions.md", "copilot", "", copilot), | ||
| ...contributing, | ||
| ] | ||
| const out: Convention[] = [] | ||
| const seen = new Set<string>() | ||
| let left = CONVENTIONS_TOTAL_CHARS | ||
| for (const c of all) { | ||
| const key = `${c.path}|${(c.globs ?? []).join(",")}|${c.text.length}` | ||
| if (seen.has(key) || c.text.length > left) continue | ||
| seen.add(key) | ||
| out.push(c) | ||
| left -= c.text.length | ||
| } |
There was a problem hiding this comment.
MINOR: 40k total cap filled shallow-first evicts the most specific conventions
...cursor,
...plain(".cursorrules", "cursorrules", "", cursorrules),
...plain(".github/copilot-instructions.md", "copilot", "", copilot),
...contributing,
]
const out: Convention[] = []
const seen = new Set<string>()
let left = CONVENTIONS_TOTAL_CHARS
for (const c of all) {
const key = `${c.path}|${(c.globs ?? []).join(",")}|${c.text.length}`
if (seen.has(key) || c.text.length > left) continue
seen.add(key)
out.push(c)
left -= c.text.length
}all is ordered root first, then scoped files shallowest first, then CodeRabbit, Cursor and CONTRIBUTING. changedPaths covers the whole PR, including directories outside the dbt project. The CONVENTIONS_TOTAL_CHARS cap is applied in this order, before any per-call ranking. Unrelated directories can therefore use up the budget, and the deepest CLAUDE.md/AGENTS.md files or the project's Cursor rules are dropped without any record.
Suggested fix: select the relevant conventions per call before applying the text budget, or build scopes only from the files the AI lane sends. Record dropped conventions in the envelope.
Raised by: lead, Codex, Claude
There was a problem hiding this comment.
✅ Fixed in 905e091494 with your second option. run.ts builds the scopes from the files the review covers (the project's changed files plus the outside Python files its AI lane may take), not from every PR path, so unrelated directories no longer use up the budget. Test: a CLAUDE.md beside an unrelated changed file outside the project is not loaded (end to end through reviewPullRequest). Not done: recording dropped conventions in the envelope.
| for (const line of lines) { | ||
| const h = /^(#{1,6})\s+(.*)$/.exec(line) | ||
| if (h) { | ||
| const level = h[1].length | ||
| if (keepLevel && level > keepLevel) kept.push(line) | ||
| else if (CONTRIBUTING_HEADING.test(h[2])) { | ||
| keepLevel = level | ||
| kept.push(line) | ||
| } else keepLevel = 0 | ||
| continue | ||
| } | ||
| if (keepLevel) kept.push(line) | ||
| } |
There was a problem hiding this comment.
MINOR: sliceContributing treats # lines in code fences as headings
for (const line of lines) {
const h = /^(#{1,6})\s+(.*)$/.exec(line)
if (h) {
const level = h[1].length
if (keepLevel && level > keepLevel) kept.push(line)
else if (CONTRIBUTING_HEADING.test(h[2])) {
keepLevel = level
kept.push(line)
} else keepLevel = 0
continue
}
if (keepLevel) kept.push(line)
}The heading regex is applied inside fenced blocks. A shell comment such as # install dbt deps inside a non-matching section becomes a matching level-1 "heading", so later unrelated sections are kept. A # activate venv inside a kept dbt section resets keepLevel and cuts the rest of that section.
Suggested fix: toggle an inFence flag on lines matching /^\s*(```|~~~)/ and skip heading detection while it is set.
Raised by: lead
There was a problem hiding this comment.
✅ Fixed in 905e091494. sliceContributing tracks backtick and tilde fences and skips heading detection inside them. Test: CONTRIBUTING: a \#` line inside a code fence is not a heading`.
| let used = 0 | ||
| for (const c of ordered) { | ||
| const cost = entryChars(c) | ||
| if (used + cost <= budget) { | ||
| out.push(c) | ||
| used += cost | ||
| } else if (!out.length) { | ||
| // The truncation marker counts toward the budget too. | ||
| const room = budget - (cost - c.text.length) - TRUNCATED.length | ||
| if (room > 200) { | ||
| out.push({ ...c, text: cut(c.text, room) }) | ||
| used = budget | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
MINOR: One long convention takes the whole per-call budget
let used = 0
for (const c of ordered) {
const cost = entryChars(c)
if (used + cost <= budget) {
out.push(c)
used += cost
} else if (!out.length) {
// The truncation marker counts toward the budget too.
const room = budget - (cost - c.text.length) - TRUNCATED.length
if (room > 200) {
out.push({ ...c, text: cut(c.text, room) })
used = budget
}
}
}CONVENTIONS_CALL_BUDGET (3,000) is smaller than CONVENTION_FILE_CHARS (4,000). When the top-ranked entry alone is over budget, withinBudget cuts it to fit and sets used = budget, so no other source fits. A long nested models/CLAUDE.md or a glob Cursor rule therefore shuts out .altimate/review.md, the only file written for this reviewer, from every call that matches it.
Suggested fix: cap a single entry at a fraction of the call budget (for example half), or reserve room for the altimate source.
Raised by: lead
There was a problem hiding this comment.
✅ Fixed in 905e091494. The first convention that does not fit whole is cut to at most half the call budget while other candidates follow, and to the whole budget when it is the last one. Test: a long nested convention leaves room for .altimate/review.md in the call.
| function frontmatterValue(raw: string): string { | ||
| const v = raw.trim() | ||
| const q = /^(["'])(.*?)\1/.exec(v) | ||
| if (q) return q[2].trim() | ||
| return v.replace(/\s+#.*$/, "").trim() | ||
| } |
There was a problem hiding this comment.
MINOR: Line-mode frontmatter keeps only the first quoted glob
function frontmatterValue(raw: string): string {
const v = raw.trim()
const q = /^(["'])(.*?)\1/.exec(v)
if (q) return q[2].trim()
return v.replace(/\s+#.*$/, "").trim()
}globs: "**/*.sql", "**/*.yml" is not valid YAML. yaml throws "Unexpected scalar at node end" (verified), so the line reader runs. frontmatterValue then matches the first quoted string and returns only **/*.sql, and the second glob is lost.
Suggested fix: in parseFrontmatterLines, strip only the inline comment and pass the raw value to globList, which already handles quotes per item.
Raised by: Claude
There was a problem hiding this comment.
✅ Fixed in 905e091494. parseFrontmatterLines strips only the inline comment, outside quotes, and passes the raw value to globList. Test: frontmatter that is not YAML keeps every quoted glob.
| prFiles, | ||
| ...(evidence ? { evidence } : {}), | ||
| ...(input.aiSwitches ? { switches: input.aiSwitches } : {}), | ||
| ...(input.conventions?.length ? { conventions: input.conventions } : {}), |
There was a problem hiding this comment.
MINOR: Verifier has no base-commit convention evidence
...(input.conventions?.length ? { conventions: input.conventions } : {}),Conventions reach the finder but not the verifier. The verifier's read_file allowlist rejects an unchanged CLAUDE.md. When the PR edits that file, the tool reads its head version, so the PR's rewritten guidance can be used to refute a finding based on the base convention. Impact is limited: unverifiable convention claims are still kept as plausible_local when the evidence line is valid.
Suggested fix: give the verifier a read-only lookup over the loaded base convention text, and resolve cited convention paths to it.
Raised by: Codex
There was a problem hiding this comment.
✅ Fixed in 09c023fdd4. AiVerifyEvidence.conventions maps each loaded convention path to its base-commit text. read_file accepts those paths and returns that text, marked as base text, for either side. An unchanged CLAUDE.md is now readable, and a PR's edit of it is not what the verifier sees. Test: read_file serves a convention file's base text, even when the PR does not change it.
| const recorded: Pick<AiLaneStatus, "input" | "unsent" | "conventions"> = { | ||
| ...(budget.coverage || dryRun || plan.focused || plan.input.some((r) => r.card) ? { input: plan.input } : {}), | ||
| ...(budget.coverage && unsent.length ? { unsent } : {}), | ||
| ...(input.conventions?.length ? { conventions: conventionRecords(input.conventions) } : {}), |
There was a problem hiding this comment.
MINOR: Multi-project merge drops ai.conventions from other lanes
...(input.conventions?.length ? { conventions: conventionRecords(input.conventions) } : {}),mergeAi (multi-project.ts) spreads one selected lane (ok ?? first) and aggregates input, but not conventions. When projects have different conventions settings and the selected lane has them disabled, the merged envelope has input[].conventions references but no ai.conventions. With the same setting everywhere, the records are normally identical, because every project gets the whole PR's paths.
Suggested fix: union the convention records across lanes in mergeAi.
Raised by: Codex
There was a problem hiding this comment.
✅ Fixed in 09c023fdd4. mergeAi takes the union of ai.conventions across lanes, deduplicated. This matters more now that each project loads only the conventions above its own files. Test: mergeProjectEnvelopes unions ai.conventions across projects.
c549962 to
3e14ea4
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. |
|
Re @hkaltai's latest review on this PR, the points in the review text:
|
| const deferredIds = new Set(inlineComments(env, opts.alreadyPosted, opts.commentable).deferred.map((f) => f.id)) | ||
| const posting = postingPolicy(env) | ||
| // Findings shown through their lead's comment (`groupedInto`) get no line of their own. | ||
| const collapsed = collapsedFindings(env, opts.alreadyPosted, opts.commentable) |
There was a problem hiding this comment.
SUGGESTION: Folded findings vanish from a summary rendered without inline comments
shown drops every finding collapsedFindings reports, but that function only asks whether the lead is eligible to go inline, not whether this rendering will post it. renderSummary is also called with inline: false: the 422 fallback at post-github.ts:373 (whose comment says it rewrites with "every finding in full so none loses its body"), and the CLI/tool output at cli/cmd/review.ts:166 and dbt-pr-review.ts:80. On those surfaces the lead has no inline comment, so a folded finding is neither posted inline nor listed in the summary: its own line, body and suggestion disappear from the only output. The same happens when the lead falls past posting.inlineBudget in inlineComments (it is deferred, so it is never posted). The fallback call also passes no commentable, so a lead on a line outside the diff (the usual 422 cause) still counts as eligible.
Suggested fix: skip collapsing when opts.inline === false, and collapse only into leads this run will actually post (e.g. derive the posted set from the budget-capped fresh list).
There was a problem hiding this comment.
✅ Fixed in 126052860d. A finding is now folded only into a lead that this run actually posts inline. The plan is settled against posting.inlineBudget, and a finding whose lead is over the budget stands on its own and is deferred to the summary. renderSummary(..., { inline: false }) folds nothing, which covers the CLI, the agent tool and the 422 fallback, so the fallback's missing commentable no longer matters. Tests: a summary rendered without inline comments (CLI, agent tool, 422 fallback) lists every folded finding, a lead over the inline budget: its folded findings are deferred to the summary, not hidden.
| * outside the diff (see `commentable`) keeps its line in the envelope and is | ||
| * listed in the summary instead. | ||
| */ | ||
| /** |
There was a problem hiding this comment.
SUGGESTION: inlineComments lost its doc comment
This new block sits between inlineComments' doc comment (lines 467-473) and inlineComments itself (line 498): the function is now undocumented, and collapsedFindings has two stacked JSDoc blocks of which only the last is attached. Move the new function (with its doc) above the inlineComments doc comment, or move that doc down to its function.
There was a problem hiding this comment.
✅ Fixed in 126052860d. The doc is back above inlineComments, and collapsedFindings has a single doc block.
hkaltai
left a comment
There was a problem hiding this comment.
Peer review (Claude + Codex, independent; findings checked against the code at 3e14ea4).
Request changes. The convention loader is careful: it reads from the base commit, skips symlinks, treats a git failure as an error, and screens out key material. The problem is the new "one comment per convention" grouping. It assumes folded findings always reach the PR through an inline lead comment. In summary-only output (CLI, agent tool, the posting fallback) and for leads over the inline budget, the folded findings disappear, and the "same applies to" list can be cut off by the body clamp. Both reviewers flagged this. Two minor grouping issues are inline. Nits are in a separate comment.
| const collapsed = collapsedFindings(env, opts.alreadyPosted, opts.commentable) | ||
| const shown = env.findings.filter((f) => !collapsed.has(f.id)) |
There was a problem hiding this comment.
MAJOR · bug
const collapsed = collapsedFindings(env, opts.alreadyPosted, opts.commentable)
const shown = env.findings.filter((f) => !collapsed.has(f.id))collapsedFindings ignores opts.inline and the inline budget. Three callers render with inline: false: the local CLI (cli/cmd/review.ts), the agent tool (tools/dbt-pr-review.ts), and the GitHub fallback when inline posting fails (post-github.ts, which promises to list "every finding in full"). In all of them, folded findings lose their line, body, severity and evidence. The lead's bullet is the only trace, and bulletsFor clamps the lead body to 600 characters before the appended "The same applies to" line is safe. So with a long lead body, the other files aren't mentioned at all. The same happens when a lead is inline-eligible but over inlineBudget.
Fix: collapse nothing when opts.inline === false. Collapse only members of leads actually returned in inlineComments(...).comments. In bulletsFor, append the "same applies" line after clampBody, as inlineComments does.
Raised by: Claude, Codex
There was a problem hiding this comment.
Already fixed in 126052860d (round 4, kilo 4716765715). Nothing is folded when the summary renders without inline comments, and findings are folded only into leads within the inline budget, so every folded finding is listed on its own in those cases. That also removes the clamp problem: the folded files no longer depend on the lead's "same applies" sentence. Tests: a summary rendered without inline comments (CLI, agent tool, 422 fallback) lists every folded finding, a lead over the inline budget: …, plus summary without inline comments, lead body over the clamp: each folded finding is still listed (23b8b528f9).
There was a problem hiding this comment.
✅ Fixed (re-review at 23b8b52). Nothing is collapsed when inline === false (format.ts:140), members fold only into leads actually posted within the budget (inlinePlan, :509-514), and the others are deferred. Tests at review-conventions.test.ts:767-789 and :822-828 cover inline:false, over budget, and a long lead body.
| const order = [...idx].sort( | ||
| (a, b) => | ||
| SEVERITY_ORDER[findings[b].severity] - SEVERITY_ORDER[findings[a].severity] || | ||
| findings[a].file.localeCompare(findings[b].file) || | ||
| (findings[a].startLine ?? 0) - (findings[b].startLine ?? 0) || | ||
| a - b, | ||
| ) | ||
| const lead = order[0] |
There was a problem hiding this comment.
MINOR · logic error
const order = [...idx].sort(
(a, b) =>
SEVERITY_ORDER[findings[b].severity] - SEVERITY_ORDER[findings[a].severity] ||
findings[a].file.localeCompare(findings[b].file) ||
(findings[a].startLine ?? 0) - (findings[b].startLine ?? 0) ||
a - b,
)
const lead = order[0]Each run picks the lead by severity → path with no memory of earlier runs. If a later push adds the same convention issue on a file that sorts first, a new lead is chosen. Its comment again lists files (and re-emits markers) already covered by the earlier lead comment, which is still on the PR: a repost.
Fix: leave findings in alreadyPosted out of the fold and the "same applies" list, or prefer a member that is already posted as the lead.
Raised by: Claude
There was a problem hiding this comment.
✅ Fixed in 23b8b528f9. A finding already on the PR (in alreadyPosted) is no longer folded, so a lead picked anew neither names it nor re-emits its marker. I fixed this at render time rather than by making the lead sticky, because grouping has no memory of earlier runs. Test: re-review: a new lead does not re-list or re-mark findings an earlier lead's comment covered.
There was a problem hiding this comment.
✅ Fixed (re-review at 23b8b52). Fixed at render time instead of with a sticky lead, which is fine: already-posted members are not foldable (format.ts:494-497), and the test at :799-811 covers the new-lead repost case.
| const folded = foldedInto.get(f.id) ?? [] | ||
| parts.push(clampBody(folded.length ? f.body.replace(SAME_APPLIES_RE, "") : f.body)) |
There was a problem hiding this comment.
MINOR · logic error
const folded = foldedInto.get(f.id) ?? []
parts.push(clampBody(folded.length ? f.body.replace(SAME_APPLIES_RE, "") : f.body))SAME_APPLIES_RE is stripped only when folded.length > 0. If every folded finding is dropped after grouping (by dedupe or a later filter), the lead still says "The same applies to: x.sql" for files that have no finding. The same stale line appears in summary bullets.
Fix: always strip the line, and append it again only when folded.length is non-zero.
Raised by: Claude
There was a problem hiding this comment.
✅ Fixed in 23b8b528f9. The grouping's sentence is always stripped, and the line is appended only for findings actually folded. Test: a lead whose folded findings were all dropped later does not say the same applies elsewhere.
There was a problem hiding this comment.
23b8b52; both reviewers agree). Inline comments now always strip the sentence (format.ts:541, test :813-820). Summary bullets still print the lead's stored body (bulletsFor → clampBody(f.body), format.ts:245), so the CLI, the 422 fallback, and over-budget leads can still say "The same applies to: x.sql" after the member was dropped by the severity threshold or dedupe. Fix: strip SAME_APPLIES_RE in bulletsFor, and extend the test to renderSummary(env, { inline: false }). Not blocking.
There was a problem hiding this comment.
✅ Fixed in 300ff5d69b. Summary bullets now show the body without the grouping's "The same applies to" sentence, as inline comments do. This covers single and grouped bullets. Since 0c377f9b81, the grouping key and the same-body check also ignore that sentence, so in a budgeted summary a lead groups with its members. Tests: a summary bullet does not repeat the lead's stored same-applies sentence (renders renderSummary(env, { inline: false }) both with the member present and with it dropped), a budgeted summary without inline comments groups the lead with its members (same-applies sentence ignored).
There was a problem hiding this comment.
✅ Fixed (round 3, adf9818). shownBody (format.ts:208) strips the sentence for the grouping key, grouped bullets and single bullets (:218, :233-250). The test at review-conventions.test.ts:822-842 renders inline: false with the member present and dropped.
|
Nits (peer review, Claude + Codex)
Missing tests: |
3e14ea4 to
23b8b52
Compare
|
Re @hkaltai's review text and nits comment:
|
| // lead picked anew on a later push neither re-lists it nor re-emits its marker. | ||
| const foldable = env.findings.filter((f) => { | ||
| const lead = f.groupedInto ? leads.get(f.groupedInto) : undefined | ||
| return !!lead && !alreadyPosted.has(f.id) && !alreadyPosted.has(lead.id) && inlineEligible(lead, posting, commentable) |
There was a problem hiding this comment.
WARNING: A folded finding that is summary-tier or pre-existing disappears from every output
foldable checks only the lead's eligibility. Grouping runs after the verifier (ai-review.ts:1086-1090), so a folded finding can itself be demoted to tier: "summary" (ai-verify.ts:604) or be marked preExisting later in cleanFindings. Such a finding fails inlineEligible (format.ts:462-463), so it is not in fresh, and released (line 513) also requires inlineEligible, so it is not deferred. But it is still foldable, so it joins collapsed whenever its lead is posted.
renderSummary then drops every collapsed id (lines 140-141), and the lead's inline comment lists only the folded file's path (format.ts:538-542), never its body, evidence or suggestion. A verifier-demoted finding on the other file is therefore reduced to a file name, and a pre-existing issue there is presented as part of the PR's change against the verifier's decision.
Fix: require inlineEligible(f, posting, commentable) (at least f.tier === "inline" && !f.preExisting) for a finding to be foldable; it then keeps its own summary bullet.
There was a problem hiding this comment.
✅ Fixed in 300ff5d69b; same fix as hkaltai's 4719797438. Test: a folded finding the verifier demoted or that is pre-existing is not folded; it keeps its summary entry.
| globs.push(...globList(frontmatterValue(item[1]))) | ||
| continue | ||
| } | ||
| inGlobList = false |
There was a problem hiding this comment.
SUGGESTION: A globs: list separated from its key by a blank or comment line is lost
inGlobList = false runs on every non-item line before the key/value test, so in Cursor frontmatter such as
globs:
# sql models only
- **/*.sql(and with a blank line instead of the comment) the comment clears inGlobList, the - **/*.sql item is ignored, and parseMdc returns no globs and alwaysApply: false. YAML.parse throws on the unquoted **, so this fallback is exactly the path for that frontmatter, and loadConventions then skips the rule entirely (!rule.alwaysApply && !globs.length, line 382). The tests cover only an inline value and a valid-YAML list.
Fix: keep inGlobList set across blank and comment lines; clear it only on a new key or a non-item line.
There was a problem hiding this comment.
✅ Valid, fixed in 9968d8e8a0. The line reader keeps reading the list across blank and comment lines. Test: frontmatter that is not YAML: a blank or comment line inside the globs list does not end it (both the comment and the blank-line case). adf9818c05 also reads a list written at column 0 (globs:\n- **/*.sql). Test: frontmatter that is not YAML: a globs list at column 0 is read.
| } | ||
| }) | ||
| const git = (cwd: string, ...args: string[]) => | ||
| execFileSync("git", args, { cwd, env: { ...process.env, GIT_AUTHOR_NAME: "t", GIT_AUTHOR_EMAIL: "t@t", GIT_COMMITTER_NAME: "t", GIT_COMMITTER_EMAIL: "t@t" } }).toString() |
There was a problem hiding this comment.
SUGGESTION: These git helpers skip the commit.gpgsign=false guard the others use
The helpers at lines 470 and 282 run git commit without -c commit.gpgsign=false, while the helpers at lines 516 and 884 pass it. With commit.gpgsign=true in the user's global or system config, these tests fail for an environment reason, not a code reason.
Fix: use the same execFileSync("git", ["-c", "commit.gpgsign=false", ...args], ...) form in both helpers.
There was a problem hiding this comment.
✅ Fixed in 9968d8e8a0. Both helpers now pass -c commit.gpgsign=false.
| const base = f.file.split("/").pop() ?? f.file | ||
| const names = [f.model, base, base.replace(/\.[^.]+$/, "")].filter((n): n is string => !!n && n.length > 1) | ||
| let t = f.title.toLowerCase() | ||
| if (f.model && t.startsWith(f.model.toLowerCase() + ":")) t = t.slice(f.model.length + 1) |
There was a problem hiding this comment.
SUGGESTION: Redundant model-prefix strip
The names loop on the next line removes every literal occurrence of f.model from the title (split/join, not a regex), and the [^a-z0-9]+ collapse turns the leftover : into a space, so this branch never changes the final issueKey.
Fix: delete line 565; the loop and the normalisation below subsume it.
There was a problem hiding this comment.
Not removed. It is not redundant for one-character model names: the names loop skips names of length 1 so that it does not erase that letter throughout the title, and only the prefix strip removes a:. Without it, a: missing description and b: missing description get different keys, so they are not grouped. The existing runAiReview groups the lane's findings when conventions were given fails with the line deleted. 9968d8e8a0 adds a comment saying why, and a test: a one-character model is taken off its `<model>:` title prefix when grouping.
hkaltai
left a comment
There was a problem hiding this comment.
Re-review at 23b8b52 (Claude + Codex, independent; findings checked against the code).
Approving: no critical or major issues remain. Moving the fold logic into one inlinePlan that both inlineComments and collapsedFindings use fixes the lost-findings bug, and the new-lead repost is fixed at render time. Two minor follow-ups remain and don't block: the stale "same applies" sentence is still in summary bullets (see that thread), and a new inline finding about members the verifier demoted.
| // lead picked anew on a later push neither re-lists it nor re-emits its marker. | ||
| const foldable = env.findings.filter((f) => { | ||
| const lead = f.groupedInto ? leads.get(f.groupedInto) : undefined | ||
| return !!lead && !alreadyPosted.has(f.id) && !alreadyPosted.has(lead.id) && inlineEligible(lead, posting, commentable) |
There was a problem hiding this comment.
MINOR · verifier / posting-policy integration
// lead picked anew on a later push neither re-lists it nor re-emits its marker.
const foldable = env.findings.filter((f) => {
const lead = f.groupedInto ? leads.get(f.groupedInto) : undefined
return !!lead && !alreadyPosted.has(f.id) && !alreadyPosted.has(lead.id) && inlineEligible(lead, posting, commentable)Folding checks only the lead's eligibility. Grouping runs after verification (ai-review.ts:1090), so a member the verifier demoted to summary-only (verification.decision: "summary") can still be folded into an eligible lead. The lead's comment then names its file and emits its posted marker, and the member's own summary entry and explanation are dropped. This overrides the verifier's decision.
Fix: also require inlineEligible(f, posting, commentable) for the member before folding, so ineligible members stay in the summary.
Raised by: Codex
There was a problem hiding this comment.
✅ Fixed in 300ff5d69b. A finding is folded only when it could go inline on its own (inlineEligible: tier, verifier demotion, pre-existing, severity floor). A member the verifier moved to the summary, or one marked pre-existing, keeps its own summary entry and is not marked as posted by the lead's comment. Test: a folded finding the verifier demoted or that is pre-existing is not folded; it keeps its summary entry.
There was a problem hiding this comment.
✅ Fixed (round 3, adf9818). Members are now checked with inlineEligible(f, posting) (format.ts:509-510, rejecting verifier demotions and preExisting at :464-470). The test at review-conventions.test.ts:844-866 asserts that neither member is named or marked in the lead and that both stay in the summary.
23b8b52 to
adf9818
Compare
| const postedIds = new Set(posted.map((f) => f.id)) | ||
| const collapsed = new Set(foldable.filter((f) => postedIds.has(f.groupedInto!)).map((f) => f.id)) | ||
| // A finding whose lead is over the budget stands on its own; the budget is spent, so it is deferred. | ||
| const released = foldable.filter((f) => !collapsed.has(f.id) && inlineEligible(f, posting, commentable) && !alreadyPosted.has(f.id)) |
There was a problem hiding this comment.
SUGGESTION: released re-checks a condition foldable already guarantees
foldable (lines 505-511) requires !alreadyPosted.has(f.id), so the trailing && !alreadyPosted.has(f.id) here can never change the result. Of the inlineEligible re-check, only its commentable half adds anything over the inlineEligible(f, posting) already applied in foldable.
| const released = foldable.filter((f) => !collapsed.has(f.id) && inlineEligible(f, posting, commentable) && !alreadyPosted.has(f.id)) | |
| const released = foldable.filter((f) => !collapsed.has(f.id) && inlineEligible(f, posting, commentable)) |
There was a problem hiding this comment.
Correct: foldable already requires !alreadyPosted.has(f.id), so that part of the check is redundant, and only the commentable half of the inlineEligible call adds anything (a member whose line is not commentable is not released inline). It does no harm, and the PR is approved, so I'm leaving it as is rather than add churn this late.
hkaltai
left a comment
There was a problem hiding this comment.
Re-review (round 3) at adf9818 (Claude + Codex, independent; findings checked against the code).
Approving. Both open threads are fixed: shownBody strips the stale sentence for summary bullets and the grouping key, and members are folded only when they are themselves inline-eligible, so verifier demotions and pre-existing findings stay in the summary. The tests would fail without each fix. No new defects; the other changed files come from the rebase onto #1836.
…the base branch - `conventions.ts` reads guideline files from the base commit, so a PR cannot rewrite the conventions it is reviewed under: `.altimate/review.md` (or `.altimate/REVIEW.md`); `REVIEW.md`, `AGENTS.md`, `CLAUDE.md`, `.claude/CLAUDE.md` at the root and every ancestor of a changed path; `.coderabbit.yaml` `path_instructions` and `tone_instructions`; `.cursor/rules/*.mdc` with globs or `alwaysApply`; `.cursorrules`; `.github/copilot-instructions.md`; the dbt/SQL/test sections of `CONTRIBUTING.md` - each finder call gets a TEAM CONVENTIONS section after the grounding with the conventions that apply to its files, most specific first, within 3,000 characters; the finder names the convention's path in the finding body (the core 0.9 output has no `cites`) - this is the one reader of repo instructions: it covers every file #1774's `loadRepoInstructions` reads, which can be dropped when that PR is rebased on this one - `conventions` switch, on by default with the AI lane: `ai.conventions: false` or `ALTIMATE_REVIEW_CONVENTIONS=0` turns it off; off, nothing is loaded and the finder's messages are byte-identical - envelope: `ai.conventions[]` (path, source, scope, globs, chars) and `ai.input[].conventions` on the first file of each call that carried any - `git.ts` `lsTreeAtRef`; `diff-filter.ts` exports `globToRegExp`; docs - tests: loader, parsing, scoping and budget; base commit read over git; off identity (plain, coverage, focused); placement and per-call scoping; envelope record; `reviewPullRequest` end to end under the AI dry run (base `CLAUDE.md`, PR edit ignored) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ral files - AI findings in one review that name the same convention path (the longest loaded path their title or body names) for the same issue (title without the file's own model and file names, trailing preposition dropped) on different files become one finding: the most severe, first on ties, with "The same applies to: `a.sql`, `b.sql`." in its body - applied in `runAiReview` after the verifier, only when conventions were given; findings that name no convention, name different ones, or sit on one file are unchanged - the core 0.9 output has no `cites` field, so the convention is read from the text the finder is asked to write; with core 0.10's `cites` the same grouping can key on it - tests: three files grouped with the most severe kept, unchanged cases, longest path, `runAiReview` with and without conventions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y source as written - `loadConventions` no longer turns a git failure into "file absent": `showAtRef` already tells a missing path from a real error, and that error now fails the review, as the base-policy read of the same commit does, instead of silently dropping every convention - the base commit is listed once with `git ls-tree -r -z` (`listFilesAt`) and filtered to `.cursor/rules/` under each scope: paths are verbatim (no C-quoting of non-ASCII or special characters) and there is no per-directory subprocess; `lsTreeAtRef` is removed - `.mdc` frontmatter is parsed as YAML (inline comments, quoting, lists); Cursor's unquoted `globs: **/*.sql`, which is not valid YAML, falls back to the line reader, which now drops inline comments too - CodeRabbit `tone_instructions` is read from the document root, with `reviews.tone_instructions` as a fallback - the per-call budget covers the whole section: the TEAM CONVENTIONS heading, each entry's joining newline and the truncation marker - `conventionsFor` and `renderConventions` share one ranking, so the ordering rule cannot drift - the envelope's convention `source` is a `z.enum` of the nine sources - docs: manual Cursor rules are skipped; `tone_instructions` is read; the switch defaults comment says conventions are on by default outside the measured configuration - tests: git read and list failures reject; a non-ASCII rule name loads over git; YAML comments in both frontmatter forms; root and nested tone; rendered section within budget; unknown source rejected by the envelope schema Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eplay groups too - `groupConventionFindings` folds only the first finding on each file other than the lead's; further findings on the lead's file (or on an already-folded file) may be distinct issues and stay as they are - replay mode (`ALTIMATE_REVIEW_AI_REPLAY`) records `ai.conventions` and groups the replayed findings like a live run - tests: same-file findings survive grouping; replay records and groups; the spies in the grouping tests are restored in `afterEach`, so a failing assertion cannot leak them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`groupConventionFindings` deleted every folded finding and kept only the lead, whose body listed the other files. Their lines, bodies and suggestions were lost from the envelope (SARIF, audit, replay), and since the fingerprint ignores the body, a file folded into an already-posted lead on a later push was never posted at all. - Folded findings stay, in place, with `groupedInto: <lead id>` (a new optional `Finding` field). - `format.ts` collapses them: no inline comment and no summary line of their own while their lead is inline-eligible and not yet on the PR. The lead's comment carries their finding markers, so the next run counts them as posted. Once the lead is on the PR, a newly folded finding posts alone. - The lead is picked deterministically: severity, then path, then line. - The grouping key adds the finding's category, so the same generic title in two categories is not folded. - Replay strips `groupedInto` and the lead's "The same applies to" line, so re-grouping a replayed envelope does not repeat it. Changed expectations: the four grouping tests that asserted the folded findings were removed now assert they are kept with `groupedInto` (the reported defect). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Credential screen: a convention document that holds a private key or a service-account key (`holdsCredentials`, the screen every other AI-lane input goes through) is skipped before it is parsed or cut. - No unbounded `git show` fan-out: with the base listing only paths it holds are read, and reads run at most 8 at a time. A PR touching ~150 directories no longer starts ~600 processes. - Symlinks at the base commit are skipped (`listSymlinksAt`, mode 120000): `git show` returns the link target's name, not its text. - `.altimate/review.md` is looked up in every scope, so a dbt project's own file next to its `.altimate/review.yml` applies to it. - Scoped files are searched above the files the review covers (in-scope changed files plus the outside Python files its AI lane may take), not every directory the PR touches, so unrelated directories do not use up the 40k total. - The dedupe key uses the full text, not its length. - `sliceContributing` ignores `#` lines inside code fences. - Line-mode frontmatter passes the raw `globs` value to `globList`, so `"a", "b"` keeps both globs. - A convention that does not fit a call whole is cut to at most half the call budget while others follow, so one long file cannot shut out `.altimate/review.md`. A git failure reading the base commit still fails the review, as the base-policy read of the same commit does. Changed expectation: the "scoped files are looked up only in ancestors" test now loads without the base listing, since with it absent candidates are no longer probed at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…i-project merge keeps every project's conventions - `AiVerifyEvidence.conventions` maps each loaded convention path to its base-commit text. `read_file` accepts those paths and serves that text, so an unchanged `CLAUDE.md` is readable and a PR's edit of it cannot be used to refute a finding based on the base convention. - `mergeAi` unions `ai.conventions` across projects (each project now loads the conventions above its own files), so the merged envelope no longer depends on which lane it spreads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Docs: `.claude/CLAUDE.md` is looked up in every scope like the other scoped files; project-level `.altimate/review.md`; symlinks and credential-bearing files are skipped; the verifier reads base text. - `AI_SWITCH_DEFAULTS` comment: conventions were part of the measured configuration, as the PR description says. - A test name no longer refers to another PR by number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…repeat merging - `inlineComments` clamps the lead's own body and adds "The same applies to: …" as a separate part, built from the folded findings it collapses. Before, a lead body over 600 characters cut the list while the folded markers were still added, so the next run treated those files as posted though no comment named them. - `mergeRepeats` keeps `groupedInto` on a merged comment only when every member was folded into the same lead, so a distinct finding merged with a folded one stays visible. When a lead is merged, findings folded into it are pointed at the merged comment's id, so they stay collapsed. - `SAME_APPLIES_RE`/`sameAppliesLine` are shared; replay strips the line wherever it sits, not only at the end of the body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On top of the PEM/service-account screen, each convention document is passed through the shared `redactSecrets` (tokens such as `ghp_…`, `password: …`, keys in URLs, long opaque blobs) plus AWS access key ids (`AKIA…`/`ASIA…`) before it is parsed or sent. Changed expectation: the per-file cap test used one 9,000-character run of `x`, which the long-blob rule now redacts; it uses words instead and checks the same 4,000-character cut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…symlinks `listTreeAt` returns every entry at the base commit and the symlinks among them from a single listing; `run.ts` shares it between `listBase` and `listBaseSymlinks`. It replaces `listSymlinksAt`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared `redactSecrets` mangled ordinary guidance: "basic tests" and "the
token count" lost their next word, "secret: never select…" lost "never",
`env_var('DBT_PASSWORD')` and md5 examples were redacted, and the 40+
character blob rule could swallow long paths. `redactConvention` now uses
only shapes prose does not have: provider-prefixed tokens and AWS key ids,
URL userinfo with a password, and a secret-named key whose value looks like
a credential (12+ characters, no template or placeholder, mixed character
classes, entropy of at least 3 bits per character). The PEM and
service-account screen is unchanged.
The per-file cap test is back to its original 9,000-character `x` fixture,
since the blob rule no longer applies; the redaction test uses credential-like
values.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… inline `collapsedFindings` asked only whether the lead could go inline, not whether this rendering posts it. A summary rendered with `inline: false` (CLI, agent tool, the 422 fallback) and a lead past `posting.inlineBudget` both dropped the folded findings: no inline comment, no summary line. `inlinePlan` now settles the folding against the budget: a finding is folded only into a lead within the budget; one whose lead is over the budget stands on its own and is deferred with it. `renderSummary` folds nothing when it renders without inline comments. `inlineComments` has its doc comment back. Tests (review-conventions.test.ts): `a summary rendered without inline comments (CLI, agent tool, 422 fallback) lists every folded finding`, `a lead over the inline budget: its folded findings are deferred to the summary, not hidden`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on the PR; the same-applies line names only folded findings - The lead is picked by severity and path on each run. When a later push added the same issue on a file that sorts first, the new lead folded the findings an earlier lead's comment already listed, and its comment named them again and re-emitted their markers. Findings in `alreadyPosted` are no longer folded. - The grouping's "The same applies to" sentence was stripped only when the lead had folded findings, so a lead whose folded findings were dropped later still named those files. It is now always replaced by the list of findings actually folded. Tests (review-conventions.test.ts): `re-review: a new lead does not re-list or re-mark findings an earlier lead's comment covered`, `a lead whose folded findings were all dropped later does not say the same applies elsewhere`, and `summary without inline comments, lead body over the clamp: each folded finding is still listed` (covers the earlier fold fix). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… bullets drop the stale same-applies line - `inlinePlan` folds a finding into its lead only when the finding could go inline on its own (`inlineEligible`: tier, verifier demotion, pre-existing, severity floor). Grouping ignores the verifier and runs before findings are marked pre-existing, so a demoted or pre-existing member was hidden behind the lead's file list. It now keeps its own summary entry and is not marked as posted. - Summary bullets show the body without the grouping's "The same applies to" sentence, as inline comments already do: the CLI, the 422 fallback and over-budget leads list each finding they show, and the sentence could name a finding dropped later. Tests: `a folded finding the verifier demoted or that is pre-existing is not folded; it keeps its summary entry`, `a summary bullet does not repeat the lead's stored same-applies sentence`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t test helpers skip signing - `parseFrontmatterLines` keeps reading a `globs:` list across blank and comment lines, so a rule whose frontmatter is not valid YAML (unquoted `**/*.sql`) keeps its globs instead of being skipped. - `issueKey`: a comment says why the `<model>:` prefix strip stays (the `names` loop skips one-character names); a test pins it. - The two remaining git helpers in review-conventions.test.ts pass `-c commit.gpgsign=false` like the others. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`bulletsFor` keyed groups and compared member bodies on the raw body, which still held the lead's "The same applies to" sentence, so a lead never grouped with its members in a budgeted summary. Both now use the shown body. Test: `a budgeted summary without inline comments groups the lead with its members (same-applies sentence ignored)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tter is not YAML Test: `frontmatter that is not YAML: a globs list at column 0 is read`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adf9818 to
c6d68f1
Compare
Issue for this PR
Part of #1792
Type of change
What does this PR do?
Stacked on
feat/review-finder-defects. The second of three PRs that bring the AI lane to the measured configuration.What changed
conventions.tsreads the repo's own review instructions from the base commit, so a PR cannot change the rules it is reviewed under. It reads:.altimate/review.md(or.altimate/REVIEW.md),REVIEW.md,AGENTS.md,CLAUDE.mdand.claude/CLAUDE.md, at the root and in each directory above a file the review covers (the project's changed files and the outside-project Python files its AI lane may take), so a dbt project's own.altimate/review.mdapplies to it.cursor/rules/*.mdc(by glob oralwaysApply; manual rules with neither are skipped; frontmatter parsed as YAML, with a line reader for Cursor's unquoted globs) and.cursorrules.github/copilot-instructions.md.coderabbit.yamlpath_instructionsand the document-leveltone_instructions(reviews.tone_instructionsas a fallback)CONTRIBUTING.mdgit ls-tree -r -z), so unusual rule file names load, and only paths it holds are read, at most 8git showcalls at a time. Symlinks at the base commit are skipped (git would return the target's name).holdsCredentials, the screen every other AI-lane input goes through) is skipped before it is parsed, so it never reaches the model. In the others, credentials are redacted with high-precision patterns only: provider-prefixed tokens, AWS key ids, URL userinfo with a password, and secret-named settings whose value looks like a credential. Ordinary guidance (env_var('DBT_PASSWORD')examples, "basic tests", md5 examples) is left as written.citesfield yet; once core 0.10 adds it, it applies here.groupedInto: <lead id>, with their own lines, for SARIF, audit and replay); the renderer shows them through the lead, whose comment carries their markers, but only when this run posts the lead inline: a lead over the inline budget, or a summary rendered without inline comments (CLI, agent tool, the 422 fallback), lists each folded finding on its own. Once the lead is on the PR, a finding newly folded into it is posted on its own, and a finding already on the PR is never folded again (so a lead picked anew on a later push does not re-list it). The lead's "same applies" line names only the findings actually folded. The list of folded files is added after the body clamp, so a long lead body cannot cut it; a repeat-merged comment keepsgroupedIntoonly when all its members share it, and findings folded into a merged lead follow it to the merged id. Only one finding per other file is folded in; further findings on the same file may be distinct issues and stay. Replay mode (ALTIMATE_REVIEW_AI_REPLAY) records and groups the same way.read_fileserves a convention file's base-branch text, so a PR's edit to aCLAUDE.mdcannot be used to refute a finding based on the base convention.conventions, on by default with the AI lane.ai.conventions: falseorALTIMATE_REVIEW_CONVENTIONS=0turns it off. When off, nothing is loaded and the finder's messages are byte-identical to before.ai.conventions[]records path, source, scope, globs and size, but not the text; under--all-projectsit is the union over the projects.ai.input[].conventionsis set on the first file of each call that carried any.loadRepoInstructionsreads. When feat(review): AI evidence line, suggestions and base-branch repo instructions (needs core 0.10) #1774 is rebased onto this PR, that commit can be dropped.Results
The measured configuration included conventions together with the other two PRs. AI and rule comments were counted together.
Conventions were not measured on their own.
The measured build deleted folded convention findings, searched for scoped files above every PR path (now only above the files the review covers), cut a long convention to the whole call budget (now half while others follow), and had no credential screen or symlink skip. Those changes can change which conventions a call carries on some PRs; the measurement was not rerun.
How did you verify your code works?
bun test test/altimate/review(packages/opencode): 1092 pass, 0 fail.bun run typecheck(packages/opencode,tsgo --noEmit): clean.reviewPullRequestend to end under the AI dry run: a base-branchCLAUDE.mdis used and the PR's edit to it is ignoredCost side effects
git ls-treelisting and agit showper instruction file that exists at the base commit, at most 8 at a time.ai.conventions: falseorALTIMATE_REVIEW_CONVENTIONS=0turns it off.Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code