Test fidelity
A green suite says the tests passed, not that they still test the code. A double that stubs a method the class lost, or an assertion that compares a stubbed value with itself, passes every run. Knossos reads a project's tests as facts beside its code, and the test-fidelity rules judge them: test doubles that no longer match the code they replace, assertions that cannot fail, tests that check only their doubles, and fixtures that no longer fit their type. It judges TypeScript and JavaScript, PHP, Python and Rust tests, and never runs them.
| Tool | CLI | Answers |
|---|---|---|
audit_tests | audit-tests | The findings: stored ones by default, on-request ones when asked. |
verify_test_doubles | verify-test-doubles | Every double of one symbol, and whether each still fits. |
check_fixtures | check-fixtures | JSON and YAML fixtures that no longer fit the type they hold. |
synthesize_mock | synthesize-mock | A mock template for a symbol, in the project's framework. |
list_test_rules | list-test-rules | Every rule, its tier, confidences and sub-rules. |
Agent integration says at which point of a change an agent calls each one, and the MCP tool reference has every field.
What the rules find
Each finding names its category and sub-rule (GHOST_MEMBER/missing_member) and its rule id (test.fidelity.ghost_member.v1). list_test_rules prints the same catalogue.
The scan tier is judged at every scan and stored with the graph:
| Category | Sub-rules | Finds | Confidence |
|---|---|---|---|
GHOST_MEMBER | missing_member, missing_export, missing_module | A double stubs a member, export or module its target does not have. | definite or warning |
ARITY_MISMATCH | call_arity, signature, argument_type, enum_case | A double's member takes another number of arguments than the member it replaces, or a matcher lists a literal its parameter's type or enum refuses. | definite or warning |
RETURN_DRIFT | return_type | A double pins a value the replaced member's declared return type does not admit. | definite or warning |
VISIBILITY_BREACH | visibility | A double replaces a member that is not visible to it. | definite or warning |
TAUTOLOGY | self_comparison, mock_echo, constant, zero_reach, unconfigured_spy, mock_only, vacuous_negation | An assertion that cannot fail: a value compared with itself, a stub's pinned value read back, constants only, a double nothing reaches, a test that checks only doubles. | definite or warning |
MOCKS_SUBJECT | mock_of_self | A test replaces the module it is testing. | warning |
The on-request tier is computed only when asked, and never stored:
| Category | Sub-rules | Finds | Confidence |
|---|---|---|---|
OVER_MOCKING | saturation | At least 7 in 10 of a test file's dependencies are doubles, and fewer than 2 of its assertions read production code. | warning |
STALE_SINCE | stale_mock | A double's target changed since a git ref while the double's own file did not. | warning |
FIXTURE_DRIFT | missing_required, unknown_key, kind_mismatch, not_a_case | A JSON or YAML fixture no longer matches the type whose records it holds. | warning |
Definite and warning
A finding is definite when the code itself proves it: the class's member list is complete and lacks the stubbed name, the declared return type refuses the pinned value, or both sides of an assertion are the same literal. It is a warning when the proof rests on something the scan cannot see whole, such as a class it does not hold, a return type that is only inferred, or a language that enforces the type at no point. Each on-request finding is a warning, since it rests on a ratio, a changed file or a match by name and shape.
A healthy test gives nothing. The rules are written so that a test which exercises real code through doubles that still fit reports no definite finding, and where the evidence runs out a rule stays silent rather than guess. So silence is not a pass: each language page lists what its rules do not see.
Scan tier and on-request tier
The scan tier costs little, so it runs on every scan, full or incremental, and its findings are stored. That is what lets them reach the model, the pane, the gate and the history:
- The model is told of the definite findings a turn introduced, at the end of that turn, and of the doubles of a file it reads that no longer match (messages for the model). Warnings are not said.
- The pane lists every stored finding, definite ones first, then warnings, on the Issues tab's Test findings card (the Issues tab); the tab's badge counts the definite ones.
audit_testslists them with a stablekey, filtered bypath_prefix,categoryorconfidence.
The on-request tier reads more of the graph and of git, so it runs only when audit_tests is called with tier: "on_request" or "all", or check_fixtures is called. scope: "git-diff" with a base_ref gives STALE_SINCE and narrows the stored findings to the diff; OVER_MOCKING and FIXTURE_DRIFT still cover the whole project. timeout_ms bounds the run, and past it the result says it is partial.
knossos audit-tests . --confidence=definite
knossos audit-tests . --tier=all --scope=git-diff --base-ref=main
knossos check-fixtures . tests/fixtures/verify_test_doubles lists the doubles of one class, interface or trait with their stored findings, before you change it. synthesize_mock writes a template from the symbol's real signatures, in the framework the project's own doubles use; it lists what it could not render under omitted.
Per language
The rules hold each language to its own semantics, so the same category can be definite in one language and a warning in another:
- TypeScript and JavaScript: vitest and jest doubles, spies and manual mocks under
__mocks__/.privateandprotectedhold at compile time only, so a double of one is a warning; an ECMAScript#nameis definite. The checks on matcher literals, cast pins and promise shapes are under field facts. - PHP: PHPUnit, Mockery, Pest, Prophecy and Laravel's doubles. Visibility holds at run time, and PHPUnit checks a pinned value strictly. See how the rules judge PHP tests.
- Python:
unittest.mockand pytest-mock. No annotation is enforced at run time, so a type a double breaks is a warning at most, while a name or a call the runtime would refuse is definite. See how the rules judge Python tests and what the Python rules do not see. A patch target such aspatch("pkg.mod.x")resolves against the repo root,src/, the package directories a build backend declares and pytest'spythonpath. Only the rootpyproject.toml'spythonpathis read:pytest.ini,setup.cfg,tox.iniand asys.pathedit in a conftest are not. - Rust: mockall and hand-written fakes. The compiler already rejects a double that no longer fits its trait, so the drift rules skip Rust doubles, and its findings are assertions that cannot fail. See how the rules judge Rust tests, known false definites and what the Rust rules do not see.
Some silences cross languages:
ARITY_MISMATCH/enum_casejudges PHP only.MOCKS_SUBJECTis silent for Rust, and for Python until a double names its test case.OVER_MOCKINGjudges PHP from the classes a test file imports or names, counting each as a module;use functionanduse constare not counted. Every namespaced class the test names counts, with or without ause, and an imported class counts even if nothing names it; a global class like\RuntimeExceptiondoes not when named without ause. A namespace import, such asuse App\Models;forModels\User::class, counts only for the classes named through it. A PHP suite that imports and names no class has no import edges, so the rule is silent for it, andby_languagein the result says so.- In PHP, an anonymous subclass is not read as a double, and nothing judges constructor drift or whether a final class, final method or static method can be doubled at all.
STALE_SINCEcompares changed files, not changed lines.FIXTURE_DRIFTreads JSON and a subset of YAML (no anchors, aliases, tags, merge keys or second documents) and no other format. A type whose wire names may differ from its field names, such as one with serde or pydantic renames, is never matched.
Configuration
Two settings govern test fidelity, in two places:
testChecks, a setting of the Claude Code plugin,trueby default (settings). Off, it stops the test-finding lines of the Read and turn-end messages. It changes only what the model is told: the scan still judges the tests, and the pane andaudit_testsstill list the findings.test_finding_suppressionsin the project'sknossos.json(test-finding suppressions). Each entry names arule(a category, a category and sub-rule, or a full rule id), optionally apathprefix, and areason. It is read on every call, so an edit applies without a scan, and it is the only way to silence an on-request finding.
{
"version": 1,
"test_finding_suppressions": [
{
"rule": "GHOST_MEMBER/missing_member",
"path": "tests/legacy/",
"reason": "generated stubs"
}
]
}In the gate, the history and SARIF
The stored findings are archived with each snapshot, so the tools that compare scans compare them too. Suppressions apply to both sides, and a finding that only moved lines is not new.
- The quality gate: the
new_definite_test_findingsbudget counts the definite findings the baseline lacks; warnings never count. A baseline archived before findings were stored makes the check indeterminate. See quality budgets. - SARIF:
quality_gatewith--sarifincludes the test findings, each with the rule id and sub-rule as itsruleId, at levelerrorwhen definite andwarningotherwise. - The history:
snapshot_diffhas atest_findingssection, and eacharchitecture_trendspoint carriesdefinite_test_findingsandstale_test_findings. See test findings in a diff.
On-request findings are in none of these: no snapshot, trend, gate budget or model message holds them.