Commit graph

676 commits

Author SHA1 Message Date
jedarden
941f8bd2c9 fix(db): add LIMITs to unbounded queries to prevent OOM
- Add LIMIT 1000 to fetchChampionshipBracket (was unbounded)
- Reduce fetchSeries from LIMIT 5000 to LIMIT 1000
- Reduce fetchLineage from LIMIT 50000 to LIMIT 10000
- Reduce fetchFeedback from LIMIT 5000 to LIMIT 1000
- Reduce fetchRatingHistory from LIMIT 10000 to LIMIT 5000

The acb-index-builder pod has been in CrashLoopBackOff with OOMKill
(exit code 137) for 45 days with 4713 restarts. These unbounded queries
were loading too much data into memory, causing the kernel to kill the
process before any logs could be written.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 00:38:55 -04:00
jedarden
8736098423 fix(db): add LIMITs to unbounded queries to prevent OOM
Added LIMIT clauses to 4 unbounded queries that were causing
acb-index-builder to crash with OOMKill after copying web assets:

- fetchPredictorStats: LIMIT 100 (was loading all predictor stats)
- fetchMaps: LIMIT 500 (was loading all maps)
- fetchSeasonSnapshots: LIMIT 1000 (was loading all season snapshots)
- fetchSeasons: LIMIT 100 (was loading all seasons)

These queries had ORDER BY but no LIMIT, causing them to load
massive datasets into memory on each build cycle, leading to
container OOM after the web asset copy phase.

Fixes bead bf-2ws
2026-06-25 00:27:21 -04:00
jedarden
1832ff439b fix(db): add LIMITs to unbounded queries to prevent OOM
- Add LIMIT 50000 to fetchLineage (evolution programs table)
- Add LIMIT 10000 to fetchBots
- Add LIMIT 5000 to fetchSeries

These queries had no bounds and could grow arbitrarily large,
causing acb-index-builder to OOM during build cycles.
The lineage table in particular grows unbounded with evolution.

Fixes CrashLoopBackOff that has persisted for 45 days.
2026-06-25 00:23:48 -04:00
jedarden
5e83945683 Merge branch 'master' of https://git.ardenone.com/jedarden/ai-code-battle 2026-06-24 07:11:11 -04:00
jedarden
34d5915abc docs: improve README for clarity and discoverability
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-24 07:10:31 -04:00
jedarden
dfe599c161 notes(bf-1kg): document verification that C# evolver support was already completed
Verified all acceptance criteria:
- buildCandidate() C# case implemented (arena.go:473-491)
- defender_strategy.cs.txt seed file exists
- defender seed entry in seed.go with language=csharp
- langDisplayName() includes C# mapping
- go build ./cmd/acb-evolver/... passes

Bead-Id: bf-1kg
2026-06-17 05:21:46 -04:00
jedarden
88a8d02a48 notes(bf-1kg): document verification that C# evolver support was already completed
Verified all acceptance criteria:
- buildCandidate() C# case implemented (arena.go:473-491)
- defender_strategy.cs.txt seed file exists
- defender seed entry in seed.go with language=csharp
- langDisplayName() includes C# mapping
- go build ./cmd/acb-evolver/... passes
2026-06-17 05:20:52 -04:00
jedarden
0756c28e1b notes(bf-1kg): document that C# evolver support was already completed 2026-06-17 05:11:41 -04:00
jedarden
de15046e3e feat(evolver): add C# language support
- Add csharp case to buildCandidate() with dotnet-script and mcs fallback
- Add defender_strategy.cs.txt seed file (combined Program.cs, Strategy.cs, Grid.cs)
- Add defender seed to population (gamma island, aggression=0.3, economy=0.4)
- Add csharp to langDisplayName() and update comments

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 05:08:19 -04:00
jedarden
c28a463997 build(bots): leader-targeter bot Maven build artifacts
Rebuilt leader-targeter-bot JAR with Maven after verifying
compilation. The bot implements multi-player score-aware
targeting strategy.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 04:54:09 -04:00
jedarden
32b173f6ad notes(bf-3rr): document leader-targeter bot completion
Bead-Id: bf-3rr
2026-06-17 04:43:12 -04:00
jedarden
f833345919 build(bots): leader-targeter bot Maven build artifacts 2026-06-17 04:41:19 -04:00
jedarden
91e272f56a feat(bots): add leader-targeter bot with multiplayer score-aware targeting
Implement a new Java bot that applies multi-player game theory: in N>2
games, always direct all units toward the current score leader rather than
the nearest enemy. This creates a natural kingmaker dynamic that prevents
any single bot from running away with the game.

