Files
scrabble-game/pkg
Ilia Denisov 41a642ef97
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 37s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m8s
R4: push enrichment — events carry a state delta, kill the last poll
Enrich the in-app live stream into a delta channel so the UI renders a move from the event without a follow-up game.state, and make the matchmaking poll a stream-down fallback.

- pkg/fbs: trailing fields on opponent_moved (move+game+bag_len), your_turn (move_count), match_found (state), game_over (game), notify (account/invitation/state), MoveResult (rack+bag_len); regenerate Go + TS.
- backend: notify owns the FB encoding (encode.go + payload.go input structs); game/lobby/social map their domain types in. emitMove builds the move delta; game.Service.InitialState feeds match_found/game_started the recipient's initial StateView; friends/invitations notify carry their account/invitation. The move-commit response (submit_play/pass/exchange/resign) returns the actor's refilled rack + bag size.
- gateway: MoveResult transcode carries rack+bag_len.
- ui: pure lib/gamedelta.ts reducer advances the per-game cache keyed on move_count (idempotent + gap-safe); app.svelte seeds the cache on match_found/game_started; Game.svelte applies the delta (commit/pass/exchange/resign drop their load()); NewGame polls only while app.streamAlive is false.
- docs: ARCHITECTURE §10, FUNCTIONAL(+ru), backend/gateway/ui READMEs; PRERELEASE R4 marked done + Refinements.
2026-06-10 08:01:50 +02:00
..

pkg

Shared wire contracts for the Scrabble platform (module scrabble/pkg), imported by both backend and gateway. It carries no logic — only the generated message types and the schemas they come from.

Layout

proto/push/v1/    # backend -> gateway live-event gRPC channel (Push.Subscribe)
                  #   committed generated Go (*.pb.go, *_grpc.pb.go)
fbs/scrabble.fbs  # FlatBuffers edge payloads (one `scrabblefb` namespace)
fbs/scrabblefb/   # committed generated Go for the schema
  • proto/push/v1 is the single gRPC server-stream the backend exposes and the gateway subscribes to (Event{user_id, kind, payload, event_id}); the payload is an opaque FlatBuffers body the gateway forwards verbatim.
  • proto/telegram/v1 is the Telegram connector's RPC contract (Stage 9; Stage 11 added ValidateLoginWidget for the web Login Widget sign-in).
  • fbs holds the client↔gateway request/response and event payloads as FlatBuffers tables. The backend encodes the push payloads from these types; the gateway transcodes the rest to and from the backend's JSON; the UI generates TypeScript from the same .fbs (Stage 7).

Generated code

Committed (CI only builds it); regenerate dev-time after editing the schemas:

make -C pkg tools   # go install protoc-gen-go + protoc-gen-go-grpc
make -C pkg gen     # buf generate (proto) + flatc (fbs)

flatc is pinned to 23.5.26 to match the github.com/google/flatbuffers Go runtime in go.mod; generating with another version is refused.

Workspace wiring

scrabble/pkg is a bare-path module (no dot), so — like scrabble-solver — it cannot be fetched as a versioned dependency. go.work carries use ./pkg and replace scrabble/pkg v0.0.0 => ./pkg; consumers require scrabble/pkg v0.0.0.