check_invariant
Check code invariants on the fly using Datalog rules. Returns violations with file and line details for quick audits or pre-commit checks.
Instructions
Check a one-off code invariant using a Datalog rule. Returns violations if broken.
Use this for ad-hoc checks without saving a permanent guarantee. For persistent rules, use create_guarantee + check_guarantees instead.
Use cases:
Quick check: "Are there any eval() calls?" — rule: violation(X) :- node(X, "CALL"), attr(X, "name", "eval").
Audit: "Functions over 100 lines?" — check for excessive complexity
Pre-commit: "Any new SQL injection risks?" — one-time check before pushing
Returns: List of nodes violating the rule, with file and line info.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"rule": "<rule>"
},
"name": "check_invariant"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rule | Yes | Datalog rule defining violation/1 | |
| description | No | Human-readable description | |
| limit | No | Max violations (default: 10) | |
| offset | No | Skip first N violations (default: 0) |