moonbit-eta-predict

    Streaming ETA prediction primitives for MoonBit: Kalman smoothing, adaptive windows, route profiles, and evaluation helpers.

    eta
    kalman
    forecast
    traffic
    streaming
    Download zip
    Version
    0.2.2
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    40

    No dependencies

    #moonbit-eta-predict

    moonbit-eta-predict provides deterministic streaming ETA prediction primitives for MoonBit applications. It combines scalar Kalman smoothing, adaptive windows, route profiles, calendar-aware congestion, typed CSV/JSON Lines codecs, batch calibration, quality gates, and reproducible benchmark reports.

    #Quick start

    Use MoonBit v0.10.9 or newer.

    moon update moon check --deny-warn --target all moon test --deny-warn --target all moon run cmd/main -- demo

    ///|
    test "README forecast example" {
    let route = demo_route()
    let batch = forecast_batch(demo_observations(), route, congestion=0.3)
    assert_true(batch.results.length() > 0)
    assert_true(batch.summary.count == batch.results.length())
    }

    #Capabilities

    • Kalman smoothing and innovation gating.
    • Adaptive windows and confidence estimation.
    • Multi-segment route ETA and weekly congestion calendars.
    • CSV and JSON Lines observation codecs with schema validation.
    • Batch forecasting, rolling evaluation, calibration, and cross-validation.
    • Error metrics, quality gates, alerts, route selection, and explanations.
    • Deterministic CLI demos and benchmark cases.

    #CLI

    moon run cmd/main -- demo moon run cmd/main -- benchmark table moon run cmd/main -- calibrate moon run cmd/main -- validate

    #Testing and CI

    moon fmt --check moon check --deny-warn --target all moon test --deny-warn --target all moon info

    The repository CI repeats these checks on Ubuntu, macOS, and Windows and publishes coverage summaries.

    #License

    Apache-2.0. See LICENSE.

    AlertKind

    pub(all) enum AlertKind {
    LowConfidence
    EtaJump
    StalledProgress
    RouteComplete
    InvalidObservation
    } derive(Eq,
    Debug
    )

    Alert categories emitted by a streaming consumer.

    BatchForecast

    pub(all) struct BatchForecast {
    results : Array[EtaResult]
    points : Array[ForecastPoint]
    summary : ErrorSummary
    skipped : Int
    } derive(Eq,
    Debug
    )

    The result of forecasting a whole dataset.

    BenchmarkCase

    pub(all) struct BenchmarkCase {
    name : String
    points : Int
    summary : ErrorSummary
    mean_confidence : Double
    notes : String
    } derive(Eq,
    Debug
    )

    A benchmark scenario with deterministic input and output metrics.

    BenchmarkReport

    pub(all) struct BenchmarkReport {
    cases : Array[BenchmarkCase]
    aggregate : ErrorSummary
    total_points : Int
    rendered : String
    } derive(Eq,
    Debug
    )

    A complete benchmark report.

    CalendarBucket

    pub(all) struct CalendarBucket {
    start_second : Double
    end_second : Double
    congestion : Double
    label : String
    } derive(Eq,
    Debug
    )

    A time-of-day congestion bucket.

    CalendarBucket::contains

    fn CalendarBucket::contains(self : CalendarBucket, second_of_day : Double) -> Bool

    Select a bucket when its half-open range contains the requested second.

    CalendarBucket::midpoint

    fn CalendarBucket::midpoint(self : CalendarBucket) -> Double

    Return the bucket's midpoint in seconds.

    CalendarBucket::new

    fn CalendarBucket::new(start_second : Double, end_second : Double, congestion : Double, label? : String) -> CalendarBucket

    Construct a safe calendar bucket.

    CalibrationCandidate

    pub(all) struct CalibrationCandidate {
    congestion : Double
    error : ErrorSummary
    rank : Int
    } derive(Eq,
    Debug
    )

    A parameter candidate and its evaluation score.

    CalibrationConfig

    pub(all) struct CalibrationConfig {
    min_congestion : Double
    max_congestion : Double
    steps : Int
    } derive(Eq,
    Debug
    )

    CalibrationResult

    pub(all) struct CalibrationResult {
    best_congestion : Double
    best_error : ErrorSummary
    candidates : Array[ForecastPoint]
    } derive(Eq,
    Debug
    )

    ConfidenceInterval

    pub(all) struct ConfidenceInterval {
    estimate : Double
    lower : Double
    upper : Double
    level : Double
    } derive(Eq,
    Debug
    )

    A confidence interval over a scalar estimate.

    ContractReport

    pub(all) struct ContractReport {
    valid : Bool
    checks : Int
    failures : Array[String]
    } derive(Eq,
    Debug
    )

    Contract result for a complete forecast trace.

    CrossValidationFold

    pub(all) struct CrossValidationFold {
    fold : Int
    train_count : Int
    test_count : Int
    summary : ErrorSummary
    } derive(Eq,
    Debug
    )

    A cross-validation fold result.

    CrossValidationReport

    pub(all) struct CrossValidationReport {
    folds : Array[CrossValidationFold]
    aggregate : ErrorSummary
    best_congestion : Double
    } derive(Eq,
    Debug
    )

    Aggregate cross-validation report.

    DatasetRow

    pub(all) struct DatasetRow {
    observation : Observation
    actual_remaining : Double?
    weight : Double
    } derive(Eq,
    Debug
    )

    A parsed row with an optional target value.

    DatasetSchema

    pub(all) struct DatasetSchema {
    name : String
    required : Array[SchemaField]
    optional : Array[SchemaField]
    version : String
    } derive(Eq,
    Debug
    )

    A named schema with required and optional fields.

    DatasetSchema::accepts

    fn DatasetSchema::accepts(self : DatasetSchema, field : SchemaField) -> Bool

    Return whether a field is accepted by the schema.

    DatasetSchema::field_count

    fn DatasetSchema::field_count(self : DatasetSchema) -> Int

    Return the number of fields in a schema.

    DatasetSummary

    pub(all) struct DatasetSummary {
    rows : Int
    duration : Double
    distance : Double
    average_speed : Double
    missing_targets : Int
    average_weight : Double
    } derive(Eq,
    Debug
    )

    A dataset-level descriptive summary.

    DayCalendar

    pub(all) struct DayCalendar {
    weekday : Int
    buckets : Array[CalendarBucket]
    fallback_congestion : Double
    } derive(Eq,
    Debug
    )

    Congestion buckets for one weekday.

    DayCalendar::congestion_at

    fn DayCalendar::congestion_at(self : DayCalendar, second_of_day : Double) -> Double

    Select a day's congestion, falling back when no bucket matches.

    DayCalendar::label_at

    fn DayCalendar::label_at(self : DayCalendar, second_of_day : Double) -> String

    Return the selected bucket label, or default when no bucket matches.

    DayCalendar::valid_bucket_count

    fn DayCalendar::valid_bucket_count(self : DayCalendar) -> Int

    Count valid buckets in a day.

    DetailedBreakdown

    pub(all) struct DetailedBreakdown {
    forecasts : Array[SegmentForecast]
    total : RouteBreakdown
    weekday : Int
    second_of_day : Double
    } derive(Eq,
    Debug
    )

    Route forecast retaining both summary and per-segment decisions.

    ErrorSummary

    pub(all) struct ErrorSummary {
    count : Int
    mae : Double
    rmse : Double
    mape : Double
    max_error : Double
    } derive(Eq,
    Debug
    )

    EtaConfig

    pub(all) struct EtaConfig {
    min_speed : Double
    max_speed : Double
    history_weight : Double
    live_weight : Double
    reliability_floor : Double
    } derive(Eq,
    Debug
    )

    EtaEngine

    pub(all) struct EtaEngine {
    kalman : KalmanState
    window : WindowState
    route : RouteProfile
    config : EtaConfig
    last_observation : Observation?
    } derive(Eq,
    Debug
    )

    EtaEngine::new

    fn EtaEngine::new(route : RouteProfile, initial_speed~ : Double, config? : EtaConfig) -> EtaEngine

    EtaEngine::observe

    fn EtaEngine::observe(self : EtaEngine, observation : Observation, congestion? : Double) -> (EtaEngine, EtaResult)

    EtaExplanation

    pub(all) struct EtaExplanation {
    remaining_distance : Double
    raw_speed : Double
    smoothed_speed : Double
    historical_speed : Double
    live_weight : Double
    history_weight : Double
    confidence : Double
    factors : Array[String]
    } derive(Eq,
    Debug
    )

    An explanation of one ETA decision.

    EtaResult

    pub(all) struct EtaResult {
    eta_seconds : Double
    smoothed_speed : Double
    raw_speed : Double
    confidence : Double
    remaining_distance : Double
    } derive(Eq,
    Debug
    )

    EvaluationWindow

    pub(all) struct EvaluationWindow {
    start : Int
    end : Int
    summary : ErrorSummary
    } derive(Eq,
    Debug
    )

    One rolling evaluation window.

    ForecastAlert

    pub(all) struct ForecastAlert {
    kind : AlertKind
    update : Int
    severity : Double
    message : String
    } derive(Eq,
    Debug
    )

    A forecast alert with a stable severity score.

    ForecastPoint

    pub(all) struct ForecastPoint {
    predicted : Double
    actual : Double
    } derive(Eq,
    Debug
    )

    GridCalibration

    pub(all) struct GridCalibration {
    candidates : Array[CalibrationCandidate]
    best : CalibrationCandidate
    evaluated : Int
    } derive(Eq,
    Debug
    )

    Calibration report with deterministic candidate ordering.

    GuardResult

    pub(all) struct GuardResult {
    accepted : Bool
    observation : Observation
    reasons : Array[String]
    } derive(Eq,
    Debug
    )

    Sanitized observation and reasons for any adjustment.

    HealthReport

    pub(all) struct HealthReport {
    ready : Bool
    route_valid : Bool
    config_valid : Bool
    calendar_valid : Bool
    messages : Array[String]
    } derive(Eq,
    Debug
    )

    Package health checks suitable for an embedding application.

    InputGuardConfig

    pub(all) struct InputGuardConfig {
    maximum_distance : Double
    maximum_timestamp : Double
    reject_backwards_time : Bool
    reject_backwards_distance : Bool
    } derive(Eq,
    Debug
    )

    Bounds applied before an observation enters a live engine.

    KalmanConfig

    pub(all) struct KalmanConfig {
    process_noise : Double
    measurement_noise : Double
    initial_error : Double
    min_variance : Double
    gate_sigma : Double
    } derive(Eq,
    Debug
    )

    KalmanState

    pub(all) struct KalmanState {
    estimate : Double
    covariance : Double
    process_noise : Double
    measurement_noise : Double
    min_variance : Double
    gate_sigma : Double
    } derive(Eq,
    Debug
    )

    KalmanState::innovation

    fn KalmanState::innovation(self : KalmanState, measurement : Double) -> Double

    KalmanState::is_outlier

    fn KalmanState::is_outlier(self : KalmanState, measurement : Double) -> Bool

    KalmanState::new

    fn KalmanState::new(initial : Double, config : KalmanConfig) -> KalmanState

    KalmanState::predict

    fn KalmanState::predict(self : KalmanState, delta_seconds? : Double) -> KalmanState

    KalmanState::update

    fn KalmanState::update(self : KalmanState, measurement : Double) -> KalmanState

    MetricBin

    pub(all) struct MetricBin {
    lower : Double
    upper : Double
    count : Int
    mean_error : Double
    mean_confidence : Double
    } derive(Eq,
    Debug
    )

    A fixed-width bin for calibration and reliability reports.

    MetricReport

    pub(all) struct MetricReport {
    summary : ErrorSummary
    bias : Double
    smape : Double
    median_absolute_error : Double
    coverage : Double
    bins : Array[MetricBin]
    } derive(Eq,
    Debug
    )

    A collection of complementary forecast metrics.

    Observation

    pub(all) struct Observation {
    timestamp : Double
    distance : Double
    elapsed : Double
    } derive(Eq,
    Debug
    )

    ObservationBatch

    pub(all) struct ObservationBatch {
    observations : Array[Observation]
    source : String
    dropped : Int
    } derive(Eq,
    Debug
    )

    A validated, ordered collection of observations.

    ObservationDataset

    pub(all) struct ObservationDataset {
    rows : Array[DatasetRow]
    name : String
    } derive(Eq,
    Debug
    )

    A dataset used by batch evaluation and calibration.

    ObservationDataset::between

    fn ObservationDataset::between(self : ObservationDataset, start~ : Double, end~ : Double) -> ObservationDataset

    Return rows that fall inside a timestamp interval.

    ObservationDataset::labeled

    Return only rows with an actual target.

    ObservationDataset::normalize

    Sort dataset rows by timestamp and remove duplicate timestamps.

    ObservationDataset::observations

    Return observations in dataset order.

    ObservationDataset::targets

    fn ObservationDataset::targets(self : ObservationDataset) -> Array[Double]

    Return targets while preserving missing labels as zero.

    ObservationDataset::weighted

    Return a dataset with all weights clamped to non-negative values.

    ObservationParseResult

    pub(all) struct ObservationParseResult {
    observations : Array[Observation]
    error : ParseError?
    lines_read : Int
    } derive(Eq,
    Debug
    )

    Result returned by observation codecs.

    ObservationParseResult::is_error

    fn ObservationParseResult::is_error(self : ObservationParseResult) -> Bool

    Return whether parsing succeeded.

    ObservationParseResult::or_empty

    Return the parsed observations, or an empty array after an error.

    ParseError

    pub(all) enum ParseError {
    EmptyInput
    MissingHeader
    MissingField(line~ : Int, field~ : String)
    ExtraField(line~ : Int)
    InvalidNumber(line~ : Int, field~ : String, value~ : String)
    InvalidSyntax(line~ : Int, message~ : String)
    UnsupportedSchema(String)
    } derive(Eq,
    Debug
    )

    Parse failure details for CSV and JSON-line input.

    ParseOutcome

    pub(all) enum ParseOutcome[T] {
    Parsed(T)
    ParseFailed(ParseError)
    } derive(Eq,
    Debug
    )

    Explicit codec outcome; parsers do not panic on bad external input.

    QualityGateConfig

    pub(all) struct QualityGateConfig {
    max_mae : Double
    max_rmse : Double
    min_confidence : Double
    min_points : Int
    require_monotonic_distance : Bool
    } derive(Eq,
    Debug
    )

    Quality thresholds used by CI and consumers.

    QualityGateResult

    pub(all) struct QualityGateResult {
    passed : Bool
    reasons : Array[String]
    checked_points : Int
    summary : ErrorSummary
    } derive(Eq,
    Debug
    )

    Quality gate outcome with actionable reasons.

    RollingEvaluation

    pub(all) struct RollingEvaluation {
    windows : Array[EvaluationWindow]
    overall : ErrorSummary
    } derive(Eq,
    Debug
    )

    Rolling error analysis over a forecast trace.

    RouteBreakdown

    pub(all) struct RouteBreakdown {
    segments : Array[SegmentEta]
    total_distance : Double
    total_eta_seconds : Double
    confidence : Double
    } derive(Eq,
    Debug
    )

    A route-level ETA breakdown.

    RouteCalendar

    pub(all) struct RouteCalendar {
    days : Array[DayCalendar]
    default_congestion : Double
    } derive(Eq,
    Debug
    )

    A weekly route calendar.

    RouteCalendar::congestion_at

    fn RouteCalendar::congestion_at(self : RouteCalendar, weekday : Int, second_of_day : Double) -> Double

    Find a day by weekday and evaluate its buckets.

    RouteCandidate

    pub(all) struct RouteCandidate {
    route_id : String
    route : RouteProfile
    breakdown : RouteBreakdown
    score : Double
    risk : Double
    } derive(Eq,
    Debug
    )

    Route candidate for ETA-aware route selection.

    RouteProfile

    pub(all) struct RouteProfile {
    segments : Array[SegmentProfile]
    } derive(Eq,
    Debug
    )

    RouteProfile::average_reliability

    fn RouteProfile::average_reliability(self : RouteProfile) -> Double

    RouteProfile::historical_eta

    fn RouteProfile::historical_eta(self : RouteProfile, congestion~ : Double) -> Double

    RouteProfile::total_distance

    fn RouteProfile::total_distance(self : RouteProfile) -> Double

    RouteSelection

    pub(all) struct RouteSelection {
    selected : RouteCandidate?
    alternatives : Array[RouteCandidate]
    reason : String
    } derive(Eq,
    Debug
    )

    Selected route and discarded alternatives.

    RouteStreamState

    pub(all) struct RouteStreamState {
    route : RouteProfile
    engine : EtaEngine
    calendar : RouteCalendar
    weekday : Int
    second_of_day : Double
    updates : Int
    } derive(Eq,
    Debug
    )

    A route state retained between streaming updates.

    RouteStreamState::new

    fn RouteStreamState::new(route : RouteProfile, initial_speed~ : Double, calendar? : RouteCalendar, weekday? : Int, second_of_day? : Double) -> RouteStreamState

    Initialize a route stream with a calendar-aware ETA engine.

    RouteStreamState::observe

    Apply one observation and retain the next stream state.

    Sampler

    pub(all) struct Sampler {
    state : UInt64
    } derive(Eq,
    Debug
    )

    A deterministic linear-congruential state for reproducible fixtures.

    Sampler::new

    fn Sampler::new(seed : UInt64) -> Sampler

    Create a sampler, replacing a zero seed with a stable non-zero seed.

    Sampler::next

    fn Sampler::next(self : Sampler) -> (Sampler, UInt64)

    Return the next pseudo-random 64-bit value.

    Sampler::noise

    fn Sampler::noise(self : Sampler, magnitude~ : Double) -> (Sampler, Double)

    Return a deterministic signed perturbation.

    Sampler::unit

    fn Sampler::unit(self : Sampler) -> (Sampler, Double)

    Return a deterministic unit interval sample.

    ScenarioConfig

    pub(all) struct ScenarioConfig {
    steps : Int
    interval_seconds : Double
    base_speed : Double
    congestion : Double
    noise_stride : Int
    noise_magnitude : Double
    } derive(Eq,
    Debug
    )

    ScenarioTrace

    pub(all) struct ScenarioTrace {
    observations : Array[Observation]
    actual_remaining : Array[Double]
    } derive(Eq,
    Debug
    )

    SchemaField

    pub(all) enum SchemaField {
    Timestamp
    Distance
    Elapsed
    ActualRemaining
    Weight
    } derive(Eq,
    Debug
    )

    Canonical fields accepted by the observation interchange layer.

    SchemaReport

    pub(all) struct SchemaReport {
    valid : Bool
    missing : Array[SchemaField]
    unknown : Array[String]
    message : String
    } derive(Eq,
    Debug
    )

    A schema validation result.

    SegmentEta

    pub(all) struct SegmentEta {
    segment_id : String
    distance : Double
    speed : Double
    eta_seconds : Double
    confidence : Double
    } derive(Eq,
    Debug
    )

    ETA contributed by one route segment.

    SegmentForecast

    pub(all) struct SegmentForecast {
    index : Int
    segment : SegmentProfile
    eta : SegmentEta
    regime : TrafficRegime
    congestion : Double
    } derive(Eq,
    Debug
    )

    One entry in a route breakdown with contextual metadata.

    SegmentProfile

    pub(all) struct SegmentProfile {
    segment_id : String
    distance : Double
    free_flow_speed : Double
    typical_speed : Double
    rush_hour_speed : Double
    reliability : Double
    } derive(Eq,
    Debug
    )

    SegmentProfile::expected_seconds

    fn SegmentProfile::expected_seconds(self : SegmentProfile, congestion~ : Double) -> Double

    SegmentProfile::expected_speed

    fn SegmentProfile::expected_speed(self : SegmentProfile, congestion~ : Double) -> Double

    SegmentProfile::speed_for_regime

    fn SegmentProfile::speed_for_regime(self : SegmentProfile, regime : TrafficRegime) -> Double

    Return the profile speed associated with a regime.

    SensitivityPoint

    pub(all) struct SensitivityPoint {
    input : Double
    eta_seconds : Double
    speed : Double
    confidence : Double
    delta_from_baseline : Double
    } derive(Eq,
    Debug
    )

    One point in a deterministic sensitivity curve.

    SensitivityReport

    pub(all) struct SensitivityReport {
    parameter : String
    baseline : SensitivityPoint
    points : Array[SensitivityPoint]
    monotonic : Bool
    elasticity : Double
    } derive(Eq,
    Debug
    )

    Sensitivity report for one route and parameter.

    SpeedPolicy

    pub(all) struct SpeedPolicy {
    free_flow_weight : Double
    typical_weight : Double
    rush_hour_weight : Double
    live_weight : Double
    minimum_speed : Double
    maximum_speed : Double
    } derive(Eq,
    Debug
    )

    Weights used to combine historical and live speed evidence.

    StreamSnapshot

    pub(all) struct StreamSnapshot {
    update : Int
    observation : Observation
    result : EtaResult
    label : String
    } derive(Eq,
    Debug
    )

    An immutable update record for an online route stream.

    StreamSummary

    pub(all) struct StreamSummary {
    snapshots : Array[StreamSnapshot]
    latest : EtaResult
    average_confidence : Double
    dropped : Int
    } derive(Eq,
    Debug
    )

    Online stream summary used by dashboards and loggers.

    TimeSeriesSummary

    pub(all) struct TimeSeriesSummary {
    count : Int
    first : Double
    last : Double
    minimum : Double
    maximum : Double
    mean : Double
    trend : Double
    volatility : Double
    } derive(Eq,
    Debug
    )

    Descriptive time-series statistics.

    TrafficRegime

    pub(all) enum TrafficRegime {
    FreeFlow
    Typical
    RushHour
    Live
    } derive(Eq,
    Debug
    )

    Traffic regime selected by a calendar or a caller.

    ValidationCode

    pub(all) enum ValidationCode {
    EmptyInput
    NonFiniteValue
    NegativeTimestamp
    NegativeDistance
    NonMonotonicTime
    NonMonotonicDistance
    InvalidConfiguration
    InvalidRange
    } derive(Eq,
    Debug
    )

    Validation categories returned by input and configuration checks.

    ValidationIssue

    pub(all) struct ValidationIssue {
    code : ValidationCode
    index : Int
    message : String
    } derive(Eq,
    Debug
    )

    A stable, machine-readable validation finding.

    ValidationReport

    pub(all) struct ValidationReport {
    valid : Bool
    checked : Int
    issues : Array[ValidationIssue]
    } derive(Eq,
    Debug
    )

    The result of validating a public input collection.

    VelocitySample

    pub(all) struct VelocitySample {
    timestamp : Double
    speed : Double
    confidence : Double
    } derive(Eq,
    Debug
    )

    WindowConfig

    pub(all) struct WindowConfig {
    min_size : Int
    max_size : Int
    low_variance : Double
    high_variance : Double
    expansion_step : Int
    shrink_step : Int
    } derive(Eq,
    Debug
    )

    WindowState

    pub(all) struct WindowState {
    values : Array[Double]
    target_size : Int
    config : WindowConfig
    } derive(Eq,
    Debug
    )

    WindowState::average

    fn WindowState::average(self : WindowState) -> Double

    WindowState::new

    fn WindowState::new(config : WindowConfig) -> WindowState

    WindowState::push

    fn WindowState::push(self : WindowState, value : Double) -> WindowState

    WindowState::stability

    fn WindowState::stability(self : WindowState) -> Double

    abs_double

    fn abs_double(value : Double) -> Double

    alert_counts

    fn alert_counts(alerts : Array[ForecastAlert]) -> Array[Int]

    Return alert counts by kind in a fixed order.

    all_schema_field_names

    fn all_schema_field_names() -> Array[String]

    Return all supported field names in canonical order.

    allocate_live_speed

    fn allocate_live_speed(route : RouteProfile, live_speed : Double, segment : SegmentProfile) -> Double

    Convert a live route speed into segment-local speed with a floor.

    append_dataset

    fn append_dataset(left : ObservationDataset, right : ObservationDataset) -> ObservationDataset

    Append two datasets in stable left-to-right order.

    apply_confidence_floor

    fn apply_confidence_floor(batch : BatchForecast, floor~ : Double) -> BatchForecast

    Apply a conservative confidence floor to a result batch.

    average_window_mae

    fn average_window_mae(evaluation : RollingEvaluation) -> Double

    Return average MAE across all non-empty rolling windows.

    baseline_delta

    fn baseline_delta(result : EtaResult, route : RouteProfile, congestion~ : Double) -> Double

    Explain how a result differs from a historical-only baseline.

    batch_confidences

    fn batch_confidences(batch : BatchForecast) -> Array[Double]

    Return confidence values from a batch result.

    batch_eta_values

    fn batch_eta_values(batch : BatchForecast) -> Array[Double]

    Return ETA values from a batch result.

    benchmark_annotation

    fn benchmark_annotation(report : BenchmarkReport) -> String

    Return a benchmark summary suitable for a single-line CI annotation.

    benchmark_case_line

    fn benchmark_case_line(case : BenchmarkCase) -> String

    Return a JSON-like line for one benchmark case without external dependencies.

    benchmark_case_names

    fn benchmark_case_names(report : BenchmarkReport) -> Array[String]

    Return all case names in report order.

    benchmark_cases

    fn benchmark_cases() -> Array[BenchmarkCase]

    Build the deterministic benchmark matrix used in CI and README output.

    benchmark_evidence

    fn benchmark_evidence(report : BenchmarkReport, command : String) -> String

    Join benchmark metadata into one reproducible evidence block.

    benchmark_interpretation

    fn benchmark_interpretation(report : BenchmarkReport) -> String

    Return a plain-language benchmark interpretation.

    benchmark_lines

    fn benchmark_lines(report : BenchmarkReport) -> Array[String]

    Return benchmark rows for a log collector.

    benchmark_mae_spread

    fn benchmark_mae_spread(report : BenchmarkReport) -> Double

    Calculate the relative MAE spread between best and worst cases.

    benchmark_passes

    fn benchmark_passes(report : BenchmarkReport, max_mae~ : Double) -> Bool

    Check whether all cases meet a deterministic quality threshold.

    benchmark_route

    fn benchmark_route(route : RouteProfile, scenarios : Array[(String, ScenarioConfig)]) -> BenchmarkReport

    Create a benchmark report from an arbitrary route and scenario matrix.

    best_benchmark_case

    fn best_benchmark_case(report : BenchmarkReport) -> BenchmarkCase?

    Return the benchmark case with the lowest MAE.

    bottleneck_segment

    fn bottleneck_segment(segments : Array[SegmentEta]) -> SegmentEta?

    Return the slowest segment by ETA, if the route is non-empty.

    breakdown_is_consistent

    fn breakdown_is_consistent(breakdown : RouteBreakdown) -> Bool

    Return whether a breakdown's totals match its segment contributions.

    build_observation_batch

    fn build_observation_batch(observations : Array[Observation], source? : String) -> ObservationBatch

    Build a normalized batch and count rows discarded by basic validity checks.

    calendar_label

    fn calendar_label(calendar : RouteCalendar, weekday : Int, second_of_day : Double) -> String

    Return a human-readable label for the current calendar bucket.

    calibrate_congestion

    fn calibrate_congestion(route : RouteProfile, observations : Array[Observation], actuals : Array[Double], config? : CalibrationConfig) -> CalibrationResult

    calibrate_demo

    fn calibrate_demo() -> CalibrationResult

    calibration_error_curve

    fn calibration_error_curve(calibration : GridCalibration) -> Array[ForecastPoint]

    Return the error curve as forecast points for charting.

    calibration_gap

    fn calibration_gap(report : MetricReport) -> Double

    Return the mean calibration gap across non-empty bins.

    calibration_improvement

    fn calibration_improvement(route : RouteProfile, dataset : ObservationDataset, baseline~ : Double, calibration : GridCalibration) -> Double

    Compare candidate calibration against a baseline congestion value.

    candidates_by_congestion

    fn candidates_by_congestion(calibration : GridCalibration) -> Array[CalibrationCandidate]

    Return calibration candidates in congestion order.

    capabilities

    fn capabilities() -> Array[String]

    Return stable package capabilities for a host application.

    capabilities_are_named

    fn capabilities_are_named() -> Bool

    Return whether all advertised capabilities are non-empty.

    change_points

    fn change_points(values : Array[Double], threshold? : Double) -> Array[Int]

    Return indexes where the first difference exceeds a robust threshold.

    check_eta_result

    fn check_eta_result(result : EtaResult) -> Bool

    Check that an ETA result respects its public numeric contract.

    check_eta_results

    fn check_eta_results(results : Array[EtaResult]) -> ContractReport

    Check a whole forecast output for finite and bounded values.

    check_remaining_distance

    fn check_remaining_distance(results : Array[EtaResult]) -> Bool

    Check that remaining distance never increases over a result trace.

    clamp

    fn clamp(value : Double, low : Double, high : Double) -> Double

    clamp_observation_distance

    fn clamp_observation_distance(observation : Observation, maximum_distance : Double) -> Observation

    Clamp a valid observation to a route distance ceiling.

    cli_help

    fn cli_help() -> String

    Render the command list.

    compare_double

    fn compare_double(left : Double, right : Double) -> Int

    Compare doubles without relying on a total-order implementation.

    completion_index

    fn completion_index(route : RouteProfile, observations : Array[Observation]) -> Int?

    Return the first index at which route completion is reached.

    completion_scenario

    fn completion_scenario() -> ScenarioConfig

    Return a scenario that reaches the route end quickly.

    confidence_interval

    fn confidence_interval(values : Array[Double], level? : Double) -> ConfidenceInterval

    Symmetric confidence interval based on a normal approximation.

    congested_scenario

    fn congested_scenario() -> ScenarioConfig

    Construct a severe congestion benchmark scenario.

    congestion_grid

    fn congestion_grid(minimum~ : Double, maximum~ : Double, steps~ : Int) -> Array[Double]

    Build evenly spaced congestion candidates, including both endpoints.

    congestion_sensitivity

    fn congestion_sensitivity(route : RouteProfile, speed? : Double, steps? : Int) -> SensitivityReport

    Evaluate ETA sensitivity to congestion.

    cross_validate_congestion

    fn cross_validate_congestion(route : RouteProfile, dataset : ObservationDataset, fold_count? : Int) -> CrossValidationReport

    Run deterministic k-fold cross-validation for congestion calibration.

    cross_validation_is_complete

    fn cross_validation_is_complete(report : CrossValidationReport) -> Bool

    Return whether all folds contain both training and test data.

    cross_validation_mean_mae

    fn cross_validation_mean_mae(report : CrossValidationReport) -> Double

    Return average fold MAE.

    cumulative_segment_eta

    fn cumulative_segment_eta(segments : Array[SegmentEta]) -> Array[Double]

    Return segment ETAs as a cumulative timeline.

    cumulative_sum

    fn cumulative_sum(values : Array[Double], initial? : Double) -> Array[Double]

    Cumulative sum with an explicit starting value.

    dataset_distance

    fn dataset_distance(dataset : ObservationDataset) -> Double

    Return the distance covered by the dataset.

    dataset_duration

    fn dataset_duration(dataset : ObservationDataset) -> Double

    Return the duration in seconds, clamped to a non-negative result.

    dataset_from_observations

    fn dataset_from_observations(observations : Array[Observation], name? : String) -> ObservationDataset

    Create a dataset from observations with no target labels.

    dataset_from_targets

    fn dataset_from_targets(observations : Array[Observation], actuals : Array[Double], name? : String) -> ObservationDataset

    Create a labeled dataset from aligned observations and targets.

    dataset_is_guarded

    fn dataset_is_guarded(dataset : ObservationDataset, config : InputGuardConfig) -> Bool

    Return whether all rows in a dataset can enter the engine.

    dataset_weights

    fn dataset_weights(dataset : ObservationDataset) -> Array[Double]

    Return row weights as an array.

    default_calibration_config

    fn default_calibration_config() -> CalibrationConfig

    default_eta_config

    fn default_eta_config() -> EtaConfig

    default_input_guard

    fn default_input_guard(route : RouteProfile) -> InputGuardConfig

    Conservative input guard defaults for embedded applications.

    default_kalman_config

    fn default_kalman_config() -> KalmanConfig

    default_quality_gate

    fn default_quality_gate() -> QualityGateConfig

    Default quality thresholds for the deterministic package fixtures.

    default_scenario_config

    fn default_scenario_config() -> ScenarioConfig

    default_speed_policy

    fn default_speed_policy() -> SpeedPolicy

    Default speed policy for combining route profile evidence.

    default_window_config

    fn default_window_config() -> WindowConfig

    delayed_scenario

    fn delayed_scenario() -> ScenarioConfig

    Construct a slow-route benchmark scenario.

    demo_calendar

    fn demo_calendar() -> RouteCalendar

    Build the reference weekly calendar used by examples and benchmarks.

    demo_calibration_dataset

    fn demo_calibration_dataset() -> ObservationDataset

    Create a calibration dataset from the deterministic demo trace.

    demo_health

    fn demo_health() -> HealthReport

    Return a health summary for the reference route.

    demo_observations

    fn demo_observations() -> Array[Observation]

    demo_report

    fn demo_report() -> String

    demo_route

    fn demo_route() -> RouteProfile

    detailed_breakdown_is_consistent

    fn detailed_breakdown_is_consistent(detailed : DetailedBreakdown) -> Bool

    Check a detailed breakdown including segment IDs and ordering.

    detect_alerts

    fn detect_alerts(summary : StreamSummary, confidence_threshold? : Double, eta_jump_threshold? : Double) -> Array[ForecastAlert]

    Detect operational alerts in a stream summary.

    dominant_eta_factor

    fn dominant_eta_factor(explanation : EtaExplanation) -> String?

    Return the dominant explanation factor, if any.

    encode_csv_observations

    fn encode_csv_observations(observations : Array[Observation]) -> String

    Encode observations as a portable CSV document.

    encode_dataset_json_lines

    fn encode_dataset_json_lines(dataset : ObservationDataset) -> String

    Encode a dataset with an optional target field.

    encode_json_lines

    fn encode_json_lines(observations : Array[Observation]) -> String

    Encode observations as one JSON object per line.

    eta_results_to_points

    fn eta_results_to_points(results : Array[EtaResult], actuals : Array[Double]) -> Array[ForecastPoint]

    eta_trend

    fn eta_trend(batch : BatchForecast) -> (Double, Double, Double)

    Return the first and last ETA values as a compact trend summary.

    evaluate_batch_quality

    fn evaluate_batch_quality(observations : Array[Observation], batch : BatchForecast, config : QualityGateConfig) -> QualityGateResult

    Evaluate a batch with input progression and metric checks.

    evaluate_quality_gate

    fn evaluate_quality_gate(results : Array[EtaResult], points : Array[ForecastPoint], config : QualityGateConfig) -> QualityGateResult

    Evaluate forecast metrics and confidence thresholds.

    explain_batch

    fn explain_batch(batch : BatchForecast, route : RouteProfile, congestion~ : Double) -> Array[EtaExplanation]

    Explain every result in a batch.

    explain_eta

    fn explain_eta(result : EtaResult, route : RouteProfile, congestion~ : Double, config? : EtaConfig) -> EtaExplanation

    Explain the factors used to produce an ETA result.

    exponential_mean

    fn exponential_mean(values : Array[Double], alpha? : Double) -> Double

    Exponentially weighted moving average.

    extrapolate_series

    fn extrapolate_series(values : Array[Double], horizon : Int) -> Array[Double]

    Forecast a constant-slope horizon from a series.

    feature_names

    fn feature_names() -> Array[String]

    Public feature names used in release notes and package discovery.

    first_differences

    fn first_differences(values : Array[Double]) -> Array[Double]

    Return first differences of a numeric series.

    forecast_batch

    fn forecast_batch(observations : Array[Observation], route : RouteProfile, congestion~ : Double) -> BatchForecast

    Forecast an observation array and score it against the route's historical baseline.

    forecast_bias

    fn forecast_bias(points : Array[ForecastPoint]) -> Double

    Mean signed forecast error; positive values indicate over-prediction.

    forecast_breakdown

    fn forecast_breakdown(route : RouteProfile, speed~ : Double, congestion~ : Double, policy? : SpeedPolicy) -> RouteBreakdown

    Forecast each route segment from a single live speed and congestion value.

    forecast_breakdown_at

    fn forecast_breakdown_at(route : RouteProfile, speed~ : Double, calendar : RouteCalendar, weekday~ : Int, second_of_day~ : Double, policy? : SpeedPolicy) -> DetailedBreakdown

    Forecast a route using a weekly calendar context.

    forecast_contract

    fn forecast_contract(observations : Array[Observation], results : Array[EtaResult]) -> ContractReport

    Run the standard route forecast contract checks.

    forecast_dataset

    fn forecast_dataset(dataset : ObservationDataset, route : RouteProfile, congestion~ : Double) -> BatchForecast

    Forecast only the rows with valid observations and retain skipped count.

    forecast_many

    fn forecast_many(observations : Array[Observation], routes : Array[RouteProfile], congestion~ : Double) -> Array[BatchForecast]

    Forecast multiple routes with one shared observation trace.

    forecast_route

    fn forecast_route(observations : Array[Observation], route : RouteProfile) -> Array[EtaResult]

    format_alert

    fn format_alert(alert : ForecastAlert) -> String

    Render alerts for a log line.

    format_alerts

    fn format_alerts(alerts : Array[ForecastAlert]) -> String

    Render every alert on its own line.

    format_batch_forecast

    fn format_batch_forecast(batch : BatchForecast) -> String

    Format a batch forecast's headline and trend.

    format_benchmark_case

    fn format_benchmark_case(case : BenchmarkCase) -> String

    Render one benchmark case as a stable text row.

    format_breakdown

    fn format_breakdown(breakdown : RouteBreakdown) -> String

    Format a route breakdown for CLI output.

    format_calibration

    fn format_calibration(result : CalibrationResult) -> String

    format_contract

    fn format_contract(report : ContractReport) -> String

    Render contract failures for an embedding log.

    format_cross_validation

    fn format_cross_validation(report : CrossValidationReport) -> String

    Render cross-validation output for CI logs.

    format_detailed_breakdown

    fn format_detailed_breakdown(detailed : DetailedBreakdown) -> String

    Format a detailed calendar-aware route forecast.

    format_error_summary

    fn format_error_summary(summary : ErrorSummary) -> String

    format_eta_explanation

    fn format_eta_explanation(explanation : EtaExplanation) -> String

    Return a concise explanation suitable for a tooltip.

    format_eta_result

    fn format_eta_result(result : EtaResult) -> String

    format_evaluation_window

    fn format_evaluation_window(window : EvaluationWindow) -> String

    Format an evaluation window in one line.

    format_grid_calibration

    fn format_grid_calibration(calibration : GridCalibration) -> String

    Format calibration candidates in ascending rank order.

    format_health

    fn format_health(report : HealthReport) -> String

    Render health status for CLI output.

    format_parse_error

    fn format_parse_error(error : ParseError) -> String

    Render a parse error for CLI and logs.

    format_parse_result

    fn format_parse_result(result : ObservationParseResult) -> String

    Format a parse result for an import command.

    format_quality_gate

    fn format_quality_gate(result : QualityGateResult) -> String

    Render a gate result for CI output.

    format_rolling_evaluation

    fn format_rolling_evaluation(evaluation : RollingEvaluation) -> String

    Render a compact rolling evaluation table.

    format_schema

    fn format_schema(schema : DatasetSchema) -> String

    Render a stable schema description.

    format_sensitivity

    fn format_sensitivity(report : SensitivityReport) -> String

    Render a sensitivity curve for chart ingestion.

    format_validation

    fn format_validation(report : ValidationReport) -> String

    Render validation findings.

    generate_scenario

    fn generate_scenario(route : RouteProfile, config : ScenarioConfig) -> ScenarioTrace

    grid_calibrate

    fn grid_calibrate(route : RouteProfile, dataset : ObservationDataset, minimum? : Double, maximum? : Double, steps? : Int) -> GridCalibration

    Evaluate a congestion grid over a labeled dataset.

    grid_calibrate_demo

    fn grid_calibrate_demo() -> GridCalibration

    Calibrate the deterministic demo route using the reusable grid API.

    guard_observation

    fn guard_observation(previous : Observation?, observation : Observation, config : InputGuardConfig) -> GuardResult

    Guard one observation against finite, range, and monotonicity constraints.

    guard_trace

    fn guard_trace(observations : Array[Observation], config : InputGuardConfig) -> (Array[Observation], Array[String])

    Filter a trace through an input guard while retaining reason counts.

    has_duplicate_fields

    fn has_duplicate_fields(fields : Array[String]) -> Bool

    Check whether a field list has duplicates.

    has_hard_alert

    fn has_hard_alert(alerts : Array[ForecastAlert]) -> Bool

    Return whether alerts contain a hard operational fault.

    health_check

    fn health_check(route : RouteProfile, config? : EtaConfig, calendar? : RouteCalendar) -> HealthReport

    Validate all runtime inputs required by the ETA facade.

    highest_alert

    fn highest_alert(alerts : Array[ForecastAlert]) -> ForecastAlert?

    Return the highest-severity alert.

    historical_deviation

    fn historical_deviation(segment : SegmentProfile, live_speed : Double) -> Double

    Measure how far live speed is from a segment's historical envelope.

    holdout_evaluate

    fn holdout_evaluate(route : RouteProfile, dataset : ObservationDataset, holdout_ratio? : Double) -> (GridCalibration, ErrorSummary)

    Evaluate a calibration report on a fixed holdout suffix.

    holt_level

    fn holt_level(values : Array[Double], alpha? : Double, beta? : Double) -> Array[Double]

    Exponential smoothing with a supplied initial level.

    integrate_series

    fn integrate_series(values : Array[Double], interval? : Double) -> Double

    Trapezoidal integration over equally spaced samples.

    interface_filename

    fn interface_filename() -> String

    Return the expected generated interface filename for the root package.

    interpolate_congestion

    fn interpolate_congestion(start : Double, end : Double, progress : Double) -> Double

    Interpolate between two congestion values over a time interval.

    interpolate_series

    fn interpolate_series(values : Array[Double], position : Double) -> Double

    Linear interpolation at a bounded index coordinate.

    is_finite_value

    fn is_finite_value(value : Double) -> Bool

    Report whether a floating-point value is a usable finite input.

    labeled_schema

    fn labeled_schema() -> DatasetSchema

    The schema used for labeled evaluation datasets.

    latest_stream_label

    fn latest_stream_label(summary : StreamSummary) -> String

    Return the latest label, or none for an empty stream.

    low_confidence_updates

    fn low_confidence_updates(summary : StreamSummary, threshold~ : Double) -> Int

    Return the number of updates with confidence below a threshold.

    mad

    fn mad(values : Array[Double]) -> Double

    Median absolute deviation, a robust scale estimate.

    make_folds

    fn make_folds(length : Int, fold_count : Int) -> Array[Array[Int]]

    Create fixed-size contiguous folds for cross-validation.

    make_route_candidates

    fn make_route_candidates(routes : Array[(String, RouteProfile)], speed~ : Double, congestion~ : Double, risk_penalty? : Double) -> Array[RouteCandidate]

    Build route candidates from multiple profiles.

    maximum_sensitivity_delta

    fn maximum_sensitivity_delta(report : SensitivityReport) -> Double

    Return the largest absolute ETA change in a sensitivity report.

    mean

    fn mean(values : Array[Double]) -> Double

    mean_absolute_difference

    fn mean_absolute_difference(left : Array[Double], right : Array[Double]) -> Double

    Difference between two arrays using the common prefix.

    median

    fn median(values : Array[Double]) -> Double

    Median with midpoint interpolation for even-length arrays.

    median_absolute_error

    fn median_absolute_error(points : Array[ForecastPoint]) -> Double

    Median absolute forecast error.

    merge_stream_summaries

    fn merge_stream_summaries(left : StreamSummary, right : StreamSummary) -> StreamSummary

    Merge two stream summaries in temporal order.

    metadata_is_complete

    fn metadata_is_complete() -> Bool

    Check the public metadata contract.

    metric_bins

    fn metric_bins(results : Array[EtaResult], points : Array[ForecastPoint], bin_count? : Int) -> Array[MetricBin]

    Compute confidence/error bins from results and scored points.

    metric_report

    fn metric_report(results : Array[EtaResult], points : Array[ForecastPoint], tolerance? : Double) -> MetricReport

    Produce a complete metric report for a result/point pair.

    metric_score

    fn metric_score(report : MetricReport, coverage_weight? : Double) -> Double

    Compare two metric reports by a weighted score.

    metric_vector

    fn metric_vector(report : MetricReport) -> Array[Double]

    Return metric values in a stable order for tabular output.

    monitor_observations

    fn monitor_observations(observations : Array[Observation], route : RouteProfile) -> (StreamSummary, Array[ForecastAlert])

    Return a route stream summary augmented with invalid-input alerts.

    monotonic_distance

    fn monotonic_distance(observations : Array[Observation]) -> Bool

    Check monotonic distance progression in a trace.

    moving_average_series

    fn moving_average_series(values : Array[Double], window_size : Int) -> Array[Double]

    Simple trailing moving average with a minimum available prefix.

    named_scenario

    fn named_scenario(name : String) -> ScenarioTrace

    Generate a trace for a named standard scenario.

    nearest_sensitivity_point

    fn nearest_sensitivity_point(report : SensitivityReport, input : Double) -> SensitivityPoint?

    Return the point closest to a requested input.

    noisy_demo_trace

    fn noisy_demo_trace() -> ScenarioTrace

    noisy_scenario

    fn noisy_scenario() -> ScenarioConfig

    Construct a high-variance benchmark scenario.

    noisy_values

    fn noisy_values(values : Array[Double], seed : UInt64, magnitude~ : Double) -> Array[Double]

    Add bounded deterministic noise to a numeric trace.

    normalize_calendar

    fn normalize_calendar(calendar : RouteCalendar) -> RouteCalendar

    Validate and normalize a route calendar.

    normalize_observations

    fn normalize_observations(observations : Array[Observation]) -> Array[Observation]

    Sort observations and keep the last value for a duplicate timestamp.

    normalize_weekday

    fn normalize_weekday(weekday : Int) -> Int

    Normalize arbitrary weekday values into Monday=0 through Sunday=6.

    observation_schema

    fn observation_schema() -> DatasetSchema

    The canonical observation schema.

    package_description

    fn package_description() -> String

    Package purpose for generated metadata and host integrations.

    package_license

    fn package_license() -> String

    License identifier used by the module metadata.

    package_name

    fn package_name() -> String

    Human-readable package title.

    package_repository

    fn package_repository() -> String

    Repository URL for diagnostics and generated reports.

    package_version

    fn package_version() -> String

    Public package version shown by the CLI and release tooling.

    page_stream

    fn page_stream(summary : StreamSummary, page_size : Int) -> Array[StreamSummary]

    Split a stream summary into fixed-size pages for a dashboard.

    pareto_routes

    fn pareto_routes(candidates : Array[RouteCandidate]) -> Array[RouteCandidate]

    Return routes that are not dominated by both ETA and risk.

    parse_cli_options

    fn parse_cli_options(arguments : Array[String]) -> Map[String, String]

    Parse a minimal key=value command option list.

    parse_csv_dataset

    fn parse_csv_dataset(csv : String, name? : String) -> ParseOutcome[ObservationDataset]

    Parse a CSV document into a dataset with optional target columns.

    parse_csv_observations

    fn parse_csv_observations(csv : String) -> ObservationParseResult

    Parse a CSV document with a required timestamp/distance/elapsed header.

    parse_double_token

    fn parse_double_token(token : String) -> Double?

    Convert a JSON number string into a Double without panicking.

    parse_error_code

    fn parse_error_code(error : ParseError) -> String

    Return a compact error code suitable for machine-readable reports.

    parse_json_dataset

    fn parse_json_dataset(input : String, name? : String) -> ParseOutcome[ObservationDataset]

    Parse JSON lines that optionally contain actual_remaining and weight.

    parse_json_lines

    fn parse_json_lines(input : String) -> ObservationParseResult

    Parse JSON-line observations without aborting on malformed input.

    passing_window_count

    fn passing_window_count(evaluation : RollingEvaluation, limit~ : Double) -> Int

    Count windows that satisfy an MAE limit.

    percentile_rank

    fn percentile_rank(values : Array[Double], value~ : Double) -> Double

    Fraction of values less than or equal to a query value.

    population_variance

    fn population_variance(values : Array[Double]) -> Double

    Population variance for finite or empty sample arrays.

    predict_segment_speed

    fn predict_segment_speed(segment : SegmentProfile, live_speed : Double, congestion : Double, policy? : SpeedPolicy) -> Double

    Blend historical and live speed according to policy and reliability.

    prediction_coverage

    fn prediction_coverage(points : Array[ForecastPoint], tolerance~ : Double) -> Double

    Fraction of predictions within an absolute tolerance.

    quality_gate_passed

    fn quality_gate_passed(result : QualityGateResult) -> Bool

    Return whether a report contains no gate failures.

    quantile

    fn quantile(values : Array[Double], probability~ : Double) -> Double

    Linear-interpolated quantile in the closed probability interval.

    rank_routes

    fn rank_routes(candidates : Array[RouteCandidate]) -> Array[RouteCandidate]

    Return route candidates in score order.

    refine_grid

    fn refine_grid(route : RouteProfile, dataset : ObservationDataset, initial : GridCalibration, radius? : Double, steps? : Int) -> GridCalibration

    Refine a grid around its current best candidate.

    regime_for_congestion

    fn regime_for_congestion(congestion : Double) -> TrafficRegime

    Map congestion to a coarse traffic regime.

    release_metadata

    fn release_metadata() -> String

    Return a stable release metadata block.

    reliable_distance_fraction

    fn reliable_distance_fraction(route : RouteProfile, floor? : Double) -> Double

    Return the fraction of a route covered by reliable segments.

    reliable_segments

    fn reliable_segments(route : RouteProfile, floor? : Double) -> Array[SegmentProfile]

    Return route segments whose reliability meets a floor.

    render_benchmark_report

    fn render_benchmark_report(cases : Array[BenchmarkCase], aggregate : ErrorSummary) -> String

    Render the full benchmark report as Markdown-compatible text.

    render_benchmark_table

    fn render_benchmark_table(report : BenchmarkReport) -> String

    Render a terminal-friendly benchmark table.

    repeat_to

    fn repeat_to(values : Array[Double], size : Int) -> Array[Double]

    Resample values cyclically to a requested size; useful for deterministic fixtures.

    replay_stream

    fn replay_stream(observations : Array[Observation], route : RouteProfile, initial_speed? : Double) -> StreamSummary

    Replay a trace through a calendar-aware stream.

    resample_series

    fn resample_series(values : Array[Double], count : Int) -> Array[Double]

    Resample a series to a requested cardinality.

    rescore_batch

    fn rescore_batch(batch : BatchForecast, actuals : Array[Double]) -> BatchForecast

    Re-score a batch against a caller-supplied actual target array.

    results_are_finite

    fn results_are_finite(results : Array[EtaResult]) -> Bool

    Return whether ETA results have finite non-negative fields.

    robust_mean

    fn robust_mean(values : Array[Double]) -> Double

    Arithmetic mean with an explicit empty-input identity.

    rolling_evaluate

    fn rolling_evaluate(results : Array[EtaResult], actuals : Array[Double], window_size~ : Int) -> RollingEvaluation

    Evaluate overlapping rolling windows over ETA results.

    rolling_improvement

    fn rolling_improvement(before : RollingEvaluation, after : RollingEvaluation) -> Double

    Compare rolling performance before and after a change.

    root_mean_square

    fn root_mean_square(values : Array[Double]) -> Double

    Root mean square of a scalar array.

    route_ids

    fn route_ids(candidates : Array[RouteCandidate]) -> Array[String]

    Return candidate IDs in rank order.

    route_progress

    fn route_progress(route : RouteProfile, distance : Double) -> Double

    Return a normalized route progress fraction.

    route_remaining_distance

    fn route_remaining_distance(route : RouteProfile, observation : Observation) -> Double

    Return a bounded remaining distance for a route observation.

    route_summary

    fn route_summary(route : RouteProfile) -> String

    Render a route summary for command output.

    run_benchmark_suite

    fn run_benchmark_suite() -> BenchmarkReport

    Run all benchmark cases and return aggregate metrics.

    run_cli

    fn run_cli(arguments : Array[String]) -> String

    The public command dispatcher used by the demo executable and tests.

    run_cli_benchmark

    fn run_cli_benchmark() -> String

    Run the benchmark and return the full evidence block.

    run_demo

    fn run_demo() -> Array[EtaResult]

    safe_div

    fn safe_div(numerator : Double, denominator : Double, fallback : Double) -> Double

    safe_route_distance

    fn safe_route_distance(route : RouteProfile) -> Double

    Return a route's total length after removing invalid negative segments.

    sample_calendar

    fn sample_calendar(calendar : RouteCalendar, weekday : Int, start_second : Double, interval : Double, count : Int) -> Array[Double]

    Evaluate a calendar over evenly spaced samples.

    sample_indices

    fn sample_indices(length : Int, count : Int) -> Array[Int]

    Generate evenly spaced indexes for a deterministic sample.

    sample_variance

    fn sample_variance(values : Array[Double]) -> Double

    Sample variance, returning zero when degrees of freedom are unavailable.

    sanitize_input_guard

    fn sanitize_input_guard(config : InputGuardConfig) -> InputGuardConfig

    Return a guard with non-negative finite limits.

    sanitize_kalman_config

    fn sanitize_kalman_config(config : KalmanConfig) -> KalmanConfig

    Clamp a configuration to safe operational limits.

    sanitize_quality_gate

    fn sanitize_quality_gate(config : QualityGateConfig) -> QualityGateConfig

    Return a gate with non-negative limits and sensible cardinality.

    sanitize_speed_policy

    fn sanitize_speed_policy(policy : SpeedPolicy) -> SpeedPolicy

    Return a policy with bounded non-negative weights.

    sanitize_window_config

    fn sanitize_window_config(config : WindowConfig) -> WindowConfig

    Clamp a window configuration while preserving its ordering invariants.

    scale_breakdown

    fn scale_breakdown(breakdown : RouteBreakdown, remaining_fraction~ : Double) -> RouteBreakdown

    Scale a breakdown to a new remaining-distance fraction.

    scenario_is_well_formed

    fn scenario_is_well_formed(trace : ScenarioTrace, route : RouteProfile) -> Bool

    Check that a scenario remains within route and time bounds.

    scenario_size_delta

    fn scenario_size_delta(left : ScenarioTrace, right : ScenarioTrace) -> Int

    Compare benchmark output cardinality for two scenarios.

    schema_field_from_name

    fn schema_field_from_name(name : String) -> SchemaField?

    Parse a schema field name.

    schema_field_name

    fn schema_field_name(field : SchemaField) -> String

    Convert a schema field into its wire name.

    schema_headers

    fn schema_headers(schema : DatasetSchema, include_optional? : Bool) -> Array[String]

    Return canonical CSV headers for a schema.

    select_route

    fn select_route(candidates : Array[RouteCandidate]) -> RouteSelection

    Select the lowest-risk-adjusted ETA candidate.

    select_values

    fn select_values(values : Array[Double], indices : Array[Int]) -> Array[Double]

    Copy values at valid indexes, ignoring indexes outside the source.

    selection_risk_premium

    fn selection_risk_premium(selection : RouteSelection) -> Double

    Compare selected route to the fastest raw ETA route.

    singleton_scenario

    fn singleton_scenario() -> ScenarioConfig

    Return a scenario with a single observation, useful for smoke tests.

    smape

    fn smape(points : Array[ForecastPoint]) -> Double

    Symmetric mean absolute percentage error.

    smooth_values

    fn smooth_values(values : Array[Double], initial~ : Double, config~ : KalmanConfig) -> Array[Double]

    snapshot_confidences

    fn snapshot_confidences(summary : StreamSummary) -> Array[Double]

    Return confidence values from stream snapshots.

    snapshot_etas

    fn snapshot_etas(summary : StreamSummary) -> Array[Double]

    Return ETA values from stream snapshots.

    sorted_values

    fn sorted_values(values : Array[Double]) -> Array[Double]

    Return a sorted copy, keeping the caller's array unchanged.

    speed_candidates

    fn speed_candidates(segment : SegmentProfile, congestion~ : Double) -> Array[Double]

    Return weighted speed candidates for diagnostics and benchmark reports.

    speed_confidence

    fn speed_confidence(segment : SegmentProfile, live_speed : Double, predicted_speed : Double) -> Double

    Estimate confidence from segment reliability and speed agreement.

    speed_sensitivity

    fn speed_sensitivity(route : RouteProfile, congestion~ : Double, baseline_speed? : Double, minimum_speed? : Double, maximum_speed? : Double, steps? : Int) -> SensitivityReport

    Evaluate ETA sensitivity to live speed.

    split_by_confidence

    fn split_by_confidence(results : Array[EtaResult], threshold~ : Double) -> (Array[EtaResult], Array[EtaResult])

    Partition results by whether their confidence meets a threshold.

    split_indices

    fn split_indices(length : Int, holdout_ratio? : Double) -> (Array[Int], Array[Int])

    Split an array into an ordered train and holdout prefix/suffix.

    square

    fn square(value : Double) -> Double

    stable_scenario

    fn stable_scenario() -> ScenarioConfig

    Construct a stable benchmark scenario.

    stable_sum

    fn stable_sum(values : Array[Double]) -> Double

    Stable sum with a simple compensation term for long traces.

    standard_scenarios

    fn standard_scenarios() -> Array[(String, ScenarioConfig)]

    Return named scenarios for external benchmark runners.

    stream_is_safe

    fn stream_is_safe(summary : StreamSummary) -> Bool

    Return whether stream ETAs are non-negative and finite.

    strict_quality_gate

    fn strict_quality_gate() -> QualityGateConfig

    Return a strict gate suitable for a production caller.

    stride_dataset

    fn stride_dataset(dataset : ObservationDataset, stride : Int) -> ObservationDataset

    Keep every nth row, preserving the first row.

    sum_segment_eta

    fn sum_segment_eta(segments : Array[SegmentEta]) -> Double

    Sum segment ETA values without recomputing speeds.

    summarize_dataset

    fn summarize_dataset(dataset : ObservationDataset) -> DatasetSummary

    Return a descriptive summary of a dataset.

    summarize_errors

    fn summarize_errors(points : Array[ForecastPoint]) -> ErrorSummary

    summarize_time_series

    fn summarize_time_series(values : Array[Double]) -> TimeSeriesSummary

    Summarize a numeric time series.

    supported_targets

    fn supported_targets() -> Array[String]

    Runtime targets exercised by the library design.

    supports_target

    fn supports_target(target : String) -> Bool

    Return whether a target is supported by the package contract.

    target_coverage

    fn target_coverage(dataset : ObservationDataset) -> Double

    Return target coverage as a fraction.

    target_distribution

    fn target_distribution(dataset : ObservationDataset) -> Array[Double]

    Return a target distribution for diagnostics.

    timestamp_grid

    fn timestamp_grid(start : Double, interval : Double, count : Int) -> Array[Double]

    Produce a sequence of monotonic timestamps.

    top_candidates

    fn top_candidates(calibration : GridCalibration, count : Int) -> Array[CalibrationCandidate]

    Return the top k candidates after calibration.

    trace_progress

    fn trace_progress(route : RouteProfile, observations : Array[Observation]) -> Array[Double]

    Return progress values for a trace.

    trimmed_mean

    fn trimmed_mean(values : Array[Double], proportion? : Double) -> Double

    Mean after removing the same proportion from both tails.

    unit_weights

    fn unit_weights(length : Int) -> Array[Double]

    Return an array of unit weights of a requested length.

    validate_calendar_bucket

    fn validate_calendar_bucket(bucket : CalendarBucket) -> Bool

    Validate a calendar bucket range.

    validate_eta_config

    fn validate_eta_config(config : EtaConfig) -> ValidationReport

    Validate a complete ETA configuration.

    validate_observations

    fn validate_observations(observations : Array[Observation]) -> ValidationReport

    Validate observations without changing caller-owned data.

    validate_route

    fn validate_route(route : RouteProfile) -> ValidationReport

    Validate a route profile and its segment parameter ranges.

    validate_schema_header

    fn validate_schema_header(schema : DatasetSchema, headers : Array[String]) -> SchemaReport

    Check a header against a schema.

    validate_schema_metadata

    fn validate_schema_metadata(schema : DatasetSchema) -> Bool

    Validate a dataset schema name and version.

    validation_commands

    fn validation_commands() -> Array[String]

    Return the recommended validation commands as data.

    variance

    fn variance(values : Array[Double]) -> Double

    velocity_from_observation

    fn velocity_from_observation(prev : Observation, next : Observation) -> VelocitySample

    version_banner

    fn version_banner() -> String

    Return a concise version string for command output.

    weighted_mean

    fn weighted_mean(values : Array[Double], weights : Array[Double]) -> Double

    Weighted average that ignores non-positive weights.

    winsorize

    fn winsorize(values : Array[Double], lower_probability? : Double, upper_probability? : Double) -> Array[Double]

    Winsorize both tails while preserving cardinality.

    with_risk_budget

    fn with_risk_budget(candidate : RouteCandidate, budget~ : Double) -> RouteCandidate

    Add a fixed operational risk budget to a candidate score.

    worst_benchmark_case

    fn worst_benchmark_case(report : BenchmarkReport) -> BenchmarkCase?

    Return the benchmark case with the highest MAE.

    worst_cross_validation_fold

    fn worst_cross_validation_fold(report : CrossValidationReport) -> CrossValidationFold?

    Return the fold with the highest error.

    worst_window

    fn worst_window(evaluation : RollingEvaluation) -> EvaluationWindow?

    Return the worst rolling window by MAE.

    z_score

    fn z_score(value : Double, values : Array[Double]) -> Double

    Standardized distance from a sample's center.