// Task 033 — pure parser for the OnboardingState read-back assertion.
//
// Extracted into a dedicated module (not src/index.ts) so the test
// suite can import it without triggering index's brand.json-at-load
// side effect. The installer's loud-fail branches at
// `assertOnboardingStateSeeded` consume the tri-state outcome.
/**
 * Classify cypher-shell --format plain output into one of three states:
 *
 * - `unreachable` — non-zero exit (auth, network, syntax). Stderr tail
 *   (last 200 chars) is preserved so the install log carries the
 *   symptom verbatim.
 * - `missing` — exit 0 but no data row beyond the header. cypher-shell
 *   prints the column name even on a zero-match query.
 * - `present` — exit 0 with at least one data row. `currentStep` is the
 *   first field on row 2.
 */
export function classifyOnboardingReadBack(input) {
    if (input.status !== 0) {
        return { kind: "unreachable", stderrTail: input.stderr.trim().slice(-200) };
    }
    const lines = input.stdout.trim().split("\n").filter((l) => l.length > 0);
    if (lines.length < 2) {
        return { kind: "missing" };
    }
    return { kind: "present", currentStep: lines[1].trim() };
}
