Skip to content

Findings Model

Every blade reports problems as the same Finding structure, and every analysis command wraps its findings in one RunReport. Read this page when you consume --format json output, write tooling around CodeKnife, or want to know why a finding’s ID changed. How each format renders these fields is on Output Formats & Exit Codes.

Change a function that two others call, then ask the Blast Radius blade about it:

Terminal window
codeknife --no-cache --changed --format json blast
{
"command": "blast",
"root": ".../ev",
"files_scanned": 3,
"elapsed_ms": 3,
"errors": 0,
"warnings": 0,
"infos": 1,
"passed": true,
"findings": [
{
"id": "abdd8bb5bb9ae3c4",
"rule": "CK_BLAST_IMPACT",
"blade": "blast",
"severity": "info",
"location": {
"file": "src/core.rs",
"start_line": 1,
"end_line": 3,
"symbol": "ev::core::price"
},
"message": "Blast radius for `ev::core::price`: 2 upstream caller(s) across 2 file(s), 0 entrypoint(s), 0 test(s)",
"fix_hint": "Add tests covering the affected entrypoints before modifying this symbol.",
"impact_score": 35.0,
"metric_value": 2.0,
"picture": {
"kind": "bar",
"label": "blast",
"length": 2,
"most": 30
},
"evidence": [
{
"file": "src/api.rs",
"line": 3,
"label": "caller: ev::api::quote"
},
{
"file": "src/api.rs",
"line": 7,
"label": "caller: ev::api::bulk"
}
]
}
]
}

The run passed (exit code 0) because its only finding is info.

Field JSON type Always present Meaning
id string yes 16 lowercase hex characters. See Finding IDs.
rule string yes The rule ID, for example CK_BLAST_IMPACT. The full list is on Rule Catalogue.
blade string yes Which blade produced it. See Blade.
severity string yes info, warning or error. See Severity.
location object yes Where the problem is. See Span.
message string yes What is wrong, in one sentence.
fix_hint string yes What to do about it.
impact_score number yes 0 to 100. See Impact score.
metric_value number no The measured value behind the finding, such as a line count, parameter count, CRAP score or number of callers. Omitted when the rule has no single metric.
picture object no Data for an ASCII diagram. See AsciiPicture.
evidence array no Related locations. See Evidence. Omitted when empty.
autofix object no A text edit. See Autofix.

location is a Span:

Field Type Always present Meaning
file string yes Path relative to the analysis root, with / separators. Some rules use a directory here, for example CK_ARCH_WIDE_DIR.
start_line integer yes First line, 1-based.
end_line integer yes Last line, 1-based, inclusive.
start_byte integer no Byte offset of the start in the file.
end_byte integer no Byte offset of the end.
symbol string no The qualified name of the function, type or module, when the finding is about one.

Byte offsets are set by the Comments blade on comments it can strip:

{
"id": "a4dc669a4bf3c6c9",
"rule": "CK_CMT_BANNER",
"blade": "comments",
"severity": "info",
"location": {
"file": "src/core.rs",
"start_line": 2,
"end_line": 2,
"start_byte": 34,
"end_byte": 63,
"symbol": "price"
},
"message": "strippable comment: section divider banner",
"fix_hint": "Run `codeknife comments --strip --write` to remove safely.",
"impact_score": 25.0
}

evidence is a list of RelatedSpan objects, each with file, line and a free-text label. Rules that set it include CK_BLAST_IMPACT (the callers), CK_BLAST_CONTRACT, CK_CLONE_BLOCK, CK_CLONE_REINVENTED_HELPER, CK_ARCH_FIELD_LEAK, CK_ARCH_MODULE_CYCLE and CK_CHURN_TEMPORAL_COUPLING.

picture holds the data for a small box-drawing diagram that the Human and Agent formats draw. In JSON it is an object whose kind field picks one of four shapes:

kind Fields Set by
circle steps (list of member, site, uses), rest (string or null) CK_ARCH_MODULE_CYCLE, CK_ARCH_TANGLE
spread owner, field, modules and others (lists of [name, count] pairs) CK_ARCH_FIELD_LEAK
lists shown, hidden, lists (list of [name, count] pairs) CK_ARCH_SHALLOW_MODULE
bar label, length, most CK_ARCH_LONG_FILE, CK_ARCH_WIDE_DIR, CK_BLAST_IMPACT, CK_CHURN_HOTSPOT

autofix is a TextEdit with file, start_byte, end_byte and replacement.

Value Counts toward Fails the run
info infos no
warning warnings yes
error errors yes

Severities are ordered from lowest to highest: info, warning, error. A finding’s severity is fixed by its rule and, for some rules, by how far over the threshold it is or by strict mode. See each blade page.

blade is one of: comments, arch, clones, dead, slop, sec, tests, mutate, churn, blast, deps, docs, map, guard. guard covers suppression checks such as CK_GUARD_SUPPRESSION_EXPIRED. map exists in the enum, but the map command reports no findings.

impact_score ranks findings within a severity. When a rule does not set it, it defaults by severity:

Severity Default impact
error 70
warning 40
info 15

