/**
 * SET 37b — solution-strata helpers. Data lives in solutionStrata.generated.ts;
 * this module re-exports and adds thin mine/lookup helpers for Integration.
 */
export {
  SOLUTION_STRATA,
  strategyOrderForClass,
} from './solutionStrata.generated';
export type {
  Strategy,
  SolutionStratumRow,
} from './solutionStrata.generated';

import type { Strategy, SolutionStratumRow } from './solutionStrata.generated';
import { SOLUTION_STRATA, strategyOrderForClass } from './solutionStrata.generated';

/** Resolve the strata row for a classKey (exact, then prefix). */
export function lookupSolutionStratum(classKey: string): SolutionStratumRow | undefined {
  if (!classKey) return undefined;
  const exact = SOLUTION_STRATA.find(r => r.classFamily === classKey);
  if (exact) return exact;
  const prefix = classKey.split('|')[0]!;
  return SOLUTION_STRATA.find(r => r.classFamily === prefix);
}

/** Top strategy for a classKey by observed resolution rate. */
export function preferredStrategy(classKey: string): Strategy {
  return strategyOrderForClass(classKey)[0] ?? 'mechanical';
}

/** Alias used by substrate re-export / Integration. */
export const solutionStratumForClass = lookupSolutionStratum;
