package com.correx.core.transitions.graph

/**
 * Per-stage execution-gate scope (staged-verification design §2) — the closed set a planner picks
 * from to say how far the project should be runnable after this stage. Resolves at runtime to a
 * concrete command drawn from the bound project profile's command aliases, so the command itself
 * stays stack-specific and operator-owned while the *scope* is a fixed vocabulary the planner can't
 * invent.
 *
 * [commandAlias] names the `[project.commands]` alias to run for this scope (null = no gate):
 * NONE → nothing (early stages where the project is not yet runnable), MODULE → typecheck,
 * PROJECT → build, TESTS → test. A stage whose profile lacks the alias skips the gate with a warning
 * rather than failing — the vocabulary degrades safely when the operator hasn't configured commands.
 */
enum class BuildExpectation(val commandAlias: String?) {
    NONE(null),
    MODULE("typecheck"),
    PROJECT("build"),
    TESTS("test"),
    ;

    companion object {
        /** Parses a plan's `build_expectation` string; null for an unrecognized value so the compiler rejects it. */
        fun fromPlan(raw: String?): BuildExpectation? = when (raw?.trim()?.lowercase()) {
            null, "", "none" -> NONE
            "module" -> MODULE
            "project" -> PROJECT
            "tests", "test" -> TESTS
            else -> null
        }
    }
}
