/**
 * Auto-Optimizer — dynamic convergence-aid activation
 *
 * Makes `uap deliver` self-optimizing: every instruction is classified for
 * complexity and the convergence aids (exploration, critic, practices,
 * escalation, ideation, HALO, coordination) are enabled to match — no flags
 * required. Trivial requests keep the cheap single-shot loop; non-trivial
 * requests always get the aids that improve outcomes.
 *
 * The classifier is the dependency-free utils scorer with thresholds owned
 * HERE: this mapping gates a cost cliff (moderate ≈ 4-5× model calls per
 * turn once judge/critic are counted), so retuning the memory system's
 * retrieval thresholds must never silently change delivery's bill.
 */
import { measureQueryComplexity, } from '../utils/query-complexity.js';
/** Delivery-owned cost-tier boundaries (see module doc). */
export const DELIVERY_COMPLEXITY_THRESHOLDS = {
    moderate: 1,
    complex: 2,
};
/**
 * Map instruction complexity to a convergence-aid plan.
 *
 *  - simple   → plain single-shot loop (aids would only add cost)
 *  - moderate → exploration ×3 + critic + practices + HALO + coordination
 *  - complex  → the full stack (= --optimize): exploration ×4, critic,
 *               practices, escalation, ideation, HALO, coordination
 *
 * The classifier is injectable for tests and future model-based upgrades.
 */
export function planAutoOptimization(instruction, classify = (q) => measureQueryComplexity(q, DELIVERY_COMPLEXITY_THRESHOLDS)) {
    const complexity = classify(instruction);
    if (complexity === 'simple') {
        return {
            complexity,
            critic: false,
            practices: false,
            escalate: false,
            ideate: false,
            halo: false,
            coordinate: false,
            summary: 'simple task → single-shot loop',
        };
    }
    if (complexity === 'moderate') {
        return {
            complexity,
            candidates: 3,
            critic: true,
            practices: true,
            escalate: false,
            ideate: false,
            halo: true,
            coordinate: true,
            summary: 'moderate task → exploration ×3, critic, practices, HALO, coordination',
        };
    }
    return {
        complexity,
        candidates: 4,
        critic: true,
        practices: true,
        escalate: true,
        ideate: true,
        halo: true,
        coordinate: true,
        summary: 'complex task → exploration ×4, critic, practices, escalation, ideation, HALO, coordination',
    };
}
//# sourceMappingURL=auto-optimizer.js.map