Strategy:
- Identify all visible opponents and their scores (cores count as proxy)
- Pick primary target: opponent with highest inferred score (tiebreak: nearest)
- Send all bots toward primary target's centroid (mean of visible bots + cores)
- Exception: if own core is under threat (enemy bot within 6 tiles), detach 2 bots to defend
- In 2-player games: fall back to straight aggressor strategy

Novelty: No current bot does multi-player score-aware target selection. Most
bots target nearest enemy, which lets a distant leader accumulate score
unmolested. Leader-targeter explicitly models the N-player problem.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 04:37:55 -04:00
jedarden
8af1c03aca feat(bots): add coordinator bot with dynamic role allocation
Implement CoordinatorBot - a multi-role strategy bot that dynamically
allocates roles (Attacker/Harvester/Defender/Scout) each turn based on
game state.

Features:
- Per-turn role assignment using greedy Hungarian-style algorithm
- Dynamic role rebalancing based on threat level, economic pressure, score
- Zone-aware survival logic
- HTTP server with HMAC authentication
- TypeScript implementation with full type safety

Role allocation algorithm:
- Base split: 50% attackers, 25% harvesters, 15% defenders, 10% scouts
- Adjusts: +10% defenders if threat > 0.3
- Adjusts: +10% harvesters if energy < spawn threshold
- Adjusts: +20% attackers if score leads by 5+
- Assigns bots by proximity to role targets

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 04:24:26 -04:00
jedarden
f0d4e661d7 verify(bf-413): confirm all mechanics iteration work completed
Verified all 5 backlog items:
- Combat kill scoring (engine/turn.go:272-275)
- Fitness formula blending win rate + kill rate (run.go:608)
- CombatDeaths tracking through arena (arena.go:204-221)
- Behavior vector derived from actual kill rate (run.go:614-625)
- Flee thresholds with outnumber logic (farmer/gatherer/siege bots)

All mechanics now make combat economically necessary for the evolver.
2026-06-17 03:58:27 -04:00
jedarden
bf80d84a6f notes(bf-413): document completion of AI Code Battle mechanics iteration
All backlog items completed:
- Combat kill scoring in engine (turn.go:274)
- Fitness formula blends win rate + kill rate (run.go:608)
- Flee thresholds reduced with outnumber logic
- CombatDeaths tracked through arena MatchOutcome
- Aggression derived from actual kill rate in behavior vector

This Genesis bead tracked the full mechanics iteration to make combat
economically necessary and reward aggression in the evolver.
2026-06-17 03:54:38 -04:00
jedarden
d5515e0bca feat(mechanics): reduce flee thresholds and derive aggression from kill rate
## Flee Threshold Changes
- Reduced flee threshold from AttackRadius2+4 to AttackRadius2 (no buffer)
- Modified bots: farmer, gatherer, siege
- Bots now only consider enemies in actual attack range, not preemptively
- Added outnumber logic: only flee when nearbyAllies < nearbyEnemies

## Behavior Vector Changes
- Derive aggression from actual kill rate (not self-reported)
- Formula: behaviorVec[0] = min(killRate, 1.0)
- Preserves existing economy value or defaults to 0.5
- Enhanced logging to show derived aggression value

## Rationale
Aggression must be economically necessary, not just rewarded.
Previous flee logic created a false safe option that discouraged combat.
Now bots only flee when actually outnumbered within combat range.

Related: bf-413 genesis bead tracking mechanics iteration
2026-06-17 03:51:15 -04:00
jedarden
2cf6437587 notes(bf-59h): document that work was already completed in commit d42d1a5 2026-06-17 03:15:28 -04:00
jedarden
d42d1a5336 feat(evolver): update fitness function to weight kill rate alongside win rate
- Updated fitness formula: fitness = 0.7*win_rate + 0.3*kill_rate (was win_rate only)
- Added kill tracking to ArenaResult: TotalKills, TotalMatches, KillRate
- Updated evolver system prompt to explicitly mention combat kills are valuable
- Enhanced arena logging to show kill rate and total kills

This change makes the LLM evolver select for combat aggression, not just win
optimization. The system prompt now informs bots that kills and eliminations
are part of the fitness evaluation, encouraging more aggressive strategies.

