Skip to content

Overview & Exit Codes

canontra <COMMAND> [ARGS] [OPTIONS]
canontra <TARGET> [--json | --hash | -q] [--cache]

canontra provides a single, zero-network command-line tool built with optparse-applicative. If you pass a file or folder directly without a subcommand, canontra runs fp on files (or - stdin) and repo on directories.

Command Alias Purpose Reference
fingerprint fp Compute 9 fingerprint tiers for a file or - stdin fp & repo
repository repo Compute repository root F_R and cross-file graphs fp & repo
commit - Fingerprint repository state at a Git commit or ref fp & repo
evolution - Compare semantic changes between two Git revisions fp & repo
watch w Watch files live and update the repository DAG fp & repo
compare - Compare two files (0 if identical, 1 if different) compare & diff
diff - Show function, import, AST, CFG, and DFG changes compare & diff
impact - Single-file or --pr-base affected test slicing impact & slice
slice - List upstream callers and outgoing calls for a symbol impact & slice
graph - Print scope tree, call graph, imports, CFG, or DFG graph & export
export - Export OASIS SARIF v2.1.0 diagnostics or Graphviz DOT graph & export
cache - Inspect, CRC-verify, prune, or clean .canontra/cache.bin (CNTR\x07) cache & verify
verify - Re-run parsing and hashing N times to prove determinism cache & verify
completions - Generate shell completions (bash, zsh, fish, powershell) cache & verify
version - Print engine name and version (canontra version 0.4.0) -
snap (Alpha) - Stateless AI harness checkpoints (0.1-alpha, zero daemon, zero .git edits) snap (Alpha)
Flag Short Behavior
--json - Output structured JSON
--hash -q Output only the 64-character composite SHA-256 hash (F4 or F_R)
--help -h Show command usage and flag descriptions

Every command returns predictable exit codes so shell scripts and CI jobs can branch reliably:

Exit Code Meaning When It Happens
0 Identical / Success / Guard Pass Command succeeded; compared files match semantically; verify or snap guard passed
1 Semantic Difference / Guard Violation compare or diff found a semantic difference (F4 changed); verify failed; slice found no matching symbol; snap guard failed
2 CLI / Syntax Error Unknown flag, missing required argument, or unknown subcommand
3 Parse Error Source file failed parsing (writes file, line, column, and reason to stderr)
4 I/O or Security Error Missing file or directory, failed git call, null-byte path, or path outside the project root (canonicalizeSafePath)
Terminal window
canontra version
canontra src/main.py --hash
canontra . --cache --json