Initial Commit
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# OpenSpec Change: enterprise-gaming-api-plugin-game-server
|
||||
|
||||
- **Change ID**: enterprise-gaming-api-plugin-game-server
|
||||
- **Package**: `@suaveplan/api-plugin-game-server`
|
||||
- **Category**: gaming/server
|
||||
- **Target path**: `gaming/server/api-plugin-game-server`
|
||||
- **Status**: PROPOSED
|
||||
- **Date**: 2026-04-24
|
||||
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/api-plugin-game-server.md`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Deliver `@suaveplan/api-plugin-game-server` on the genesis branch from scratch at enterprise quality. The package wraps `@suaveplan/game-server`'s `SessionManager` in a Hono HTTP plugin. Routes expose session lifecycle (create, list, join, leave, heartbeat, terminate), player management (add/remove/list), and server health. A `definePlugin()` factory registers the `SessionManager` as an injectable service. Genesis adds Zod request/response schemas, structured errors, OTel route instrumentation, and 100% coverage with Hono test client integration tests.
|
||||
|
||||
---
|
||||
|
||||
## Current-state audit (genesis)
|
||||
|
||||
Package does not exist on genesis yet — fresh build.
|
||||
|
||||
---
|
||||
|
||||
## Available workspace deps on genesis
|
||||
|
||||
| Package | Role |
|
||||
|---|---|
|
||||
| `@suaveplan/error` (`workspace:^`) | HTTP error mapping |
|
||||
| `@suaveplan/game-server` (`workspace:^`) | `SessionManager`, `Session` core logic |
|
||||
| `@suaveplan/events` (`workspace:^`) | Session event forwarding |
|
||||
| `zod` (`catalog:forms`) | Request/response schemas |
|
||||
| `@opentelemetry/api` (`catalog:observability`) | Route span instrumentation |
|
||||
|
||||
---
|
||||
|
||||
## HTTP Routes
|
||||
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `POST` | `/sessions` | Create session |
|
||||
| `GET` | `/sessions` | List sessions |
|
||||
| `GET` | `/sessions/:id` | Get session |
|
||||
| `DELETE` | `/sessions/:id` | Terminate session |
|
||||
| `POST` | `/sessions/:id/join` | Player join |
|
||||
| `POST` | `/sessions/:id/leave` | Player leave |
|
||||
| `POST` | `/sessions/:id/heartbeat` | Update heartbeat |
|
||||
| `GET` | `/sessions/:id/players` | List players |
|
||||
| `GET` | `/health` | Session manager health |
|
||||
|
||||
---
|
||||
|
||||
## File layout
|
||||
|
||||
```text
|
||||
gaming/server/api-plugin-game-server/
|
||||
package.json
|
||||
tsconfig.json
|
||||
vitest.config.ts
|
||||
src/
|
||||
index.ts
|
||||
error-codes.ts
|
||||
types/common.ts
|
||||
types/common.md
|
||||
routes/
|
||||
sessions.ts
|
||||
sessions.md
|
||||
players.ts
|
||||
health.ts
|
||||
plugin.ts
|
||||
plugin.md
|
||||
tests/
|
||||
integration.test.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Impact
|
||||
|
||||
**Downstream**: `@suaveplan/api-plugin-matchmaking` posts to this to assign matches. Prerequisites: `@suaveplan/error`, `@suaveplan/game-server`, `@suaveplan/events`.
|
||||
@@ -0,0 +1,44 @@
|
||||
# Tasks: enterprise-gaming-api-plugin-game-server
|
||||
|
||||
## 0. Pre-flight (non-negotiable)
|
||||
|
||||
- [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each)
|
||||
- [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
|
||||
- [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
|
||||
|
||||
## Phase 1 — Scaffold
|
||||
|
||||
- [ ] Create `gaming/server/api-plugin-game-server/` (`@suaveplan/api-plugin-game-server`, `0.1.0`, `sideEffects: false`)
|
||||
- [ ] `tsconfig.json`, `vitest.config.ts`
|
||||
|
||||
## Phase 2 — Types + error codes
|
||||
|
||||
- [ ] `src/error-codes.ts` + `src/types/common.ts` + `common.md`
|
||||
|
||||
## Phase 3 — Session routes
|
||||
|
||||
- [ ] `src/routes/sessions.ts` — CRUD + join/leave/heartbeat endpoints, Zod validation, OTel spans
|
||||
- [ ] `src/routes/sessions.md`
|
||||
|
||||
## Phase 4 — Player routes
|
||||
|
||||
- [ ] `src/routes/players.ts` — list players per session
|
||||
|
||||
## Phase 5 — Health route
|
||||
|
||||
- [ ] `src/routes/health.ts` — session count, active player count
|
||||
|
||||
## Phase 6 — Plugin factory
|
||||
|
||||
- [ ] `src/plugin.ts` — `gameServerPlugin()`, SessionManager registration
|
||||
- [ ] `src/plugin.md`
|
||||
|
||||
## Phase 7 — Integration tests
|
||||
|
||||
- [ ] `tests/integration.test.ts` — full HTTP lifecycle using Hono test client
|
||||
|
||||
## Phase 8 — Pre-publish gate
|
||||
|
||||
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-game-server` green
|
||||
- [ ] 100% coverage
|
||||
- [ ] Publish: `bun scripts/publish.ts --package @suaveplan/api-plugin-game-server`
|
||||
Reference in New Issue
Block a user