Related: bf-59h
2026-06-17 03:11:05 -04:00
jedarden
42398eb34a feat(evolver): add phalanx, assassin, opportunist as generation-0 seeds
Add 3 new hand-written bots to expand evolver seed pool:
- phalanx (Rust, alpha island) - formation combat with aggression=0.85, economy=0.1
- assassin (Rust, alpha island) - decapitation strategy with aggression=1.0, economy=0.0
- opportunist (Go, beta island) - conditional aggression with aggression=0.55, economy=0.55

This brings the total seed count from 6 to 9, providing richer starting
population across islands with diverse attack archetypes the evolver
can recombine.

Changes:
- Add seeds/phalanx_strategy.rs.txt, assassin_strategy.rs.txt, opportunist_strategy.go.txt
- Update seed.go with 3 new embed directives and seed entries
- Add TestSeedPopulation to verify 9 seeds insert correctly
- Update comments to reflect 9 seeds instead of 6

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 03:01:18 -04:00
jedarden
dce34f97b6 fix(economist): use bot positions as keys instead of non-existent IDs
- Fixed contest_assignments to use bot positions as keys since bots only have position and owner (no ID field)
- Fixed tuple conversions for energy and walls to properly convert elements to int
- Added curl to Dockerfile for health check support
- Updated docker-compose.bots.yml for economist bot

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 02:50:49 -04:00
jedarden
0db45dcfc2 Implement EconomistBot: energy-denial via node contesting
Adds bots/economist/bot.py and Dockerfile implementing a new strategy:
deliberately contest energy nodes that enemies are approaching to
destroy the contested energy, denying enemy income while harvesting
uncontested nodes for own economy.

Strategy priorities:
1. Maintain existing contest assignments (stay put)
2. Contest threatened nodes (intercept approaching enemies)
3. Reserve 1-2 bots to guard cores
4. Collect uncontested energy
5. Remaining bots explore toward map center

Pure collection mode when score lead ≥3 and turn > 200.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 01:35:10 -04:00
jedarden
0cbc08ef48 docs(bf-1dy): document ZoneDriver bot completion
The ZoneDriver bot was fully implemented and committed in cdbc4c0.
This note documents the implementation and verifies acceptance criteria.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 01:19:19 -04:00
jedarden
cdbc4c0cbd Implement ZoneDriverBot: zone-herding elimination strategy
ZoneDriver weaponizes the shrinking zone to force enemy eliminations:
- Computes zone boundary and identifies "kill band" (zone edge-2 to edge)
- Positions units to block enemy escape routes inward
- Herds enemies toward zone edge for passive eliminations
- Prioritizes survival for own bots near zone boundary

Novel approach: turns zone from map feature into active weapon.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 01:16:21 -04:00
jedarden
2696e70257 Implement SiegeBot: spawn-lockout strategy
- Add SiegeBot to engine/bot_strategies.go with spawn denial logic
- Implement standalone siege bot in bots/siege/ with main.go, strategy.go, Dockerfile
- Register siege bot in acb-local for arena testing
- Add test-siege-arena.sh script for validation

Strategy: Surround enemy cores to block spawning phase. Bot assigns
units to lockout rings (8 neighbors) around cores, greedily by distance.
Unassigned units collect energy or rush fully-sieged cores.

Tested: 3/10 wins vs rusher+gatherer, 1/10 wins vs rusher+gatherer+guardian
2026-06-17 01:02:01 -04:00
jedarden
2de4ddc720 notes(bf-dgn): verify setup-r2.sh replaced with setup-b2.sh 2026-06-17 00:30:34 -04:00
jedarden
65ea26f6da Replace setup-r2.sh with setup-b2.sh
- Delete scripts/setup-r2.sh (Cloudflare R2 is not the storage provider)
- Create scripts/setup-b2.sh that documents B2 CDN setup:
  - Prints B2 bucket endpoint (us-west-002)
  - Prints CNAME target for b2.aicodebattle.com
  - Verifies B2 credentials when env vars are set
  - Informational/verification-only (no destructive operations)
- Update scripts/cloudflare-setup.sh:
  - Remove R2 bucket creation steps
  - Add note that B2 setup is separate (see setup-b2.sh)

