synheart_flux/lib.rs
1//! Synheart Flux - On-device compute engine for HSI-compliant human state signals
2//!
3//! Flux transforms raw wearable vendor data into HSI-compliant signals through a
4//! deterministic pipeline: vendor adaptation → normalization → feature derivation
5//! → baseline computation → HSI encoding.
6//!
7//! ## Module Structure
8//!
9//! - **core/**: Shared infrastructure (error types, schema definitions)
10//! - `error.rs`: `ComputeError` enum for pipeline errors
11//! - `schema/`: Raw event schema and adapters (wear.raw_event.v1)
12//! - **biosignal/**: Wearable physiology processing pipeline
13//! - `adapters/`: Vendor-specific adapters (WHOOP, Garmin)
14//! - `normalizer.rs`: Unit normalization
15//! - `features.rs`: Feature derivation
16//! - `baseline.rs`: Rolling baseline computation
17//! - `encoder.rs`: HSI output encoding
18//! - `types.rs`: Core biosignal data structures
19//! - **behavior/**: Smartphone behavioral data processing
20//! - `parser.rs`: Session parsing
21//! - `normalizer.rs`: Behavioral normalization
22//! - `features.rs`: Feature derivation
23//! - `baseline.rs`: Rolling baselines
24//! - `encoder.rs`: HSI output encoding
25//! - `pipeline.rs`: BehaviorProcessor orchestration
26//! - **pipeline/**: Top-level orchestration
27//! - `context.rs`: Staleness-aware bio context (BioDailyContext, DecayedBioContext)
28//! - `biosignal_flow.rs`: Stateless biosignal processing
29//! - `behavior_flow.rs`: Reserved for behavior flow extraction
30//! - FluxProcessor: Stateful processor with baseline persistence
31//! - **ffi/**: C-compatible bindings for FFI
32//! - `biosignal.rs`: WHOOP/Garmin FFI functions
33//! - `behavior.rs`: Behavioral FFI functions
34
35// Core shared infrastructure
36pub mod core;
37
38// Biosignal domain (wearable physiology)
39pub mod biosignal;
40
41// Behavioral domain
42pub mod behavior;
43
44// Orchestration (pipeline module with context, flows)
45pub mod pipeline;
46
47pub mod snapshot_adapter;
48pub mod stats;
49
50// FFI bindings for C interop (always available for cdylib/staticlib builds)
51pub mod ffi;
52
53// Re-exports from core for backward compatibility
54pub use core::error::ComputeError;
55pub use core::hsi::{
56 HsiAxes, HsiAxesDomain, HsiAxisReading, HsiConsent, HsiDirection, HsiPayload, HsiPrivacy,
57 HsiProducer, HsiSource, HsiSourceType, HsiWindow, HSI_VERSION,
58};
59pub use core::schema::{RawEvent, RawEventAdapter, ValidationError, SCHEMA_VERSION};
60
61// Re-exports from snapshot_adapter
62pub use snapshot_adapter::{
63 AdaptSnapshot, DataSource, HsiScores, MappingConfig, ScoreConfidence, SnapshotAdapter,
64};
65
66// Re-exports from biosignal for backward compatibility
67pub use biosignal::types::*;
68pub use biosignal::{
69 BaselineStore, FeatureDeriver, GarminAdapter, HsiEncoder, Normalizer, VendorPayloadAdapter,
70 WhoopAdapter, DEFAULT_BASELINE_WINDOW,
71};
72
73// Re-exports from pipeline for public API
74pub use pipeline::context::{BioDailyContext, DecayedBioContext, DEFAULT_DECAY_HALF_LIFE_HOURS};
75pub use pipeline::{garmin_to_hsi_daily, whoop_to_hsi_daily, FluxProcessor};
76
77// Stats exports
78pub use stats::ExtendedStats;
79
80// Behavioral exports
81pub use behavior::{behavior_to_hsi, BehaviorProcessor};
82
83/// Flux version embedded in all HSI payloads
84pub const FLUX_VERSION: &str = env!("CARGO_PKG_VERSION");
85
86/// Producer name for HSI payloads
87pub const PRODUCER_NAME: &str = "synheart-flux";