Skip to content

Mutou322/SymNebula

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SymNebula — 符号星云

Scientific Computing Runtime Platform

一张活的、可自动重算的数学草稿纸。 一个可嵌入、可观察、可跨语言调用的确定性数学内核平台。

SymNebula 是一个以 Rust 编写的确定性数学 Runtime Platform,提供 Formula Parser → AST → IR → ConstraintGraph 的全链路公式推演,支持 C ABI / Python Bridge / Event Stream 多层嵌入接口,并通过 Plugin System 实现求解器、节点类型、外部模块的动态扩展。Phase 9 新增 Tensor Runtime、PDE 求解、DSL、编译器、GPU Kernel Fusion、Sparse 矩阵等科学计算能力。


架构总览

┌──────────────────────────────────────────────────────────────────┐
│                        Scientific Computing Runtime              │
├──────────────────────────────────────────────────────────────────┤
│  DSL Layer          dsl/ grammar → parser → tensor/pde cmd       │
│  Compiler Layer     compiler/ lowering → GPU/SIMD/JIT            │
│  PDE Runtime        pde/ heat / wave / poisson / NS / FEM        │
│  Tensor Runtime     tensor/ N-D ops → autodiff → solver          │
│  Sparse Runtime     sparse/ CSR/COO → Jacobian → solver          │
│  Graph Optimizer    optimizer/ folding → fusion → partition      │
│  Adaptive Scheduler scheduler/ GPU/CPU/Remote load balance       │
│  GPU Kernel Fusion  gpu/ WGSL kernel fusion                      │
├──────────────────────────────────────────────────────────────────┤
│  Clients (Python / C / AI / Web)                                 │
│     ┌───────┴───────┐                                            │
│     │  External API  │  session/external_api.rs                   │
│     │  C ABI (ffi/) │  extern "C"                                │
│     │  Python Bridge │  pyo3 #[pyclass]                          │
│     └───────┬───────┘                                            │
│  ┌──────────┴──────────┐                                         │
│  │  RuntimeSession      │  session/session.rs + api.rs            │
│  │  add_formula / tick  │  solve / get_value                     │
│  │  snapshot            │  register_solver / solve_with          │
│  └──────────┬──────────┘                                         │
│  ┌──────────┼──────────┐  ┌───────────────┐  ┌─────────────────┐│
│  │Formula   │Constraint│  │ Event Stream  │  │  Observatory    ││
│  │Parser    │Graph     │  │ tokio broadcast│  │  Graph/Sparse/  ││
│  │Token→IR  │DirtyProp │  └───────────────┘  │  Tensor/PDE/... ││
│  └──────────┴──────────┘                     └─────────────────┘│
├──────────────────────────────────────────────────────────────────┤
│  Distributed OS: Cluster / Scheduler / Fabric / Network          │
│  Storage / PersistentWorld / WASM / Monitor                      │
└──────────────────────────────────────────────────────────────────┘

里程碑

Phase 主题 状态
Phase 6 Runtime Platform Core (Parser/Graph/Session/CABI/Python) ✅ 已发布
Phase 7 Plugin Architecture (Solver/Node/Module/Sandbox) ✅ 已发布
Phase 8 Distributed Runtime OS (Cluster/Scheduler/Fabric/PersistentWorld) ✅ 已发布
Phase 9 Scientific Computing (Tensor/PDE/Compiler/DSL/Sparse/Optimizer/GPU) ✅ 已发布
Phase 10 Runtime Intelligence (Observability/Monitor/Optimizer/Scheduler) ✅ 已发布
Phase 11 Runtime Cognition (Cognition/Fabric/Compiler 2.0/AI Coprocessor) ✅ 已发布
Phase 12 Autonomous Scientific Civilization Runtime (Evolution/Ecology/Swarm/Scientist) ✅ 已发布
Phase 13 Scientific Universe Runtime (Physics/Time/Thermo/Life/Observers/Domain Earthquake) ✅ 已发布
Phase 14 AI Observer API — 只读 snapshot 接口层 (31 快照类型, 6 crates) ✅ 已发布

端到端数据流

parse_formula("x = (40 * AU * (1 - kappa)) / c")
  → lex → Token[]
  → parse → Expr::Assign
  → to_ir() → Vec<IRNode>
  → graph.insert_ir() → propagate_dirty() → get_value("x") = 42.0

测试状态

范围 测试数 状态
Runtime (Phase 9) 209
HPC Solver (Phase 5) 19
Advanced GPU (Phase 4) 6
GPU Newton (Phase 4) 5
GPU Batch (Phase 4) 5
Runtime Evolution (Phase 12.1) 32
Scientific Knowledge (Phase 12.2) 24
Compiler Ecology (Phase 12.3) 20
Fabric Swarm (Phase 12.4) 20
Runtime Scientist (Phase 12.5) 22
Runtime Physics (Phase 13) 102
Runtime Time (Phase 13) 65
Runtime Thermodynamics (Phase 13) 43
Runtime Life (Phase 13) 49
Runtime Observers (Phase 13) 63
Domain Earthquake (Phase 13) 68
编译 warning ⚠️ 少量(未清理)