Acceptance criteria met:
- scripts/setup-r2.sh does not exist
- scripts/setup-b2.sh exists, is executable, and runs without error
- No references to setup-r2 remain in scripts/
2026-06-17 00:29:39 -04:00
jedarden
5546fd4f81 docs(bf-2x3): fix region inconsistency in B2 CDN documentation
Update B2 bucket details table to consistently show region as VERIFIED.
The region was already verified via garage-to-b2-sync.yml but the table
incorrectly showed it as 'unconfirmed'.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 00:26:48 -04:00
jedarden
66bf23f3f2 docs(bf-2x3): fix region inconsistency in B2 CDN documentation
Fix typo on line 147 where us-west-004 was incorrectly referenced
instead of the verified us-west-002 region from garage-to-b2-sync.yml
2026-06-17 00:18:59 -04:00
jedarden
d9bce29a3d docs(bf-2x3): verify B2 region as us-west-002, update documentation status
Verified B2 endpoint region via declarative-config garage-to-b2-sync.yml:
- Confirmed region: us-west-002
- Confirmed CNAME target: acb-data.s3.us-west-002.backblazeb2.com
- Updated implementation status table

Acceptance criteria met:
- notes/b2-cdn-setup.md exists with exact CNAME target 
- Region verified from production config (declarative-config) 
- Document clearly states verification status and blockers 

Note: B2 API auth could not be tested due to read-only proxy limitations.
Public access status requires Backblaze console access.
2026-06-17 00:16:47 -04:00
jedarden
eae2f70c2a docs(bf-2x3): update B2 CDN setup documentation with verification status
- Add current status summary identifying blockers
- Document region inconsistency (us-west-002 vs us-west-004 vs us-east-005)
- Note that aicodebattle.com domain zone does not exist yet
- Add B2 API authentication test section (skipped due to permissions)
- Update implementation status table with verification results
- Clarify that secret access requires direct kubeconfig, not read-only proxy
- Add detailed next steps with prerequisites section

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 00:16:47 -04:00
jedarden
915113b3a0 docs(bf-2x3): update B2 CDN setup documentation with verified CNAME status
- Corrected date from 2025 to 2026
- Confirmed b2.aicodebattle.com CNAME does NOT exist (NXDOMAIN verified)
- Added bucket name verification from enrichment deployment config
- Updated implementation status to reflect current CNAME status
- Added verification details for DNS resolution check
2026-06-17 00:16:47 -04:00
jedarden
75c0bb0d66 docs(bf-3dv): re-verify K8s strategy bot manifests already exist
- Confirmed all 7 original strategy bot deployment manifests exist
- Verified each follows required pattern: image=ronaldraygun/acb-strategy-{name}:latest, BOT_PORT=8080, BOT_SECRET from acb-bot-secrets key={name}-secret, Service ClusterIP:8080
- Verified acb-bot-secrets.yml.template contains all 7 bot secret keys
- Original work completed in commit 909f38f on 2026-06-16

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-16 23:57:33 -04:00
jedarden
c565cbab44 docs(bf-3dv): verify K8s strategy bot manifests already exist
Task completed in prior commit 909f38f. All 7 bot deployment manifests
and acb-bot-secrets.yml.template already present in declarative-config.
Verified pattern compliance: image ronaldraygun/acb-strategy-{name}:latest,
BOT_PORT=8080, BOT_SECRET from acb-bot-secrets key={name}-secret,
ClusterIP Service on port 8080.
2026-06-16 23:54:22 -04:00
jedarden
75f5b5755f docs(bf-z9m): verify combat kill scoring already implemented 2026-06-16 23:46:12 -04:00
jedarden
3fd355d377 docs(bf-z9m): verify combat kill scoring already implemented
- Confirmed feature exists in commit c1acd83 (2026-06-16)
- KillScore config field with default value of 1
- Score awarded in executeCombat() loop
- No code changes needed
2026-06-16 23:42:55 -04:00
jedarden
c1acd832f0 feat(combat): award score for combat kills
- Add KillScore config field (default: 1 point per kill)
- Increment killer's score in executeCombat() when tracking CombatDeaths
- Makes killing enemy bots worth real score, not just foraging
- Keeps kill_score configurable for balance tuning

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-16 23:40:47 -04:00
jedarden
b9a70cd873 docs(bf-1pc): re-verify SPA R2→B2 migration - complete 2026-06-16 23:36:49 -04:00
jedarden
f0ac0313a1 docs(bf-1pc): verify SPA R2→B2 migration - already complete
All acceptance criteria met:
- No /r2/ paths in source code
- Build succeeds
- No r2.aicodebattle.com references in dist

