Skip to content

LING71671/SMA-OS

Repository files navigation

SMA-OS v1.2.0

中文 | English


一个基于事件溯源和 eBPF 的 AI 智能体调度系统。

CI Security Audit License Release Coverage

📖 简介

SMA-OS (Stateful Machine/Memory Agent Operating System) 是一个面向 AI 智能体集群的调度系统。

核心能力

  1. 事件溯源状态管理 - 基于 Redis/PostgreSQL 的状态持久化,支持状态回放和快照恢复
  2. eBPF 网络安全 - 内核态包过滤,实现纳秒级延迟的安全防护
  3. DAG 任务编排 - 拓扑排序的分布式任务执行,支持依赖管理和并行调度
  4. 意图理解 - 基于 AI 大模型的自然语言理解,将用户指令转换为结构化操作
  5. 🆕 任务管理 - 任务拆解、进度查询、暂停/恢复、子任务聚合
  6. 🆕 依赖分析 - 循环依赖检测、关键路径分析、并行度计算、依赖可视化

设计目标

  • 为 AI 智能体提供可靠的调度基础设施
  • 通过事件溯源保证状态的可追溯性
  • 利用 eBPF 实现高性能的安全隔离
  • 支持 DAG 工作流的自动化编排

🏗️ 核心架构

┌─────────────────────────────────────────────────────────────────┐
│                   Observability UI (Next.js)                    │
│                Real-time DAG Visualization                      │
├─────────────────────────────────────────────────────────────────┤
│                     Control Plane (Rust)                        │
│  ┌─────────────┬─────────────┬─────────────┬─────────────┐      │
│  │ State Engine│  Identity   │  Teardown   │   eBPF      │      │
│  │(Event Source)│   (IAM)    │  (Cleanup)  │  Gateway    │      │
│  └─────────────┴─────────────┴─────────────┴─────────────┘      │
├─────────────────────────────────────────────────────────────────┤
│                    Orchestration (Go)                           │
│  ┌─────────────┬─────────────┬─────────────┐                    │
│  │   Manager   │  Scheduler  │  Evaluator  │                    │
│  │  (DAG Exec) │ (Worker Pool)│(Validation) │                    │
│  └─────────────┴─────────────┴─────────────┘                    │
├─────────────────────────────────────────────────────────────────┤
│                     Memory Bus (Go)                             │
│  ┌─────────────────────┬─────────────────────┐                  │
│  │     Ingestion       │      Vector-KV      │                  │
│  │   (AI Intent)       │  (Vector + KV Store)│                  │
│  └─────────────────────┴─────────────────────┘                  │
├─────────────────────────────────────────────────────────────────┤
│                  Execution Layer (Rust)                         │
│  ┌─────────────────────┬─────────────────────┐                  │
│  │   Sandbox Daemon    │    Stateful REPL    │                  │
│  │  (Firecracker VM)   │  (Persistent Term)  │                  │
│  └─────────────────────┴─────────────────────┘                  │
└─────────────────────────────────────────────────────────────────┘

📦 组件列表

模块 语言 功能
control-plane/state-engine Rust 事件溯源状态内核
control-plane/identity Rust 身份认证管理
control-plane/teardown-ctrl Rust 级联清理控制器
control-plane/fractal-gateway-ebpf Rust (eBPF) XDP 包过滤
orchestration/manager Go DAG 拓扑执行引擎 + 任务管理 + 依赖分析
orchestration/scheduler Go Worker 调度器
orchestration/evaluator Go 输出验证器
orchestration/types Go 共享类型定义
memory-bus/ingestion Go AI 意图提取
memory-bus/vector-kv Go 向量+KV 存储
observability-ui/web-dashboard TypeScript DAG 可视化 + 进度追踪 + 依赖图

🚀 快速启动

环境要求

  • Docker Desktop 20.10+
  • Go 1.21+
  • Rust 1.75+
  • Node.js 20+

1. 克隆仓库

git clone https://github.com/LING71671/SMA-OS.git
cd SMA-OS

2. 启动基础设施

cp .env.example .env
docker-compose up -d

3. 构建服务

# Go 服务
cd memory-bus && go build -o bin/ingestion ./ingestion
cd ../orchestration && go build -o bin/manager ./manager

# Rust 服务 (需要 Docker/Linux)
docker run --rm -v "$(pwd):/workspace" -w /workspace rust:latest \
  bash -c "apt-get update && apt-get install -y protobuf-compiler && \
  cd control-plane && cargo build --release"

# eBPF 程序 (需要 Linux 内核 4.19+)
./scripts/build-ebpf.sh

4. 运行服务

./scripts/start-services.sh

🧪 测试

# Go 测试
cd memory-bus && go test -v ./...
cd ../orchestration && go test -v ./... -cover

# E2E 测试
cd tests/e2e && go test -v .

# 性能基准测试
cd tests/benchmark && go test -bench=. -benchmem .

# Rust 测试
docker run --rm -v "$(pwd):/workspace" -w /workspace rust:latest \
  bash -c "cd control-plane && cargo test --release"

测试覆盖率

模块 覆盖率 状态
orchestration/manager 87.2% ✅ 超过目标 (80%)
E2E 测试 8 tests ✅ 全部通过
性能基准 7 benchmarks ✅ 全部达标

📊 性能目标

指标 目标值
P99 延迟 < 10ms
并发智能体 1000+
事件吞吐量 100K/sec

🔒 安全特性

  • eBPF 沙箱: 内核态网络过滤
  • 身份认证: PostgreSQL IAM 系统
  • 审计日志: 操作可追溯
  • 密钥管理: 环境变量配置

📚 文档

更多文档

🔌 API 端点

任务管理 API

端点 方法 描述
/api/v1/tasks/{id}/progress GET 获取任务进度 (0-100%)
/api/v1/tasks/{id}/pause POST 暂停运行中的任务
/api/v1/tasks/{id}/resume POST 恢复已暂停的任务

依赖分析 API

端点 方法 描述
/api/v1/dags/analysis GET 完整依赖分析
/api/v1/dags/critical-path GET 关键路径分析
/api/v1/dags/parallelism GET 并行度分析
/api/v1/tasks/{id}/impact GET 任务失败影响范围

🤝 贡献

欢迎参与贡献!请阅读 贡献指南 了解贡献流程。

📄 许可证

本项目采用 Apache-2.0 许可证。

🙏 致谢


Made with ❤️ by LING71671

About

SMA-OS: A high-performance, mathematically proven absolute deterministic, heavily sandboxed physical execution layer, and cognitive orchestration AI OS.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors