"""Canonical ecosystem catalog used by the human analysis engine."""

from __future__ import annotations

from .models import HumanNeed, HumanProfile, NeedCategory, PlatformDefinition


HUMAN_PROFILES: tuple[HumanProfile, ...] = (
    HumanProfile(
        profile_id="administrador_empresa",
        name="Administrador da empresa",
        description="Pessoa responsavel por configurar acesso, planos, operacao e visao geral.",
        priority_needs=(
            NeedCategory.ADMINISTRATION,
            NeedCategory.SECURITY,
            NeedCategory.COMMERCIAL,
            NeedCategory.OBSERVABILITY,
            NeedCategory.GOVERNANCE,
        ),
        typical_questions=(
            "Quem pode acessar esta plataforma?",
            "O que esta funcionando agora?",
            "Quais pendencias impedem uso seguro?",
            "Como eu bloqueio ou libero um cliente?",
        ),
        expected_outputs=(
            "painel executivo",
            "readiness operacional",
            "matriz de permissao",
            "relatorio de bloqueios",
        ),
        sensitive_concerns=("segredo", "permissao", "bloqueio indevido", "auditoria"),
    ),
    HumanProfile(
        profile_id="ceo",
        name="CEO",
        description="Pessoa que precisa de leitura executiva, valor do produto e risco estrategico.",
        priority_needs=(
            NeedCategory.STRATEGY,
            NeedCategory.COMMERCIAL,
            NeedCategory.OBSERVABILITY,
            NeedCategory.DOCUMENTATION,
        ),
        typical_questions=(
            "Quais plataformas ja sustentam receita?",
            "Onde esta o maior risco operacional?",
            "Que parte ja pode ir para piloto?",
            "Qual proximo investimento desbloqueia valor?",
        ),
        expected_outputs=("sumario executivo", "grafico de maturidade", "mapa de risco"),
    ),
    HumanProfile(
        profile_id="gestor_operacional",
        name="Gestor operacional",
        description="Pessoa que coordena execucao diaria, fila de incidentes e continuidade.",
        priority_needs=(
            NeedCategory.OPERATIONS,
            NeedCategory.SUPPORT,
            NeedCategory.OBSERVABILITY,
            NeedCategory.GOVERNANCE,
        ),
        typical_questions=(
            "Qual ordem devo executar agora?",
            "Que teste comprova esta entrega?",
            "Que incidente esta aberto?",
            "Quem depende desta plataforma?",
        ),
        expected_outputs=("fila operacional", "runbook", "evidencia", "proxima OS"),
    ),
    HumanProfile(
        profile_id="suporte",
        name="Equipe de suporte",
        description="Pessoa que atende falhas, explica limites e encaminha diagnostico.",
        priority_needs=(
            NeedCategory.SUPPORT,
            NeedCategory.OPERATIONS,
            NeedCategory.DOCUMENTATION,
            NeedCategory.OBSERVABILITY,
        ),
        typical_questions=(
            "O erro e do usuario, da plataforma ou de provedor externo?",
            "Qual proxima acao sugerida?",
            "Que dado posso mostrar sem vazar segredo?",
            "Existe historico do incidente?",
        ),
        expected_outputs=("diagnostico sanitizado", "proxima acao", "ticket", "evidencia"),
        sensitive_concerns=("dado pessoal", "segredo", "trace bruto"),
    ),
    HumanProfile(
        profile_id="atendimento_cliente",
        name="Atendimento ao cliente",
        description="Pessoa que traduz estado tecnico em orientacao simples para cliente.",
        priority_needs=(
            NeedCategory.EXPERIENCE,
            NeedCategory.SUPPORT,
            NeedCategory.DOCUMENTATION,
            NeedCategory.SELF_SERVICE,
        ),
        typical_questions=(
            "O que eu posso prometer ao cliente?",
            "Qual tela resolve esta duvida?",
            "Qual mensagem explica a pendencia?",
            "O cliente consegue se autosservir?",
        ),
        expected_outputs=("resposta simples", "status do pedido", "artigo de ajuda", "acao orientada"),
    ),
    HumanProfile(
        profile_id="financeiro",
        name="Financeiro",
        description="Pessoa que cuida de fatura, consumo, bloqueio comercial e previsao.",
        priority_needs=(
            NeedCategory.FINANCE,
            NeedCategory.COMMERCIAL,
            NeedCategory.OBSERVABILITY,
            NeedCategory.GOVERNANCE,
        ),
        typical_questions=(
            "Qual foi o consumo?",
            "Existe excedente?",
            "Qual cliente esta inadimplente?",
            "O bloqueio comercial esta correto?",
        ),
        expected_outputs=("fatura", "consumo", "franquia", "bloqueio comercial"),
        sensitive_concerns=("valor", "inadimplencia", "plano", "dados fiscais"),
    ),
    HumanProfile(
        profile_id="contador",
        name="Contador",
        description="Pessoa que precisa de consistencia fiscal, extratos e historico financeiro.",
        priority_needs=(
            NeedCategory.FINANCE,
            NeedCategory.DOCUMENTATION,
            NeedCategory.GOVERNANCE,
        ),
        typical_questions=(
            "Existe relatorio exportavel?",
            "A fatura tem trilha?",
            "O historico financeiro e confiavel?",
        ),
        expected_outputs=("extrato", "relatorio fiscal", "evidencia de cobranca"),
    ),
    HumanProfile(
        profile_id="juridico",
        name="Juridico",
        description="Pessoa que avalia riscos, contratos, privacidade e uso de fontes.",
        priority_needs=(
            NeedCategory.LEGAL,
            NeedCategory.SECURITY,
            NeedCategory.DOCUMENTATION,
            NeedCategory.GOVERNANCE,
        ),
        typical_questions=(
            "Qual contrato rege esta ferramenta?",
            "A fonte e publica ou restrita?",
            "Existe consentimento?",
            "Qual evidencia prova a acao?",
        ),
        expected_outputs=("contrato", "politica", "evidencia", "classificacao de risco"),
        sensitive_concerns=("segredo de justica", "consentimento", "dados pessoais"),
    ),
    HumanProfile(
        profile_id="secretaria",
        name="Secretaria",
        description="Pessoa que precisa de tarefas claras, status, agenda e documentos prontos.",
        priority_needs=(
            NeedCategory.EXPERIENCE,
            NeedCategory.OPERATIONS,
            NeedCategory.DOCUMENTATION,
            NeedCategory.SELF_SERVICE,
        ),
        typical_questions=(
            "O que preciso fazer agora?",
            "Qual documento esta pronto?",
            "Qual cliente precisa de retorno?",
            "Onde encontro a tela certa?",
        ),
        expected_outputs=("checklist", "documento", "status", "atalho de tela"),
    ),
    HumanProfile(
        profile_id="tecnico",
        name="Tecnico",
        description="Pessoa que opera deploy, logs, testes, secrets e integracoes.",
        priority_needs=(
            NeedCategory.INTEGRATION,
            NeedCategory.SECURITY,
            NeedCategory.OPERATIONS,
            NeedCategory.OBSERVABILITY,
        ),
        typical_questions=(
            "Qual comando valida isto?",
            "Qual endpoint esta quebrado?",
            "Qual segredo falta?",
            "Como executo smoke sem vazar token?",
        ),
        expected_outputs=("comando", "health", "smoke", "log sanitizado"),
        sensitive_concerns=("token", "secret", "binding", "remote"),
    ),
    HumanProfile(
        profile_id="usuario_final",
        name="Usuario final",
        description="Pessoa que usa a interface para resolver uma necessidade sem entender a arquitetura.",
        priority_needs=(
            NeedCategory.EXPERIENCE,
            NeedCategory.SELF_SERVICE,
            NeedCategory.DOCUMENTATION,
            NeedCategory.SUPPORT,
        ),
        typical_questions=(
            "Onde clico?",
            "O resultado e confiavel?",
            "O que faco quando falha?",
            "Posso acompanhar o status?",
        ),
        expected_outputs=("tela clara", "mensagem util", "status", "ajuda"),
    ),
    HumanProfile(
        profile_id="cliente_externo",
        name="Cliente externo",
        description="Pessoa ou organizacao que compra o produto e espera valor, suporte e transparencia.",
        priority_needs=(
            NeedCategory.COMMERCIAL,
            NeedCategory.EXPERIENCE,
            NeedCategory.SELF_SERVICE,
            NeedCategory.SUPPORT,
        ),
        typical_questions=(
            "O produto resolve meu problema?",
            "Quanto custa?",
            "O que esta incluido?",
            "Como acompanho uso e suporte?",
        ),
        expected_outputs=("oferta", "plano", "onboarding", "status de uso"),
    ),
    HumanProfile(
        profile_id="planejamento_estrategico",
        name="Planejamento estrategico",
        description="Pessoa que transforma maturidade, risco e oportunidade em roadmap.",
        priority_needs=(
            NeedCategory.STRATEGY,
            NeedCategory.GOVERNANCE,
            NeedCategory.OBSERVABILITY,
            NeedCategory.COMMERCIAL,
        ),
        typical_questions=(
            "Qual plataforma merece prioridade?",
            "Qual pendencia trava receita?",
            "Que dependencia impacta mais perfis humanos?",
            "Qual maturidade esperamos no proximo ciclo?",
        ),
        expected_outputs=("roadmap", "matriz de prioridade", "score de maturidade", "ordens futuras"),
    ),
)


