ai-code-battle/PROGRESS.md
jedarden b06350d762
Some checks failed
CI / Go Tests (push) Has been cancelled
CI / Worker API Tests (push) Has been cancelled
CI / Indexer Tests (push) Has been cancelled
CI / Web Build (push) Has been cancelled
Remove legacy code: worker-api/, cmd/acb-indexer/, cluster-configuration/, gut cmd/acb-api/
Cleanup of superseded code that no longer matches the architecture:

Removed:
- worker-api/ - Cloudflare Worker with D1, superseded by K8s-based matchmaker + direct PostgreSQL
- cmd/acb-indexer/ - TypeScript index builder, superseded by Go cmd/acb-index-builder/
- cluster-configuration/ - K8s manifests belong in ardenone-cluster repo

Gutted cmd/acb-api/:
- Removed registration, job claim/result endpoints (deferred for v1)
- Removed dead code: predictions.go, seasons.go, series.go, register.go, jobs.go, glicko2.go
- API is now a stub with only health/ready endpoints
- Matchmaker and workers handle the core loop without it

Updated PROGRESS.md to reflect current architecture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 10:22:16 -04:00

296 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AI Code Battle - Implementation Progress
## Current Phase: Phase 10 - Ecosystem & Polish
**Status: ✅ Complete**
**Last Updated: 2026-03-29** (Legacy code cleanup)
### Legacy Code Cleanup (2026-03-29)
Removed superseded code that no longer matches the architecture:
- **Removed `worker-api/`**: Cloudflare Worker with D1, superseded by K8s-based matchmaker + direct PostgreSQL
- **Removed `cmd/acb-indexer/`**: TypeScript index builder, superseded by Go `cmd/acb-index-builder/`
- **Removed `deploy/k8s/`**: Old K8s manifest location (already migrated to ardenone-cluster repo)
- **Removed `cluster-configuration/`**: K8s manifests belong in ardenone-cluster repo at `declarative-config/k8s/apexalgo-iad/ai-code-battle/`
- **Gutted `cmd/acb-api/`**: Removed registration, job claim/result endpoints (deferred for v1), removed dead code (predictions.go, seasons.go, series.go, register.go, jobs.go, glicko2.go)
- API is now a stub with only health/ready endpoints
- Matchmaker and workers handle the core loop without it
### Marathon Verification (2026-03-29)
- Project verified complete - no remaining work
- Web build: passing
- Git status: clean, up to date with origin/master
- K8s manifests: in ardenone-cluster repo at `declarative-config/k8s/apexalgo-iad/ai-code-battle/`
- cmd packages: 9 present (acb-api stub, acb-evolver, acb-index-builder, acb-local, acb-map-evolver, acb-mapgen, acb-matchmaker, acb-wasm, acb-worker)
- All phases 1-10 complete - project finished
### Phase 10 Completed ✅
- [x] Accessibility suite (`web/src/replay-viewer.ts`, `web/src/app.ts`, `web/app.html`)
- Paul Tol color-blind safe palette (8 distinct colors)
- Shapes per player (circle, square, triangle, diamond, pentagon, hexagon)
- High contrast mode (brighter colors, darker walls)
- Reduced motion support (auto-detect prefers-reduced-motion)
- Accessibility controls UI in replay page
- Keyboard shortcuts: Space (play/pause), ArrowLeft/Right (step), Home/End (start/end)
- Screen reader region for turn announcements
- Focus indicators (`:focus-visible` styles) for all interactive elements
- Skip link for screen reader navigation
- High contrast focus enhancement (`prefers-contrast: more` media query)
- [x] Weekly meta report blog infrastructure
- Blog generation module in Go index builder (`cmd/acb-index-builder/blog.go`)
- Meta report content generation (leaderboard, strategies, rising/falling bots, rivalries)
- Chronicle generation (rise stories, upset narratives, rivalry chronicles)
- Blog page component with filtering and post rendering (`web/src/pages/blog.ts`)
- Individual post page with markdown rendering
- Blog routes added to SPA router
- Blog link added to navigation
- [x] Live evolution observatory (evolver writes live.json to R2)
- R2 client module (`cmd/acb-evolver/internal/live/r2.go`) for S3-compatible uploads
- `live-export -r2` and `live-export -r2-only` flags for R2 upload
- Frontend fetches from R2 (`https://r2.aicodebattle.com/evolution/live.json`)
- Cache-Control: max-age=10 for near-real-time updates
- Tests for R2 config validation and credential handling
- [x] Narrative engine (weekly story arc detection + LLM chronicles)
- [x] Public match data documentation (OpenAPI-style)
- New `/docs/api` route with comprehensive endpoint documentation
- Documents Pages, R2, and B2 static JSON endpoints
- Includes JSON Schema for replay format
- Fetching pattern with R2-then-B2 fallback
- Cache behavior documentation
### Phase 10 Exit Criteria
| Criterion | Status |
|-----------|--------|
| Weekly editorial content (meta reports + story arcs) as blog posts | ✅ Complete |
| All match data exposed as documented static JSON | ✅ Complete |
| WCAG accessibility standards for color and keyboard navigation | ✅ Complete |
| Live evolution observatory streaming | ✅ Complete |
### Phase 9 Completed ✅
- [x] Bot profile cards (`cmd/acb-index-builder/cards.go`, `web/src/og-tags.ts`)
- Canvas-rendered PNG images (1200x630 for Open Graph)
- Displays: bot name, rating, win rate, W/L record, rank badge
- [x] Map evolution pipeline (`cmd/acb-map-evolver/`)
- Parent selection by engagement × vote multiplier
- Crossover breeding with sector-based inheritance
- Symmetry-preserving mutation
- [x] Replay playlists (`cmd/acb-index-builder/playlists.go`, `web/src/pages/playlists.ts`)
- Auto-curated collections: featured, upsets, comebacks, domination
- [x] Embeddable replay widget (`web/embed.html`, `web/src/embed.ts`)
### Phase 8 Completed ✅
- [x] WASM game engine (`cmd/acb-wasm/`)
- [x] In-browser sandbox (`web/src/pages/sandbox.ts`)
- [x] Win probability computation (`web/src/win-probability.ts`)
- [x] Replay commentary (`web/src/commentary.ts`)
- [x] Clip maker (`web/src/pages/clip-maker.ts`)
- [x] Rivalry detection (`web/src/pages/rivalries.ts`)
- [x] Replay feedback system (`web/src/pages/feedback.ts`)
### Phase 7 Completed ✅
- [x] Evolution pipeline (`cmd/acb-evolver/`)
- Programs database with island model (4 islands)
- MAP-Elites behavior grid integration
- Validation pipeline: syntax → schema → sandbox smoke test
- Evaluation arena: 10-match mini-tournament
- Promotion gate: Nash equilibrium computation + MAP-Elites niche fill
- Live export: generates live.json for dashboard
- [x] LLM integration (`cmd/acb-evolver/internal/llm/`)
### Phase 6 Completed ✅
- [x] Go API server (`cmd/acb-api/`) — now a stub, full API deferred for v1
- [x] Match worker container (`cmd/acb-worker/Dockerfile`)
- [x] Discord/Slack alerting webhooks (`cmd/acb-api/alerts.go`)
- [x] Prometheus metrics endpoint (`cmd/acb-worker/metrics.go`)
- [x] GitHub Actions CI workflow (`.github/workflows/ci.yml`)
### Phase 5 Completed ✅
- [x] SPA application shell (`web/app.html`)
- [x] Hash-based router (`web/src/router.ts`)
- [x] Page components (`web/src/pages/`)
- [x] API client (`web/src/api-types.ts`)
- [x] Cloudflare Pages deployment configuration
### Phase 4 Completed ✅
### Phase 3 Completed ✅
### Phase 2 Completed ✅
### 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-api/ # Go API server (stub - deferred for v1)
│ │ ├── main.go # Server entry point
│ │ ├── server.go # Route registration (health/ready only)
│ │ ├── config.go # Environment configuration
│ │ ├── db.go # PostgreSQL schema
│ │ ├── health.go # Health/ready endpoints
│ │ ├── crypto.go # ID generation, AES-256-GCM encryption
│ │ ├── alerts.go # Discord/Slack alerts
│ │ ├── Dockerfile # API container
│ │ └── *_test.go # Test files
│ ├── acb-local/ # CLI match runner
│ ├── acb-mapgen/ # Map generator
│ ├── acb-worker/ # Match execution worker
│ │ ├── main.go # Worker entry point
│ │ ├── api.go # Worker API client
│ │ ├── metrics.go # Prometheus metrics
│ │ ├── b2.go # B2 upload client
│ │ └── Dockerfile # Worker container
│ ├── acb-index-builder/ # Go index builder
│ │ ├── main.go
│ │ ├── blog.go # Blog generation
│ │ ├── cards.go # OG image generation
│ │ └── playlists.go # Playlist generation
│ ├── acb-evolver/ # Evolution pipeline
│ │ ├── main.go # CLI entry point
│ │ └── internal/
│ │ ├── db/ # Programs database
│ │ ├── arena/ # Tournament evaluation
│ │ ├── validator/# 3-stage validation
│ │ ├── promoter/ # Promotion gate
│ │ ├── selector/ # Parent sampling
│ │ ├── prompt/ # LLM prompt builder
│ │ ├── llm/ # LLM client
│ │ ├── mapelites/ # Behavior grid
│ │ └── live/ # Dashboard export
│ ├── acb-wasm/ # WASM game engine
│ │ ├── main.go # JS bindings
│ │ ├── bots.go # Bot interface
│ │ ├── build.sh # Build script
│ │ └── strategies/ # Strategy implementations
│ ├── acb-matchmaker/ # Internal matchmaker
│ │ ├── main.go # Ticker orchestration
│ │ ├── tickers.go # Pairing, health, reaping
│ │ ├── config.go # Configuration
│ │ ├── crypto.go # Shared crypto
│ │ └── alerts.go # Discord/Slack alerts
│ └── acb-map-evolver/ # Map evolution pipeline
│ └── main.go # CLI entry point
├── 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
│ ├── embed.html # Embeddable replay widget
│ ├── public/ # Static assets (copied to dist/)
│ │ ├── _headers # Cloudflare cache headers
│ │ ├── robots.txt # SEO
│ │ └── data/ # Index files
│ └── 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
│ ├── engine.ts # Browser game engine
│ ├── commentary.ts # AI replay commentary
│ ├── win-probability.ts # Monte Carlo win prob
│ ├── og-tags.ts # Dynamic OG tag updates
│ ├── main.ts # Standalone replay viewer
│ ├── app.ts # SPA entry point
│ ├── embed.ts # Embeddable widget
│ └── pages/ # SPA page components
│ ├── home.ts
│ ├── leaderboard.ts
│ ├── matches.ts
│ ├── bots.ts
│ ├── bot-profile.ts
│ ├── register.ts
│ ├── sandbox.ts
│ ├── evolution.ts
│ ├── clip-maker.ts
│ ├── rivalries.ts
│ ├── feedback.ts
│ ├── playlists.ts
│ ├── blog.ts
│ └── docs-api.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
```
**Note:** K8s manifests are in the ardenone-cluster repo at `declarative-config/k8s/apexalgo-iad/ai-code-battle/`
## 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)
```