Skip to content

paiml/decy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

decy

Crates.io Documentation License

Tests Coverage PMAT Score Repo Health


What's New in 2.0

Release Date: January 2025

  • 99.9% Test Pass Rate - 1,391 tests passing
  • 95% Code Coverage - Comprehensive test suite
  • DECY-220: Fixed malloc cast expression handling ((int*)malloc(n)Vec<T>)
  • Portable Tests: All test paths use CARGO_MANIFEST_DIR
  • System Include Discovery: Automatic detection of stdlib.h, string.h
cargo install decy

Quick Start

# Transpile a C file to Rust
decy transpile input.c -o output.rs

# Transpile an entire project
decy transpile-project src/ -o rust_output/

# Audit unsafe code
decy audit output.rs

Example:

// input.c
int add(int a, int b) {
    return a + b;
}
decy transpile input.c
// Generated Rust (no unsafe!)
fn add(a: i32, b: i32) -> i32 {
    a + b
}

Quality Metrics (PMAT)

Metric Score Target
Rust Project Score 92.9% (A+) 90%+
Repository Health 84.5/100 (B+) 80+
Test Coverage 95.1% 80%+
Test Pass Rate 99.9% 100%
Clippy Warnings 0 0

Run quality analysis:

pmat rust-project-score
pmat repo-score
pmat analyze complexity

Installation

From crates.io (Recommended)

cargo install decy

From Source

git clone https://github.com/paiml/decy.git
cd decy
make install   # Installs Rust + LLVM/Clang
cargo install --path crates/decy

Requirements

  • Rust: 1.70+ (stable)
  • LLVM/Clang: 14+ (for C parsing)
  • Platform: Linux, macOS, Windows (WSL2)

Features

Core Transpilation

# Single file
decy transpile input.c -o output.rs

# Project with caching (10-20x faster on unchanged files)
decy transpile-project src/ -o rust_output/
decy cache-stats src/

Debug & Visualization

# Visualize C AST
decy debug --visualize-ast input.c

# Visualize ownership inference
decy debug --visualize-ownership input.c

# Step-through debugging
decy debug --step-through input.c

Safety Analysis

# Audit unsafe blocks
decy audit output.rs --verbose

# Generate verification book
decy verify --book-output ./book

MCP Integration

# Start MCP server for Claude Code
decy mcp-server --port 3000

Architecture

C Source → Parser → HIR → Analyzer → Ownership → Codegen → Rust
             │         │       │          │          │
           clang    Rust-IR  Types   &T/&mut T    Safe code

Crates

Crate Description
decy-parser C AST parsing (clang-sys)
decy-hir High-level IR (Rust-oriented)
decy-analyzer Static analysis, type inference
decy-ownership Ownership inference (pointers → references)
decy-codegen Rust code generation
decy-verify Safety verification
decy-debugger AST/HIR visualization
decy CLI binary

Unsafe Minimization

Decy uses a 4-phase approach to minimize unsafe code:

Phase Reduction Technique
1. Pattern-Based 100% → 50% malloc/freeBox, arrays → Vec
2. Ownership 50% → 20% Infer &T, &mut T from usage
3. Lifetime 20% → 10% Infer <'a, 'b> annotations
4. Safe Wrappers 10% → <5% Generate safe abstractions

Target: <5 unsafe blocks per 1000 LOC


Development

EXTREME TDD Workflow

# RED: Write failing tests
git commit -m "[RED] DECY-XXX: Add failing tests"

# GREEN: Minimal implementation
git commit -m "[GREEN] DECY-XXX: Implement feature"

# REFACTOR: Meet quality gates
git commit -m "[REFACTOR] DECY-XXX: Clean up"

Quality Gates

make quality-gates   # Run all checks
make test            # Run tests
make coverage        # Generate coverage report

Running Tests

cargo test --workspace          # All tests
cargo test -p decy-ownership    # Single crate
cargo llvm-cov --workspace      # Coverage

Documentation


License

MIT OR Apache-2.0


Acknowledgments

  • C2Rust - Mozilla's C-to-Rust transpiler
  • PMAT - Quality metrics toolkit
  • Toyota Production System - Quality principles

Built with EXTREME quality standards

About

Transpile C to Rust

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •