import aner.parallel

// Each realization writes its own [step, metric] region. The input snapshot
// is shared read-only across tasks, while local simulation state stays private.
fn simulate(parameters: List, iteration: Int64, seed: Int64,
            output: OutputRegion<Float32>) -> Unit {
    let input = cast<FrozenArray<Float32>>(parameters.get(0))
    var state = input[iteration % input.len()]
    var step = 0
    while step < 8 {
        state = state + Float32(0.25)
        output[step, 0] = state
        output[step, 1] = Float32(iteration)
        step += 1
    }
}

let input = Array<Float32>(4, Float32(1.0)).snapshot()
let history = parallel.repeat(iterations: 1000, task: simulate,
    parameters: List(input), output_shape: List(8, 2), seed: 2026)

print(type_of(history))          // OutputResults<Float32>
print(history.shape())          // List(1000, 8, 2)
print(history[999, 7, 0])        // 3.0
print(history.value(999, 15))    // 999.0: flat column within one region
print(history.bytes())          // 64000 packed payload bytes
print(history.summary())        // Includes coverage/control and input accounting
