Commit Graph

437 Commits

Author SHA1 Message Date
cal
272ad102c0 Update VERSION
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m15s
2026-02-11 21:35:13 +00:00
Cal Corum
bc4daeece1 fix: unpack range() objects in pitcher error rating checks
range() objects were used directly in list membership checks instead of
being unpacked with *, causing all pitcher error ratings in range values
(roughly e27+) to silently fail during x-checks. Also fixed two range
boundary mismatches on dice 12 and dice 6.

Closes #12

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 15:33:37 -06:00
cal
128b669b85 Merge pull request 'fix: preserve batter at plate when half-inning ends on caught stealing' (#11) from fix/cs-batter-skip-1.9.1 into main
All checks were successful
Build Docker Image / build (push) Successful in 1m31s
2026-02-11 04:37:53 +00:00
Cal Corum
1eda66a06c fix: preserve batter at plate when half-inning ends on caught stealing
Some checks failed
Build Docker Image / build (pull_request) Failing after 15s
When a half-inning ended with a CS (or pickoff), the batter who was at
the plate was incorrectly skipped in the next inning. The side-switch
code unconditionally advanced the batting order by 1 without checking
whether the last play was a plate appearance. Now checks opponent_play.pa
before incrementing, matching the existing non-side-switch logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 22:37:42 -06:00
cal
df97b76294 Merge pull request 'fix/position-validation-lineup' (#10) from fix/position-validation-lineup into main
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
Reviewed-on: #10
2026-02-11 04:15:44 +00:00
cal
0168279f6d Update VERSION
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m20s
2026-02-11 04:12:42 +00:00
Cal Corum
1a9efa8f7e fix: add locked_play context manager to prevent stuck play locks
Early returns in log_chaos, log_sac_bunt, and log_stealing left play
locks permanently stuck because the lock was acquired but never released.
The new locked_play async context manager wraps checks_log_interaction()
and guarantees lock release on exception, early return, or normal exit.

Migrated all 18 locking commands in gameplay.py and removed redundant
double-locking in end_game_command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 21:54:44 -06:00
cal
a0b5feebf7 Merge pull request 'fix: validate player positions in lineup before game start' (#9) from fix/position-validation-lineup into main
All checks were successful
Build Docker Image / build (push) Successful in 1m20s
Reviewed-on: #9
2026-02-08 03:17:21 +00:00
cal
a79bfbe6eb Update VERSION
All checks were successful
Build Docker Image / build (pull_request) Successful in 5m27s
2026-02-08 03:03:50 +00:00
Cal Corum
c4577ed46f fix: validate player positions in lineup before game start
Some checks failed
Build Docker Image / build (pull_request) Failing after 16s
Prevents PositionNotFoundException from crashing mlb-campaign when a
player is placed at a position they cannot play (e.g. an outfielder
listed at Catcher in the Google Sheet). Adds early validation in
get_lineups_from_sheets and proper error handling at all read_lineup
call sites so the user gets a clear message and the game is cleaned up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:32:27 -06:00
cal
caabf9c6d2 Merge pull request 'master' (#8) from master into main
All checks were successful
Build Docker Image / build (push) Successful in 48s
Reviewed-on: #8
2026-02-04 15:41:29 +00:00
Cal Corum
a9fa2abbd1 Merge homelab/master - resolve VERSION conflict to 1.8.4
All checks were successful
Build Docker Image / build (pull_request) Successful in 44s
2026-02-04 09:40:00 -06:00
Cal Corum
aaca46d72f Merge branch 'main' of https://git.manticorum.com/cal/paper-dynasty-discord 2026-02-04 09:38:43 -06:00
Cal Corum
c98feea295 Merge branch 'master' 2026-02-04 09:38:18 -06:00
cal
a8b8f59bff Update VERSION
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m11s
2026-02-04 15:35:58 +00:00
cal
7038924e56 Update VERSION
Some checks failed
Build Docker Image / build (pull_request) Failing after 15s
2026-02-04 15:34:14 +00:00
Cal Corum
89801e1d42 Fix circular import by moving play lock functions to separate module
HOTFIX: Production bot failed to start due to circular import.

Root cause: utilities/dropdown.py importing from command_logic/logic_gameplay.py
while logic_gameplay.py imports from utilities/dropdown.py.

Solution: Created play_lock.py as standalone module containing:
- release_play_lock()
- safe_play_lock()

Both modules now import from play_lock.py instead of each other.

Error message:
  ImportError: cannot import name 'release_play_lock' from partially
  initialized module 'command_logic.logic_gameplay' (most likely due
  to a circular import)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 09:33:37 -06:00
cal
d181ee6201 Merge pull request 'Fix play lock system to prevent permanent user lockouts' (#7) from master into main
All checks were successful
Build Docker Image / build (push) Successful in 51s
Reviewed-on: #7
2026-02-04 15:27:33 +00:00
cal
5233c04e17 Update VERSION
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m15s
2026-02-04 15:25:17 +00:00
Cal Corum
48c86e54fd Merge remote-tracking branch 'homelab/main'
Some checks failed
Build Docker Image / build (pull_request) Failing after 24s
2026-02-04 09:24:15 -06:00
Cal Corum
ebf006e5c6 Fix play lock system to prevent permanent user lockouts
CRITICAL BUG FIX: Play locks were never released on exceptions, causing
permanent user lockouts. Found 13 stuck plays in production.

Changes:
1. Added lock_play parameter to checks_log_interaction() (default True)
2. Removed unnecessary locks from read-only commands:
   - /settings-ingame (game settings, not play state)
   - /show-card defense (read-only display)
   - /substitute commands (just show UI, lock in callback)
3. Added safe_play_lock() context manager for automatic lock release
4. Added play locking to substitution callbacks:
   - SelectBatterSub.callback()
   - SelectReliefPitcher.callback()
5. Global error handler now releases stuck locks automatically

Architecture:
- Commands that display UI or read data: No lock
- Commands that modify play state: Lock at last possible moment
- 3-layer defense: manual release, context manager, global handler

Resolves race condition from concurrent play modifications.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 09:21:18 -06:00
cal
c055276dd9 Merge pull request 'Update .gitea/workflows/docker-build.yml' (#6) from fix-docker-push into main
All checks were successful
Build Docker Image / build (push) Successful in 1m17s
Reviewed-on: #6
2026-02-04 07:11:33 +00:00
cal
735d51ab2e Update VERSION
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m5s
2026-02-04 07:09:05 +00:00
cal
8183549b65 Update .gitea/workflows/docker-build.yml
Some checks failed
Build Docker Image / build (pull_request) Failing after 11s
2026-02-04 07:07:58 +00:00
cal
0fb980aec1 Merge pull request 'debug-discord-notis' (#5) from debug-discord-notis into main
All checks were successful
Build Docker Image / build (push) Successful in 54s
Reviewed-on: #5
2026-02-04 07:00:12 +00:00
cal
1f4fad4a66 Update .gitea/workflows/docker-build.yml
All checks were successful
Build Docker Image / build (pull_request) Successful in 57s
2026-02-04 06:58:18 +00:00
cal
56746a8f6a Update .gitea/workflows/docker-build.yml
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m3s
2026-02-04 06:53:48 +00:00
cal
f36bcaccd2 Update .gitea/workflows/docker-build.yml
Some checks failed
Build Docker Image / build (pull_request) Failing after 1m4s
2026-02-04 06:49:54 +00:00
cal
ab0f42d615 Update VERSION
Some checks failed
Build Docker Image / build (pull_request) Failing after 1m9s
2026-02-04 06:47:22 +00:00
cal
b90006cbab Update .gitea/workflows/docker-build.yml
Some checks failed
Build Docker Image / build (pull_request) Failing after 13s
2026-02-04 06:45:52 +00:00
cal
6eece9f1db Update .gitea/workflows/docker-build.yml 2026-02-04 06:43:59 +00:00
cal
cd1b485946 Merge pull request 'Update VERSION' (#4) from cal-patch-1 into main
All checks were successful
Build Docker Image / build (push) Successful in 46s
Reviewed-on: #4
2026-02-04 06:37:15 +00:00
cal
f0c124b00f Update .gitea/workflows/docker-build.yml
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m8s
2026-02-04 06:35:09 +00:00
cal
a360e8812d Update .gitea/workflows/docker-build.yml
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m2s
2026-02-04 06:28:55 +00:00
cal
8bd30211e0 Update VERSION
Some checks failed
/ build (pull_request) Has been cancelled
2026-02-04 06:22:40 +00:00
cal
61a0ad60ba Merge pull request 'Pulling master over to main' (#3) from master into main
All checks were successful
/ build (push) Successful in 1m17s
Reviewed-on: #3
2026-02-04 06:16:29 +00:00
cal
63ea86f35a Update .gitea/workflows/docker-build.yml
All checks were successful
/ build (pull_request) Successful in 2m9s
2026-02-04 06:13:37 +00:00
cal
8ff9cc02e7 Merge branch 'main' into master
All checks were successful
/ build (pull_request) Successful in 1m1s
2026-02-04 06:09:45 +00:00
cal
c252ab3f1a Merge pull request 'Update .gitea/workflows/docker-build.yml' (#2) from cal-patch-2 into main
All checks were successful
/ build (push) Successful in 34s
Reviewed-on: #2
2026-02-04 06:02:36 +00:00
cal
175a19b372 Update .gitea/workflows/docker-build.yml
All checks were successful
/ build (pull_request) Successful in 57s
2026-02-04 06:01:01 +00:00
cal
a1c7aec7af Merge pull request 'Add automated docker build' (#1) from cicd/docker-build into main
All checks were successful
/ build (push) Successful in 32s
Reviewed-on: #1
2026-02-04 05:54:35 +00:00
cal
7ad8d03f98 Update .gitea/workflows/docker-build.yml
All checks were successful
/ build (pull_request) Successful in 57s
2026-02-04 05:52:17 +00:00
cal
91e96a2876 Update .gitea/workflows/docker-build.yml
Some checks failed
/ build (pull_request) Failing after 1m4s
2026-02-04 05:48:40 +00:00
cal
d094809838 Add automated docker build
Some checks failed
Build Docker Image / build (pull_request) Failing after 6m57s
2026-02-04 05:41:18 +00:00
Cal Corum
eb2a511507 Update restart notification message to be more accurate
Changed from 'Auto-Restarted' to 'Restarted' and made the message
generic since the bot restarts for multiple reasons (manual, deployment,
healthcheck) - not just healthcheck failures.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 23:29:51 -06:00
Cal Corum
d31ca7d7e5 Fix webhook notification by adding User-Agent header
Discord webhooks require a User-Agent header or they return 403 Forbidden.
Added 'Paper-Dynasty-Discord-Bot/1.0' as User-Agent.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 23:28:41 -06:00
Cal Corum
4c39e9c0ce Add Discord webhook notifications for bot restarts
Sends instant notifications to Discord when the bot restarts, helping
track stability issues and auto-recovery events.

Changes:
- Add notify_restart.py script to send webhook notifications
- Integrate notification into bot startup (on_ready event)

The notification includes:
- Timestamp of restart (CST)
- Reason (healthcheck failure detection)
- Reference to diagnostics logs

Configuration:
Set RESTART_WEBHOOK_URL environment variable in docker-compose.yml
to enable notifications.

This provides immediate visibility when Docker auto-restarts the bot
due to crashes or healthcheck failures.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 23:19:24 -06:00
Cal Corum
90d7345850 Implement play locking to prevent concurrent command processing
Adds idempotency guard to prevent race conditions when multiple users
submit commands for the same play simultaneously.

Changes:
- Add PlayLockedException for locked play detection
- Implement lock check in checks_log_interaction()
- Acquire lock (play.locked = True) before processing commands
- Release lock (play.locked = False) after play completion
- Add warning logs for rejected duplicate submissions
- Add /diagnostics endpoint to health server for debugging

This prevents database corruption and duplicate processing when users
spam commands like "log xcheck" while the first is still processing.

Tested successfully in Discord - duplicate commands now properly return
PlayLockedException with instructions to wait.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 23:13:40 -06:00
Cal Corum
00ed42befd Add tests for play lock release and cross-command racing
Adds two new test cases to test_play_locking.py to improve coverage:

1. test_lock_released_after_successful_completion
   - Verifies play.locked is set to False after complete_play()
   - Confirms play.complete is set to True
   - Validates database commit is called

2. test_different_commands_racing_on_locked_play
   - Tests that ANY command type is blocked on locked plays
   - Prevents race conditions between different command types
   - Tests multiple commands: walk, strikeout, single, xcheck

These tests ensure the play locking idempotency guard works correctly
for both lock acquisition and release, and prevents all command types
from racing (not just duplicate commands).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 17:13:57 -06:00
Cal Corum
38a411fd3e Bump version to 1.7.13 2026-01-31 15:53:07 -06:00