/**
 * SET 23e / R1 — pure precedence decision for `bootstrapConnectionFromEnv`
 * (src/server/index.ts). Extracted so the precedence order is unit-testable
 * with real inputs, not just a source-position regression test.
 *
 * MOCK_LLM=1 must win over EVERYTHING else, including a persisted verified
 * operator in data/providers.json — a stale providers.json on disk must
 * never silently wire a mock-flagged boot to a real host.
 */

export type BootstrapChoice = 'mock' | 'persisted' | 'local-env' | 'claude-env' | 'none';

export interface BootstrapPrecedenceInputs {
  /** process.env.MOCK_LLM === '1' */
  mockLlm: boolean;
  /** A previously-verified operator is persisted in data/providers.json. */
  hasPersistedOperator: boolean;
  /** process.env.LOCAL_LLM === '1' */
  localLlmEnv: boolean;
  claudeKeyPresent: boolean;
  claudeModelPresent: boolean;
}

export function resolveBootstrapChoice(inputs: BootstrapPrecedenceInputs): BootstrapChoice {
  if (inputs.mockLlm) return 'mock';
  if (inputs.hasPersistedOperator) return 'persisted';
  if (inputs.localLlmEnv) return 'local-env';
  if (inputs.claudeKeyPresent && inputs.claudeModelPresent) return 'claude-env';
  return 'none';
}
