Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/fractal-inference-swarms/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
dist/
.next/
.env
.env.local
*.log
logs/
.DS_Store
21 changes: 21 additions & 0 deletions apps/fractal-inference-swarms/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Cortensor Community

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
16 changes: 16 additions & 0 deletions apps/fractal-inference-swarms/PROJECTS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- name: fractal-inference-swarms
category: apps
owner: "@your-github-username"
collaborators:
- "@your-discord#0001"
status: active
created: 2026-02-11
version: v0.1.0
tags:
- cortensor
- orchestration
- ai-swarms
- pouw
- validators
- x402
- observability
79 changes: 79 additions & 0 deletions apps/fractal-inference-swarms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Fractal Inference Swarms (FIS)
Cortensor-Native AI Orchestration Infrastructure
A production-grade distributed inference system that decomposes complex tasks, routes them through Cortensor nodes, validates outputs, and distributes micropayments based on performance.
🎯 Project OverviewFractal Inference Swarms is a Kubernetes-like orchestration layer for decentralized AI inference. It sits on top of Cortensor and provides:
Intelligent Task Decomposition - Break complex prompts into atomic subtasks
Distributed Inference Routing - Route subtasks to multiple Cortensor nodes
Validation & Consensus - Validate outputs using Cortensor validators
Result Aggregation - Merge validated outputs into unified responses
PoUW-Based Scoring - Rank node performance using multi-factor metrics
Micropayment Distribution - Reward high-performing nodes with x402 tokens
Real-Time Observability - Monitor the entire swarm lifecycle via dashboard
This is NOT a prototype. This is enterprise-grade AI infrastructure designed for production workloads.🏗️ Architecture┌─────────────────────────────────────────────────────────────┐
│ User Interface │
│ (Next.js Real-Time Dashboard) │
└────────────────────┬────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ Fractal Orchestrator │
│ ┌──────────────┐ ┌──────────────┐ ┌─────────────────┐ │
│ │ Task Splitter│ │ Merge Engine │ │ Scoring Engine │ │
│ └──────────────┘ └──────────────┘ └─────────────────┘ │
│ ┌──────────────┐ ┌──────────────┐ ┌─────────────────┐ │
│ │ Validation │ │Reward Engine │ │ WebSocket Server│ │
│ └──────────────┘ └──────────────┘ └─────────────────┘ │
└────────────────────┬────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ Cortensor Network │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Node A │ │ Node B │ │ Node C │ │ Node D │ ... │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Cortensor Validators (Consensus) │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ Mock x402 Payment Ledger │
│ (Ready for Real Blockchain Integration) │
└─────────────────────────────────────────────────────────────┘✨ Key Features🧠 Intelligent Orchestration

Automatic task decomposition into optimized subtasks
Dynamic subtask routing to available Cortensor nodes
State machine tracking (CREATED → SPLIT → ROUTED → VALIDATING → MERGED → FINALIZED)
✅ Validation & Consensus

Cross-validation of outputs from multiple nodes
Cortensor validator consensus integration
Conflict resolution using confidence-weighted voting
Quality gates to reject low-confidence results
🔀 Result Merging

Synthesizes distributed outputs into coherent final result
Contribution mapping (tracks which node provided what)
Confidence scoring for merged output
Deduplication and format normalization
📊 PoUW-Based Scoring
Final Score = w₁×consensus + w₂×confidence + w₃×speed + w₄×reliability
Configurable weights via environment variables
Multi-dimensional node evaluation
Real-time leaderboard updates
💰 Economic Layer

Mock x402 micropayment distribution
reward = baseReward × normalizedScore
Complete transaction ledger with audit trail
Stake simulation (increases/slashing based on performance)
📡 Real-Time Dashboard

WebSocket-powered live updates
Agent spawn animations
Session lifecycle visualization
Validator consensus progress bars
Leaderboard and reward distribution charts
8 changes: 8 additions & 0 deletions apps/fractal-inference-swarms/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Release Notes

## v0.1.0 - Initial Release
- Cortensor-native swarm orchestration
- Real-time dashboard
- PoUW scoring engine
- x402 mock reward ledger
- Observability metrics
25 changes: 25 additions & 0 deletions apps/fractal-inference-swarms/STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Project Status

## Current Version
v0.1.0-beta

## Completed
- Task orchestration
- Cortensor session integration
- Validator consensus integration
- PoUW scoring
- x402 mock rewards
- Dashboard visualization

## In Progress
- On-chain artifact storage
- Stake slashing logic

## Planned
- ERC-8004 artifact support
- Real Cortensor mainnet integration
- Benchmark suite

## Known Issues
- Simulated latency variability
- Limited validator diversity in demo mode
7 changes: 7 additions & 0 deletions apps/fractal-inference-swarms/backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
dist
logs
.env
*.log
.git
.gitignore
31 changes: 31 additions & 0 deletions apps/fractal-inference-swarms/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Server Configuration
PORT=3001
NODE_ENV=development
HOST=0.0.0.0

# CORS
CORS_ORIGIN=http://localhost:3000

# WebSocket
WS_PORT=3002
WS_HEARTBEAT_INTERVAL=30000

# Orchestrator Configuration
MAX_CONCURRENT_AGENTS=20
DEFAULT_SWARM_SIZE=5
AGENT_TIMEOUT_MS=30000
TASK_SPLIT_STRATEGY=semantic

# Scoring Engine Weights
SCORING_WEIGHT_CONFIDENCE=0.4
SCORING_WEIGHT_SPEED=0.3
SCORING_WEIGHT_RELIABILITY=0.3

# Reward Engine
BASE_REWARD_TOKENS=100
MIN_SCORE_THRESHOLD=0.3
REWARD_POOL_SIZE=1000

# Logging
LOG_LEVEL=debug
LOG_FORMAT=json
37 changes: 37 additions & 0 deletions apps/fractal-inference-swarms/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:20-alpine AS builder

WORKDIR /app

COPY package.json package-lock.json* ./
RUN npm ci --ignore-scripts

COPY tsconfig.json ./
COPY src ./src

RUN npm run build

FROM node:20-alpine AS runner

WORKDIR /app

ENV NODE_ENV=production

RUN addgroup --system --gid 1001 swarm && \
adduser --system --uid 1001 agent

COPY --from=builder /app/package.json ./
COPY --from=builder /app/package-lock.json* ./
RUN npm ci --omit=dev --ignore-scripts

COPY --from=builder /app/dist ./dist

RUN mkdir -p logs && chown -R agent:swarm logs

USER agent

EXPOSE 3001

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3001/api/health || exit 1

CMD ["node", "dist/server.js"]
Loading