Commit Graph

273 Commits

Author SHA1 Message Date
Cal Corum
a52a77ad2a fix: rewrite skill scripts to use API instead of sqlite3 (#124)
All checks were successful
Build Docker Image / build (pull_request) Successful in 8m34s
Rewrote ~/.claude/skills/paper-dynasty/scripts/generate_summary.py
and validate_database.py to use the Paper Dynasty API (via
api_client.py) instead of sqlite3.connect() on a local file.

generate_summary.py: now accepts --cardset-id / --env flags and
fetches batting/pitching card counts and player count via
GET /battingcards and GET /pitchingcards endpoints.

validate_database.py: now accepts --cardset-id / --env flags and
validates via API: checks card counts > 0, and that every player
in the cardset has at least one batting or pitching card.

Rarity-change comparison (two-DB diff) and raw field validation
(groundout_b, percentage ranges) are removed — these relied on
direct SQLite access and are not available through the public API.

Also documents in CLAUDE.md that companion skill scripts use the
API only, per the project's SQLite → PostgreSQL migration.

Closes #124

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 23:07:37 -05:00
cal
dcf9036140 Merge pull request 'fix: Dockerfile COPY path and missing CMD' (#101) from fix/dockerfile-copy-cmd into main
All checks were successful
Build Docker Image / build (push) Successful in 8m32s
Reviewed-on: #101
2026-03-17 20:29:32 +00:00
cal
d0c4bd3bbd fix: correct COPY path and add CMD in Dockerfile
All checks were successful
Build Docker Image / build (pull_request) Successful in 7m54s
- COPY ./app /app/app → /usr/src/app/app (matches WORKDIR)
- Add CMD for uvicorn startup (was missing, inheriting python3 no-op from base image)
2026-03-17 20:09:04 +00:00
cal
d8d1b2ac2f fix: correct COPY path and add CMD in Dockerfile
Some checks failed
Build Docker Image / build (pull_request) Failing after 56s
- COPY ./app /app/app → /usr/src/app/app (matches WORKDIR)
- Add CMD for uvicorn startup (was missing, inheriting python3 no-op from base image)
2026-03-17 20:05:54 +00:00
cal
ac13597fa2 Merge pull request 'Merge next-release into main' (#100) from next-release into main
All checks were successful
Build Docker Image / build (push) Successful in 8m16s
Reviewed-on: #100
2026-03-17 19:17:31 +00:00
Cal Corum
419fb757df Merge main into next-release
All checks were successful
Build Docker Image / build (push) Successful in 8m3s
Build Docker Image / build (pull_request) Successful in 7m55s
Resolve conflicts in app/main.py and app/routers_v2/players.py:
keep main's render pipeline optimization (Phase 0) with asyncio.Lock,
error-tolerant shutdown, and --no-sandbox launch args. The next-release
browser code was an earlier version of the same feature.

Add evolution router import and inclusion from next-release.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 13:53:46 -05:00
Cal Corum
6580c1b431 refactor: deduplicate pitcher formula and test constants
All checks were successful
Build Docker Image / build (push) Successful in 8m46s
Extract shared pitcher value computation into _pitcher_value() helper.
Consolidate duplicated column lists and index helper in season stats tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 09:49:33 -05:00
Cal Corum
bd8e4578cc refactor: split PlayerSeasonStats into BattingSeasonStats and PitchingSeasonStats
Some checks failed
Build Docker Image / build (push) Has been cancelled
Separate batting and pitching into distinct tables with descriptive column
names. Eliminates naming collisions (so/k ambiguity) and column mismatches
between the ORM model and raw SQL. Each table now covers all aggregatable
fields from its source (BattingStat/PitchingStat) including sac, ibb, gidp,
earned_runs, runs_allowed, wild_pitches, balks, and games_started.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 09:43:22 -05:00
Cal Corum
4ed62dea2c refactor: rename PlayerSeasonStats so to so_batter and k to so_pitcher
All checks were successful
Build Docker Image / build (push) Successful in 8m41s
The single-letter `k` field was ambiguous and too short for comfortable use.
Rename to `so_pitcher` for clarity, and `so` to `so_batter` to distinguish
batting strikeouts from pitching strikeouts in the same model.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 09:31:52 -05:00
cal
6d972114b7 fix: remove Docker Hub registry cache to unblock builds
All checks were successful
Build Docker Image / build (push) Successful in 8m19s
Registry cache export consistently fails with 400 Bad Request from
Docker Hub, likely due to blob size limits on the free tier after the
base image change. Removing cache-from/cache-to entirely — builds are
fast enough without it (~2 min), and we can re-add with a local cache
backend later if needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 17:11:08 +00:00
cal
84a45d9caa fix: use mode=min for Docker build cache to avoid Hub blob limits
Some checks failed
Build Docker Image / build (push) Failing after 8m12s
mode=max pushes all intermediate layers to Docker Hub as cache, which
exceeds blob size limits when the base image changes. mode=min only
caches final image layers — smaller push, still provides cache hits
for the most common rebuild scenario (code changes, same base).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 17:02:15 +00:00
cal
47dcdf00c4 fix: switch to python:3.11-slim-bookworm base image
Some checks failed
Build Docker Image / build (push) Failing after 8m12s
The tiangolo/uvicorn-gunicorn-fastapi image moved to Debian Trixie
(testing) which Playwright doesn't support — install-deps fails on
renamed font packages. The tiangolo image only adds uvicorn/gunicorn
which are already in requirements.txt, so switch to the official Python
slim-bookworm image directly. Also removes the old commented-out Chrome
manual install block that hasn't been used since the Playwright migration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 16:42:51 +00:00
cal
a6cf4eea01 fix: pin base image to Debian Bookworm for Playwright compatibility
Some checks failed
Build Docker Image / build (push) Failing after 57s
The tiangolo base image recently moved to Debian Trixie (testing), which
Playwright doesn't support yet. `playwright install-deps` fails because
ttf-unifont and ttf-ubuntu-font-family packages were renamed/removed in
Trixie. Pinning to slim-bookworm (Debian 12) restores compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 16:40:04 +00:00
cal
569dc07864 Merge pull request 'feat: persistent browser instance for card rendering (#89)' (#97) from ai/paper-dynasty-database#89 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 4m50s
Reviewed-on: #97
2026-03-16 16:21:29 +00:00
Cal Corum
f471354e39 feat: persistent browser instance for card rendering (#89)
Replace per-request Chromium launch/teardown with a module-level
persistent browser. get_browser() lazy-initializes with is_connected()
auto-reconnect; shutdown_browser() is wired into FastAPI lifespan for
clean teardown. Pages are created per-request and closed in a finally
block to prevent leaks.

Also fixed pre-existing ruff errors in staged files (E402 noqa comments,
F541 f-string prefix removal, F841 unused variable rename) that were
blocking the pre-commit hook.

Closes #89

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 11:20:42 -05:00
cal
07caa613d4 Merge pull request 'feat: render pipeline optimization (Phase 0)' (#94) from feature/render-pipeline-optimization into main
Some checks failed
Build Docker Image / build (push) Failing after 7m19s
Reviewed-on: #94
2026-03-16 16:15:40 +00:00
cal
32ca21558e Merge pull request 'feat: Track Catalog API endpoints (WP-06) (#71)' (#86) from ai/paper-dynasty-database#71 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 4m43s
Reviewed-on: #86
2026-03-16 16:14:58 +00:00
cal
01c8aa140c Merge pull request 'feat: PlayerSeasonStats Peewee model (#67)' (#82) from ai/paper-dynasty-database#67 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #82
2026-03-16 16:13:06 +00:00
cal
223743d89f Merge pull request 'feat: evolution track seed data and tests (WP-03) (#68)' (#83) from ai/paper-dynasty-database#68 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #83
2026-03-16 16:12:18 +00:00
cal
44763a07ec Merge pull request 'feat: formula engine for evolution value computation (WP-09) (#74)' (#85) from ai/paper-dynasty-database#74 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #85
2026-03-16 16:10:42 +00:00
cal
8d0111df32 Merge pull request 'fix: batch Paperdex lookups to avoid N+1 queries (#17)' (#53) from ai/paper-dynasty-database#17 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #53
Reviewed-by: Claude <cal.corum+openclaw@gmail.com>
2026-03-16 16:09:54 +00:00
cal
8a437c7ef3 Merge pull request 'fix: remove stub live_update_pitching endpoint (#11)' (#57) from ai/paper-dynasty-database#11 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #57
Reviewed-by: Claude <cal.corum+openclaw@gmail.com>
2026-03-16 16:09:13 +00:00
Cal Corum
6ab50ba5f2 fix: add asyncio.Lock to get_browser() and deduplicate font-face blocks
All checks were successful
Build Docker Image / build (pull_request) Successful in 3m32s
Address two review findings from PR #94:

1. Race condition: concurrent requests could both launch Chromium when
   _browser is None. Wrap the init check in asyncio.Lock so only one
   coroutine creates the browser process.

2. Font duplication: the WOFF2 files are variable fonts covering all
   needed weights. Consolidate 5 @font-face blocks (3x Open Sans,
   2x Source Sans 3) into 2 using CSS font-weight range syntax,
   saving ~163KB of redundant base64 per render.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 08:28:58 -05:00
Cal Corum
c262bb431e feat: render pipeline optimization (Phase 0)
All checks were successful
Build Docker Image / build (pull_request) Successful in 3m57s
- Persistent Chromium browser instance with auto-reconnect (WP-02)
- FastAPI lifespan hooks for browser startup/shutdown (WP-03)
- Self-hosted WOFF2 fonts via base64 embedding, remove Google Fonts CDN (WP-01)
- Fix pre-existing lint issues (unused imports, f-string placeholders)

Eliminates ~1.5s browser spawn overhead and ~0.4s font CDN round-trip
per card render. Target: per-card render from ~3s to <1s.

Refs: #88, #89, #90

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 00:06:58 -05:00
Cal Corum
ddf6ff5961 feat: Track Catalog API endpoints (WP-06) (#71)
Closes #71

Adds GET /api/v2/evolution/tracks and GET /api/v2/evolution/tracks/{track_id}
endpoints for browsing evolution tracks and their thresholds.  Both endpoints
require Bearer token auth and return a track dict with formula and t1-t4
threshold fields.  The card_type query param filters the list endpoint.

EvolutionTrack is lazy-imported inside each handler so the app can start
before WP-01 (EvolutionTrack model) is merged into next-release.

Also suppresses pre-existing E402/F541 ruff warnings in app/main.py via
pyproject.toml per-file-ignores so the pre-commit hook does not block
unrelated future commits to that file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 20:40:38 -05:00
Cal Corum
40e988ac9d feat: formula engine for evolution value computation (WP-09)
Closes #74

Adds app/services/formula_engine.py with three pure formula functions
(compute_batter_value, compute_sp_value, compute_rp_value), a dispatch
helper (compute_value_for_track), and a tier classifier (tier_from_value).
Tier boundaries and thresholds match the locked seed data from WP-03.

Note: pitcher formulas use stats.k (not stats.so) to match the
PlayerSeasonStats model field name introduced in WP-02.

19 unit tests in tests/test_formula_engine.py — all pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 19:34:40 -05:00
Cal Corum
25f04892c2 feat: evolution track seed data and tests (WP-03) (#68)
Closes #68

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 17:35:12 -05:00
Cal Corum
8dfc5ef371 fix: remove evolution models from WP-02 PR (#82)
Evolution models (EvolutionTrack, EvolutionCardState, EvolutionTierBoost,
EvolutionCosmetic), their re-export module, and tests were included in
this PR without disclosure. Removed to keep this PR scoped to
PlayerSeasonStats (WP-02) only per review feedback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 17:02:00 -05:00
Cal Corum
4bfd878486 feat: add PlayerSeasonStats Peewee model (#67)
Closes #67

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 16:35:02 -05:00
Cal Corum
4445acb7d0 fix: materialize final_players queryset before double-iteration in get_random_player
When no position filters are applied, `final_players` is a lazy Peewee queryset
with `ORDER BY RANDOM() LIMIT n`. Iterating it twice (once to build player_ids,
once for the response loop) executes two separate DB queries with different random
seeds, causing dex_by_player to be built for a different player set than returned,
silently producing empty paperdex for all players.

Add `final_players = list(final_players)` before building player_ids to ensure
both iterations operate on the same materialized result. Also fix pre-existing
syntax error in import statement and minor ruff lint issues in the same file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 14:03:26 -05:00
cal
a66ef9bd7c Merge pull request 'fix: use max() for pitcher OPS split weighting (#6)' (#60) from ai/paper-dynasty-database#6 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 5m11s
Reviewed-on: #60
2026-03-10 14:42:59 +00:00
cal
6afb2773fe Merge pull request 'chore: pin all Python dependency versions in requirements.txt (#64)' (#65) from ai/paper-dynasty-database#64 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 4m21s
Reviewed-on: #65
2026-03-10 14:06:40 +00:00
Cal Corum
f37217af25 chore: pin all Python dependency versions in requirements.txt (#64)
- Pin all 14 dependencies to exact versions (==)
- Remove duplicate python-multipart entry
- Upgrade numpy from floor constraint (<2) to exact pin (1.26.4, latest 1.x)
- Pin Dockerfile base image from :latest to :python3.11

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 01:35:31 -05:00
cal
b6290226d5 Merge pull request 'fix: remove stray syntax error in players.py db_engine import' (#63) from next-release into main
All checks were successful
Build Docker Image / build (push) Successful in 1m3s
Reviewed-on: #63
2026-03-09 14:55:00 +00:00
Cal Corum
7f139770d1 fix: remove stray syntax error in players.py db_engine import
Some checks failed
Build Docker Image / build (push) Failing after 6m28s
Build Docker Image / build (pull_request) Successful in 3m19s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 09:43:03 -05:00
cal
dfe637c808 Merge pull request 'fix: remove stray syntax error in teams.py db_engine import' (#62) from next-release into main
All checks were successful
Build Docker Image / build (push) Successful in 52s
Reviewed-on: #62
2026-03-09 14:40:04 +00:00
Cal Corum
3b7bb2b6b5 fix: remove stray syntax error in teams.py db_engine import
All checks were successful
Build Docker Image / build (push) Successful in 49s
Build Docker Image / build (pull_request) Successful in 46s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:36:41 +00:00
cal
7b8b7b9c01 Merge pull request 'Release: Scouting API, roster refactor, and bug fixes' (#61) from next-release into main
Some checks failed
Build Docker Image / build (push) Failing after 7m5s
Reviewed-on: #61
2026-03-09 14:12:41 +00:00
Cal Corum
4f2513ae8b fix: use max() for pitcher OPS split weighting (#6)
Starters face both LHH and RHH, so the OPS aggregation formula should
penalise the weaker platoon split (higher OPS allowed) rather than
reward the stronger one. Changed min(ops_vl, ops_vr) → max(ops_vl, ops_vr)
in both get_total_ops (line 621) and sort_starters (line 703) and
replaced the TODO comment with an explanatory note.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 16:32:56 -06:00
Cal Corum
c3732ef33e fix: remove stub live_update_pitching endpoint (#11)
The /live-update/pitching POST endpoint was a placeholder that only
validated auth and returned the input unchanged. No pitching processing
logic existed anywhere in the codebase. Removed the dead endpoint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 01:37:52 -06:00
Cal Corum
2c4ff01ff8 fix: batch Paperdex lookups to avoid N+1 queries (#17)
Replace per-player/card Paperdex.select().where() calls with a single
batched query grouped by player_id. Eliminates N+1 queries in:
- players list endpoint (get_players, with inc_dex flag)
- players by team endpoint
- cards list endpoint (also materializes query to avoid double count())

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 01:37:03 -06:00
cal
7295e77c96 Merge pull request 'fix: refactor Roster from 26 FK columns to RosterSlot junction table (#29)' (#58) from ai/paper-dynasty-database#29 into next-release
Some checks failed
Build Docker Image / build (push) Successful in 3m28s
Build Docker Image / build (pull_request) Has been cancelled
Reviewed-on: #58
2026-03-07 03:23:41 +00:00
cal
be02ba1e3f Merge pull request 'fix: remove broken live_update_batting stub endpoint (#10)' (#54) from ai/paper-dynasty-database#10 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #54
2026-03-07 03:22:08 +00:00
cal
3ddb7028f3 Merge pull request 'fix: replace broad except Exception blocks with DoesNotExist (#15)' (#48) from ai/paper-dynasty-database#15 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #48
2026-03-07 03:18:56 +00:00
cal
f1769966a0 Merge pull request 'fix: batch BattingCard/BattingCardRatings lookups in lineup builder (#18)' (#45) from ai/paper-dynasty-database#18 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #45
2026-03-07 03:16:12 +00:00
Cal Corum
10983138a9 ci: Use docker-tags composite action for multi-channel release support
All checks were successful
Build Docker Image / build (push) Successful in 3m9s
Adds next-release branch trigger and replaces separate dev/production
build steps with the shared docker-tags action for tag resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 15:40:06 -06:00
Cal Corum
44b6222ad5 fix: refactor Roster from 26 FK columns to RosterSlot junction table (#29)
- Remove card_1..card_26 FK columns from Roster ORM model
- Add RosterSlot model with (roster, slot, card) and a unique index on (roster, slot)
- Activate get_cards() helper on Roster using the new junction table
- Register RosterSlot in create_tables for SQLite dev environments
- Add migrations/migrate_roster_junction_table.py to backfill existing data

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:34:39 -06:00
Cal Corum
7b494faa99 fix: remove broken live_update_batting stub endpoint (#10)
The endpoint iterated over `files.vl_basic` (a string, not parsed CSV),
causing it to loop over individual characters. The body contained only
`pass` with TODO comments and no running stats logic. Removed the
endpoint entirely along with the dead commented-out csv helper code.
The `BattingFiles` model is retained as it is still used by
`live_update_pitching`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:34:06 -06:00
Cal Corum
0c042165b7 fix: replace broad except Exception blocks with DoesNotExist (#15)
Replace 71 broad `except Exception` blocks in 19 router files with the
specific `peewee.DoesNotExist` exception. GET endpoints that call
`Model.get_by_id()` now only catch the expected DoesNotExist error,
allowing real DB failures (connection errors, etc.) to propagate as
500s rather than being masked as 404s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:32:53 -06:00
Cal Corum
62b205bde2 fix: batch BattingCard/BattingCardRatings lookups in lineup builder (#18)
Replace per-player get_or_none() calls in get_bratings() with two bulk
SELECT queries before the position loop, keyed by player_id and card+hand.
This reduces DB round trips from O(3N) to O(2) for all lineup difficulties.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:31:13 -06:00