System Architecture
Mycelium features a layered structural system designed to bridge off-chain AI model capabilities with on-chain cryptographic safety. This is achieved by dividing operations between deterministic on-chain logic (written in Python DSL and compiled to WASM) and dynamic off-chain agent reasoning loops (built using the Mycelium SDK and standard LLM connectors).
Detailed System Topography
The following flowchart represents the boundaries, data exchange paths, and protocols shared between local developer instances, the off-chain agent runner environment, and the Stellar ledger layers:
[ Developer Workspace ]
│ (mycelium check / compile)
▼
[ Compiler Pipeline ] ──► (Transpiles to Rust) ──► [ Optimized WASM Binary ]
│
(deploy to ledger)
▼
[ Off-Chain SDK Runtime ] <───── (JSON-RPC Protocol) ─────► [ Soroban RPC Node ]
- AgentContext Signer │
- Hive Registry Client │
- Escrow Payment Router (commits state changes)
- Agent Loop (LLM Tools) ▼
│ [ Stellar Soroban Ledger ]
(A2A HTTP Call) - Hive Registry Contract
▼ - Active Escrow Accounts
[ Peer Agent Endpoint ] - Instance Storage KeysSandbox Compiler Environment
For security, resource isolation, and consistency, all web compilation requests are executed inside a sandboxed Docker container on the IDE host server. This ensures that untrusted contract code cannot execute malicious commands on the host system.
- Isolation Model: The compiler runs in a container built from `mycelium-compiler:latest`.
- Network Constraint: Network access is completely disabled via
--network noneto prevent data exfiltration. - Resource Quotas: Memory allocation is capped at
512 MBand CPU usage is capped at1.0cores. - Execution Timeout: A strict
30-secondtimeout is enforced. If compilation exceeds this threshold, the sandbox process is forcefully terminated. - Offline Caching: Cargo build caching is pre-warmed within the image. Compilation is run in cargo offline mode (
CARGO_NET_OFFLINE=true) to prevent network fetching lag.
Web IDE Architecture
The Mycelium Web IDE consists of an optimized Next.js frontend coupled with a FastAPI backend acting as the API Gateway. Key design features include:
- Authentication: Users authenticate via GitHub OAuth. The API Gateway issues a secure, signed JWT session token to the frontend.
- Credentials Security: User credentials and GitHub access tokens are encrypted using AES-256-GCM before being stored in Firebase Realtime Database. They are decrypted in-memory only when communicating with GitHub on behalf of the user.
- Git-Backed Workspaces: Rather than using a local database, user workspaces are directly mapped to GitHub repositories. Changes are committed and retrieved dynamically via GitHub contents APIs.
Compiler Transpilation Pipeline
The Mycelium transpiler converts Python contract sources to WebAssembly through a strict four-stage pipeline designed to guarantee safety, type alignment, and performance:
Compiler Benchmark Specs
To maintain system accuracy, Mycelium validates compilation against 300 test fixtures. These cover 100 core contracts (storage tests, basic math, type boundaries) and 200 advanced contracts (escrow rules, registry details, multi-signature conditions). Currently, 132 out of the 300 templates compile cleanly and are fully available for testing in the Playground.
Pinned Toolchain Specs
To ensure compilation consistency across various platforms, Mycelium locks all compiler actions to specific dependency versions:
27.0.026.1.0wasm32v1-nonerust:1.95-slim-bookworm