scriba-atomickit
v0.42.0
Published
AtomicKit is an ultra-lightweight, **polyglot execution engine** designed to run distributed logic across multiple languages (**Node.js, Python, Rust, Go**) without the overhead of managing microservices or containers for every small task.
Readme
⚛️ AtomicKit (Ribosome)
AtomicKit is an ultra-lightweight, polyglot execution engine designed to run distributed logic across multiple languages (Node.js, Python, Rust, Go) without the overhead of managing microservices or containers for every small task.
🚀 The Concept
AtomicKit operates on a biological metaphor of modularity:
- Atoms: The smallest unit of logic. A YAML file containing the implementation code, required dependencies, and a strict contract (JSON Schema).
- Strands: Logical sequences or "chains." They orchestrate multiple Atoms or even other Strands, creating a data flow where the output of one step becomes the input for the next.
🛠️ Key Features
- Native Polyglotism: Run high-performance Rust, simple Python scripts, or Node.js logic side-by-side.
- Recursive Composition: Strands can call other Strands, allowing for complex, nested workflow architectures.
- Immune System: Integrated validation using Ajv. If the input doesn't match the
input_schemadefined in the Atom, execution is halted before it even starts. - JIT Compilation & Dependency Management: Automatically handles
npm install,pip install, and triggerscargo buildorgo buildon the fly for compiled languages. - Universal IPC: Communication between the engine and different runtimes is handled via
STDIN/STDOUTusing JSON, ensuring maximum compatibility and low overhead.
📂 Project Structure
.
├── atoms/ # .atom definitions (The Logic)
├── strands/ # .strand definitions (The Workflows)
├── bin/ # Compiled binaries (Auto-generated)
├── .atomic_cache/ # Global dependency cache (node_modules, pip packages)
└── src/ # Core Engine (TypeScript)
📝 Practical Examples
1. High-Performance Atom (Rust)
atoms/compute_hash.atom
name: compute_hash
runtime: rust
require:
- sha2
implementation: |
use sha2::{Sha256, Digest};
let text = input["data"].as_str().unwrap_or("");
let mut hasher = Sha256::new();
hasher.update(text);
let result = format!("{:x}", hasher.finalize());
serde_json::json!({ "hash": result })
2. Data Processing Atom (Python)
atoms/format_response.atom
name: format_response
runtime: python
implementation: |
def handle(data):
return {
"status": "processed",
"result": data.get("hash"),
"timestamp": 1690000000
}
3. Nested Recursive Strand
strands/secure_flow.strand
name: secure_flow
run:
- compute_hash # Atom
- format_response # Atom
strands/main_pipeline.strand
name: main_pipeline
run:
- secure_flow # Calling another Strand (Recursion)
- notify_service # Atom
🚦 Getting Started
- Install Engine Dependencies:
npm install
- Start the Ribosome Server:
npm run dev
- Execute a Pipeline: Send a POST request to the engine. The engine will automatically detect if it's a Strand or an Atom:
curl -X POST http://localhost:3000/strand/main_pipeline \
-H "Content-Type: application/json" \
-d '{"data": "atomic-secret-key"}'
🛡️ Recursive Execution Note
The engine supports Recursive Composition, meaning a Strand can invoke other Strands. This allows for massive reusability of logic blocks.
Warning: Ensure your Strand chains are directed acyclic graphs (DAGs) to avoid infinite loops, as the engine will follow the chain until completion.
