refactor(battle-node): de-magic wire flags and scattered constants

Quality pass from the 2026-06-04 BattleNode review (audit in the outer
repo). All changes are behavior-preserving — identical wire bytes,
verified by the full 1008-test suite staying green.

- Name scattered magic numbers: crypto key/IV lengths, outbound-sequencer
  base, WS receive buffer / EIO ping / SID length, polite-close timeout,
  upgrade-credential keys, battle-id digit math, deterministic-turn spin.
- resultCode = 1 -> (int)ReceiveNodeResultCode.Success across body records.
- Pong "3" -> EngineIoPacketType.Pong; remove dead NoOpBotParticipant.Touch
  (replace with #pragma warning disable CS0067).
- Wire-flag enums, serialized as numbers via JsonNumberEnumConverter:
  turnState -> TurnState{First,Second}, isSelf -> CardOwner{Opponent,Self},
  open -> ChoiceVisibility{Hidden,Open}.
- isOfficial / isInvoke -> bool / bool? via new NumericBoolJsonConverter
  (reads/writes 0/1; TDD'd). Scoped to the BattleNode wire boundary only;
  MatchContext and the HTTP/AI-start path stay int (AI-start uses -1 as a
  sentinel, so it is not boolean).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-04 20:46:09 -04:00
parent ed88683fa0
commit 24180d5b4b
38 changed files with 304 additions and 95 deletions

View File

@@ -1,7 +1,9 @@
namespace SVSim.BattleNode.Reliability;
/// <summary>
/// Body builders for the alive channel. The timer/loop that drives 5s emits lives on
/// Body builders for the alive channel ("Gungnir" is the client's codename for the
/// keepalive/connection-status channel — see <see cref="Protocol.Bodies.AlivePushBody"/>).
/// The timer/loop that drives <see cref="EmitInterval"/> emits lives on
/// BattleSession; this class is just the pure body-shape factory.
/// v1 always reports scs/ocs=ONLINE — real disconnect detection is deferred. The push
/// body itself is constructed inline in BattleSession.HandleAliveEventAsync using

View File

@@ -9,7 +9,11 @@ namespace SVSim.BattleNode.Reliability;
/// </summary>
public sealed class OutboundSequencer
{
private long _next = 1;
/// <summary>First playSeq assigned. Starts at 1, not 0 — 0 is reserved for no-stock /
/// unsequenced pushes (which carry a null PlaySeq via <see cref="WrapNoStock"/>).</summary>
private const long FirstPlaySeq = 1;
private long _next = FirstPlaySeq;
private readonly Dictionary<long, MsgEnvelope> _archive = new();
public IReadOnlyDictionary<long, MsgEnvelope> Archive => _archive;