CC-MCS Daemon Architecture
The "Living Timeline" daemon is an always-on motion processing service that runs on a GCP VM. It maintains continuous sensor alignment, anticipation computation, and gesture detection.
Full Public Reader
CC-MCS Daemon Architecture
Overview
The "Living Timeline" daemon is an always-on motion processing service that runs on a GCP VM. It maintains continuous sensor alignment, anticipation computation, and gesture detection.
Architecture
┌─────────────────────────────────────────────────────────────────────────────┐
│ LIVING TIMELINE DAEMON │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ Devices (iPhone/Watch/Mocopi/AirPods) │
│ │ │
│ │ UDP/HTTP │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ DO Relay ([ip]) │ │
│ │ ────────────────────────────────────────────────────────────────── │ │
│ │ • NAT traversal for mobile devices │ │
│ │ • Geographic flexibility │ │
│ │ • Forwards to GCP VM via HTTP │ │
│ └───────────────────────────────┬──────────────────────────────────────┘ │
│ │ HTTP POST │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ GCP VM (cc-infrastructure-vm @ [ip]) │ │
│ │ ══════════════════════════════════════════════════════════════════ │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────────┐ │ │
│ │ │ cc-mcs-headless (Rust) │ │ │
│ │ │ ───────────────────────────────────────────────────────────────│ │ │
│ │ │ │ │ │
│ │ │ 1. INGRESS LOOP (sensor_receiver) │ │ │
│ │ │ ├─ HTTP POST /api/data (from DO relay) │ │ │
│ │ │ ├─ UDP :12351 (Mocopi direct) │ │ │
│ │ │ └─ Decode → Timestamp → Enqueue │ │ │
│ │ │ │ │ │ │
│ │ │ 2. FUSION LOOP (fusion_loop @ 60Hz) │ │ │
│ │ │ ├─ cc-collection sensor fusion │ │ │
│ │ │ ├─ Multi-device clock normalization │ │ │
│ │ │ ├─ Extended Kalman filtering │ │ │
│ │ │ └─ Output: FusedSkeleton │ │ │
│ │ │ │ │ │ │
│ │ │ 3. WINDOW LOOP (anticipation_bridge @ 50Hz) │ │ │
│ │ │ ├─ SkeletonFrame conversion │ │ │
│ │ │ ├─ Deterministic window slicing │ │ │
│ │ │ ├─ Coverage & validity checks │ │ │
│ │ │ └─ Output: MotionWindow + AnticipationPacket │ │ │
│ │ │ │ │ │ │
│ │ │ 4. GESTURE LOOP (gesture_bridge) │ │ │
│ │ │ ├─ Full-body: GestureClassifier │ │ │
│ │ │ ├─ Hand: HandAnticipationKernel │ │ │
│ │ │ ├─ Action mapping (gesture → DJ command) │ │ │
│ │ │ └─ Output: GestureDetectionEvent │ │ │
│ │ │ │ │ │ │
│ │ │ 5. CONDUCTOR LOOP (conductor_bridge) │ │ │
│ │ │ ├─ Policy evaluation │ │ │
│ │ │ ├─ Event gating │ │ │
│ │ │ └─ Output: PolicySignals │ │ │
│ │ │ │ │ │ │
│ │ │ 6. EMIT │ │ │
│ │ │ ├─ WebSocket broadcast (visualization) │ │ │
│ │ │ ├─ Supabase persistence (replay) │ │ │
│ │ │ └─ HTTP API (on-demand queries) │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ Ports: │ │
│ │ • 8765 - HTTP API (health, config, session) │ │
│ │ • 8766 - WebSocket (real-time streaming) │ │
│ │ • 12351 - UDP (Mocopi direct) │ │
│ │ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ┌─────────────┼─────────────┐ │
│ ▼ ▼ ▼ │
│ ┌────────────────────┐ ┌────────────────┐ ┌──────────────────────┐ │
│ │ Cloud Run │ │ MacBook │ │ Supabase │ │
│ │ (RAG++/Orbit) │ │ (Audio) │ │ (Storage) │ │
│ │ On-demand compute │ │ WebSocket rx │ │ Windows, sessions │ │
│ └────────────────────┘ └────────────────┘ └──────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────────┘Components
### 1. DO Relay (DigitalOcean)
- Purpose: UDP ingress, NAT traversal
- IP: [ip]
- Cost: ~$5/month
- Why: Mobile devices need a stable public endpoint
### 2. GCP VM (cc-infrastructure-vm)
- Purpose: Always-on alignment and processing daemon
- IP: [ip]
- Machine: e2-small (2 vCPU, 2GB RAM)
- Cost: ~$19/month
- Container: cc-mcs-daemon
### 3. Cloud Run Services
- Purpose: Heavy compute (RAG, training), on-demand
- orbit-server: Project orchestration, RAG proxy
- rag-plusplus: Semantic search, CognitiveTwin training
- Cost: ~$0-5/month (pay per use)
Data Flow
| Stage | Input | Output | Rate |
|---|---|---|---|
| Ingress | Raw packets | DeviceFrame | Variable |
| Fusion | DeviceFrames | FusedSkeleton | 60Hz |
| Window | FusedSkeleton | MotionWindow | 50Hz |
| Anticipation | MotionWindow | AnticipationPacket | 50Hz |
| Gesture | AnticipationPacket | GestureEvent | On detection |
| Conductor | AnticipationPacket | PolicySignals | 50Hz |
Session Management
Sessions are managed by the daemon:
POST /session/start → Initializes new session
POST /session/stop → Ends session, flushes buffers
GET /session/status → Current session infoSession Invariants
1. Clock Reset: All device clocks re-synchronized on session start
2. Buffer Clear: All rolling buffers emptied
3. ID Generation: New session UUID minted
4. Persistence: Session metadata written to Supabase
Device Join Protocol
When a new device joins mid-session:
t=0.0s Device sends first packet
t=0.0s Daemon marks device as "JOINING"
t=0.0s Clock offset estimation begins
t=0.2s Jitter buffer accumulates samples
t=0.5s Offset/drift stabilized
t=0.5s Device marked as "ACTIVE"
t=0.5s Authority weight gradually increases
t=2.0s Device at full authority weightReplay Stability
Every emitted window includes:
{
"window_id": "w_1735567890.123_1735567891.123",
"session_id": "uuid",
"config_hash": "sha256(aligner_config)",
"aligner_version": "0.1.0",
"checksum": "crc32(frames)",
"coverage": 0.98,
"device_mask": ["left_iphone", "right_iphone", "watch"]
}This ensures windows can be reproduced exactly from raw packet recordings.
Deployment
Build & Deploy
cd backend/cc-mcs
./deploy-gcp-daemon.sh allCheck Status
./deploy-gcp-daemon.sh statusView Logs
./deploy-gcp-daemon.sh logsSSH to VM
./deploy-gcp-daemon.sh sshFirewall Rules
| Rule | Port | Protocol | Source |
|---|---|---|---|
| allow-cc-mcs-api | 8765 | TCP | [ip]/0 |
| allow-cc-mcs-ws | 8766 | TCP | [ip]/0 |
| allow-cc-mcs-udp | 12351 | UDP | [ip]/0 |
Environment Variables
| Variable | Required | Description |
|---|---|---|
| `SUPABASE_URL` | Yes | Supabase project URL |
| `SUPABASE_ANON_KEY` | Yes | Supabase anonymous key |
| `SENSOR_PORT` | No | HTTP API port (default: 8765) |
| `MOCOPI_UDP_PORT` | No | Mocopi UDP port (default: 12351) |
| `PHRASE_LIBRARY_PATH` | No | Path to phrase library binary |
| `ORBIT_SERVER_URL` | No | Orbit Cloud Run URL |
| `RAG_SERVICE_URL` | No | RAG++ Cloud Run URL |
| `RUST_LOG` | No | Log level (default: info) |
Cost Summary
| Service | Monthly Cost |
|---|---|
| DO Relay | ~$5 |
| GCP VM | ~$19 |
| Cloud Run | ~$0-5 |
| Supabase | ~$0-25 |
| Total | ~$24-54 |
Upgrade Path
More CPU/RAM
gcloud compute instances stop cc-infrastructure-vm --zone=us-central1-a
gcloud compute instances set-machine-type cc-infrastructure-vm \
--zone=us-central1-a --machine-type=e2-medium
gcloud compute instances start cc-infrastructure-vm --zone=us-central1-aAdd GPU (for ML inference)
# Switch to n1-standard with GPU
gcloud compute instances set-machine-type cc-infrastructure-vm \
--zone=us-central1-a --machine-type=n1-standard-4
gcloud compute instances add-accelerator cc-infrastructure-vm \
--zone=us-central1-a --accelerator=type=nvidia-tesla-t4,count=1Promotion Decision
Promote into a technical note or architecture paper with implementation anchors.
Source Anchor
Comp-Core/backend/cc-mcs/DAEMON_ARCHITECTURE.md
Detected Structure
Method · Evaluation · Architecture