faf-sdk (Rust)
High-performance Rust SDK for FAF (Foundational AI-context Format) - optimized for inference workloads.
IANA Media Type: application/vnd.faf+yaml
Installation
[]
= "1.3"
Quick Start
use ;
Features
Zero-Copy Parsing
Designed for high-throughput inference:
use parse;
// Parse in ~1ms
let faf = parse?;
// Direct field access - no allocation
let name = faf.project_name;
let stack = faf.tech_stack;
Compression Levels
Optimize for context window constraints:
use ;
// Level 1: ~150 tokens
let minimal = compress;
// Level 2: ~400 tokens
let standard = compress;
// Level 3: ~800 tokens
let full = compress;
Validation
Check structure and completeness:
use validate;
let result = validate;
if result.valid else
API
Core Functions
| Function | Description |
|---|---|
parse(content) |
Parse YAML string |
parse_file(path) |
Parse from file |
validate(&faf) |
Validate structure |
compress(&faf, level) |
Compress for tokens |
stringify(&faf) |
Convert back to YAML |
FafFile Methods
| Method | Returns | Description |
|---|---|---|
project_name() |
&str |
Project name |
goal() |
Option<&str> |
Project goal |
score() |
Option<u8> |
AI score (0-100) |
tech_stack() |
Option<&str> |
Technology stack |
what_building() |
Option<&str> |
What's being built |
key_files() |
&[String] |
Key file paths |
is_high_quality() |
bool |
Score >= 70% |
Testing
145/145 passing — WJTTC Championship-Grade 3-Tier coverage:
| Tier | Tests | What |
|---|---|---|
| T1 BRAKES | 16 | Security — corruption, validation, type safety |
| T2 ENGINE | 22 | Core — parsing, scoring, compression, discovery |
| T3 AERO | 20 | Polish — unicode, large inputs, YAML quirks |
| Axum | 8 | Integration — middleware, extractors, builder |
| Unit | 17 | Inline |
| Doc | 10 | Doctests |
Performance
Optimized for inference workloads:
| Operation | Time |
|---|---|
| Parse | <1ms |
| Validate | <0.1ms |
| Compress | <0.1ms |
Why Rust?
For native AI inference embedding:
- Zero-copy where possible
- No GC pauses
- Predictable latency
- Easy FFI to Python/C++
Axum Integration
Add FAF project context to any Axum server with one line:
[]
= { = "1.3", = ["axum"] }
use ;
use ;
let app: Router = new
.route
.layer;
async
The .faf file is parsed once at startup. Per-request cost is a single Arc::clone.
Use the builder for options:
use FafLayer;
use CompressionLevel;
let layer = builder
.dir
.compression
.try_build?;
See Also
- mcpaas — Connect to MCPaaS Radio Protocol in Rust. Broadcast context once, every AI receives. faf-rust-sdk reads the format; mcpaas streams it live.
Do I need both? Yes. faf-rust-sdk parses your .faf project DNA. mcpaas streams it live to every AI. One reads, the other delivers.
Links
- Spec: github.com/Wolfe-Jam/faf
- Site: faf.one
- Python SDK: faf-python-sdk
License
MIT