synheart_sensor_agent/lib.rs
1//! Synheart Sensor Agent - Privacy-first behavioral sensor for research.
2//!
3//! This library provides tools for capturing keyboard and mouse interaction
4//! timing for behavioral research, with strong privacy guarantees.
5//!
6//! # Privacy Guarantees
7//!
8//! - **No key content**: We never capture which keys are pressed, only timing
9//! - **No coordinates**: We never capture cursor position, only movement magnitude
10//! - **No raw storage**: Raw events are not stored beyond the current window
11//! - **Transparency**: All collection is logged and auditable
12//!
13//! # Architecture
14//!
15//! ```text
16//! ┌─────────────────────────────────────────────────────────────┐
17//! │ Synheart Sensor Agent │
18//! ├─────────────────────────────────────────────────────────────┤
19//! │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
20//! │ │ Collector │──▶│ Windowing │──▶│ Features │ │
21//! │ │ (macOS) │ │ (10s bins) │ │ (compute) │ │
22//! │ └─────────────┘ └─────────────┘ └─────────────┘ │
23//! │ │ │ │
24//! │ ▼ ▼ │
25//! │ ┌─────────────┐ ┌─────────────┐ │
26//! │ │Transparency │ │ HSI │ │
27//! │ │ Log │ │ Snapshot │ │
28//! │ └─────────────┘ └─────────────┘ │
29//! └─────────────────────────────────────────────────────────────┘
30//! ```
31//!
32//! # Example
33//!
34//! ```no_run
35//! use synheart_sensor_agent::{collector, core, transparency};
36//!
37//! // Create a collector (requires Input Monitoring permission)
38//! let config = collector::CollectorConfig::default();
39//! let mut collector = collector::Collector::new(config);
40//!
41//! // Start collection
42//! collector.start().expect("Failed to start collector");
43//!
44//! // Events can be received from collector.receiver()
45//! ```
46
47pub mod collector;
48pub mod config;
49pub mod core;
50pub mod transparency;
51
52#[cfg(feature = "flux")]
53pub mod flux;
54
55#[cfg(feature = "gateway")]
56pub mod gateway;
57
58#[cfg(feature = "server")]
59pub mod server;
60
61// Re-export key types at crate root for convenience
62pub use collector::{Collector, CollectorConfig, CollectorError, SensorEvent};
63pub use config::{Config, SourceConfig};
64pub use core::{compute_features, HsiBuilder, HsiSnapshot, WindowFeatures, WindowManager};
65pub use transparency::{SharedTransparencyLog, TransparencyLog, TransparencyStats};
66
67// Flux re-exports (when enabled)
68#[cfg(feature = "flux")]
69pub use flux::{EnrichedSnapshot, SensorFluxProcessor};
70
71// Gateway re-exports (when enabled)
72#[cfg(feature = "gateway")]
73pub use gateway::{
74 BlockingGatewayClient, GatewayClient, GatewayConfig, GatewayError, GatewayResponse,
75};
76
77// Server re-exports (when enabled)
78#[cfg(feature = "server")]
79pub use server::{run as run_server, ServerConfig};
80
81/// Library version.
82pub const VERSION: &str = env!("CARGO_PKG_VERSION");
83
84/// Privacy declaration that can be displayed to users.
85pub const PRIVACY_DECLARATION: &str = r#"
86╔══════════════════════════════════════════════════════════════════╗
87║ SYNHEART SENSOR AGENT - PRIVACY DECLARATION ║
88╠══════════════════════════════════════════════════════════════════╣
89║ ║
90║ This agent captures behavioral timing data for research. ║
91║ ║
92║ ✓ WHAT WE CAPTURE: ║
93║ • When keys are pressed (timing only) ║
94║ • How fast the mouse moves (speed only) ║
95║ • When clicks and scrolls occur (timing only) ║
96║ ║
97║ ✗ WHAT WE NEVER CAPTURE: ║
98║ • Which keys you press (no passwords, messages, etc.) ║
99║ • Where your cursor is (no screen position tracking) ║
100║ • What applications you use ║
101║ • Any screen content ║
102║ ║
103║ All data is processed locally. Raw events are discarded ║
104║ after feature extraction (every 10 seconds). ║
105║ ║
106║ You can view collection statistics anytime with: ║
107║ synheart-sensor status ║
108║ ║
109╚══════════════════════════════════════════════════════════════════╝
110"#;
111
112#[cfg(test)]
113mod tests {
114 use super::*;
115
116 #[test]
117 fn test_privacy_declaration_contents() {
118 assert!(PRIVACY_DECLARATION.contains("PRIVACY"));
119 assert!(PRIVACY_DECLARATION.contains("NEVER CAPTURE"));
120 assert!(PRIVACY_DECLARATION.contains("keys you press"));
121 }
122}