fix(trip): redesign By Games mode with hierarchical calendar picker

Replace navigation-based team→games flow with expandable Sport→Team→Date
hierarchy. Games now grouped by date under each team with inline selection.
Also fixed game loading to always fetch 90-day browsing window.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-01-10 17:31:16 -06:00
parent 44952140c8
commit 6db0bdefcd
2 changed files with 414 additions and 374 deletions

View File

@@ -1,18 +1,3 @@
# Claude Code State & Control System
This document contains **everything you need** to keep Claude Code from losing context, looping, or rewriting history:
1. A canonical `PROJECT_STATE.md` file template
2. A full set of **copypaste prompts** for working with Claude Code
3. Claude Code **hooks / scripts** to automate checkpoints and recovery
---
## 1⃣ PROJECT_STATE.md (CANONICAL FILE)
Create this file at the root of your repo.
```md
# PROJECT STATE — CANONICAL
⚠️ This file is the single source of truth.
@@ -22,203 +7,153 @@ Create this file at the root of your repo.
---
## Goal (LOCKED)
<!-- 13 sentences. Immutable unless explicitly changed by the user. -->
Build a functional iOS sports trip planning app that helps users plan multi-stop road trips to attend games across MLB, NBA, NHL, NFL, MLS, WNBA, and NWSL. The app creates optimized routes with 3 planning modes: by dates, by must-see games, or by start/end cities. Ongoing development with no fixed completion milestone.
## NonNegotiable Constraints (LOCKED)
- No reevaluation of prior decisions
## Non-Negotiable Constraints (LOCKED)
- No re-evaluation of prior decisions
- No alternative architectures unless explicitly requested
- No refactors outside the active task
- No scope expansion
- iOS 26 minimum target (do not support older iOS versions)
- SwiftData + CloudKit + offline-first architecture is locked
- Three-layer architecture (Presentation/Domain/Data) is locked
- Python pipeline for data scraping remains (even though it needs rewrite)
## Architecture Decisions (LOCKED)
-
-
- **Data flow**: Python scrape → canonicalize → CloudKit → SwiftData → AppDataProvider.shared (single source of truth)
- **Trip planning**: 3 scenario modes (A: by dates, B: must-see games, C: start/end cities) using GameDAGRouter with beam search
- **Offline-first**: Bundled JSON bootstrap → SwiftData → background CloudKit sync
- **Test framework**: Swift Testing (@Test/@Suite syntax, not XCTest)
- **Sports supported**: 7 leagues (MLB, NBA, NHL, NFL, MLS, WNBA, NWSL), 148 stadiums
- **Export**: PDF itinerary generation with maps, photos, POIs
## Current Phase
<!-- Short name + description -->
**No active phase** — Previous phase-based workflow (.planning/) was removed as failed organization system. Ignore all git commit references to "Phase 8", "Phase 9", "v1.1 milestone" etc.
## Active Tasks
<!-- Only tasks Claude is allowed to work on -->
- [ ]
- [ ]
- [x] Fix "By Games" Mode Game Selection
- [ ] Group Schedule View Games by Sport
- [ ] Remove Buffer Days from Trip Planner
## Completed Tasks
- [x]
**Core Features (Working):**
- [x] Trip planning engine with 3 scenario modes (A/B/C)
- [x] GameDAGRouter with beam search optimization
- [x] Offline-first data architecture (bundled JSON → SwiftData → CloudKit)
- [x] AppDataProvider as single source of truth
- [x] Stadium progress tracking with photo import
- [x] Achievement system
- [x] PDF trip export with maps and POIs
- [x] UI: Home, Trip Creation/Detail, Schedule, Progress, Settings views
- [x] Python data pipeline (scraping, canonicalization, CloudKit upload) — functional but needs rewrite
- [x] 7 sport modules with multi-source fallback architecture
## Open Questions (UserOwned)
<!-- Claude may not answer these unless asked -->
-
**Recent Work (from git history, prior to .planning/ removal):**
- [x] GameDAGRouter edge case tests
- [x] Performance optimization for large datasets (10-17x speedup)
- [x] Scenario A timezone and conflict tests
- [x] Scenario B filler conflict tests
- [x] Scenario C corridor efficiency and anti-backtracking tests
## Open Questions (User-Owned)
## Checkpoints (APPENDONLY)
- Data quality: User is "unsure" if the 148 stadiums across 7 sports are accurate and complete
- CloudKit sync: "As far as I know yes" — not 100% certain sync is working correctly
- Test implementation completeness: Tests exist but are broken — unclear if implementations they test are actually complete
- When to rewrite Python pipeline: Acknowledged as needed but not scheduled
### Checkpoint YYYYMMDD HH:MM
- What exists:
- What is missing:
- Known issues:
- Next step:
```
## Known Issues
---
1. **Test suite broken** — Tests do not run in parallel OR serial execution. Files and tests need complete revisit. (NOT BLOCKING: app is functional)
2. **Data scraping broken** — Python pipeline "messed up" data, data directories (`data/canonical/`, `data/games/`) emptied. CloudKit still has data, so app functions.
3. **5 flaky tests** — Fail in parallel but pass individually (Swift Testing + simulator state pollution). Ignoring for now.
4. **Python pipeline out of control** — Grown unwieldy, needs complete rewrite from scratch (future task).
## 2⃣ CLAUDE CODE PROMPTS (COPY / PASTE)
## Deferred Work
Save this section as `CLAUDE_PROMPTS.md` if you want it separate.
All items in TO-DOS.md (16 items) are deferred — will become tasks in future phases when prioritized. See TO-DOS.md for full list.
---
**High-level categories:**
- In-app purchases (StoreKit, receipt validation)
- UI/UX improvements (redesign, theme fixes, region picker map)
- Testing gaps (trip filtering, repeat cities, must-stops, driving limits)
- Schedule improvements (UTC→local timezone, group by sport, show all games)
- Buffer days removal
### 🔹 Initialize Project State
```
Create or update PROJECT_STATE.md.
Write the goal, nonnegotiable constraints, architecture decisions, and an initial task list.
Do NOT write code.
Do NOT speculate.
This file is canonical.
```
**Feature flags (disabled, future work):**
- EV charging (`FeatureFlags.enableEVCharging = false`)
- Foundation Models / AI descriptions (commented out in RouteDescriptionGenerator)
---
## What Exists
### 🔹 Start Any Work Session
```
Before doing anything, read PROJECT_STATE.md in full.
Summarize:
- Goal
- Current Phase
- Active Tasks
Then proceed with the first unfinished task only.
Do not modify PROJECT_STATE.md unless explicitly told to.
```
**iOS App (SportsTime/):**
- Functional trip planning: 3 scenario modes, can create and save trips
- GameDAGRouter: Graph routing with beam search, directional filtering, performance-optimized
- Data layer: SwiftData models (SavedTrip, StadiumVisit, CanonicalStadium, CanonicalTeam, CanonicalGame)
- Services: CloudKitService, CanonicalSyncService, BootstrapService, LocationService, AchievementEngine
- UI: 5 main views (Home, Trip, Schedule, Progress, Settings), fully SwiftUI with @Observable ViewModels
- Export: PDF generator with map snapshots, remote image caching, POI search
- Progress tracking: Stadium visits, photos, achievements, progress map
- ~27,500 lines of Swift code
---
**Python Pipeline (Scripts/):**
- 7 sport scrapers (mlb, nba, nhl, nfl, mls, wnba, nwsl)
- Canonicalization pipeline (stadiums, teams, games with alias resolution)
- CloudKit import (full CRUD with diff reporting)
- Validation tools (health scores, completeness metrics)
- ~12,000 lines of Python code
- Status: Functional but "out of control", needs rewrite
### 🔹 Execute a Task (No Drift)
```
Work only on the selected Active Task.
Do not introduce new abstractions.
Do not refactor unrelated code.
Do not reanalyze architecture.
Produce the minimum change required.
```
**Tests:**
- 6 test files, ~7,000 lines of Swift Testing code
- Coverage: GameDAGRouter, ScenarioA/B/C planners, TravelEstimator
- Status: BROKEN (don't run in parallel or serial)
---
**Documentation:**
- CLAUDE.md: Comprehensive iOS app docs, build commands, architecture
- ARCHITECTURE.md: Original design document
- docs/: Market research, stadium progress spec, WNBA/MLS/NWSL implementation guides, data scraping architecture
- Scripts/: README, DATA_SOURCES, CLOUDKIT_SETUP
### 🔹 Write a Checkpoint
```
Write a new checkpoint to PROJECT_STATE.md.
Append only under the Checkpoints section.
Do not modify earlier content.
Summarize truthfully:
- What exists
- What is missing
- Known issues
- Next step
```
**Data:**
- Bundled JSON in `SportsTime/Resources/` (games_canonical.json, stadiums_canonical.json, teams_canonical.json, etc.)
- CloudKit container: `iCloud.com.sportstime.app` (contains current schedule data)
- Local data directories (`data/`) emptied after pipeline issues
---
## What Is Missing
### 🔹 Context Reset / Recovery
```
Clear context.
Read PROJECT_STATE.md completely.
Summarize:
- Goal
- Current Phase
- Active Tasks
Then continue from the next unfinished task.
```
**Broken/Incomplete:**
- Test suite execution (doesn't run properly)
- Python pipeline stable/maintainable implementation (current version works but needs rewrite)
- Data quality confidence (user unsure if 148 stadiums are accurate)
---
**Future Features (from TO-DOS.md):**
- In-app purchases / subscription system
- UI redesign
- Trip filtering
- Repeat cities option testing
- Must-stops (non-game POIs) testing
- Full test coverage for constraints (driving limits, etc.)
- Schedule improvements (timezone conversion, grouping by sport)
- Interactive region picker map
### 🔹 Scope Guard (When Claude Starts Drifting)
```
Stop.
This is out of scope.
Reread PROJECT_STATE.md.
Return to the current Active Task.
```
**Future Enhancements (from docs/MARKET_RESEARCH.md):**
- AI trip assistant (natural language planning)
- Group trip coordination
- Ticket integration
- Fan community features
---
## Checkpoints (APPEND-ONLY)
### 🔹 Lock or Unlock Sections
```
Unlock the following section(s):
- <section name>
No other sections may be modified.
```
---
## 3⃣ CLAUDE CODE HOOKS / SCRIPTS
These assume Claude Code can run shell commands or that you trigger them manually.
---
### 🧠 AutoCheckpoint Script
Create `checkpoint.sh`
```bash
#!/usr/bin/env bash
echo "\n### Checkpoint $(date '+%Y-%m-%d %H:%M')" >> PROJECT_STATE.md
echo "- What exists:" >> PROJECT_STATE.md
echo "- What is missing:" >> PROJECT_STATE.md
echo "- Known issues:" >> PROJECT_STATE.md
echo "- Next step:" >> PROJECT_STATE.md
echo "" >> PROJECT_STATE.md
```
Use prompt:
```
Run checkpoint.sh and then fill in the new checkpoint accurately.
```
---
### 🔁 Session Start Hook
Create `session_start.md`
```md
Read PROJECT_STATE.md.
You may not write code until you summarize:
- Goal
- Current Phase
- Active Tasks
```
Paste this at the top of every new Claude Code session.
---
### 🧯 Emergency Reset Hook
Create `RESET.md`
```md
STOP ALL WORK.
Discard assumptions from previous context.
Read PROJECT_STATE.md in full.
State what the next correct action is.
Do not code until confirmed.
```
---
## Final Rule (Read This Once)
Claude Code is a **stateless executor**, not a planner.
This system turns it into:
- A reliable implementer
- A resumable worker
- A nonlooping assistant
If Claude starts looping, drifting, or "thinking creatively" — it means the rails werent explicit enough.
Tighten the rails.
### Checkpoint 2026-01-10 16:30
- What exists: Functional iOS app with trip planning (3 modes), stadium tracking, PDF export. Python pipeline functional. CloudKit contains current data.
- What is missing: Working test suite (broken), stable Python pipeline (needs rewrite), data quality validation
- Known issues: Tests don't run (parallel or serial), data scraping "messed up" data (CloudKit still OK), flaky tests
- Next step: Fix broken test suite as first active task