You use AI to write code. Reading every line defeats the purpose.
Invar provides mechanical verification so you can trust AI output without manual review.
Invar handles mechanical correctness. You focus on business logic.
• Contracts exist (boundaries were considered)
• Contracts aren't empty placeholders
• Doctests pass (behavior is proven)
• Pure logic has no I/O calls
• Code size limits respected
• Whether contracts match business requirements
• Whether edge cases are covered
• Whether the architecture is correct
• Whether to ship
Choose depth based on your needs
Principles that make AI code verifiable
Pure logic (Core) and I/O (Shell) must be physically separate
Define COMPLETE boundaries that uniquely determine implementation
Read map → signatures → implementation (only if needed)
Break complex tasks into sub-functions before implementing
If fail: Reflect (why?) → Fix → Verify again
Verify all feature paths connect; local correctness ≠ global correctness
AI follows this workflow for every task
| Intent | Core function (pure logic, no I/O) |
| Contract | @pre: price > 0, discount ∈ [0,1]. @post: result ≥ 0 |
| Inspect | invar sig — check existing patterns |
| Design | File size OK, no extraction needed |
| Implement | Write code with contracts and doctest |
| Verify | invar guard — Smart Guard runs static + doctests |
First-class tools for AI agents
invar init creates .mcp.json automatically
Every law is grounded in research
pip install python-invar
invar init
AI follows INVAR.md
MCP server included by default