tpt-telos
tpt-telos is a compiler for the tpt-telos language: a formally-specified, verification-first source language that lowers to both Rust and Go behind an automatic FFI bridge.
The pipeline is:
parser → IR / constraint extraction → SMT-style verifier → agentic transpiler
→ context router → Rust/Go codegen → FFI bridge → eject hatch → LSP
Every func carries requires/ensures contracts that are extracted to
QF_LRA linear arithmetic and discharged by a self-contained
Fourier–Motzkin SMT-style solver — no external Z3 dependency is required to
build or run.
Status: v1.2, Phase 7 and Phase 8 complete (see
TODO.md). Counterexamples are surfaced bytelos verify/buildand the LSP; structs, enums, boundedforall/aggregates, disjunction, and modularCall/MethodCallverification are all wired intotelos-ir/telos-codegen.
Install
Or build from this workspace:
Usage
# Scaffold a starter module
# Parse and type/contract-check a .telos file
# Run formal verification (requires/ensures → QF_LRA); prints a counterexample on FAIL
# Machine-readable output for CI/editors, or watch the file and re-verify on save
# Exact nonlinear arithmetic via Z3 (requires building with --features z3)
# Transpile to a single self-contained Rust file
# Build a verified, compiling Rust crate (writes telos-proof.json alongside it)
# Generate a dual Rust+Go project with the FFI bridge
# Fail the build if a real_time/zero_allocation module got routed to Go
# Eject a function to a hand-tunable opaque block wrapped by a contract guard
# Re-hash source against a previously generated telos-proof.json to detect drift
# Run the language server (JSON-RPC 2.0 over stdio)
LLM-backed agent
By default the agentic transpiler runs the fully offline StaticAgent. To use a
real LLM backend, build with the llm feature and pass --llm:
At runtime it needs TELAS_LLM_KEY and TELAS_LLM_PROVIDER
(openai default | ollama | openrouter | grok | anthropic); optionally
TELAS_LLM_MODEL / TELAS_LLM_URL / TELAS_LLM_MAX_TOKENS.
Crates
| Crate | Purpose |
|---|---|
tpt-telos |
The telos binary and CLI surface (incl. init/verify-manifest, --json/--watch/--strict-rt/--solver). |
tpt-telos-parser |
Lexer, parser, and AST. |
tpt-telos-ir |
AST → IR lowering + QF_LRA constraint extraction, disjunction/DNF, bounded forall/aggregates, modular Call/MethodCall verification. |
tpt-telos-verifier |
Self-contained Fourier–Motzkin SMT-style solver, plus an optional Z3 backend (--features z3) and a gRPC solver cluster. |
tpt-telos-router |
Classifies modules to Rust/Go/Python from @boundary(...), storage class from @state(...), and real-time/Go conflict warnings. |
tpt-telos-agent |
CodeAgent trait: StaticAgent + LlmAgent (behind llm). |
tpt-telos-codegen |
Rust/Go/Python backends, FFI bridge, eject, project assembly, cryptographic proof manifest. |
tpt-telos-lsp |
JSON-RPC 2.0 language server over stdio (diagnostics, hover, quick-fix code actions, telos/verify, telos/eject). |
License
Licensed under either of:
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.