# Context Window Handoff - Cleanup Work in Progress **Date**: 2025-01-14 **Current Session**: Cleanup of proposed changes from demo review **Status**: Session 1 Part 3 Complete (3/11 changes done - 27%) --- ## Copy This Prompt to New Context Window ``` I'm continuing cleanup work on the Paper Dynasty / SBA web app. We're making changes based on a review of the frontend demo pages. Current status: Session 1 Part 3 complete (3/11 changes done). Now continuing with Session 1 Part 4. Please read these files for full context: - @.claude/PROPOSED_CHANGES_2025-01-14.md (master list of all 11 changes) Key decisions from Cal: 1. Remove supports_manual_result_selection() - ✅ DONE (Part 1) 2. Pitching change player ID - Will use league-independent polymorphic Player ID 3. Remove defensive alignment & offensive approach - ✅ ALIGNMENT DONE (Part 3), approach next 4. Offensive workflow refactor - YES, do before Phase F6 (last thing in cleanup) 5. Hit location fix - ✅ DONE (Part 2): GROUNDOUT, FLYOUT, LINEOUT, SINGLE_UNCAPPED, DOUBLE_UNCAPPED, ERROR Completed (Session 1 Parts 1-3): ✅ Part 1: Removed strikes_for_out, balls_for_walk, supports_manual_result_selection() ✅ Part 2: Fixed hit location requirements (reduced from 11 to 6 outcomes) ✅ Part 3: Removed defensive alignment field (11 files modified) Current TODO list (in TodoWrite): - [completed] Fix hit location requirements in ManualOutcomeEntry.vue - [completed] Remove defensive alignment from DefensiveDecision model - [pending] Remove offensive approach from OffensiveDecision model - [pending] Add infield depth validation (infield_in, corners_in, normal) - [pending] Add outfield depth validation (normal, shallow with walk-off rules) - [pending] Refactor offensive decision workflow (swing_away, check_jump, hit_and_run, sac_bunt, squeeze_bunt) - [pending] Add check jump validation (lead runner only) Workflow: - Session 1: Quick wins (Changes #1-5) - 60% COMPLETE (Parts 4-5 remaining) - Session 2: Standard changes (Changes #6-7) - NOT STARTED - Session 3: Major refactor (Changes #8-11) - NOT STARTED Dev server is running at http://localhost:3005 with demo pages. Please continue from Session 1 Part 4: Remove offensive approach field from OffensiveDecision model. ``` --- ## Files Modified So Far ### Session 1 Part 3: Remove Defensive Alignment (11 files) **Backend** (5 files): 1. `backend/app/models/game_models.py` - Removed `alignment` field from DefensiveDecision (line 154) - Removed `validate_alignment()` method (lines 159-166) 2. `backend/terminal_client/display.py` - Removed alignment from defensive decision display (line 191) 3. `backend/app/core/ai_opponent.py` - Updated log message to remove alignment reference (line 82) 4. `backend/tests/unit/models/test_game_models.py` - Removed 3 alignment tests (lines 235-245) 5. `backend/tests/unit/core/test_validators.py` - Removed test_validate_defensive_decision_invalid_alignment (lines 180-191) **Frontend** (3 files): 1. `frontend-sba/types/game.ts` - Removed `alignment` field from DefensiveDecision interface (line 125) 2. `frontend-sba/components/Decisions/DefensiveSetup.vue` - Removed "Defensive Alignment" section (lines 19-31) - Removed `alignment` from localSetup (line 154) - Removed `alignmentOptions` array (lines 175-180) - Removed `alignmentDisplay` computed (lines 197-200) - Removed `alignment` from hasChanges (line 226) - Reorganized preview grid (alignment row removed, holding now col-span-2) **Git commits**: - Commit 2f0f35f: Hit location fix - Commit 197d91e: Defensive alignment removal **Tests**: ✅ All 728 backend unit tests passing --- ### Session 1 Part 2: Fix Hit Location Requirements (1 file) **Frontend**: 1. `frontend-sba/components/Gameplay/ManualOutcomeEntry.vue:152-160` - Reduced `outcomesNeedingHitLocation` from 11 to 6 outcomes - Removed: SINGLE_1, SINGLE_2, DOUBLE_2, DOUBLE_3, TRIPLE - Kept: GROUNDOUT, FLYOUT, LINEOUT, SINGLE_UNCAPPED, DOUBLE_UNCAPPED, ERROR --- ### Session 1 Part 1: Remove Unused Config Fields (2 files) ### backend/app/config/base_config.py **Changes**: Removed 3 items - Line 27: `strikes_for_out` field - Line 28: `balls_for_walk` field - Lines 41-48: `supports_manual_result_selection()` method **Current state**: Clean, tests passing ### backend/tests/unit/config/test_league_configs.py **Changes**: Updated 2 test methods - `test_sba_basic_rules`: Removed assertions for strikes/balls - `test_sba_supports_auto_mode`: Renamed from manual_selection, tests auto mode - `test_pd_basic_rules`: Removed assertions for strikes/balls - `test_pd_supports_auto_mode`: Renamed from manual_selection, tests auto mode **Current state**: 28/28 tests passing --- ## Next Steps (Session 1 Part 4) ### Change #7: Remove Offensive Approach **Pattern**: Same as Part 3 (defensive alignment removal) **Files to Modify**: **Backend** (~5 files): 1. `backend/app/models/game_models.py` - OffensiveDecision class - Remove `approach` field (currently line ~193) - Remove `validate_approach()` method if exists 2. `backend/terminal_client/display.py` - Remove approach from offensive decision display (~line 196-197) 3. `backend/app/core/ai_opponent.py` - Update offensive decision generation (remove approach) 4. `backend/tests/unit/models/test_game_models.py` - Remove approach-related tests 5. `backend/tests/unit/core/test_validators.py` - Remove approach validation test if exists **Frontend** (~3 files): 1. `frontend-sba/types/game.ts` - Remove `approach` field from OffensiveDecision interface 2. `frontend-sba/components/Decisions/OffensiveApproach.vue` - Remove "Batting Approach" section from template - Remove `approach` from localSetup - Remove approachOptions array - Remove approachDisplay computed - Remove approach from hasChanges 3. Check for any other usages: - Grep for `.approach` in frontend **Note**: Offensive approach will be replaced in Session 3 (Change #10) with specific actions: swing_away, check_jump, hit_and_run, sac_bunt, squeeze_bunt. For now, just remove the unused field. **Estimated Time**: 15-20 minutes --- ## Completed Steps ### Change #5: Fix Hit Location Requirements ✅ DONE **Problem**: `frontend-sba/components/Gameplay/ManualOutcomeEntry.vue:152` had: ```typescript const outcomesNeedingHitLocation = [ 'GROUNDOUT', 'FLYOUT', 'LINEOUT', 'SINGLE_1', // ❌ Too broad 'SINGLE_2', // ❌ Too broad 'SINGLE_UNCAPPED', // ✅ Correct 'DOUBLE_2', // ❌ Too broad 'DOUBLE_3', // ❌ Too broad 'DOUBLE_UNCAPPED', // ✅ Correct 'TRIPLE', // ❌ Too broad 'ERROR', // ✅ Correct ] ``` **Correct List** (per Cal): - GROUNDOUT (all groundouts) - FLYOUT (all flyouts) - LINEOUT (all lineouts) - SINGLE_UNCAPPED - DOUBLE_UNCAPPED - ERROR **Files to Update**: 1. `frontend-sba/components/Gameplay/ManualOutcomeEntry.vue:152` - Update array 2. Verify `PlayOutcome.requires_hit_location()` matches in backend (if it exists) **Expected outcome**: Only outcomes that affect defensive plays require hit location --- ## Remaining Work After Session 1 ### Session 2: Standard Changes (2-4 hours) **Change #6**: Remove defensive alignment - File: `backend/app/models/game_models.py` - DefensiveDecision model - File: `frontend-sba/components/Decisions/DefensiveSetup.vue` - Action: Remove `alignment` field completely **Change #7**: Remove offensive approach - File: `backend/app/models/game_models.py` - OffensiveDecision model - File: `frontend-sba/components/Decisions/OffensiveApproach.vue` - Action: Remove `approach` field completely (will be replaced in Change #10) **Change #8**: Add infield depth validation - Valid values: "infield_in", "corners_in", "normal" - Rule: infield_in and corners_in only legal with R3 - Files: validators.py, DefensiveSetup.vue **Change #9**: Add outfield depth validation - Valid values: "normal", "shallow" - Rule: shallow only legal when walk-off possible (home team, bottom 9+, trailing/tied, runner on base) - Files: validators.py, DefensiveSetup.vue ### Session 3: Major Refactor (4+ hours) **Change #10**: Refactor offensive decision model - Replace `approach` field with specific actions - New actions: swing_away, check_jump, hit_and_run, sac_bunt, squeeze_bunt - Validation rules: - squeeze_bunt only with R3 and bases not loaded - check_jump only with runner on base - Files: OffensiveDecision model, OffensiveApproach.vue, tests - **Impact**: Will break 213 Phase F3 tests - need to update **Change #11**: Check jump validation - Rule: Only lead runner or both if 1st and 3rd - No trail runners - Bundle with Change #10 --- ## Git Status **Branch**: `implement-phase-3` **Last Commit**: `eab61ad` - "Phases 3.5, F1-F5 Complete" **Working Tree**: Clean (all previous work committed) **Commits This Session**: - Will need to commit cleanup work when done --- ## Test Status Baseline **Before cleanup started**: - Backend: 731/731 passing (100%) - Frontend: 446/446 passing (100%) **After Session 1 Part 1**: - Backend config tests: 28/28 passing (100%) - Need to verify full suite still passing **Expected after Session 3**: - Backend tests: Will need updates for offensive decision refactor - Frontend tests: 213 F3 tests will need updates --- ## Key Context Files **Master tracking**: - `.claude/PROPOSED_CHANGES_2025-01-14.md` - All 11 changes with analysis - `.claude/TODO_VERIFICATION_RESULTS.md` - What TODOs were already resolved - `.claude/TODO_SUMMARY.md` - Quick reference **Implementation docs**: - `backend/app/config/CLAUDE.md` - Config system docs - `backend/app/models/CLAUDE.md` - Game models docs (will need for Changes #6-11) - `frontend-sba/CLAUDE.md` - Frontend docs **Modified files so far**: - `backend/app/config/base_config.py` - `backend/tests/unit/config/test_league_configs.py` --- ## Important Notes 1. **Dev server running**: http://localhost:3005 for testing frontend changes 2. **Always run tests** after each change 3. **Commit frequently** - don't batch all changes into one commit 4. **Session 3 is complex** - offensive decision refactor affects many files 5. **Follow workflow** - Don't skip to Session 3, do Session 1 & 2 first --- ## Questions Already Answered Q: Remove or keep supports_manual_result_selection()? A: Remove completely ✅ Q: What identifier for pitching change? A: League-independent polymorphic Player ID Q: Remove alignment and approach? A: Yes, remove completely Q: When to do offensive refactor? A: Before Phase F6, as last part of cleanup Q: Hit location requirements? A: Only GROUNDOUT, FLYOUT, LINEOUT, SINGLE_UNCAPPED, DOUBLE_UNCAPPED, ERROR --- **Ready to continue!** Start with Session 1 Part 2: Fix hit location requirements.