Function append_terminal_trial
pub fn append_terminal_trial(
storage: &dyn Storage,
study: StudyId,
trial: &FrozenTrial,
clock: &dyn Clock,
) -> Result<()>Expand description
Appends one finished trial as new history in study.
The trial’s source id, number, study, and timestamps are ignored: the
destination assigns a new trial id and number, and the claim heartbeat is
read from clock. Its parameters (each with its distribution),
canonical constraint vector, user attributes, intermediates, and terminal
outcome are written in that order through the owned lifecycle calls while
the study’s finalization ownership is held. Only
Complete, Pruned, and
Failed trials are terminal history.
Callers validate the trial against the study (objective arity, parameter compatibility, attribute keys) before calling; this function only refuses records it cannot write.
Finalization ownership is always released, including after a failure. A
failure after the claim but before the terminal commit leaves the new
trial Failed with an "add_trial aborted: …"
reason; a trial whose terminal commit already succeeded is never
overwritten.
§Errors
Error::Unsupportedwhenstoragehas no trial lifecycle capability.Error::Conflictwhen a parameter has no distribution, a complete trial has no values, the trial is not terminal, the constraint vector is longer thanu32::MAX, or the unbounded reservation reports exhaustion.Error::LostRacewhen the claim failed and its reservation was already gone.Error::Storagenaming both errors when the operation and its cleanup (abandon, failed terminal, or finalization release) both failed.- Any error from the backend’s lifecycle calls.