Commit Graph
100 Commits
Author SHA1 Message Date
KoalaTrapLord cb38081a8b fix: add top_n cutoff to ELO tournament (default top 10 generations) 2026-03-27 01:48:10 -04:00
KoalaTrapLord cd9d2eebd8 feat(coach): Phase 1 - pass richer card stats to Claude prompt (#108)
- _format_underperformers: add synergyScore, clunkinessScore, avgTurnCast, keptInOpeningHandRate
- _format_top_cards: add synergyScore and avgTurnCast
- _format_matchups: append perArchetypeWinRates block from DeckMeta
- USER_PROMPT_TEMPLATE: add ### Archetype Win Rates section placeholder
2026-03-27 01:32:51 -04:00
KoalaTrapLord e6f18d4a61 feat(training): add intro banner and parameter tooltips to ML Training page 2026-03-27 00:18:21 -04:00
KoalaTrapLord 4e90337f54 feat: extend card hover preview to all card names in coach UI 2026-03-26 23:48:27 -04:00
KoalaTrapLord a01a70f725 Use DEFAULT_MAX_TOKENS config for Anthropic max_tokens 2026-03-26 22:50:10 -04:00
KoalaTrapLord 4da58681a4 Enhance coach prompt for more detailed reports 2026-03-26 22:41:23 -04:00
KoalaTrapLord 224b4b5d5b feat: increase coach detail limits (MAX_UNDERPERFORMERS=8, MAX_TOKENS=16384) 2026-03-26 22:33:18 -04:00
KoalaTrapLord 1a34f00574 Update .env.examplefix: correct model ID in .env.example (claude-opus-4-0 -> claude-opus-4) 2026-03-26 15:50:53 -04:00
KoalaTrapLord 8ec7db1612 fix: correct malformed string literals in config.py model defaults 2026-03-26 15:42:34 -04:00
KoalaTrapLord e0a75e2d04 fix: correct Anthropic model ID from claude-opus-4-0 to claude-opus-4 2026-03-26 15:36:23 -04:00
KoalaTrapLord 15bd6f42bb fix: resolve all ruff linting errors across coach module 2026-03-26 15:30:27 -04:00
KoalaTrapLord 0aa57ab7d2 fix: remove duplicate resp token on line 284 in run_coaching_session (#105) 2026-03-26 14:23:52 -04:00
KoalaTrapLord 9f5eb4a99f fix: add missing resp= assignment on line 284 (#105) 2026-03-26 14:11:35 -04:00
KoalaTrapLord a9f18f53da fix: correct indentation of try/except/else block in run_coaching_session (#105) 2026-03-26 14:06:27 -04:00
KoalaTrapLord c9e932ef43 fix: correct try: block indentation in run_coaching_session (#105) 2026-03-26 13:44:33 -04:00
KoalaTrapLord cb99388e3c fix: correct indentation of total_steps in collect_rollouts 2026-03-26 13:14:34 -04:00
KoalaTrapLord 2e316548e7 fix: repair resp= assignment and _re.sub typo in coach_service.py (#105) 2026-03-26 13:11:55 -04:00
KoalaTrapLord b46e1e0877 fix: remove stray string literal in init_coach_service (#105) 2026-03-26 12:31:52 -04:00
KoalaTrapLord e17b877dcc fix: repair syntax errors in coach_status and init_coach_service (#105) 2026-03-26 12:18:07 -04:00
KoalaTrapLord 6ce21908d3 Update coach.py 2026-03-26 11:53:39 -04:00
KoalaTrapLord 15495483f3 fix: remove _coach_init_error reference from status endpoint (#105) 2026-03-26 11:36:33 -04:00
KoalaTrapLord 540fbbf1b3 fix: remove broken _coach_init_error lines from coach.py (#105) 2026-03-26 10:52:41 -04:00
KoalaTrapLord a5cc7736b4 feat: update thread dropdown to 1,2,4,8,16,24,32 2026-03-25 23:15:38 -04:00
KoalaTrapLord 8c6248cf84 feat: increase max threads from 16 to 32 2026-03-25 21:37:21 -04:00
KoalaTrapLord 22d63fd15e Update coach.py 2026-03-25 21:29:24 -04:00
KoalaTrapLord 2dc0ba2d25 Update coach.py 2026-03-25 21:18:27 -04:00
KoalaTrapLord 8f180820f9 fix: add missing _DEFAULT_ORIGINS definition in lab_api.py (#105) 2026-03-25 21:00:34 -04:00
KoalaTrapLord b283418879 fix: correct indentation in _call_anthropic_api else-block (#105) 2026-03-25 20:43:11 -04:00
KoalaTrapLord 61be42ea6d fix: resolve IndentationError on line 882 in routes/deckgen.py (#105) 2026-03-25 20:18:19 -04:00
KoalaTrapLord 3906b93c6a feat: add WebSocket support for Unity game state streaming (#107)
* feat: add ws/ package for WebSocket game state streaming

* feat: add WebSocket ConnectionManager with per-game broadcasting

* feat: add GameStateTracker with deep-diff delta engine

* feat: add WebSocket route with delta push and REST bridge endpoints

* feat: register ws_game_router in lab_api.py
2026-03-25 19:51:15 -04:00
KoalaTrapLord af2a71d1a5 fix: eliminate event-loop-blocking sync calls in async FastAPI routes (#106)
* feat: add async DB wrapper and eliminate event-loop blocking

* fix: rewrite llm_client.py with native async httpx - removes urlopen and run_in_executor

* fix: rewrite routes/coach.py - replace all sync DB/HTTP with async (aiosqlite + httpx)

* fix: add async DB shutdown hook to lab_api.py

* feat: add aiosqlite>=0.19.0 to requirements
2026-03-25 19:17:41 -04:00
KoalaTrapLord cf7c872e12 feat: update test mock from pplx_client to anthropic_client (#105) 2026-03-25 16:43:11 -04:00
KoalaTrapLord c9227dac70 Update substitution_prompt.pyfeat: update substitution_prompt.py docstring from Perplexity to Claude Opus (#105) 2026-03-25 16:41:47 -04:00
KoalaTrapLord 34b1ea2e30 feat: update deck_gen_user.py docstring from Perplexity to Claude Opus (#105) 2026-03-25 16:41:24 -04:00
KoalaTrapLord 1c6454dce5 feat: update substitution_schema.py source field from perplexity to anthropic (#105) 2026-03-25 16:39:16 -04:00
KoalaTrapLord 464dd732d5 feat: update deck_schema.py docstring from Perplexity to Claude Opus (#105) 2026-03-25 16:36:22 -04:00
KoalaTrapLord f481243c4e feat: replace Perplexity AI with Claude Opus in deckgenerator.html (#105) 2026-03-25 16:33:00 -04:00
KoalaTrapLord f49b6cbea5 feat: replace Perplexity AI spinner text with Claude Opus in deckbuilder.html (#105) 2026-03-25 16:30:00 -04:00
KoalaTrapLord 71f316a220 feat: update status label from Perplexity to Claude Opus in coach.html (#105) 2026-03-25 16:26:31 -04:00
KoalaTrapLord 9556f9d7d0 feat: replace Perplexity with Anthropic Claude in lab_api.py (#105) 2026-03-25 15:18:14 -04:00
KoalaTrapLord 9de0965c78 feat: replace Perplexity with Anthropic Claude in routes/deckgen.py (#105) 2026-03-25 15:09:46 -04:00
KoalaTrapLord 38bfa51d85 feat: replace Perplexity with Anthropic Claude in routes/coach.py (#105) 2026-03-25 14:41:34 -04:00
KoalaTrapLord c58f561df4 feat: replace PerplexityClient with AnthropicClient in deck_generator.py (#105) 2026-03-25 14:34:18 -04:00
KoalaTrapLord 6cf1e58018 feat: replace Perplexity with Anthropic Claude in coach_service.py (#105) 2026-03-25 14:30:40 -04:00
KoalaTrapLord 1382d25e46 feat: update clients __init__.py comment to reference Anthropic (#105) 2026-03-25 12:25:56 -04:00
KoalaTrapLord d8f7105471 feat: replace PPLX_API_KEY with ANTHROPIC_API_KEY in install script (#105) 2026-03-25 12:25:01 -04:00
KoalaTrapLord 071088715f feat: replace PPLX_API_KEY with ANTHROPIC_API_KEY in start-lab.bat (#105) 2026-03-25 12:23:43 -04:00
KoalaTrapLord 95429d9f35 feat: replace PPLX_API_KEY with ANTHROPIC_API_KEY in .env.example (#105) 2026-03-25 12:21:40 -04:00
KoalaTrapLord 55379a98ef feat: replace Perplexity config with Anthropic Claude settings (#105) 2026-03-25 12:20:33 -04:00
KoalaTrapLord 173dee6ccc feat: add anthropic>=0.40.0 and openai>=1.0.0 to requirements (#105) 2026-03-25 12:17:52 -04:00
KoalaTrapLord 34dee24399 feat: add AnthropicClient as drop-in replacement for PerplexityClient (closes #105 phase 1) 2026-03-25 12:16:14 -04:00
KoalaTrapLord 88f1022d0e fix: deduplicate card names globally before Scryfall batch lookup
enforce_deck_ratios can return the same card name under multiple
categories (e.g. Teferi's Protection in both protection + synergy).
all_card_names had no cross-category dedup, so get_cards_by_names
returned duplicate CardEntry objects that then failed the singleton
validator in CommanderDeck.

Fix: build all_card_names with dict.fromkeys() across all categories
so each name appears exactly once. Also deduplicate after Scryfall
lookup by name as a second safety net.
2026-03-25 11:23:06 -04:00
KoalaTrapLord 737863c55d fix: .env.example default COACH_PROVIDER to perplexity 2026-03-25 10:43:42 -04:00
KoalaTrapLord e710287c35 fix: run_coaching_session respects COACH_PROVIDER for Perplexity API
The coaching pipeline in coach_service.py was always calling self.llm (Ollama) regardless of COACH_PROVIDER setting. Now branches on COACH_PROVIDER == 'perplexity' to call the Perplexity API directly via httpx, matching the pattern used in routes/coach.py coach_chat endpoint.
2026-03-25 10:42:49 -04:00
KoalaTrapLord 2e3c1ec0f1 fix: startup logs and DeckBuilderAdapter respect COACH_PROVIDER/DECK_GEN_PROVIDER instead of hardcoding Ollama 2026-03-25 10:34:04 -04:00
KoalaTrapLord 21f032d32e fix: set DECK_GEN_PROVIDER default to perplexity and DECK_GEN_MODEL to sonar-pro 2026-03-25 10:29:54 -04:00
KoalaTrapLord 2881309d41 fix: set COACH_PROVIDER default to perplexity, remove stale DeepSeek comment 2026-03-25 10:13:58 -04:00
KoalaTrapLord e162d50608 feat: bulk quantity edit for collection table 2026-03-25 10:12:03 -04:00
KoalaTrapLord 49bab7fb0a fix: set FORGE_DIR to repo root so cardsfolder path resolves correctly 2026-03-25 10:09:10 -04:00
KoalaTrapLord 34e88a3a14 fix: correct indentation of commander_keywords and oracle overlap scoring in deckgen.py 2026-03-25 08:45:51 -04:00
KoalaTrapLord f199bcfa34 feat: column visibility toggle UI for collection table 2026-03-25 08:31:12 -04:00
KoalaTrapLord 77c92d569d fix: correct indentation of elif/else branches in _run_sim_thread_deepseek 2026-03-25 08:24:21 -04:00
KoalaTrapLord f24bd05be8 feat: collection stats dashboard (CMC curve, color/type/rarity/value) 2026-03-25 07:51:09 -04:00
KoalaTrapLord e7ffccf3e8 feat: persist coach sessions to SQLite with disk fallback 2026-03-24 23:44:20 -04:00
KoalaTrapLord 64a65ca2f6 feat: auto-fill deck name with Auto - {CommanderName} on select 2026-03-24 23:19:17 -04:00
KoalaTrapLord 3ba44f68d9 feat: oracle-text keyword overlap scoring in _generate_deck 2026-03-24 22:56:30 -04:00
KoalaTrapLord f851df6dbf fix: add getBaseUrl(), PolicyDecision record, and decide(String,int) to PolicyClient
GameSession.java references these APIs which were missing from
PolicyClient, causing 3 compilation errors. Added:
- getBaseUrl() getter
- PolicyDecision record (action, confidence)
- decide(String, int) overload that delegates to decide(JsonObject)
2026-03-24 22:46:45 -04:00
KoalaTrapLord ded79bfde1 feat: add omit_cards chips styles to deck generator CSS 2026-03-24 22:20:10 -04:00
KoalaTrapLord 411e40e46e feat: add omit_cards chips panel to deck generator HTML 2026-03-24 22:17:25 -04:00
KoalaTrapLord a4e49daf49 feat: add omit_cards chips/tags input to deck generator JS 2026-03-24 22:11:36 -04:00
KoalaTrapLord 675c64029b feat: add progress bar + ETA to deck generation UI 2026-03-24 21:20:47 -04:00
KoalaTrapLord 4c47b9d5e2 fix: add V3 result cache to avoid re-generating deck on export 2026-03-24 21:07:59 -04:00
KoalaTrapLord 8903432d67 fix: add missing export filter params (rarity, setCode, power, toughness, keyword, edhrec, qty) 2026-03-24 21:01:35 -04:00
KoalaTrapLord b1e473397f fix: shopping list field name + scan-add refresh function name 2026-03-24 20:53:19 -04:00
KoalaTrapLord 07b2c9d5a9 fix: add missing LLM_TIMEOUT constant in coach.py
LLM_TIMEOUT was referenced but never defined, causing a NameError
in the Ollama streaming SSE code path when COACH_PROVIDER != 'perplexity'.
2026-03-24 20:43:36 -04:00
KoalaTrapLord 58bbb514ad fix: skip ML decision flush when brain not connected (heuristic fallback guard) 2026-03-24 20:27:02 -04:00
KoalaTrapLord d70d74d753 feat: add Scryfall on-the-fly embedding fallback for unknown cards 2026-03-24 20:09:27 -04:00
KoalaTrapLord 475849e477 fix: prevent double-flush of ML decisions in deepseek sim thread
_run_sim_thread_deepseek was manually calling engine.flush_ml_decisions()
and writing the .jsonl, then passing engine=engine to _finish_sim which
called flush_ml_decisions() a second time — returning an empty list and
producing empty training data files.

Fix: pass engine=None to _finish_sim when the deepseek thread has already
flushed manually, so _finish_sim skips the second flush entirely.
2026-03-24 19:19:45 -04:00
KoalaTrapLord b2d1078ca9 fix: disable quiet mode when ML logging is enabled in createWorker
DecisionExtractor requires verbose Forge output to reconstruct board
states. When quiet=true, Forge runs with -q which strips the verbose
log lines, causing 0 decisions to be extracted. This change passes
quiet=false to BatchRunner when mlLogEnabled is true.
2026-03-24 18:45:36 -04:00
KoalaTrapLord 9bce919690 fix: replace non-existent ForgeEpisodeGenerator import with actual exports 2026-03-24 13:45:48 -04:00
KoalaTrapLord 41b711c17e fix: normalize deck report slug matching (spaces/hyphens/underscores) 2026-03-24 13:31:52 -04:00
KoalaTrapLord a6940ca61a fix: update get_status() to check Perplexity connection when COACH_PROVIDER=perplexity 2026-03-24 13:29:16 -04:00
KoalaTrapLord a65daaf801 fix: update Deck Coach status label from LM Studio to Perplexity 2026-03-24 13:26:41 -04:00
KoalaTrapLord c475f5998b docs: add COACH_PROVIDER to .env.example 2026-03-24 12:54:30 -04:00
KoalaTrapLord 456ef927f9 feat: add Perplexity deep research support to coach chat endpoint 2026-03-24 12:53:42 -04:00
KoalaTrapLord a515049542 feat: add COACH_PROVIDER config for Perplexity-powered coach chat 2026-03-24 12:50:21 -04:00
KoalaTrapLord 457e6f91c8 docs: add PPLX_MODEL to .env.example 2026-03-24 12:47:58 -04:00
KoalaTrapLord 977dbd96d7 feat: use PPLX_MODEL config instead of hardcoded 'sonar' in deckgen 2026-03-24 12:47:09 -04:00
KoalaTrapLord 5a499442e6 feat: add PPLX_MODEL env var for configurable Perplexity model 2026-03-24 12:45:40 -04:00
KoalaTrapLord 1f3b17d173 fix: remove ForgeEpisodeQueue import from training __init__
ForgeEpisodeQueue does not exist in rollout_buffer.py yet.
Removing premature import to unblock supervised training pipeline.
2026-03-24 12:26:06 -04:00
KoalaTrapLord f51ff61568 feat(83): Phase 3 — Performance & Scale (#83) (#101)
* feat(83): Phase 3.1 — persistent JVM worker pool in MultiThreadBatchRunner (#83)

* feat(83): Phase 3.2 — async Forge episode generator with producer-consumer pipeline (#83)

* feat(83): Phase 3.3 — deprecate self_play.py synthetic mode for training (#83)

Mark self_play.py synthetic training as deprecated per Phase 3.3:
- Add deprecation notice to module docstring
- Add import warnings and _TRAINING_DEPRECATION_MSG constant
- Add DeprecationWarning in collect_rollouts()
- Synthetic sim retained for local testing/unit tests only
- scope.py already defaults forge_weight=1.0, ppo_weight=0.0

* feat(83): Phase 3.3 — update ml/training/__init__.py exports (#83)
2026-03-24 10:43:51 -04:00
KoalaTrapLord 39bc36afef rename: update JsonExporter.java javadoc example from batch- to ml-decision- 2026-03-23 23:10:44 -04:00
KoalaTrapLord dffd89a01c rename: update LabCli.java default output from batch-latest to ml-decision-latest 2026-03-23 23:09:51 -04:00
KoalaTrapLord 015b9da1e9 rename: update forge_runner.py file prefix from batch- to ml-decision- 2026-03-23 23:06:33 -04:00
KoalaTrapLord f9007effa3 rename: update report_generator.py glob from batch- to ml-decision- 2026-03-23 23:05:25 -04:00
KoalaTrapLord 29ad996966 rename: batch-sim- to ml-decision-sim- prefix in deepseek.py 2026-03-23 23:04:13 -04:00
KoalaTrapLord 51b4e9b5ff rename: batch result files from batch- to ml-decision- prefix in lab.py 2026-03-23 23:00:24 -04:00
KoalaTrapLord 573a271561 fix: use correct query param format for batch status endpoint in overnight-batch.py
The /api/lab/status endpoint uses ?batchId= query param, not path param /{batch_id}
2026-03-23 22:19:21 -04:00
KoalaTrapLord 411fa41063 feat(83): Phase 2 — Live Forge-to-Policy-Server IPC (#100)
* feat(83): add PolicyClient for live Forge-to-policy-server IPC (#83)

Phase 2.1: Bridge between Forge decision points and Python policy
server for online training. Calls /api/policy/decide endpoint,
collects (state, action, reward) tuples in real-time, and flushes
them to the server for online PPO updates.

Falls back to Forge built-in AI if server is unavailable.

* feat(83): add /api/policy/* routes for live Forge IPC (#83)

Phase 2.2: Policy decision routes for real-time Forge IPC.

- POST /api/policy/decide — full game state inference with log_prob/value
- POST /api/policy/collect — online learning tuple batch collection
- POST /api/policy/reward — end-of-game reward propagation
- GET /api/policy/health — readiness check for Java PolicyClient
- GET /api/policy/stats — session statistics

Includes Forge phase mapping and PlayerZoneState with full zone contents.

* feat(83): integrate PolicyClient into GameSession for bidirectional sync (#83)
2026-03-23 22:08:37 -04:00
87404f3702 refactor: move logging out of routes/shared.py into services/logging.py (#99)
Create services/logging.py as the canonical home for setup_logging(),
all log format constants, named loggers, and _ml_logging_enabled.

Update all route modules and lab_api.py to import logging symbols from
services.logging and all other symbols from their canonical sources
(models.state, models.requests, models.responses, services.database,
services.deck_service, services.scryfall, services.import_helpers,
services.import_service, services.precon_service, services.forge_runner).

Delete routes/shared.py — the re-export hub is no longer needed.

Closes #61

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 21:04:25 -04:00