HUMAN_NEEDS: tuple[HumanNeed, ...] = (
    HumanNeed(
        need_id="entender_estado_operacional",
        title="Entender estado operacional sem ler codigo",
        category=NeedCategory.OBSERVABILITY,
        description="A pessoa precisa saber se a plataforma esta pronta, parcial ou bloqueada.",
        success_markers=("health", "readiness", "status", "evidencia", "bloqueio classificado"),
        risk_if_missing="Decisoes humanas ficam baseadas em impressao tecnica dispersa.",
        expected_surfaces=("painel", "relatorio", "MCP admin_ui"),
    ),
    HumanNeed(
        need_id="agir_com_permissao_segura",
        title="Executar acoes com permissao e trilha",
        category=NeedCategory.SECURITY,
        description="A acao humana deve respeitar identidade, papel, escopo e auditoria.",
        success_markers=("identity", "rbac", "audit", "trace", "redaction"),
        risk_if_missing="A operacao pode vazar segredo ou executar acao indevida.",
        expected_surfaces=("Identity", "MCP", "logs sanitizados"),
    ),
    HumanNeed(
        need_id="comprar_e_usar_produto",
        title="Comprar e usar produto com clareza comercial",
        category=NeedCategory.COMMERCIAL,
        description="Cliente e equipe interna precisam entender plano, entitlement e uso.",
        success_markers=("plano", "entitlement", "checkout", "franquia", "bloqueio"),
        risk_if_missing="Produto tecnico fica dificil de vender e suportar.",
        expected_surfaces=("Business", "Finance", "painel comercial"),
    ),
    HumanNeed(
        need_id="receber_suporte_util",
        title="Receber suporte que diagnostica e orienta",
        category=NeedCategory.SUPPORT,
        description="Falhas devem virar diagnostico, proxima acao e evidencia segura.",
        success_markers=("incidente", "ticket", "diagnostico", "nextAction", "evidence"),
        risk_if_missing="O suporte vira repasse de erro bruto e perde confianca.",
        expected_surfaces=("Customer Ops", "MCP admin_ui", "runbook"),
    ),
    HumanNeed(
        need_id="documentar_decisao",
        title="Documentar decisao e fonte da verdade",
        category=NeedCategory.DOCUMENTATION,
        description="Pessoas precisam de documentos claros, versionados e verificaveis.",
        success_markers=("docs", "contrato", "versao", "hash", "indice"),
        risk_if_missing="A memoria do ecossistema se perde entre rodadas.",
        expected_surfaces=("Docs", "central de OS", "SQLite semantico"),
    ),
    HumanNeed(
        need_id="operar_integracao_real",
        title="Operar integracao real sem expor segredo",
        category=NeedCategory.INTEGRATION,
        description="Integracoes precisam de credencial segura, smoke e estado por tenant.",
        success_markers=("BYOK", "credentialRef", "smoke", "tenant", "redaction"),
        risk_if_missing="A integracao parece pronta, mas nao e operavel por cliente real.",
        expected_surfaces=("Integracoes", "Identity", "Business"),
    ),
    HumanNeed(
        need_id="visualizar_sem_backend_paralelo",
        title="Visualizar a mesma fonte que o GPT explica",
        category=NeedCategory.EXPERIENCE,
        description="A UI deve renderizar o mesmo contrato que agentes e MCP consomem.",
        success_markers=("panelReady", "sameSource", "sourceHash", "screenData"),
        risk_if_missing="Painel e GPT podem divergir e quebrar confianca humana.",
        expected_surfaces=("UI Platform", "MCP admin_ui"),
    ),
    HumanNeed(
        need_id="planejar_proxima_os",
        title="Transformar lacuna em ordem de servico",
        category=NeedCategory.GOVERNANCE,
        description="Toda lacuna material deve virar continuidade executavel e rastreavel.",
        success_markers=("ordem", "pendencia", "criterio de pronto", "validacao"),
        risk_if_missing="A rodada avanca sem deixar caminho operacional claro.",
        expected_surfaces=("central de OS", "controle semantico", "relatorios"),
    ),
)


