Skip to content

Mental Model

Standard build caches (git hash-object, sha256sum, Docker COPY layer digests, and Turborepo file hashes) hash raw file bytes. Even changing a single space or comment invalidates the hash and forces downstream rebuilds or test runs.

Canontra separates file bytes (F0) from program structure (F1 through F_T). Each fingerprint only changes when its specific layer changes.

Code Edit sha256sum / git hash-object F0 F1 F2 F3 F_CG F_CF F_DF F_T F4
Trailing spaces or CRLF vs. LF line endings BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Comments or unflagged docstrings BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Reorder independent pure helper functions BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Rename local variable (total to acc) BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Safe integer swap (a + b to b + a) BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Flip comparison (b > a to a < b) BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Flip branch (if (!c) B else A to if (c) A else B) BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Remove dead statements after return or raise BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Rename generic type params (<K, V> to <Key, Val>) BUST DIFF SAME SAME SAME SAME SAME SAME SAME SAME
Change internal math (+ to -) BUST DIFF DIFF SAME SAME SAME SAME DIFF SAME DIFF
Add internal call to another helper BUST DIFF DIFF SAME SAME DIFF SAME DIFF SAME DIFF
Change exported function signature or type width BUST DIFF DIFF DIFF SAME SAME SAME DIFF DIFF DIFF
Add or remove module import BUST DIFF DIFF SAME DIFF SAME SAME SAME SAME DIFF

When canontra impact compares two versions of a file, it translates these tier changes into three practical actions:

Level 1: Cosmetic / Trivia (F0 changed, F4 identical)

Section titled “Level 1: Cosmetic / Trivia (F0 changed, F4 identical)”
  • What changed: Formatting, comments, docstrings, line endings, local variable names, safe integer math ordering, branch polarity, or generic type parameter names.
  • What to do: Skip recompiling, skip container rebuilds, and run 0 tests.

Level 2: Internal Logic (F1, F_CF, F_DF, or F_CG changed; F2, F3, and F_T identical)

Section titled “Level 2: Internal Logic (F1, F_CF, F_DF, or F_CG changed; F2, F3, and F_T identical)”
  • What changed: Implementation inside a function changed, while its public name, parameter list, imports, and type contracts stayed identical.
  • What to do: Callers do not need to change. Run direct unit tests for the modified file rather than testing the whole repository.

Level 3: Public Interface or Dependencies (F2, F3, or F_T changed)

Section titled “Level 3: Public Interface or Dependencies (F2, F3, or F_T changed)”
  • What changed: Public function names, arguments, default values, struct/interface types, or imported modules changed.
  • What to do: Walk the cross-file call graph (Canontra.Analysis.BatchImpact) to find and test every file that calls or depends on the modified symbols.