Stage 17: fix the robot-nudge frequency + per-game push language
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 11s
CI / ui (pull_request) Has been skipped
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m6s

Two owner-reported defects from a live contour game.

A. Frequency: the robot's proactive nudge fired hourly for 12h+ (a 12h idle threshold
   then the 1h cooldown, uncapped). Replaced with a lengthening, randomized schedule
   (proactiveNudgeGap): the first nudge ~60-90 min into the human's turn, each later gap
   growing toward 1-6h (uniform sample in [60min, ceil], ceil ramping 90min->6h over 12h
   of idle, measured from the previous nudge), so a long wait gets a handful of
   increasingly-spaced reminders instead of a stream.

B. Language: out-of-app push routed by the recipient's GLOBAL service_language
   (last-login-wins), so after re-logging via the RU bot an English game's nudges came
   from the RU bot. Now a game push (your_turn, game_over, nudge, match_found) carries
   the game's own language (engine.Variant.Language) on push.Event, and the gateway
   routes by it (falling back to service_language for non-game pushes). The New-Game
   variant-gating guarantees the game's bot is one the player has started, so delivery is
   never blocked.

Tests: proactiveNudgeGap unit + retimed TestRobotProactiveNudge; TestVariantLanguage;
emit your_turn/game_over language; TestNudgeRoutedByGameLanguage integration. Docs:
ARCHITECTURE (§7 nudge, §10/§13 routing), FUNCTIONAL (+ _ru), PLAN tracker.
This commit is contained in:
Ilia Denisov
2026-06-09 08:06:58 +02:00
parent 265e442252
commit bf7dca0a09
21 changed files with 257 additions and 45 deletions
+20 -7
View File
@@ -79,11 +79,16 @@ func (x *SubscribeRequest) GetGatewayId() string {
// FlatBuffers-encoded body for that kind. event_id is a correlation id the
// gateway carries through to the client envelope.
type Event struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"`
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
EventId string `protobuf:"bytes,4,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"`
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"`
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
EventId string `protobuf:"bytes,4,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"`
// language routes an out-of-app push to a specific per-language bot (Stage 17): for a game
// event it carries the game's language ("en"/"ru") so the notification comes from the game's
// bot rather than the recipient's last-login bot. Empty falls back to the recipient's service
// language at the gateway.
Language string `protobuf:"bytes,5,opt,name=language,proto3" json:"language,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -146,6 +151,13 @@ func (x *Event) GetEventId() string {
return ""
}
func (x *Event) GetLanguage() string {
if x != nil {
return x.Language
}
return ""
}
var File_push_v1_push_proto protoreflect.FileDescriptor
const file_push_v1_push_proto_rawDesc = "" +
@@ -153,12 +165,13 @@ const file_push_v1_push_proto_rawDesc = "" +
"\x12push/v1/push.proto\x12\x10scrabble.push.v1\"1\n" +
"\x10SubscribeRequest\x12\x1d\n" +
"\n" +
"gateway_id\x18\x01 \x01(\tR\tgatewayId\"i\n" +
"gateway_id\x18\x01 \x01(\tR\tgatewayId\"\x85\x01\n" +
"\x05Event\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\x12\x12\n" +
"\x04kind\x18\x02 \x01(\tR\x04kind\x12\x18\n" +
"\apayload\x18\x03 \x01(\fR\apayload\x12\x19\n" +
"\bevent_id\x18\x04 \x01(\tR\aeventId2R\n" +
"\bevent_id\x18\x04 \x01(\tR\aeventId\x12\x1a\n" +
"\blanguage\x18\x05 \x01(\tR\blanguage2R\n" +
"\x04Push\x12J\n" +
"\tSubscribe\x12\".scrabble.push.v1.SubscribeRequest\x1a\x17.scrabble.push.v1.Event0\x01B#Z!scrabble/pkg/proto/push/v1;pushv1b\x06proto3"
+5
View File
@@ -33,4 +33,9 @@ message Event {
string kind = 2;
bytes payload = 3;
string event_id = 4;
// language routes an out-of-app push to a specific per-language bot (Stage 17): for a game
// event it carries the game's language ("en"/"ru") so the notification comes from the game's
// bot rather than the recipient's last-login bot. Empty falls back to the recipient's service
// language at the gateway.
string language = 5;
}