快速开始

# 编译 Runtime
cd ~/sym-nebula

# 运行全部 Runtime 测试
cargo test -p symnebula-runtime

# 编译 Python Bridge
cargo check -p symnebula-runtime --features python

# 编译整个工作区
cargo check --workspace

项目结构

sym-nebula/
├── runtime/                 # 主 Runtime crate (Phase 6-9)
│   ├── src/
│   │   ├── parser/          # Formula lexer + parser + AST + IR
│   │   ├── graph/           # IRNode + ConstraintGraph + RPN fusion
│   │   ├── stream/          # Event bus (tokio broadcast)
│   │   ├── serialization/   # Snapshot save/load (serde JSON)
│   │   ├── session/         # RuntimeSession + API + External API
│   │   ├── ffi/             # C ABI layer (extern "C")
│   │   ├── plugins/         # SolverPlugin + NodePlugin + ModuleLoader
│   │   ├── sandbox/         # Capability sandbox
│   │   ├── registry/        # RuntimeRegistry (聚合)
│   │   ├── sparse/          # CSR/COO sparse matrix + Jacobian
│   │   ├── optimizer/       # DAG optimizer (folding/fusion/partition)
│   │   ├── tensor/          # N-D Tensor + autodiff + solver
│   │   ├── pde/             # PDE solvers (Heat/Wave/Poisson/NS/FEM)
│   │   ├── compiler/        # Lowering → GPU/SIMD Codegen → JIT
│   │   ├── dsl/             # Tensor/PDE DSL grammar + parser
│   │   ├── gpu/             # GPU kernel fusion (WGSL)
│   │   ├── observatory/     # Runtime visualization (9 viewers)
│   │   ├── scheduler/       # Adaptive GPU/CPU/Remote scheduler
│   │   ├── cluster.rs       # Cluster node management
│   │   ├── fabric.rs        # Network fabric
│   │   ├── distributed_scheduler.rs
│   │   ├── persistent_world.rs
│   │   ├── network/         # TCP/UDP transport
│   │   ├── storage/         # Persistent storage
│   │   ├── monitor/         # System monitor
│   │   ├── wasm/            # WASM stub
│   │   ├── python_bridge.rs # pyo3 Python bindings
│   │   └── lib.rs
│   └── Cargo.toml
├── symmath/                # 历史 GPU/分布式求解器 (Phase 4-5)
│   └── crates/
│       ├── gpu_batch_solver/
│       ├── gpu_newton_solver/
│       ├── gpu_newton_solver_advanced/
│       ├── distributed_cluster_solver/
│       └── distributed_cluster_solver_hpc/
├── runtime_evolution/      # Phase 12.1 — Runtime Evolution Engine
├── scientific_knowledge/   # Phase 12.2 — Scientific Knowledge Graph
├── compiler_ecology/       # Phase 12.3 — Autonomous Compiler Ecology
├── fabric_swarm/           # Phase 12.4 — Autonomous Fabric Swarm
├── runtime_scientist/      # Phase 12.5 — Scientific AI Runtime Scientist
├── runtime_physics/        # Phase 13.1 — CausalGraph + Seismic Runtime (+ api.rs)
├── runtime_time/           # Phase 13.2 — Timeline + CausalClock + Rollback (+ api.rs)
├── runtime_thermodynamics/ # Phase 13.3 — EnergyBudget + Equilibrium (+ api.rs)
├── runtime_life/           # Phase 13.4 — Organism + Ecosystem + Extinction (+ api.rs)
├── runtime_observers/      # Phase 13.5 — Observer + Telescope + Dashboard (+ api.rs)
├── domain_earthquake/      # Phase 13.7 — Seismic domain model + ETAS + Guangxi (+ api.rs)
├── core/                   # 历史核心引擎 (legacy)
├── macros/                 # proc-macro crate
├── docs/
│   ├── PHASE6_ROADMAP.md
│   ├── PHASE7_ROADMAP.md
│   └── PHASE8_ROADMAP.md
└── README.md

设计原则

  1. Runtime First, AI Optional — AI/LLM 是外部客户端,不侵入核心
  2. Runtime deterministic — 相同公式 + 输入 → 相同输出
  3. Plugin ≠ Core — 求解器、节点类型、模块都是插件
  4. Sandbox Everywhere — 每个插件绑定 RuntimeCapability
  5. Context-window friendlyexport_context_summary() 提供摘要而非完整 DAG
  6. AI = Observer, Not Mutator — AI 只能通过只读 snapshot API 观察宇宙状态(各 crate 的 src/api.rs),不能直接修改内部状态。所有写操作须经 RuntimeSession 事务隔离

开源协议 | License

GNU General Public License v3.0

Copyright (c) 2026 NebulaMind

About

NebulaMind — Pure mathematical formula deduction & model dynamics engine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors