Skip to content

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.

ToolCLIAnswers
audit_testsaudit-testsThe findings: stored ones by default, on-request ones when asked.
verify_test_doublesverify-test-doublesEvery double of one symbol, and whether each still fits.
check_fixturescheck-fixturesJSON and YAML fixtures that no longer fit the type they hold.
synthesize_mocksynthesize-mockA mock template for a symbol, in the project's framework.
list_test_ruleslist-test-rulesEvery 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:

CategorySub-rulesFindsConfidence
GHOST_MEMBERmissing_member, missing_export, missing_moduleA double stubs a member, export or module its target does not have.definite or warning
ARITY_MISMATCHcall_arity, signature, argument_type, enum_caseA 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_DRIFTreturn_typeA double pins a value the replaced member's declared return type does not admit.definite or warning
VISIBILITY_BREACHvisibilityA double replaces a member that is not visible to it.definite or warning
TAUTOLOGYself_comparison, mock_echo, constant, zero_reach, unconfigured_spy, mock_only, vacuous_negationAn 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_SUBJECTmock_of_selfA test replaces the module it is testing.warning

The on-request tier is computed only when asked, and never stored:

CategorySub-rulesFindsConfidence
OVER_MOCKINGsaturationAt least 7 in 10 of a test file's dependencies are doubles, and fewer than 2 of its assertions read production code.warning
STALE_SINCEstale_mockA double's target changed since a git ref while the double's own file did not.warning
FIXTURE_DRIFTmissing_required, unknown_key, kind_mismatch, not_a_caseA 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_tests lists them with a stable key, filtered by path_prefix, category or confidence.

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.

sh
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__/. private and protected hold at compile time only, so a double of one is a warning; an ECMAScript #name is 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.mock and 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 as patch("pkg.mod.x") resolves against the repo root, src/, the package directories a build backend declares and pytest's pythonpath. Only the root pyproject.toml's pythonpath is read: pytest.ini, setup.cfg, tox.ini and a sys.path edit 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_case judges PHP only.
  • MOCKS_SUBJECT is silent for Rust, and for Python until a double names its test case.
  • OVER_MOCKING judges PHP from the classes a test file imports or names, counting each as a module; use function and use const are not counted. Every namespaced class the test names counts, with or without a use, and an imported class counts even if nothing names it; a global class like \RuntimeException does not when named without a use. A namespace import, such as use App\Models; for Models\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, and by_language in 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_SINCE compares changed files, not changed lines.
  • FIXTURE_DRIFT reads 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, true by 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 and audit_tests still list the findings.
  • test_finding_suppressions in the project's knossos.json (test-finding suppressions). Each entry names a rule (a category, a category and sub-rule, or a full rule id), optionally a path prefix, and a reason. 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.
json
{
    "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_findings budget 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_gate with --sarif includes the test findings, each with the rule id and sub-rule as its ruleId, at level error when definite and warning otherwise.
  • The history: snapshot_diff has a test_findings section, and each architecture_trends point carries definite_test_findings and stale_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.