Why the diff is not the change

A pull request arrives as a diff: a sequence of file additions and deletions, line by line. But a code change is not a container; it is a bomb. Every renamed function, every changed signature, every removed export detonates somewhere — at every place in the codebase that did not change but will feel the change.

A reviewer who only reads the diff sees the explosion site. A reviewer who reads the blast radius sees the explosion.

CodeOtter ships Outside-Diff Call Graph Impact Slicing as a first-class part of Smart Context. In the CLI, three small deterministic functions draw the call graph that the diff hides (the hosted reviewer has its own tracer, covered in Step 2):

  • extractSymbolsFromDiff(diffText) (tui/codeotter.mjs, L188) — pulls every exported function, const, let, var, class, type, interface (and the Python def / class / Go func equivalents) out of the diff in one regex pass.
  • findOutsideImpact(symbols, modifiedFiles, repoRoot) (tui/codeotter.mjs, L201) — for each symbol, runs git grep -n -w <sym> against the rest of the repo and returns the caller hits that live in files the diff did not touch (capped at 20).
  • blastRadius(files, outsideCallers, outsideFiles) (core/server.mjs, L1017) — counts the changed files, lines, areas, hotspots and test files, adds the outside-diff hit counts, and computes a heuristic 0–100 score from them. The score on the review comes from System One or the language model (see Step 3).

The trace itself lives in extractSymbolsFromDiff and findOutsideImpact in tui/codeotter.mjs (L188–L224) and, for hosted reviews, in sliceOutsideDiffImpact in core/server.mjs (L952); the counts come from blastRadius (L1017). The trace is deterministic, costs one git grep pass per extracted symbol, and adds no dependencies to the CLI.

Step 1 — extract the symbols you touched (extractSymbolsFromDiff, L188)

The first pass is a single regex over the diff text. It matches JavaScript / TypeScript / Python / Go exports and keyword picks the first non-keyword capture group as the symbol:

// tui/codeotter.mjs — L190
const exportPattern = /(?:export\s+(?:async\s+)?function\s+([a-zA-Z0-9_$]+)|export\s+(?:const|let|var)\s+([a-zA-Z0-9_$]+)|export\s+class\s+([a-zA-Z0-9_$]+)|export\s+type\s+([a-zA-Z0-9_$]+)|export\s+interface\s+([a-zA-Z0-9_$]+)|def\s+([a-zA-Z0-9_]+)|class\s+([a-zA-Z0-9_]+)|func\s+(?:\([^\)]+\)\s+)?([a-zA-Z0-9_]+))/g;

The pattern is permissive on purpose. The point is not to parse every TypeScript file — the point is to not miss a renamed export. It is a text match, not a parser: the regex intentionally accepts JS / TS / Python / Go in one pass, so a match is a candidate symbol, not proof that the name is exported or in use.

The output is a de-duplicated array of up to 15 symbol names (names of one or two characters are skipped):

// tui/codeotter.mjs — L198
return Array.from(symbols).slice(0, 15);

The 15-symbol ceiling bounds the trace: a diff that exports more than 15 symbols gets only the first 15 searched, in the order the regex finds them.

Step 2 — trace callers outside the diff (findOutsideImpact, L201)

The second pass is where the outside-diff story happens. For every extracted symbol, CodeOtter runs one git grep -n -w <sym> over the repository — the same exact CLI command you would run by hand — and collects the caller hits that live in files not present in the modified-set:

// tui/codeotter.mjs — L208
const grepOut = execFileSync("git", ["grep", "-n", "-w", sym], { cwd: repoRoot, encoding: "utf8", maxBuffer: 1024 * 1024 });
for (const line of grepOut.split("\n")) {
  if (!line.trim()) continue;
  const [file, lineNum, ...codeParts] = line.split(":");
  const normFile = (file || "").replace(/\\/g, "/");
  if (normFile && !modifiedSet.has(normFile) && !/test|spec|__tests__/.test(normFile)) {
    callers.push({ file: normFile, line: lineNum, symbol: sym, code: codeParts.join(":").trim() });
    if (callers.length >= 20) break;
  }
}

Three properties matter:

  • Zero new dependencies. git grep is the only external command — it ships with Git, which you already have because you cloned the repo.
  • Word-boundary matching. -w reports only whole-word matches. Without it, a search for submitOrder would also hit submitOrderV2, resubmitOrder and submitOrderCount. The flag still matches the name anywhere it appears as a whole word — in comments, strings, or an unrelated symbol that happens to share it — so a hit is a candidate to check, not proof that the call breaks.
  • 20-hit cap, no test files. Any path containing test, spec or __tests__ is skipped, so the test suite that should exercise the change does not add to the count. The loop stops at 20 hits.

findOutsideImpact returns { outsideCallers, uniqueFiles, callers[] }. outsideCallers is the total hit count (capped at 20). uniqueFiles is new Set(callers.map(c => c.file)).size — the number of distinct un-modified files that the change detonates against.

