- Runs Go engine tests with race detector on every push/PR - Runs TypeScript tests for worker-api and indexer - Builds web app and uploads artifacts - Builds all Go CLI tools (acb-local, acb-mapgen, acb-worker) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
260 lines
9.6 KiB
Markdown
260 lines
9.6 KiB
Markdown
# AI Code Battle - Implementation Progress
|
|
|
|
## Current Phase: Phase 6 - Deployment & Production
|
|
|
|
**Status: 🔄 In Progress**
|
|
|
|
**Last Updated: 2026-03-24**
|
|
|
|
### Recent Changes (2026-03-24)
|
|
- Added GitHub Actions CI workflow (`.github/workflows/ci.yml`)
|
|
- Runs Go engine tests with race detector
|
|
- Runs TypeScript tests for worker-api and indexer
|
|
- Builds web app and uploads artifacts
|
|
- Builds all Go CLI tools
|
|
- Added `README.md` with project overview and quick start guide
|
|
- Added `.gitignore` for proper repository hygiene
|
|
- Added `package-lock.json` files for reproducible builds
|
|
- Verified all tests pass (glicko2.test.ts, generator.test.ts)
|
|
- Verified web build succeeds
|
|
- Verified compiled binaries work (acb-local, acb-mapgen, acb-worker)
|
|
|
|
### Phase 6 Progress
|
|
|
|
- [x] Match worker container (`cmd/acb-worker/Dockerfile`)
|
|
- Multi-stage Go build
|
|
- Non-root user for security
|
|
- Environment variable configuration
|
|
- [x] Bot-host deployment (`docker-compose.bots.yml`)
|
|
- Orchestrates all 6 strategy bots
|
|
- Health checks for each bot
|
|
- Environment-based secret configuration
|
|
- [x] Worker deployment (`docker-compose.workers.yml`)
|
|
- Match worker with scaling support
|
|
- Index builder for periodic runs
|
|
- R2 and API configuration
|
|
- [x] Environment configuration (`.env.example`)
|
|
- Documented all required environment variables
|
|
- [x] Deployment documentation (`DEPLOYMENT.md`)
|
|
- Architecture overview
|
|
- Cloudflare setup instructions
|
|
- Container deployment commands
|
|
- Troubleshooting guide
|
|
- [x] D1 database schema and migrations
|
|
- Complete schema.sql with all tables from plan
|
|
- Added: predictions, predictor_stats, map_votes, replay_feedback, series, series_games, seasons
|
|
- Added evolution fields to bots table (evolved, island, generation, parent_ids)
|
|
- Created migrations/0001_initial.sql for D1 migrations
|
|
- Updated wrangler.toml with migrations_dir config
|
|
- [x] Monitoring endpoints
|
|
- `/health` - Liveness probe (always returns 200)
|
|
- `/ready` - Readiness probe (checks database connectivity, returns 503 if unavailable)
|
|
- Documented in DEPLOYMENT.md
|
|
- [x] GitHub Actions CI workflow
|
|
- `.github/workflows/ci.yml` for automated testing
|
|
- Go tests with race detector
|
|
- TypeScript tests for worker-api and indexer
|
|
- Web build verification
|
|
- Go binary builds
|
|
|
|
### Remaining Phase 6 Work (requires Cloudflare account access)
|
|
|
|
- [ ] Cloudflare Pages project creation and deployment
|
|
- [ ] R2 bucket creation and custom domain
|
|
- [ ] Worker API deployment via Wrangler (`wrangler deploy`)
|
|
- [ ] DNS configuration
|
|
|
|
### Phase 5 Completed ✅
|
|
|
|
- [x] SPA application shell (`web/app.html`)
|
|
- Navigation header with links to all sections
|
|
- Dark theme with CSS custom properties
|
|
- Responsive layout
|
|
- [x] Hash-based router (`web/src/router.ts`)
|
|
- Pattern matching with parameter extraction
|
|
- Navigation and history support
|
|
- [x] Page components (`web/src/pages/`)
|
|
- Home page with hero, features, quick links
|
|
- Leaderboard with ranking table
|
|
- Match history with match cards
|
|
- Bot directory with bot cards
|
|
- Bot profile with stats, rating chart, recent matches
|
|
- Registration form with API key display
|
|
- Replay viewer (integrated from Phase 3)
|
|
- Docs/Getting Started page
|
|
- [x] API client (`web/src/api-types.ts`)
|
|
- fetchLeaderboard()
|
|
- fetchBotDirectory()
|
|
- fetchBotProfile()
|
|
- fetchMatchIndex()
|
|
- registerBot()
|
|
- rotateApiKey()
|
|
- [x] Cloudflare Pages deployment configuration
|
|
- `web/pages.json` - Project configuration
|
|
- `web/public/_headers` - Cache control headers
|
|
- `web/public/robots.txt` - SEO
|
|
- `web/public/data/` - Placeholder index file structure
|
|
- [x] R2 bucket custom domain documentation
|
|
- Documented in `web/pages.json` data_paths section
|
|
|
|
### Phase 4 Completed
|
|
|
|
### Phase 3 Completed
|
|
|
|
### Phase 2 Completed
|
|
|
|
### Phase 5 Exit Criteria
|
|
|
|
| Criterion | Status |
|
|
|-----------|--------|
|
|
| SPA with navigation (leaderboard, matches, bots, register) | ✅ Complete |
|
|
| Home page with getting started info | ✅ Complete |
|
|
| Registration form with API key display | ✅ Complete |
|
|
| Bot profiles with rating history chart | ✅ Complete |
|
|
| Match history page | ✅ Complete |
|
|
| Leaderboard with rankings | ✅ Complete |
|
|
| Getting started / docs page | ✅ Complete |
|
|
| Cloudflare Pages deployment config | ✅ Complete |
|
|
| R2 bucket custom domain for replays | ✅ Documented |
|
|
|
|
### Phase 1 Completed
|
|
|
|
## File Structure
|
|
|
|
```
|
|
ai-code-battle/
|
|
├── go.mod
|
|
├── go.sum
|
|
├── .env.example # Environment configuration template
|
|
├── DEPLOYMENT.md # Deployment guide
|
|
├── docker-compose.bots.yml # Bot-host orchestration
|
|
├── docker-compose.workers.yml # Worker orchestration
|
|
├── .github/
|
|
│ └── workflows/
|
|
│ └── ci.yml # GitHub Actions CI workflow
|
|
├── engine/
|
|
│ ├── types.go # Core data types
|
|
│ ├── grid.go # Toroidal grid implementation
|
|
│ ├── game.go # Game state management
|
|
│ ├── turn.go # Turn execution phases
|
|
│ ├── replay.go # Replay recording
|
|
│ ├── match.go # Match runner
|
|
│ ├── bot_local.go # Local bot interface
|
|
│ ├── bot_http.go # HTTP bot client
|
|
│ ├── auth.go # HMAC authentication
|
|
│ └── *_test.go # Test files
|
|
├── cmd/
|
|
│ ├── acb-local/ # CLI match runner
|
|
│ ├── acb-mapgen/ # Map generator
|
|
│ ├── acb-worker/ # Match execution worker
|
|
│ │ ├── main.go # Worker entry point
|
|
│ │ ├── api.go # Worker API client
|
|
│ │ ├── api_test.go # API client tests
|
|
│ │ ├── r2.go # R2 upload client
|
|
│ │ └── Dockerfile # Worker container
|
|
│ └── acb-indexer/ # Index builder
|
|
│ ├── package.json
|
|
│ ├── Dockerfile
|
|
│ └── src/
|
|
│ ├── index.ts # Entry point
|
|
│ ├── api.ts # Worker API client
|
|
│ ├── generator.ts # Index file generator
|
|
│ ├── writer.ts # File system writer
|
|
│ └── generator.test.ts
|
|
├── worker-api/
|
|
│ ├── package.json # npm dependencies
|
|
│ ├── wrangler.toml # Cloudflare Worker config
|
|
│ ├── schema.sql # Complete D1 schema (all tables)
|
|
│ ├── migrations/ # D1 migration files
|
|
│ │ └── 0001_initial.sql
|
|
│ └── src/
|
|
│ ├── index.ts # Router + cron dispatcher
|
|
│ ├── types.ts # TypeScript types
|
|
│ ├── glicko2.ts # Glicko-2 rating system
|
|
│ ├── glicko2.test.ts # Rating system tests
|
|
│ ├── jobs.ts # Job coordination endpoints
|
|
│ ├── bots.ts # Bot management endpoints
|
|
│ ├── export.ts # Data export endpoint
|
|
│ └── cron.ts # Cron handlers
|
|
├── web/
|
|
│ ├── package.json # npm dependencies
|
|
│ ├── tsconfig.json # TypeScript config
|
|
│ ├── vite.config.ts # Vite bundler config
|
|
│ ├── pages.json # Cloudflare Pages project config
|
|
│ ├── index.html # Standalone replay viewer
|
|
│ ├── app.html # SPA shell with navigation
|
|
│ ├── public/ # Static assets (copied to dist/)
|
|
│ │ ├── _headers # Cloudflare cache headers
|
|
│ │ ├── robots.txt # SEO
|
|
│ │ └── data/ # Placeholder index files
|
|
│ │ ├── leaderboard.json
|
|
│ │ ├── bots/index.json
|
|
│ │ └── matches/index.json
|
|
│ └── src/
|
|
│ ├── types.ts # Replay type definitions
|
|
│ ├── api-types.ts # API client and types
|
|
│ ├── router.ts # Hash-based SPA router
|
|
│ ├── replay-viewer.ts # Canvas viewer class
|
|
│ ├── main.ts # Standalone replay viewer
|
|
│ ├── app.ts # SPA entry point
|
|
│ └── pages/ # SPA page components
|
|
│ ├── home.ts
|
|
│ ├── leaderboard.ts
|
|
│ ├── matches.ts
|
|
│ ├── bots.ts
|
|
│ ├── bot-profile.ts
|
|
│ └── register.ts
|
|
├── bots/
|
|
│ ├── random/ # Python - RandomBot
|
|
│ ├── gatherer/ # Go - GathererBot
|
|
│ ├── rusher/ # Rust - RusherBot
|
|
│ ├── guardian/ # PHP - GuardianBot
|
|
│ ├── swarm/ # TypeScript - SwarmBot
|
|
│ └── hunter/ # Java - HunterBot
|
|
└── docs/
|
|
└── plan/
|
|
└── plan.md # Full implementation plan
|
|
```
|
|
|
|
## Strategy Bot Summary
|
|
|
|
| Bot | Language | Strategy | Expected Rank |
|
|
|-----|----------|----------|---------------|
|
|
| RandomBot | Python | Random valid moves | 6th (floor) |
|
|
| GathererBot | Go | Energy collection, avoid combat | 4th-5th |
|
|
| RusherBot | Rust | Rush enemy cores aggressively | 4th-5th |
|
|
| GuardianBot | PHP | Defend cores, cautious expansion | 3rd-4th |
|
|
| SwarmBot | TypeScript | Formation cohesion, group advance | 1st-2nd |
|
|
| HunterBot | Java | Target isolated enemies | 1st-2nd |
|
|
|
|
## Running Tests
|
|
|
|
```bash
|
|
# Go engine tests
|
|
go test ./engine/... -v
|
|
|
|
# Web build verification
|
|
cd web && npm run build
|
|
```
|
|
|
|
## Building CLI Tools
|
|
|
|
```bash
|
|
go build ./cmd/acb-local
|
|
go build ./cmd/acb-mapgen
|
|
```
|
|
|
|
## Running a Match
|
|
|
|
```bash
|
|
./acb-local -seed 42 -max-turns 100 -output replay.json -verbose
|
|
```
|
|
|
|
## Viewing a Replay
|
|
|
|
```bash
|
|
cd web
|
|
npm run dev
|
|
# Standalone viewer: http://localhost:3000/index.html
|
|
# Full SPA: http://localhost:3000/app.html (then go to #/replay)
|
|
```
|