Summary
Implement per-move stat capture in gameNamespace.js by writing move deltas into a single Firestore document at matchLogs/{roomId}, using an append-only moves array (not a subcollection).
Schema alignment
This issue follows docs/design/player-profile-schema.md:
- One parent document per match:
matchLogs/{roomId}
- Per-move deltas stored in
moves[] on that parent document
- Typical payload (~16KB) remains well below Firestore's 1MB document limit
Implementation
- On first confirmed
make_move, create (or upsert) matchLogs/{roomId}.
- Ensure base fields exist (example):
roomId, createdAt, startedAt, players, completedAt, winner
moves: []
- After each confirmed move, append one entry to
moves[] with:
moveNum, color, from, to, piece, capturedPiece
evalBefore, evalAfter, severity
veiled, veiledOpponent, sacrifice
inversionClause, promotedTo
timeMs, timestamp
- On
gameOver=true, set:
Constraints
moves[] must be append-only and preserve chronological order.
- Writes should be idempotent against duplicate move events (no duplicate
moveNum entries).
- Keep document size under Firestore limits for expected match lengths.
Acceptance Criteria
- A completed remote match produces one readable
matchLogs/{roomId} document.
- Per-move deltas are present in
moves[] and ordered by moveNum.
- No subcollection is used for move logs.
- Finalization fields (
completedAt, winner) are set on game completion.
Summary
Implement per-move stat capture in
gameNamespace.jsby writing move deltas into a single Firestore document atmatchLogs/{roomId}, using an append-onlymovesarray (not a subcollection).Schema alignment
This issue follows
docs/design/player-profile-schema.md:matchLogs/{roomId}moves[]on that parent documentImplementation
make_move, create (or upsert)matchLogs/{roomId}.roomId,createdAt,startedAt,players,completedAt,winnermoves: []moves[]with:moveNum,color,from,to,piece,capturedPieceevalBefore,evalAfter,severityveiled,veiledOpponent,sacrificeinversionClause,promotedTotimeMs,timestampgameOver=true, set:completedAtwinnerConstraints
moves[]must be append-only and preserve chronological order.moveNumentries).Acceptance Criteria
matchLogs/{roomId}document.moves[]and ordered bymoveNum.completedAt,winner) are set on game completion.