/**
 * Shared read-projection for the two `traces`-sourced fact tables (D0091):
 * `tool_calls` and `trace_rollups`. Both parse the same `EvalTrace` payload,
 * so its untyped read-view and the trial-axis coercion live here once.
 *
 * Derives from the canonical `EvalTrace` core type (D0045, derive, don't
 * redeclare); each field is `unknown` because the payload is JSON-deserialized
 * but unvalidated, and the descriptors' `rowSchema`s are the output guard.
 *
 * @see packages/core/src/types/trace.ts, EvalTrace
 */
/**
 * Coerce the `trial` association axis (`string | number | undefined`) to a
 * 1-based trial number. Single-trial runs emit `trial: 1`; a missing or
 * non-numeric axis defaults to 1.
 */
export function trialNumber(value) {
    if (typeof value === "number" && Number.isFinite(value))
        return value;
    if (typeof value === "string") {
        const parsed = Number.parseInt(value, 10);
        if (Number.isFinite(parsed))
            return parsed;
    }
    return 1;
}