Most rules set their own value, which is clamped to 0 through 100. For example CK_ARCH_TOO_MANY_PARAMS uses 45 and CK_BLAST_IMPACT uses 35 in the samples on this page. CK_TEST_HIGH_CRAP uses the CRAP score itself, capped at 95.

codeknife plan rewrites impact_score in its output. For each finding it computes:

min(100, impact_score * (1 + min(churn_commits, 10) * 0.1) + min(max_crap_in_file, 30) * 0.4)

where churn_commits is the file’s commit count in the churn window and max_crap_in_file is the highest CRAP score of any function in that file. See Work Orders (plan).

Findings in a report are sorted by:

  1. severity, highest first;
  2. impact_score, highest first;
  3. location.file, A to Z;
  4. location.start_line, lowest first;
  5. rule, A to Z.

plan uses its own order: the rewritten score, then severity, file and line.

The id is the xxh3 64-bit hash, as 16 lowercase hex digits, of this string (fields separated by tab characters):

<rule> <location.file> <location.symbol, or "-" when there is none> <location.start_line>

For the CK_ARCH_TOO_MANY_PARAMS finding on chg::d::d at src/d.rs line 1, that string hashes to 30cb77310e4fe806, which is the id CodeKnife printed.

The ID is stable when the message, severity, impact, metric, end line or configured threshold change. Raising or lowering max_params changed the message from (limit 5) to (limit 3) but kept 30cb77310e4fe806. The ID changes when the rule, file path, symbol name or start line changes. Inserting one blank line above the function moved it to line 2 and the ID became 7665c23f5a462bbb:

30cb77310e4fe806 CK_ARCH_TOO_MANY_PARAMS src/d.rs 1 `d` takes 6 parameters (limit 5)
30cb77310e4fe806 CK_ARCH_TOO_MANY_PARAMS src/d.rs 1 `d` takes 6 parameters (limit 3)
7665c23f5a462bbb CK_ARCH_TOO_MANY_PARAMS src/d.rs 2 `d` takes 6 parameters (limit 5)

The single-blade commands, check, plan, map and the MCP tools codeknife_check and codeknife_blast each build one RunReport. (score, dossier, reuse, fix, test and verify have their own report shapes, documented on their pages.) In JSON it is the top-level object.

Field Type Always present Meaning
command string yes The command name, for example check or blast.
root string yes Absolute path of the analysis root.
files_scanned integer yes Number of source files in the code model.
elapsed_ms integer yes Wall time from the start of the command to the report.
errors integer yes Count of error findings in findings.
warnings integer yes Count of warning findings.
infos integer yes Count of info findings.
passed bool yes See below.
findings array yes The findings, sorted as described above.
loosenings array of strings no Config or baseline weakenings found by the guard. Omitted when empty. See Loosening Guard.
notes array of strings no Informational lines, such as which coverage report was loaded. Omitted when empty.
pr_brief object no The PR risk brief. See below.

The counts and findings are taken after the baseline has been applied: findings covered by codeknife.baseline are removed and a note such as 3 finding(s) suppressed by codeknife.baseline is added. plan and map ignore the baseline at this step (plan applies it earlier itself).

passed is false when any remaining finding is a warning or error, or when loosenings is not empty. plan and map always report passed: true. A report that did not pass exits with code 1. A run that stops with an error exits with code 2. Full table: Output Formats & Exit Codes.

pr_brief is a reviewability summary of a change set. It appears in the report of check --changed, plan --changed and the MCP codeknife_check tool called with changed: true. Other commands do not include it in their output.

A real brief from check --changed --format json after adding a branch to a function covered by an LCOV report:

{
"changed_files": 2,
"directories_touched": 2,
"diff_crap_max": 16.798828125,
"new_suppressions": 0,
"new_dependencies": 0,
"review_risk": "medium",
"hotspots": [
"src/lib.rs",
"Cargo.lock"
]
}
Field Type How it is computed
changed_files integer Number of paths in the change set, including non-source files such as Cargo.lock.
directories_touched integer Number of distinct parent directories of those paths (files in the root count as .).
diff_crap_max number or null Highest CRAP score among functions in changed files whose line range overlaps an added or modified line. null when no coverage report was loaded or no such function exists.
new_suppressions integer Number of findings whose rule starts with CK_GUARD_.
new_dependencies integer Number of CK_DEP_PHANTOM and CK_DEP_SLOPSQUAT_RISK findings.
review_risk string high, medium or low (below).
hotspots array of strings Up to 5 changed paths, ranked by churn_commits * 2 + findings_in_file * 5, ties broken by path.

review_risk is:

  • high when there is any error finding, any loosening, or diff_crap_max is 30 or more;
  • otherwise medium when there is any warning finding, more than 10 changed files, or more than 4 directories touched;
  • otherwise low.

How the change set is built, and its edge cases, are on Paths, Excludes & Changed Scope.

  • The MCP tools codeknife_check and codeknife_blast build the same RunReport and Finding data. See MCP Tools.
  • --format sarif, markdown, human and agent render the same data. See Output Formats & Exit Codes.