iachat/config/schedule.yml
Rodribm10 cfffea9c16 feat(captain): semantic memory fixes + roleta + reclamações + analytics
Consolida o trabalho desta branch de abril/2026 em um bloco pronto pra
testar em staging antes do merge pra main.

## Correções de memória semântica
- ExtractionService: Princípio Zero + Regra de Ouro (ação consumada vs intenção).
- Cenário Daniela_Reservas: Passo 0 de classificação (consulta/intenção/fora).

## Roleta da Sorte (end-to-end)
- Schema Supabase + 7 RPCs atômicas (server-side, idempotentes).
- Services: Offer, Redeem, WeeklyReport.
- Jobs: OfferRouletteJob (hook em ConfirmationService após Pix pago),
  NotifyRevealed + Scheduler de fallback.
- Tool manual GenerateRoletaLinkTool + endpoint público /roleta/notify.
- Dashboard /captain/roleta com Resgate + Relatório + anomaly detection.

## Cenário Reclamacoes_Ouvidoria
- Triagem P1-P4, framework LAST, Three-level listening, Self-check.
- Sem compensação material, detecção de cliente frustrado eleva prioridade.

## Analytics
- Funil de conversão /captain/funnel: 5 etapas via regex, zero LLM.
- Detector de churn via ChurnOutreach* (cron dias úteis 10h-17h BRT).

## Trabalho pré-existente incluído
- Captain Executive Reports (ceo_digest, mattermost_delivery).
- get_reserva_preco_tool, Lifecycle ajustes, Reservations UI polimentos.

## Outros
- .gitignore: patterns pra credenciais.
- Migrations de scenarios idempotentes.
- i18n completa pt_BR+en pra roleta/funnel.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 15:36:25 -03:00

154 lines
4.9 KiB
YAML

# https://github.com/ondrejbartas/sidekiq-cron
# use https://crontab.guru/ to validate
# validations for this file exist in /spec/configs/schedule_spec.rb
# executed At 12:00 on every day-of-month.
internal_check_new_versions_job:
cron: '0 12 */1 * *'
class: 'Internal::CheckNewVersionsJob'
queue: scheduled_jobs
# # executed At every 5th minute..
trigger_scheduled_items_job:
cron: '*/5 * * * *'
class: 'TriggerScheduledItemsJob'
queue: scheduled_jobs
# Fallback pra draws da roleta revelados cujo callback do front falhou.
# Executa a cada 5 minutos.
captain_roleta_notify_revealed_scheduler_job:
cron: '*/5 * * * *'
class: 'Captain::Roleta::NotifyRevealedSchedulerJob'
queue: scheduled_jobs
# Re-engajamento de clientes recorrentes que sumiram há 60+ dias.
# Roda de hora em hora das 13h às 20h UTC (10h às 17h BRT).
# O job verifica internamente se está em horário comercial BRT + dia útil.
captain_retention_churn_outreach_scheduler_job:
cron: '5 13-20 * * 1-5'
class: 'Captain::Retention::ChurnOutreachSchedulerJob'
queue: scheduled_jobs
# executed every minute.
trigger_scheduled_messages_job:
cron: '* * * * *'
class: 'ScheduledMessages::TriggerScheduledMessagesJob'
queue: scheduled_jobs
# executed At every minute..
trigger_imap_email_inboxes_job:
cron: '*/1 * * * *'
class: 'Inboxes::FetchImapEmailInboxesJob'
queue: scheduled_jobs
# executed daily at 2230 UTC
# which is our lowest traffic time
remove_stale_contact_inboxes_job.rb:
cron: '30 22 * * *'
class: 'Internal::RemoveStaleContactInboxesJob'
queue: scheduled_jobs
# executed daily at 2230 UTC
# which is our lowest traffic time
remove_stale_redis_keys_job.rb:
cron: '30 22 * * *'
class: 'Internal::RemoveStaleRedisKeysJob'
queue: scheduled_jobs
# DISABLED: investigating if this job is the source of orphan conversations
# #executed daily at 0430 UTC
# # which will be IST 10:00 AM
# process_stale_contacts_job:
# cron: '30 04 * * *'
# class: 'Internal::ProcessStaleContactsJob'
# queue: housekeeping
# executed daily at 0100 UTC
# to delete accounts marked for deletion
delete_accounts_job:
cron: '0 1 * * *'
class: 'Internal::DeleteAccountsJob'
queue: scheduled_jobs
# executed every 15 minutes
# to assign unassigned conversations for all inboxes
bulk_auto_assignment_job:
cron: '*/15 * * * *'
class: 'Inboxes::BulkAutoAssignmentJob'
queue: scheduled_jobs
# executed every 10 minutes
# proactively checks pending PIX charges (Inter) while txid is still valid
captain_proactive_pix_polling_job:
cron: '*/10 * * * *'
class: 'Captain::Payments::ProactivePixPollingSchedulerJob'
queue: scheduled_jobs
# executed every 30 minutes for assignment_v2
periodic_assignment_job:
cron: '*/30 * * * *'
class: 'AutoAssignment::PeriodicAssignmentJob'
queue: scheduled_jobs
# executed daily at 2230 UTC
# removes old notifications (>1 month) and trims to 300 per user
remove_old_notification_job:
cron: '30 22 * * *'
class: 'Notification::RemoveOldNotificationJob'
queue: purgable
# executed every 12 hours
# to remove orphan conversations without contact
remove_orphan_conversations_job:
cron: '0 */12 * * *'
class: 'Internal::RemoveOrphanConversationsJob'
queue: housekeeping
# executed every 5 minutes
# scans reservations and sends configured notification templates (pre/post arrival)
captain_notification_scanner_job:
cron: '*/5 * * * *'
class: 'Captain::Notifications::NotificationScannerJob'
queue: scheduled_jobs
# executed every hour
# keeps landing page promotions and Captain knowledge in sync (including expired promotions cleanup)
landing_hosts_promotion_sync_scheduler_job:
cron: '0 * * * *'
class: 'LandingHosts::PromotionSyncSchedulerJob'
queue: scheduled_jobs
# Sunday at 04:00 UTC (01:00 BRT)
# Generates weekly LLM insights for every account + every captain unit.
# Each account gets a global insight (all conversations) plus one per unit.
captain_weekly_insights_job:
cron: '0 4 * * 0'
class: 'Captain::Reports::WeeklyInsightsJob'
queue: scheduled_jobs
# Monday at 11:00 UTC (08:00 BRT)
# Aggregates last week's insights and delivers the CEO Digest to Mattermost.
# Requires per-account config in account.custom_attributes.ceo_digest
# or fallback ENV CEO_DIGEST_MATTERMOST_WEBHOOK_URL.
captain_ceo_digest_job:
cron: '0 11 * * 1'
class: 'Captain::Reports::CeoDigestJob'
queue: scheduled_jobs
# every 10 minutes - detects silent conversations for memory extraction
captain_contact_memory_silence_detector_job:
cron: '*/10 * * * *'
class: 'Captain::ContactMemories::SilenceDetectorJob'
queue: scheduled_jobs
# weekly - Sundays at 03:00 UTC - TTL aging + LRU cap of contact memories
captain_contact_memory_aging_job:
cron: '0 3 * * 0'
class: 'Captain::ContactMemories::AgingJob'
queue: scheduled_jobs
# daily at 03:30 UTC - hard-delete soft-deleted contact memories older than 30 days (LGPD)
captain_contact_memory_hard_delete_job:
cron: '30 3 * * *'
class: 'Captain::ContactMemories::HardDeleteExpiredJob'
queue: scheduled_jobs