PLATFORMS: tuple[PlatformDefinition, ...] = (
    PlatformDefinition(
        platform_id="business",
        repo_name="tudo-para-ia-business-platform",
        central_folder="01_repo_tudo-para-ia-business-platform",
        title="Business Platform",
        mission="Concentrar contratacao, plano ativo, cobranca, entitlement, consumo e bloqueio comercial.",
        primary_categories=(NeedCategory.COMMERCIAL, NeedCategory.FINANCE, NeedCategory.ADMINISTRATION),
        expected_profiles=("administrador_empresa", "ceo", "financeiro", "contador", "cliente_externo"),
        related_platforms=("identity", "integracoes", "finance", "customer_ops"),
        expected_surfaces=("checkout", "billing", "entitlements", "consumption", "commercial-readiness"),
    ),
    PlatformDefinition(
        platform_id="compliance",
        repo_name="tudo-para-ia-compliance-platform",
        central_folder="02_repo_tudo-para-ia-compliance-platform",
        title="Compliance Platform",
        mission="Governar privacidade, risco, politica, consentimento, auditoria e evidencias.",
        primary_categories=(NeedCategory.LEGAL, NeedCategory.SECURITY, NeedCategory.GOVERNANCE),
        expected_profiles=("juridico", "administrador_empresa", "ceo", "suporte"),
        related_platforms=("identity", "docs", "customer_ops"),
        expected_surfaces=("privacy", "risk", "audit", "consent", "retention"),
    ),
    PlatformDefinition(
        platform_id="customer_ops",
        repo_name="tudo-para-ia-customer-ops-platform",
        central_folder="03_repo_tudo-para-ia-customer-ops-platform",
        title="Customer Ops Platform",
        mission="Organizar suporte, atendimento, incidentes, handoffs e comunicacao com clientes.",
        primary_categories=(NeedCategory.SUPPORT, NeedCategory.OPERATIONS, NeedCategory.EXPERIENCE),
        expected_profiles=("suporte", "atendimento_cliente", "gestor_operacional", "cliente_externo"),
        related_platforms=("business", "identity", "docs"),
        expected_surfaces=("tickets", "incidents", "diagnostics", "customer-status", "handoffs"),
    ),
    PlatformDefinition(
        platform_id="docs",
        repo_name="tudo-para-ia-docs-plataform",
        central_folder="04_repo_tudo-para-ia-docs-plataform",
        title="Docs Platform",
        mission="Ser fonte documental de contratos, guias, provas e leitura canonica do ecossistema.",
        primary_categories=(NeedCategory.DOCUMENTATION, NeedCategory.GOVERNANCE, NeedCategory.STRATEGY),
        expected_profiles=(
            "ceo",
            "juridico",
            "suporte",
            "atendimento_cliente",
            "planejamento_estrategico",
        ),
        related_platforms=("mcps", "ui", "compliance"),
        expected_surfaces=("canonical-docs", "contracts", "proofs", "help", "runbooks"),
        known_blockers=("catalogOnly precisa decisao formal ou leitura responseReady minima",),
    ),
    PlatformDefinition(
        platform_id="finance",
        repo_name="tudo-para-ia-finance-platform",
        central_folder="05_repo_tudo-para-ia-finance-platform",
        title="Finance Platform",
        mission="Materializar cobranca, fatura, consumo, custos, extratos e reconciliacao financeira.",
        primary_categories=(NeedCategory.FINANCE, NeedCategory.COMMERCIAL, NeedCategory.OBSERVABILITY),
        expected_profiles=("financeiro", "contador", "ceo", "administrador_empresa"),
        related_platforms=("business", "identity"),
        expected_surfaces=("invoices", "usage", "cost", "reconciliation", "quota"),
    ),
    PlatformDefinition(
        platform_id="gettys",
        repo_name="tudo-para-ia-gettys-platform",
        central_folder="06_repo_tudo-para-ia-gettys-platform",
        title="Gettys Platform",
        mission="Fornecer superficie operacional especifica do produto Gettys e sua visao administrativa.",
        primary_categories=(NeedCategory.OPERATIONS, NeedCategory.EXPERIENCE, NeedCategory.OBSERVABILITY),
        expected_profiles=("gestor_operacional", "usuario_final", "suporte", "cliente_externo"),
        related_platforms=("ui", "mcps", "business"),
        expected_surfaces=("gettys-overview", "admin-screen", "health", "product-readiness"),
    ),
    PlatformDefinition(
        platform_id="identity",
        repo_name="tudo-para-ia-identity-platform",
        central_folder="07_repo_tudo-para-ia-identity-platform",
        title="Identity Platform",
        mission="Centralizar usuario, organizacao, sessao, papel, escopo, tenant e autorizacao.",
        primary_categories=(NeedCategory.SECURITY, NeedCategory.ADMINISTRATION, NeedCategory.GOVERNANCE),
        expected_profiles=("administrador_empresa", "suporte", "tecnico", "usuario_final", "juridico"),
        related_platforms=("business", "integracoes", "customer_ops", "compliance"),
        expected_surfaces=("rbac", "sessions", "organizations", "incidents", "audit", "contracts"),
    ),
    PlatformDefinition(
        platform_id="integracoes",
        repo_name="tudo-para-ia-integracoes-plataform",
        central_folder="08_repo_tudo-para-ia-integracoes-plataform",
        title="Integracoes Platform",
        mission="Operar providers externos, BYOK, credenciais, smoke e produtos de integracao.",
        primary_categories=(NeedCategory.INTEGRATION, NeedCategory.SECURITY, NeedCategory.COMMERCIAL),
        expected_profiles=("tecnico", "administrador_empresa", "gestor_operacional", "cliente_externo"),
        related_platforms=("identity", "business", "mcps", "customer_ops"),
        expected_surfaces=("BYOK", "providers", "credentials", "smoke", "products", "tenant"),
        known_blockers=("tokens live por provider ainda variam por produto",),
    ),
    PlatformDefinition(
        platform_id="intelligence",
        repo_name="tudo-para-ia-intelligence-platform",
        central_folder="09_repo_tudo-para-ia-intelligence-platform",
        title="Intelligence Platform",
        mission="Planejar inteligencia analitica, recomendacao e leitura assistida do ecossistema.",
        primary_categories=(NeedCategory.STRATEGY, NeedCategory.OBSERVABILITY, NeedCategory.EXPERIENCE),
        expected_profiles=("ceo", "planejamento_estrategico", "gestor_operacional"),
        related_platforms=("mcps", "docs", "business"),
        expected_surfaces=("analytics", "recommendations", "risk", "prioritization"),
        known_blockers=("estado unsupported/configuracao incompleta precisa decisao formal",),
    ),
    PlatformDefinition(
        platform_id="mcps",
        repo_name="tudo-para-ia-mcps-internos-plataform",
        central_folder="10_repo_tudo-para-ia-mcps-internos-plataform",
        title="MCPs Internos Platform",
        mission="Ser control-plane MCP, backend de painel humano, catalogo, auditoria e descoberta assistida.",
        primary_categories=(NeedCategory.GOVERNANCE, NeedCategory.INTEGRATION, NeedCategory.OBSERVABILITY),
        expected_profiles=("tecnico", "gestor_operacional", "administrador_empresa", "planejamento_estrategico"),
        related_platforms=("ui", "docs", "integracoes", "identity", "business"),
        expected_surfaces=("admin_ui", "tools", "readiness", "sameSource", "evidence", "catalog"),
    ),
    PlatformDefinition(
        platform_id="platform_base",
        repo_name="tudo-para-ia-platform-base",
        central_folder="11_repo_tudo-para-ia-platform-base",
        title="Platform Base",
        mission="Oferecer padroes, base tecnica, contratos e referencias comuns para plataformas.",
        primary_categories=(NeedCategory.GOVERNANCE, NeedCategory.OPERATIONS, NeedCategory.DOCUMENTATION),
        expected_profiles=("tecnico", "gestor_operacional", "planejamento_estrategico"),
        related_platforms=("mcps", "docs", "ui"),
        expected_surfaces=("templates", "standards", "contracts", "shared-runtime"),
    ),
    PlatformDefinition(
        platform_id="public",
        repo_name="tudo-para-ia-public-platform",
        central_folder="12_repo_tudo-para-ia-public-platform",
        title="Public Platform",
        mission="Representar superficies publicas, onboarding, paginas e comunicacao externa.",
        primary_categories=(NeedCategory.EXPERIENCE, NeedCategory.COMMERCIAL, NeedCategory.DOCUMENTATION),
        expected_profiles=("cliente_externo", "usuario_final", "atendimento_cliente", "ceo"),
        related_platforms=("business", "docs", "ui"),
        expected_surfaces=("landing", "onboarding", "public-docs", "status"),
    ),
    PlatformDefinition(
        platform_id="stj",
        repo_name="tudo-para-ia-stj-platform",
        central_folder="13_repo_tudo-para-ia-stj-platform",
        title="STJ Platform",
        mission="Materializar produto juridico/processual e sua leitura operacional vendavel.",
        primary_categories=(NeedCategory.LEGAL, NeedCategory.OPERATIONS, NeedCategory.COMMERCIAL),
        expected_profiles=("juridico", "cliente_externo", "suporte", "administrador_empresa"),
        related_platforms=("business", "integracoes", "compliance", "customer_ops"),
        expected_surfaces=("process-query", "monitoring", "public-documents", "legal-readiness"),
    ),
    PlatformDefinition(
        platform_id="ui",
        repo_name="tudo-para-ia-ui-platform",
        central_folder="14_repo_tudo-para-ia-ui-platform",
        title="UI Platform",
        mission="Renderizar contratos MCP-ready, design system, telas-base e experiencia humana.",
        primary_categories=(NeedCategory.EXPERIENCE, NeedCategory.SELF_SERVICE, NeedCategory.GOVERNANCE),
        expected_profiles=("usuario_final", "administrador_empresa", "suporte", "atendimento_cliente"),
        related_platforms=("mcps", "docs", "business", "identity", "integracoes"),
        expected_surfaces=("design-system", "screen-contract", "PWA", "panelReady", "sameSource"),
    ),
)


