package com.correx.core.kernel.orchestration

/**
 * The reconciliation of a stage's [produced] artifacts against the [expected] produces-slots of the
 * locked plan. [missing] is the expected slots that were never produced; [passed] holds when none
 * are missing. Extra produced artifacts beyond [expected] do not fail the checkpoint.
 */
internal data class StageCheckpoint(
    val expected: Set<String>,
    val produced: Set<String>,
) {
    val missing: Set<String> get() = expected - produced
    val passed: Boolean get() = missing.isEmpty()
}

/**
 * Pure reconciler for stage-level plan checkpointing: compares the artifacts a stage produced
 * against the artifacts the locked plan expected it to produce. Side-effect free and replay-safe.
 */
internal object StageCheckpointReconciler {
    fun reconcile(expected: Set<String>, produced: Set<String>): StageCheckpoint =
        StageCheckpoint(expected = expected, produced = produced)
}
