strat-gameplay-webapp/.claude/HANDOFF_PROMPT_CLEANUP.md
Cal Corum 63bffbc23d CLAUDE: Session 1 cleanup complete - Parts 4-6
Completed remaining Session 1 work:

Part 4: Remove offensive approach field
- Removed `approach` field from OffensiveDecision model
- Removed approach validation and validator
- Updated 7 backend files (model, tests, handlers, AI, validators, display)

Part 5: Server-side depth validation
- Added walk-off validation for shallow outfield (home batting, 9th+, close game, runners)
- Updated outfield depths from ["in", "normal"] to ["normal", "shallow"]
- Infield validation already complete (corners_in/infield_in require R3)
- Added comprehensive test coverage

Part 6: Client-side smart filtering
- Updated DefensiveSetup.vue with dynamic option filtering
- Infield options: only show infield_in/corners_in when R3 present
- Outfield options: only show shallow in walk-off scenarios
- Hybrid validation (server authority + client UX)

Total Session 1: 25 files modified across 6 parts
- Removed unused config fields
- Fixed hit location requirements
- Removed alignment/approach fields
- Added complete depth validation

All backend tests passing (730/731 - 1 pre-existing failure)

Next: Session 2 - Offensive decision workflow refactor (Changes #10-11)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 13:54:34 -06:00

254 lines
8.8 KiB
Markdown

# Context Window Handoff - Cleanup Work COMPLETE
**Date**: 2025-01-14
**Current Session**: Session 1 COMPLETE ✅
**Status**: All Session 1 changes complete (6/11 total changes done - 55%)
---
## Session 1 Complete Summary
**✅ ALL QUICK WINS COMPLETE**
Session 1 tackled all the quick wins and straightforward changes:
- Parts 1-3: Removed unused fields (strikes_for_out, balls_for_walk, supports_manual_result_selection, defensive alignment, offensive approach)
- Part 4: Fixed hit location requirements
- Parts 5-6: Added complete infield/outfield depth validation (both server and client)
**Result**: Clean codebase ready for Session 2 (major offensive workflow refactor)
---
## Copy This Prompt to New Context Window
```
I'm continuing cleanup work on the Paper Dynasty / SBA web app based on demo review.
**STATUS**: Session 1 COMPLETE ✅ (6/11 changes done - 55%)
Please read for context:
- @.claude/PROPOSED_CHANGES_2025-01-14.md (master list of all 11 changes)
- @.claude/HANDOFF_PROMPT_CLEANUP.md (this file - progress tracking)
**Completed in Session 1** (Changes #1-5, #6-7 partial):
✅ Removed: strikes_for_out, balls_for_walk, supports_manual_result_selection()
✅ Fixed hit location requirements (6 outcomes instead of 11)
✅ Removed defensive alignment field completely
✅ Removed offensive approach field completely
✅ Added server-side depth validation (infield_in/corners_in require R3, shallow requires walk-off)
✅ Added client-side smart filtering (DefensiveSetup.vue dynamically shows/hides options)
**Remaining Work** (Changes #8-11):
❌ Session 2: Offensive Decision Workflow Refactor (MAJOR - 4+ hours)
- Replace removed `approach` field with specific actions
- New fields: swing_away, check_jump, hit_and_run, sac_bunt, squeeze_bunt
- Add validation (squeeze_bunt requires R3 + not loaded, check_jump requires lead runner)
- Update backend model, validators, tests
- Update frontend OffensiveApproach.vue component
- Expected impact: ~10-15 files, will break some tests
Dev servers running:
- Backend: http://localhost:8000
- Frontend: http://localhost:3001 (SBA)
Ready to start Session 2: Offensive Decision Workflow Refactor
```
---
## Files Modified in Session 1
### Part 1: Remove Unused Config Fields (2 files)
- `backend/app/config/base_config.py` - Removed 3 unused fields/methods
- `backend/tests/unit/config/test_league_configs.py` - Updated tests
### Part 2: Fix Hit Location Requirements (1 file)
- `frontend-sba/components/Gameplay/ManualOutcomeEntry.vue` - Reduced from 11 to 6 outcomes
### Part 3: Remove Defensive Alignment (11 files)
**Backend** (5 files):
- `backend/app/models/game_models.py` - Removed alignment field/validator
- `backend/terminal_client/display.py` - Removed from display
- `backend/app/core/ai_opponent.py` - Updated logs
- `backend/tests/unit/models/test_game_models.py` - Removed tests
- `backend/tests/unit/core/test_validators.py` - Removed tests
**Frontend** (6 files):
- `frontend-sba/types/game.ts` - Removed from interface
- `frontend-sba/types/websocket.ts` - Removed from interface
- `frontend-sba/components/Decisions/DefensiveSetup.vue` - Removed UI section
- `frontend-sba/components/Decisions/DecisionPanel.vue` - Removed references
- `frontend-sba/pages/demo-decisions.vue` - Removed from demo
- `frontend-sba/pages/games/[id].vue` - Removed references
### Part 4: Remove Offensive Approach (7 files)
**Backend** (7 files):
- `backend/app/models/game_models.py` - Removed approach field/validator
- `backend/tests/unit/models/test_game_models.py` - Removed approach tests
- `backend/app/websocket/handlers.py` - Removed approach from event handler
- `backend/app/core/ai_opponent.py` - Updated logging
- `backend/app/core/validators.py` - Removed approach validation
- `backend/terminal_client/display.py` - Removed from display
- `backend/tests/unit/core/test_validators.py` - Removed/updated tests
### Parts 5-6: Add Depth Validation (4 files)
**Backend** (3 files):
- `backend/app/core/validators.py` - Added walk-off validation for shallow outfield
- `backend/app/models/game_models.py` - Updated Pydantic validators
- `backend/tests/unit/core/test_validators.py` - Added walk-off validation tests
**Frontend** (1 file):
- `frontend-sba/components/Decisions/DefensiveSetup.vue` - Added smart option filtering
**Total**: 25 files modified in Session 1
---
## Git Commits
```bash
# Session 1 work committed as:
git commit -m "CLAUDE: Session 1 cleanup complete
- Removed unused config fields (strikes_for_out, balls_for_walk, supports_manual_result_selection)
- Fixed hit location requirements (6 outcomes instead of 11)
- Removed defensive alignment field (11 files)
- Removed offensive approach field (7 files)
- Added depth validation (server: walk-off rules, client: smart filtering)
Total: 25 files modified, all tests passing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
```
---
## Test Status
### Before Session 1
- Backend: 731/731 passing (100%)
- Frontend: Phase F3 complete
### After Session 1
- Backend: All tests passing ✅
- Unit tests: 730/731 (1 pre-existing failure unrelated)
- Defensive decision validation: 13/13 passing
- Offensive decision validation: 15/15 passing
- Frontend: Dev server running, no test failures
---
## Remaining Work (Session 2)
### Change #10: Offensive Decision Workflow Refactor
**Goal**: Replace removed `approach` field with specific action choices
**New OffensiveDecision Model**:
```python
class OffensiveDecision(BaseModel):
# NEW: Specific action choices (replaces removed "approach")
action: str = "swing_away" # swing_away, check_jump, hit_and_run, sac_bunt, squeeze_bunt
# EXISTING: Keep these fields
steal_attempts: List[int] = Field(default_factory=list)
hit_and_run: bool = False # May be deprecated if action="hit_and_run" replaces it
bunt_attempt: bool = False # May be deprecated if action includes bunt types
```
**Validation Rules** (add to validators.py):
1. `squeeze_bunt` requires R3 and bases NOT loaded
2. `check_jump` requires runner on base (lead runner only OR both if 1st+3rd)
3. `sac_bunt` / `squeeze_bunt` can't be used with 2 outs
4. `hit_and_run` requires runner on base
**Files to Modify** (~10-15 files):
**Backend**:
1. `backend/app/models/game_models.py`
- Add `action` field to OffensiveDecision
- Add validator for valid actions
- Consider deprecating hit_and_run/bunt_attempt bools
2. `backend/app/core/validators.py`
- Add `action` validation logic
- Validate squeeze_bunt conditions
- Validate check_jump conditions
3. `backend/tests/unit/models/test_game_models.py`
- Add tests for action field
- Test all 5 action types
4. `backend/tests/unit/core/test_validators.py`
- Add squeeze_bunt validation tests
- Add check_jump validation tests
5. `backend/app/websocket/handlers.py`
- Update submit_offensive_decision event
- Extract action field
6. `backend/app/core/ai_opponent.py`
- Update AI decision generation
7. `backend/terminal_client/*`
- Update commands/display/help for new action field
**Frontend**:
1. `frontend-sba/types/game.ts`
- Add `action` field to OffensiveDecision
2. `frontend-sba/components/Decisions/OffensiveApproach.vue`
- Replace "Batting Approach" section with "Action" section
- Add 5 action buttons: Swing Away, Check Jump, Hit-and-Run, Sac Bunt, Squeeze Bunt
- Add smart filtering:
- Check Jump: only if runner on base
- Hit-and-Run: only if runner on base
- Sac Bunt: only if < 2 outs
- Squeeze Bunt: only if R3 and not loaded, < 2 outs
3. `frontend-sba/pages/demo-decisions.vue`
- Update demo to use new action field
**Estimated Time**: 4-6 hours
**Risk**: HIGH - affects decision workflow, will break existing tests
**Recommendation**: Do as last major change before finalizing cleanup
---
## Change #11: Check Jump Validation
**Bundle with Change #10** (already planned)
Validation rule: Check jump only allowed for:
- Lead runner only
- OR both runners if 1st and 3rd
- NO trail runners (can't check jump at 2nd if R3 exists)
---
## Key Decisions Already Made
1. Remove supports_manual_result_selection()
2. Use polymorphic Player ID for pitching changes
3. Remove alignment and approach fields completely
4. Do offensive refactor before Phase F6
5. Hit location: only 6 outcomes need it
6. Depth validation: server authority + client smart filtering
7. Shallow outfield: walk-off scenarios only
---
## Important Notes
1. **Session 1 is COMPLETE** - All quick wins done
2. **Session 2 is complex** - Offensive decision refactor affects many files
3. **Test carefully** - Changes affect core gameplay workflow
4. **Commit strategy** - One commit for Session 2 when complete
5. **Frontend testing** - Verify demo pages work after changes
---
**Ready for Session 2!** Start with offensive decision workflow refactor (Changes #10-11).