Skip to content

CTF-1004: Event Start/End Automation

Statement

The system should automatically transition event state at the configured start and end times. At start time, the event shall transition from registration to active (enabling flag submissions). At end time, the event shall transition from active to ended (disabling submissions and triggering cleanup). The system shall log automated transitions and notify organizers.

Rationale

Manual event start/end requires an organizer to be online at the exact scheduled time, which is unreliable across timezones. Automated transitions ensure events start and end precisely when configured, maintaining fairness and consistency. (CTFd enforces time-based submission windows; Shifter should similarly automate the state transitions that enforce these windows.)

Traceability

  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/management/commands/run_ctf_scheduler.py::_handle_event_start (EVENT_START task handler - runs the automatic start at the configured start time)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/management/commands/run_ctf_scheduler.py::_handle_event_end (EVENT_END task handler - runs the automatic end at the configured end time)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/services/event/ (activate_event: scheduled->active transition. complete_event: active->completed transition. Both log transitions.)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/services/event/ (Schedules EVENT_START task at event_start time and EVENT_END task at event_end time when event is scheduled)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/services/event/automation.py::start_event_automatically (Locked automatic start; the event_started organizer alert commits with the transition)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/services/event/automation.py::run_automatic_end (Automatic end; retained alerts retry through the scheduler task)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/services/event/_lifecycle.py::complete_event (Locked automatic end; the event_ended organizer alert commits with the transition)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/services/notification/_organizer.py (Durable organizer alert declarations on the communication ledger (ADR-065-R4))
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/ctf/services/challenge/_access.py::_assert_event_active_and_in_window (Submissions close at the end instant)
  • IMPLEMENTS → CODE_FILE shifter/shifter_platform/frontend/src/features/ctf/admin/OrganizerAlertsCard.tsx (Monitoring page Alerts tab for organizer alerts)
  • TESTS → TEST shifter/shifter_platform/tests/ctf/test_organizer_lifecycle_alerts.py (Automatic start and end, alert durability, refused start retry and submission end instant)
  • TESTS → TEST shifter/shifter_platform/tests/ctf/test_services/test_scheduler_handlers.py::TestHandleEventEnd (Scheduler end handler uses the automatic end path)
  • TESTS → TEST shifter/shifter_platform/tests/ctf/test_organizer_alerts.py (Organizer recipients, policy, worker fence, inbox and console isolation)
  • IMPLEMENTS → GITHUB_ISSUE 528 (Issue #528 - organizer alerts for late ranges and automatic start and end)