Hosted reviews use a separate server-side tracer, sliceOutsideDiffImpact (core/server.mjs, L952), with its own symbol extractor (extractChangedSymbols, L918). It runs git grep -n -w first, keeps up to five lines per symbol, and stops adding symbols once it holds 12 hits (L984). Only when that finds nothing does it fall back to GitHub code search (GET /search/code, L991) for at most three symbols (L989), again stopping once it holds 10 hits; those hits record line: 1 and the snippet reference to <sym>. Unlike the CLI, it does not skip test paths; besides the changed files, it drops only hits whose path ends in .lock, .map, .min.js, .svg, .png or .json (L978, L996). Its callers are shaped { symbol, file, line, snippet }, not the CLI's { file, line, symbol, code }.

Step 3 — count the blast (blastRadius, core/server.mjs L1017)

The third pass is a single deterministic function with no model call and no prompt. Given the changed files and the outside-diff hit counts, it returns the numbers behind the Blast radius details panel plus a heuristic 0–100 score:

// core/server.mjs — L1023–L1024
const callerImpact = Math.min(25, outsideCallers * 4 + outsideFiles * 2);
const score = Math.min(100, Math.min(30, files.length * 2.5) + Math.min(25, lines / 30) + Math.min(25, hot.length * 10) + callerImpact);

Four weighted components — files (capped at 30), lines, hotspots and outside-caller-impact (each capped at 25) — summed and clamped to [0, 100]:

  • Files changed — min(30, files.length * 2.5). Caps at 12 files; PRs touching 12+ files already need to be decomposed.
  • Lines touched — min(25, lines / 30). Caps at ~750 lines; PRs beyond that should be split.
  • Known hotspots touched — min(25, hot.length * 10). The HOTSPOTS constant in core/server.mjs (L908) lists high-blast-radius paths (migrations, auth / security, payments / money, public API routes, core domain, dependencies, CI / deploy) — each distinct hotspot category the diff touches is worth 10 points.
  • Outside-diff caller impact — min(25, outsideCallers * 4 + outsideFiles * 2). The new piece. The piece the diff almost never shows.

blastRadius returns { score, files, lines, dirs, hotspots, testFiles, outsideCallers, outsideFiles }. In hosted reviews it is called with the outside-diff hit counts, and the result is what the Blast radius details panel shows. The score is a heuristic and a placeholder: when System One is on, its own blast_radius score replaces it (L2536, L2588); with System One off, the language model's score does (L2558). The number on the Blast Radius gauge is therefore System One's or the model's, not this function's. The CLI follows the same rule: runReview calls reviewDiff from core/server.mjs, which returns the scorer's number (L4611), and the CLI renders that.

What the scorers get to see depends on the path. In hosted reviews the outside-diff hits are also given to the models: System One's input carries them as outside_diff_call_graph (L1347) unless it runs on an on-device local model, which gets a compact digest instead, and the language-model prompt includes them as a block of call sites (L1937). In the CLI the trace runs after reviewDiff returns and its counts are shown beside the score; the scorers never see them. The trace and the counts involve no model. The number on the gauge comes from one.

Step 4 — render the call graph

Both tracers return a callers[] array whose entries carry a file, a line and a symbol. In the hosted review, buildBlastMermaid (core/server.mjs, L3224) draws a Mermaid flowchart LR graph of the whole change: a node for the PR, the changed files grouped by directory, any hotspot and test nodes, and up to four 🌐 Outside nodes (file name, line and calls <symbol>()) for the first outside callers, each joined to the first changed-file group by a dashed edge labeled calls <symbol>. The review's markdown export (buildAiReviewMarkdown, web/src/review-page.tsx, L252) also lists the first five call sites under Outside-Diff Call Graph Impact.

The diff says "you renamed submitOrder". The trace adds "and payment, loyalty, subscription-renewal, and risk-checkout still call it under the old name." The sketch below is a simplified illustration of that idea, not captured output; the real graph also carries the PR, directory, hotspot and test nodes described above:

Why the call-site list belongs in the review

The diff changes with every commit, but the list of downstream callers is also the human reviewer's checklist. When the reviewer reads "you renamed submitOrder, and payment, loyalty, subscription-renewal, and risk-checkout still call it," they are not re-discovering what the diff left out — they are confirming a list a script already produced. Hosted reviews also give the same call sites to the models as input (Step 3).

Three reasons the trace is built this way:

  1. The trace is deterministic. No prompt, no model, no temperature: the same diff against the same repo state returns the same hits. The score shown on the gauge is a separate matter (Step 3).
  2. It is grounded in code, not prose. The graph nodes are file paths and line numbers; the edges are real git grep -w hits. Nothing is generated.
  3. It adds no model call. The CLI runs a single git grep -n -w per extracted symbol, with the trace capped at 20 caller hits per review.

What this is not

Outside-Diff Blast Radius is not a "smart" replacement for human review. It is a deterministic blast-radius map — a structured list of files outside the diff that the change detonates against. The author or the coding agent decides what to do about the blast radius (rename in lockstep, keep both names with a deprecation period, open follow-up issues per caller). The human reviewer decides whether that plan is right. The call-site list gives both of them the same starting point.

It is also a text search, with the limits that implies:

  • git grep searches only the files git tracks, and -w matches a name wherever it appears as a whole word. A hit is a candidate to check, not proof of breakage.
  • The symbol pass is a regex over the diff text. It skips names of one or two characters and traces at most 15 symbols, and the CLI stops at 20 hits.
  • Hosted reviews of Forgejo and Gitea repositories skip the trace: sliceOutsideDiffImpact returns early for them (core/server.mjs, L955), so those reviews show no outside callers.