tpt-fulcrum

Rust

Universal code modernization engine — extracts legacy codebases (C/C++, Java/C#, PHP/Python) into a language-agnostic knowledge graph, then regenerates idiomatic, memory-safe code in modern targets (Rust, Go, TypeScript) with automated differential-execution parity testing.

0 stars0 forks0 watchersApache License 2.0

Languages

Rust99.4%Dockerfile0.6%
README

TPT Fulcrum

CI License: MIT OR Apache-2.0 Rust

Universal Code Modernization Engine

"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." — Archimedes

"Syntax is temporary; Intent is permanent."

The internet's foundational infrastructure is trapped in decades-old legacy code (C, Java, PHP). TPT Fulcrum breaks the syntax chain. It ingests a legacy repository, extracts its core business logic, state machines, and data flows into a Knowledge Graph (the Fulcrum), then forges brand-new, idiomatic, memory-safe code in a modern target language — and proves functional parity with an automated differential execution sandbox (the Crucible).

The Three-Stage Pipeline

  1. Extractor — Reads the legacy codebase, maps its true intent via lightweight AST parsers (tree-sitter), and emits a language-agnostic Knowledge Graph (JSON-LD).
  2. Generator — Prompts an LLM with the Knowledge Graph (not the original code) to synthesize idiomatic, target-language source from scratch.
  3. Crucible — Compiles both legacy and generated code in isolated Docker environments, runs identical inputs, diffs the outputs, and feeds failures back to the Generator until 100% parity is reached.

Target Matrix

OriginalTargetArchitecture ProfileUse Case
C / C++RustSystems, Zero-CopyMedia engines, crypto, databases
Java/C#GoMicroservices, goroutinesWeb backends, API gateways
PHP/PyTypeScriptServerless, Edge, React/NodeCMS backends, rapid prototyping

Supported source languages for ingestion: C, C++, Python, Java, C#, PHP, Ruby, and JavaScript (each with a csv_parser PoC fixture under examples/poc-<lang>/), plus Fortran (chunked via tree-sitter) and Cobol (chunked via a hand-rolled line scanner, since no tree-sitter-cobol release exposes usable bindings). Neither Fortran nor Cobol has cross-file import resolution yet.

Architecture

legacy-repo/
   │  (Extractor: tree-sitter AST + LLM)
   ▼
KnowledgeGraph  ── JSON-LD (the Fulcrum)
   │  (Generator: LLM + Target Profile)
   ▼
modernized/     ── idiomatic Rust / Go / TypeScript
   │  (Crucible: Docker differential verification)
   ▼
parity report   ── 100% output parity guaranteed

CLI Workflow

# 1. Point Fulcrum at a legacy repo
$ tpt fulcrum init ./legacy-java-backend

# 2. Build the Knowledge Graph
$ tpt fulcrum analyze --depth deep
> [████████████████████] 100% | Extracting State Machines...
> Graph built: 4,502 nodes, 12,840 edges.

# 3. Forge the new codebase
$ tpt fulcrum forge --target go --profile microservices
> [████████████████████] 100% | Generating Go interfaces...
> [████████████████████] 100% | Running Crucible Verification...
> Crucible: 142/142 tests passed. Output parity: 100%.

# 4. Output
> Success. Modernized code written to ./modernized-go-backend

Repository Layout

crates/
  core/      # Knowledge graph model, LLM provider trait, domain types
  tpt-fulcrum-cli/   # Binary: `tpt fulcrum init | analyze | forge`

Building

cargo build --release
cargo test
cargo clippy --all-targets
cargo fmt --check

Status

Pre-Alpha, but functionally complete end-to-end: Extractor, Generator, and Crucible are all implemented, source-language coverage spans eight languages (C, C++, Python, Java, C#, PHP, Ruby, JavaScript), and the CLI drives the full init → analyze → forge pipeline with Crucible-verified parity. Remaining work is the public launch itself (crates.io/GitHub publish, community triage) — see todo.md.

License

Dual-licensed under MIT or Apache-2.0.

© TPT Solutions