feat: add check command for CI validation predicates#225
Conversation
Add `codegraph batch <command> [targets...]` CLI command, `batchData()` programmatic API, and `batch_query` MCP tool. Runs the same query against multiple targets in one call, returning all results in a single JSON payload with per-target error isolation. Supports 10 commands: fn-impact, context, explain, where, query, fn, impact, deps, flow, complexity. Accepts targets via positional args, --from-file (JSON array or newline-delimited), or --stdin. Impact: 3 functions changed, 3 affected
Impact: 1 functions changed, 1 affected
Composable validation predicates that run against git changes (staged or vs a ref) and return exit code 0/1 for CI gates and pre-commit hooks. Four predicates: --cycles (no dependency cycles involving changed files), --blast-radius <n> (no function exceeds N transitive callers), --signatures (no function declaration lines modified), --boundaries (no cross-owner CODEOWNERS violations). All boolean predicates enabled by default; configurable via .codegraphrc.json `check` section. Impact: 7 functions changed, 3 affected
Greptile SummaryIntroduced Major Changes:
Code Quality:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Start([codegraph check ref]) --> LoadConfig[Load .codegraphrc.json config]
LoadConfig --> VerifyGit{Git repository?}
VerifyGit -->|No| ErrorExit[Return error]
VerifyGit -->|Yes| RunDiff[Execute git diff]
RunDiff --> ParseDiff[parseDiffOutput: Extract changed/old ranges]
ParseDiff --> HasChanges{Changes detected?}
HasChanges -->|No| EmptyResult[Return passed: true, predicates: empty]
HasChanges -->|Yes| ResolvePredicates[Resolve enabled predicates: CLI → config → defaults]
ResolvePredicates --> Cycles{Cycles enabled?}
Cycles -->|Yes| CheckCycles[checkNoNewCycles: findCycles + filter changed files]
Cycles -->|No| BlastCheck
CheckCycles --> BlastCheck
BlastCheck{Blast-radius threshold set?}
BlastCheck -->|Yes| CheckBlast[checkMaxBlastRadius: BFS transitive callers for changed functions]
BlastCheck -->|No| SigCheck
CheckBlast --> SigCheck
SigCheck{Signatures enabled?}
SigCheck -->|Yes| CheckSig[checkNoSignatureChanges: Match declaration lines against old ranges]
SigCheck -->|No| BoundCheck
CheckSig --> BoundCheck
BoundCheck{Boundaries enabled?}
BoundCheck -->|Yes| CheckBound[checkNoBoundaryViolations: Parse CODEOWNERS + match cross-owner edges]
BoundCheck -->|No| Aggregate
CheckBound --> Aggregate
Aggregate[Aggregate predicate results] --> Summary[Build summary: total/passed/failed counts]
Summary --> Format{JSON output?}
Format -->|Yes| JSONOut[Print JSON + exit with code]
Format -->|No| PrettyOut[Print formatted results + exit with code]
JSONOut --> End([Exit 0 if passed, 1 if failed])
PrettyOut --> End
Last reviewed commit: 49c8f4c |
Impact: 8 functions changed, 8 affected
|
Claude finished @carlos-alm's task —— View job PR Review:
|
Summary
codegraph check [ref]command with composable validation predicates that run against git changes (staged or vs a ref) and return exit code 0/1 for CI gates and pre-commit hooks--cycles(no dependency cycles involving changed files),--blast-radius <n>(no function exceeds N transitive callers),--signatures(no function declaration lines modified),--boundaries(no cross-owner CODEOWNERS violations)--blast-radiusonly when explicit threshold provided; configurable via.codegraphrc.jsonchecksectionfindCycles(Tarjan SCC),diffImpactDataBFS pattern,parseCodeowners/matchOwnersboundary detectionTest plan
tests/integration/check.test.js)parseDiffOutputunit tests for new-side/old-side range extraction and new file detectioncodegraph check main -T,codegraph check --staged --json,codegraph check main -T --blast-radius 5