PROFILE_BY_ID = {profile.profile_id: profile for profile in HUMAN_PROFILES}
PLATFORM_BY_ID = {platform.platform_id: platform for platform in PLATFORMS}


CATEGORY_KEYWORDS: dict[NeedCategory, tuple[str, ...]] = {
    NeedCategory.ADMINISTRATION: (
        "admin",
        "administrator",
        "organizacao",
        "organization",
        "tenant",
        "workspace",
        "operador",
        "gestao",
    ),
    NeedCategory.SUPPORT: (
        "support",
        "suporte",
        "ticket",
        "incident",
        "incidente",
        "diagnostic",
        "diagnostico",
        "handoff",
    ),
    NeedCategory.FINANCE: (
        "finance",
        "billing",
        "invoice",
        "fatura",
        "consumo",
        "quota",
        "franquia",
        "cobranca",
    ),
    NeedCategory.LEGAL: (
        "legal",
        "jurid",
        "privacy",
        "privacidade",
        "consent",
        "contrato",
        "processo",
        "compliance",
    ),
    NeedCategory.SECURITY: (
        "auth",
        "rbac",
        "identity",
        "secret",
        "token",
        "credential",
        "redaction",
        "permiss",
    ),
    NeedCategory.OPERATIONS: (
        "operation",
        "operacao",
        "health",
        "readiness",
        "smoke",
        "deploy",
        "runbook",
        "status",
    ),
    NeedCategory.STRATEGY: (
        "strategy",
        "estrateg",
        "roadmap",
        "maturity",
        "maturidade",
        "prioridade",
        "risk",
        "risco",
    ),
    NeedCategory.DOCUMENTATION: (
        "docs",
        "document",
        "readme",
        "manual",
        "guia",
        "evidence",
        "prova",
        "template",
    ),
    NeedCategory.SELF_SERVICE: (
        "self-service",
        "autosserv",
        "portal",
        "onboarding",
        "wizard",
        "form",
        "acao",
        "action",
    ),
    NeedCategory.COMMERCIAL: (
        "business",
        "commerce",
        "commercial",
        "produto",
        "plano",
        "checkout",
        "entitlement",
        "sellable",
    ),
    NeedCategory.EXPERIENCE: (
        "ui",
        "screen",
        "view",
        "panel",
        "pwa",
        "interface",
        "layout",
        "visual",
    ),
    NeedCategory.GOVERNANCE: (
        "governance",
        "governanca",
        "audit",
        "trace",
        "contract",
        "version",
        "schema",
        "policy",
    ),
    NeedCategory.INTEGRATION: (
        "integration",
        "integracao",
        "provider",
        "BYOK",
        "cloudflare",
        "gitlab",
        "stripe",
        "whatsapp",
    ),
    NeedCategory.OBSERVABILITY: (
        "observability",
        "metrics",
        "latency",
        "trace",
        "audit",
        "health",
        "readiness",
        "evidence",
    ),
}


def platform_ids() -> tuple[str, ...]:
    return tuple(platform.platform_id for platform in PLATFORMS)


def profile_ids() -> tuple[str, ...]:
    return tuple(profile.profile_id for profile in HUMAN_PROFILES)


def categories_for_text(text: str) -> tuple[NeedCategory, ...]:
    lowered = text.lower()
    matched: list[NeedCategory] = []
    for category, keywords in CATEGORY_KEYWORDS.items():
        if any(keyword.lower() in lowered for keyword in keywords):
            matched.append(category)
    return tuple(matched)


def get_platform(platform_id: str) -> PlatformDefinition:
    return PLATFORM_BY_ID[platform_id]


def get_profile(profile_id: str) -> HumanProfile:
    return PROFILE_BY_ID[profile_id]

