impact & slice
Synopsis
Section titled “Synopsis”canontra impact <FILE> [-b|--base BASE_FILE] [-r|--repo DIR] [--json]canontra impact --pr-base <GIT_REF> [-r|--repo DIR] [--json]canontra slice <SYMBOL> [-r|--repo DIR] [--json]Description
Section titled “Description”impact <FILE>: ComparesFILEagainstBASE_FILE(orgit show HEAD:<FILE>if--baseis omitted), builds the repository call graph, and lists downstream callers and matching test suites.impact --pr-base <GIT_REF>: Analyzes an entire Pull Request (Canontra.Analysis.BatchImpact). Runsgit diff --name-only <GIT_REF>, sorts each changed source file into Level 1 (Cosmetic / Trivia), Level 2 (Internal Logic), or Level 3 (Public API / Imports), walks the compact CSR call graph (backwardReachabilityCone) to find transitive callers, and outputs a ready-to-run test command (birTestCommand).slice <SYMBOL>: Looks up a symbol by name (verifyorauth.verify) across the repository call graph and prints its direct callers, transitive callers, affected files, matching tests, and outgoing calls.
| Flag | Short | Default | Description |
|---|---|---|---|
--pr-base <GIT_REF> |
- |
- |
Base Git ref for Pull Request batch impact analysis (e.g. main, origin/main, HEAD~1) |
--base <BASE_FILE> |
-b |
git HEAD |
Baseline file for single-file impact comparison |
--repo <DIR> |
-r |
. |
Repository root directory |
--json |
- |
false |
Print ImpactSlice, BatchImpactResult, or symbol slice as JSON |
Output Schema & Exit Codes
Section titled “Output Schema & Exit Codes”canontra impact --pr-base <GIT_REF> --json outputs BatchImpactResult:
{ "birModifiedFiles": ["src/auth.py", "src/formatting_only.py"], "birLevel1TriviaFiles": ["src/formatting_only.py"], "birLevel2LogicFiles": [], "birLevel3ApiFiles": ["src/auth.py"], "birTransitiveCallers": ["src/routes/login.py"], "birImpactedTests": ["tests/test_auth.py", "tests/test_login.py"], "birTotalRepoTests": 42, "birSavedComputePct": 95.24, "birTestCommand": "pytest tests/test_auth.py tests/test_login.py"}impact: Exits0on completion;3on parse error;4if--repo, target file, orgit difffails.slice: Exits0when the symbol is found; exits1when the symbol is missing from the repository index.
Examples
Section titled “Examples”# Multi-file PR impact slice against origin/maincanontra impact --pr-base origin/main --json
# Single-file impact against a saved baselinecanontra impact src/router.go -b /tmp/router.old.go -r .
# Upstream callers and downstream calls for one symbolcanontra slice calculate_discount --repo . --json