[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. The decoder finds it again by name
10
in the routine catalog, so a stored workout stays valid only as long as its
11
routine and workout names do. That is the intended coupling: prescriptions
12
are 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
| Unsupported_version of int
22
(** The record was written by a newer codec. It is refused rather than
23
misread, so a downgraded binary never corrupts what it does not
24
understand. *)
25
26
val pp_error : Format.formatter -> error -> unit
27
28
val current_version : int
29
(** The layout this codec writes. Every stored workout names its version on its
30
first line; a row without one predates the tag and carries this layout. *)
31
32
val encode_workout : routine_name:string -> Evidence.Workout.t -> string
33
(** A stable, single-string encoding of a performed or in-progress workout,
34
tagged with {!current_version}. [routine_name] identifies the catalog
35
routine the prescription came from. *)
36
37
val decode_workout :
38
find_routine:(string -> Prescription.Routine.t option) ->
39
string ->
40
(Evidence.Workout.t, error) result
41
(** Rebuilds a workout, resolving its prescription through [find_routine]. *)
42
43
val encode_feedback : Feedback.t -> string
44
(** A stable, single-string encoding of a subjective feedback report. *)
45
46
val decode_feedback : string -> (Feedback.t, error) result
47
(** Rebuilds a feedback report from its encoding. *)
48