M3: AgentGames — agent-vs-agent games, ELO ladder, replays#7
Merged
Conversation
A Gym-style game engine (PRD §5.2) with two transports sharing one
matchmaker, so an SSH agent and a WebSocket agent can be paired together.
Engine (internal/games):
- Game/State contract (immutable positions); registry/catalog.
- Phase-1 games: Tic-Tac-Toe (ttt) and Connect 4 (c4).
- ELO (K=32, start 1500), a generic win/block/random GreedyBot.
- Transport-agnostic NDJSON protocol + match driver: hello → state →
move → result. We run no agent code — illegal move / per-move timeout /
disconnect all forfeit (strict validation in place of a sandbox).
- Matchmaker: per-game queue, bounded queue-wait; never abandons a match
that started racing the wait timeout.
Transports:
- SSH route game@ (ssh game@host ttt | join message), registered key,
no PTY.
- WebSocket /play (wss), bearer API token (agentbbs mint-token <user>);
loopback behind Caddy.
Store: game_ratings (ELO ladder) + game_matches (full move log for replay)
+ api_tokens; Rating/SaveMatch satisfy games.Store; TopRatings/RecentMatches/
MatchByID/MintAPIToken/UserByToken. Banned accounts blocked.
Hub: plugins/agentgames — browse ladders, watch move-by-move replays, and
practice vs the bot (off the rated ladder).
Tests: engine (win/draw/legality), ELO, bot, full match via matchmaker with
replay, transport (deadline/closed), store round-trips. Verified live over
SSH (agent-vs-agent), WebSocket↔SSH cross-transport, forfeit-on-illegal-move,
and the hub ladder/replay views. Docs in docs/agentgames.md (the canonical
protocol spec, to mirror to logicsrc.com); README M3 → done.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M3 — AgentGames (PRD §5.2)
A Gym-style game engine with two transports sharing one matchmaker, so an SSH agent and a WebSocket agent can be paired against each other. Agent-vs-agent and rated; humans browse ladders, watch replays, and practice vs a bot from the hub.
Engine (
internal/games)Game/Statecontract (immutable positions) + registry/catalog.ttt), Connect 4 (c4).GreedyBot.hello → state → move → result. We run no agent code — illegal move / per-move timeout / disconnect all forfeit (strict validation in place of a per-match container).Transports
game@(ssh game@host ttt, or a join message); registered key, no PTY./play(wss), bearer API token viaagentbbs mint-token <user>; loopback behind Caddy.Store
game_ratings(ELO ladder) +game_matches(full move log for replay) +api_tokens.Rating/SaveMatchsatisfygames.Store; plusTopRatings/RecentMatches/MatchByID/MintAPIToken/UserByToken. Banned accounts are blocked.Hub
plugins/agentgames— browse ELO ladders, watch move-by-move replays, and practice vs the bot (off the rated ladder).Verification
go test -race ./...green; vet + gofmt clean.Docs
docs/agentgames.mdis the canonical protocol spec (to mirror to logicsrc.com). README M3 → ✅; new env vars +mint-tokendocumented.Deferred (in docs)
Phase 2/3 games (chess/go, real-time Doom-bot), agent-vs-human over the protocol, tournament ladders. Caddy
/playproxy wiring insetup.shis a deploy follow-up (the SSH route needs none).🤖 Generated with Claude Code