Skip to content

add job_broadcaster to apply bot bans and post to discord - #260

Merged
extreme4all merged 5 commits into
developfrom
t3/rework-broadcaster-job
Nov 11, 2026
Merged

extreme4all merged 5 commits into
developfrom
t3/rework-broadcaster-job

Conversation

@extreme4all

Copy link
Copy Markdown
Contributor

Summary

  • Add job_broadcaster cronjob (base, project, Dockerfile, CI workflow) that applies predicted bot bans (confirmed_ban = 1) and announces results to the graveyard Discord channel
  • New database/ban_broadcast component: counts pending bans, selects predicted bots (Real_Player probability < 0.5), and applies bans in one transaction so announced counts/names match the UPDATE; a symmetry test enforces the SELECT and UPDATE predicates stay in sync
  • New discord_webhook component: async aiohttp poster that returns errors as values (no abort mid-broadcast), honors 429 retry_after with uniform retries on every post, and validates Discord embed size limits at construction
  • Chunked names embeds respect the 1024-char field limit and 50-name cap, with configurable sleep between posts; completion embed carries an optional role mention (empty string disables the ping)
  • Prometheus metrics (bans applied, embeds sent/failed) with a Grafana panel; compose services for dev/prd, MySQL user + grants, and .env.example entries (GRAVEYARD_WEBHOOK required, GRAVEYARD_ROLE_MENTION optional)

Testing

  • uv run pytest: 494 passed, including 41 new tests covering job_broadcaster, discord_webhook, and database/ban_broadcast
  • test_repository.py::test_select_and_apply_predicates_are_symmetric guards SELECT/UPDATE predicate drift
  • uv run mypy: no issues found
  • uv run ruff format --check . and uv run ruff check .: clean
  • Not run: live webhook post to the graveyard channel and PRD deploy via workflow_dispatch

extreme4all added 5 commits November 11, 2026 01:45
- new ban_broadcast and discord_webhook components; counts, selection, and confirmed_ban update run in one transaction
- embeds post over aiohttp webhook with 429 retry; errors returned as values
- adds job-broadcaster mysql user/grants, compose services, CI workflow, grafana panel, and tests
- retry the snapshot and each apply batch on transient db errors
  (lock waits, deadlocks, lost connections) with exponential backoff
- apply bans in id batches, one short transaction per batch, single
  table PK updates - no join, no json evaluation in the update
- lower session innodb_lock_wait_timeout so lock waits fail fast
- read pages stream by id cursor instead of one big result set
- emit a wide event per run via the wide_event component
- add idx_ban_labels on Players for the pending-ban scan
one loop: apply chunk -> post chunk's names embed. the apply batching
now shares chunk_size with the embeds, so the discord pacing throttles
the update rate too, and applied bans are announced incrementally.
totals embed posts before the loop; DB_UPDATE_BATCH_SIZE is gone.
@extreme4all
extreme4all merged commit 2544d62 into develop Nov 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant