# Architecture Overview

## System Diagram (text)
```
            +--------------------+
            |  Program Generator |
            | (Type 1 setpoints) |
            +---------+----------+
                      |
                      v
            +-----------------------+
            | Controller / Actuator |
            | (Type 2/3 modules)    |
            +---------+-------------+
                      |
                      v
        +----------------------------+
        |  Diffusion (Residuals)     |
        |  - Continuous PVs          |
        |  - Discrete mask diffusion |
        +---------+------------------+
                  |
                  v
     +-----------------------------+
     | Post-processing             |
     | - Derived tags (Type 5)     |
     | - KS-only resample baseline |
     +-----------------------------+
```

## Core Components
- **Stage‑1 Temporal GRU**: learns trend for continuous features.
- **Diffusion Backbone**: Transformer (default) or GRU; predicts residuals + discrete logits.
- **Post-hoc Calibration**: optional quantile calibration to align 1D CDFs.
- **KS-only Baseline**: Type1/2/3/5/6 empirical resampling for rapid KS reduction (diagnostic; may hurt joint realism).

## Feature-Type Split
1) **Type 1**: Setpoints/demands → program generator  
2) **Type 2**: Controller outputs → small emulator / conditional head  
3) **Type 3**: Actuators/valves → spike‑and‑slab / dwell-time model  
4) **Type 4**: Process PVs (multi‑modal/heavy tail) → diffusion with conditioning  
5) **Type 5**: Derived tags → deterministic reconstruction (or empirical KS baseline)  
6) **Type 6**: Auxiliary/vibration → narrow-band AR/SSM or empirical KS baseline

## Data Flow
- Input CSV → stats/vocab → normalized batches  
- Trend GRU → residual diffusion → inverse transforms → export  
