Paper Dynasty Database - PostgreSQL database service
Go to file
Cal Corum ab15228c44 fix(refractor): mask variant hash to 31 bits to fit Postgres INTEGER
compute_variant_hash took the first 8 hex chars of a SHA-256 digest and
cast to int, producing values up to 2^32 - 1. The variant columns on
Card, BattingCard, PitchingCard, and RefractorCardState are Peewee
IntegerField → Postgres INTEGER, which is signed 32-bit (max 2^31 - 1).
Roughly half of all players (~50%) would hash into the range [2^31,
2^32 - 1] and crash tier-up writes with:

  peewee.DataError: integer out of range

Surfaced via /dev refractor-test card_id:64460 (Charles Nagy,
player_id=10795), whose tier-1 hash was 2874960417. The outer
exception handler in refractor.evaluate_game caught the error and
logged a warning, so the tier-up was silently dropped — the test
harness reported "No tier-up detected (evaluated 2 cards)" while
apply_tier_boost was actually failing mid-write.

Fix: mask the hash with & 0x7FFFFFFF, dropping one bit of entropy.
~2.1B distinct values remain — still astronomically collision-safe.

Backwards-compatible: all 9 existing refractor_boost_audit rows and
9 persisted non-zero variants have hashes where the high bit was
already 0 (those tier-ups happened to land in the safe half). Masking
leaves those values unchanged.

Added regression test test_fits_postgres_int32 covering 10,000 player
IDs × 5 tiers = 50,000 combinations, all asserted ≤ 2,147,483,647.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 13:11:40 -05:00
.gitea/workflows ci: switch buildx cache from registry to local volume 2026-03-24 00:15:38 -05:00
.githooks fix: address review feedback (#181) 2026-04-04 23:03:06 -05:00
app fix(refractor): mask variant hash to 31 bits to fit Postgres INTEGER 2026-04-11 13:11:40 -05:00
docs Remove deprecated legacy files and reorganize documentation 2026-02-05 13:34:09 -06:00
migrations chore: remove unused RefractorTierBoost and RefractorCosmetic tables 2026-04-05 22:27:26 -05:00
scripts fix: address PR review — unknown flag guard, local var scope, container map 2026-04-07 20:32:12 -05:00
storage/templates fix: improve diamond tier indicator visibility 2026-04-07 08:47:24 -05:00
tests fix(refractor): mask variant hash to 31 bits to fit Postgres INTEGER 2026-04-11 13:11:40 -05:00
.dockerignore Add .dockerignore 2026-01-30 22:47:07 -06:00
.env fix: correct inverted TESTING env check and leading space in .env (#23) 2026-03-03 21:43:54 +00:00
.env.example CLAUDE: Add .env.example with comprehensive configuration guide 2025-11-07 11:53:23 -06:00
.gitignore fix: visual tuning from live preview — diamond position, borders, corners, header z-index 2026-04-04 11:20:05 -05:00
CLAUDE.md docs: fix dev PostgreSQL container/db/user in CLAUDE.md 2026-04-07 03:15:21 +00:00
compose.production.yml Add production deployment config and fix stringified list parsing 2026-01-30 14:03:07 -06:00
docker-compose.yml CLAUDE: Comment out API service - prevents race condition in db_engine.py 2025-11-07 14:07:13 -06:00
Dockerfile fix: correct COPY path and add CMD in Dockerfile 2026-03-17 20:09:04 +00:00
LICENSE Initial commit 2023-02-19 21:38:07 -06:00
pyproject.toml feat: Track Catalog API endpoints (WP-06) (#71) 2026-03-12 20:40:38 -05:00
requirements.txt fix: correct apng version pin (0.3.4, not 3.1.1) 2026-04-06 23:23:48 -05:00
ruff.toml fix: address PR review findings 2026-03-17 21:38:12 -05:00
run-local.sh fix: refractor card art post-merge fixes — cache bypass, template guards, dev server 2026-04-04 12:37:30 -05:00
VERSION Bump version to 1.5.5 2026-02-04 08:48:12 -06:00