Skip to main content

derive_repeat

Function derive_repeat 

Source
pub fn derive_repeat(
    clock: &impl Clock,
    task_id: TaskId,
    params: RepeatDerivationParams,
) -> Result<DerivationSuccess, DerivationError>
Expand description

Derives runs for a Repeat policy task.

Creates runs up to the count if they don’t exist, spaced by the interval. Returns a DerivationSuccess with newly created runs and the total policy count.

§Errors

Returns DerivationError::ArithmeticOverflow if the schedule time calculation schedule_origin + (index * interval_secs) would overflow u64::MAX for any index. This ensures strict exact-N accounting - derivation either produces exactly N runs or fails with a typed error.

Returns DerivationError::InvalidPolicy if count == 0 or interval_secs == 0, preserving defensive contract enforcement for callers that bypass the primary run-policy boundary.

schedule_origin is the stable base timestamp for repeat scheduling. Derived run times are always schedule_origin + index * interval_secs, independent of the current clock time, ensuring deterministic re-derivation.