Data Integrity Rules

R1
No Data Fabrication

Tools SHALL NOT generate, invent, or hallucinate sensor readings, session data, or match results not present in the database.

R2
Timestamp Integrity

All timestamps are stored in UTC. Display conversions happen at presentation layer only.

R3
Sensor Source Attribution

Every data point must be traceable to its source sensor (AppleWatch, Zepp, Babolat, Garmin).

Query Processing Rules

R4
Deterministic Resolution

Identical queries MUST produce identical results. No randomness in query resolution or tool execution.

R5
Date Format Normalization

Dates are normalized to YYYY-MM-DD format. Relative dates ("yesterday", "last week") are resolved at parse time.

R6
Session ID Resolution

Session IDs support device prefix matching. "watch_20251113" resolves to full Apple Watch session ID.

R7
Default Date Range

Queries without explicit date range default to last 52 weeks unless tool specifies otherwise.

Tool Execution Rules

R8
Pure Functions

Query tools are stateless. No tool call affects the outcome of any subsequent tool call (except explicit data mutations).

R9
Parameter Validation

All tool parameters are validated before execution. Invalid session IDs, dates, or sensor types are rejected with error.

R10
Dependency Resolution

Step dependencies (e.g., $step_0_result.session_id) are resolved before tool execution using ExecutionContext.

R11
Caching Strategy

Session summaries and sensor data are cached per-execution to avoid redundant database queries.

Sensor-Specific Rules

R12
Apple Watch Threshold

Default swing detection threshold is 10 rad/s rotation rate. Configurable per-tool call.

R13
Linked Session Tolerance

Sessions are considered "linked" if start times are within 5 minutes (configurable via tolerance_minutes).

R14
Minimum Swing Count

Zepp sessions require minimum 10 swings to be considered valid for analysis (configurable via min_swings).

R15
Babolat Activity ID Format

Babolat activity IDs follow format "MAC_ADDRESS_NUMBER" (e.g., "9C:68:5B:00:35:65_657").

Visualization Rules

R16
Default Output Directory

Visualizations are saved to /tmp/tennis_viz by default unless output_dir is specified.

R17
Impact Zone Overlay

Zepp impact visualizations show 5-zone overlay by default (show_zones=True).

R18
Jitter for Anti-Overplotting

Scatter plots use jitter (default 0.03) to prevent point overlap on identical positions.

Error Handling Rules

R19
Graceful Degradation

Missing data returns structured error with context, not crashes. Query continues with available data.

R20
Explicit Not Found

When no results match, return explicit "not found" message with search criteria, not empty result.

R21
State Machine Recovery

On error during RUNNING state, transition to FAILED with error context preserved for debugging.

Policy Enforcement

These rules implement tau-bench principles for the tennis analytics domain. Every tool execution is validated against these policies.