Implementa Fases 1+2 do plano Captain Codex OAuth.
Fase 1 — Auth módulo:
- Migration captain_codex_credentials (tokens AR-encrypted)
- Model Captain::CodexCredential (singleton-ish com .current)
- Captain::Codex::AuthService com device flow completo:
start_device_login, poll_once, exchange_for_credential,
valid_access_token (auto-refresh), refresh!
- Rake task captain:codex:{login,status,refresh}
- Sidekiq job Captain::Codex::RefreshTokensJob rodando a cada 30min
Fase 2 — Proxy Chat Completions → Responses:
- Captain::Codex::Translator (chat ↔ responses, tools, tool_calls)
- Captain::Codex::Client (streaming SSE → agregado)
- Api::Internal::CodexProxyController expondo
POST /codex/v1/chat/completions
- 10 specs do Translator passando
Próximo: Fase 3 (feature flag + fallback) e reconfiguração dos
clientes RubyLLM/Agents/ruby-openai pra apontarem pro proxy quando
CAPTAIN_LLM_PROVIDER=openai_codex_oauth.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
170 lines
5.7 KiB
YAML
170 lines
5.7 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
|
|
|
|
# Refresh proativo dos tokens OAuth do ChatGPT Plus (Captain Codex).
|
|
# Roda a cada 30min e renova access_tokens que estão a <5min de expirar.
|
|
# Garante que não tenha cold start causado por token vencido em horário de pico.
|
|
captain_codex_refresh_tokens_job:
|
|
cron: '*/30 * * * *'
|
|
class: 'Captain::Codex::RefreshTokensJob'
|
|
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
|
|
|
|
# Recalcula stats de retenção (interações, Pix, reservas, recorrência) de
|
|
# todos os contatos ativos nos últimos 120 dias. Roda diariamente às 3am BRT
|
|
# (6am UTC) — fora do horário comercial pra não competir com atendimento.
|
|
captain_retention_recalculate_all_contact_stats_job:
|
|
cron: '0 6 * * *'
|
|
class: 'Captain::Retention::RecalculateAllContactStatsJob'
|
|
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
|