[OCaml] High Intensity Training Online
1
(** Serialization of performed facts, and their replay through the core.
2
3
The core types are opaque and carry no serializers, by design: the logbook
4
records, it never interprets. This module is the trust boundary for stored
5
data. It captures only what was performed — exercise, load, reps, outcome,
6
timestamps, and the basis on which a workout was begun — and rebuilds a
7
{!Evidence.Workout.t} by driving the same constructors a live session does.
8
9
A workout's prescription is not stored. It is found again by name in the
10
routine catalog, so a stored workout stays valid only as long as its routine
11
and workout names do. That is the intended coupling: prescriptions are
12
authored, not recorded. *)
13
14
type error =
15
| Malformed of string (** The stored text does not parse. *)
16
| Unknown_exercise of string
17
| Unknown_routine of string
18
| Unknown_workout_name of { routine : string; workout : string }
19
| Replay_rejected of string
20
(** The core refused a stored stimulus; the store is inconsistent. *)
21
22
val pp_error : Format.formatter -> error -> unit
23
24
val encode_workout : routine_name:string -> Evidence.Workout.t -> string
25
(** A stable, single-string encoding of a performed or in-progress workout.
26
[routine_name] identifies the catalog routine the prescription came from. *)
27
28
val decode_workout :
29
find_routine:(string -> Prescription.Routine.t option) ->
30
string ->
31
(Evidence.Workout.t, error) result
32
(** Rebuilds a workout, resolving its prescription through [find_routine]. *)
33
34
val encode_feedback : Evidence.Feedback.t -> string
35
(** A stable, single-string encoding of a subjective feedback report. *)
36
37
val decode_feedback : string -> (Evidence.Feedback.t, error) result
38
(** Rebuilds a feedback report from its encoding. *)
39