(** Serialization of performed facts, and their replay through the core. The core types are opaque and carry no serializers, by design. The logbook records. It never interprets. This module is the trust boundary for stored data. It captures only what was performed — exercise, load, reps, outcome, timestamps, and the basis on which a workout was begun — and rebuilds a {!Evidence.Workout.t} by driving the same constructors a live session does. A workout's prescription is not stored. The decoder finds it again by name in the routine catalog, so a stored workout stays valid only as long as its routine and workout names do. That is the intended coupling: prescriptions are authored, not recorded. *) type error = | Malformed of string (** The stored text does not parse. *) | Unknown_exercise of string | Unknown_routine of string | Unknown_workout_name of { routine : string; workout : string } | Replay_rejected of string (** The core refused a stored stimulus. The store is inconsistent. *) | Unsupported_version of int (** The record was written by a newer codec. It is refused rather than misread, so a downgraded binary never corrupts what it does not understand. *) val pp_error : Format.formatter -> error -> unit val current_version : int (** The layout this codec writes. Every stored workout names its version on its first line; a row without one predates the tag and carries this layout. *) val encode_workout : routine_name:string -> Evidence.Workout.t -> string (** A stable, single-string encoding of a performed or in-progress workout, tagged with {!current_version}. [routine_name] identifies the catalog routine the prescription came from. *) val decode_workout : find_routine:(string -> Prescription.Routine.t option) -> string -> (Evidence.Workout.t, error) result (** Rebuilds a workout, resolving its prescription through [find_routine]. *) val encode_feedback : Feedback.t -> string (** A stable, single-string encoding of a subjective feedback report. *) val decode_feedback : string -> (Feedback.t, error) result (** Rebuilds a feedback report from its encoding. *)