Skip to content

10. Blast Radius

codeknife blast answers “what breaks if I change this function?”. It walks the call graph backwards from a target function to collect every transitive caller, the entrypoints and tests among them, and any SQL table, HTTP route or environment variable those callers share with other files. Use it before you edit a widely used function, or with --changed to size up a diff.

The demo repository has a Python backend, a TypeScript frontend and a Go job:

backend/rules.py validate_total(total)
backend/pricing.py compute_total() calls validate_total
backend/refunds.py refund() calls validate_total
backend/db.py database_url() os.getenv("DATABASE_URL")
save_order() "INSERT INTO orders (total) VALUES (?)"
backend/service.py create_order() calls compute_total, save_order
backend/api.py handle_create() route = "/api/orders"; calls create_order
backend/main.py main() calls handle_create; has if __name__ == "__main__"
backend/test_service.py test_create_order() calls create_order
frontend/api.ts submitOrder() fetch('/api/orders', ...)
databaseUrl() process.env.DATABASE_URL
frontend/validate.ts validate_total(n)
jobs/cleanup.go PurgeOrders() "DELETE FROM orders WHERE total = 0"

Trace save_order:

Terminal window
codeknife blast --no-cache --symbol save_order --format human
info[CK_BLAST_IMPACT]: Blast radius for `backend.db.save_order`: 3 upstream caller(s) across 4 file(s), 1 entrypoint(s), 1 test(s)
--> backend/db.py:8-9 (backend.db.save_order)
= note: backend/test_service.py:9 — covering test: backend.test_service.test_create_order
= note: backend/service.py:5 — caller: backend.service.create_order
= note: backend/api.py:4 — caller: backend.api.handle_create
= note: backend/main.py:4 — entrypoint reaches save_order via caller cone
blast │ 4 ▓▓▓▓▓
= fix: Verify the impacted entrypoints and callers listed in evidence.
warning[CK_BLAST_CONTRACT]: Cross-boundary contract in `backend.db.save_order` touches [http:/api/orders, sql:orders] shared across 5 peer reference(s)
--> backend/db.py:8-9 (backend.db.save_order)
= note: backend/db.py:9 — sql:orders consumer (python)
= note: jobs/cleanup.go:6 — sql:orders consumer (go)
= note: backend/api.py:5 — http:/api/orders consumer (python)
= note: frontend/api.ts:2 — http:/api/orders consumer (typescript)
= note: frontend/api.ts:2 — http:/api/orders consumer (typescript)
= fix: Keep producer and cross-file/cross-language contract consumers synchronized.
codeknife blast: FAIL (11 files, 0 errors, 1 warnings, 1 info, 2ms)

The exit code is 1 because of the contract warning.

  • The cone is save_order plus its 3 callers in 4 files. main is an entrypoint.
  • test_create_order calls create_order, which is in the cone, so it counts as a covering test.
  • save_order writes to table orders, which the Go job also uses. handle_create, a caller, holds the route /api/orders, which the frontend also calls. Contracts held anywhere in the cone are reported against the target.
  • frontend/api.ts:2 appears twice. For a TypeScript string, both the string node and its inner text fragment are scanned, so the same route is recorded twice.

The JSON report holds the same findings. This is the impact finding from it:

Terminal window
codeknife blast --no-cache --symbol save_order --format json
{
"id": "585ff9326156c16f",
"rule": "CK_BLAST_IMPACT",
"blade": "blast",
"severity": "info",
"location": {
"file": "backend/db.py",
"start_line": 8,
"end_line": 9,
"symbol": "backend.db.save_order"
},
"message": "Blast radius for `backend.db.save_order`: 3 upstream caller(s) across 4 file(s), 1 entrypoint(s), 1 test(s)",
"fix_hint": "Verify the impacted entrypoints and callers listed in evidence.",
"impact_score": 35.0,
"metric_value": 4.0,
"picture": {
"kind": "bar",
"label": "blast",
"length": 4,
"most": 30
},
"evidence": [
{
"file": "backend/test_service.py",
"line": 9,
"label": "covering test: backend.test_service.test_create_order"
},
...
]
}

metric_value is the number of affected files.

The command picks target functions in one of three ways. --symbol wins over --changed.

Invocation Targets Mode
--symbol NAME Every item in the code model that matches NAME, at most 20 explicit
--changed (no --symbol) Every function, method and route that is not a test and sits in a changed file, at most 30 explicit
neither Non-test functions, methods and routes outside test files with at least 2 direct callers, ranked by caller count, top 20 implicit

An item matches when any of these is true. Matching is case-sensitive.

  • its short name equals NAME
  • its qualified name equals NAME
  • its qualified name ends with ::NAME, .NAME or /NAME

