import {
  SIZING_GUIDE_REF
} from "./chunk-DWMLTXKQ.js";

// src/wu-sizing-validation.ts
var SIZING_STRATEGIES = [
  "single-session",
  "checkpoint-resume",
  "orchestrator-worker",
  "decomposition"
];
var SIZING_EXCEPTION_TYPES = ["docs-only", "shallow-multi-file"];
var SIZING_THRESHOLDS = {
  SIMPLE: { files: 20, tool_calls: 50 },
  MEDIUM: { files: 50, tool_calls: 100 },
  OVERSIZED: { files: 100, tool_calls: 200 },
  /** Docs-only exception thresholds (section 1.1) */
  DOCS_ONLY: { files: 40, tool_calls: 50 }
};
function validateSizingEstimate(estimate) {
  if (estimate === void 0) {
    return { valid: true, errors: [] };
  }
  const errors = [];
  if (typeof estimate.estimated_files !== "number" || estimate.estimated_files < 0) {
    errors.push("sizing_estimate.estimated_files must be a non-negative number");
  }
  if (typeof estimate.estimated_tool_calls !== "number" || estimate.estimated_tool_calls < 0) {
    errors.push("sizing_estimate.estimated_tool_calls must be a non-negative number");
  }
  if (!SIZING_STRATEGIES.includes(estimate.strategy)) {
    errors.push(`sizing_estimate.strategy must be one of: ${SIZING_STRATEGIES.join(", ")}`);
  }
  if (estimate.exception_type !== void 0) {
    if (!SIZING_EXCEPTION_TYPES.includes(estimate.exception_type)) {
      errors.push(
        `sizing_estimate.exception_type must be one of: ${SIZING_EXCEPTION_TYPES.join(", ")}`
      );
    }
    if (!estimate.exception_reason || estimate.exception_reason.trim().length === 0) {
      errors.push("sizing_estimate.exception_reason is required when exception_type is set");
    }
  }
  return { valid: errors.length === 0, errors };
}
function hasValidException(estimate) {
  return estimate.exception_type !== void 0 && estimate.exception_reason !== void 0 && estimate.exception_reason.trim().length > 0;
}
function checkSizingAdvisory(estimate) {
  if (estimate === void 0) {
    return { oversize: false, warnings: [] };
  }
  if (hasValidException(estimate)) {
    return { oversize: false, warnings: [] };
  }
  const warnings = [];
  if (estimate.estimated_files > SIZING_THRESHOLDS.OVERSIZED.files || estimate.estimated_tool_calls > SIZING_THRESHOLDS.OVERSIZED.tool_calls) {
    warnings.push(
      `Sizing estimate exceeds OVERSIZED threshold (${estimate.estimated_files} files, ${estimate.estimated_tool_calls} tool calls). This WU MUST be split per ${SIZING_GUIDE_REF}.`
    );
    return { oversize: true, warnings };
  }
  if (estimate.estimated_files > SIZING_THRESHOLDS.SIMPLE.files) {
    warnings.push(
      `sizing: estimated_files (${estimate.estimated_files}) exceeds Simple threshold (${SIZING_THRESHOLDS.SIMPLE.files}). Consider adding exception_type/exception_reason or splitting the WU. See ${SIZING_GUIDE_REF}.`
    );
  }
  if (estimate.estimated_tool_calls > SIZING_THRESHOLDS.SIMPLE.tool_calls) {
    warnings.push(
      `sizing: estimated_tool_calls (${estimate.estimated_tool_calls}) exceeds Simple threshold (${SIZING_THRESHOLDS.SIMPLE.tool_calls}). Consider checkpoint-resume strategy or splitting the WU. See ${SIZING_GUIDE_REF}.`
    );
  }
  return { oversize: warnings.length > 0, warnings };
}

export {
  validateSizingEstimate,
  checkSizingAdvisory
};
