2025 04 14.pause resume duration design - SergeiGolos/wod-wiki GitHub Wiki
Date: 2025-04-14
This document describes the canonical event flow and design for accurate duration reporting in the wod.wiki runtime, especially across multiple pause/resume cycles. It serves as a reference for developers and maintainers.
User Action | Event(s) Generated | Notes |
---|---|---|
Start workout | start |
Marks the beginning of a timing span |
Pause (stop) | stop |
Ends the current timing span; no explicit pause event |
Resume | start |
Begins a new timing span |
Complete round/set |
lap , done , complete
|
Used for workout structure and reporting |
End workout |
stop , complete
|
Finalizes all spans |
- The event list for a workout is an alternating sequence of
start
andstop
events, possibly interleaved withlap
,done
, orcomplete
. - Durations are calculated as the sum of all (
stop
- previousstart
) pairs, plus any active span if running.
sequenceDiagram
participant User
participant Runtime
User->>Runtime: Start workout
Runtime-->>Runtime: Add `start` event
User->>Runtime: Pause
Runtime-->>Runtime: Add `stop` event
User->>Runtime: Resume
Runtime-->>Runtime: Add `start` event
User->>Runtime: Pause again
Runtime-->>Runtime: Add `stop` event
User->>Runtime: Complete
Runtime-->>Runtime: Add `complete` event
- There is no explicit
pause
event; thestop
event acts as a pause marker. - Each resume is a new
start
event. - The event list must be well-formed (no consecutive
start
orstop
without a matching pair). - Filtering out
pause
events is a legacy step and can be ignored if onlystart
/stop
are used.
- Enforces canonical event sequence: always alternate
start
andstop
/terminal event. - Detects and flags malformed event sequences (e.g., consecutive
start
orstop
). - Optionally repairs event sequences for reporting, ignoring duplicates or incomplete pairs.
- Provides robust span aggregation for duration reporting, even with edge cases.
- Exposes utility methods for validation and canonical state extraction.
Event Sequence | Result/Handling |
---|---|
start, stop, start, stop | Two valid spans |
start, start, stop | First span closed by second start, then stop |
start, stop, stop | Second stop ignored (or flagged as anomaly) |
start, stop, start | One closed span, one open span |
stop, start | First stop ignored (or flagged as anomaly) |
-
getAnomalies()
: Returns a list of detected anomalies in the event sequence. - Aggregation logic now flags and/or repairs malformed sequences for more robust reporting.
- Updated to use EventSpanAggregator for span detection and duration calculation.
- Ensures robust and canonical reporting of all workout durations, including across multiple pauses/resumes.
- Reports anomalies detected in the event sequence (e.g., consecutive starts/stops) for debugging and analytics.
- Updated to use EventSpanAggregator for span detection and duration calculation.
- Ensures robust and canonical reporting of all work/rest spans, including across multiple pauses/resumes.
- Reports anomalies detected in the event sequence (e.g., consecutive starts/stops) for debugging and analytics.
- Update EventSpanAggregator and report logic to robustly handle all valid event sequences.
- Write comprehensive tests for edge cases (e.g., consecutive pauses, missing resumes).
- Update documentation and developer guides accordingly.