Work was completed in commit 76369b5 on 2026-06-16.
2026-06-16 23:26:31 -04:00
jedarden
69c1a80d1e docs(bf-1pc): verify SPA R2→B2 migration - already complete 2026-06-16 23:22:30 -04:00
jedarden
92dd1f92fd docs(bf-1pc): verify SPA R2→B2 migration - already complete 2026-06-16 23:20:06 -04:00
jedarden
76369b5252 fix(spa): replace /r2/ data path prefix with /b2/
- Update R2_COMMENTARY_BASE constant from '/r2' to '/b2'
- Storage migrated from Cloudflare R2 to Backblaze B2
- All data-fetch URLs now use b2.aicodebattle.com subdomain

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-16 23:17:32 -04:00
jedarden
724f5162b1 fix(spa): replace r2.aicodebattle.com with b2.aicodebattle.com
- Update docs-api.ts: use B2_BASE, remove R2 references, simplify fetch pattern
- Update docs-data.ts: replace R2 constant with B2
- Update docs-replay-format.ts: update curl example URL
- Update test files: update thumbnail URLs and comments

The SPA was migrated from Cloudflare R2 to Backblaze B2 storage.
All data-fetch URLs now point to b2.aicodebattle.com.
2026-06-16 23:13:08 -04:00
jedarden
faf8770dee docs: replace R2 with B2 throughout deployment docs
Cloudflare R2 was never the intended storage layer — plan.md correctly
specifies Backblaze B2 via Cloudflare Bandwidth Alliance. Remove the
Cloudflare R2 Setup section from the phase6 checklist, replace all
r2.aicodebattle.com URLs with b2.aicodebattle.com, fix the data flow
diagram to show K8s cluster as write-only compute (battles + replay
building) with no inbound user traffic, and update spa-route-test-results
to reference /b2/ paths consistently.
2026-06-07 08:50:34 -04:00
jedarden
00aece3f62 docs(bf-22vc5): investigate and verify - deployment enabled, infrastructure blocked
Verified the acb-enrichment deployment state:
- Deployment file is ENABLED (not .disabled)
- Image SHA is REAL (sha-97b4b0f, not placeholder)
- Task description premises were incorrect

Infrastructure blocker confirmed:
- Forgejo registry down (503 Service Unavailable)
- Pods stuck in Pending due to cluster CPU exhaustion
- 20+ pods Pending for 40+ days across cluster

Code requirements fully met - deployment requires infrastructure intervention.
2026-06-04 09:00:57 -04:00
jedarden
9c317c8c8b docs(bf-22vc5): document final status - code complete, infrastructure blocked
All code requirements met:
- Source code at cmd/acb-enrichment/ (405 lines)
- Dockerfile valid (multi-stage build with golang:1.25-alpine)
- Deployment manifest has real SHA (sha-97b4b0f), not placeholder
- Deployment IS enabled (replicas: 1)
- WorkflowTemplate exists in declarative-config

Infrastructure blockers (outside scope):
- Forgejo registry down (CPU exhaustion on apexalgo-iad)
- No iad-ci kubeconfig to trigger builds

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 08:58:51 -04:00
jedarden
66767fdc2e docs(bf-22vc5): document session status - code complete, infrastructure blocked
- Verified enrichment source code at cmd/acb-enrichment/
- Verified Dockerfile (golang:1.25-alpine -> alpine:3.19)
- Verified deployment manifest with real SHA (sha-97b4b0f)
- Verified workflow templates (acb-enrichment-build + acb-images-build)
- Infrastructure blocker: Forgejo registry down (254 pending pods on apexalgo-iad)
- Missing iad-ci kubeconfig prevents manual workflow trigger
2026-06-04 08:58:34 -04:00
jedarden
9db707eebe docs(bf-22vc5): document current session status - code complete, infrastructure blocked 2026-06-04 08:57:54 -04:00
jedarden
012bdc7c8d docs(bf-22vc5): update afternoon investigation - confirmed 2 infrastructure blockers
- Verified code requirements: source, Dockerfile, manifest all complete
- Found deployment manifest has real SHA (sha-97b4b0f), not placeholder
- Identified 2 blockers: no iad-ci kubeconfig access, Forgejo registry down
- Old ReplicaSets have placeholder SHAs but current spec is correct
- Documented manual trigger command for when infra is fixed
2026-06-04 08:57:54 -04:00
jedarden
598d357ace docs(bf-22vc5): document infrastructure blocker - Forgejo registry down due to cluster overprovisioning
- All code requirements satisfied (Dockerfile, source, manifest)
- Deployment already enabled with real SHA (sha-97b4b0f)
- BLOCKED by infrastructure: Forgejo registry down (503)
- Root cause: 223 pending pods blocking Forgejo scheduling
- acb-enrichment deployment in ImagePullBackOff state
- Requires infrastructure team intervention (scale nodes or cleanup pending pods)
2026-06-04 08:54:59 -04:00