FAI Engine
The runtime that reads fai-manifest.json, resolves context, wires primitives, runs hooks, and evaluates quality — 7 modules, 42 tests, 12ms.
What does the FAI Engine do?
The FAI Protocol defines how primitives connect. The FAI Engine executes that specification. Give it a fai-manifest.json and it will:
Interactive Pipeline
{
"play": "01-enterprise-rag",
"version": "1.0.0",
"context": {
"knowledge": [
"R2-RAG-Architecture",
"O3-MCP-Tools",
"T3-Production-Patterns",
"F1-GenAI-Foundations"
],
"waf": [
"security",
"reliability",
"cost-optimization",
"operational-excellence",
"responsible-ai"
],
"scope": "enterprise-rag-qa"
},
"primitives": {
"agents": 3,
"instructions": 3,
"skills": 1,
"hooks": 3,
"guardrails": {
"groundedness": 0.95,
"coherence": 0.9,
"relevance": 0.85,
"safety": 0,
"costPerQuery": 0.01
}
},
"infrastructure": {
"bicep": "./infra/main.bicep"
},
"toolkit": {
"devkit": ".github/",
"tunekit": "config/",
"speckit": "spec/"
}
}7 Engine Modules
Each module is a focused unit with a single responsibility. Together they form the full FAI Engine pipeline.
Pipeline Flow
The engine processes a manifest through 6 sequential stages — each building on the previous.
Usage
Use the engine programmatically or from the command line.
const { initEngine } = require('./engine/index');
// Initialize engine with a manifest
const engine = initEngine('solution-plays/01-enterprise-rag/fai-manifest.json');
if (engine.errors.length > 0) {
console.error('Engine errors:', engine.errors);
process.exit(1);
}
// Access wiring status
console.log(engine.status);
// → { play: "01-enterprise-rag", primitives: 10, modules: 4, pillars: 5, ms: 12 }
// Check context resolution
console.log(engine.context.knowledge);
// → ["R2-RAG-Architecture", "O3-MCP-Tools", ...]
// Run evaluation against guardrails
const evaluation = engine.evaluator.check({
groundedness: 0.97,
coherence: 0.92,
relevance: 0.88,
safety: 0,
costPerQuery: 0.008,
});
console.log(evaluation);
// → { pass: true, metrics: { groundedness: "PASS", ... } }Test Results
42/42 PASS| Suite | Tests | Status |
|---|---|---|
| Manifest Reader | 8 | 8/8 |
| Context Resolver | 6 | 6/6 |
| Primitive Wirer | 10 | 10/10 |
| Hook Runner | 5 | 5/5 |
| Evaluator | 7 | 7/7 |
| MCP Bridge | 3 | 3/3 |
| Integration | 3 | 3/3 |
Configuration Reference
Engine behavior is controlled by the manifest itself — no separate config files needed.
FAI Protocol Integration
The FAI Engine is the reference implementation of the FAI Protocol. Any runtime that reads fai-manifest.json and follows the wiring specification is a FAI Engine. The protocol is the spec; the engine is one implementation.