Commit graph

13 commits

Author SHA1 Message Date
jedarden
1c8f0aea72 K8s deployments and ExternalSecrets for extended bot fleet
Add Deployment, ExternalSecret, and Service manifests for 10 new strategy bots:
- scout (Python)
- assassin (Rust)
- defender (C#)
- farmer (Go)
- kamikaze (Node)
- nomad (Python)
- opportunist (Go)
- pacifist (Node)
- phalanx (Rust)
- raider (Java)

Each bot includes:
- Deployment with ArgoCD Image Updater annotations
- ExternalSecret for OpenBao shared-secret
- ClusterIP service (bot-<name>.acb-bots.svc.cluster.local)

Resource allocations tailored per language (JVM/C#/Rust = higher, Go/Python/Node = lower)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 14:58:41 -04:00
jedarden
bb3c6d8d64 Bug fix bf-3dy1: Add R2 credentials to worker deployment for direct replay upload
The worker was only configured with B2 (ARMOR) credentials, so replays were
being uploaded to B2 but not to R2. The index builder's B2→R2 promotion
cycle only covers the last 24 hours, so older replays were not available
in R2, causing 404 errors when clicking "Watch Replay".

This fix adds R2 credentials to the worker deployment, allowing it to
upload replays directly to R2 (hot cache) in addition to B2 (cold archive).
This makes replays immediately available for viewing without waiting for
the promotion cycle.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 18:25:04 -04:00
jedarden
e88c108010 feat(acb-enrichment): implement AI replay enrichment service
Implements the acb-enrichment service (plan §13.3) that generates AI
commentary for featured matches.

Key features:
- LLM client (OpenAI/Anthropic API compatible)
- Replay fetch from B2/R2 storage
- Structured commentary output (key_moments array with turn,
  description, significance, tags)
- Rate limiting to control LLM costs
- Match selection based on:
  - Minimum turn count
  - Win probability crossings
  - Upset threshold
  - Close finishes

Components:
- cmd/acb-enrichment/main.go - service entry point
- cmd/acb-enrichment/config.go - configuration from env vars
- cmd/acb-enrichment/service.go - orchestration logic
- internal/db/store.go - database access for match selection
- internal/llm/client.go - OpenAI-compatible LLM client
- internal/selector/selector.go - match selection with priority
- internal/generator/generator.go - commentary generation
- internal/storage/client.go - S3-compatible storage client
- Dockerfile - container image
- manifests/acb-enrichment-deployment.yml - K8s deployment
- metrics/metrics.go - Prometheus metrics for enrichment

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-04 02:22:28 -04:00
jedarden
181e846d8a feat(map-evolver): bootstrap empty maps table and containerize
- Add seedIfEmpty: idempotent startup seeding (20 maps per player count,
  ON CONFLICT DO NOTHING) using cellular-automata generation + validate()
- Add continuous evolution loop across all player counts (2/3/4/6)
- ACB_MIN_SEED_COUNT and ACB_EVOLUTION_PERIOD configurable via env vars
- Add Dockerfile (lean Alpine build, no language runtimes)
- Add acb-map-evolver to acb-build.yml CI pipeline
- Add staging K8s Deployment manifest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 08:05:51 -04:00
jedarden
3938afd058 fix(worker): set ACB_B2_REGION to empty string for ARMOR/B2 S3-compatible API
The AWS SDK rejects 'us-east-1' as a region when using a custom S3-compatible
endpoint (ARMOR proxy wrapping Backblaze B2). The B2 client code already
hardcodes config.WithRegion('auto') which is correct for S3-compatible APIs.

This fixes the 'Invalid region: region was not a valid DNS name' error that
was preventing replay uploads to B2.
2026-04-25 09:56:55 -04:00
jedarden
9771c5dd00 ci: update acb-eventsensor.yml to match deployed forgejo-webhooks EventSource
The staging manifest now reflects the actual deployed state in declarative-config:
- EventSource name: forgejo-webhooks (was acb-webhook)
- Endpoint: /ai-code-battle (was /push)
- Namespace: argo-events (was argo-workflows)
- Includes all three triggers: acb-images-build, acb-site-build, acb-bots-build
- Adds Forgejo webhook registration instructions

The forgejo-webhooks EventSource and updated webhook IngressRoute were added
to declarative-config to complete the CI wiring for jedarden/ai-code-battle.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 23:32:54 -04:00
jedarden
bceb686322 feat(manifests): add bot-seeder to register strategy bots via POST /api/register
The bot-seeder Deployment runs a shell script at startup that:
- Checks GET /api/bots and skips any bot already registered (idempotent)
- Waits for each bot's /health endpoint before registering
- POSTs to /api/register with name, owner=system, and cluster-internal endpoint_url
- Captures the returned shared_secret and upserts acb-bot-<name>-secret via the K8s REST API
- Sleeps forever after all 6 bots are registered

Also adds reloader.stakater.com/auto: "true" to all 6 bot Deployments so Reloader
triggers a rolling restart when the seeder writes/updates their secrets, ensuring
pods pick up the correct BOT_SECRET for HMAC validation.

RBAC: bot-seeder ServiceAccount + Role (get/create/patch secrets) + RoleBinding.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 23:27:03 -04:00
jedarden
1c61d80bd4 feat(manifests): add acb-bots namespace with K8s manifests for 6 strategy bots
Creates manifests/acb-bots/ staging directory for the acb-bots namespace,
containing Deployment + Service + ExternalSecret for all 6 strategy bots
(random, gatherer, rusher, guardian, swarm, hunter) plus namespace and
docker-hub-registry ExternalSecret.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 23:22:09 -04:00
jedarden
978bcffc91 fix(manifests): pin all ronaldraygun images to SHA digests, add image-updater annotations
Replace :latest with @sha256: digest for acb-api, acb-evolver, acb-index-builder,
acb-matchmaker, and acb-worker. Add argocd-image-updater annotations to all five
deployments to auto-track future sha-* tag builds. Add missing deployment manifests
for index-builder, matchmaker, and worker.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 23:07:29 -04:00
jedarden
88bd70640a fix(types): add missing ReplayPlayer import and type annotation for transcript feature
- Add ReplayPlayer to type imports in replay-viewer.ts
- Add explicit type annotation for entry parameter in replay.ts transcript map
- Fixes TypeScript compilation errors for §15.3 screen reader transcript feature
2026-04-22 18:20:56 -04:00
jedarden
f4352c6304 feat(evolver): add workflow completion polling to promoter
Per plan §10.8 (deployment pipeline) and §9.8 (Argo Workflows):

- Add waitForWorkflowCompletion() that polls Argo Workflow API
- Add getWorkflowStatus() to fetch workflow phase/status
- Update Promote() to wait for workflow completion before inserting bot record
- Update Promote() to wait for K8s deployment readiness (waitForDeployment)
- Update triggerArgoWorkflow() to return workflow name for polling
- Add acb-evolved-bot-deploy-workflowtemplate.yml to manifests

The promotion flow now:
1. Writes bot source to bots/evolved/<bot_name>/
2. Commits and pushes source to git
3. Triggers Argo WorkflowTemplate
4. Waits for workflow completion (build + manifest commit)
5. Waits for K8s deployment to be ready
6. Inserts bot record into bots table
7. Updates programs table with bot_id/bot_name

This ensures evolved bots have running containers before being marked active.
2026-04-22 17:46:33 -04:00
jedarden
5a1130c77a feat(bot): add Pacifist bot (JavaScript) — non-aggressive attrition archetype
PacifistBot never attacks; it survives by maximizing distance from enemies
and retreating toward own core when cornered. Pure evasion strategy that
wins via opponent elimination by third parties.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 16:32:50 -04:00
jedarden
a06129132e feat(k8s): add deployment manifests for acb-evolver and acb-api per §9.2
Staging manifests for sync to declarative-config/k8s/apexalgo-iad/ai-code-battle/:
- acb-evolver: Deployment + ServiceAccount with LLM/PG/R2 secrets
- acb-api: Deployment + Service + IngressRoute for api.ai-code-battle.ardenone.com

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 13:50:20 -04:00