How ambrose-tang/larch-verify works
Larch verifies functions by formalizing approved contracts as Lean models, checking proofs about those models, then comparing the real implementation against the model with generated tests and mutation analysis. The CLI and interactive session also support repository scanning, contract drafting, reports, and validated fix proposals. The graph combines documented workflow stages with relationships visible in the excerpts and SOURCE INDEX; unsampled subsystem links are omitted where their callers cannot be established.
Main entry points: session.py Run orchestration · cli.py CLI · lang.py Language dispatch · chat.py Interactive drafting
Components 24
User workflows
- CLI
larch/cli.py - Interactive drafting
larch/chat.py
Repository and contracts
- Repo discovery
larch/repo.py - Contract parsing
larch/contracts.py - Language dispatch
larch/lang.py - Python backend
larch/py/backend.py - JS and TS backend
larch/js/backend.py
Verification pipeline
- Run orchestration
larch/engine/session.py - Model formalization
larch/engine/formalize.py - Formal specification
larch/spec.py - Proof workflow
larch/engine/prove.py - Differential testing
larch/engine/runner.py - Mutation analysis
larch/py/mutate.py - Findings and fixes
larch/engine/findings.py - Results and reports
larch/report.py
Execution and Lean
- Implementation adapter
larch/engine/impl_client.py - Lean workspace
larch/lean/workspace.py - Lean toolchain
larch/lean/toolchain.py - Proof checker
larch/lean/checker.py
Models and services
- LLM client and providers
larch/llm/providers.py - Run context
larch/engine/context.py - Run configuration
larch/config.py - Certificates and outputs
larch/outputs.py
Other components
- Developer
Connections 24
- Developer → CLI: invokes
- Developer → Interactive drafting: starts session
- CLI → Run orchestration: runs verification
larch/cli.py - Interactive drafting → Contract parsing: drafts contracts
larch/chat.py - CLI → Repo discovery: scans candidates
larch/cli.py - CLI → Contract parsing: loads contracts
larch/cli.py - Repo discovery → Language dispatch: discovers functions
larch/repo.py - Language dispatch → Python backend: dispatches Python
larch/lang.py - Language dispatch → JS and TS backend: dispatches JS/TS
larch/lang.py - Run orchestration → Run context: builds context
larch/engine/session.py - Run orchestration → Model formalization: formalizes model
larch/engine/session.py - Model formalization → Formal specification: produces specification
larch/engine/formalize.py - Run orchestration → Proof workflow: proves approved specs
larch/engine/session.py - Run orchestration → Differential testing: compares implementation
larch/engine/session.py - Differential testing → Implementation adapter: dispatches calls
larch/engine/runner.py - Run orchestration → Mutation analysis: runs mutation analysis
- Run orchestration → Findings and fixes: records disagreements
larch/engine/session.py - Run orchestration → Results and reports: builds report
larch/engine/session.py - Run orchestration → Certificates and outputs: writes certificate
- Proof workflow → Proof checker: checks proof
larch/engine/prove.py - Proof checker → Lean toolchain: uses Lean toolchain
larch/lean/checker.py - Lean workspace → Lean toolchain: runs Lean
larch/lean/workspace.py - Run context → LLM client and providers: requests completion
larch/engine/context.py - Run orchestration → Run configuration: uses settings
larch/engine/session.py