export function selectLoopGates(input) {
    const files = input.changedFiles.join(' ');
    const triage = ['loop:state-valid', 'loop:budget-valid'];
    const local = new Set();
    if (input.node.level === 'L0-report')
        return { triage, local: [], checker: [], integration: [], final: [] };
    if (isDocsOnly(input.changedFiles, input.node))
        add(local, ['docs:loop-runtime', 'changelog:check']);
    else if (/zellij/.test(files) || input.node.loop_id.includes('zellij'))
        add(local, ['zellij:slot-telemetry-live-flush', 'zellij:slot-pane-stale-detection']);
    else if (/release/.test(files) || input.node.loop_id.includes('release'))
        add(local, ['release:affected-selector', 'release:dynamic-presets']);
    else if (/research/.test(files) || input.node.loop_id.includes('research'))
        add(local, ['research:quality-contract']);
    else if (/qa-loop/.test(files) || input.node.loop_id.includes('qa-loop'))
        add(local, ['qa-loop:app-handoff-gate-lifecycle']);
    else if (/codex/.test(files) || input.node.loop_id.includes('codex'))
        add(local, ['codex:0139-capability', 'codex-sdk:version-compat']);
    else if (/mad-db|db-safety/.test(files) || input.node.loop_id.includes('mad-db'))
        add(local, ['mad-db:safety-conflict-matrix', 'mad-db:operation-lifecycle-ledger']);
    else if (/agent|scheduler|native-swarm/.test(files) || input.node.loop_id.includes('naruto'))
        add(local, ['parallel:runtime-real-blackbox', 'scheduler:utilization-proof']);
    else
        add(local, ['loop:affected']);
    const integration = new Set();
    if ((input.packageScriptsChanged || []).length || (input.releaseGateIdsChanged || []).length || files.includes('package.json') || files.includes('release-gates.v2.json')) {
        integration.add('release:dag-full-coverage');
    }
    if (input.risk.level === 'high')
        integration.add('loop:integration-required');
    const final = new Set();
    if (input.changedFiles.length || input.risk.requires_gpt_final)
        final.add('gpt:final-arbiter');
    if (input.risk.level === 'critical')
        final.add('human:handoff-required');
    return {
        triage,
        local: [...local],
        checker: input.node.level === 'L2-action' ? ['loop:checker-fresh-session'] : [],
        integration: [...integration],
        final: [...final]
    };
}
function isDocsOnly(files, node) {
    const scoped = [...files, ...node.owner_scope.files, ...node.owner_scope.directories];
    return scoped.length > 0 && scoped.every((file) => file === 'README.md' || file === 'CHANGELOG.md' || file.startsWith('docs'));
}
function add(target, values) {
    for (const value of values)
        target.add(value);
}
//# sourceMappingURL=loop-gate-selector.js.map