Welcome to the Corebrum Getting Started Developer Guide! This comprehensive guide will help you understand, install, configure, and use Corebrum - the mesh supercomputer platform for decentralized computing.
- Introduction & Architecture Overview
- Installation & Setup
- Building with Claude Code
- Zenoh Configuration & Deployment
- Corebrum Daemon & Workers
- Corebrum CLI
- Corebrum CMOS (Interactive Shell)
- Corebrum REST API
- Corebrum Web UI
- Task Definition Structure
- Parallel Computing Examples
- Sequential Computing Examples
- Streaming Tasks
- MCP (Model Context Protocol) Integration
- ROS2 + Corebrum: Physical AI Robotics
- Corebrum Cortex: Identity, Memory, and Hiveminds
- Storage System
- Advanced Features
- Best Practices & Patterns
- Quick Reference
- Next Steps & Resources
Agent integration test scripts: scripts/agents/README.md — shell checks for OpenClaw, Claude (HTTP + optional MCP), and Gemini; overview also in §14 MCP.
Example layout: General mesh task definitions are under task_definitions/. Bundles that require Corebrum Cortex (identity, memory, hive, OpenClaw) are under cortex/task_definitions/ — start at cortex/README.md.
Hands-on commands (Zenoh, daemon, CMOS, ROS2, streams, REST, Cortex paths from a sibling corebrum-cortex checkout): CHEATSHEET.md.
Corebrum is a mesh supercomputer platform that enables decentralized, distributed computing across a network of devices. It transforms any collection of connected machines into a powerful, unified computing resource capable of executing tasks in parallel, sequentially, or as long-running streams.
- Mesh Computing: Distributed computing where tasks can execute on any available worker in the network
- Decentralized Execution: No central coordinator - workers discover and claim tasks autonomously
- Zenoh Networking: Built on Zenoh for efficient, low-latency communication
- Cognitive Computing: Identity, memory, and collaborative learning through the Corebrum Cortex
graph TB
subgraph "Corebrum Architecture"
ZR[Zenoh Router<br/>zenohd]
CD[Corebrum Daemon<br/>+ Workers]
CLI[CLI Tools]
CMOS[CMOS Shell]
API[REST API<br/>Port 6502]
UI[Web UI]
end
subgraph "Task Execution"
T1[Parallel Tasks]
T2[Sequential Pipelines]
T3[Streaming Tasks]
end
subgraph "External Systems"
ROS2[ROS2 Robots<br/>via zenoh-bridge]
MCP[MCP Servers]
Docker[Docker Containers]
end
ZR --> CD
CLI --> ZR
CMOS --> ZR
API --> ZR
UI --> API
CD --> T1
CD --> T2
CD --> T3
ROS2 --> ZR
MCP --> CD
Docker --> CD
- Multi-language Support: Python, JavaScript, Rust, Docker, WebAssembly
- Task Types: Parallel, sequential, and streaming execution modes
- ROS2 Integration: Native bi-directional ROS2 message handling
- Cognitive Layer: Identity, memory, and hive systems for learning robots
- Storage Backends: Filesystem, RocksDB, InfluxDB support
- REST API & Web UI: Complete programmatic and visual interfaces
- Scientific Computing: Distributed simulations and data analysis
- AI/ML Workloads: Parallel model training and inference
- Robotics: Real-time sensor processing and control
- Edge Computing: Distributed processing across IoT devices
- Data Pipelines: ETL workflows and data transformation
- Operating System: Linux, macOS, or Windows (WSL2)
- Rust: 1.70+ (for building from source)
- Docker: Optional, for container-based tasks
- Network: TCP/IP connectivity for mesh networking
# Add Corebrum APT repository
echo "deb [trusted=yes] https://corebrum.github.io/corebrum-cortex/apt-repo/ stable main" | sudo tee /etc/apt/sources.list.d/cortex.list
# Update package list
sudo apt update
# Install Corebrum
sudo apt install cortex# Add Corebrum tap
brew tap corebrum/corebrum
# Install Corebrum
brew install cortex# Download Corebrum for Windows
# Direct download: https://corebrum-releases.s3.amazonaws.com/releases/v0.2.112/corebrum-x86_64-pc-windows-msvc.zip
# Extract the zip file
# Add cortex.exe to your PATH environment variableWindows Installation Steps:
- Download the corebrum-x86_64-pc-windows-msvc.zip file from: https://github.com/Corebrum/corebrum-cortex/releases
- Extract the zip file to a directory (e.g.,
C:\Program Files\Corebrum) - Add the directory containing
cortex.exeto your PATH:- Open System Properties → Environment Variables
- Edit the
Pathvariable in User or System variables - Add the directory path (e.g.,
C:\Program Files\Corebrum) - Click OK to save
# Clone the repository
git clone https://github.com/Corebrum/corebrum-cortex.git
cd corebrum-cortex
# Build Corebrum
cargo build --release
# Install (optional)
cargo install --path .Install the Corebrum Python library to execute Python code on Corebrum's distributed infrastructure:
pip install corebrumQuick Start:
import corebrum
# Configure Corebrum connection
corebrum.configure(base_url="http://localhost:6502")
# Decorate function to run on Corebrum
@corebrum.run()
def process_data(data):
import pandas as pd
df = pd.DataFrame(data)
return df.describe().to_dict()
# Call normally - executes on Corebrum
result = process_data([{"x": 1, "y": 2}, {"x": 3, "y": 4}])Features:
- Transparent execution: Code runs as if local, but executes on Corebrum
- Automatic dependency detection and installation
- Workers automatically install missing Python packages (e.g., pandas, numpy)
- Two usage patterns: Decorator (
@corebrum.run()) and raw code execution (corebrum.execute()) - Error handling with Python exceptions
- Identity and memory support
Documentation: https://github.com/Corebrum/corebrum-pip
PyPI Package: https://pypi.org/project/corebrum/
# Check Corebrum version
cortex --version
# View help
cortex --help
# List available commands
cortex helpCorebrum uses sensible defaults and typically requires no initial configuration. The default Zenoh router endpoint is tcp://127.0.0.1:7447 for local development.
You can override the Zenoh router endpoint using the --zenoh-router flag:
cortex daemon --zenoh-router tcp://your-router:7447Claude Code is an AI-powered development environment that can help you build and run Corebrum applications interactively. With Claude Code, you can describe what you want to build in natural language, and Claude will help you create task definitions, write code, and execute your Corebrum apps.
-
Clone the repository:
git clone git@github.com:Corebrum/corebrum-examples.git cd corebrum-examples -
Launch Claude Code:
claude
-
Ask Claude to build a Corebrum app: At the Claude Code prompt, describe what you want to build. For example:
help me build and run a cortex app that calculates pi out to 5 decimals -
Approve Claude's actions: Answer YES to Claude's requests to fix and run commands. Claude will:
- Create task definition files (YAML/JSON)
- Write the necessary code
- Submit tasks to Corebrum
- Monitor execution and retrieve results
Initial Request:
help me build and run a cortex app that calculates pi out to 5 decimals
Claude will:
- Create a task definition file (e.g.,
task_definitions/python/pi_calculation.yaml) - Write Python code to calculate π using a method like the Leibniz formula or Monte Carlo
- Submit the task using
cortex submit - Wait for completion and display results
Iterative Refinement:
now run it out to 10 decimals
Claude will modify the task definition and resubmit with updated parameters.
- Natural Language Interface: Describe what you want in plain English
- Interactive Development: Iterate on your apps through conversation
- Automatic Code Generation: Claude writes task definitions and code for you
- Error Handling: Claude fixes issues and retries automatically
- Learning Tool: See how Corebrum apps are structured by watching Claude build them
- Claude Code installed and configured
- Corebrum daemon running (see Section 5: Corebrum Daemon & Workers)
- Zenoh router running (see Section 4: Zenoh Configuration & Deployment)
Claude can create various types of Corebrum tasks:
- Mathematical computations: Factorial, Fibonacci, π calculation
- Data processing: CSV parsing, JSON transformation
- Parallel tasks: Multiple independent computations
- Sequential pipelines: Multi-stage data processing
- Streaming tasks: Real-time data processing
- Be Specific: Clearly describe what you want the app to do
- Provide Context: Mention if you want parallel execution, specific precision, etc.
- Iterate: Ask Claude to modify or improve the app after initial creation
- Review Generated Code: Check the task definitions Claude creates to learn the structure
For a detailed walkthrough and examples, see the Medium article: Building and running Corebrum apps with Claude Code!
Zenoh is a high-performance, distributed pub/sub and storage system that Corebrum uses for networking. It provides:
- Low-latency messaging: Efficient pub/sub communication
- Storage backends: Persistent storage for data and state
- Network abstraction: Seamless local and distributed networking
# Install Zenoh using Homebrew
brew install zenohOption 1: Download Pre-built Binary
- Download from GitHub releases: https://github.com/eclipse-zenoh/zenoh/releases
- Extract the zip file
- Add
zenohd.exeto your PATH environment variable
Option 2: Using Cargo (if Rust is installed)
cargo install zenoh# Add Zenoh APT repository
sudo sh -c 'echo "deb [trusted=yes] https://download.eclipse.org/zenoh/debian/ stable main" > /etc/apt/sources.list.d/zenoh.list'
# Update package list
sudo apt update
# Install Zenoh
sudo apt install zenohUsing Cargo:
cargo install zenohOr download from GitHub releases:
Start Zenoh router with default configuration:
zenohdThe router will start on tcp://127.0.0.1:7447 by default.
Corebrum supports multiple Zenoh storage backends for persistence:
Simple file-based storage for development:
# Start zenohd with filesystem backend
zenohd --config /path/to/corebrum-cortex/docs/zenoh_configs/zenohd-filesystem.json5High-performance key-value storage for production:
# Start zenohd with RocksDB backend
zenohd --config /path/to/corebrum-cortex/docs/zenoh_configs/zenohd-rocksdb.json5Time-series database for metrics and temporal data:
# Start InfluxDB first
influxd
# Then start zenohd with InfluxDB backend
zenohd --config /path/to/corebrum-cortex/docs/zenoh_configs/zenohd-influxdb.json5Use different backends for different data types:
zenohd --config /path/to/corebrum-cortex/docs/zenoh_configs/zenohd-multi-backend.json5Key Expression Mapping:
cortex/storage/**→ Filesystem backendcortex/cache/**→ RocksDB backendcortex/metrics/**→ InfluxDB backendcortex/memory/**→ In-memory (ephemeral)
For local development, use the default configuration:
zenohdFor a laptop/edge hub plus workers and robots, generate matching JSON5 instead of a one-off listen flag or a missing zenoh-distributed.json5:
npx zenoh-fleet # wizard (same CLI as @agenticros/zenoh-fleet)
zenohd -c /path/to/<fleet>/zenohd.json5
cortex daemon --zenoh-router tcp://<hub>:7447Corebrum joins over native TCP (tcp://<hub>:7447), not AgenticROS's WebSocket endpoint (ws://…:10000). Full CLI: zenoh-fleet. ROS2 mesh steps: ../corebrum-cortex/ROS2-README.md.
To listen on all interfaces without a generated file:
zenohd --listen tcp/0.0.0.0:7447# Test Zenoh connectivity
zenoh info
# Subscribe to test topic
zenoh sub -k test/topic
# In another terminal, publish
zenoh pub -k test/topic "Hello, Zenoh!"- Router not starting: Check if port 7447 is available
- Connection refused: Verify router is running and accessible. For a laptop+robots mesh, run
npx zenoh-fleetthencortex daemon --zenoh-router tcp://<hub>:7447. From another machine:nc -zv <hub> 7447. - Storage errors: Ensure storage directories exist and are writable
For fleet topology configs, see zenoh-fleet. For storage backend JSON5, see: ../corebrum-cortex/docs/zenoh_configs/
The Corebrum daemon manages workers that execute tasks:
# Start daemon with default settings (4 workers)
cortex daemon
# Start with custom worker count
cortex daemon --worker-count 8
# Start with specific Zenoh router
cortex daemon --zenoh-router tcp://192.168.1.100:7447
# Start with custom timeout
cortex daemon --default-timeout 600Workers can be configured with specific capabilities (languages/runtimes):
# Start workers with Python capability
cortex daemon --capabilities python
# Multiple capabilities
cortex daemon --capabilities "python,javascript,docker"
# Different capabilities per worker (comma-separated lists)
cortex daemon --capabilities "python,python,python,docker"Workers automatically manage resources:
- CPU: Tasks specify required CPU cores
- Memory: Tasks specify memory requirements in MB
- Timeout: Tasks can specify execution timeout
The daemon automatically connects to the Zenoh router. By default, it connects to tcp://127.0.0.1:7447.
To connect to a different router:
cortex daemon --zenoh-router tcp://router-ip:7447# Check network status
cortex netstat
# Check compute capacity
cortex compute-stats
# List active jobs
cortex jobs
# Ping a specific worker
cortex ping <worker-id>- Startup: Workers register with the mesh network
- Discovery: Workers discover available tasks
- Claiming: Workers claim tasks matching their capabilities
- Execution: Workers execute tasks and publish results
- Shutdown: Workers gracefully shut down on daemon stop
The Corebrum CLI provides command-line access to all Corebrum functionality.
# Submit from file
cortex submit --file task_definitions/python/factorial_task.yaml
# Submit with inputs
cortex submit --file task.yaml --input '{"number": 10}'
# Submit from URL
cortex submit --file https://example.com/task.yaml --input '{"data": "value"}' --capability python
# Submit with identity
cortex submit --file task.yaml --identity <key-id>Wait for task completion before returning:
cortex submit-and-wait --file task.yaml --input '{"number": 5}'# Check task status
cortex status <task-id>
# Watch status changes
cortex status <task-id> --watch# List all jobs
cortex jobs# Get task logs
cortex logs <task-id># Get results as JSON
cortex results <task-id>
# Get results as YAML
cortex results <task-id> --format yaml
# Save results to file
cortex results <task-id> --output results.json# Cancel a running task
cortex cancel <task-id># Show network topology and workers
cortex netstat# Ping a specific worker
cortex ping <worker-id># List all topics
cortex topics
# Filter ROS2 topics
cortex topics ros2
# Filter Corebrum topics
cortex topics cortex# List active streaming tasks
cortex streams# Publish to a topic
cortex publish <topic> '{"message": "data"}'# Subscribe and display messages
cortex subscribe <topic># Show network topology
cortex network# Put data in storage
cortex storage put <key> '{"data": "value"}'
# Get data from storage
cortex storage get <key>
# Query storage
cortex storage query <prefix>
# Delete from storage
cortex storage delete <key># Put data in memory
cortex memory put <key> '{"data": "value"}'
# Get data from memory
cortex memory get <key>
# Query memory
cortex memory query <prefix>
# Delete from memory
cortex memory delete <key># Create identity
cortex identity create --name "My Robot"
# List identities
cortex identity list
# Show identity details
cortex identity show <key-id>
# Set default identity
cortex identity set <key-id>
# Enable feature
cortex identity enable <key-id> memory
# Disable feature
cortex identity disable <key-id> memory# Create hive
cortex hive create "Research Team" --description "Shared knowledge" --key-id <key-id>
# List hives
cortex hive list --key-id <key-id>
# Join hive
cortex hive join <hive-id> --key-id <key-id>
# Put memory in hive
cortex hive memory put <hive-id> <key> '{"value": "data"}' --key-id <key-id>
# Query hive memory
cortex hive memory query <hive-id> --key-id <key-id># Login
cortex auth login
# Logout
cortex auth logout
# Check auth status
cortex auth status# Sync licenses
cortex license sync
# Check license status
cortex license status <key-id>
# List licenses
cortex license listFor complete CLI documentation, see: ../corebrum-cortex/src/cli/commands/
CMOS (Corebrum Mesh Operating System) is an interactive shell that provides a unified interface for managing Corebrum operations.
# Start CMOS with default settings
cortex cmos
# Start with custom Zenoh router
cortex cmos --zenoh-router tcp://192.168.1.100:7447
# Start with VFS mount point
cortex cmos --mount-point /mnt/corebrum
# Start without FUSE filesystem
cortex cmos --no-fuseCMOS provides commands for all Corebrum operations:
- Task Management:
submit,status,results,logs,cancel - Network Operations:
netstat,ping,topics,streams - Storage:
storage put,storage get,storage query - Memory:
memory put,memory get,memory query - Identity:
identity create,identity list,identity set - Hive:
hive create,hive join,hive memory put
CMOS supports interactive task creation:
CMOS[user@local] > submit --interactiveWhen started with VFS enabled, CMOS provides a virtual file system:
# Mount point provides access to mesh resources
cd /mnt/corebrum
ls tasks/
ls storage/
ls memory/$ cortex cmos
CMOS[user@local] > submit --file task.yaml --input '{"number": 10}'
✅ Task submitted: abc123-def456-789
CMOS[user@local] > status abc123-def456-789
Status: running
CMOS[user@local] > results abc123-def456-789
{
"result": 3628800,
"status": "completed"
}
CMOS[user@local] > exitFor detailed CMOS documentation, see: ../corebrum-cortex/src/shell/
The Corebrum REST API provides programmatic access to all Corebrum functionality.
# Start web server on default port (6502)
cortex web
# Start on custom host and port
cortex web --host 0.0.0.0 --port 8080The API server runs on http://localhost:6502 by default.
Base URL: http://localhost:6502/api
Some endpoints require authentication. Check authentication status:
curl http://localhost:6502/api/auth/statuscurl -X POST http://localhost:6502/api/submit \
-H "Content-Type: application/json" \
-d '{
"file": "task_definitions/python/factorial_task.yaml",
"input": "{\"number\": 10}",
"identity": "optional-key-id"
}'curl -X POST http://localhost:6502/api/submit-and-wait \
-H "Content-Type: application/json" \
-d '{
"file": "task.yaml",
"input": "{\"data\": \"value\"}"
}'curl http://localhost:6502/api/status/<task-id>curl http://localhost:6502/api/results/<task-id>curl http://localhost:6502/api/logs/<task-id>curl -X POST http://localhost:6502/api/cancel/<task-id>curl http://localhost:6502/api/jobscurl http://localhost:6502/api/compute-capacitycurl http://localhost:6502/api/netstatcurl -X POST http://localhost:6502/api/ping/<worker-id>curl http://localhost:6502/api/topicscurl http://localhost:6502/api/streamscurl -X POST http://localhost:6502/api/publish \
-H "Content-Type: application/json" \
-d '{
"topic": "test/topic",
"message": "{\"data\": \"value\"}"
}'curl http://localhost:6502/api/subscribe/<topic>curl http://localhost:6502/api/networkcurl -X PUT http://localhost:6502/api/storage/<key> \
-H "Content-Type: application/json" \
-d '{"value": "data"}'curl http://localhost:6502/api/storage/<key>curl http://localhost:6502/api/storage?prefix=cortex/storage/curl -X DELETE http://localhost:6502/api/storage/<key>curl -X PUT http://localhost:6502/api/memory/<key> \
-H "Content-Type: application/json" \
-d '{"value": "data"}'# Get memory for identity
curl http://localhost:6502/api/memory/<key-id>
# Get specific memory key
curl http://localhost:6502/api/memory/<key-id>/<memory-key>curl http://localhost:6502/api/memory?key_id=<key-id>&prefix=pref_curl -X DELETE http://localhost:6502/api/memory/<key>curl http://localhost:6502/api/identitycurl -X POST http://localhost:6502/api/identity \
-H "Content-Type: application/json" \
-d '{
"name": "My Robot",
"set_as_default": true
}'curl -X DELETE http://localhost:6502/api/identity/<key-id>curl http://localhost:6502/api/identity/<key-id>/genesiscurl -X PUT http://localhost:6502/api/identity/<key-id>/enable \
-H "Content-Type: application/json" \
-d '{"feature": "memory"}'curl -X PUT http://localhost:6502/api/identity/<key-id>/disable \
-H "Content-Type: application/json" \
-d '{"feature": "memory"}'curl -X POST "http://localhost:6502/api/hives?key_id=<key-id>" \
-H "Content-Type: application/json" \
-d '{
"name": "Research Team",
"description": "Shared knowledge base"
}'curl "http://localhost:6502/api/hives?key_id=<key-id>"curl -X PUT http://localhost:6502/api/hives/<hive-id>/members/<key-id>curl "http://localhost:6502/api/hives/<hive-id>/memory?key_id=<key-id>"curl -X PUT "http://localhost:6502/api/hives/<hive-id>/memory/<key>?key_id=<key-id>" \
-H "Content-Type: application/json" \
-d '{"value": "data"}'curl -X POST http://localhost:6502/api/llm/complete \
-H "Content-Type: application/json" \
-d '{
"key_id": "<key-id>",
"prompt": "What is Corebrum?",
"provider": "local",
"model": "qwen2.5vl:3b",
"temperature": 0.7
}'The API supports WebSocket and Server-Sent Events (SSE) for real-time updates:
# WebSocket connection
ws://localhost:6502/ws
# SSE endpoint
http://localhost:6502/api/eventsWhen the server is running, access interactive API documentation:
http://localhost:6502/api/docs
For complete API reference, see: ../corebrum-cortex/src/web/routes.rs
The Corebrum Web UI provides a visual interface for managing and monitoring Corebrum operations.
The Web UI is automatically available when you start the REST API server:
# Start web server (includes UI)
cortex webAccess the UI at: http://localhost:6502
The dashboard provides:
- Task Management: Submit, monitor, and manage tasks
- Network Visualization: View mesh network topology
- Resource Monitoring: CPU, memory, and worker status
- Real-time Updates: Live status updates via WebSocket
Submit tasks through the web interface:
- Navigate to the Tasks page
- Click "Submit New Task"
- Upload task definition file or enter YAML/JSON
- Provide input data
- Select identity (optional)
- Submit task
- Task List: View all submitted tasks
- Status Indicators: Visual status (pending, running, completed, failed)
- Real-time Logs: Stream task execution logs
- Results Viewer: View and download task results
- Timeline: Visual timeline of task execution
- Worker Nodes: Visual representation of workers
- Connections: Network connections between nodes
- Resource Usage: CPU and memory usage per worker
- Health Status: Worker health indicators
- Browse Storage: Navigate storage keys
- View Data: Inspect stored values
- Query Interface: Search and filter storage
- CRUD Operations: Create, read, update, delete
- Identity Memory: View memory for specific identities
- Memory Aggregation: See own, ancestor, and hive memories
- Memory Search: Query memory by prefix
- Memory Management: Add, edit, delete memories
- Create Identities: Create new robot identities
- List Identities: View all identities
- Feature Management: Enable/disable features
- Set Default: Set default identity for tasks
For UI source code, see: ../corebrum-cortex/src/web/ui/
Task definitions specify what work should be executed and how. They can be written in YAML or JSON format.
name: "my-task"
version: "1.0"
description: "Task description"
language: "python"
source:
inline:
code: |
# Your code here
result = inputs['number'] * 2
outputs = {"result": result}
inputs:
- name: "number"
type: "integer"
required: true
outputs:
- name: "result"
type: "integer"
requirements:
memory_mb: 512
cpu_cores: 1
timeout_seconds: 300name: Unique task namelanguage: Execution language (python, javascript, docker, wasm, etc.)source: Code source (inline, url, git, gist, docker, wasm)
source:
inline:
code: |
# Python code here
outputs = {"result": 42}source:
url: "https://example.com/script.py"source:
git:
repository: "https://github.com/user/repo.git"
path: "scripts/task.py"
branch: "main"source:
gist:
id: "abc123def456"
filename: "task.py"source:
docker:
image: "python:3.9-slim"
command: ["python", "-c", "print('Hello')"]source:
wasm:
file: "path/to/module.wasm"
entry_point: "compute"
memory_pages: 16inputs:
- name: "data"
type: "object"
required: true
description: "Input data"
default: null
outputs:
- name: "result"
type: "object"
description: "Processing result"requirements:
memory_mb: 1024
cpu_cores: 2
timeout_seconds: 600
dependencies:
- "numpy"
- "pandas"Note: Python dependencies (like numpy, pandas, etc.) are automatically installed by Corebrum workers at runtime if they're not already present. This means you don't need to pre-install packages on workers - just specify them in the dependencies field. To disable auto-install, set COREBRUM_AUTO_INSTALL_DEPS=false before starting the daemon.
# No execution_mode specified = one-shotexecution_mode: "stream_reactive"
stream_config:
trigger: "on_message" # or "time_interval", "rate_limited"
rate_limit_hz: 10
interval_ms: 1000For streaming tasks with Zenoh topics:
inputs:
- name: "sensor_data"
type: "zenoh"
key_expr: "rt/robot1/sensors/data"
encoding: "json" # or "cdr" for ROS2
message_type: "sensor_msgs/LaserScan" # for ROS2
outputs:
- name: "control_command"
type: "zenoh"
key_expr: "rt/robot1/cmd_vel"
encoding: "cdr"
message_type: "geometry_msgs/Twist"For complete examples, see: task_definitions/
Corebrum excels at parallel computing where multiple independent tasks execute simultaneously across the mesh network.
Parallel tasks are independent and can run concurrently on different workers. This maximizes resource utilization and reduces total execution time.
Python Task:
name: "factorial-computation"
language: "python"
source:
inline:
code: |
import math
result = math.factorial(inputs['number'])
outputs = {"result": result}
inputs:
- name: "number"
type: "integer"
required: trueUsage:
# Submit multiple parallel tasks
cortex submit --file task_definitions/python/factorial_task.yaml --input '{"number": 10}'
cortex submit --file task_definitions/python/factorial_task.yaml --input '{"number": 15}'
cortex submit --file task_definitions/python/factorial_task.yaml --input '{"number": 20}'# Generate different sequence lengths in parallel
cortex submit --file task_definitions/python/fibonacci_task.json --input '{"terms": 20}'
cortex submit --file task_definitions/python/fibonacci_task.json --input '{"terms": 50}'
cortex submit --file task_definitions/python/fibonacci_task.json --input '{"terms": 100}'Execute tasks in isolated Docker containers:
name: "data-processing-docker"
language: "docker"
source:
docker:
image: "pandas/pandas:latest"
command:
- "python"
- "-c"
- |
import pandas as pd
import json
data = json.loads('{{inputs.data}}')
df = pd.DataFrame(data)
summary = df.describe().to_dict()
print(json.dumps(summary))
requirements:
memory_mb: 512
cpu_cores: 2
timeout_seconds: 300Usage:
cortex submit --file task_definitions/docker/docker_task.yaml \
--input '{"data": [{"x": 1, "y": 2}, {"x": 3, "y": 4}]}'name: "wasm-factorial"
language: "wasm"
source:
wasm:
file: "wasm_factorial/target/wasm32-unknown-unknown/release/wasm_factorial.wasm"
entry_point: "compute_factorial"
memory_pages: 16name: "wasm-factorial-url"
language: "wasm"
source:
wasm:
url: "https://github.com/user/repo/releases/latest/download/factorial.wasm"
entry_point: "compute_factorial"
memory_pages: 32Usage:
# Build WASM module first
cd wasm_factorial
./build.sh
# Submit WASM task
cortex submit --file task_definitions/wasm/factorial_wasm.yaml --input '{"number": 25}'{
"name": "fibonacci-gist",
"language": "python",
"source": {
"gist": {
"id": "abc123def456",
"filename": "fibonacci.py"
}
}
}{
"name": "git-repo-task",
"language": "python",
"source": {
"git": {
"repository": "https://github.com/user/compute-examples.git",
"path": "algorithms/sorting.py",
"branch": "main"
}
}
}- Independence: Each task should be independent
- Stateless: Tasks should not maintain state
- Idempotent: Tasks should produce the same result when run multiple times
- Resource Awareness: Set appropriate memory and CPU requirements
For more examples, see: task_definitions/python/, task_definitions/docker/, task_definitions/wasm/
Sequential tasks execute in order, with each task's output becoming the next task's input.
Sequential pipelines are useful for:
- ETL Workflows: Extract → Transform → Load
- AI/ML Pipelines: Preprocessing → Inference → Postprocessing
- Multi-stage Analysis: Data processing with multiple transformation stages
- Task Arrays: Define multiple tasks in a single YAML file
- Automatic Chaining: Tasks execute in order automatically
- Previous Result Access: Access previous task output via
resultvariable - Decentralized Execution: Any worker can claim any task in the sequence
- Error Handling: If any task fails, the entire sequence fails
name: "sequential-pipeline"
tasks:
- name: "fetch-data"
language: "python"
source:
inline:
code: |
import requests
response = requests.get(inputs['url'])
outputs = {"data": response.json()}
- name: "process-data"
language: "python"
source:
inline:
code: |
# Access previous task result via 'result' variable
data = result['data']
processed = [item * 2 for item in data]
outputs = {"processed": processed}
- name: "store-results"
language: "python"
source:
inline:
code: |
# Access previous task result
processed = result['processed']
# Store results
outputs = {"stored": len(processed)}Usage:
cortex submit --file task_definitions/sequential/sequential_pipeline.yaml# View results for entire chain
cortex cmos
CMOS[user@local] > results <parent-task-id> --chain
# View logs for entire chain
CMOS[user@local] > logs <parent-task-id> --chain
# Check status of individual tasks
CMOS[user@local] > status <parent-task-id>-0 # First task
CMOS[user@local] > status <parent-task-id>-1 # Second task
CMOS[user@local] > status <parent-task-id>-2 # Third taskSequential tasks use hierarchical IDs:
- Parent ID:
abc123-def456 - Child IDs:
abc123-def456-0,abc123-def456-1,abc123-def456-2
- Data Processing Pipelines: ETL workflows
- AI/ML Workflows: Preprocessing → Inference → Postprocessing
- Robotics Computing: Sensor → Process → Actuate control loops
- Scientific Computing: Simulation → Analysis → Visualization
For more examples, see: task_definitions/sequential/
Streaming tasks are long-running tasks that process data continuously, responding to triggers or time intervals.
Streaming tasks enable:
- Real-time Processing: Continuous data processing
- Event-Driven Execution: React to Zenoh topic messages
- Time-Based Execution: Periodic processing
- Rate-Limited Processing: Control processing frequency
Tasks that react to Zenoh topic messages:
name: "stream-reactive-task"
execution_mode: "stream_reactive"
stream_config:
trigger: "on_message"
rate_limit_hz: 10
inputs:
- name: "sensor_data"
type: "zenoh"
key_expr: "rt/robot1/sensors/data"
outputs:
- name: "processed_data"
type: "zenoh"
key_expr: "rt/robot1/processed/data"
compute_logic:
type: "expression"
language: "python"
code: |
# Process each incoming message
processed = process_data(inputs['sensor_data'])
outputs = {"processed_data": processed}Periodic tasks that run at fixed intervals:
execution_mode: "stream_reactive"
stream_config:
trigger: "time_interval"
interval_ms: 60000 # Every minuteExample: Battery Monitor
cortex submit --file task_definitions/ros2/battery_monitor.yamlProcess high-frequency data with rate limiting:
stream_config:
trigger: "rate_limited"
rate_limit_hz: 5 # Max 5 calls per secondSee Section 15: ROS2 + Corebrum for comprehensive ROS2 streaming examples.
See Section 14: MCP Integration for MCP streaming patterns.
For more examples, see: task_definitions/ros2/, task_definitions/mcp/
MCP is a standardized protocol for AI systems (LLMs) to interact with external tools and data sources.
The main Corebrum repo ships contrib/corebrum-mcp: a stdio MCP server that calls the REST API (/api/submit, /api/jobs, /api/v1/integration/register-worker, …). Use it with Claude Code / Desktop / Dispatch. See that package’s README.md for COREBRUM_URL and Claude config snippets.
Smoke script: scripts/integration/smoke_hub_api.sh — quick curl checks against a running cortex web instance.
Per-agent scripts: scripts/agents/ — test_openclaw.sh, test_claude.sh, test_gemini.sh, optional test_claude_mcp.mjs, and run_all_agent_tests.sh (see scripts/agents/README.md).
MCP enables:
- Tool Integration: Call external tools from AI systems
- Dynamic Data Access: Access databases, APIs, and services
- Streaming Results: Real-time tool execution results
- ROS2 Integration: Process ROS2 sensor data through AI tools
Single operation MCP calls:
name: "mcp-one-shot"
language: "python"
source:
inline:
code: |
import requests
import json
mcp_server = inputs.get('mcp_server_url', 'http://localhost:3000')
tool_name = inputs['tool_name']
tool_args = inputs['tool_args']
# Call MCP server
response = requests.post(mcp_server, json={
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": tool_name,
"arguments": tool_args
}
})
result = response.json()
outputs = {"status": "success", "result": result}Usage:
cortex submit --file task_definitions/mcp/mcp_one_shot_job.yaml \
--input '{
"mcp_server_url": "http://localhost:3000",
"tool_name": "web_search",
"tool_args": {"query": "Corebrum mesh computing"}
}'Continuous MCP processing:
name: "mcp-streaming"
execution_mode: "stream_reactive"
stream_config:
trigger: "on_message"
rate_limit_hz: 5
inputs:
- name: "trigger_data"
type: "zenoh"
key_expr: "mcp/trigger/data"
outputs:
- name: "results"
type: "zenoh"
key_expr: "mcp/results/processed"Usage:
# Submit streaming MCP job
cortex submit --file task_definitions/mcp/mcp_streaming_job.yaml
# Publish trigger data
zenoh pub -k mcp/trigger/data '{"tool_name": "analyze_sensor", "arguments": {"sensor_id": "temp_01", "value": 25.5}}'
# Monitor results
zenoh sub -k mcp/results/processedProcess ROS2 camera images through MCP AI tools:
# 1. Start ROS2 camera node
ros2 run realsense_camera realsense_camera_node
# 2. Start zenoh-bridge-ros2dds
zenoh-bridge-ros2dds
# 3. Submit MCP image analysis job
cortex submit --file task_definitions/mcp/mcp_ros2_image_analysis.yaml
# 4. Monitor analysis results
zenoh sub -k rt/robot1/camera/analysisAI-powered robot control using sensor data:
# 1. Start ROS2 robot nodes
ros2 launch robot_bringup robot.launch.py
# 2. Start zenoh-bridge-ros2dds
zenoh-bridge-ros2dds
# 3. Submit MCP sensor control job
cortex submit --file task_definitions/mcp/mcp_ros2_sensor_control.yaml
# 4. Monitor velocity commands
zenoh sub -k rt/robot1/cmd_velMCP servers expose HTTP endpoints accepting JSON-RPC 2.0 requests:
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/', methods=['POST'])
def mcp_handler():
data = request.json
method = data.get('method')
params = data.get('params', {})
if method == 'tools/call':
tool_name = params.get('name')
tool_args = params.get('arguments', {})
# Process tool call
result = process_tool(tool_name, tool_args)
return jsonify({
"jsonrpc": "2.0",
"id": data.get('id'),
"result": result
})
return jsonify({
"jsonrpc": "2.0",
"id": data.get('id'),
"error": {"code": -32600, "message": "Invalid Request"}
})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3000)For complete MCP documentation, see: task_definitions/mcp/README.md
Corebrum provides native, bi-directional ROS2 integration through Zenoh, enabling seamless communication between ROS2 robots and Corebrum's distributed computing mesh.
Corebrum automatically handles ROS2 message types with:
- CDR Encoding/Decoding: Automatic conversion between ROS2 binary format (CDR) and JSON
- Message Type Registry: Support for common ROS2 message types:
geometry_msgs/Twist- Velocity commandssensor_msgs/Image- Camera imagesnav_msgs/Odometry- Robot odometrygeometry_msgs/Vector3,geometry_msgs/Point- 3D vectors and pointsstd_msgs/Header- Message headers
- Type-Safe Task Definitions: Message types validated at submission time
- Auto-Detection: Message types automatically detected from topic names
- Explicit Specification: Option to explicitly specify message types
- Bi-directional Communication: Subscribe to ROS2 topics and publish ROS2 messages seamlessly
The zenoh-bridge-ros2dds bridges ROS2 DDS topics to Zenoh key expressions. Generate matching hub/member configs with npx zenoh-fleet (robot is a member — do not run a second zenohd on the robot). Then start Corebrum on the hub over TCP:
npx zenoh-fleet
zenohd -c /path/to/<fleet>/zenohd.json5
cortex daemon --zenoh-router tcp://<hub>:7447# Install zenoh-bridge-ros2dds
cargo install zenoh-bridge-ros2dds
# Prefer the zenoh-fleet member file (hub endpoint already filled)
zenoh-bridge-ros2dds -c /path/to/<fleet>/zenoh-bridge-ros2dds-robot.json5
# Or, without a generated config:
zenoh-bridge-ros2ddsFull mesh steps: ../corebrum-cortex/ROS2-README.md.
ROS2 topics are mapped to Zenoh key expressions:
- ROS2 topic:
/robot1/cmd_vel→ Zenoh key:rt/robot1/cmd_vel - ROS2 topic:
/robot1/camera/color/image_raw→ Zenoh key:rt/robot1/camera/color/image_raw
ROS2 Robot → zenoh-bridge-ros2dds → Zenoh Router → Corebrum Workers
Multiple robots can share the same Zenoh mesh (each robot is a zenoh-fleet member connecting to the same hub):
# Robot 1 — generated member file, or:
zenoh-bridge-ros2dds --ros-args -p robot_id:=robot1
# Robot 2
zenoh-bridge-ros2dds --ros-args -p robot_id:=robot2Long-running tasks that respond to ROS2 sensor data:
execution_mode: "stream_reactive"
stream_config:
trigger: "on_message"
rate_limit_hz: 10on_message: React to incoming ROS2 messagestime_interval: Periodic processing (e.g., battery monitoring)rate_limited: Process high-frequency data with rate limiting
Subscribe to sensors and publish control commands:
inputs:
- name: "sensor_data"
type: "zenoh"
key_expr: "rt/robot1/sensors/data"
encoding: "cdr"
message_type: "sensor_msgs/LaserScan"
outputs:
- name: "control_command"
type: "zenoh"
key_expr: "rt/robot1/cmd_vel"
encoding: "cdr"
message_type: "geometry_msgs/Twist"Complete vision-based person detection and following system:
Components:
- Subscribes to ROS2 camera topic (
sensor_msgs/Image) - Uses AI vision model (Qwen2.5VL) for person detection
- Publishes velocity commands (
geometry_msgs/Twist)
Setup:
# 1. Install Ollama and Qwen model
ollama pull qwen2.5vl:3b
ollama serve
# 2. Start ROS2 camera node
ros2 run realsense_camera realsense_camera_node
# 3. Start zenoh-bridge-ros2dds
zenoh-bridge-ros2dds
# 4. Submit person following task
cortex submit --file task_definitions/ros2/person_follow_simple.yaml
# 5. Monitor velocity commands
python3 task_definitions/ros2/monitor_twist_commands.pyReference: task_definitions/ros2/person_follow_simple.yaml, task_definitions/ros2/zenoh_person_follow.py
AI-powered robot control using odometry and battery data:
Features:
- Subscribes to
nav_msgs/Odometryfor navigation - Monitors battery level
- Uses MCP AI for decision-making
- Publishes
geometry_msgs/Twistvelocity commands
Usage:
# 1. Start ROS2 robot nodes
ros2 launch robot_bringup robot.launch.py
# 2. Start zenoh-bridge-ros2dds
zenoh-bridge-ros2dds
# 3. Submit sensor-based control task
cortex submit --file task_definitions/mcp/mcp_ros2_sensor_control.yaml
# 4. Monitor velocity commands
zenoh sub -k rt/robot1/cmd_velReference: task_definitions/mcp/mcp_ros2_sensor_control.yaml
Real-time camera image analysis:
Features:
- Processes
sensor_msgs/Imagestreams - AI-powered object detection
- Streaming analysis results
Usage:
cortex submit --file task_definitions/mcp/mcp_ros2_image_analysis.yaml
zenoh sub -k rt/robot1/camera/analysisReference: task_definitions/mcp/mcp_ros2_image_analysis.yaml, task_definitions/ros2/camera_frame_analysis.yaml
Coordinated control of multiple robots:
Reference: task_definitions/ros2/multi_robot_formation.yaml
# 1. Start ROS2 camera node (on robot)
ros2 run realsense_camera realsense_camera_node
# 2. Start zenoh-bridge-ros2dds
zenoh-bridge-ros2dds
# 3. Submit streaming image analysis task
cortex submit --file task_definitions/mcp/mcp_ros2_image_analysis.yaml
# 4. Monitor analysis results
zenoh sub -k rt/robot1/camera/analysis# 1. Start ROS2 robot nodes
ros2 launch robot_bringup robot.launch.py
# 2. Start zenoh-bridge-ros2dds
zenoh-bridge-ros2dds
# 3. Submit sensor-based control task
cortex submit --file task_definitions/mcp/mcp_ros2_sensor_control.yaml
# 4. Monitor velocity commands
zenoh sub -k rt/robot1/cmd_vel# 1. Setup Ollama and Qwen model
ollama pull qwen2.5vl:3b
ollama serve
# 2. Start ROS2 camera and zenoh-bridge
ros2 run realsense_camera realsense_camera_node
zenoh-bridge-ros2dds
# 3. Submit person following task
cortex submit --file task_definitions/ros2/person_follow_simple.yaml
# 4. Monitor twist commands
python3 task_definitions/ros2/monitor_twist_commands.pyinputs:
- name: "camera_image"
type: "zenoh"
key_expr: "rt/robot1/camera/color/image_raw"
encoding: "cdr"
message_type: "sensor_msgs/Image"outputs:
- name: "velocity_command"
type: "zenoh"
key_expr: "rt/robot1/cmd_vel"
encoding: "cdr"
message_type: "geometry_msgs/Twist"execution_mode: "stream_reactive"
stream_config:
trigger: "on_message"
rate_limit_hz: 10
inputs:
- name: "sensor_data"
type: "zenoh"
key_expr: "rt/robot1/sensors/data"
encoding: "cdr"
message_type: "sensor_msgs/LaserScan"
outputs:
- name: "control_command"
type: "zenoh"
key_expr: "rt/robot1/cmd_vel"
encoding: "cdr"
message_type: "geometry_msgs/Twist"# Monitor ROS2 topics via Zenoh
zenoh sub -k rt/robot1/cmd_vel
zenoh sub -k rt/robot1/camera/analysis# Real-time twist command monitoring
python3 task_definitions/ros2/monitor_twist_commands.pyTasks can save processed images for troubleshooting:
# In task code
cv2.imwrite('/tmp/debug_image.jpg', processed_image)# Check Zenoh connectivity
zenoh info
# Check Corebrum network
cortex netstat- Rate Limiting: Use
rate_limit_hzto prevent overwhelming systems - Error Handling: Graceful handling of sensor failures
- Latency Optimization: Minimizing sensor-to-actuator delay
- Resource Management: Appropriate timeout and memory settings
- Multi-robot Coordination: Using Zenoh for inter-robot communication
- Safety Considerations: Emergency stop mechanisms and fail-safes
- Custom Message Types: Adding support for custom ROS2 message types
- Message Type Extensions: Extending the message type registry
- Performance Tuning: Optimizing for low-latency robotics applications
- Distributed Robot Swarms: Coordinating multiple robots across the mesh
- Integration with ROS2 Navigation Stack: Combining with existing ROS2 systems
For comprehensive ROS2 examples, see: task_definitions/ros2/README.md
The Corebrum Cortex is the cognitive architecture that transforms Corebrum from a compute platform into a true cognitive mesh supercomputer. It consists of three fundamental systems that enable robots to learn, remember, and collaborate.
Each robot in Corebrum has a unique, persistent identity (key_id) that serves as its cognitive fingerprint. This identity enables:
- Isolated Learning: Each robot maintains its own private memory space
- Lineage Tracking: Parent-child relationships for hierarchical learning
- Persistent Context: Identity and memories persist across restarts
- Feature Licensing: Granular control over capabilities (Memory, Hive, AncestorAccess)
Command Line:
# Create a new identity
cortex identity create --name "Robot Alpha"
# List all identities
cortex identity list
# Set default identity
cortex identity set <key_id>
# Show identity details
cortex identity show <key_id>REST API:
curl -X POST 'http://localhost:6502/api/identity' \
-H 'Content-Type: application/json' \
-d '{
"name": "Robot Alpha",
"set_as_default": true
}'Web UI:
Navigate to http://localhost:6502/identity and click "Create Identity"
The Identity system includes feature flags that control access to advanced capabilities:
- Memory: Enables memory storage and retrieval operations
- Hive: Enables hive memory sharing capabilities
- AncestorAccess: Enables access to ancestor memories in the identity lineage
# Enable memory feature
cortex identity enable <key_id> memory
# Enable hive feature
cortex identity enable <key_id> hive
# Enable ancestor access
cortex identity enable <key_id> ancestor_accessWhen you submit a task with an identity context, the robot gains access to its memory:
# Submit task with identity context
cortex submit --file task.yaml \
--input '{"data": "value"}' \
--identity <key_id>
# If default identity is set, it's used automatically
cortex identity set <key_id>
cortex submit --file task.yaml # Uses default identityFor complete identity examples, see: cortex/task_definitions/identity/README.md
The Memory System provides three types of memory access, each serving a different purpose:
Each robot maintains its own private memory space at memory/{key_id}/{key}:
- Isolated: Completely private to each robot
- Secure: Access-controlled by identity
- Persistent: Survives restarts and system reboots
- Requires License: Memory feature flag must be enabled
# Store memory for an identity
curl -X PUT 'http://localhost:6502/api/memory/memory/{key_id}/preference' \
-H 'Content-Type: application/json' \
-d '{"value": "I prefer Python"}'
# Retrieve memory
curl 'http://localhost:6502/api/memory/memory/{key_id}/preference'Robots can access memories from their parent robots in the identity lineage:
- Hierarchical Learning: Child robots inherit knowledge from parents
- Secure Access: Only accessible through verified lineage relationships
- Automatic Loading: Ancestor memories are automatically loaded when tasks run
- Requires License: AncestorAccess feature flag must be enabled
The identity graph tracks parent-child relationships, and when a robot queries its memory, ancestor memories are automatically included in the aggregated view.
Hive memory enables robots to share knowledge within named groups:
- Collaborative: Multiple robots contribute to shared knowledge
- Group-Based: Access controlled by hive membership
- Persistent: Hive memories persist across all member restarts
- Requires License: Hive feature flag must be enabled
Hive memory is stored at memory/hives/{hive_id}/memory/{key} and is automatically aggregated when robots query their memory.
┌─────────────────────────────────────────┐
│ Robot Memory Access │
│ (Automatic Aggregation) │
└─────────────────────────────────────────┘
│
┌─────────┼─────────┐
│ │ │
┌───▼───┐ ┌──▼──┐ ┌────▼────┐
│ Own │ │Anc. │ │ Hive │
│Memory │ │Mem. │ │ Memory │
│ │ │ │ │ │
│Private│ │Lineage│ │Shared │
│ │ │Based │ │Group │
└───────┘ └─────┘ └─────────┘
│ │ │
└─────────┼─────────┘
│
┌───────▼───────┐
│ Aggregated │
│ Memory View │
│ (All Three) │
└───────────────┘
When a task runs with an identity context, memory API helper functions are automatically injected:
# Memory API helpers are automatically available
# when identity_id is set
# Get own memory
preference = get_memory(identity_id, "preference")
# Store own memory
put_memory(identity_id, "last_result", result)
# Query memories with prefix
all_prefs = query_memory(identity_id, prefix="pref_")
# Get hive memory
hive_data = get_hive_memory("research_team", "shared_fact")
# Store hive memory
put_hive_memory("research_team", "new_insight", insight_data)name: memory_persistence_example
language: "python"
source:
inline:
code: |
# Get previous result from memory
previous_result = get_memory(identity_id, "previous_result")
# Process current input
number = inputs.get("number", 0)
factorial = 1
for i in range(1, number + 1):
factorial *= i
# Store result for next execution
put_memory(identity_id, "previous_result", {
"number": number,
"factorial": factorial
})
outputs = {
"number": number,
"factorial": factorial,
"previous_result": previous_result,
"identity_id": identity_id
}# First execution
cortex submit --file task_with_identity.yaml \
--input '{"number": 5}' \
--identity <key_id>
# Second execution - remembers previous result
cortex submit --file task_with_identity.yaml \
--input '{"number": 7}' \
--identity <key_id>When you query memory for an identity, all three types are automatically aggregated:
# Query returns: own + ancestor + hive memories
curl 'http://localhost:6502/api/memory/{key_id}'The response includes:
- All own memories (
memory/{key_id}/*) - All ancestor memories (from parent lineage, if AncestorAccess enabled)
- All hive memories (from all hives the robot belongs to, if Hive enabled)
For complete memory examples, see: cortex/task_definitions/identity/README.md, cortex/task_definitions/memory/README.md
Hives are named groups that enable robots to share memories and collaborate. Think of them as "teams" or "organizations" where robots work together.
- Membership-Based: Only hive members can access hive memories
- Named Groups: Create hives for specific purposes (e.g., "Research Team", "Production Workers")
- Collaborative Learning: Robots share insights and learn from each other
- Persistent: Hive memories persist across all member restarts
1. Create a Hive:
curl -X POST 'http://localhost:6502/api/hives?key_id={creator_key_id}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Research Team",
"description": "Shared knowledge base for research robots"
}'2. Add Robots to the Hive:
# Add robot 1
curl -X PUT 'http://localhost:6502/api/hives/{hive_id}/members/{key_id_1}'
# Add robot 2
curl -X PUT 'http://localhost:6502/api/hives/{hive_id}/members/{key_id_2}'3. Share Knowledge:
curl -X PUT 'http://localhost:6502/api/hives/{hive_id}/memory/fact_1?key_id={key_id_1}' \
-H 'Content-Type: application/json' \
-d '{"value": "The speed of light is 299,792,458 m/s"}'4. Access Shared Knowledge:
# Any hive member can access shared knowledge
curl 'http://localhost:6502/api/hives/{hive_id}/memory?key_id={key_id_2}'┌─────────────────────────────────────┐
│ Hive: Research Team │
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ Robot A │ │ Robot B │ │
│ │ (key_id_1)│ │ (key_id_2)│ │
│ └─────┬─────┘ └─────┬─────┘ │
│ │ │ │
│ └────────┬───────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ Shared Memory │ │
│ │ (Hive Storage) │ │
│ └─────────────────┘ │
└─────────────────────────────────────┘
Robots can access hive memory directly in their task code:
# Get shared knowledge from hive
speed_of_light = get_hive_memory("research_team", "fact_1")
# Contribute new knowledge to hive
put_hive_memory("research_team", "discovery_42", {
"discovered_by": identity_id,
"discovery": "New finding about quantum entanglement",
"timestamp": "2025-01-15T10:30:00Z"
})
# All hive members can now access this knowledgeFor complete hive examples, see: cortex/task_definitions/hive/README.md, cortex/task_definitions/hive/hive_demo.sh
Step 1: Create Identities
cortex identity create --name "Research Bot 1"
# Returns: key_id_1 = 9f5ae164-4c3b-4c8a-9a83-fc7587b5f96a
cortex identity create --name "Research Bot 2"
# Returns: key_id_2 = 8e4bd053-3b2a-3b79-8b72-eb6479a4e85bStep 2: Enable Features
cortex identity enable 9f5ae164-4c3b-4c8a-9a83-fc7587b5f96a memory
cortex identity enable 9f5ae164-4c3b-4c8a-9a83-fc7587b5f96a hiveStep 3: Create a Hive
curl -X POST 'http://localhost:6502/api/hives?key_id=9f5ae164-4c3b-4c8a-9a83-fc7587b5f96a' \
-H 'Content-Type: application/json' \
-d '{
"name": "Quantum Research Team",
"description": "Collaborative learning for quantum computing research"
}'Step 4: Add Members to Hive
curl -X PUT 'http://localhost:6502/api/hives/research_quantum_2025/members/9f5ae164-4c3b-4c8a-9a83-fc7587b5f96a'
curl -X PUT 'http://localhost:6502/api/hives/research_quantum_2025/members/8e4bd053-3b2a-3b79-8b72-eb6479a4e85b'Step 5: Use in Tasks
# Task code running on Robot 2
# Automatically has access to:
# - Own memory (preference = "Rust")
# - Hive memory (discovery_1 from Robot 1)
own_pref = get_memory(identity_id, "preference")
hive_discovery = get_hive_memory("research_quantum_2025", "discovery_1")
outputs = {
"robot_id": identity_id,
"preference": own_pref,
"shared_knowledge": hive_discovery,
"analysis": f"Based on {hive_discovery}, I can now..."
}- Persistent Learning Robots: Robots that learn from each interaction
- Collaborative Research Teams: Multiple robots working on the same problem
- Hierarchical Robot Families: Parent robots pass knowledge to children
For comprehensive Cortex documentation, see: ../corebrum-cortex/docs/blog/introducing-corebrum-cortex.md
Corebrum provides persistent storage capabilities using Zenoh storage backends.
- Filesystem: Simple file-based storage for development
- RocksDB: High-performance key-value storage for production
- InfluxDB: Time-series database for metrics and temporal data
# CLI
cortex storage put "results/task1" '{"result": 42}'
# REST API
curl -X PUT 'http://localhost:6502/api/storage/results/task1' \
-H 'Content-Type: application/json' \
-d '{"value": {"result": 42}}'# CLI
cortex storage get "results/task1"
# REST API
curl 'http://localhost:6502/api/storage/results/task1'# CLI
cortex storage query "results/"
# REST API
curl 'http://localhost:6502/api/storage?prefix=results/'# CLI
cortex storage delete "results/task1"
# REST API
curl -X DELETE 'http://localhost:6502/api/storage/results/task1'cortex/storage/results/{key}- Task resultscortex/storage/cache/{category}/{key}- Cached computationscortex/storage/datasets/{key}- Datasets and model datacortex/storage/config/{key}- Configuration data
Use storage for persistent result caching:
name: "factorial-with-cache"
language: "python"
source:
inline:
code: |
import zenoh
import json
session = zenoh.open()
cache_key = f"cortex/storage/cache/factorial/{inputs['n']}"
# Check cache
cached = session.get(cache_key)
if cached:
result = json.loads(cached[0].payload.deserialize())
outputs = {"result": result, "cached": True}
else:
# Compute
n = inputs['n']
factorial = 1
for i in range(1, n + 1):
factorial *= i
# Store in cache
session.put(cache_key, json.dumps(factorial))
outputs = {"result": factorial, "cached": False}For complete storage examples, see: task_definitions/storage/README.md
Corebrum includes a learning system that tracks preferences and optimizes task execution based on historical data.
Feature-based licensing controls access to advanced capabilities:
- Memory operations
- Hive collaboration
- Ancestor memory access
CMOS provides a virtual file system for accessing mesh resources:
cortex cmos --mount-point /mnt/corebrum
cd /mnt/corebrum
ls tasks/
ls storage/
ls memory/Corebrum supports cognitive traces for tracking AI reasoning and decision-making processes.
For advanced features, see: task_definitions/omnagi/
- Independence: Tasks should be independent and not rely on other tasks
- Stateless: Tasks should not maintain state between executions
- Idempotent: Tasks should produce the same result when run multiple times
- Resource Awareness: Set appropriate memory and CPU requirements
Always include error handling in your task code:
try:
# Main computation
result = compute_something(inputs['data'])
outputs = {"result": result, "status": "success"}
except Exception as e:
outputs = {"error": str(e), "status": "failed"}Set appropriate resource limits:
requirements:
memory_mb: 1024
cpu_cores: 2
timeout_seconds: 600- Validate all inputs
- Sanitize data before processing
- Use identity-based access control
- Enable feature flags only when needed
- Batch Processing: Group related computations
- Memory Efficiency: Use streaming for large datasets
- Caching: Cache frequently used data
- Load Balancing: Distribute tasks across workers
- Use print statements for logging
- Check task logs:
cortex logs <task-id> - Monitor network:
cortex netstat - Verify Zenoh connectivity:
zenoh info
cortex submit --file task.yaml --input '{"data": "value"}'
cortex submit-and-wait --file task.yaml
cortex status <task-id>
cortex results <task-id>
cortex logs <task-id>
cortex cancel <task-id>cortex netstat
cortex ping <worker-id>
cortex topics
cortex streams
cortex publish <topic> '{"data": "value"}'
cortex subscribe <topic>cortex identity create --name "Robot"
cortex identity list
cortex identity set <key-id>
cortex memory put <key> '{"value": "data"}'
cortex memory get <key>cortex hive create "Team Name" --key-id <key-id>
cortex hive join <hive-id> --key-id <key-id>
cortex hive memory put <hive-id> <key> '{"value": "data"}' --key-id <key-id>name: "parallel-task"
language: "python"
source:
inline:
code: |
outputs = {"result": process(inputs['data'])}name: "pipeline"
tasks:
- name: "step1"
language: "python"
source: {...}
- name: "step2"
language: "python"
source: {...}name: "stream-task"
execution_mode: "stream_reactive"
stream_config:
trigger: "on_message"
inputs:
- name: "data"
type: "zenoh"
key_expr: "topic/data"zenohd --config zenoh-config.json5cortex daemon --worker-count 8 --zenoh-router tcp://192.168.1.100:7447cortex web --host 0.0.0.0 --port 8080- Check Zenoh router is running
- Verify port availability
- Check worker capabilities
- Verify workers are available:
cortex netstat - Check task requirements match worker capabilities
- Review task logs:
cortex logs <task-id>
- Verify router is accessible:
zenoh info - Check network connectivity
- Review Zenoh configuration
- Corebrum Project:
../corebrum-cortex/README.md - Zenoh Configuration:
../corebrum-cortex/docs/zenoh_configs/ - Corebrum Cortex:
../corebrum-cortex/docs/blog/introducing-corebrum-cortex.md
- Python:
task_definitions/python/ - Docker:
task_definitions/docker/ - WASM:
task_definitions/wasm/ - ROS2:
task_definitions/ros2/ - MCP:
task_definitions/mcp/ - Sequential:
task_definitions/sequential/ - Identity (Cortex):
cortex/task_definitions/identity/ - Memory (Cortex):
cortex/task_definitions/memory/ - Hive (Cortex):
cortex/task_definitions/hive/ - OpenClaw (Cortex):
cortex/task_definitions/openclaw/ - AGI Operating System:
task_definitions/agi/- Autonomous mission agents that create and manage their own tasks
The Corebrum Python library provides a convenient way to execute Python code on Corebrum without writing YAML/JSON task definitions. Examples are available in the examples/python/ directory:
Install the Python library:
pip install corebrumExample Scripts:
-
examples/python/basic_usage.py- Basic examples covering fundamental Corebrum usage:- Simple function execution with
@run()decorator - Data processing with pandas (demonstrates automatic dependency installation)
- Mathematical computations using standard library
- Using
execute()method for raw code execution
- Simple function execution with
-
examples/python/advanced_usage.py- Advanced features and patterns:- Functions with default arguments
- Error handling and exception catching
- Custom timeout configuration
- Using identity context for memory access
execute()with input data- Comprehensive error handling patterns
-
examples/python/factorial_demo.py- Comprehensive demonstration comparingrun()vsexecute():- Method 1: Using
@run()decorator - best for existing functions - Method 2: Using
execute()method - best for raw code strings - Method 3: Parallel execution of multiple factorial calculations
- Includes detailed comments explaining when to use each approach
- Method 1: Using
Quick Example:
import corebrum
# Decorate function to run on Corebrum
@corebrum.run()
def process_data(data):
import pandas as pd
df = pd.DataFrame(data)
return df.describe().to_dict()
# Call normally - executes on Corebrum
result = process_data([{"x": 1, "y": 2}, {"x": 3, "y": 4}])Repository: https://github.com/Corebrum/corebrum-pip
PyPI Package: https://pypi.org/project/corebrum/
The Corebrum JavaScript library provides a convenient way to execute JavaScript code on Corebrum without writing YAML/JSON task definitions. Examples are available in the corebrum-npm repository:
Install the JavaScript library:
npm install corebrumExample Scripts:
-
basic_usage.js- Basic examples covering fundamental Corebrum usage:- Simple function execution with
run()wrapper - Data processing with array operations
- Mathematical computations using standard library
- Using
execute()method for raw code execution
- Simple function execution with
-
advanced_usage.js- Advanced features and patterns:- Functions with default arguments
- Error handling and exception catching
- Custom timeout configuration
- Using identity context for memory access
execute()with input data- Comprehensive error handling patterns
-
factorial_demo.js- Comprehensive demonstration comparingrun()vsexecute():- Method 1: Using
run()wrapper - best for existing functions - Method 2: Using
execute()method - best for raw code strings - Method 3: Recursive factorial implementation
- Method 4: Parallel execution of multiple factorial calculations
- Includes detailed comments explaining when to use each approach
- Method 1: Using
Quick Example:
const cortex = require('corebrum');
// Wrap function to run on Corebrum
const processData = corebrum.run((data) => {
const result = data.map(item => ({
...item,
processed: true,
timestamp: Date.now()
}));
return result;
});
// Call normally - executes on Corebrum
const result = await processData([
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' }
]);Repository: https://github.com/Corebrum/corebrum-npm
npm Package: https://www.npmjs.com/package/corebrum
- GitHub: https://github.com/Corebrum/corebrum-cortex
- Examples Repository: https://github.com/Corebrum/corebrum-examples
- Python Library: https://github.com/Corebrum/corebrum-pip
- JavaScript Library: https://github.com/Corebrum/corebrum-npm
We welcome contributions! Please see the contributing guidelines in the main Corebrum repository.
Happy Computing with Corebrum! 🚀