Semantic code analysis for the AI era. Extract structural facts from any codebase, query them with Prolog, and catch what traditional linters miss — intent mismatches, orphaned functions, and architectural drift. All extracted facts are encrypted at rest.
Traditional linters check formatting and type errors. They don't understand what your code is supposed to do. When an AI agent writes a function called validate_email that actually deletes records, no linter will catch it. Invariant extracts semantic structure — modules, functions, dependencies, call graphs — into Prolog facts, then lets you query for things that matter: intent mismatches, untested public functions, architectural violations, and consequence analysis.
Invariant CLI (local)
Structural fact extraction — modules, functions, calls, dependencies. Runs in milliseconds on your machine.
DataGrout Invariant (server)
LLM intent enrichment, Prolog-backed semantic queries, and cross-repo consequence analysis.
The CLI runs locally for speed — tree-sitter parsing extracts facts in milliseconds. Facts upload to DataGrout Invariant via the Conduit SDK with mTLS authentication and are encrypted at rest on the server. Server-side, LLMs enrich raw structure with intent classification, and Prolog enables queries no traditional tool can answer.
Native tree-sitter grammars for Python, Rust, TypeScript, TSX, JavaScript, Go, Elixir, and Ruby. Extracts modules, functions, imports, calls, and visibility — including Ruby's private/protected modifiers — in milliseconds.
Every code element becomes a queryable Prolog fact, encrypted at rest. Ask questions like "which public functions have no tests?" or "what breaks if we delete this module?"
LLM-powered enrichment classifies what each function is supposed to do. Detects mismatches between function names and actual behavior.
Compare before/after code against a stated goal. Get an alignment score, unexpected changes, and concerns — all structured and machine-readable.
First run bootstraps a machine identity automatically. No API keys to manage — subsequent runs auto-authenticate via persisted mTLS certificates.
Respects .gitignore and .ignore files natively. No manual exclusion patterns needed.
# Initialize Invariant (one-time setup) $ invariant init --url https://gateway.datagrout.ai/servers/{uuid}/mcp --token <token> # Analyze your codebase $ invariant lens Analyzing 142 files... Repo: my-project Commit: a1b2c3d4 Functions: 847 Facts: 3,291 ↑ 142 files uploaded to Invariant # Query for issues $ invariant query orphans [orphans] 12 results • module: auth.utils, function: hash_legacy, arity: 1 • module: api.v1, function: deprecated_handler, arity: 2
From zero to semantic insights in three commands. The CLI handles identity bootstrap, file scanning, fact extraction, and server upload automatically.
Validate AI-generated code against architectural invariants before merging. Catch intent mismatches, orphaned functions, and dependency violations automatically.
Before deleting a module or refactoring an interface, query the fact base to understand downstream impact across your entire codebase.
Run Invariant in CI to enforce team conventions — no untested public functions, no circular dependencies, no functions exceeding complexity thresholds.