Repository navigation
Daemon Services Architecture
Audience: Programmers
Thread Context: The daemon is a separate long-lived process. The server accepts multiple client connections and dispatches to per-service handlers; engine-side clients connect over the framed IPC transport. The engine falls back to in-process behavior when no daemon is running.
Platform/Backend Scope: Cross-platform IPC — Unix domain sockets on Linux/macOS, named pipes on Windows.
A SparkDaemon is a long-lived background process (inspired by Wine's wineserver) that outlives any single engine or editor instance. It owns shared mutable state — caches, file watches, session coordination — and serves multiple clients over a framed length-prefixed protocol. It exists because several engine subsystems currently keep per-process state that would be better shared: two editor instances can't share a compiled-asset cache, shader hot-reload polls timestamps on the main thread, and collaborative editing is P2P with no persistence.
Originally a plan, the daemon framework has since been implemented. The engine-side client and the standalone daemon both exist.
Overall: Implemented across Windows named pipes and Unix-domain sockets. Control, Asset, Shader, and optional Orchestration run in SparkDaemon; collaboration runs in the separately isolated SparkCollabServer. Build Monitor remains reserved.
| Component | Plan | Status | Evidence |
|---|---|---|---|
| Daemon framework | Phase 1 | Implemented |
SparkDaemon/src/ has DaemonServer.{h,cpp}, ServiceBase.h, main.cpp
|
| Wire protocol / framing | Phase 1 | Implemented |
SparkEngine/Source/Utils/DaemonProtocol.h, DaemonFraming.h
|
| Engine-side client | Phase 1 | Implemented |
DaemonClient.{h,cpp}, DaemonConnection.{h,cpp}, DaemonLifecycle.{h,cpp}, DaemonDiagnostics.{h,cpp}
|
| Control service | (new, not in original plan) | Implemented |
SparkDaemon/src/ControlService.{h,cpp} — ping, shutdown, version, stats |
| Asset service | Phase 3 | Implemented | SparkDaemon/src/AssetService.{h,cpp} |
| Shader service | Phase 2 | Implemented | SparkDaemon/src/ShaderService.{h,cpp} |
| Collab broker | Phase 4 | Implemented, isolated process |
CollaborationService.{h,cpp}, CollaborationProtocol.h, and SparkCollabServer provide token-authenticated sessions, presence, locks, and edit history |
| Build Monitor | (lightweight) | Reserved, not built |
ServiceId::Build = 0x0004 is allocated; no service implementation is present |
| Orchestration | external-process expansion | Implemented, opt-in |
OrchestrationService, journal, identity, and SparkOrchestrator; registered only when explicitly configured |
| CMake wiring | — | Wired |
CMakeLists.txt:996 — add_subdirectory(SparkDaemon) guarded by EXISTS SparkDaemon/CMakeLists.txt
|
The implemented ServiceId enum (DaemonProtocol.h:35) differs from the plan's 0x01–0x04 numbering — a built-in Control service was added at 0x0000:
Control = 0x0000 // built-in: ping, shutdown, version query
Asset = 0x0001 // compiled-asset cache, cook pipeline
Shader = 0x0002 // compile, disk cache, hot reload
Collab = 0x0003 // collaborative editing broker (SparkCollabServer)
Build = 0x0004 // reserved build-monitor protocol slot
Orchestration = 0x0005 // trusted opt-in process control plane
┌─────────────┐ ┌─────────────┐ ┌──────────────┐
│ Editor #1 │ │ Editor #2 │ │ CLI cook tool│
│ (client) │ │ (client) │ │ (client) │
└──────┬──────┘ └──────┬──────┘ └──────┬───────┘
│ │ │
└────────┬───────┴───────┬───────┘
│ socket/pipe │
┌─────┴───────────────┴─────┐
│ SparkDaemon │
│ ┌─────────┐ ┌─────────┐ │
│ │ Control │ │ Asset │ │
│ │ Service │ │ Service │ │
│ ├─────────┤ ├─────────┤ │
│ │ Shader │ │ Orchestr.│ │
│ │ Service │ │ (opt-in) │ │
│ └─────────┘ └─────────┘ │
└───────────────────────────┘
SparkCollabServer (separate trust boundary)
└─ token-authenticated sessions, locks, presence, edit history
Length-prefixed binary frames, reusing the serialization pattern from CollaborativeEditSession:
[4 bytes: payload length][2 bytes: service ID][2 bytes: message type][N bytes: payload]
Framing lives in DaemonFraming.h; message/service definitions in DaemonProtocol.h.
Handles PingRequest, ShutdownRequest, version query, and StatsRequest. DaemonServer may share its stats/shutdown state with ControlService so a ShutdownRequest cleanly stops the server.
Backend for the compiled-asset cache and cook pipeline (mesh compression, texture mip gen, audio transcode). Lets multiple editors share one warm cache and replaces per-process timestamp polling with file watchers. Client requests: GetAsset, CookAsset, WatchDirectory, GetCacheStats, InvalidateCache.
Owns warm compiler state, a persistent shader disk cache, and a thread pool for parallel variant compilation. ShaderHotReload becomes a thin client receiving push events instead of polling. Client requests: CompileShader, CompileBatch, WatchShaders, GetCacheEntry, WarmCache.
SparkCollabServer hosts CollaborationService in a separate process because collaborative traffic has a different trust class from local cache and orchestration traffic. It provides capability-token-authenticated session creation/join/delete, presence, node locks, bounded operation history, snapshots, peer expiry, and lock cleanup. The legacy editor P2P path remains a distinct compatibility surface; it is not the daemon broker.
Planned lightweight service to watch CMakeLists.txt/source files and stream BuildStatus events. The service ID is reserved, but no backend is present.
| Component | Role |
|---|---|
AssetPipeline (Graphics/AssetPipeline.h) |
Asset service backend |
SparkShaderCompiler/src/ |
Shader service backend |
ShaderHotReload (Graphics/ShaderHotReload.h) |
Becomes a daemon client |
CollaborationService / CollaborationProtocol
|
Standalone authoritative collaboration broker |
ConsoleProcessManager (Utils/) |
Pattern for daemon launch |
Process::Builder (Utils/Process.h) |
Daemon process launcher (Detached()) |
VirtualFileSystem (Engine/) |
Gets a DaemonProvider mount |
Each service is independently shippable, and the engine falls back to in-process behavior when no daemon is running — so adding a service never breaks the no-daemon path.
-
Original entry date: 2026-04-16 (
daemon-services-architecture-2026-04-16.md, type: Plan) - Verified against codebase 2026-08-26.
- Status bullets:
-
Framework Implemented —
SparkDaemon/src/(DaemonServer, ServiceBase, main) plus engine-sideDaemonClient/Connection/Protocol/Framing/Lifecycle/DiagnosticsunderSparkEngine/Source/Utils/. -
Control / Asset / Shader services exist; a built-in Control service (
0x0000) was added that wasn't in the original plan. -
Service-ID numbering changed from the plan's
0x01–0x04toControl=0x0000, Asset=0x0001, Shader=0x0002, Collab=0x0003. -
Collaboration is implemented in isolated
SparkCollabServer; Build Monitor remains reserved/not built. - Windows named-pipe and Unix-domain-socket transports are both implemented.
- CMake wiring confirmed at
CMakeLists.txt:996.
-
Framework Implemented —
- SparkBuild In-Tree — sibling developer tooling
-
Wine Role and Fallback Tiers — the
wineserverpattern that inspired this
Published from 2b03dc797148. Edit the canonical source in wiki/.
- Documentation
- Docs route
- Wiki index
- Guides
- Tutorials
- Samples
- Examples
- API Reference
- API route
- Reference
- Build Guide
- Dependencies
- FAQ
- Changelog
- Roadmap
- Contributing
- Code of Conduct
- Home
- FAQ
- Getting Started
- Quick-Start Tutorial
- Making Your First Game
- Making Your First Multiplayer Game
- Artist Workflow Guide
- Editor Walkthrough
- Migration Guide
- How SparkEngine Works
- Architecture Overview
- Engine Architecture Flowchart
- Creating a Game Module
- Game Modules (catalog)
- Entity Component System
- Rendering and Graphics
- Physics
- Cloth Simulation
- Audio
- Input System
- Camera System
- Scripting with AngelScript
- Visual Scripting
- AI and Navigation
- Animation
- 2D Systems
- Networking
- Dedicated Server
- Multiplayer Quick Start
- Area Server Architecture
- Scene Management
- Large World Support
- Collaborative Editing
- Coroutine System
- Event System
- Event Response System
- Job System
- UI System
- UI Layout Extensions
- Localization
- Dialogue System
- Destruction System
- Replay System
- Achievement System
- Loading System
- Mod System
- Content Delivery
- Tween System
- Memory Integrity
- Gameplay Systems
- Terrain and Procedural Generation
- Save System
- Persistence System
- Day Night Cycle and Weather
- Cinematic Sequencer
- Runtime Prefabs
- SparkEditor
- Editor Tutorials
- SparkConsole
- SparkDaemon
- Shader Pipeline
- Asset Pipeline
- Asset Validation
- Asset Migration
- Game Packaging
- Online Services
- DataTable System
- Loot and Crafting System
- CSG System
- Font System
- Timer Manager
- Movie Render Pipeline
- HLOD and World Partition
- Remote Debug System
- Selection Manager
- Asset Dependency Graph
- Editor Automation
- File Watcher
- Project Templates
- System Requirements
- VR Support
- Mobile Platform
- Accessibility
- Platform Input
- Platform Certification
- Cross-Compilation: Wine Testing
- RHI Abstraction Layer
- D3D11 Backend
- D3D12 Backend
- Vulkan Backend
- OpenGL Backend
- Metal Backend
- DXR Raytracing
- Hybrid Ray Tracing
- Upscaling (DLSS/FSR)
- Render Graph
- Shader Graph
- GPU Particles
- GPU-Driven Rendering
- Volumetric Fog
- Volumetric Clouds
- Global Illumination
- Virtual Texturing
- Water Rendering
- Clustered Lighting
- Material System
- Post-Processing
- Shadow System
- Particle System
- Decal System
- Sky and Atmosphere
- Foliage System
- Mesh Shaders
- Neural Rendering
- Configuration Reference
- Performance Tips
- Benchmark Framework
- Threading Model
- Fuzz Policy and Parser Security
- Memory Safety
- Memory Management Patterns
- Build System and CMake Modules
- Profiler and Debugging
- Performance Profiling Guide
- Telemetry System
- Crash Reporting
- Golden Image Testing
- Utilities
- Testing
- Fuzz Policy and Parser Security
- Codebase Statistics
- Codebase Health
- Error Handling Patterns
- Hot Reload Overview
- Troubleshooting
- Contributing
- Workflow Patterns
- Build Optimizations
- CI Reproducible Builds
- GitHub API and PR Checks
- Git Rebase Conflicts
- Clang-Format
- Code Quality Violations
- AI Bloat Pattern
- MinGW + Wine Cross-Compilation
- Live Editor Testing
- Engine & Renderer Landscape
- DuetOS Portability Catalog
- Five-Engine Analysis
- Eleven-Engine Analysis
- ThorVG / Unity Graphics Analysis
- Advanced Techniques Catalog
- Third-Party Library Evaluation
- Engine Viability Evaluation
- Engine Feature Recommendations
- Project Recommendations
- Mac Compatibility Analysis
- Codebase Observations
- Codebase Bloat Audit
- Test Suite Audit
- Documentation Coverage Audit
- ThirdParty Dependencies Audit
- Load Test Baseline
- Gameplay Systems Status
- SparkGame Module Status
- Stub and Abandoned Features
- Memory Integrity System
- Memory Safety Evaluation
- Hardware Acceleration Systems
- Jolt Physics Integration
- GPU/CPU Separation Plan
- Daemon Services Architecture
- Reflection & Polymorphism Refactoring Plan
- SparkBuild In-Tree
- Wine No-JobSystem Breakthrough
- Wine Role and Fallback Tiers