faf-rust-sdk v2
High-performance Rust SDK for FAF (Foundational AI-context Format) — parsing, scoring, validation, and the FAFb binary format.
IANA Media Type: application/vnd.faf+yaml
v2 — The Definitive Edition
The definitive binary format for AI context. v2 ships FAFb — the compiled form of .faf files, future-proofed for any repo size, complexity, or organization. The FAF creator fell in love with IFF in the 90s — working with the Interchange File Format that Commodore created for the Amiga across early computer graphics engines and apps. That chunked binary architecture influenced everything that came after. Microsoft literally riffed on it with RIFF. IFF got it right the first time.
FAFb brings that same architecture into the AI era: a string table replacing the fixed enum, the same pattern ELF and IFF have used for decades. FAF creator realized every YAML key can just become a named section. No limits. No "Unknown" fallback. No artificial ceiling. Sections are classified as DNA (core identity), Context (supplementary), or Pointer (documentation). Works for a solo dev or a 680-engineer enterprise.
This is a significant free upgrade. The SDK is MIT, the format is an IANA-registered open standard, and the binary spec is public. We're making the standard bulletproof so everyone can build on it.
Installation
[]
= "2.0"
Quick Start
use ;
FAFb Binary Format
Compile .faf YAML to a sealed binary. YAML is source code, FAFb is the compiled output.
use ;
// Compile YAML → binary
let yaml = "faf_version: 2.5.0\nproject:\n name: my-project\n";
let opts = CompileOptions ;
let bytes = compile.unwrap;
// Decompile binary → structured result
let result = decompile.unwrap;
let name = result.get_section_string_by_name.unwrap;
// Query by classification
let dna = result.dna_sections; // Core identity sections
let ctx = result.context_sections; // Supplementary sections
let ptr = result.pointer_section; // Documentation references
Binary Layout
HEADER (32 bytes) — Magic "FAFB", version, flags, CRC32 checksum
SECTION DATA (variable) — Each YAML key → one section, priority-ordered
STRING TABLE (appended) — Section name index, unlimited names, O(1) lookup
SECTION TABLE (at end) — 16 bytes per entry: name, priority, offset, length, tokens, classification
Features
Parsing & Validation
use ;
let faf = parse?;
let result = validate;
println!;
Compression Levels
Optimize for context window constraints:
use ;
let minimal = compress; // ~150 tokens
let standard = compress; // ~400 tokens
let full = compress; // ~800 tokens
Axum Integration
Add FAF project context to any Axum server:
[]
= { = "2.0", = ["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.
Testing
175 tests passing — WJTTC Championship-Grade coverage:
See Also
- faf-wasm-sdk — Same FAFb format compiled to WASM for browsers and edge compute
- mcpaas — Stream FAF context live via Radio Protocol
Links
- faf.one — project home
- IANA Registration —
application/vnd.faf+yaml - FAF on Zenodo — academic paper
- FAF on Grokipedia — 28 citations
License
MIT