Computational Choreography - Complete System Architecture
The Computational Choreography (CC) system transforms raw motion sensor data into musically-coherent audio control signals. The architecture follows a strict **bottom-up dependency graph** where lower layers know nothing about higher layers.
Full Public Reader
Computational Choreography - Complete System Architecture
## Table of Contents
1. [Executive Overview](#1-executive-overview)
2. [System Stack Diagram](#2-system-stack-diagram)
3. [Crate Hierarchy](#3-crate-hierarchy)
4. [Layer-by-Layer Breakdown](#4-layer-by-layer-breakdown)
5. [Data Flow Pipeline](#5-data-flow-pipeline)
6. [Module Reference](#6-module-reference)
7. [Type System](#7-type-system)
8. [Frozen Contracts](#8-frozen-contracts)
9. [CC-Echelon Workspace Deep Dive](#9-cc-echelon-workspace-deep-dive) (18 crates, ~50,000 lines)
10. [CC-RAG-Plus-Plus Deep Dive](#10-cc-rag-plus-plus-deep-dive) (51 files, 24,879 lines)
11. [Python Layer Architecture](#11-python-layer-architecture) (~60,000 lines)
12. [Complete Data Flow Pipeline](#12-complete-data-flow-pipeline)
13. [FROZEN Contracts & Schema Versions](#13-frozen-contracts--schema-versions)
14. [Complete Crate Reference Table](#14-complete-crate-reference-table)
15. [Glossary of Key Terms](#15-glossary-of-key-terms)
---
1. Executive Overview
The Computational Choreography (CC) system transforms raw motion sensor data into musically-coherent audio control signals. The architecture follows a strict bottom-up dependency graph where lower layers know nothing about higher layers.
┌─────────────────────────────────────────────────────────────────────────────────┐
│ COMPUTATIONAL CHOREOGRAPHY │
│ │
│ "Motion becomes sound through anticipation, not reaction" │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ SENSORS │───▶│ ALIGNMENT │───▶│ SEMANTICS │───▶│ AUDIO │ │
│ │ (Motion) │ │ (Windows) │ │ (Meaning) │ │ (Sound) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ Key Principle: Every semantic value carries CONFIDENCE and VALIDITY HORIZON │
└─────────────────────────────────────────────────────────────────────────────────┘Core Statistics (EXHAUSTIVE COUNT - December 2025)
| Metric | Value |
|---|---|
| Total Rust Crates | 32 (13 top-level + 18 cc-echelon + 1 workspace) |
| Python Packages | 2 (cc-ml, cc-core) |
| Total Rust Source Lines | ~185,000 |
| Total Python Source Lines | ~60,000 |
| cc-rag-plus-plus | 24,879 lines (51 files) |
| cc-echelon workspace | ~50,000 lines (18 sub-crates) |
| cc-window-aligner | ~22,000 lines |
| cc-ml Python | ~33,000 lines |
| cc-core Python | ~27,000 lines |
| Test Coverage | 400+ tests |
| FROZEN Contracts | 5 (v1.0.0) |
| CC-Echelon Sub-crates | 18 |
| ML Model Families | 11 |
---
2. System Stack Diagram
╔═════════════════════════════════════════════════════════════════════════════════╗
║ FULL SYSTEM STACK ║
║ (Bottom to Top, Left to Right) ║
╠═════════════════════════════════════════════════════════════════════════════════╣
║ ║
║ ┌───────────────────────────────────────────────────────────────────────────┐ ║
║ │ LAYER 7: AUDIO OUTPUT │ ║
║ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ ║
║ │ │ audio-engine │ │ ts-shift │ │ dsp-utils │ │ ║
║ │ │ (cpal, mixer) │ │ (rubberband) │ │ (filters, lim) │ │ ║
║ │ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │ ║
║ └───────────┼────────────────────┼────────────────────┼────────────────────┘ ║
║ │ │ │ ║
║ ┌───────────┼────────────────────┼────────────────────┼────────────────────┐ ║
║ │ ▼ LAYER 6: SCHEDULING & CONTROL ▼ │ ║
║ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ ║
║ │ │ scheduler │ │ link-clock │ │ control-bus │ │ ║
║ │ │ (quantizer,exec)│ │ (Ableton Link) │ │ (ring buffers) │ │ ║
║ │ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │ ║
║ └───────────┼────────────────────┼────────────────────┼────────────────────┘ ║
║ │ │ │ ║
║ ┌───────────┼────────────────────┼────────────────────┼────────────────────┐ ║
║ │ ▼ LAYER 5: DECISION (CONDUCTOR) ▼ │ ║
║ │ ┌─────────────────────────────────────────────────────────────────┐ │ ║
║ │ │ cc-conductor │ │ ║
║ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ ║
║ │ │ │ action │ │ budget │ │ gate │ │ trigger │ │ │ ║
║ │ │ │ (verbs) │ │(resources)│ │(predicates)│ │(conditions)│ │ │ ║
║ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ ║
║ │ └─────────────────────────────────┬───────────────────────────────┘ │ ║
║ └────────────────────────────────────┼──────────────────────────────────────┘ ║
║ │ ║
║ ┌────────────────────────────────────┼──────────────────────────────────────┐ ║
║ │ LAYER 4: ANTICIPATION & RETRIEVAL │ ║
║ │ ┌─────────────────────────────────┼───────────────────────────────┐ │ ║
║ │ │ cc-anticipation │ cc-retrieval │ │ ║
║ │ │ ┌──────────┐ ┌──────────┐ │ ┌──────────┐ ┌──────────┐ │ │ ║
║ │ │ │ horizon │ │ events │ │ │ phrase │ │ result │ │ │ ║
║ │ │ │ forecast │ │ forecast │ │ │ library │ │ ranking │ │ │ ║
║ │ │ └──────────┘ └──────────┘ │ └──────────┘ └──────────┘ │ │ ║
║ │ │ ┌──────────┐ │ ┌──────────┐ │ │ ║
║ │ │ │ packet │ │ │ query │ │ │ ║
║ │ │ │(v1 FROZEN)│ │ │ builder │ │ │ ║
║ │ │ └──────────┘ │ └──────────┘ │ │ ║
║ │ └─────────────────────────────────┴───────────────────────────────┘ │ ║
║ └───────────────────────────────────────────────────────────────────────────┘ ║
║ │ ║
║ ┌────────────────────────────────────┼──────────────────────────────────────┐ ║
║ │ LAYER 3: SEMANTIC INTERPRETATION │ ║
║ │ ┌─────────────────────────────────┴───────────────────────────────┐ │ ║
║ │ │ cc-semantic │ │ ║
║ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ ║
║ │ │ │ phase │ │ momentum │ │ tension │ │ intent │ │ │ ║
║ │ │ │(cyclic φ)│ │(velocity)│ │(jerk/disp)│ │(direction)│ │ │ ║
║ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ ║
║ │ │ ┌──────────┐ ┌──────────┐ ┌────────────────────────┐ │ │ ║
║ │ │ │stability │ │ regime │ │ frame (v1 FROZEN) │ │ │ ║
║ │ │ │(health) │ │(classify)│ │ SemanticFrame │ │ │ ║
║ │ │ └──────────┘ └──────────┘ └────────────────────────┘ │ │ ║
║ │ └─────────────────────────────────────────────────────────────────┘ │ ║
║ └───────────────────────────────────────────────────────────────────────────┘ ║
║ │ ║
║ ┌────────────────────────────────────┼──────────────────────────────────────┐ ║
║ │ LAYER 2: ALIGNMENT & WINDOWING │ ║
║ │ ┌─────────────────────────────────┴───────────────────────────────┐ │ ║
║ │ │ cc-window-aligner │ │ ║
║ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ ║
║ │ │ │ PIPELINE STAGES │ │ │ ║
║ │ │ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌─────┐ │ │ │ ║
║ │ │ │ │ Time │─▶│Resample│─▶│ Coord │─▶│ Fusion │─▶│Window││ │ │ ║
║ │ │ │ │Normalize│ │ (50Hz) │ │ Unify │ │(multi-D)│ │ ││ │ │ ║
║ │ │ │ └────────┘ └────────┘ └────────┘ └────────┘ └─────┘ │ │ │ ║
║ │ │ └──────────────────────────────────────────────────────────┘ │ │ ║
║ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ ║
║ │ │ │ skeleton │ │ clock │ │ buffer │ │ audit │ │ │ ║
║ │ │ │(27 bones)│ │ (sync) │ │(ring buf)│ │ (trace) │ │ │ ║
║ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ ║
║ │ │ ┌──────────────────────┐ ┌──────────────────────────┐ │ │ ║
║ │ │ │ interpolation │ │ validation │ │ │ ║
║ │ │ │ (linear, slerp, hold)│ │ (invariants, discontin.) │ │ │ ║
║ │ │ └──────────────────────┘ └──────────────────────────┘ │ │ ║
║ │ └─────────────────────────────────────────────────────────────────┘ │ ║
║ └───────────────────────────────────────────────────────────────────────────┘ ║
║ │ ║
║ ┌────────────────────────────────────┼──────────────────────────────────────┐ ║
║ │ LAYER 1: FOUNDATION TYPES │ ║
║ │ ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐ │ ║
║ │ │ cc-types │ │ cc-protocol │ │ cc-core-rs │ │ ║
║ │ │ (LatentVector, │ │ (MessagePack, │ │ (ring buffers, │ │ ║
║ │ │ Quaternion) │ │ Serde, JSON) │ │ filters, EMA) │ │ ║
║ │ └───────────────────┘ └───────────────────┘ └───────────────────┘ │ ║
║ └───────────────────────────────────────────────────────────────────────────┘ ║
║ │ ║
║ ┌────────────────────────────────────┼──────────────────────────────────────┐ ║
║ │ LAYER 0: SENSOR INPUT │ ║
║ │ ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐ │ ║
║ │ │ motion-bridge │ │ cc-collection │ │ cc-echelon │ │ ║
║ │ │ (mocopi, HTTP, │ │ (sensor fusion, │ │ (Tauri UI, │ │ ║
║ │ │ WebSocket) │ │ Kalman filter) │ │ cc-brain) │ │ ║
║ │ └───────────────────┘ └───────────────────┘ └───────────────────┘ │ ║
║ └───────────────────────────────────────────────────────────────────────────┘ ║
║ ║
╚═════════════════════════════════════════════════════════════════════════════════╝---
3. Crate Hierarchy
3.1 Complete Directory Structure
core/
│
├── cc-types/ # LAYER 1: Foundation types (~700 lines)
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs # LatentVector, Quaternion, basic math
│
├── cc-semantic/ # LAYER 3: Semantic layer (~2,500 lines)
│ ├── Cargo.toml
│ └── src/
│ ├── lib.rs # Confidence, ValidityHorizon, SemanticValue
│ ├── frame.rs # SemanticFrame v1 (FROZEN)
│ ├── phase.rs # CyclicCoordinate, PhaseState
│ ├── momentum.rs # HeadingVector, MomentumState
│ ├── tension.rs # TensionState, TensionTrend
│ ├── intent.rs # IntentState, IntentAvailability
│ ├── stability.rs # StabilityState, StabilityFlags
│ └── regime.rs # RegimeType, RegimeDescriptor
│
├── cc-retrieval/ # LAYER 4: RAG++ Retrieval (~2,200 lines)
│ ├── Cargo.toml
│ └── src/
│ ├── lib.rs # RetrievalError, constants
│ ├── phrase.rs # MotionPhrase v1 (FROZEN)
│ ├── result.rs # RetrievalResult v1 (FROZEN)
│ └── query.rs # RetrievalQuery, SemanticQuery
│
├── cc-window-aligner/ # LAYER 2: Alignment (~22,000 lines)
│ ├── Cargo.toml
│ └── src/
│ ├── lib.rs # WindowAligner, main pipeline
│ ├── types.rs # MotionWindow, SkeletonFrame
│ ├── config.rs # WindowConfig, AlignerMode
│ ├── error.rs # AlignerError
│ │
│ ├── stages/ # Pipeline stages
│ │ ├── mod.rs
│ │ ├── time_normalize.rs # Stage 1: Device → canonical time
│ │ ├── resample.rs # Stage 2: Interpolate to 50Hz
│ │ ├── coordinate.rs # Stage 3: Unify coordinate frames
│ │ ├── fusion.rs # Stage 4: Multi-device fusion
│ │ └── windowing.rs # Stage 5: Slice into windows
│ │
│ ├── skeleton/ # Skeleton model
│ │ ├── mod.rs # 27-bone hierarchy
│ │ ├── mocopi.rs # Mocopi device mapping
│ │ └── transform.rs # Quaternion transforms
│ │
│ ├── interpolation/ # Interpolation policies (FROZEN)
│ │ ├── mod.rs
│ │ ├── linear.rs # Linear scalar/vec3
│ │ ├── slerp.rs # Quaternion slerp
│ │ └── hold.rs # Zero-order hold
│ │
│ ├── clock/ # Clock synchronization
│ │ ├── mod.rs
│ │ └── sync.rs # Multi-device clock sync
│ │
│ ├── buffer/ # Buffering
│ │ ├── mod.rs # Reorder buffer
│ │ └── ring.rs # Ring buffer impl
│ │
│ ├── audit/ # Causality auditing
│ │ ├── mod.rs
│ │ └── trace.rs # Trace recorder
│ │
│ ├── validation/ # Invariant checking
│ │ ├── mod.rs
│ │ ├── invariants.rs # INV-001 through INV-007
│ │ └── discontinuity.rs # Bone discontinuity detection
│ │
│ ├── semantic/ # RE-EXPORTS from cc-semantic
│ │ ├── mod.rs # pub use cc_semantic::*
│ │ ├── projection/ # LOCAL: Projection algorithms
│ │ │ ├── mod.rs # SemanticProjector
│ │ │ ├── config.rs # FROZEN projection thresholds
│ │ │ ├── phase.rs # Autocorrelation phase detection
│ │ │ ├── momentum.rs # EMA velocity decomposition
│ │ │ ├── tension.rs # Jerk/displacement ratio
│ │ │ ├── intent.rs # Directional intent
│ │ │ └── stability.rs # System health metrics
│ │ │
│ │ └── [orphaned files] # Old local impls (unused)
│ │
│ ├── retrieval/ # RE-EXPORTS from cc-retrieval
│ │ ├── mod.rs # pub use cc_retrieval::*
│ │ └── [orphaned files] # Old local impls (unused)
│ │
│ ├── anticipation/ # Anticipation forecasts
│ │ ├── mod.rs
│ │ ├── packet.rs # AnticipationPacket v1
│ │ ├── horizon.rs # HorizonForecast (200ms, 500ms, 1s, 2s)
│ │ └── events.rs # EventForecast
│ │
│ └── conductor/ # Decision layer
│ ├── mod.rs # ConductorDecision v1
│ ├── action.rs # Action vocabulary
│ ├── budget.rs # Resource budgets
│ ├── gate.rs # Boolean predicates
│ ├── trigger.rs # Event conditions
│ ├── clock.rs # Musical clock
│ ├── mode.rs # Conductor modes
│ ├── decision.rs # Decision builder
│ └── trace.rs # Decision trace
│
├── cc-anticipation/ # Anticipation kernel
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
│
├── cc-conductor/ # Conductor policy layer
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
│
├── cc-protocol/ # Unified message types
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
│
├── cc-core-rs/ # Signal processing primitives
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
│
├── cc-collection/ # Sensor fusion library
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
│
├── cc-rag-plus-plus/ # RAG++ retrieval engine
│ ├── Cargo.toml
│ └── crates/
│ ├── core/
│ │ └── src/
│ └── python/
│ └── src/
│
└── cc-echelon/ # Desktop application (workspace)
├── Cargo.toml # Workspace manifest
└── crates/
├── cc-brain/ # AI motion processing
│ └── src/
│ ├── lib.rs
│ ├── conductor.rs
│ ├── latent/
│ │ ├── simple.rs
│ │ └── learned.rs
│ ├── nn/
│ │ ├── encoder.rs
│ │ ├── linear.rs
│ │ └── weights.rs
│ └── lexicon/
│
├── audio-engine/ # Audio output
│ └── src/
│ ├── lib.rs
│ ├── backend.rs
│ ├── mixer.rs
│ ├── loader.rs
│ ├── nodes.rs
│ ├── fx.rs
│ ├── limiter.rs
│ └── synth/
│ ├── mod.rs
│ ├── oscillators.rs
│ ├── filters.rs
│ ├── envelopes.rs
│ ├── voice.rs
│ └── effects.rs
│
├── scheduler/ # Event scheduling
│ └── src/
│ ├── lib.rs
│ ├── clock.rs
│ ├── quantizer.rs
│ ├── executor.rs
│ ├── action.rs
│ ├── action_queue.rs
│ ├── intents.rs
│ └── safety.rs
│
├── control-bus/ # Message passing
│ └── src/
│ └── lib.rs
│
├── motion-bridge/ # Sensor input
│ └── src/
│ ├── lib.rs
│ ├── receiver.rs
│ ├── http_server.rs
│ ├── websocket_server.rs
│ ├── cloud_client.rs
│ ├── lim_rps.rs
│ ├── calibration.rs
│ └── translator.rs
│
├── link-clock/ # Ableton Link
│ └── src/
│ ├── lib.rs
│ ├── beat_clock.rs
│ ├── link_clock.rs
│ └── ffi.rs
│
├── midi-osc/ # MIDI/OSC I/O
│ └── src/
│ ├── lib.rs
│ ├── midi_in.rs
│ ├── midi_out.rs
│ ├── osc.rs
│ ├── mapping.rs
│ └── keyboard.rs
│
├── media/ # Audio file handling
│ └── src/
│ ├── lib.rs
│ ├── clip.rs
│ ├── analysis.rs
│ ├── phrase_db.rs
│ └── transition_fit.rs
│
├── ui-shell/ # User interface
│ └── src/
│ ├── lib.rs
│ ├── main_view.rs
│ ├── echelon_view.rs
│ ├── motion_panel.rs
│ ├── phrase_browser.rs
│ ├── master_controls.rs
│ ├── deck_lane.rs
│ ├── theme.rs
│ ├── world/
│ │ ├── mod.rs
│ │ ├── latent_orb.rs
│ │ ├── motion_trace.rs
│ │ ├── phrase_spine.rs
│ │ └── ...
│ └── physics/
│ ├── mod.rs
│ ├── latent_state.rs
│ └── animation.rs
│
├── phrase-intelligence/ # Phrase recommendation
│ └── src/
│ ├── lib.rs
│ ├── database.rs
│ ├── recommender.rs
│ └── service.rs
│
├── voice-control/ # Voice commands
│ └── src/
│ ├── lib.rs
│ ├── recognizer.rs
│ ├── vad.rs
│ ├── parser.rs
│ └── feedback.rs
│
├── dsp-utils/ # DSP primitives
│ └── src/
│ ├── lib.rs
│ ├── biquad.rs
│ ├── limiter.rs
│ ├── compressor.rs
│ ├── envelope.rs
│ └── meter.rs
│
├── ts-shift/ # Time-stretching
│ └── src/
│ ├── lib.rs
│ └── rubberband.rs
│
├── viz/ # Visualization
│ └── src/
│ ├── lib.rs
│ └── projector.rs
│
├── viz-server/ # WebSocket viz server
│ └── src/
│ └── lib.rs
│
├── shmem-ipc/ # Shared memory IPC
│ └── src/
│ └── lib.rs
│
└── music-brain/ # Music analysis
└── src/
├── lib.rs
├── bpm.rs
├── camelot.rs
├── playlist.rs
└── export.rs3.2 Dependency Graph (Extracted Crates)
┌─────────────────────────────────────────────────────────────────────────┐
│ EXTRACTED CRATE DEPENDENCIES │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────┐ │
│ │ cc-window-aligner │ │
│ │ (re-exports all) │ │
│ │ ~22,000 lines │ │
│ │ 216 tests │ │
│ └───────────┬─────────────┘ │
│ │ │
│ ┌─────────────┴─────────────┐ │
│ │ │ │
│ ▼ ▼ │
│ ┌────────────────────┐ ┌────────────────────┐ │
│ │ cc-retrieval │ │ (local modules) │ │
│ │ ~2,200 lines │ │ stages, skeleton │ │
│ │ 21 tests │ │ interpolation... │ │
│ └─────────┬──────────┘ └────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────┐ │
│ │ cc-semantic │ │
│ │ ~2,500 lines │ │
│ │ 35 tests │ │
│ └─────────┬──────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────┐ │
│ │ cc-types │ │
│ │ ~700 lines │ │
│ └────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘---
4. Layer-by-Layer Breakdown
4.1 LAYER 0: Sensor Input
┌─────────────────────────────────────────────────────────────────────────────┐
│ SENSOR INPUT LAYER │
│ │
│ Purpose: Capture raw motion data from heterogeneous devices │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ SUPPORTED DEVICES │ │
│ ├─────────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ Mocopi │ │ AirPods │ │ Apple Watch │ │ │
│ │ │ (Full body │ │ (Head IMU) │ │ (Wrist IMU) │ │ │
│ │ │ 27 bones) │ │ │ │ │ │ │
│ │ │ 50 Hz │ │ 100 Hz │ │ 100 Hz │ │ │
│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ iPhone │ │ MediaPipe │ │ Future │ │ │
│ │ │ (ARKit pose) │ │ (Camera pose)│ │ Devices... │ │ │
│ │ │ 60 Hz │ │ 30 Hz │ │ │ │ │
│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ TRANSPORT PROTOCOLS │ │
│ ├─────────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ HTTP/REST ───────────────────────────────────────────────┐ │ │
│ │ WebSocket ───────────────────────────────────────────────┤ │ │
│ │ UDP (low-latency) ───────────────────────────────────────┤ │ │
│ │ Bluetooth LE ────────────────────────────────────────────┘ │ │
│ │ │ │ │
│ │ ▼ │ │
│ │ ┌─────────────────┐ │ │
│ │ │ motion-bridge │ │ │
│ │ │ (Crate) │ │ │
│ │ └─────────────────┘ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘4.2 LAYER 1: Foundation Types
┌─────────────────────────────────────────────────────────────────────────────┐
│ FOUNDATION TYPES LAYER │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ cc-types │ │
│ │ (~700 lines) │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ pub struct LatentVector<const N: usize> { │ │
│ │ values: [f32; N], // Latent space coordinates │ │
│ │ confidence: f32, // [0, 1] validity │ │
│ │ timestamp: f64, // Canonical time │ │
│ │ } │ │
│ │ │ │
│ │ pub type Quaternion = [f32; 4]; // [x, y, z, w] rotation │ │
│ │ pub type Vec3 = [f32; 3]; // 3D position/velocity │ │
│ │ pub type Mat3 = [[f32; 3]; 3]; // 3x3 rotation matrix │ │
│ │ │ │
│ │ // Numeric utilities │ │
│ │ pub fn lerp(a: f32, b: f32, t: f32) -> f32; │ │
│ │ pub fn clamp(v: f32, min: f32, max: f32) -> f32; │ │
│ │ pub fn normalize_quat(q: Quaternion) -> Quaternion; │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ cc-protocol │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ // Unified message format for all components │ │
│ │ pub enum Message { │ │
│ │ MotionFrame(MotionFrameMsg), │ │
│ │ SemanticState(SemanticStateMsg), │ │
│ │ AnticipationPacket(AnticipationPacketMsg), │ │
│ │ ConductorDecision(ConductorDecisionMsg), │ │
│ │ AudioControl(AudioControlMsg), │ │
│ │ } │ │
│ │ │ │
│ │ // Serialization: MessagePack (binary) or JSON (debug) │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ cc-core-rs │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ // Signal processing primitives │ │
│ │ pub struct RingBuffer<T, const N: usize>; │ │
│ │ pub struct EmaFilter { alpha: f32 } │ │
│ │ pub struct BiquadFilter { b: [f32; 3], a: [f32; 3] } │ │
│ │ pub struct EquilibriumTracker { /* adaptive baseline */ } │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘4.3 LAYER 2: Alignment & Windowing
┌─────────────────────────────────────────────────────────────────────────────┐
│ ALIGNMENT & WINDOWING LAYER │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ cc-window-aligner │ │
│ │ (~22,000 lines) │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ FIVE-STAGE PIPELINE: │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ │ │ │
│ │ │ RawPacket Stage 1 Stage 2 Stage 3 │ │ │
│ │ │ ┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐ │ │ │
│ │ │ │Device │───▶│ Time │─────▶│Resample│────▶│ Coord │ │ │ │
│ │ │ │ Data │ │Normalize│ │ 50 Hz │ │ Unify │ │ │ │
│ │ │ └───────┘ └───────┘ └───────┘ └───────┘ │ │ │
│ │ │ │ │ │ │
│ │ │ ▼ │ │ │
│ │ │ Stage 5 Stage 4 │ │ │
│ │ │ MotionWindow ┌───────┐ ┌───────┐ │ │ │
│ │ │ ┌───────┐◀────│Window │◀─────│Fusion │ │ │ │
│ │ │ │ 50 fr │ │ Slice │ │Multi-D│ │ │ │
│ │ │ └───────┘ └───────┘ └───────┘ │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ INVARIANTS (INV-001 through INV-007): │ │
│ │ │ │
│ │ INV-001: DETERMINISM │ │
│ │ Same inputs → identical outputs (byte-for-byte) │ │
│ │ │ │
│ │ INV-002: BOUNDEDNESS │ │
│ │ Fixed frame count per window (50 frames @ 50Hz = 1s) │ │
│ │ │ │
│ │ INV-003: EXPLICIT MISSINGNESS │ │
│ │ No silent interpolation; all gaps marked │ │
│ │ │ │
│ │ INV-004: TEMPORAL MONOTONICITY │ │
│ │ Strictly increasing timestamps │ │
│ │ │ │
│ │ INV-005: COVERAGE THRESHOLD │ │
│ │ Min 90% real data (not interpolated) │ │
│ │ │ │
│ │ INV-006: SCHEMA VERSION │ │
│ │ All windows carry schema version tag │ │
│ │ │ │
│ │ INV-007: CHECKSUM │ │
│ │ xxHash64 of frame data for replay verification │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ KEY DATA TYPES: │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ MotionWindow │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ pub struct MotionWindow { │ │
│ │ frames: Vec<SkeletonFrame>, // 50 frames at 50Hz │ │
│ │ latent_frames: Option<Vec<LatentFrame>>, // LIM-RPS output │ │
│ │ t_start: f64, // Canonical start time │ │
│ │ t_end: f64, // Canonical end time │ │
│ │ fps: f32, // 50.0 │ │
│ │ coverage: f32, // [0, 1] real data ratio │ │
│ │ device_mask: DeviceMask, // Which devices contributed │ │
│ │ dropped_frames: Vec<usize>, // Indices of interpolated │ │
│ │ session_id: String, // Session identifier │ │
│ │ window_id: String, // Unique window ID │ │
│ │ aligner_version: String, // "0.1.0" │ │
│ │ schema_version: String, // "0.1.0" │ │
│ │ config_hash: u64, // Config fingerprint │ │
│ │ checksum: u64, // xxHash64 of frame data │ │
│ │ } │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ SkeletonFrame │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ pub struct SkeletonFrame { │ │
│ │ timestamp: f64, // Canonical time │ │
│ │ bones: [BoneState; 27], // All 27 bones │ │
│ │ root_position: [f32; 3], // World-space position │ │
│ │ provenance: FrameProvenance, // Source device info │ │
│ │ } │ │
│ │ │ │
│ │ pub struct BoneState { │ │
│ │ rotation: [f32; 4], // Quaternion [x, y, z, w] │ │
│ │ angular_velocity: [f32; 3], // Degrees per second │ │
│ │ } │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ SKELETON HIERARCHY (27 bones): │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ HIPS (0) │ │
│ │ │ │ │
│ │ ┌───────────────┼───────────────┐ │ │
│ │ │ │ │ │ │
│ │ LEFT_UP_LEG SPINE (3) RIGHT_UP_LEG │ │
│ │ (1) │ (2) │ │
│ │ │ │ │ │ │
│ │ LEFT_LEG CHEST (4) RIGHT_LEG │ │
│ │ (5) │ (6) │ │
│ │ │ │ │ │ │
│ │ LEFT_FOOT UPPER_CHEST (7) RIGHT_FOOT │ │
│ │ (9) │ (10) │ │
│ │ │ ┌───────┼───────┐ │ │ │
│ │ LEFT_TOE_BASE│ NECK (8) │ RIGHT_TOE_BASE │ │
│ │ (13) │ │ │ (14) │ │
│ │ │ HEAD (11) │ │ │
│ │ LEFT_SHOULDER │ RIGHT_SHOULDER │ │
│ │ (15) │ (16) │ │
│ │ │ │ │ │ │
│ │ LEFT_ARM │ RIGHT_ARM │ │
│ │ (17) │ (18) │ │
│ │ │ │ │ │ │
│ │ LEFT_FOREARM │ RIGHT_FOREARM │ │
│ │ (19) │ (20) │ │
│ │ │ │ │ │ │
│ │ LEFT_HAND │ RIGHT_HAND │ │
│ │ (21) │ (22) │ │
│ │ │ │ │ │ │
│ │ ┌───────┼───────┐ │ ┌────┼────┐ │ │
│ │ L_THUMB L_INDEX L_RING │ R_THUMB R_INDEX R_RING │ │
│ │ (23) (24) (25) │ (26) (27) ... │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘4.4 LAYER 3: Semantic Interpretation
┌─────────────────────────────────────────────────────────────────────────────┐
│ SEMANTIC INTERPRETATION LAYER │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ cc-semantic │ │
│ │ (~2,500 lines) │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ THE FIVE SEMANTIC PROJECTIONS: │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ │ │ │
│ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │
│ │ │ │ PHASE │ │ MOMENTUM │ │ TENSION │ │ INTENT │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ Cyclic │ │ Heading │ │ Effort │ │ Preferred│ │ │ │
│ │ │ │ position │ │ Vector │ │ vs Flow │ │ Direction│ │ │ │
│ │ │ │ [0, 2π) │ │ (r,u,f) │ │ [0, 1] │ │ (unit) │ │ │ │
│ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ │
│ │ │ │ │ │
│ │ │ ┌──────────┐ │ │ │
│ │ │ │STABILITY │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ System │ │ │ │
│ │ │ │ Health │ │ │ │
│ │ │ │ [0, 1] │ │ │ │
│ │ │ └──────────┘ │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ANTI-HALLUCINATION PATTERN: │ │
│ │ │ │
│ │ Every semantic value MUST carry: │ │
│ │ │ │
│ │ ┌───────────────────────────────────────────────────────────┐ │ │
│ │ │ pub struct SemanticValue<T> { │ │ │
│ │ │ value: Option<T>, // None if unknown │ │ │
│ │ │ confidence: Confidence, // [0, 1] │ │ │
│ │ │ validity: ValidityHorizon, // How long stable │ │ │
│ │ │ unavailable_reason: Option<UnavailableReason>, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ pub struct Confidence { │ │ │
│ │ │ value: f32, // 0.0 to 1.0 │ │ │
│ │ │ is_valid: bool, // >= MIN_CONFIDENCE_THRESHOLD │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ pub struct ValidityHorizon { │ │ │
│ │ │ frames: usize, // How many frames this is valid │ │ │
│ │ │ ms: u32, // Equivalent milliseconds │ │ │
│ │ │ } │ │ │
│ │ └───────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ PROJECTION DETAILS: │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ PHASE (phase.rs) - Cyclic Motion Tracking │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ // Uses 2D unit vector (cos, sin) to avoid wrap discontinuity │ │
│ │ pub struct CyclicCoordinate { │ │
│ │ cos: f32, // cos(2πφ) │ │
│ │ sin: f32, // sin(2πφ) │ │
│ │ } │ │
│ │ │ │
│ │ pub struct PhaseState { │ │
│ │ coordinate: CyclicCoordinate, // Wrap-safe phase │ │
│ │ scalar_phase: f32, // [0, 1) for display │ │
│ │ periodicity: f32, // [0, 1] how periodic │ │
│ │ period_frames: usize, // Detected period │ │
│ │ phase_type: PhaseType, // Gait, Gesture, Unknown │ │
│ │ confidence: Confidence, │ │
│ │ validity: ValidityHorizon, │ │
│ │ } │ │
│ │ │ │
│ │ Algorithm: Autocorrelation-based period detection │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ MOMENTUM (momentum.rs) - Velocity Decomposition │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ pub struct HeadingVector { │ │
│ │ right: f32, // Body-relative X │ │
│ │ up: f32, // Body-relative Y │ │
│ │ forward: f32, // Body-relative Z │ │
│ │ } │ │
│ │ │ │
│ │ pub struct MomentumState { │ │
│ │ direction: HeadingVector, // Unit heading │ │
│ │ magnitude: f32, // Speed in m/s │ │
│ │ slow_transport: HeadingVector, // EMA-smoothed (trend) │ │
│ │ fast_impulse: HeadingVector, // Residual (bursts) │ │
│ │ impulse_indicator: ImpulseIndicator, // None→Extreme │ │
│ │ confidence: Confidence, │ │
│ │ validity: ValidityHorizon, │ │
│ │ } │ │
│ │ │ │
│ │ Algorithm: EMA decomposition (slow_transport + fast_impulse) │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ TENSION (tension.rs) - Effortful Control │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ pub struct TensionState { │ │
│ │ value: f32, // [0, 1] tension level │ │
│ │ trend: TensionTrend, // Rising, Flat, Falling │ │
│ │ proxies: TensionProxies, // Raw measurements │ │
│ │ confidence: Confidence, │ │
│ │ validity: ValidityHorizon, │ │
│ │ } │ │
│ │ │ │
│ │ pub struct TensionProxies { │ │
│ │ jerk_displacement_ratio: f32, // Jerk per meter │ │
│ │ micro_perturbation: f32, // High-freq oscillation │ │
│ │ stiffness: f32, // Low displacement + high acc │ │
│ │ } │ │
│ │ │ │
│ │ Interpretation: │ │
│ │ High tension (>0.7): Compressed, controlled, ready to release │ │
│ │ Low tension (<0.3): Flowing, ballistic, released │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ REGIME (regime.rs) - Motion Classification │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ pub enum RegimeType { │ │
│ │ Periodic, // Walking, running, cycling │ │
│ │ Ballistic, // Throws, jumps, swings │ │
│ │ Gestural, // Discrete bounded movements │ │
│ │ Transitional, // Between regimes │ │
│ │ Static, // Standing still │ │
│ │ Noisy, // Sensor noise dominates │ │
│ │ QuasiPeriodic, // Almost periodic with drift │ │
│ │ Unknown, // Insufficient data │ │
│ │ } │ │
│ │ │ │
│ │ pub struct RegimeDescriptor { │ │
│ │ primary: RegimeType, │ │
│ │ secondary: Option<RegimeType>, │ │
│ │ evidence: RegimeEvidence, │ │
│ │ duration_frames: usize, │ │
│ │ confidence: Confidence, │ │
│ │ } │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ SemanticFrame v1 (FROZEN) │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ pub struct SemanticFrame { │ │
│ │ // Identity │ │
│ │ timestamp: f64, │ │
│ │ frame_index: usize, │ │
│ │ │ │
│ │ // The Five Projections │ │
│ │ phase: PhaseState, │ │
│ │ momentum: MomentumState, │ │
│ │ tension: TensionState, │ │
│ │ intent: IntentState, │ │
│ │ stability: StabilityState, │ │
│ │ │ │
│ │ // Classification │ │
│ │ regime: RegimeDescriptor, │ │
│ │ │ │
│ │ // Meta │ │
│ │ overall_confidence: Confidence, │ │
│ │ overall_validity: ValidityHorizon, │ │
│ │ provenance: SemanticProvenance, │ │
│ │ } │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘4.5 LAYER 4: Anticipation & Retrieval
┌─────────────────────────────────────────────────────────────────────────────┐
│ ANTICIPATION & RETRIEVAL LAYER │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ cc-retrieval │ │
│ │ (~2,200 lines) │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ RAG++ (Retrieval-Augmented Generation for Motion) │ │
│ │ │ │
│ │ ┌───────────────────────────────────────────────────────────┐ │ │
│ │ │ MotionPhrase v1 (FROZEN) │ │ │
│ │ ├───────────────────────────────────────────────────────────┤ │ │
│ │ │ │ │ │
│ │ │ pub struct MotionPhrase { │ │ │
│ │ │ id: String, // Unique phrase ID │ │ │
│ │ │ name: String, // Human-readable │ │ │
│ │ │ duration_frames: usize, // Length at 50Hz │ │ │
│ │ │ tension_profile: TensionProfile, │ │ │
│ │ │ momentum_profile: MomentumProfile, │ │ │
│ │ │ phase_relationship: PhaseRelationship, │ │ │
│ │ │ invariants: Vec<PhraseInvariant>, // Must hold │ │ │
│ │ │ variants: Vec<PhraseVariant>, // Variations │ │ │
│ │ │ constraints: PlaybackConstraints, │ │ │
│ │ │ metadata: PhraseMetadata, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ └───────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌───────────────────────────────────────────────────────────┐ │ │
│ │ │ PhraseInvariant │ │ │
│ │ ├───────────────────────────────────────────────────────────┤ │ │
│ │ │ │ │ │
│ │ │ // Conditions that MUST hold during playback │ │ │
│ │ │ pub struct PhraseInvariant { │ │ │
│ │ │ name: String, │ │ │
│ │ │ invariant_type: InvariantType, │ │ │
│ │ │ operator: InvariantOperator, │ │ │
│ │ │ threshold: f32, │ │ │
│ │ │ tolerance: f32, │ │ │
│ │ │ severity: InvariantSeverity, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ pub enum InvariantType { │ │ │
│ │ │ TensionAbove, TensionBelow, │ │ │
│ │ │ MomentumAbove, MomentumBelow, │ │ │
│ │ │ StabilityAbove, │ │ │
│ │ │ RegimeMatch, │ │ │
│ │ │ PhaseInRange, │ │ │
│ │ │ Custom(String), │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ └───────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌───────────────────────────────────────────────────────────┐ │ │
│ │ │ RetrievalResult v1 (FROZEN) │ │ │
│ │ ├───────────────────────────────────────────────────────────┤ │ │
│ │ │ │ │ │
│ │ │ pub struct RetrievalResult { │ │ │
│ │ │ candidates: Vec<RetrievalCandidate>, │ │ │
│ │ │ context: RetrievalContext, │ │ │
│ │ │ query_hash: u64, │ │ │
│ │ │ retrieval_time_us: u64, │ │ │
│ │ │ confidence: Confidence, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ pub struct RetrievalCandidate { │ │ │
│ │ │ phrase: MotionPhrase, │ │ │
│ │ │ score: CandidateScore, │ │ │
│ │ │ rank: usize, │ │ │
│ │ │ suggested_entry: Option<usize>, │ │ │
│ │ │ suggested_rate: f32, │ │ │
│ │ │ suggested_variant: Option<usize>, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ pub struct CandidateScore { │ │ │
│ │ │ fit: f32, // Semantic match [0, 1] │ │ │
│ │ │ legibility: f32, // How clear is the sound? [0, 1] │ │ │
│ │ │ novelty: f32, // Not recently used [0, 1] │ │ │
│ │ │ continuity: f32, // Flows from current [0, 1] │ │ │
│ │ │ total: f32, // Weighted combination │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ └───────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ ANTICIPATION MODULE │ │
│ │ (in cc-window-aligner/src/anticipation/) │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ HORIZON FORECASTS: │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ NOW 200ms 500ms 1s 2s │ │ │
│ │ │ │ │ │ │ │ │ │ │
│ │ │ ▼ ▼ ▼ ▼ ▼ │ │ │
│ │ │ ┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐ │ │ │
│ │ │ │Current│ │Horizon│ │Horizon│ │Horizon│ │Horizon│ │ │ │
│ │ │ │ State │ │ #1 │ │ #2 │ │ #3 │ │ #4 │ │ │ │
│ │ │ └───────┘ └───────┘ └───────┘ └───────┘ └───────┘ │ │ │
│ │ │ ▲ ▲ ▲ ▲ │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ decreasing ◀──────────────────────────▶ │ │ │
│ │ │ confidence │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ pub struct HorizonForecast { │ │
│ │ horizon_ms: u32, // 200, 500, 1000, 2000 │ │
│ │ phase_prediction: Option<CyclicCoordinate>, │ │
│ │ momentum_prediction: Option<HeadingVector>, │ │
│ │ tension_trend: TensionTrend, │ │
│ │ regime_prediction: RegimeType, │ │
│ │ confidence: Confidence, // Decreases with horizon │ │
│ │ uncertainty: f32, // Increases with horizon │ │
│ │ } │ │
│ │ │ │
│ │ EVENT FORECASTS: │ │
│ │ │ │
│ │ pub enum EventType { │ │
│ │ PhraseBoundary, // End of current phrase │ │
│ │ TensionRelease, // Tension drop │ │
│ │ ImpulseEvent, // Sudden acceleration │ │
│ │ RegimeChange, // Motion type change │ │
│ │ DirectionReversal, // 180° turn │ │
│ │ StabilityDrop, // System instability │ │
│ │ } │ │
│ │ │ │
│ │ pub struct EventForecast { │ │
│ │ event_type: EventType, │ │
│ │ probability: f32, // Likelihood in horizon │ │
│ │ expected_frame: usize, // When (if probability > 0.5) │ │
│ │ uncertainty: f32, // Timing uncertainty │ │
│ │ } │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘4.6 LAYER 5: Decision (Conductor)
┌─────────────────────────────────────────────────────────────────────────────┐
│ DECISION LAYER (CONDUCTOR) │
│ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ CONDUCTOR MODULE │ │
│ │ (in cc-window-aligner/src/conductor/) │ │
│ ├───────────────────────────────────────────────────────────────────┤ │
│ │ │ │
│ │ ACTION VOCABULARY (FROZEN): │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ │ │ │
│ │ │ pub enum ActionType { │ │ │
│ │ │ // Silence Control │ │ │
│ │ │ SilenceGate { │ │ │
│ │ │ open: bool, // true = allow sound │ │ │
│ │ │ crossfade_ms: u32, // Fade duration │ │ │
│ │ │ }, │ │ │
│ │ │ │ │ │
│ │ │ // Instantaneous Events │ │ │
│ │ │ ImpulseHit { │ │ │
│ │ │ intensity: f32, // [0, 1] strike strength │ │ │
│ │ │ timbre: String, // Sound selection │ │ │
│ │ │ }, │ │ │
│ │ │ │ │ │
│ │ │ // Continuous Textures │ │ │
│ │ │ SustainTexture { │ │ │
│ │ │ texture_id: String, │ │ │
│ │ │ level: f32, │ │ │
│ │ │ morph: f32, // Timbral position [0, 1] │ │ │
│ │ │ }, │ │ │
│ │ │ │ │ │
│ │ │ // Phrase Management │ │ │
│ │ │ PhraseSelect { │ │ │
│ │ │ phrase_id: String, │ │ │
│ │ │ entry_point: usize, │ │ │
│ │ │ rate: f32, // Playback rate │ │ │
│ │ │ }, │ │ │
│ │ │ PhraseAbort { │ │ │
│ │ │ reason: AbortReason, │ │ │
│ │ │ crossfade_ms: u32, │ │ │
│ │ │ }, │ │ │
│ │ │ PhraseTransform { │ │ │
│ │ │ transform_type: TransformType, │ │ │
│ │ │ amount: f32, │ │ │
│ │ │ }, │ │ │
│ │ │ │ │ │
│ │ │ // Regime Transitions │ │ │
│ │ │ RegimeShift { │ │ │
│ │ │ target_regime: RegimeType, │ │ │
│ │ │ transition_frames: usize, │ │ │
│ │ │ }, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ GATES (Boolean Predicates): │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ │ │ │
│ │ │ pub enum GateClauseType { │ │ │
│ │ │ StabilityAbove { threshold: f32 }, │ │ │
│ │ │ TensionInRange { min: f32, max: f32 }, │ │ │
│ │ │ MomentumAbove { threshold: f32 }, │ │ │
│ │ │ MomentumBelow { threshold: f32 }, │ │ │
│ │ │ IntentAligned { direction: [f32; 3], tolerance: f32 }, │ │ │
│ │ │ RegimeIs { allowed: Vec<RegimeType> }, │ │ │
│ │ │ ConfidenceAbove { threshold: f32 }, │ │ │
│ │ │ BudgetAvailable { budget_type: BudgetType }, │ │ │
│ │ │ PhaseNear { target: f32, tolerance: f32 }, │ │ │
│ │ │ Custom { name: String, predicate_id: u32 }, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ Gate = AND(clause1, clause2, ...) OR OR(clause1, ...) │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ BUDGETS (Resource Management): │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ │ │ │
│ │ │ pub enum BudgetType { │ │ │
│ │ │ Density, // Events per second │ │ │
│ │ │ Intensity, // Loudness/energy │ │ │
│ │ │ Novelty, // New phrases vs repeats │ │ │
│ │ │ Complexity, // Polyphony, texture density │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ pub struct Budget { │ │ │
│ │ │ budget_type: BudgetType, │ │ │
│ │ │ current: f32, // Available [0, ceiling] │ │ │
│ │ │ ceiling: f32, // Maximum │ │ │
│ │ │ recharge_rate: f32, // Per second │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ CONDUCTOR DECISION v1: │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ │ │ │
│ │ │ pub struct ConductorDecision { │ │ │
│ │ │ actions: Vec<Action>, // Emitted actions │ │ │
│ │ │ mode: ConductorMode, // Current operating │ │ │
│ │ │ budgets: BudgetSnapshot, // Resource state │ │ │
│ │ │ phrase_state: PhraseState, // Active phrase │ │ │
│ │ │ reasoning: Option<DecisionTrace>, // Debug trace │ │ │
│ │ │ timestamp: f64, │ │ │
│ │ │ decision_id: u64, │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ │ pub enum ConductorMode { │ │ │
│ │ │ FullExpression, // All capabilities enabled │ │ │
│ │ │ Conservative, // Reduced complexity │ │ │
│ │ │ SafeMode, // Minimal output │ │ │
│ │ │ Silent, // No output │ │ │
│ │ │ } │ │ │
│ │ │ │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘---
5. Data Flow Pipeline
┌─────────────────────────────────────────────────────────────────────────────┐
│ COMPLETE DATA FLOW │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ │
│ SENSORS │
│ ┌─────┐ ┌─────┐ ┌─────┐ │
│ │Mocopi│ │Watch│ │Phone│ │
│ └──┬──┘ └──┬──┘ └──┬──┘ │
│ │ │ │ │
│ └───────┼───────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ RAW PACKETS │ │
│ │ { device_id, device_timestamp, arrival_time, payload } │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Stage 1: Time Normalization │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ NORMALIZED PACKETS │ │
│ │ { device_id, canonical_time, arrival_time, payload } │ │
│ │ (All devices now share same time base) │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Stage 2: Resampling (to 50 Hz) │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ RESAMPLED FRAMES │ │
│ │ { timestamp @ 50Hz intervals, interpolated bone data } │ │
│ │ Interpolation: SLERP for rotations, LINEAR for positions │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Stage 3: Coordinate Unification │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ UNIFIED FRAMES │ │
│ │ { timestamp, bones[27] in body frame, root_position } │ │
│ │ All devices transformed to common coordinate system │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Stage 4: Multi-Device Fusion │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ FUSED FRAMES │ │
│ │ { timestamp, bones[27], device_mask, provenance } │ │
│ │ Authority table: Mocopi > ARKit > MediaPipe for each bone │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Stage 5: Windowing (50 frames = 1 second) │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ MOTION WINDOW │ │
│ │ ┌─────────────────────────────────────────────────────────┐ │ │
│ │ │ frames: [SkeletonFrame × 50] │ │ │
│ │ │ t_start: 0.0, t_end: 1.0, fps: 50.0 │ │ │
│ │ │ coverage: 0.96, device_mask: MOCOPI | WATCH │ │ │
│ │ │ checksum: 0xABCD1234... │ │ │
│ │ └─────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Semantic Projection (SemanticProjector) │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ SEMANTIC FRAMES [50] │ │
│ │ ┌─────────────────────────────────────────────────────────┐ │ │
│ │ │ phase: { coordinate: (0.7, 0.7), periodicity: 0.85 } │ │ │
│ │ │ momentum: { forward: 0.8, magnitude: 1.2 m/s } │ │ │
│ │ │ tension: { value: 0.3, trend: Falling } │ │ │
│ │ │ intent: { direction: (0, 0, 1), available: true } │ │ │
│ │ │ stability: { value: 0.95, fallback: false } │ │ │
│ │ │ regime: Periodic │ │ │
│ │ └─────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Anticipation Kernel │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ ANTICIPATION PACKET │ │
│ │ ┌─────────────────────────────────────────────────────────┐ │ │
│ │ │ horizons: [ │ │ │
│ │ │ { ms: 200, phase: 0.85, confidence: 0.9 }, │ │ │
│ │ │ { ms: 500, phase: 0.15, confidence: 0.7 }, │ │ │
│ │ │ { ms: 1000, regime: Ballistic, confidence: 0.5 }, │ │ │
│ │ │ { ms: 2000, uncertainty: 0.8 } │ │ │
│ │ │ ] │ │ │
│ │ │ events: [ │ │ │
│ │ │ { type: PhraseBoundary, prob: 0.7, frame: 35 }, │ │ │
│ │ │ { type: TensionRelease, prob: 0.85, frame: 12 } │ │ │
│ │ │ ] │ │ │
│ │ └─────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Retrieval Query │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ RETRIEVAL RESULT │ │
│ │ ┌─────────────────────────────────────────────────────────┐ │ │
│ │ │ candidates: [ │ │ │
│ │ │ { phrase: "walk_casual", fit: 0.92, legibility: 0.85 },│ │ │
│ │ │ { phrase: "walk_determined", fit: 0.87, legibility: 0.88 },│ │ │
│ │ │ { phrase: "stride_forward", fit: 0.81, legibility: 0.90 }│ │ │
│ │ │ ] │ │ │
│ │ └─────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Conductor Policy │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ CONDUCTOR DECISION │ │
│ │ ┌─────────────────────────────────────────────────────────┐ │ │
│ │ │ actions: [ │ │ │
│ │ │ PhraseSelect { id: "walk_casual", rate: 1.0 }, │ │ │
│ │ │ SustainTexture { id: "footsteps", level: 0.6 } │ │ │
│ │ │ ] │ │ │
│ │ │ mode: FullExpression │ │ │
│ │ │ budgets: { density: 0.7, intensity: 0.5 } │ │ │
│ │ └─────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ Audio Scheduler │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ AUDIO OUTPUT │ │
│ │ ┌─────────────────────────────────────────────────────────┐ │ │
│ │ │ 🔊 Synchronized sound responding to motion │ │ │
│ │ └─────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘---
6. Module Reference
6.1 cc-types (Foundation)
| File | Lines | Purpose |
|---|---|---|
| `lib.rs` | 692 | LatentVector, Quaternion, Vec3, numeric utilities |
6.2 cc-semantic (Semantic Layer)
| File | Lines | Purpose |
|---|---|---|
| `lib.rs` | 270 | Confidence, ValidityHorizon, SemanticValue, UnavailableReason |
| `frame.rs` | 400 | SemanticFrame v1, SemanticFrameBuilder, SemanticProvenance |
| `phase.rs` | 290 | CyclicCoordinate, PhaseState, PhaseType |
| `momentum.rs` | 300 | HeadingVector, MomentumState, ImpulseIndicator |
| `tension.rs` | 293 | TensionState, TensionTrend, TensionProxies |
| `intent.rs` | 200 | IntentState, IntentAvailability |
| `stability.rs` | 396 | StabilityState, StabilityFlags, HealthMetrics |
| `regime.rs` | 335 | RegimeType, RegimeDescriptor, RegimeEvidence |
6.3 cc-retrieval (RAG++ Layer)
| File | Lines | Purpose |
|---|---|---|
| `lib.rs` | 149 | RetrievalError, constants |
| `phrase.rs` | 787 | MotionPhrase v1, PhraseInvariant, TensionProfile |
| `result.rs` | 684 | RetrievalResult v1, RetrievalCandidate, CandidateScore |
| `query.rs` | 580 | RetrievalQuery, SemanticQuery, QueryConstraints |
6.4 cc-window-aligner (Main Crate)
| Module | Files | Lines | Purpose |
|---|---|---|---|
| `lib.rs` | 1 | 575 | WindowAligner, pipeline entry |
| `types` | 1 | 653 | MotionWindow, SkeletonFrame, DeviceMask |
| `config` | 1 | 416 | WindowConfig, AlignerMode |
| `error` | 1 | 251 | AlignerError |
| `stages/` | 6 | 1,263 | Pipeline stages |
| `skeleton/` | 3 | 688 | 27-bone hierarchy, mocopi mapping |
| `interpolation/` | 4 | 500 | SLERP, linear, hold policies |
| `clock/` | 2 | 400 | Clock sync, device mapping |
| `buffer/` | 2 | 350 | Reorder buffer, ring buffer |
| `audit/` | 2 | 350 | Causality tracing |
| `validation/` | 3 | 628 | Invariant checking |
| `semantic/` | 10 | 3,500 | Re-exports + projection |
| `retrieval/` | 4 | 100 | Re-exports |
| `anticipation/` | 4 | 800 | Horizon/event forecasts |
| `conductor/` | 9 | 5,000 | Decision layer |
---
7. Type System
7.1 Core Type Hierarchy
┌─────────────────────────────────────────────────────────────────────────────┐
│ TYPE HIERARCHY │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ PRIMITIVES (cc-types) │
│ ├── f32, f64, usize, u64 │
│ ├── Vec3 = [f32; 3] │
│ ├── Quaternion = [f32; 4] │
│ └── LatentVector<N> │
│ │
│ CONFIDENCE PATTERN (cc-semantic) │
│ ├── Confidence { value: f32, is_valid: bool } │
│ ├── ValidityHorizon { frames: usize, ms: u32 } │
│ ├── SemanticValue<T> { value, confidence, validity, reason } │
│ └── UnavailableReason (enum) │
│ │
│ MOTION TYPES (cc-window-aligner) │
│ ├── RawPacket { device_id, timestamps, payload } │
│ ├── SkeletonFrame { timestamp, bones[27], root_position } │
│ ├── BoneState { rotation: Quaternion, angular_velocity: Vec3 } │
│ ├── MotionWindow { frames[50], t_start, t_end, coverage, ... } │
│ └── DeviceMask (bitfield: MOCOPI | WATCH | PHONE | ...) │
│ │
│ SEMANTIC TYPES (cc-semantic) │
│ ├── CyclicCoordinate { cos, sin } │
│ ├── PhaseState { coordinate, periodicity, phase_type } │
│ ├── HeadingVector { right, up, forward } │
│ ├── MomentumState { direction, magnitude, slow, fast, impulse } │
│ ├── TensionState { value, trend, proxies } │
│ ├── IntentState { direction, availability, turn_likelihood } │
│ ├── StabilityState { value, flags, fallback_recommended } │
│ ├── RegimeType (enum) │
│ ├── RegimeDescriptor { primary, secondary, evidence } │
│ └── SemanticFrame { phase, momentum, tension, intent, stability, regime } │
│ │
│ RETRIEVAL TYPES (cc-retrieval) │
│ ├── MotionPhrase { id, duration, profiles, invariants, variants } │
│ ├── PhraseInvariant { name, type, operator, threshold } │
│ ├── TensionProfile { shape, start, peak, end } │
│ ├── RetrievalQuery { semantic, features, constraints } │
│ ├── RetrievalResult { candidates, context, query_hash } │
│ └── CandidateScore { fit, legibility, novelty, continuity } │
│ │
│ ANTICIPATION TYPES │
│ ├── HorizonForecast { ms, predictions, confidence } │
│ ├── EventForecast { type, probability, expected_frame } │
│ └── AnticipationPacket { horizons[4], events, frame_id } │
│ │
│ CONDUCTOR TYPES │
│ ├── Action { id, type, trigger, gate, priority } │
│ ├── ActionType (enum: SilenceGate, ImpulseHit, PhraseSelect, ...) │
│ ├── Gate { clauses, operator, min_open_frames } │
│ ├── Trigger { condition, hysteresis } │
│ ├── Budget { type, current, ceiling, recharge_rate } │
│ └── ConductorDecision { actions, mode, budgets, phrase_state } │
│ │
└─────────────────────────────────────────────────────────────────────────────┘---
8. Frozen Contracts
8.1 SemanticFrame v1.0.0
// FROZEN - DO NOT MODIFY WITHOUT MAJOR VERSION BUMP
pub struct SemanticFrame {
pub timestamp: f64,
pub frame_index: usize,
pub phase: PhaseState,
pub momentum: MomentumState,
pub tension: TensionState,
pub intent: IntentState,
pub stability: StabilityState,
pub regime: RegimeDescriptor,
pub overall_confidence: Confidence,
pub overall_validity: ValidityHorizon,
pub provenance: SemanticProvenance,
}8.2 MotionPhrase v1.0.0
// FROZEN - DO NOT MODIFY WITHOUT MAJOR VERSION BUMP
pub struct MotionPhrase {
pub id: String,
pub name: String,
pub duration_frames: usize,
pub tension_profile: TensionProfile,
pub momentum_profile: MomentumProfile,
pub phase_relationship: PhaseRelationship,
pub invariants: Vec<PhraseInvariant>,
pub variants: Vec<PhraseVariant>,
pub constraints: PlaybackConstraints,
pub metadata: PhraseMetadata,
}8.3 RetrievalResult v1.0.0
// FROZEN - DO NOT MODIFY WITHOUT MAJOR VERSION BUMP
pub struct RetrievalResult {
pub candidates: Vec<RetrievalCandidate>,
pub context: RetrievalContext,
pub query_hash: u64,
pub retrieval_time_us: u64,
pub confidence: Confidence,
}---
9. CC-Echelon Workspace Deep Dive
CC-Echelon is a motion-driven generative performance engine - fundamentally different from traditional DJ systems. Rather than a deck-based paradigm (Deck A, Deck B), Echelon is phrase-based where musical structure emerges from embodied latent physics (LIM-RPS).
Core Philosophy: "The performer exists first, music is born from their embodied movement."
9.1 Workspace Architecture (18 Crates)
cc-echelon/
├── Cargo.toml # Workspace manifest
└── crates/
│
├─────────────────────────────────────────────────────────────────────┐
│ CORE BRAIN & MOTION PROCESSING │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ cc-brain motion-bridge music-brain │
│ ┌──────────────────┐ ┌──────────────────┐ ┌────────────┐│
│ │ EchelonCore │ │ HTTP/WS Server │ │ Camelot ││
│ │ LatentUpdater │◀─────│ Sensor Logger │ │ BPM Match ││
│ │ StateMachine │ │ Cloud Client │ │ Playlist ││
│ │ LexiconController│ │ Gesture Detect │ │ Builder ││
│ └──────────────────┘ │ LIM-RPS Process │ └────────────┘│
│ │ └──────────────────┘ │
│ ▼ │ │
├─────────────────────────────────────────────────────────────────────┤
│ AUDIO PROCESSING & REAL-TIME ENGINE │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ audio-engine dsp-utils ts-shift │
│ ┌──────────────────┐ ┌──────────────────┐ ┌────────────┐│
│ │ AudioEngine │ │ Biquad Filters │ │ Rubberband ││
│ │ DSP Graph │◀─────│ Compressor │ │ TimeStretch││
│ │ Ring Buffers │ │ Limiter │ │ Config ││
│ │ CPAL Backend │ │ Envelope │ └────────────┘│
│ │ Synth Modules: │ │ Meter │ │
│ │ • Oscillators │ └──────────────────┘ │
│ │ • Filters │ │
│ │ • Envelopes │ │
│ │ • MotionSynth │ │
│ │ • Kick808 │ │
│ │ • AcidBass │ │
│ │ • SuperSawLead │ │
│ └──────────────────┘ │
│ │
├─────────────────────────────────────────────────────────────────────┤
│ SCHEDULER & TIMING │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ scheduler link-clock shmem-ipc │
│ ┌──────────────────┐ ┌──────────────────┐ ┌────────────┐│
│ │ ActionQueue │ │ LocalBeatClock │ │ SharedMem ││
│ │ Quantizer │◀─────│ LinkClock (Net) │ │ IPC Stub ││
│ │ Compiler │ │ MidiSyncClock │ │ ML/ASR ││
│ │ Executor │ │ BeatClock Trait │ │ Sidecar ││
│ │ Safety Policies │ └──────────────────┘ └────────────┘│
│ │ Decimation │ │
│ └──────────────────┘ │
│ │
├─────────────────────────────────────────────────────────────────────┤
│ MEDIA & PHRASE MANAGEMENT │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ media phrase-intelligence │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Clip Decoder │ │ PhraseDatabase │ │
│ │ Feature Analysis │─────▶│ PhraseRecommender│ │
│ │ Phrase DB (SQLite│ │ Recommendation │ │
│ │ HNSW Vector │ │ Context Scoring │ │
│ │ Transition Fit │ └──────────────────┘ │
│ └──────────────────┘ │
│ │
├─────────────────────────────────────────────────────────────────────┤
│ CONTROL & ROUTING │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ control-bus midi-osc voice-control│
│ ┌──────────────────┐ ┌──────────────────┐ ┌────────────┐│
│ │ ControlEvent │ │ MIDI Input │ │ Whisper ││
│ │ (30+ variants) │◀─────│ MIDI Output │ │ VAD ││
│ │ MeterFrame │ │ OSC Server │ │ 25+ Cmds ││
│ │ FastState │ │ Keyboard Sim │ │ Parser ││
│ │ SlowState │ │ DJ Controller │ │ Feedback ││
│ │ Telemetry │ └──────────────────┘ └────────────┘│
│ │ Ring Buffers │ │
│ └──────────────────┘ │
│ │
├─────────────────────────────────────────────────────────────────────┤
│ UI & VISUALIZATION │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ui-shell viz viz-server │
│ ┌──────────────────┐ ┌──────────────────┐ ┌────────────┐│
│ │ EchelonApp │ │ VizCore │ │ Axum WS ││
│ │ Latent World: │◀─────│ VizWidget │ │ LatentState││
│ │ • LatentOrb │ │ VizRunner │ │ Broadcast ││
│ │ • PhraseSpine │ │ Trail Rendering │ │ React UI ││
│ │ • ForceField │ │ 2D Projection │ └────────────┘│
│ │ • Horizon │ └──────────────────┘ │
│ │ • Reservoir │ │
│ │ egui/eframe │ │
│ └──────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘9.2 CC-Echelon Crate Dependency Graph
LAYER 1 (No Internal Dependencies)
├── dsp-utils [rustfft]
├── ts-shift [rubato, anyhow]
├── link-clock [anyhow, tracing]
├── shmem-ipc [serde, serde_yaml]
└── control-bus [ringbuf, serde] ◀── HUB FOR ALL COMMUNICATION
LAYER 2 (Depends on Layer 1)
├── audio-engine [dsp-utils, ts-shift, control-bus, cpal, crossbeam]
├── cc-brain [nalgebra, rand, serde, chrono]
├── scheduler [control-bus, link-clock, ringbuf, shmem-ipc]
├── midi-osc [control-bus, scheduler, midir, tokio]
└── voice-control [control-bus, scheduler, cpal, ringbuf]
LAYER 3 (Depends on Layer 1-2)
├── media [rustfft, rubato, sqlite, symphonia, hnsw_rs]
├── motion-bridge [scheduler, control-bus, tokio, reqwest]
├── phrase-intelligence [motion-bridge, sqlite, lru]
└── music-brain [media, anyhow, serde]
LAYER 4 (Depends on Layer 1-3)
├── viz [control-bus, egui, ringbuf, eframe]
├── viz-server [control-bus, tokio, axum, tower, ringbuf]
└── ui-shell [control-bus, scheduler, midi-osc, phrase-intelligence, viz, egui, eframe]9.3 Key Data Types in CC-Echelon
┌─────────────────────────────────────────────────────────────────────────┐
│ EMBODIED LATENT PHYSICS │
└─────────────────────────────────────────────────────────────────────────┘
│
┌─────────▼─────────┐
│ LatentState │ (from cc-brain)
├───────────────────┤
│ z: Vec<f32> │ ← latent vector
│ velocity │ ← first derivative
│ speed │ ← magnitude
│ curvature │ ← geometry
│ periodicity │ ← oscillation
│ timestamp_ns │
└─────────┬─────────┘
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ StateMachine│ │ Lexicon │ │ UIState │
│ (6 states) │ │ Controller │ │ (viz coords)│
├─────────────┤ ├─────────────┤ ├─────────────┤
│ Entry │ │ tension │ │ orb_x,y │
│ Stable │ │ energy │ │ orb_glow │
│ Divergence │ │ divergence │ │ orb_hue │
│ Transition │ │ expressivity│ │ spine_* │
│ Resolution │ │ transition_ │ │ horizon_* │
│ Exit │ │ intensity │ └─────────────┘
└─────────────┘ └─────────────┘
┌─────────────────────────────────────────────────────────────────────────┐
│ RING BUFFER COMMUNICATION │
└─────────────────────────────────────────────────────────────────────────┘
control-bus provides lock-free ring buffers for:
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ ControlEvent │ │ MeterFrame │ │ FastState │
│ (30+ variants) │ │ (RMS, LUFS) │ │ (latent snap) │
├──────────────────┤ ├──────────────────┤ ├──────────────────┤
│ Play/Stop/Pause │ │ left_rms │ │ z_snapshot │
│ SetTempo/Pitch │ │ right_rms │ │ velocity │
│ LoadPhrase │ │ lufs_integrated │ │ section_state │
│ FxEnable/Select │ │ peak_left/right │ │ timestamp │
│ MIDI/OSC events │ └──────────────────┘ └──────────────────┘
│ KeyboardSim │
└──────────────────┘
│
▼
┌──────────────────┐
│ AudioEngine │ ← Consumes ControlEvents
│ (DSP Graph) │ → Produces MeterFrames
└──────────────────┘9.4 EXHAUSTIVE Sub-Crate Details (18 crates, ~50,000 lines)
| Crate | Lines | Key Types |
|---|---|---|
| audio-engine | ~8,500 | `AudioEngine`, `GraphExecutor`, `Node` trait, `DeckPlayer`, `Eq3Node`, `MotionSynth` |
| cc-brain | ~6,200 | `EchelonCore`, `LatentState`, `Lexicon`, `SectionState`, `StateMachine` |
| control-bus | ~2,800 | `ControlEvent` (20+ variants), `MeterFrame`, `FastState`, `SlowState` |
| scheduler | ~4,100 | `Scheduler`, `compile_intent()`, `ActionQueue`, `Safety`, `Decimation` |
| motion-bridge | ~3,900 | `LimRpsProcessor`, `DeviceCalibration`, `GestureDetector`, `MotionFrame` |
| ui-shell | ~7,200 | `EchelonView`, `LatentOrb`, `PhraseSpine`, `GenerativeHorizon`, `DeckLane` |
| link-clock | ~1,800 | `BeatClock` trait, `LocalBeatClock`, `LinkClock`, `MidiSyncClock` |
| midi-osc | ~2,400 | `MidiInput`, `MidiOutput`, `OscServer`, `Mapping`, `KeyboardSim` |
| media | ~3,600 | `Clip`, `PhraseDb`, `TransitionFit`, `FeatureAnalysis` |
| phrase-intelligence | ~2,100 | `PhraseDatabase`, `PhraseRecommender`, `ContextScoring` |
| voice-control | ~2,500 | `WhisperRecognizer`, `VAD`, `CommandParser`, `Feedback` |
| dsp-utils | ~1,900 | `Biquad`, `Limiter`, `Compressor`, `Envelope`, `Meter` |
| ts-shift | ~1,200 | `RubberbandStretcher`, `TimeStretchConfig` |
| viz | ~1,400 | `VizCore`, `VizWidget`, `TrailRenderer`, `2DProjection` |
| viz-server | ~800 | `AxumServer`, `LatentBroadcast`, `WebSocketHandler` |
| music-brain | ~1,800 | `BpmAnalyzer`, `CamelotKey`, `PlaylistBuilder`, `Export` |
| shmem-ipc | ~600 | `SharedMemory`, `IpcStub`, `SidecarBridge` |
9.5 Signal Flow (Sensors → Audio)
┌─────────────────────────────────────────────────────────────────────────┐
│ CC-ECHELON SIGNAL FLOW │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ iPhone Sensors ──┐ │
│ (CoreMotion) │ ┌─────────────────┐ │
│ ├───▶│ motion-bridge │ │
│ Mocopi (UDP) ────┤ │ HTTP/WS Server │ │
│ │ │ GestureDetect │ │
│ MediaPipe ───────┘ └────────┬────────┘ │
│ │ │
│ ▼ SensorFrame │
│ ┌─────────────────┐ │
│ │ cc-brain │ │
│ │ LimRpsProcess │ │
│ │ StateMachine │ │
│ │ Lexicon │ │
│ └────────┬────────┘ │
│ │ │
│ ▼ LatentState + ControlEvent │
│ ┌─────────────────┐ │
│ │ control-bus │ ◀── Ring Buffer Hub │
│ │ (SPSC queues) │ │
│ └────────┬────────┘ │
│ ┌────────────┼────────────┐ │
│ ▼ ▼ ▼ │
│ ┌──────────────┐ ┌──────────┐ ┌──────────┐ │
│ │ scheduler │ │ ui-shell │ │ viz │ │
│ │ ActionQueue │ │ LatentOrb│ │ 2D/3D │ │
│ │ link-clock │ │ Spine │ │ Trails │ │
│ └──────┬───────┘ └──────────┘ └──────────┘ │
│ │ │
│ ▼ QuantizedAction │
│ ┌──────────────┐ │
│ │ audio-engine │ │
│ │ DSP Graph │ │
│ │ Synths: │ │
│ │ • SuperSaw │ │
│ │ • AcidBass │ │
│ │ • Kick808 │ │
│ │ • MotionSyn │ │
│ └──────┬───────┘ │
│ │ │
│ ▼ Audio Samples │
│ ┌──────────────┐ │
│ │ CPAL Backend │───────▶ 🔊 Speakers │
│ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘9.6 Motion Sensor Pipeline
┌────────────────────────────────────────────────────────────────────────┐
│ iPhone SensorFrame (from motion-bridge HTTP/WebSocket) │
│ ┌──────────────────────────────────────────────────────────────────┐ │
│ │ acceleration: (x, y, z) │ │
│ │ rotation_rate: (x, y, z) │ │
│ │ magnetic_field: (x, y, z) │ │
│ │ attitude: (roll, pitch, yaw) │ │
│ │ quaternion: (w, x, y, z) │ │
│ │ timestamp: f64 │ │
│ └──────────────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────────────┘
│
┌───────────────┴───────────────┐
▼ ▼
┌──────────────────────┐ ┌──────────────────────┐
│ MotionCalibrator │ │ GestureDetector │
│ • Zero-offset │ │ • Punch detection │
│ • Scale normalization │ • Shake detection │
└──────────┬───────────┘ │ • Circle detection │
│ │ • Swipe detection │
▼ └──────────┬───────────┘
┌──────────────────────┐ │
│ MotionTranslator │ │
│ • Feature extraction│◀─────────────────┘
│ • Energy, balance │
│ • Coherence metrics │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ MotionFrame │
├──────────────────────┤
│ left_device │
│ right_device │
│ coherence: f32 │
│ balance: f32 │
│ tempo_bpm: f32 │
│ beat_phase: f32 │
│ system_state: enum │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ LimRpsProcessor │
│ • Latent extraction │
│ • Embodied physics │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ LatentState │
│ (to cc-brain) │
└──────────────────────┘9.7 EXHAUSTIVE Type Reference (All 18 Sub-Crates)
9.7.1 audio-engine (29 files, ~3,500 lines)
| Type | Kind | Fields/Variants | Description |
|---|---|---|---|
| `AudioEngine` | struct | config, backend, stream, render_tx/rx, telemetry | Primary audio I/O entry point |
| `EngineConfig` | struct | sample_rate: u32, buffer_frames: u32, channels: u16, render_queue_capacity | Engine configuration |
| `EngineTelemetry` | struct | overruns, underruns, mismatches, blocks_rendered, callback_ns (AtomicU64) | Lock-free metrics |
| `GraphBuilder` | struct | nodes, connections | Audio graph construction |
| `GraphMetadata` | struct | descriptors, connections, node_order | Immutable graph topology |
| `GraphExecutor` | struct | graph, buffers, node_states | Topological order execution |
| `Node` | trait | `process(&mut self, inputs: &[&[f32]], output: &mut [f32])` | DSP node interface |
| `TestToneNode` | struct | frequency, phase, amplitude | Sine wave generator |
| `DeckPlayer` | struct | buffer, position, loop_start/end, command_queue | Sample playback with looping |
| `Eq3Node` | struct | low/mid/high filters, biquad states | 3-band parametric EQ |
| `CrossfaderNode` | struct | position, curve | Equal-power crossfade |
| `MixerState` | struct | crossfader, curve, channel_a/b, master_gain | Full mixer state |
| `ChannelStrip` | struct | gain, trim_db, filter, eq | Per-channel processing |
| `ChannelEq` | struct | low_db, mid_db, high_db, filter_states | 3-band EQ state |
| `MotionSynth` | struct | voice_manager, gesture_mapper, mod_matrix | Gesture-driven synthesizer |
| `NodeDescriptor` | enum | DeckPlayer, Crossfader, Eq3, Limiter, TestTone | Node type descriptors |
| `DeckCommand` | enum | Play, Pause, Seek{position_samples}, SetLooping | Deck control commands |
| `CrossfaderCurve` | enum | Linear, ConstantPower, SharpCut, Smooth | Crossfader curves |
| `BackendKind` | enum | Cpal, Jack | Audio backend selection |
Synth Sub-Module Types:
| Type | Kind | Description |
|---|---|---|
| `Oscillator` | struct | Phase accumulator with waveform selection |
| `SuperSaw` | struct | Detuned 7-oscillator super saw |
| `WavetableOsc` | struct | Wavetable interpolation oscillator |
| `NoiseGenerator` | struct | White/pink/brown noise |
| `MoogLadder` | struct | 4-pole resonant ladder filter |
| `SVFilter` | struct | State-variable filter (LP/HP/BP/Notch) |
| `FormantFilter` | struct | Vocal formant shaping |
| `CombFilter` | struct | Feedforward/feedback comb |
| `AllpassFilter` | struct | Phase-shifting allpass |
| `ADSR` | struct | Attack-Decay-Sustain-Release envelope |
| `MultiStageEnv` | struct | Arbitrary breakpoint envelope |
| `EnvelopeFollower` | struct | Audio-rate envelope extraction |
| `LFO` | struct | Low-frequency oscillator with sync |
| `ModMatrix` | struct | Source→Destination modulation routing |
| `Voice` | struct | Single synth voice (osc + filter + env) |
| `VoiceManager` | struct | Polyphony management (8+ voices) |
| `PlateReverb` | struct | Plate reverb algorithm |
| `Chorus` | struct | Modulated delay chorus |
| `Phaser` | struct | Multi-stage allpass phaser |
| `Distortion` | struct | Soft/hard clip distortion |
| `StereoDelay` | struct | Ping-pong stereo delay |
| `Kick808` | struct | TR-808 kick drum synth |
| `AcidBass` | struct | TB-303 style acid bass |
| `SuperSawLead` | struct | Supersaw lead synth |
| `PluckSynth` | struct | Karplus-Strong pluck |
9.7.2 cc-brain (20 files, ~2,800 lines)
| Type | Kind | Fields/Variants | Description |
|---|---|---|---|
| `EchelonCore` | struct | config, latent_updater, state_machine, lexicon_controller, sensor_buffer, current_latent/state/lexicon/ui_state, total_frames | Main brain controller |
| `LatentState` | struct | z: Vec<f32>, velocity, norm, speed, curvature, periodicity, timestamp_ns | Embodied motion latent |
| `Lexicon` | struct | tension, divergence, transition_intensity, dissolution, reformation, resolution, energy, expressivity (all f32 [0,1]) | Expressive control vocabulary |
| `UIState` | struct | orb_x/y, orb_stretch/glow/hue/saturation, spine_length/curvature/thickness/oscillation, horizon_bend/brightness | Visualization state |
| `SectionState` | enum | Entry, StableSection, Acceleration, Deceleration, Peak, Valley, Transition, Release | High-level motion phases |
| `SensorFrame` | struct | timestamp_ns, device_id, accel[3], gyro[3] | Raw sensor input |
| `LogFrame` | struct | timestamp_ns, raw_sensors, normalized_sensors, z, z_velocity, norm, speed, curvature, state, lexicon | Training log entry |
| `BrainConfig` | struct | latent: LatentConfig, state_machine: StateMachineConfig, lexicon: LexiconConfig | Configuration |
| `Conductor` | struct | section: MusicSection, bar/beat counters, pending_edits, cooldowns | Musical form orchestrator |
| `MusicSection` | enum | Intro, Groove, Build, Climax, Breakdown, Outro | DJ set sections |
| `PatternEdit` | enum | SetParam, ScheduleEvent, Transform, SectionChange, PhraseRequest | Pattern modifications |
| `LatentUpdater` | trait | `update(&frame, dt)`, `reset()` | Motion→latent mapping |
| `SimpleLatentUpdater` | struct | config, state | Rule-based latent mapping |
| `LearnedLatentUpdater` | struct | encoder, weights | Neural network latent mapping |
9.7.3 control-bus (1 file, ~485 lines)
| Type | Kind | Fields/Variants | Description |
|---|---|---|---|
| `ControlEvent` | enum | Play, Stop, Pause, Seek, Cue, HotCue, SetHotCue, Loop, LoopExit, Sync, SetParam, RampParam, SetTempo, NudgeTempo, SetPitch, KeyLock, LoadPhrase, LoadTrack, SeekBeat, FxEnable, FxSelect, FxParam, KeyboardEvent, MidiCC, MidiNote (30+ variants) | All control messages |
| `MeterFrame` | struct | deck_a_rms, deck_b_rms, master_lufs: f32 | Audio metering snapshot |
| `FastState` | struct | latent: Vec<f32>, phase, latent_energy, residual, limb_energy, timestamp_micros | Fast-loop latent (50Hz) |
| `SlowState` | struct | latent: Vec<f32>, coupling, timestamp_micros | Slow-loop equilibrium (2Hz) |
| `Telemetry` | struct | engine_callback_ns, scheduler_latency_ns, cpu_percent, xruns, timestamp_micros | Performance metrics |
| `ChoreoFrame` | struct | timestamp_micros, devices: Vec<DeviceFrame>, audio_features | Fused sensor frame |
| `ChoreoMoment` | struct | x_star, psi, phi, limb_energy, y_star, tempo_bpm, confidence, residual, timestamp_micros | LIM-RPS/DELL output |
| `Intent` | struct | gesture_id, confidence, metadata, timestamp_micros | High-level gesture intent |
| `ActionDefinition` | struct | action_type, quantize, params | Executable action definition |
| `DeckId` | enum | A, B | Deck identifier |
| `FxType` | enum | None, Filter, Delay, Reverb, Echo, Flanger, Phaser, BitCrush, Distortion, Compressor, Gate | Effect types |
| `ParamId` | enum | Crossfader, DeckAEqLow/Mid/High, DeckAGain, DeckAFilter, DeckBEqLow/Mid/High, DeckBGain, DeckBFilter, MasterGain, ... | Parameter identifiers |
| `DeviceType` | enum | Phone, Watch, VR, IMU | Sensor device types |
| `ActionType` | enum | Keyboard, MidiCC, MidiNote, OSC, HTTP, InternalControl, Custom | Action execution types |
| `QuantizeMode` | enum | Immediate, NextBeat, NextBar, Custom(f32) | Beat quantization modes |
Ring Buffer Constructors:
fn control_ring(capacity) → (ControlProducer, ControlConsumer)
fn meter_ring(capacity) → (MeterProducer, MeterConsumer)
fn fast_state_ring(capacity) → (FastStateProducer, FastStateConsumer)
fn slow_state_ring(capacity) → (SlowStateProducer, SlowStateConsumer)
fn telemetry_ring(capacity) → (TelemetryProducer, TelemetryConsumer)
fn choreo_frame_ring(capacity) → (ChoreoFrameProducer, ChoreoFrameConsumer)
fn choreo_moment_ring(capacity) → (ChoreoMomentProducer, ChoreoMomentConsumer)
fn intent_ring(capacity) → (IntentProducer, IntentConsumer)
fn action_ring(capacity) → (ActionProducer, ActionConsumer)9.7.4 dsp-utils (6 files, ~600 lines)
| Type | Kind | Description |
|---|---|---|
| `BiquadCoeffs` | struct | b0, b1, b2, a1, a2 filter coefficients |
| `BiquadState` | struct | x1, x2, y1, y2 filter state |
| `Compressor` | struct | threshold_db, ratio, attack_ms, release_ms, makeup_gain_db, lookahead_samples |
| `Envelope` | struct | attack, decay, sustain, release times (ms) |
| `EnvelopeState` | struct | Envelope follower state with process_sample() |
| `Limiter` | struct | threshold_db, release_ms hard-knee limiter |
| `LimiterState` | struct | Limiter processing state |
| `Meter` | struct | RMS/peak meter with process_sample(), rms(), peak() |
Filter Design Functions:
fn design_lowpass(sr: f32, freq: f32, q: f32) → BiquadCoeffs
fn design_highpass(sr: f32, freq: f32, q: f32) → BiquadCoeffs
fn design_peaking(sr: f32, freq: f32, gain_db: f32, q: f32) → BiquadCoeffs
fn design_low_shelf(sr: f32, freq: f32, gain_db: f32, q: f32) → BiquadCoeffs
fn design_high_shelf(sr: f32, freq: f32, gain_db: f32, q: f32) → BiquadCoeffs9.7.5 link-clock (4 files, ~400 lines)
| Type | Kind | Description |
|---|---|---|
| `LocalBeatClock` | struct | Standalone offline clock (tempo_bpm, beat, phase, running) |
| `LinkClock` | struct | Ableton Link integrated clock with FFI binding |
| `MidiSyncClock` | struct | MIDI clock synchronized beat tracking |
| `SharedClock` | struct | Thread-safe Arc<RwLock<T>> wrapper |
| `BeatClock` | trait | `current_beat() → f64`, `phase() → f32`, `tempo_bpm() → f32`, `set_tempo(bpm)` |
| `LinkTimeline` | struct | FFI timeline state |
| `ClockEvent` | enum | TempoChange, BeatChange, PhaseReset |
| `ClockMonitor` | struct | Event watcher for tempo/beat changes |
9.7.6 scheduler (13 files, ~1,600 lines)
| Type | Kind | Description |
|---|---|---|
| `Scheduler` | struct | state: EngineShadowState, snapshot_publishers |
| `Action` | struct | action_type, deck, param, value, timing |
| `ScheduledAction` | struct | action, scheduled_time, quantization |
| `ActionQueue` | struct | Lock-free action storage |
| `Intent` | struct | gesture_id, confidence, metadata, timestamp |
| `Quantizer` | struct | Beat quantization: quantize(action, resolution, clock) |
| `QuantizedAction` | struct | action, target_beat, target_bar |
| `EngineShadowState` | struct | Replica of engine state for non-blocking decisions |
| `SnapshotPublishers` | struct | Ring buffer producers for visualization |
| `QuantizationResolution` | enum | Immediate, 16th, 8th, Quarter, Half, Bar |
Key Function:
fn compile_intent(intent: Intent, state: &EngineShadowState) → Vec<ControlEvent>9.7.7 motion-bridge (11 files, ~1,400 lines)
| Type | Kind | Description |
|---|---|---|
| `MotionReceiverConfig` | struct | Configuration for motion receiver |
| `DellMotionReceiver` | struct | Multi-device sensor processor |
| `Episode1Features` | struct | t_host_ms, lr_pan, lr_energy, coherence, E_left, E_right, tempo_bpm, beat_phase |
| `MotionEvent` | enum | BalanceShift{lr_pan}, CoherenceChange{coherence}, EnergySpike{energy, device}, BeatSync{phase, tempo} |
| `LimRpsProcessor` | struct | Neural latent processor with new(), process(), reset() |
| `LatentState` | struct | z, velocity, norm, speed, curvature, periodicity, timestamp_ns |
| `DeviceCalibration` | struct | accel_offsets, accel_scales, gyro_offsets |
| `MotionCalibrator` | struct | Calibration interface with capture_calibration(), apply() |
| `DeviceConfig` | struct | pairing, roles, primary_device |
| `MotionTranslator` | struct | Features → intents with translate(), detect_gesture() |
| `GestureDetector` | struct | detect(), register_pattern() |
| `CloudClient` | struct | Cloud Run client for Episode 1 |
| `MotionWebSocketServer` | struct | Real-time WebSocket streaming |
| `DeviceId` | enum | Left, Right |
| `DevicePresence` | enum | Available, Lost, Reconnecting |
| `DeviceRole` | enum | Primary, Secondary, Accessory |
9.7.8 ui-shell (31 files, ~3,500 lines)
Main UI Types:
| Type | Kind | Description |
|---|---|---|
| `UiShell` | struct | Main shell with new(), run() |
| `EchelonApp` | struct | Latent world application |
| `EchelonView` | struct | The visual instrument container |
| `MainView` | struct | Legacy DJ interface |
| `DeckLaneWidget` | struct | Single deck panel (waveform, hot_cues, levels) |
| `CrossfaderWidget` | struct | Mixing control |
| `MasterControlsWidget` | struct | Output levels & metering |
| `PhraseBrowserWidget` | struct | Phrase selection |
| `Theme` | struct | Color palette |
Latent World Visualization Types:
| Type | Kind | Description |
|---|---|---|
| `LatentOrb` | struct | position, stretch, glow, hue, saturation - embodied state sphere |
| `PhraseSpine` | struct | length, curvature, thickness, oscillation - musical form line |
| `GenerativeHorizon` | struct | bend, brightness, trails - future prediction arc |
| `PhraseReservoir` | struct | Possibility cloud visualization |
| `SomaticTimeline` | struct | Motion memory trace |
| `ForceField` | struct | Gesture detection visualization |
| `AmbientAura` | struct | Ambient background |
| `AudioVessel` | struct | Audio reactive visual |
| `AuroraField` | struct | Waveform field |
| `EmbodiedBand` | struct | Device motion trails |
| `MotionTrace` | struct | Motion path recording |
UI Enums:
| Type | Variants |
|---|---|
| `ActivePanel` | DeckLane, Effects, Mapping, Automation, PhraseBrowser |
| `SectionState` | Stable, Divergence, Transition, Resolution |
| `DeckAction` | Play, Stop, Seek, Cue, LoadPhrase |
| `MainViewAction` | UI event types |
| `PhraseBrowserAction` | Browser event types |
9.7.9 Remaining Sub-Crates Summary
| Crate | Files | Lines | Key Types |
|---|---|---|---|
| `media` | 6 | ~800 | AudioClip, ClipAnalysis, PhraseDb, Phrase, TransitionFit |
| `midi-osc` | 6 | ~750 | DJController, MidiInputHandler, MidiOutputHandler, MidiMessage, OscServer, OscClient, KeyboardExecutor |
| `music-brain` | 5 | ~600 | PlaylistBuilder, PlaylistConfig, Playlist, CamelotKey, BpmMatcher, BpmProgression |
| `phrase-intelligence` | 4 | ~500 | PhraseDatabase, Phrase, PhraseMetadata, PhraseRecommender, RecommendationContext, RecommendationService |
| `shmem-ipc` | 1 | ~10 | `open_channel(name) → Result` (stub) |
| `ts-shift` | 2 | ~120 | TimeStretchConfig, RubberBand FFI bindings |
| `viz` | 3 | ~600 | VizConfig, VizOverlays, VizCore, VizWidget, Projector |
| `viz-server` | 1 | ~200 | LatentVisualizationState, VizServer (Axum HTTP) |
| `voice-control` | 5 | ~700 | VoiceRecognizer, VoiceActivityDetector, VadState, VoiceCommandParser, VoiceFeedback, VoiceCommand |
---
10. CC-RAG-Plus-Plus Deep Dive
CC-RAG-Plus-Plus is a memory-conditioned candidate selection engine - pure retrieval + statistics, NO model training.
10.1 Core Architecture
┌─────────────────────────────────────────────────────────────────────────┐
│ RAG++ ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ QUERY LAYER │ │
│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │
│ │ │ QueryEngine │ │ Reranker │ │ QueryCache │ │ │
│ │ │ QueryRequest │ │ RerankerType │ │ CacheConfig │ │ │
│ │ │ QueryResponse│ │ • Cross │ │ CacheStats │ │ │
│ │ └───────────────┘ │ • Point │ └───────────────┘ │ │
│ │ │ • None │ │ │
│ │ └───────────────┘ │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ INDEX LAYER │ │
│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │
│ │ │ FlatIndex │ │ HNSWIndex │ │ IndexRegistry │ │ │
│ │ │ (brute-force)│ │ (approx-NN) │ │ (multi-index) │ │ │
│ │ └───────────────┘ └───────────────┘ └───────────────┘ │ │
│ │ │ │
│ │ Distance Types: L2, InnerProduct, Cosine │ │
│ │ Multi-Index Fusion: RRF (Reciprocal Rank Fusion) │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ STORAGE LAYER │ │
│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │
│ │ │ InMemoryStore │ │ WriteBuffer │ │ WalWriter │ │ │
│ │ │ RecordStore │ │ BufferStats │ │ WalReader │ │ │
│ │ │ SharedStore │ │ │ │ WalEntry │ │ │
│ │ └───────────────┘ └───────────────┘ └───────────────┘ │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ TRAJECTORY MEMORY │ │
│ │ ┌───────────────────────────────────────────────────────────────┐ │ │
│ │ │ TrajectoryGraph │ │ │
│ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │
│ │ │ │ Episode │──│ Edge │──│ Episode │──│ Edge │──▶ ... │ │ │
│ │ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │ │
│ │ │ │ │ │
│ │ │ EdgeType: Temporal, Semantic, Causal │ │ │
│ │ │ PathSelectionPolicy: Greedy, BeamSearch, Sampling │ │ │
│ │ └───────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │
│ │ │TrajectoryPhase│ │SalienceScorer │ │ConservationMet│ │ │
│ │ │PhaseInferencer│ │SalienceFactors│ │PathQuality │ │ │
│ │ │TurnFeatures │ │TurnSalience │ │PathQualityWts │ │ │
│ │ └───────────────┘ └───────────────┘ └───────────────┘ │ │
│ │ │ │
│ │ TrajectoryCoordinate: (tension, momentum, phase) - 3D │ │
│ │ TrajectoryCoordinate5D: + (commitment, complexity) │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ STATISTICS │ │
│ │ ┌───────────────────────────────────────────────────────────────┐ │ │
│ │ │ OutcomeStats (Welford's Algorithm) │ │ │
│ │ │ ┌────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ Numerically stable running mean/variance/count │ │ │ │
│ │ │ │ • No accumulator overflow │ │ │ │
│ │ │ │ • Single-pass computation │ │ │ │
│ │ │ │ • Exact results for any input order │ │ │ │
│ │ │ └────────────────────────────────────────────────────────┘ │ │ │
│ │ └───────────────────────────────────────────────────────────────┘ │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘10.2 Key Invariants
| Invariant | Description |
|---|---|
| INV-001 | Record immutability after creation |
| INV-002 | Welford numerical stability |
| INV-003 | WAL-before-buffer for durability |
| INV-004 | Index-record consistency |
10.3 Ring Structure (Episode Memory)
┌─────────────────────────────────────────┐
│ Episode Ring (Circular) │
│ │
│ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │
│ │ E1│───▶│ E2│───▶│ E3│───▶│ E4│ │
│ └───┘ └───┘ └───┘ └───┘ │
│ ▲ │ │
│ └──────────────────────────┘ │
│ │
│ build_weighted_ring() │
│ build_dual_ring() (IRCP/RCP) │
└─────────────────────────────────────────┘10.4 EXHAUSTIVE File Listing (51 .rs files, 24,879 lines)
cc-rag-plus-plus/
├── Cargo.toml # Workspace manifest
├── crates/
│ ├── core/ # Main library (18,421 lines)
│ │ └── src/
│ │ ├── lib.rs # 245 lines - exports, RagPlusPlusEngine
│ │ ├── config.rs # 312 lines - RagConfig, IndexConfig
│ │ ├── error.rs # 189 lines - RagError enum
│ │ │
│ │ ├── storage/ # Record persistence (3,245 lines)
│ │ │ ├── mod.rs # RecordStore trait
│ │ │ ├── memory.rs # InMemoryStore (lock-free)
│ │ │ ├── buffer.rs # WriteBuffer, BufferStats
│ │ │ └── wal.rs # WalWriter, WalReader, WalEntry
│ │ │
│ │ ├── index/ # Vector indexing (4,567 lines)
│ │ │ ├── mod.rs # VectorIndex trait
│ │ │ ├── flat.rs # FlatIndex (brute-force)
│ │ │ ├── hnsw.rs # HNSWIndex (M, ef_construction, ef_search)
│ │ │ ├── registry.rs # IndexRegistry (multi-index)
│ │ │ └── distance.rs # L2, InnerProduct, Cosine
│ │ │
│ │ ├── query/ # Query processing (2,134 lines)
│ │ │ ├── mod.rs # QueryEngine
│ │ │ ├── request.rs # QueryRequest, QueryFilter
│ │ │ ├── response.rs # QueryResponse, ScoredResult
│ │ │ ├── reranker.rs # RerankerType (Cross/Point/None)
│ │ │ └── cache.rs # QueryCache, CacheConfig
│ │ │
│ │ ├── trajectory/ # Trajectory memory (6,597 lines)
│ │ │ ├── mod.rs # TrajectoryMemory facade
│ │ │ ├── graph.rs # TrajectoryGraph (679 lines)
│ │ │ ├── episode.rs # Episode, EpisodeMetadata
│ │ │ ├── edge.rs # Edge, EdgeType (Temporal/Semantic/Causal)
│ │ │ ├── phase.rs # TrajectoryPhase, PhaseInferencer (458 lines)
│ │ │ ├── salience.rs # SalienceScorer, TurnSalience (441 lines)
│ │ │ ├── ring.rs # build_weighted_ring, build_dual_ring (965 lines)
│ │ │ ├── coordinate.rs # TrajectoryCoordinate5D (1,347 lines)
│ │ │ ├── ircp.rs # IRCPPropagator (897 lines)
│ │ │ ├── chainlink.rs # ChainLink, AttentionWeights (810 lines)
│ │ │ └── conservation.rs # ConservationMetrics, PathQuality
│ │ │
│ │ └── stats/ # Statistics (1,423 lines)
│ │ ├── mod.rs # OutcomeStats
│ │ ├── welford.rs # Welford's algorithm (numerically stable)
│ │ └── summary.rs # StatsSummary, percentiles
│ │
│ └── python/ # Python bindings (6,458 lines)
│ └── src/
│ ├── lib.rs # PyO3 module registration
│ ├── engine.rs # PyRagEngine wrapper
│ ├── types.rs # Python type conversions
│ └── trajectory.rs # PyTrajectoryMemory10.5 Key Data Types (cc-rag-plus-plus)
// TrajectoryCoordinate5D - 5-dimensional DLM coordinate
pub struct TrajectoryCoordinate5D {
pub depth: f32, // Hierarchical depth in trajectory
pub sibling: f32, // Sibling index at current depth
pub homogeneity: f32, // Temporal consistency [0,1]
pub temporal: f32, // Time position in episode
pub complexity: f32, // Structural complexity
}
// DLMWeights - Learned weights for coordinate computation
pub struct DLMWeights {
pub depth_weight: f32,
pub sibling_weight: f32,
pub homogeneity_weight: f32,
pub temporal_weight: f32,
pub complexity_weight: f32,
}
// IRCPPropagator - Inverse Recursive Context Propagation
pub struct IRCPPropagator {
pub attention_heads: usize,
pub propagation_depth: usize,
pub decay_factor: f32,
}
// ChainLink - Attention-weighted episode connection
pub struct ChainLink {
pub source_id: EpisodeId,
pub target_id: EpisodeId,
pub attention: AttentionWeights,
pub edge_type: EdgeType,
}
// ConservationMetrics - Path quality tracking
pub struct ConservationMetrics {
pub energy_conservation: f32,
pub momentum_conservation: f32,
pub information_preservation: f32,
}10.6 Trajectory Module Deep Dive (7,589 lines)
The trajectory module is the heart of RAG++, providing episodic memory with 5D DLM coordinates.
10.6.1 Core Data Structures
TrajectoryGraph - DAG for episode relationships:
pub struct TrajectoryGraph {
pub fn new() -> Self
pub fn add_edge(parent: NodeId, child: NodeId, edge_type: EdgeType) -> Result<()>
pub fn find_primary_path(policy: PathSelectionPolicy) -> Result<PathResult>
pub fn traverse(order: TraversalOrder) -> Vec<NodeId>
}
pub enum EdgeType { Continuation, Regeneration, Branch }
pub enum PathSelectionPolicy { FeedbackFirst, FirstByTime, LongestContent, HighestWeight }
pub enum TraversalOrder { DepthFirst, BreadthFirst, Topological, ReverseTopological }TrajectoryCoordinate5D - 5-dimensional positioning:
pub struct TrajectoryCoordinate5D {
pub depth: u32, // Distance from root (0 = root)
pub sibling_order: u32, // Position among siblings
pub homogeneity: f32, // [0,1] semantic similarity to parent
pub temporal: f32, // [0,1] normalized timestamp
pub complexity: u32, // Message complexity (n_parts)
}
pub struct DLMWeights {
pub depth: f32, // Default: 0.25
pub sibling: f32, // Default: 0.15
pub homogeneity: f32, // Default: 0.30
pub temporal: f32, // Default: 0.20
pub complexity: f32, // Default: 0.10
}10.6.2 I-RCP (Inverse Ring Contextual Propagation)
pub struct IRCPPropagator {
config: IRCPConfig,
}
pub struct IRCPConfig {
pub temperature: f32, // Softmax temperature (default: 1.0)
pub coord_weights: DLMWeights, // Coordinate weights
pub spatial_weight: f32, // [0,1] spatial vs semantic (default: 0.3)
pub causal_mask: bool, // Apply causal masking (default: false)
}
pub struct AttentionWeights {
pub forward: Vec<f32>, // A_F: query → context (RCP)
pub inverse: Vec<f32>, // A_I: context → query (IRCP)
pub cross: Vec<f32>, // A_C: user/assistant turns
pub total_mass: f32, // Sum of weights
}
impl IRCPPropagator {
pub fn compute_attention(
query_coord: &TrajectoryCoordinate5D,
context_coords: &[TrajectoryCoordinate5D],
query_emb: &[f32],
context_embs: &[&[f32]],
) -> AttentionWeights
}10.6.3 ChainLink Estimation
pub enum LinkType {
Continuation, Elaboration, Summary, Contradiction, Tangent,
Question, Answer, Code, Error, Solution, Meta, Unknown
}
pub struct ChainLink {
pub coordinate: TrajectoryCoordinate5D,
pub embedding: Vec<f32>,
pub link_type: LinkType,
pub attention: Option<AttentionWeights>,
}
pub struct ChainLinkEstimate {
pub baseline: f32, // 0.20 weight - Base semantic similarity
pub relationship: f32, // 0.30 weight - Relationship strength
pub type_based: f32, // 0.20 weight - Link type compatibility
pub context_weighted: f32, // 0.30 weight - Context-aware similarity
pub total_strength: f32, // Weighted sum
}10.6.4 Phase Inference
pub enum TrajectoryPhase {
Exploration, // Initial inquiry, topic discovery
Consolidation, // Building understanding, implementation
Synthesis, // Summarization, decisions
Debugging, // Error resolution
Planning, // Roadmaps, structured plans
}
pub struct PhaseInferencer {
pub fn infer_single(features: &TurnFeatures) -> Result<(TrajectoryPhase, f32)>
pub fn infer_sequence(features: &[TurnFeatures]) -> Result<Vec<PhaseTransition>>
}
pub struct TurnFeatures {
pub question_count: usize,
pub code_block_count: usize,
pub has_error_keywords: bool,
pub has_decision_keywords: bool,
}10.6.5 Salience Scoring
pub struct SalienceConfig {
pub base_score: f32, // Default: 0.5
pub feedback_up_boost: f32, // Default: 0.35
pub feedback_down_penalty: f32, // Default: 0.35
pub phase_transition_boost: f32, // Default: 0.10
pub novelty_boost_max: f32, // Default: 0.10
}
pub struct TurnSalience {
pub turn_id: u64,
pub score: f32, // [0, 1]
pub feedback_contribution: f32,
pub phase_contribution: f32,
pub novelty_contribution: f32,
}10.6.6 Ring Topology
pub struct Ring<T> {
pub fn new(nodes: Vec<T>) -> Self
pub fn get(idx: usize) -> &T // Wrapping index
pub fn ring_distance(a: usize, b: usize) -> usize
pub fn neighbors(idx: usize, radius: usize) -> impl Iterator<Item = &T>
}
pub struct DualRing<T> {
pub forward: Ring<T>, // Temporal order
pub inverse: Ring<T>, // Reverse temporal
}10.6.7 Conservation Laws
pub struct ConservationMetrics {
pub magnitude: f32, // Σᵢ aᵢ ‖eᵢ‖
pub energy: f32, // ½Σᵢⱼ aᵢaⱼ cos(eᵢ, eⱼ)
pub information: f32, // -Σ aᵢ log(aᵢ) (Shannon entropy)
}
impl ConservationMetrics {
pub fn is_conserved(other: &Self, tolerance: f32) -> bool
pub fn violation(other: &Self) -> ConservationViolation
}---
11. Python Layer Architecture
The Python layer provides ML training, high-level orchestration, and bridges to the Rust core.
11.1 CC-ML (Machine Learning)
cc-ml/
├── cc-motiongen/ # Motion Diffusion System
│ ├── config.py # Pydantic configs (352 lines)
│ │ ├── MotionConfig # 25D latents @ 30 FPS
│ │ ├── AudioConfig # 164-dim features
│ │ ├── DiffusionConfig # 1000 timesteps, cosine beta
│ │ ├── UNetConfig # 1D U-Net, 4 levels
│ │ ├── MusicalityConfig # 5 weighted metrics
│ │ └── SamplingConfig # Two-stage (8-step → 20-step)
│ │
│ └── model/
│ ├── diffusion.py # DDPM/DDIM implementation (882 lines)
│ │ ├── GaussianDiffusion
│ │ ├── forward_diffusion()
│ │ ├── reverse_diffusion()
│ │ ├── ddpm_sample()
│ │ ├── ddim_sample()
│ │ ├── inpainting_sample()
│ │ └── mpms_prior_inject() # RAG++ conditioning
│ │
│ ├── unet.py # 1D U-Net architecture
│ │ ├── UNet1D
│ │ ├── ResBlock
│ │ ├── AttentionBlock
│ │ └── TimeEmbedding
│ │
│ └── conditioning.py # Audio conditioning
│ ├── AudioConditioner
│ └── ContextTransformer
│
├── diffusion/ # Audio Diffusion Generation
│ ├── audio_codecs/ # Neural codecs
│ │ ├── dac.py # Discrete Audio Codec
│ │ ├── encodec.py # Meta EnCodec
│ │ └── vqvae.py # VQ-VAE codec
│ │
│ ├── models/
│ │ ├── vqvae/ # Vector-Quantized VAE
│ │ │ ├── encoder.py
│ │ │ ├── codebook.py
│ │ │ ├── decoder.py
│ │ │ └── losses.py
│ │ │
│ │ └── diffusion/
│ │ ├── unet.py # 1D U-Net (659 lines)
│ │ ├── dit.py # Diffusion Transformer (573 lines)
│ │ ├── noise_scheduler.py# Beta schedules (333 lines)
│ │ └── samplers.py # DDPM/DDIM (409 lines)
│ │
│ ├── integration/
│ │ ├── motion_diffusion_bridge.py # Motion → Audio orchestration
│ │ ├── phrase_retriever.py # RAG-based phrase retrieval
│ │ └── echelon_conditioning.py # Echelon-specific
│ │
│ └── inference/
│ ├── pipeline.py # Full inference pipeline
│ ├── realtime.py # Real-time streaming
│ ├── batched.py # Batch processing
│ └── export.py # ONNX/TorchScript export
│
├── models/cc-models/ # 11 Model Families
│ ├── rps/ # LIM-RPS Solver
│ │ ├── lim_rps.py # Lipschitz Implicit Map
│ │ ├── dell.py # DELL encoder
│ │ ├── encoders.py # Multi-modal encoders
│ │ └── prox_update.py # Proximal step
│ │
│ ├── gesture/ # Gesture Detection
│ │ ├── cnn_detector.py # CNN classifier
│ │ └── temporal_cnn.py # Temporal modeling
│ │
│ ├── phrase/ # Phrase Boundary Detection
│ │ ├── phrase_boundary_detector.py
│ │ └── heuristics.py
│ │
│ ├── planner/ # Motion Planning
│ │ ├── latent_intent_policy.py
│ │ ├── reward_model.py
│ │ └── rule_based_layer.py
│ │
│ └── resonant_flow/ # Audio Generation
│ ├── conductor.py # (13.5K lines)
│ ├── velocity_unet.py # (15.5K lines)
│ ├── phrase_encoder.py # (10.9K lines)
│ └── vocoder.py # (11.8K lines)
│
└── training/ # Training Infrastructure
├── trainers/
│ ├── train_dell.py
│ ├── train_rps.py
│ ├── train_gesture.py
│ └── train_dj_rl.py # RL-based DJ agent
│
└── dataloaders/
├── dell_dataset.py
└── sensor_processor.py11.2 CC-Core (Python Runtime)
cc-core/
├── equilibria/ # Mathematical Core
│ ├── lim_rps.py # LIM-RPS v1 (PyTorch)
│ │ ├── CrossModalOperator # 1-Lipschitz via spectral norm
│ │ ├── DiagMetric # Learned diagonal metric
│ │ ├── StepField # Learned step size γ(z)
│ │ ├── proximal_update() # L2 soft-thresholding
│ │ └── box_constraint() # Element-wise clipping
│ │
│ ├── lim_rps_v0.py # Legacy (no PyTorch required)
│ ├── fast_solver.py # Real-time approximation
│ ├── slow_solver.py # High-precision offline
│ └── coordinator.py # Solver selection
│
├── encoders/ # Sensor Encoding
│ ├── imu_encoder.py # IMU → latent
│ ├── mocopi_encoder.py # Mocopi skeleton → latent
│ └── limb_temporal.py # Per-limb temporal encoding
│
├── skeleton/ # Pose Representation
│ ├── pose_frame.py # Quaternion + position
│ ├── derived_kinematics.py # Velocity, accel, jerk
│ └── limb_windows.py # Local temporal windows
│
├── realtime/ # Production Runtime
│ ├── scheduler.py # Lock-free scheduling
│ ├── ring_buffer.py # Circular buffer
│ ├── instrument/ # Low-latency kernel
│ │ ├── kernel.py # 100+ Hz processing
│ │ ├── features.py # Feature extraction
│ │ └── events.py # Event generation
│ │
│ ├── audio_stream.py # Audio I/O
│ ├── choreo_server.py # HTTP API
│ └── echelon_adapter.py # Echelon integration
│
├── signal/ # Signal Processing
│ ├── audio.py # Mel, MFCC, chroma
│ ├── filters.py # LP, HP, BP, Kalman
│ ├── coherence.py # Phase/frequency alignment
│ └── dual_mic_fusion.py # Multi-mic processing
│
├── fusion/ # Sensor Fusion
│ ├── ekf.py # Extended Kalman Filter
│ ├── phase_lock.py # Beat tracking PLL
│ └── transformer.py # Cross-modal attention
│
├── bridge/ # Rust Integration
│ └── rust_accelerator.py # Transparent Rust bridge
│ ├── LockFreeRingBuffer # → cc_core_rs
│ ├── SlewLimiter # → cc_core_rs
│ ├── SecondOrderSlewLimiter# → cc_core_rs
│ ├── OneEuroFilter # → cc_core_rs
│ └── is_rust_available() # Graceful fallback
│
└── policy/ # RAG MotionPhrase
└── rag_motionphrase/
├── retriever.py # FAISS-based retrieval
├── reranker.py # Learned reranking
├── prior_builder.py # Prior construction
└── service.py # Production service11.3 Key ML Data Types
# 25D Motion Representation (cc-ml)
class MotionDim(IntEnum):
POS_X = 0 # Position X
POS_Y = 1 # Position Y
POS_Z = 2 # Position Z
VEL_X = 3 # Velocity X
VEL_Y = 4 # Velocity Y
VEL_Z = 5 # Velocity Z
ACC_X = 6 # Acceleration X
ACC_Y = 7 # Acceleration Y
ACC_Z = 8 # Acceleration Z
ROT_W = 9 # Rotation quaternion W
ROT_X = 10 # Rotation quaternion X
ROT_Y = 11 # Rotation quaternion Y
ROT_Z = 12 # Rotation quaternion Z
ANG_VEL_X = 13 # Angular velocity X
ANG_VEL_Y = 14 # Angular velocity Y
ANG_VEL_Z = 15 # Angular velocity Z
TENSION = 16 # Tension scalar
MOMENTUM = 17 # Momentum scalar
CURV_X = 18 # Curvature X
CURV_Y = 19 # Curvature Y
CURV_Z = 20 # Curvature Z
STABILITY = 21 # Stability scalar
PHASE = 22 # Phase [0, 2π]
# Dims 23-24 reserved
# DELL Config (cc-core)
@dataclass
class DELLConfig:
fast_rate: float = 50.0 # Frame rate (Hz)
slow_rate: float = 2.0 # Beat rate (Hz)
coupling_strength: float = 0.3
latent_dim: int = 16
spectral_norm: bool = True # 1-Lipschitz constraint
# GaussianDiffusion (cc-ml)
class GaussianDiffusion:
timesteps: int = 1000
beta_schedule: str = "cosine"
prediction_type: str = "v_prediction"
rescale_betas_zero_snr: bool = True11.4 Rust ↔ Python Bridge Pattern
# cc-core/bridge/rust_accelerator.py
try:
from cc_core_rs import (
LockFreeRingBuffer,
SlewLimiter,
SecondOrderSlewLimiter,
OneEuroFilter,
)
_RUST_AVAILABLE = True
except ImportError:
_RUST_AVAILABLE = False
# Define Python fallbacks...
def is_rust_available() -> bool:
return _RUST_AVAILABLE
# Usage: Same API regardless of backend
buffer = LockFreeRingBuffer(capacity=1024) # Uses Rust if available11.5 CC-Core Equilibrium Solvers (Python)
The cc-core Python package provides production-ready equilibrium solvers with provable stability guarantees.
11.5.1 LIMRPSSolver - Full Multi-Modal Fixed-Point
@dataclass
class LIMRPSConfig:
"""Configuration for Lipschitz-constrained Implicit Map solver."""
# Iteration
max_iters: int = 4 # K iterations
step_size: float = 0.5 # γ step size
# Architecture
hidden_dim: int = 128 # B_θ hidden dimension
num_layers: int = 2 # MLP depth
spectral_iters: int = 1 # Power iteration count
# Proximal
prox_mode: str = "l2" # "l2", "group_l2", "none"
prox_tau: float = 0.05 # Regularization strength
# Box constraints
box_lower: float = -10.0
box_upper: float = 10.0
# Adaptive geometry
use_metric: bool = False # Learned s(z) scaling
use_step_field: bool = False # Learned γ(z) step size
class LIMRPSSolver(nn.Module):
"""Multi-modal fixed-point solver with 1-Lipschitz operator."""
def forward(
self,
latents: Dict[str, Tensor], # {modality: [B, d_m]}
mask: Optional[Dict[str, Tensor]] = None,
z_init: Optional[Tensor] = None,
z_prev: Optional[Tensor] = None, # Temporal coupling
update_stats: bool = False # Power iteration update
) -> Tuple[Tensor, Tensor, Dict]:
"""
Returns:
z_star: [B, D] equilibrium latent
residuals: [K, B] convergence history
diagnostics: {mean_residual, convergence_achieved, ...}
Iteration: z^{k+1} = prox_G(z^k - γ(z^k) * B_θ(z^k))
"""11.5.2 DELLCoordinator - Dual-Equilibrium System
@dataclass
class DELLConfig:
"""Dual-Equilibrium Latent Learning configuration."""
# Fast equilibrium (frame-rate ~50Hz)
K_fast: int = 4
fast_step: float = 0.5
fast_hidden: int = 128
# Slow equilibrium (beat-rate ~2Hz)
K_slow: int = 6
slow_step: float = 0.4
slow_hidden: int = 64
D_slow: int = 32 # Slow latent dimension
# Timing
frames_per_beat: int = 24 # 120 BPM @ 50 FPS
# Coupling
coupling_weight: float = 1.0 # F_x, F_y strength
pool_type: str = "mean_std" # "mean", "mean_std", "last"
@dataclass
class DELLState:
"""Snapshot of DELL system at one frame."""
x_fast: Dict[str, Tensor] # Fast latents per modality
y_slow: Optional[Dict[str, Tensor]] # Slow latents (per beat)
frame_idx: int
tempo_bpm: float
confidence: float # Convergence confidence
residual: float # Final residual norm
class DELLCoordinator(nn.Module):
"""Orchestrates fast/slow equilibria with temporal coupling."""
def forward_one_frame(
self,
latents: Dict[str, Tensor],
frame_idx: int,
coupling_force: Optional[Tensor] = None
) -> DELLState:
"""
Single-frame processing:
1. Run FastEquilibrium with coupling injection
2. Check beat boundary (frame_idx % frames_per_beat == 0)
3. If beat: pool fast_history → run SlowEquilibrium → update y_slow
4. Compute coupling forces for next frame
"""11.5.3 CrossModalOperator - 1-Lipschitz Guarantee
class SpectralNormDense(nn.Module):
"""Linear layer with spectral normalization to enforce Lipschitz ≤ 1."""
def forward(self, x: Tensor, update_stats: bool = False) -> Tensor:
# Power iteration: u → v → σ
# Normalize: W_norm = W / σ
# Returns: x @ W_norm.T + bias
class CrossModalOperator(nn.Module):
"""
1-Lipschitz MLP: B_θ(z) where ||B_θ(z1) - B_θ(z2)|| ≤ ||z1 - z2||
Architecture:
- L hidden layers with SpectralNormDense
- ReLU scaled by 1/√2 (preserves Lipschitz ≤ 1)
- Final SpectralNormDense, no activation
"""11.5.4 Real-Time Infrastructure
class ControlThreadScheduler:
"""Dedicated control thread with fixed-frequency loop."""
def __init__(
self,
dell: DELLCoordinator,
encoder: Optional[Callable],
config: ControlThreadConfig # rate_hz=100, max_latency_ms=8
):
self.ring_buffer = LockFreeRingBuffer(capacity=256)
self.profiler = LatencyProfiler(window_size=100)
def submit_sensor_data(self, data: ChoreoFrame) -> None:
"""Non-blocking push to queue (thread-safe)."""
def get_latest_control_vector(self) -> ControlVector:
"""Lock-free read of latest state."""
def run_loop(self) -> None:
"""
Main control loop:
- Fixed dt = 1.0 / rate_hz
- Adaptive K iterations if latency exceeded
- Error handling with fallback vectors
"""
class LockFreeRingBuffer(Generic[T]):
"""SPSC ring buffer for thread-safe handoff."""
def push(self, value: T) -> bool # Non-blocking write
def pop(self) -> Optional[T] # Non-blocking read
def peek() -> Optional[T] # Read without remove11.6 CC-ML Diffusion Models (Python)
The cc-ml package provides motion generation via diffusion models.
11.6.1 GaussianDiffusion - Core Diffusion Engine
@dataclass
class DiffusionConfig:
timesteps: int = 1000 # T diffusion steps
beta_schedule: str = "cosine" # "linear", "cosine", "sqrt"
beta_start: float = 0.0001
beta_end: float = 0.02
prediction_type: str = "v" # "eps", "x0", "v"
rescale_betas_zero_snr: bool = True
clip_denoised: bool = True
class GaussianDiffusion(nn.Module):
"""DDPM/DDIM diffusion with v-prediction."""
# Forward (noising)
def q_sample(self, x_0: Tensor, t: Tensor) -> Tuple[Tensor, Tensor]:
"""Add noise: x_t = √α̅_t * x_0 + √(1-α̅_t) * ε"""
# Reverse (sampling)
def ddpm_sample(self, shape: Tuple, cond: Dict, **kwargs) -> Tensor:
"""Standard DDPM reverse process (stochastic)."""
def ddim_sample(
self, shape: Tuple, cond: Dict,
eta: float = 0.0, # 0 = deterministic DDIM
steps: int = 50 # < T for fast sampling
) -> Tensor:
"""Deterministic DDIM sampling."""
def inpaint_sample(
self, shape: Tuple, cond: Dict,
mask: Tensor, # [B, T, D] binary mask
x_known: Tensor # Known regions
) -> Tensor:
"""Inpainting via masked diffusion."""
def transition_blend(
self, x_from: Tensor, x_to: Tensor,
t_blend: int = 100 # Blend timestep
) -> Tensor:
"""Smooth transition between two motions."""11.6.2 UNet1D - Denoising Network
@dataclass
class UNetConfig:
in_channels: int = 25 # 25D motion
out_channels: int = 25
model_channels: int = 256
num_res_blocks: int = 2
attention_resolutions: List[int] = [4, 8, 16]
dropout: float = 0.0
channel_mult: Tuple = (1, 2, 4, 8)
num_heads: int = 8
class UNet1D(nn.Module):
"""
1D U-Net for motion denoising.
Architecture:
- Encoder: ↓ conv with attention at specified resolutions
- Middle: Self-attention + ResBlock
- Decoder: ↑ conv with skip connections
- Time embedding: sinusoidal → MLP
- Conditioning: cross-attention to audio/text
"""
def forward(
self, x: Tensor, # [B, C, T] noisy motion
t: Tensor, # [B] timestep
cond: Optional[Dict] = None # Audio, text, etc.
) -> Tensor: # [B, C, T] predicted v/eps/x011.6.3 VQ-VAE - Discrete Latent Space
@dataclass
class VQVAEConfig:
in_channels: int = 25
latent_dim: int = 64
codebook_size: int = 2048
total_stride: int = 256 # Temporal compression
commitment_weight: float = 0.25
class VQVAE(nn.Module):
"""Vector-Quantized VAE for motion compression."""
encoder: Encoder # Motion → continuous latent
quantizer: VectorQuantizer # Continuous → discrete
decoder: Decoder # Discrete → motion
def encode(self, x: Tensor) -> Tuple[Tensor, Tensor, float]:
"""Returns: (z_q, indices, commitment_loss)"""
def decode(self, z_q: Tensor) -> Tensor:
"""Reconstruct motion from quantized latent."""
class VectorQuantizer(nn.Module):
"""Codebook with EMA updates."""
codebook: Tensor # [codebook_size, latent_dim]
def forward(self, z: Tensor) -> Tuple[Tensor, Tensor, float]:
"""
Quantize: z → z_q using nearest codebook entry
Returns: (z_q, indices, commitment_loss)
"""11.6.4 25D Motion Representation
class MotionDim(IntEnum):
"""25-dimensional motion vector layout."""
# Position (3)
POS_X, POS_Y, POS_Z = 0, 1, 2
# Velocity (3)
VEL_X, VEL_Y, VEL_Z = 3, 4, 5
# Acceleration (3)
ACC_X, ACC_Y, ACC_Z = 6, 7, 8
# Root rotation quaternion (4)
ROT_W, ROT_X, ROT_Y, ROT_Z = 9, 10, 11, 12
# Angular velocity (3)
ANG_VEL_X, ANG_VEL_Y, ANG_VEL_Z = 13, 14, 15
# Semantic scalars (7)
TENSION = 16 # [0, 1] muscular tension
MOMENTUM = 17 # [0, 1] movement magnitude
CURVATURE_X, CURVATURE_Y, CURVATURE_Z = 18, 19, 20
STABILITY = 21 # [0, 1] balance confidence
PHASE = 22 # [0, 2π] cyclic phase
# Reserved (2)
RESERVED_0, RESERVED_1 = 23, 24---
12. Complete Data Flow Pipeline
┌─────────────────────────────────────────────────────────────────────────────┐
│ FULL SYSTEM DATA FLOW │
└─────────────────────────────────────────────────────────────────────────────┘
SENSORS (Layer 0)
┌───────────────────────────────────────────────────────────────────────────┐
│ Mocopi (UDP) Phone (WS) Watch (BLE) AirPods DepthCamera │
│ │ │ │ │ │ │
│ └──────────────┼──────────────┼──────────────┼───────────┘ │
│ ▼ │
│ ┌───────────────┐ │
│ │ cc-collection │ Kalman fusion, validation │
│ └───────┬───────┘ │
└──────────────────────┼────────────────────────────────────────────────────┘
│
▼ RawPacket
ALIGNMENT (Layer 2)
┌───────────────────────────────────────────────────────────────────────────┐
│ cc-window-aligner (5 Stages) │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ 1. Time │→│2.Resamp │→│3. Coord │→│4. Fusion│→│5.Window │ │
│ │Normalize│ │ 50Hz │ │ Unify │ │(multi-D)│ │ (50 fr) │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ │ │
│ Invariants: INV-001 (determinism), INV-004 (monotonic) │
└────────────────────────────────────────────────────────┼──────────────────┘
│
▼ MotionWindow (FROZEN)
SEMANTIC (Layer 3)
┌───────────────────────────────────────────────────────────────────────────┐
│ cc-semantic │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ SemanticProjector │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
│ │ │ Phase │ │Momentum │ │ Tension │ │ Intent │ │Stability│ │ │
│ │ │(cyclic) │ │(heading)│ │(jerk/d) │ │(direct) │ │(health) │ │ │
│ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │ │
│ │ └───────────┼───────────┼───────────┼───────────┘ │ │
│ │ ▼ │ │
│ │ SemanticFrame v1 (FROZEN) │ │
│ │ + Confidence, ValidityHorizon │ │
│ └────────────────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────┬───────────────────┘
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
ANTICIPATION (Layer 4) RETRIEVAL (Layer 4) RAG++ MEMORY
┌───────────────────────┐ ┌───────────────────┐ ┌───────────────────┐
│ cc-anticipation │ │ cc-retrieval │ │ cc-rag-plus-plus │
│ ┌─────────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │AnticipationPkt │ │ │ │MotionPhrase │ │ │ │TrajectoryMem│ │
│ │ • Commitment │ │ │ │(FROZEN v1) │ │ │ │ • Episodes │ │
│ │ • Uncertainty │ │ │ └─────────────┘ │ │ │ • Edges │ │
│ │ • TransPressure │ │ │ ┌─────────────┐ │ │ │ • Salience │ │
│ │ • RegimeEmbed │ │ │ │RetrievalRes │ │ │ └─────────────┘ │
│ └────────┬────────┘ │ │ │(FROZEN v1) │ │ │ ┌─────────────┐ │
└───────────┼───────────┘ │ └─────────────┘ │ │ │OutcomeStats │ │
│ └─────────┬─────────┘ │ │(Welford) │ │
│ │ │ └─────────────┘ │
└────────────────────────┼────────────┴───────────────────┘
│
▼
CONDUCTOR (Layer 5)
┌───────────────────────────────────────────────────────────────────────────┐
│ cc-conductor │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ AnticipationScalars → [Gates] → [Policy] → PolicySignals │ │
│ │ │ │ │ │
│ │ ConductorState PolicyMode: │ │
│ │ (history/smooth) Conservative → Expressive │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ Output: ExplorationBudget, TemperatureParams, EventGates │
└───────────────────────────────────────────────────────────────────────────┘
│
▼
SCHEDULING (Layer 6)
┌───────────────────────────────────────────────────────────────────────────┐
│ cc-echelon/scheduler │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Intent → Compiler → QuantizedAction → Executor │ │
│ │ │ │ │ │ │
│ │ Safety Policies link-clock action_queue │ │
│ │ (Ableton Link) │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────────────────┘
│
▼ ControlEvent (via control-bus ring)
AUDIO (Layer 7)
┌───────────────────────────────────────────────────────────────────────────┐
│ cc-echelon/audio-engine │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ DSP Graph: │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
│ │ │Oscillator│→│ Filter │→│ Effects │→│ Mixer │→│ Limiter │ │ │
│ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │
│ │ │ │ │
│ │ Synths: SuperSaw, AcidBass, Kick808, MotionSynth ▼ │ │
│ │ CPAL Backend │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────────────────┘
│
▼
🔊 Audio Output---
13. FROZEN Contracts & Schema Versions
13.1 Frozen Type Summary
| Type | Crate | Version | Status | Key Fields |
|---|---|---|---|---|
| SemanticFrame | cc-semantic | 1.0.0 | FROZEN | phase, momentum, tension, intent, stability, regime |
| MotionPhrase | cc-retrieval | 1.0.0 | FROZEN | metadata, invariants, variants, playback_constraints |
| RetrievalResult | cc-retrieval | 1.0.0 | FROZEN | candidates, context, query_hash, confidence |
| MotionWindow | cc-types | 0.1.0 | FROZEN | frames[50], t_start, t_end, coverage, device_mask |
| SkeletonFrame | cc-types | 0.1.0 | FROZEN | bones[27], root_position, provenance |
13.2 Invariants Catalog
| Code | Name | Description |
|---|---|---|
| INV-001 | Determinism | Same inputs → identical outputs (byte-for-byte) |
| INV-002 | Boundedness | Exactly `config.frames_per_window` frames |
| INV-003 | Explicit Missingness | Interpolated frames marked, no silent gaps |
| INV-004 | Temporal Monotonicity | Strictly increasing timestamps |
| INV-005 | Device Coverage | At least `min_coverage` frames from devices |
| INV-006 | Quaternion Normalization | All rotations unit quaternions |
| INV-007 | Checksum Validity | XXH64 checksum matches content |
| INV-010 | Window ID Determinism | Hash of (session_id, t_start, config_hash) |
13.3 Confidence Anti-Hallucination Pattern
All semantic values are wrapped:
pub struct SemanticValue<T> {
pub value: Option<T>, // None if unavailable
pub confidence: Confidence, // 0.0-1.0 with is_valid flag
pub validity: ValidityHorizon, // Recomputation cycle
pub unavailable_reason: Option<UnavailableReason>,
}
// Reasons for unavailability
pub enum UnavailableReason {
NotComputed,
LowConfidence,
MissingStream,
SensorDesync,
Initializing,
}---
Summary Statistics (EXHAUSTIVE - December 2025)
| Category | Count |
|---|---|
| Total Rust Crates | 32 (13 top-level + 18 cc-echelon + 1 workspace) |
| CC-Echelon Sub-crates | 18 |
| Python Packages | 2 (cc-ml, cc-core) |
| Total Rust Lines | ~185,000 |
| Total Python Lines | ~60,000 |
| cc-rag-plus-plus lines | 24,879 (51 .rs files) |
| cc-echelon lines | ~50,000 (18 sub-crates) |
| cc-semantic lines | ~2,500 |
| cc-retrieval lines | ~2,200 |
| cc-window-aligner lines | ~22,000 |
| cc-ml Python lines | ~33,000 |
| cc-core Python lines | ~27,000 |
| FROZEN Contracts | 5 |
| Total Tests | 400+ |
| Skeleton Bones | 27 |
| Window Frames | 50 (1 second @ 50Hz) |
| Anticipation Horizons | 4 (200ms, 500ms, 1s, 2s) |
| Semantic Projections | 5 (Phase, Momentum, Tension, Intent, Stability) |
| Regime Types | 8 |
| Action Types | 7 |
| CC-Echelon ControlEvent variants | 30+ |
| ML Model Families | 11 |
| Diffusion Model Params | 1000 timesteps, cosine beta |
| 25D Motion Representation | pos(3), vel(3), acc(3), rot(4), ang_vel(3), tension, momentum, curv(3), stability, phase |
Crate Categories
| Category | Crates |
|---|---|
| Foundation | cc-types, cc-core-rs |
| Semantic | cc-semantic, cc-retrieval |
| Pipeline | cc-window-aligner, cc-collection, cc-protocol |
| Intelligence | cc-anticipation, cc-conductor, cc-rag-plus-plus |
| CC-Echelon Core | cc-brain, motion-bridge, music-brain |
| CC-Echelon Audio | audio-engine, dsp-utils, ts-shift |
| CC-Echelon Scheduling | scheduler, link-clock, shmem-ipc |
| CC-Echelon Media | media, phrase-intelligence |
| CC-Echelon Control | control-bus, midi-osc, voice-control |
| CC-Echelon UI | ui-shell, viz, viz-server |
Key Algorithms
| Component | Algorithm |
|---|---|
| Diffusion | DDPM/DDIM + classifier-free guidance |
| LIM-RPS | Fixed-point iteration with Lipschitz constraints |
| VQ-VAE | Vector-quantized autoencoder |
| Sensor Fusion | Extended Kalman Filter + phase-lock loops |
| Phrase Retrieval | HNSW + RRF multi-index fusion |
| Statistics | Welford's algorithm (numerically stable) |
---
14. Complete Crate Reference Table
| Crate | Layer | Lines | Key Exports | Status |
|---|---|---|---|---|
| cc-types | Foundation | ~700 | `LatentVector`, `Quaternion`, `Vec3` | Stable |
| cc-core-rs | Foundation | ~2,000 | `RingBuffer`, `EmaFilter`, `OneEuroFilter`, `SlewLimiter` | Stable |
| cc-semantic | Semantic | ~2,500 | `SemanticFrame`, `PhaseState`, `MomentumState`, `TensionState` | FROZEN v1 |
| cc-retrieval | Semantic | ~2,200 | `MotionPhrase`, `RetrievalResult`, `RetrievalQuery` | FROZEN v1 |
| cc-window-aligner | Pipeline | ~22,000 | `WindowAligner`, `MotionWindow`, `SkeletonFrame`, `SemanticProjector` | Stable |
| cc-collection | Pipeline | ~3,500 | `SensorFusion`, `KalmanFilter`, `DeviceRegistry` | Stable |
| cc-protocol | Pipeline | ~1,800 | `Message`, `DualTimeContract`, `MessagePackCodec` | Stable |
| cc-anticipation | Intelligence | ~4,200 | `AnticipationPacket`, `HorizonForecast`, `EventForecast` | Stable |
| cc-conductor | Intelligence | ~5,500 | `ConductorDecision`, `PolicySignals`, `Gate`, `Budget` | Stable |
| cc-rag-plus-plus | Intelligence | ~24,879 | `RagPlusPlusEngine`, `TrajectoryMemory`, `HNSWIndex`, `Welford` | Stable |
| cc-echelon | Application | ~50,000 | 18 sub-crates (see Section 9) | Active |
---
15. Glossary of Key Terms
| Term | Definition |
|---|---|
| LIM-RPS | Lipschitz Implicit Map for Recursive Polymodal Synthesis - embodied latent physics |
| DELL | Dual-Equilibrium Latent Learning - fast/slow solver coupling |
| SemanticFrame | Replay-stable motion interpretation with confidence |
| MotionPhrase | Reusable motor program with invariants |
| Dual-Time Contract | Latent time (continuous) vs Execution time (quantized bar/beat) |
| HNSW | Hierarchical Navigable Small World - approximate nearest neighbor index |
| I-RCP | Inverse Recursive Context Propagation - attention-based trajectory linking |
| Welford | Numerically stable running statistics algorithm |
| Ring Buffer | Lock-free SPSC circular buffer for real-time data |
| 5D DLM Coordinate | (depth, sibling, homogeneity, temporal, complexity) trajectory position |
16. Cross-References & Dependencies
16.1 Rust Crate Dependency Matrix
┌─────────────────────────────────────────────────────────┐
│ CRATE DEPENDENCY GRAPH │
└─────────────────────────────────────────────────────────┘
Level 5 (Applications)
┌─────────────────────────────────────────────────────────────────────────────────┐
│ cc-echelon (18 crates) │ iOS Apps │ Desktop Apps │ Python Bindings │
└─────────────────────────────────────────────────────────────────────────────────┘
│
Level 4 (Intelligence) ▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ cc-conductor ──► cc-anticipation ──► cc-rag-plus-plus │
└─────────────────────────────────────────────────────────────────────────────────┘
│
Level 3 (Semantic) ▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ cc-semantic (FROZEN v1) │ cc-retrieval (FROZEN v1) │
└─────────────────────────────────────────────────────────────────────────────────┘
│
Level 2 (Pipeline) ▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ cc-window-aligner ──► cc-collection ──► cc-protocol │
└─────────────────────────────────────────────────────────────────────────────────┘
│
Level 1 (Foundation) ▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ cc-types │ cc-core-rs │
└─────────────────────────────────────────────────────────────────────────────────┘16.2 Explicit Crate Dependencies
| Crate | Direct Dependencies | Transitive Count |
|---|---|---|
| cc-types | (none - foundation) | 0 |
| cc-core-rs | cc-types | 1 |
| cc-semantic | cc-types | 1 |
| cc-retrieval | cc-types, cc-semantic | 2 |
| cc-protocol | cc-types, serde, postcard | 3 |
| cc-collection | cc-types, cc-core-rs, nalgebra | 4 |
| cc-window-aligner | cc-types, cc-semantic, cc-retrieval, cc-core-rs | 5 |
| cc-anticipation | cc-types, cc-semantic, cc-protocol | 4 |
| cc-conductor | cc-types, cc-semantic, cc-retrieval, cc-protocol, cc-anticipation | 6 |
| cc-rag-plus-plus | cc-types, hnsw_rs, nalgebra | 4 |
16.3 CC-Echelon Internal Dependencies
audio-engine ◄── scheduler ◄── cc-brain ◄── motion-bridge
│ │ │ │
▼ ▼ ▼ ▼
control-bus ◄─────────────────────────────────────
│
▼
dsp-utils, link-clock| Sub-Crate | Depends On |
|---|---|
| control-bus | (none - core ring buffer) |
| dsp-utils | (none - pure DSP functions) |
| link-clock | ableton_link |
| audio-engine | control-bus, dsp-utils, link-clock |
| scheduler | control-bus, link-clock |
| cc-brain | control-bus, audio-engine, scheduler |
| motion-bridge | control-bus, cc-brain |
| ui-shell | control-bus, cc-brain, audio-engine |
| phrase-intelligence | cc-brain, audio-engine |
| midi-osc | control-bus |
| voice-control | control-bus, whisper-rs |
| media | (standalone - media database) |
| music-brain | media, phrase-intelligence |
| viz | control-bus, ui-shell |
16.4 Python ↔ Rust Type Mappings
| Python Type | Rust Type | Bridge Mechanism |
|---|---|---|
| `numpy.ndarray[float32]` | `&[f32]` / `Vec<f32>` | PyO3 buffer protocol |
| `torch.Tensor` | `Vec<f32>` | `.numpy()` conversion |
| `LIMRPSConfig` | `cc_core_rs::SolverConfig` | PyO3 `#[pyclass]` |
| `MotionFrame` | `cc_types::SkeletonFrame` | serde JSON bridge |
| `DELLState` | `cc_semantic::SemanticFrame` | Protocol buffer |
| `GaussianDiffusion` | N/A (Python only) | - |
| `EKFState` | `cc_collection::FusedState` | PyO3 struct |
| `PhaseLock` | `cc_core_rs::PhaseLockLoop` | Direct binding |
16.5 FROZEN Schema Cross-References
| Schema | Version | Frozen Date | Depends On |
|---|---|---|---|
| `cc-types` (SkeletonFrame) | 1.0.0 | 2025-01 | - |
| `cc-types` (MotionWindow) | 1.0.0 | 2025-01 | SkeletonFrame |
| `cc-semantic` (SemanticFrame) | 1.0.0 | 2025-01 | cc-types |
| `cc-retrieval` (MotionPhrase) | 1.0.0 | 2025-01 | cc-semantic |
| `cc-retrieval` (RetrievalResult) | 1.0.0 | 2025-01 | MotionPhrase |
| `cc-protocol` (CoreMessage) | 1.0.0 | 2025-01 | cc-types, cc-semantic |
| `cc-window-aligner` (projection) | 1.0.0 | 2025-01 | cc-semantic |
Schema Compatibility Matrix:
cc-types cc-semantic cc-retrieval cc-protocol
cc-types ─ ✓ ✓ ✓
cc-semantic ✗ ─ ✓ ✓
cc-retrieval ✗ ✗ ─ ✓
cc-protocol ✗ ✗ ✗ ─
✓ = Row depends on Column's schema
✗ = No dependency
─ = Self16.6 Invariant Cross-References
| Invariant ID | Crate(s) | Description | Validation |
|---|---|---|---|
| INV-001 | cc-types | Bone indices 0-26 valid | `BONE_COUNT = 27` |
| INV-002 | cc-semantic | Confidence ∈ [0, 1] | `Confidence::new()` clamp |
| INV-003 | cc-retrieval | Fit score ≥ 0.3 for selection | `MIN_FIT_SCORE` |
| INV-004 | cc-retrieval | Legibility ≥ 0.5 for selection | `MIN_LEGIBILITY_SCORE` |
| INV-005 | cc-protocol | Dual-time contract | `latent_time` + `execution_time` |
| INV-006 | cc-window-aligner | Deterministic replay | Frozen thresholds |
| INV-007 | cc-rag-plus-plus | 5D coordinate bounds | DLMWeights normalization |
| INV-008 | cc-conductor | Policy ∈ valid enum | `ControlPolicy` exhaustive |
| INV-009 | cc-anticipation | Futures horizon ≤ 2s | `MAX_ANTICIPATION_HORIZON` |
| INV-010 | cc-core-rs | Ring buffer SPSC | Single producer/consumer |
16.7 Message Flow Cross-References
Sensor Input Pipeline Intelligence Output
───────────────────────────────────────────────────────────────────────────
┌──────────────┐ ┌──────────────┐
Mocopi UDP ──────────►│ cc-collection│──────►│ │
│ (Kalman EKF) │ │ │
MediaPipe WS ────────►└──────────────┘ │ │
│ │ cc-conductor │───► Actions
▼ │ (Policy) │
┌──────────────┐ │ │
│cc-window- │──────►│ │
│ aligner │ │ │
│(5-stage pipe)│ └──────────────┘
└──────────────┘ │
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ cc-semantic │ │cc-anticipation│
│(SemanticFrame│◄─────►│ (Futures) │
└──────────────┘ └──────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ cc-retrieval │◄─────►│cc-rag-plus- │
│(MotionPhrase)│ │ plus │
└──────────────┘ │(Trajectory) │
└──────────────┘16.8 Python Package Dependencies
# cc-ml dependencies
torch >= 2.0
diffusers >= 0.21
transformers >= 4.30
numpy >= 1.24
einops >= 0.6
accelerate >= 0.20
# cc-core dependencies
numpy >= 1.24
scipy >= 1.10
torch >= 2.0 # optional for GPU
maturin >= 1.0 # for Rust bindings| Python Package | Rust Bridge | External Deps |
|---|---|---|
| cc-core | cc-core-rs (PyO3) | numpy, scipy |
| cc-ml | None (pure Python) | torch, diffusers |
| cc-mcs | cc-collection (PyO3) | fastapi, websockets |
| cc-vision | mediapipe | opencv |
17. Final Statistics Summary
17.1 Documented Type Counts
| Category | Count | Notes |
|---|---|---|
| Rust Structs | 387 | Across all 32 crates |
| Rust Enums | 124 | Including 30+ variant ControlEvent |
| Rust Traits | 18 | Node, BeatClock, Filter, etc. |
| Rust Constants | 67 | FROZEN thresholds and configs |
| Python Classes | 89 | cc-ml (52) + cc-core (37) |
| Python Functions | 156 | Utility and processing functions |
| Python Dataclasses | 34 | Config and state containers |
| Total Public APIs | 512 | Methods documented |
17.2 Codebase Scale
| Metric | Value |
|---|---|
| Total Rust Files | 352 |
| Total Rust Lines | ~145,000 |
| Total Python Files | 481 |
| Total Python Lines | ~147,000 |
| Combined Source Lines | ~292,000 |
| Rust Crates | 32 (13 top-level + 18 cc-echelon + 1 workspace) |
| Python Packages | 14 |
| Test Coverage (Rust) | ~78 |
| Test Coverage (Python) | ~65 |
17.3 Schema & Contract Summary
| Schema Type | Count | Status |
|---|---|---|
| FROZEN Schemas | 7 | Locked for v1 |
| Provisional Schemas | 4 | May evolve |
| Invariants Documented | 10 | INV-001 through INV-010 |
| Cross-Crate Contracts | 12 | Type-safe boundaries |
17.4 Layer Distribution
┌────────────────────────────────────────────────────────────────┐
│ CODE DISTRIBUTION │
├────────────────────────────────────────────────────────────────┤
│ cc-echelon (18 crates) ████████████████████████ 48,000 lines │
│ cc-rag-plus-plus ████████████ 24,000 lines │
│ cc-window-aligner ███████████ 22,000 lines │
│ cc-ml (Python) ██████████████████████ 44,000 lines │
│ cc-core (Python) ██████████████ 28,000 lines │
│ Foundation crates ████████████████ 32,000 lines │
│ Other (apps, tools) ████████████████████████ 94,000 lines │
└────────────────────────────────────────────────────────────────┘17.5 Key Type Summary Table
| Type | Crate | Role | Complexity |
|---|---|---|---|
| `SkeletonFrame` | cc-types | Motion capture frame | 27 bones × 7 floats |
| `MotionWindow` | cc-types | Aligned frame sequence | ~100 frames typical |
| `SemanticFrame` | cc-semantic | Interpreted motion state | 6 sub-states |
| `MotionPhrase` | cc-retrieval | Reusable motor program | Variable length |
| `TrajectoryGraph` | cc-rag-plus-plus | Memory structure | ~10K nodes typical |
| `TrajectoryCoordinate5D` | cc-rag-plus-plus | Position in memory | 5 dimensions |
| `CoreMessage` | cc-protocol | Wire format | postcard-encoded |
| `ControlEvent` | cc-echelon | Ring buffer message | 30+ variants |
| `AudioEngine` | cc-echelon | DSP graph | 128-sample blocks |
| `GaussianDiffusion` | cc-ml | Denoising model | 1000 timesteps |
| `LIMRPSSolver` | cc-core | Physics solver | 4 iterations |
| `DELLCoordinator` | cc-core | Dual equilibrium | 50Hz + 2Hz |
17.6 Performance Characteristics
| Component | Latency | Throughput | Memory |
|---|---|---|---|
| cc-collection (EKF) | <1ms | 50 FPS | ~2 KB/frame |
| cc-window-aligner | 2-5ms | 50 FPS | ~50 KB/window |
| cc-semantic projection | <0.5ms | 50 FPS | ~1 KB/frame |
| cc-retrieval lookup | 1-3ms | On-demand | ~100 MB index |
| cc-rag-plus-plus HNSW | 5-20ms | On-demand | ~500 MB graph |
| cc-echelon audio | <3ms | 375 Hz | 128-sample buffer |
| cc-ml diffusion | 50-200ms | 5-20 Hz | ~2 GB VRAM |
| LIM-RPS solver | 2-8ms | 50 FPS | ~10 KB state |
17.7 Documentation Completeness
| Section | Lines | Tables | Diagrams | Code Blocks |
|---|---|---|---|---|
| Executive Summary | 45 | 1 | 0 | 0 |
| System Architecture | 180 | 2 | 3 | 0 |
| Foundation Layer | 320 | 8 | 1 | 4 |
| Semantic Layer | 280 | 6 | 0 | 3 |
| Pipeline Layer | 420 | 12 | 2 | 5 |
| Intelligence Layer | 380 | 10 | 1 | 4 |
| Protocol Layer | 240 | 5 | 1 | 3 |
| CC-Echelon | 520 | 15 | 2 | 6 |
| RAG++ Trajectory | 340 | 8 | 1 | 4 |
| Python Layers | 380 | 10 | 0 | 8 |
| Cross-References | 200 | 8 | 3 | 2 |
| Total | ~3,500 | 85 | 14 | 39 |
---
Document generated: 2025-12-28
Schema Version: 1.0.0
Total Document Lines: ~3,500
Total Codebase Lines: ~292,000 (Rust + Python)
Documented Types: 512+ public APIs
FROZEN Contracts: 7 schemas, 10 invariants
Promotion Decision
Promote into a technical note or architecture paper with implementation anchors.
Source Anchor
projects/Documentation/01-architecture/MASTER_ARCHITECTURE.md
Detected Structure
Method · Evaluation · References · Code Anchors · Architecture