tpt-telos-codegen
Rust/Go dual-backend code generation and FFI bridge for tpt-telos.
Part of the tpt-telos compiler workspace.
Overview
tpt-telos-codegen is the final emission stage of the tpt-telos pipeline. It consumes the verified
FuncOutcomes produced by tpt-telos-agent and emits human-readable, compilable source code.
generate_program— emits a single self-contained Rust library file (structs, invariantimplmethods, contract doc-comments, onefnper function).generate_project— assembles a full dual-backend project tree: a Rust crate, a Go module, and a C-ABI FFI bridge between them, with each module routed to Rust, Go, or Python bytpt-telos-router.pythonmodule — emits a Python backend for@boundary(ml_training|python|jax)modules:@dataclassstructs withsatisfies_invariants()and runtimeassertguards for every contract; thejaxflag additionally annotates fields withjnp.int64.proofmodule — generatestelos-proof.jsonon everybuild/projectrun (SHA-256 of the source, per-function verification outcomes, a tamper-evidentmanifest_hash) and embeds it as#[used] static TELOS_PROOF_MANIFESTin the generated Rust binary;verify_manifestre-hashes a source file against a saved manifest to detect drift (telos verify-manifest).- eject hatch — functions marked
@ejectare compiled to a trusted opaquef_impl/fImplstub wrapped by a generated guard that enforcesrequires/ensuresat runtime viaassert!/panic.
Usage
use ;
// Single Rust file
let rust_src = generate_program;
write.unwrap;
// Full dual-backend project
let project = generate_project;
for file in &project.files
Key API
| Item | Description |
|---|---|
generate_program(modules, outcomes) -> String |
Single Rust library source |
generate_project(modules, outcomes) -> Project |
Full Rust+Go(+Python) project tree |
Project |
Collection of GeneratedFile { path, contents } |
eject module |
Renders @eject functions as an opaque stub + contract-guarded wrapper (invoked automatically by generate_program/generate_project, not a public entry point) |
go module |
Go backend emitter |
python module |
Python/JAX backend emitter |
ffi module |
C-ABI FFI bridge generator |
proof::generate_manifest / proof::verify_manifest |
Cryptographic proof manifest write/verify |
License
Licensed under either of MIT or Apache-2.0 at your option.