* Compact "blast radius" for the entry symbols of an explore result: who * depends on each (callers) and which test files cover it — LOCATIONS ONLY, * no source, so the agent knows what to update / re-verify before editing * without reaching for a separate impact call. Always-on, but skips
(
cg: CodeGraph,
subgraph: Subgraph,
/**
* Exact targets (a qualified name, a line anchor) lead the list. The search
* roots are whatever FTS ranked first for the bare name, so without this a
* query for `SQLCompiler.as_sql` headlined `SQLInsertCompiler.as_sql` — and
* the agent took that as the tool having found the wrong method.
*/
leadingIds: Iterable<string> = [],
)
| 4214 | * qualify so a leaf-only exploration stays clean. |
| 4215 | */ |
| 4216 | private buildBlastRadiusSection( |
| 4217 | cg: CodeGraph, |
| 4218 | subgraph: Subgraph, |
| 4219 | /** |
| 4220 | * Exact targets (a qualified name, a line anchor) lead the list. The search |
| 4221 | * roots are whatever FTS ranked first for the bare name, so without this a |
| 4222 | * query for `SQLCompiler.as_sql` headlined `SQLInsertCompiler.as_sql` — and |
| 4223 | * the agent took that as the tool having found the wrong method. |
| 4224 | */ |
| 4225 | leadingIds: Iterable<string> = [], |
| 4226 | ): string { |
| 4227 | const ROOT_CAP = 5; // only the symbols the query actually targeted |
| 4228 | const FILE_CAP = 4; // caller files listed per symbol before "+N more" |
| 4229 | const TEMPLATE_VIEW_FILE = /\.(?:cshtml|razor|vue|svelte|astro)$/i; |
| 4230 | const MEANINGFUL = new Set<string>([ |
| 4231 | 'function', 'method', 'class', 'interface', 'struct', 'union', 'trait', 'protocol', |
| 4232 | 'enum', 'type_alias', 'component', 'constant', 'variable', 'property', 'field', |
| 4233 | ]); |
| 4234 | const rel = (p: string) => p.replace(/\\/g, '/'); |
| 4235 | const isTest = this.testCodeReading(cg); |
| 4236 | |
| 4237 | const roots = [...new Set([...leadingIds, ...subgraph.roots])] |
| 4238 | .map((id) => subgraph.nodes.get(id)) |
| 4239 | .filter((n): n is Node => !!n && MEANINGFUL.has(n.kind)) |
| 4240 | .slice(0, ROOT_CAP); |
| 4241 | if (roots.length === 0) return ''; |
| 4242 | |
| 4243 | const entries: string[] = []; |
| 4244 | for (const root of roots) { |
| 4245 | let callers: Array<{ node: Node }> = []; |
| 4246 | try { callers = cg.getCallers(root.id) as Array<{ node: Node }>; } catch { /* skip this root */ } |
| 4247 | |
| 4248 | const seen = new Set<string>(); |
| 4249 | const uniq: Node[] = []; |
| 4250 | for (const c of callers) { |
| 4251 | if (c?.node && !seen.has(c.node.id)) { seen.add(c.node.id); uniq.push(c.node); } |
| 4252 | } |
| 4253 | if (uniq.length === 0) continue; // no blast radius → nothing to flag |
| 4254 | |
| 4255 | // By caller, not by file: a Rust file holds its `#[cfg(test)] mod tests` |
| 4256 | // next to the production code it tests. |
| 4257 | const testFiles = [...new Set(uniq.filter(isTest).map((n) => rel(n.filePath)))]; |
| 4258 | const nonTest = [...new Set(uniq.filter((n) => !isTest(n)).map((n) => rel(n.filePath)))]; |
| 4259 | |
| 4260 | // A view depends on a helper across a layer, and is easily outnumbered by |
| 4261 | // same-language callers: one flat cap showed none of a helper's 22 views |
| 4262 | // behind four `.js` files. "Which views use this?" gets its own slot. |
| 4263 | const viewFiles = nonTest.filter((f) => TEMPLATE_VIEW_FILE.test(f)); |
| 4264 | const codeFiles = nonTest.filter((f) => !TEMPLATE_VIEW_FILE.test(f)); |
| 4265 | const shown = codeFiles.slice(0, FILE_CAP).map((f) => `\`${f}\``).join(', '); |
| 4266 | const more = codeFiles.length > FILE_CAP ? ` +${codeFiles.length - FILE_CAP} more` : ''; |
| 4267 | const views = viewFiles.length > 0 |
| 4268 | ? `${codeFiles.length > 0 ? ';' : ' in'} ${viewFiles.length} view${viewFiles.length === 1 ? '' : 's'}: ${viewFiles.slice(0, FILE_CAP).map((f) => `\`${f}\``).join(', ')}${viewFiles.length > FILE_CAP ? ` +${viewFiles.length - FILE_CAP}` : ''}` |
| 4269 | : ''; |
| 4270 | const where = (codeFiles.length > 0 ? ` in ${shown}${more}` : '') + views; |
| 4271 | const tests = testFiles.length > 0 |
| 4272 | ? `; tests: ${testFiles.slice(0, FILE_CAP).map((f) => `\`${f}\``).join(', ')}${testFiles.length > FILE_CAP ? ` +${testFiles.length - FILE_CAP}` : ''}` |
| 4273 | : this.indirectTestNote(cg, uniq, rel, isTest); |
no test coverage detected