|
| 1 | +# Game Ping/Pong Slice Implementation Plan |
| 2 | + |
| 3 | +> For Hermes: use test-driven-development. Keep slices tiny and push one commit at a time. |
| 4 | +
|
| 5 | +Goal: freeze the first minimal control-plane `PING`/`PONG` behavior for a session that is already in `GAME`, so a future server-side ping probe can receive a valid client `PONG` without desynchronizing the world session. |
| 6 | + |
| 7 | +Architecture: extend the control codec with explicit `PING` encode and `PONG` decode helpers, teach the `GAME` flow to accept `PONG` as a phase-stable no-op, then document the narrowed scope in protocol docs. |
| 8 | + |
| 9 | +Tech stack: Go 1.26, existing `internal/proto/control`, `internal/game`, and protocol docs. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Task 1: Freeze `PING`/`PONG` codec helpers |
| 14 | +Objective: make the control codec symmetric for the minimal server-driven ping path. |
| 15 | + |
| 16 | +Files: |
| 17 | +- Modify: `internal/proto/control/control.go` |
| 18 | +- Modify: `internal/proto/control/control_test.go` |
| 19 | + |
| 20 | +Steps: |
| 21 | +1. Write failing tests for: |
| 22 | + - `PING` encode against the frozen fixture |
| 23 | + - `PONG` decode for a header-only frame |
| 24 | +2. Run: `go test ./internal/proto/control` |
| 25 | +3. Implement the smallest codec changes to pass. |
| 26 | +4. Re-run: `go test ./internal/proto/control` |
| 27 | +5. Commit: `feat: add game ping-pong control support` |
| 28 | + |
| 29 | +## Task 2: Accept `PONG` in `GAME` |
| 30 | +Objective: allow the live game session to tolerate the automatic client reply path. |
| 31 | + |
| 32 | +Files: |
| 33 | +- Modify: `internal/game/flow.go` |
| 34 | +- Modify: `internal/game/flow_test.go` |
| 35 | + |
| 36 | +Steps: |
| 37 | +1. Write a failing test proving `PONG` is accepted in `GAME`. |
| 38 | +2. Run: `go test ./internal/game` |
| 39 | +3. Implement the smallest game-phase branch to decode and ignore `PONG`. |
| 40 | +4. Re-run: `go test ./internal/game` |
| 41 | +5. Keep the session in `GAME` and emit no server frames. |
| 42 | + |
| 43 | +## Task 3: Update docs |
| 44 | +Objective: record the phase-stable in-world control path. |
| 45 | + |
| 46 | +Files: |
| 47 | +- Modify: `README.md` |
| 48 | +- Modify: `spec/protocol/README.md` |
| 49 | +- Modify: `spec/protocol/boot-path.md` |
| 50 | +- Modify: `spec/protocol/packet-matrix.md` |
| 51 | +- Modify: `spec/protocol/session-phases.md` |
| 52 | +- Create: `spec/protocol/game-ping-pong.md` |
| 53 | + |
| 54 | +Steps: |
| 55 | +1. Document the packet layouts and the no-response `PONG` behavior. |
| 56 | +2. Note that the current slice does not yet add a periodic ping scheduler. |
| 57 | +3. Run: `go test ./... && go vet ./...` |
| 58 | +4. Commit: `docs: document game ping-pong slice` |
| 59 | + |
| 60 | +## Verification |
| 61 | +- `go test ./internal/proto/control ./internal/game` |
| 62 | +- `go test ./...` |
| 63 | +- `go vet ./...` |
| 64 | + |
| 65 | +## Scope guardrails |
| 66 | +- Do not add a timer loop or heartbeat scheduler in this slice. |
| 67 | +- Do not introduce disconnect policy for missed replies yet. |
| 68 | +- Do not broaden the slice into movement, chat, or warp work. |
| 69 | +- Do not invent extra `PONG` payload fields. |
0 commit comments