Skip to content

feat: Dad of the Month#60

Draft
kbuechl wants to merge 3 commits into
mainfrom
feat/dad-of-month
Draft

feat: Dad of the Month#60
kbuechl wants to merge 3 commits into
mainfrom
feat/dad-of-month

Conversation

@kbuechl

@kbuechl kbuechl commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Dad of the Month

Automated, fair-rotating "Dad of the Month" plus a batch of pre-existing bug fixes that were uncommitted on main.

Features

  • Auto-pick on the 1st at 10am EST (DST-safe via IANA America/New_York); catches up on restart if a pick was missed.
  • Fairness: excludes last month's pick, then random among fewest non-override picks in 12 months. Baby-override months are free.
  • Commands: !whosdad (anyone), !adddad @user, !setdad @user (admin), !pickdad (admin).
  • Announces to DAD_ANNOUNCEMENT_CHANNEL_ID; pool keyed off DAD_ROLE_ID. Dormant if either is unset.

Design

  • Repository interface isolates persistence; pgxRepository holds raw pgx SQL (never mocked). New dad_of_month table, unique (GuildId, Year, Month). All month math via estNow().

Also included (bug-fix commit)

Ollama model-creation deadlock; LLM temperature/guidance data race -> atomic; missing DB name in pgx URL; nil panics in WATO CanActivate; Dezgo off-by-one; tiktoken panic -> sync.Once; removed dead messageHistory.go/vector.go.

Tests

TDD; pure logic fully covered. Raw SQL + Discord glue left for manual/integration verification. go build/vet/test/gofmt clean.

Setup before running

  1. Apply dad_of_month from init.sql. 2. Set DAD_ANNOUNCEMENT_CHANNEL_ID and DAD_ROLE_ID.

🤖 Generated with Claude Code

kbuechl added 3 commits June 19, 2026 14:34
- Fix deadlock in model creation: WaitGroup.Done() was only called on
  "success" status; removed WaitGroup in favor of sequential creation
- Fix data race: Temperature and Guidance now use atomic.Uint32 with
  Float32frombits/Float32bits accessors instead of plain float32 fields
- Fix missing database name in pgxpool connection URL
- Fix nil panic in WATO CanActivate: missing return false after channel
  fetch error in all four WATO commands
- Fix nil pointer dereference: ChallengerBet/ChallengedBet are pointers,
  comparison now correctly dereferences them
- Fix off-by-one in Dezgo model selection (rand.Intn(len-1) to len)
- Fix return err vs return cErr typo in configure error path
- Fix chat history slice panic when msgs is empty
- Compile URL regex once at package level instead of per-message
- Replace tiktoken panic with sync.Once lazy init and warn-on-failure
- Delete unused messageHistory.go and vector.go (dead langchain/chroma code)
Monthly automated rotation of a "dad of the month" role with fairness
tracking, baby-override support, and a channel announcement.

Behavior:
- Auto-picks on the 1st of each month at 10am EST; catches up on restart
  if the bot was down and no dad is set for the current month
- Fairness: excludes last month's pick, then randomly selects among the
  candidates with the fewest non-override appearances in the last 12 months
- Override (baby) months are free — they don't count against fairness
- Commands: !adddad @user (grant dad role), !setdad @user (admin override
  for current + next month), !pickdad (admin force pick), !whosdad (anyone)
- Announcements go to DAD_ANNOUNCEMENT_CHANNEL_ID; dad role via DAD_ROLE_ID

Design:
- Repository interface isolates persistence; pgxRepository holds the raw
  SQL (pgx, never mocked). Commands/scheduler depend on the interface so
  logic is tested against an in-memory fake.
- New dad_of_month table with unique (GuildId, Year, Month) constraint

Tests (TDD, RED then GREEN): pure logic fully covered — selectDad,
nextPickTime, shouldCatchUp, command CanActivate routing, admin gating,
whosdad handler, and setDadOverride (incl. Dec->Jan rollover and error
paths). SQL and Discord-session glue are intentionally left to manual/
integration verification.
Previously the pick *timing* used America/New_York but the calendar
month written to the DB and shown in announcements came from the raw
server-local time.Now(). On a UTC server these disagree in the late-
evening-EST window near a month boundary (e.g. Jun 30 8:30pm EST is
Jul 1 UTC), which could file a pick under the wrong month.

Add estNow() and source every calendar-month derivation from it so the
feature behaves identically regardless of server timezone (the IANA zone
also handles EST/EDT automatically).

Also document the Dad of the Month commands in !help (admin-only ones
marked) and fix a stray backtick in the image-tuning help text.
@kbuechl

kbuechl commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

Still want to test this end-to-end before merging — haven't run it against a live Discord server / DB yet.

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