Qualified names use the separator of the language: backend.db.save_order in Python, frontend/validate/validate_total in TypeScript. So --symbol db.save_order also finds backend.db.save_order.

A name shared by several items is not an error. Each match is traced separately:

Terminal window
codeknife blast --no-cache --symbol validate_total --format agent
CODEKNIFE blast status=fail files=11 errors=0 warnings=1 infos=2 elapsed_ms=3
[1] WARNING CK_BLAST_CONTRACT backend/rules.py:1-2 sym=backend.rules.validate_total impact=78 | Cross-boundary contract in `backend.rules.validate_total` touches [http:/api/orders] shared across 3 peer reference(s) | fix: Keep producer and cross-file/cross-language contract consumers synchronized.
[2] INFO CK_BLAST_IMPACT backend/rules.py:1-2 sym=backend.rules.validate_total impact=35 | Blast radius for `backend.rules.validate_total`: 5 upstream caller(s) across 6 file(s), 1 entrypoint(s), 1 test(s) | fix: Verify the impacted entrypoints and callers listed in evidence.
[3] INFO CK_BLAST_IMPACT frontend/validate.ts:1-3 sym=frontend/validate/validate_total impact=35 | Blast radius for `frontend/validate/validate_total`: 0 upstream caller(s) across 1 file(s), 0 entrypoint(s), 0 test(s) | fix: Add tests covering the affected entrypoints before modifying this symbol.

When nothing matches, the run passes with a note:

Terminal window
codeknife blast --no-cache --symbol save --format agent
CODEKNIFE blast status=pass files=11 errors=0 warnings=0 infos=0 elapsed_ms=2
NOTE no symbol matched `save` in codebase model

The changed set comes from the git working tree, plus the diff against --since when given. See Paths, Excludes & Changed Scope. After adding a new function validate_items to backend/rules.py without committing:

Terminal window
codeknife blast --no-cache --changed --format agent
CODEKNIFE blast status=fail files=11 errors=0 warnings=1 infos=2 elapsed_ms=14
[1] WARNING CK_BLAST_CONTRACT backend/rules.py:1-2 sym=backend.rules.validate_total impact=78 | Cross-boundary contract in `backend.rules.validate_total` touches [http:/api/orders] shared across 3 peer reference(s) | fix: Keep producer and cross-file/cross-language contract consumers synchronized.
[2] INFO CK_BLAST_IMPACT backend/rules.py:1-2 sym=backend.rules.validate_total impact=35 | Blast radius for `backend.rules.validate_total`: 5 upstream caller(s) across 6 file(s), 1 entrypoint(s), 1 test(s) | fix: Verify the impacted entrypoints and callers listed in evidence.
[3] INFO CK_BLAST_IMPACT backend/rules.py:5-6 sym=backend.rules.validate_items impact=35 | Blast radius for `backend.rules.validate_items`: 0 upstream caller(s) across 1 file(s), 0 entrypoint(s), 0 test(s) | fix: Add tests covering the affected entrypoints before modifying this symbol.

Every callable in a changed file is traced, not only the changed lines. With a clean working tree, --changed has no targets and the run passes with no output beyond the summary line.

Without --symbol or --changed, only functions with at least two direct callers are traced, and an impact finding is reported only when the cone spans at least 4 files and contains an entrypoint or at least 5 callers. Contract findings are info in this mode.

Terminal window
codeknife blast --no-cache --format agent
CODEKNIFE blast status=pass files=11 errors=0 warnings=0 infos=2 elapsed_ms=4
[1] INFO CK_BLAST_CONTRACT backend/rules.py:1-2 sym=backend.rules.validate_total impact=40 | Cross-boundary contract in `backend.rules.validate_total` touches [http:/api/orders] shared across 3 peer reference(s) | fix: Keep producer and cross-file/cross-language contract consumers synchronized.
[2] INFO CK_BLAST_IMPACT backend/rules.py:1-2 sym=backend.rules.validate_total impact=35 | Blast radius for `backend.rules.validate_total`: 5 upstream caller(s) across 6 file(s), 1 entrypoint(s), 1 test(s) | fix: Verify the impacted entrypoints and callers listed in evidence.
  1. CodeKnife builds a call graph from the code model. Each resolved call reference adds an edge from caller to callee.

  2. From the target, it runs a breadth-first search over incoming call edges. Every function reached is in the cone. There is no depth limit; the search stops when no new callers are found.

  3. Covering tests are collected separately: every test-code call whose target is any function in the cone (including the target) adds the calling test.

  4. Each item in the cone is classified:

    • a test item, or any item in a test file, is counted as a test
    • otherwise, an item marked as an entrypoint, a route, or any item other than the target in an entry file, is counted as an entrypoint
    • every other item except the target is a caller

    What counts as an entrypoint or entry file depends on the language. See Language Support.

  5. upstream callers is the cone size minus the target. affected files is the number of distinct files in the cone, including the target’s file.

Evidence lists covering tests first (up to 10), then callers and entrypoints while the list holds fewer than 8 entries. If a function has 8 or more covering tests, no callers appear in the evidence.

While parsing, CodeKnife scans every file for three kinds of boundary tokens:

Kind Label prefix Detected from
SQL table sql: Inside a string literal, the word after FROM, INTO, UPDATE or JOIN (case-insensitive, keyword preceded by a space). The word may contain letters, digits, _ and ., and is lowercased. Only the first occurrence of each keyword per string is used.
HTTP route http: A string literal that, without its quotes, starts with /, is longer than 2 characters, contains no space and does not start with //.
Environment variable env: process.env.NAME where NAME is at least 2 characters of uppercase letters, digits and _; or a call containing env::var(", std::env::var(", os.Getenv(", os.getenv(" or os.environ.get(" followed by a double-quoted name.

Two more kinds exist in the code with the labels wire: and flag:, but nothing produces them, so they never appear.

Each token is attached to the smallest function, method, route or test whose line range contains it. Tokens outside any function, such as a module-level constant, are not attached to anything and are never reported for a target. They still count as peers for other tokens.

For each token attached to an item in the cone, CodeKnife looks up all tokens of the same kind with the same text, compared after trimming and lowercasing. If there is more than one, the token is a contract hit. Peers are listed as evidence when they are in a different file from the token, or when the peers span more than one language. Evidence is capped at 10 entries. A CK_BLAST_CONTRACT finding is emitted only when at least one peer was listed.

Contract tokens only connect through matching text. There is no data-flow analysis. Any string such as "/etc/hosts" is recorded as an HTTP route by the rule above.

Neither rule has a fixer in the Autofix Engine. The full catalogue is on Rule Catalogue. Explicit mode means --symbol or --changed was given.

Rule ID Severity Fires when --strict effect
CK_BLAST_IMPACT warning or info Explicit mode: always, once per target. Implicit mode: affected files ≥ 4 and the cone has an entrypoint or at least 5 upstream callers. Warning when affected files ≥ 4, the cone has no tests and the target is not an entrypoint, or in explicit mode when affected files ≥ 5 and the cone has no tests. Otherwise info. none
CK_BLAST_CONTRACT warning in explicit mode, info otherwise At least one boundary token in the cone has a peer listed as evidence. none

There are no configuration keys for this blade. The file-count thresholds above are fixed in the code. Impact scores are 74 (warning) and 35 (info) for CK_BLAST_IMPACT, and 78 (warning) and 40 (info) for CK_BLAST_CONTRACT. The contract finding’s metric_value is the number of evidence entries.

Removing backend/test_service.py from the demo turns the impact finding for validate_total into a warning, because its cone of 6 files now has no tests:

[2] WARNING CK_BLAST_IMPACT backend/rules.py:1-2 sym=backend.rules.validate_total impact=74 | Blast radius for `backend.rules.validate_total`: 5 upstream caller(s) across 6 file(s), 1 entrypoint(s), 0 test(s) | fix: Add tests covering the affected entrypoints before modifying this symbol.
Flag Default Effect
--symbol <SYMBOL> none Trace the matching items. See How –symbol matches.
--changed off Trace every callable in changed files. Ignored for target selection when --symbol is given, but still turns on explicit mode.
--since <REF> none Base ref for the changed set.
--path, --format, --no-cache, --max-items, --strict Global flags. --strict does not change this blade. See CLI Reference.
  • check: when --changed is given and the changed set is not empty, the static suite runs blast in --changed mode and adds its findings to the gate. Without --changed, check does not run blast. A contract warning therefore fails check --changed. See The Check Gate.
  • test: Smart Test Selection runs blast in --changed mode over the changed files and selects every test listed in the resulting cones, alongside its other selection rules.
  • mutate: Mutation Testing traces each mutated function with blast to find the tests that cover it, and narrows the test command to them when it can.
  • dossier and plan --grouped include cone data for their targets. See Dossier and Work Orders (plan).

The CLI reports only findings. The cone details (callers, entrypoints, tests, boundary hits) are used internally by these commands and are not printed by codeknife blast.

Code Meaning
0 No warning or error findings remain after the baseline is applied.
1 At least one warning or error finding.
2 The command failed, for example because codeknife.toml could not be parsed.

The MCP tool codeknife_blast runs the same analysis and returns the JSON report. It accepts symbol, changed, since, path and no_cache. See MCP Tools.