Determinism & Limits
Canontra is explicit about what it proves mathematically and where static analysis stops.
What Equivalence Means (Rice’s Theorem)
Section titled “What Equivalence Means (Rice’s Theorem)”By Rice’s Theorem, no algorithm can decide whether two arbitrary programs always produce the same output for every possible input. Canontra does not claim to solve general program equivalence.
Instead, Canontra guarantees exact equivalence under a documented, finite set of normalization rules:
Two programs that compute the same answer using completely different algorithms (for example, iterative vs. recursive Fibonacci) will intentionally produce different F1 and F4 fingerprints.
Verified Properties (795 Automated Tests)
Section titled “Verified Properties (795 Automated Tests)”Canontra’s verification suite (test/Canontra/MetamorphicSpec.hs, 795 passing tests under stack test --pedantic) tests seven properties across Python, JavaScript/TypeScript, Go, and Rust:
- Cosmetic Invariance: Formatting, comments, docstrings, dead
passstatements, and independent helper function order keepF1,F2,F_T, andF4identical. - Mutation Sensitivity: Logic edits (operator flips, constant changes, negated branch conditions, signature edits) change
F1andF4. - Local Rename Invariance: Renaming local variables preserves
F1,F_DF, andF4under language-specific rules (canonicalizeAlphaModuleForLang), whileF2remains sensitive to exported function and parameter names. - Guarded Algebraic Equivalence: Pure non-trapping integer/bitwise swaps (
a + bvsb + a), relational flips (b > avsa < b), and double negations (not (not x)vsx) keepF1identical;isNonTrappingPureExprandcontainsFloatOperandblock unsafe reordering of side-effecting calls, trapping expressions, or IEEE-754 floats. - Control-Flow Equivalence: Flipped branches and early-return guard clauses with identical execution paths produce identical
F_CFdigests under Lengauer-Tarjan dominator and RPO numbering. - Type Contract Compatibility: Backwards-compatible extensions (such as extra optional fields) update
F2while staying subtype-compatible underF_T; breaking width (i32vsi64) or mutability (&Tvs&mut T) changes divergeF_T. - Impact Reachability Soundness:
computeBatchImpactSliceCSRreturns every symbol reachable from modified files along directed call edges, avoiding false negatives in test selection.
Bit-Identical Results Across Operating Systems
Section titled “Bit-Identical Results Across Operating Systems”The same repository produces identical SHA-256 hashes on Linux (x86_64/ARM64), macOS (Apple Silicon), and Windows (AMD64/ARM64):
- Line Ending Normalization: 256-bit ByteString/SWAR/SIMD scanning (
Canontra.Canonical.SIMDScan) converts\r\nto\nbefore parsing. - Unicode NFC Normalization: Identifiers normalize to Unicode Canonical Composition (
NFC) viaCanontra.Canonical.Unicode. - IEEE-754 Float Normalization:
-0.0normalizes to+0.0, and all NaN payloads normalize to a single quiet NaN bit pattern (Canontra.Canonical.Float). - Big-Endian Serialization: Integers, lengths, and 1-byte AST tags serialize in network byte order regardless of CPU endianness (
Canontra.Canonical.Serialize). - Case-Folded POSIX Path Sorting: Paths normalize to
/and sort deterministically across case-sensitive Linux (ext4) and case-insensitive Windows (NTFS).
Hard Resource Limits
Section titled “Hard Resource Limits”To bound memory usage and prevent crashes on malformed or adversarial repositories (Canontra.Security.Path):
| Resource Guard | Limit | Behavior When Exceeded |
|---|---|---|
| Maximum Single File Size | 50 MB (52,428,800 bytes) |
File is skipped and reported |
| Maximum Directory Depth | 64 levels |
Deeper directories are rejected |
| Symlink and Junction Loop Detection | FileNodeIdentity (fniVolumeID, fniFileID) |
Circular links are cut before recursion overflows |
| Graph and Dominator Passes | Finite bounded iteration | Guaranteed termination on cyclic control-flow graphs |
| Null-Byte Path Guard | \0 prohibited |
Rejected immediately with Exit Code 4 |
Known Parser Limitations
Section titled “Known Parser Limitations”- Dynamic Evaluation: Runtime features such as Python
eval()/exec()/getattr(), JavaScriptProxy/ dynamicimport(), or Goreflectare hashed as literal AST calls; Canontra does not execute code or guess dynamic call targets. - Rust Macro Expansion:
macro_rules!and procedural macros (#[derive(...)], attribute macros) are hashed at their surface syntax and token-tree structure rather than expanded withrustc, because Canontra never invokes external compilers. - Not a Taint Security Scanner: Canontra computes deterministic code fingerprints and test impact slices; it does not replace inter-procedural security taint engines such as CodeQL.