// tools/generate-tests/generators/microservices/detectors.ts — SPEC-058b Section E
// Broker and service mesh detection signals and predicates for microservices test generation.
const BROKER_SIGNALS = ['kafka', 'rabbitmq', 'sqs', 'nats', 'redis-streams', 'pulsar', 'amqp'];
const MESH_SIGNALS = [
    'istio',
    'envoy',
    'linkerd',
    'kong',
    'traefik',
    'nginx-ingress',
    'api-gateway',
];
export function detectBroker(knowledge) {
    const stackLower = knowledge.stack.map((s) => s.toLowerCase());
    for (const sig of BROKER_SIGNALS) {
        if (stackLower.some((s) => s.includes(sig))) {
            return sig;
        }
    }
    return null;
}
export function detectServiceMesh(knowledge) {
    const stackLower = knowledge.stack.map((s) => s.toLowerCase());
    for (const sig of MESH_SIGNALS) {
        if (stackLower.some((s) => s.includes(sig))) {
            return sig;
        }
    }
    return null;
}
export function isMicroservicesTestProject(knowledge) {
    if (knowledge.architecture.primary === 'microservices') {
        return true;
    }
    if (knowledge.architecture.secondary.some((s) => s === 'microservices')) {
        return true;
    }
    if (detectBroker(knowledge) !== null) {
        return true;
    }
    if (detectServiceMesh(knowledge) !== null) {
        return true;
    }
    const backends = knowledge.apps.filter((a) => a.type === 'backend' || a.type === 'worker');
    return backends.length > 1;
}
//# sourceMappingURL=detectors.js.map