From d12c0ab2e7a7d1d40f62991e3d097bd9090cc2ef Mon Sep 17 00:00:00 2001
From: Ben Hook <5009589+benhook1013@users.noreply.github.com>
Date: Sun, 1 Nov 2026 08:48:19 +1300
Subject: [PATCH 01/23] Keep delegation JWTs out of Redis and deny unproved
presence elevation
---
.../game-session-service/runtime-and-data.md | 3 +-
...m-architecture-redis-reset-and-recovery.md | 2 +-
...e-session-runtime-and-tick-coordination.md | 2 +
.../player-access-and-session.md | 12 +-
...r-experience-commands-and-communication.md | 12 +-
.../common/security/SessionClaims.java | 35 --
.../common/security/SessionClaimsTest.java | 30 +-
.../GameplayLocalPathReadinessProbe.java | 2 +-
.../gamesession/service/SessionContext.java | 26 ++
.../impl/GameplayPresenceRoleClassifier.java | 41 ---
.../impl/RedisGameplayPresenceService.java | 112 ++++---
...RedisMovementEffectIdempotencyService.java | 34 +-
.../impl/RedisSessionContextService.java | 30 +-
...SecretAndPresenceRedisIntegrationTest.java | 314 ++++++++++++++++++
.../impl/FakeGameplayPresenceService.java | 12 +-
.../text/SessionResumptionFlowTest.java | 36 +-
.../text/TextCommandInterpreterTest.java | 4 +-
.../command/text/WhoCommandHandlerTest.java | 16 +-
.../GameplayLocalPathReadinessProbeTest.java | 30 +-
.../GameplayPresenceRoleClassifierTest.java | 178 ----------
.../RedisGameplayPresenceServiceTest.java | 156 +++++++--
...sMovementEffectIdempotencyServiceTest.java | 36 +-
.../impl/RedisSessionContextServiceTest.java | 125 ++++++-
...essionContextSerializationTestSupport.java | 38 +++
24 files changed, 843 insertions(+), 443 deletions(-)
delete mode 100644 services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifier.java
create mode 100644 services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/impl/SessionContextSecretAndPresenceRedisIntegrationTest.java
delete mode 100644 services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifierTest.java
create mode 100644 services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/SessionContextSerializationTestSupport.java
diff --git a/design/architecture/microservices/game-session-service/runtime-and-data.md b/design/architecture/microservices/game-session-service/runtime-and-data.md
index ca2734d7e3..01bd9379da 100644
--- a/design/architecture/microservices/game-session-service/runtime-and-data.md
+++ b/design/architecture/microservices/game-session-service/runtime-and-data.md
@@ -59,9 +59,10 @@ The sections below define the target-state runtime contract. Current implementat
- Current hosted wiring still exposes one generic `firemud.redis` connection to Game Session while the shared Helm profile sets `FIREMUD_REDIS_HOST=redis-cache`; the role-specific `FIREMUD_REDIS_COORD_*` and `FIREMUD_REDIS_CACHE_*` variables are not consumed by the common Redis auto-configuration. Consequently, the live Game Session tick/session coordination path is not proven to reach Coordination Redis in that profile and may share the Cache/Rate-Limit endpoint. This is implementation drift against ADR 0171, not a target-state role assignment; named role clients, endpoint-collision failure, and role-specific health/eviction proof remain required.
- Current tick/session coordination also bypasses the target key/script boundary: `TickQueueControlService`/`TickServiceImpl` build untagged `gamesession:tick:*` keys and pass queue, pending, and lock keys together to Lua, while `RedisSessionContextService` performs watched multi-key writes across untagged `sessionctx:*` families. Those calls are not proven same-slot and can fail with `CROSSSLOT` on a supported Redis Cluster profile; the live families are not represented by the canonical builder/registry contract. This records current implementation/proof drift only; migration must use the canonical tagged builders, registered scripts, reset inventory, and fenced readback before claiming cluster support.
- The current `IpConnectionLimiter` stores the source address directly in `ipconn:
` keys and `sessionip:` values, and registration passes both keys to one Lua invocation without a shared hash slot, so it fails with `CROSSSLOT` on Redis Cluster. This is not the ADR 0087 opaque-HMAC subject contract and has no evidenced tenant/policy scope or current Cache/Rate-Limit loss profile. The limiter remains a current heuristic seam; convergence requires one mutation on one opaque subject bucket, session lifecycle correlation outside exact cross-key atomicity, an owner-declared subject scope, opaque full-digest mapping, and focused privacy, isolation, eviction, reset, clustered, and unavailable-store proof; no final reverse-index design is implied.
-- The current `LOGIN` path receives Account's `game-session-account-delegation` JWT and places it in the persisted `SessionContext.jwt` value, which is serialized into Redis by `RedisSessionContextService`. This contradicts the process-local/no-raw-delegation-JWT boundary in ADR 0031. The target binding must persist only bounded non-secret evidence such as the token hash or opaque rebind handle; stripping the token, fenced cleanup of existing values, and focused no-secret serialization proof remain implementation work.
+- Current Redis session-context and movement writers persist a projection without the raw `game-session-account-delegation` JWT, preserving other binding fields. Canonical/index and movement legacy reads return the same non-secret projection without rewriting retained values or extending their lifetime. Existing stored bytes are not globally erased: owner-fenced retained-value cleanup, complete rotation/rebind metadata and the rest of [ADR 0031](../../decisions/adr-0031-revocation-safe-session-token-rotation-and-logout.md) remain incomplete. Focused receiving proof and limits are tracked in [Player Access](../../../project-management/implementation-tracking/player-access-and-session.md#session-secret-and-presence-containment).
- An unregistered initial-LOGIN journal, cleanup owner and exact-context Redis CAS/closure adapter are prepared independently of that legacy handler. The adapter follows the [initial-context owner](../../system-architecture-redis.md#initial-login-context-aggregate) and requires the separately supplied protected binding and external qualification; it does not implement legacy Redis context save/delete, trusted TCP custody or runtime LOGIN. Qualified source and physical proof status belongs to [Player Access and Session](../../../project-management/implementation-tracking/player-access-and-session.md#initial-private-gameplay-login-issuance-source-intake).
- Bounded durable semantic reconnect-context persistence is partial: ordered `resume_transcript_entry` rows and best-effort Redis caching are live, while namespace-key migration to `{tenantId, playableStateNamespaceId, characterId}`, the distinct durable `resumeContextGeneration` episode fence and termination protocol, complete-envelope hard-bound accounting and omission-marker convergence, and post-logout replay suppression remain implementation/proof gaps.
+- Current live-presence registration, returned legacy projections and ordinary activity updates use `PLAYER`: no independently verified gameplay-grant carrier is available. JWT global/scoped roles and retained cached elevation grant no gameplay capability. Read projection does not persist the demotion or refresh TTL; ordinary activity writes retain their existing lifetime behavior and preserve other fields. The [authentication owner](../../system-architecture-authentication.md#global-role-to-route-class-matrix-normative) defines grant authority; [Player Experience](../../../project-management/implementation-tracking/player-experience-commands-and-communication.md#communication-social-and-presence) records implementation/proof limits.
- Current live/recent presence projection wiring is implementation drift: `gameplaypresence:session:`, its game-instance/account set indexes, and `accountrecentpresence::` are written with untagged, separate Redis value/index operations. Game Session remains the target owner, but the physical shapes, storage-role classification, exact scope, partial-write handling, reset/rebuild/readback behavior, and private-by-failure contract are unproved; the [Redis owner and reset catalog](../../system-architecture-redis-reset-and-recovery.md#reset-policy-matrix-prefix-summary) records these current families without accepting them as target authority.
- Current LOOK handling writes the legacy `lookcache::` projection even though reads remain authoritative/uncached. Its ten-minute, session-or-instance-only scope lacks the target viewer, policy, and causal read-fence identity; it is disposable implementation drift and must not be treated as the target `view:room-look:*` cache. See the [Redis cache catalog](../../system-architecture-redis-cache-reference.md#cache-rate-limit-key-catalog).
diff --git a/design/architecture/system-architecture-redis-reset-and-recovery.md b/design/architecture/system-architecture-redis-reset-and-recovery.md
index 3b64506781..13a48e6578 100644
--- a/design/architecture/system-architecture-redis-reset-and-recovery.md
+++ b/design/architecture/system-architecture-redis-reset-and-recovery.md
@@ -236,7 +236,7 @@ A region- or tenant-scoped reset parent cannot claim global account- or issuer-i
| `session:game:index:realm-grant:{tenantGameplayTag}:` | Coordination | **Reset-sensitive with mandatory binding reconciliation** | At tenant scope, the lifecycle-bound private/playtest grant lookup may be dropped; at region scope, the key remains and only members affected by the selected region are updated or reconciled from durable binding inventory, preserving unrelated regions and tenants. Reset tooling enumerates the complete expected tuple set from the exact Account v1 inventory, obtains every key through the shared `grant/v1` lifecycle-qualified realm-grant index builder, and keeps realm admission and grant-driven revocation fenced until Game Session rebuilds or reconciles and reads back those exact entries under current Account grant authority. | `grantScopeId` is the exact canonical scope ID for the complete Account-owned tuple. Reset and reconciliation never concatenate world/realm selectors or other tuple fields independently. The entries are tenant-scoped, shard-local bounded lookup evidence; Account state remains authoritative, and stale, wrong-lifecycle, or cross-tenant entries are removed. Public-production and unscoped bindings have no entry. |
| `session:game:index:issuer:{issuerIndexLayoutTag}::` | Coordination | **Reset-sensitive with mandatory issuer-coverage rebuild** | Issuer cutoff and issuer-wide lookup remain fenced until the complete owner-defined issuer recovery result qualifies; region and tenant resets never flush a whole issuer partition. | Global per issuer across tenants and partitioned by the immutable issuer layout, not tenant-tagged. The inventory, capacity, acknowledgement, and coverage contract is owned by the linked Game Session evidence documents. |
| `session:game:{tenantGameplayTag}::` | Coordination | **Reset-sensitive** | Region and tenant resets retain or invalidate this record only under their explicit session policy. Cluster scope requires `--invalidate-sessions`; preserved-session rebind is not a cluster option. | Authoritative for connection identity and reconnect/session CAS state, but not a substitute for the owner-defined rebind/admission contract. |
-| `sessionctx:*` | Coordination | **Reset-sensitive, not preservable** | Current Game Session bootstrap and lookup context is invalidated or rebuilt by any reset; it is never covered by `--preserve-sessions` and cannot authorize gameplay. | Game Session owns this live implementation-local family. Its reset consequence is local to the family; the canonical reset lifecycle and session policy remain defined above. |
+| `sessionctx:*` | Coordination | **Reset-sensitive, not preservable** | Current Game Session bootstrap and lookup context is invalidated or rebuilt by any reset; it is never covered by `--preserve-sessions` and cannot authorize gameplay. | Game Session owns this live implementation-local family. New context/movement writes omit the raw delegation JWT; legacy reads project without rehydrating it or authorizing retained-value cleanup, as recorded by [Game Session runtime](./microservices/game-session-service/runtime-and-data.md#implementation-status). Its reset consequence is local to the family; the canonical reset lifecycle and session policy remain defined above. |
| `session:game:direct-text-worlds:v1:` | Coordination | **Reset-sensitive, not preservable UI state** | Loss, expiry or an applicable session reset invalidates the original public WORLDS menu and requires fresh `WORLDS`. A present undecodable value is refused until actual key expiry; no current supported administrative repair path is implemented, so a malformed key without a TTL can block fresh discovery indefinitely, as defined by the linked menu owner; the old snapshot is never reconstructed or its expiry extended. A tenant/region reset cannot infer key membership from this tenantless UUID key or from the numeric transport-session ID, and must not use a wildcard scan to delete, rebuild, or preserve affected menus. Cluster reset drops the family. | Game Session owns one full-key-hashed key per canonical original proxy UUID. This is observational public UI only, contains no Account identity, credentials, REALMS scope, or JOIN intent, and is outside authenticated gameplay `--preserve-sessions` recovery. See [Direct-text WORLDS UI menu](./system-architecture-redis.md#direct-text-worlds-ui-menu). |
| `session:game:initial-context:v1:*` | Coordination | **Reset-sensitive, non-preservable pre-auth state** | A whole-family invalidation declares its global impact and closes the affected initial-LOGIN boundary. A tenant or region reset cannot infer membership of tenantless records or delete this family under a tenant filter. Current recovery authority must qualify the exact global family, fence and protected binding before a physical closure continuation; missing records, retained receipts and bare absence never establish that qualification. | No expiry or recreation of missing/replaced/closed original contexts. The production external qualification producer remains unavailable; controlled fixture leases do not prove reset/restore continuity. See the [initial-context owner](./system-architecture-redis.md#initial-login-context-aggregate). |
| `gameplaypresence:session:`, `gameplaypresence:::sessions`, and `gameplaypresence::account::sessions` | **Current legacy projection (role unproved; not an accepted target prefix)** | **Reset-sensitive, private-by-failure until the target contract is proven** | These current live-presence value/index families are unavailable when missing, partial, stale, or ambiguous; `WHO` and account-presence reads must fail private-by-failure rather than expose stale or cross-scope presence. Game Session must fence the affected scope, rebuild an exact-scoped owner projection, and complete exact readback before presence is exposed again. | The current writer uses untagged keys and separate value/set mutations; it is implementation drift, not target authority. The target must choose and prove the Redis role, exact scope, atomic owner mutation, reset inventory, and readback contract. |
diff --git a/design/project-management/implementation-tracking/game-session-runtime-and-tick-coordination.md b/design/project-management/implementation-tracking/game-session-runtime-and-tick-coordination.md
index a3d4a59744..8dda305151 100644
--- a/design/project-management/implementation-tracking/game-session-runtime-and-tick-coordination.md
+++ b/design/project-management/implementation-tracking/game-session-runtime-and-tick-coordination.md
@@ -6,6 +6,8 @@ This is a non-normative implementation tracker for Game Session runtime and tick
## Current Status
+Local session-state reception strips raw delegation JWTs from Redis writes and returned legacy context/movement projections, and presence remains `PLAYER` without independently verified grants. The owning [Player Access record](./player-access-and-session.md#session-secret-and-presence-containment) and [Player Experience record](./player-experience-commands-and-communication.md#communication-social-and-presence) retain detailed scope, qualified receiving proof and cleanup/authority gaps. This does not install canonical bindings, recover credentials, grant gameplay capabilities or activate runtime admission.
+
### Historical StartSession receiver transport denials
At donor HEAD `5f92bc4a364f07799b19e25180166f5bc81157d7`, five freshly executed cases in the [historical owner-read transport test](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/HistoricalOriginalStartSessionOwnerEvidenceReadGrpcMtlsTest.java) pass against the actual historical client and unregistered receiver over loopback mTLS. Exact same-namespace World and Account clients reach the mocked repository and receive `FAILED_PRECONDITION` for missing retained evidence. Wrong-service or wrong-namespace client certificates, wrong-service or wrong-namespace server certificates, a missing client certificate, and injected authenticated end-user context are rejected before owner access. Receiving HEAD `bf09b5ac77eeae6969d3f3fa1aa8d83c35c25c18` separately passed all five cases freshly at 2026-10-17 08:06:21 UTC, with zero failures, errors or skips. The affected test static analysis, formatting, documentation links and Markdown checks also passed in the canonical gate.
diff --git a/design/project-management/implementation-tracking/player-access-and-session.md b/design/project-management/implementation-tracking/player-access-and-session.md
index 0942454c5c..3bb835ddbd 100644
--- a/design/project-management/implementation-tracking/player-access-and-session.md
+++ b/design/project-management/implementation-tracking/player-access-and-session.md
@@ -491,7 +491,7 @@ Account connect-token issuance retains its existing bootstrap and scope authenti
| `AA-1.5` Entitlements, quotas, and hosting eligibility | `partial` | `drift-found` | [Subscription management](../../architecture/microservices/account-service/subscription-management.md); [Multi-tenancy](../../architecture/system-architecture-multi-tenancy.md); [Versioning and runtime](../../architecture/system-architecture-versioning-runtime.md); [ADR 0028](../../architecture/decisions/adr-0028-differentiated-entitlement-freshness.md) | [AccountServiceImpl.java](../../../services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountServiceImpl.java); [RuntimeEntitlementsDto.java](../../../services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeEntitlementsDto.java); [Subscription.java](../../../services/account-service/src/main/java/net/firedevops/firemud/accountservice/entity/Subscription.java); [account_service.proto](../../../protos/account/v1/account_service.proto); [application.yml](../../../services/account-service/src/main/resources/application.yml) | [AccountServiceImplTest.java](../../../services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountServiceImplTest.java); [AccountGrpcServiceTest.java](../../../services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java); [PublicBootstrapRoutesProdProfileTest.java](../../../services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/controller/PublicBootstrapRoutesProdProfileTest.java) | [Realm Routing](./realm-routing-and-playable-state.md); [Game Authoring](./game-authoring-publishing-and-activation.md) | The producer returns retryable `ENTITLEMENT_UNAVAILABLE` for zero or multiple tenant subscription rows and projects status only from exactly one explicit row; gRPC carries the unavailable outcome in its error field and HTTP bootstrap routes map it to 503. Focused Account proofs cover zero rows, conflicting active/canceled rows, gRPC classification, and connect-token retry after recovery without caching an unavailable receipt. Explicit free/trial row creation and authoritative current-row selection/constraint/history remain absent. The runtime response still lacks committed status and the full explicit entitlement/freshness evidence; its row-ID-derived version/sequence and newly stamped evaluation time, quotas, real sequencing/source freshness, caching/events, strict new-commitment enforcement, five-minute continuity, and instance lifecycle enforcement remain open. The target handoff between fresh connect-token reissuance and eligible exact-binding entitlement-only reconnect continuity is unresolved: token expiry can block that continuity before Account's resume lease, and no fallback reissuance path is authorized pending owner decision. Current `past_due` handling remains gameplay-available and public-join-eligible only when the sole explicit row is `past_due`. |
| `AA-2.1` Gameplay login, character selection, and session binding | `partial` | `drift-found` | [Authentication and authorization](../../architecture/system-architecture-authentication.md); [Session behavior](../../architecture/system-architecture-session-behavior.md); [ADR 0021](../../architecture/decisions/adr-0021-staged-player-authentication-and-gameplay-binding.md); [ADR 0122](../../architecture/decisions/adr-0122-stable-playable-state-namespaces-for-runtime-replacement.md); [ADR 0132](../../architecture/decisions/adr-0132-namespace-scoped-single-character-controller.md); [ADR 0140](../../architecture/decisions/adr-0140-realm-authored-controllable-actor-entry.md); [JWT and Token Contracts](../../architecture/system-architecture-jwt-and-token-contracts.md#game-session-original-attempt-coordination); [Gateway Architecture](../../architecture/system-architecture-gateway.md#gameplay-websocket-route) | [SessionAuthenticationService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionAuthenticationService.java); [PlayCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayCommandHandler.java); [CanonicalGameplayMigrationDriverMain.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/CanonicalGameplayMigrationDriverMain.java); [CanonicalGameplayMigrationDriverProtocol.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/CanonicalGameplayMigrationDriverProtocol.java); [CanonicalGameplayMigrationDriverLauncher.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/CanonicalGameplayMigrationDriverLauncher.java); [game-session-service build](../../../services/game-session-service/build.gradle.kts); [AccountGameplayCanonicalLoginOwner.java](../../../services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/session/AccountGameplayCanonicalLoginOwner.java); [AccountGameplayDelegationIssuanceRepository.java](../../../services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountGameplayDelegationIssuanceRepository.java); [V147__account_gameplay_delegation_issuance.sql](../../../services/account-service/src/main/resources/db/migration/V147__account_gameplay_delegation_issuance.sql); [V157.1__account_gameplay_token_fence_truncate_guard.sql](../../../services/account-service/src/main/resources/db/migration/V157.1__account_gameplay_token_fence_truncate_guard.sql); [CanonicalGameplayRosterSelectionService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/CanonicalGameplayRosterSelectionService.java); [AccountServiceImpl.java](../../../services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountServiceImpl.java); [GatewayFirstPartyConnectContextEnvelope.java](../../../services/common-security/src/main/java/net/firedevops/firemud/common/security/GatewayFirstPartyConnectContextEnvelope.java); [FirstPartyConnectContext.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/FirstPartyConnectContext.java); [FirstPartyConnectContextService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/FirstPartyConnectContextService.java); [FirstPartyConnectContextRegistry.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/FirstPartyConnectContextRegistry.java); [FirstPartyConnectContextResolution.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/FirstPartyConnectContextResolution.java); [RedisFirstPartyConnectContextRegistry.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisFirstPartyConnectContextRegistry.java); [GameSessionWebSocketHandshakeInterceptor.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandshakeInterceptor.java); [GameSessionWebSocketHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandler.java); [SessionRoutingNormalizationService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionRoutingNormalizationService.java); [InitialGameplayLoginOwner.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/InitialGameplayLoginOwner.java); [CanonicalGameplayLoginAccountClient.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/CanonicalGameplayLoginAccountClient.java); [CanonicalGameplayLoginResult.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/dto/CanonicalGameplayLoginResult.java); [GameplayHandshakeFilter.java](../../../services/spring-cloud-gateway/src/main/java/net/firedevops/firemud/springcloudgateway/filter/GameplayHandshakeFilter.java); [GameplayRouteReadinessHealthIndicator.java](../../../services/spring-cloud-gateway/src/main/java/net/firedevops/firemud/springcloudgateway/health/GameplayRouteReadinessHealthIndicator.java); [FirstPartyConnectContextConfig.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/FirstPartyConnectContextConfig.java); [FirstPartyConnectContextProperties.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/FirstPartyConnectContextProperties.java); [CanonicalPlayerRouteReadService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/CanonicalPlayerRouteReadService.java); [SessionContext.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionContext.java); [RedisSessionContextService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java); [ActiveTransportSessionRegistry.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/ActiveTransportSessionRegistry.java); [InMemoryActiveTransportSessionRegistry.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/InMemoryActiveTransportSessionRegistry.java); [CommunicationRecipientDeliveryService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/CommunicationRecipientDeliveryService.java); [PlayerOutputDeliveryService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/PlayerOutputDeliveryService.java); [CanonicalGameplayIssuerAdmissionControlRepository.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerAdmissionControlRepository.java); [CanonicalGameplayIssuerAdmissionBarrierRepository.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerAdmissionBarrierRepository.java); [CanonicalGameplayIssuerBindingLocalAcknowledgementRepository.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerBindingLocalAcknowledgementRepository.java); [V1045__canonical_issuer_binding_local_acknowledgement.sql](../../../services/game-session-service/src/main/resources/db/migration/V1045__canonical_issuer_binding_local_acknowledgement.sql); [V1046__canonical_issuer_live_admission_control.sql](../../../services/game-session-service/src/main/resources/db/migration/V1046__canonical_issuer_live_admission_control.sql); [DirectTextAuthenticatedLobbyOwner.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/directtext/DirectTextAuthenticatedLobbyOwner.java); [DirectTextAuthenticatedLobbyRepository.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/DirectTextAuthenticatedLobbyRepository.java); [V1052__direct_text_authenticated_lobby.sql](../../../services/game-session-service/src/main/resources/db/migration/V1052__direct_text_authenticated_lobby.sql) | [SessionResumptionFlowTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java); [CanonicalGameplayMigrationDriverMainTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/repository/CanonicalGameplayMigrationDriverMainTest.java); [CanonicalGameplayMigrationDriverProtocolTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/repository/CanonicalGameplayMigrationDriverProtocolTest.java); [CanonicalGameplayMigrationDriverStdoutTest.java](../../../services/game-session-service/src/test/java/net/firedevops/firemud/gamesession/repository/CanonicalGameplayMigrationDriverStdoutTest.java); [migration-driver image contract](../../../dev-tools/tests/game-session-migration-driver-image-contract.sh); [V34.3 PostgreSQL fixture](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayInitialAdmissionIntentRequestIdMigrationIntegrationTest.java); [AccountGameplayCanonicalLoginOwnerTest.java](../../../services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/session/AccountGameplayCanonicalLoginOwnerTest.java); [AccountGameplayDelegationIssuancePersistenceIntegrationTest.java](../../../services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/repository/AccountGameplayDelegationIssuancePersistenceIntegrationTest.java); [CanonicalGameplayRosterSelectionServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/CanonicalGameplayRosterSelectionServiceTest.java); [GatewayFirstPartyConnectContextEnvelopeTest.java](../../../services/common-security/src/test/java/unit/net/firedevops/firemud/common/security/GatewayFirstPartyConnectContextEnvelopeTest.java); [AccountServiceImplTest.java](../../../services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountServiceImplTest.java); [AuthControllerTest.java](../../../services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/controller/AuthControllerTest.java); [FirstPartyConnectContextServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/FirstPartyConnectContextServiceTest.java); [FirstPartyConnectContextResolutionTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/FirstPartyConnectContextResolutionTest.java); [RedisFirstPartyConnectContextRegistryTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisFirstPartyConnectContextRegistryTest.java); [GameSessionWebSocketHandshakeInterceptorTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandshakeInterceptorTest.java); [GameSessionWebSocketHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandlerTest.java); [InitialGameplayLoginOwnerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/InitialGameplayLoginOwnerTest.java); [InitialGameplayLoginContextRedisIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/InitialGameplayLoginContextRedisIntegrationTest.java); [CanonicalGameplayLoginAccountClientTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/client/CanonicalGameplayLoginAccountClientTest.java); [CanonicalGameplayLoginResultTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/dto/CanonicalGameplayLoginResultTest.java); [GameplayHandshakeFilterTest.java](../../../services/spring-cloud-gateway/src/test/java/unit/net/firedevops/firemud/springcloudgateway/filter/GameplayHandshakeFilterTest.java); [GameplayRouteReadinessHealthIndicatorTest.java](../../../services/spring-cloud-gateway/src/test/java/unit/net/firedevops/firemud/springcloudgateway/health/GameplayRouteReadinessHealthIndicatorTest.java); [CanonicalPlayerRouteReadServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/CanonicalPlayerRouteReadServiceTest.java); [RedisSessionContextServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextServiceTest.java); [SessionContextTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/SessionContextTest.java); [InitialGameplayLoginCoordinationJournalRepositoryIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/InitialGameplayLoginCoordinationJournalRepositoryIntegrationTest.java); [InMemoryActiveTransportSessionRegistryTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/InMemoryActiveTransportSessionRegistryTest.java); [CommunicationRecipientDeliveryServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/CommunicationRecipientDeliveryServiceTest.java); [PlayerOutputDeliveryServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/PlayerOutputDeliveryServiceTest.java); [CanonicalGameplayIssuerAdmissionBarrierRepositoryIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerAdmissionBarrierRepositoryIntegrationTest.java); [CanonicalGameplayIssuerBindingLocalRedisOwnerIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/CanonicalGameplayIssuerBindingLocalRedisOwnerIntegrationTest.java); R849 partial execution, R855/R856 recovery, R867 and R902 focused execution have separate scopes and limits recorded above; [DirectTextAuthenticatedLobbyTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/directtext/DirectTextAuthenticatedLobbyTest.java); [DirectTextAuthenticatedLobbyIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/directtext/DirectTextAuthenticatedLobbyIntegrationTest.java) | [Realm Routing](./realm-routing-and-playable-state.md); [Player Experience](./player-experience-commands-and-communication.md) | Gameplay admission and binding remain partial. Exact-head execution scope and fixture results, including the V34.3 fixture pass, are recorded in the [consolidated proof record](#consolidated-exact-head-and-historical-proof). This verifies the tested migration fixture, not namespace-aware atomic takeover: that remains incomplete, as do issuer-index and region reconciliation and retained-binding inventory/conversion. Final immutable image build and authority, trusted bootstrap/execution, and live playable proof remain unproved. Current `/auth/connect-token` validates existing bootstrap and scope, then returns `AUTH_UNAVAILABLE` before cached-success replay, token minting, or replay/session mutation. The canonical Account producer, shared replay fence, dedicated Gateway signing keys, and deployment qualification remain unavailable. Game Session retains complete signed-context, canonical-route/private-handle, and retention sources, but public first-party bare `LOGIN`/`PLAY` deny before legacy Account, Entity, or binding effects; partial selectors never provide fallback. Generic credential LOGIN/PLAY and retained-edge rebind remain separate behavior, and earlier first-party happy-handshake/reconnect proofs are historical. Synthetic actor fallback, descriptor/template resolution, and fork-local identity proof remain gaps under [ADR 0140](../../architecture/decisions/adr-0140-realm-authored-controllable-actor-entry.md) and the [Game Session persisted-actor boundary](../../architecture/microservices/game-session-service/runtime-and-data.md#persisted-actor-admission-boundary). Deployment/mTLS and fresh-image proof for gameplay admission remain incomplete; gameplay completion under #2967/#2898 remains open. Live no-key disposal remains fail-closed pending the protected retained binding-history/restore-continuity producer tracked with `PO-3.4` in [Platform Operations](./platform-operations-and-delivery.md#capability-status). The initial private gameplay LOGIN now has local unregistered composition source; runtime caller registration and authentication, deployed ACL/TLS and signer custody, missing-Account decoy timing parity, and singleton source-fence allocator throughput remain open (see [source-intake status](#initial-private-gameplay-login-issuance-source-intake)). The default-off roster selection source has no player-command caller; `PLAY`/`LOOK` activation and live owner-RPC execution remain unproved, so `AA-2.1` stays partial. Issuer LIVE/OPEN/cutoff and INITIAL Account components are manually composed prerequisites, not complete original NEW or playable admission; custody, default registration, final admission and activation remain unqualified as recorded in the [readiness scope and proof](#canonical-new-admission-components). The authenticated lobby SQL companion exists but is unregistered; live REALMS/JOIN registration and admission remain open. |
| `AA-2.2` Reconnect, resume eligibility, and cross-device continuity | `partial` | `drift-found` | [Reconnection](../../architecture/system-architecture-reconnection.md); [Session behavior](../../architecture/system-architecture-session-behavior.md); [Redis architecture](../../architecture/system-architecture-redis.md); [ADR 0019](../../architecture/decisions/adr-0019-separate-active-session-resume-and-transcript-lifetimes.md); [ADR 0132](../../architecture/decisions/adr-0132-namespace-scoped-single-character-controller.md); [ADR 0133](../../architecture/decisions/adr-0133-fresh-edge-reconnect-without-client-input-replay.md); [ADR 0134](../../architecture/decisions/adr-0134-bounded-durable-semantic-reconnect-context.md) | [SessionAuthenticationService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionAuthenticationService.java); [RedisSessionContextService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java); [DurableScreenBufferService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/DurableScreenBufferService.java); [GameplayWebSocketBridgeHandler.java](../../../services/spring-cloud-gateway/src/main/java/net/firedevops/firemud/springcloudgateway/websocket/GameplayWebSocketBridgeHandler.java); [FirstPartyConnectContextService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/FirstPartyConnectContextService.java); [EffectiveReconnectionSettingsResolver.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/EffectiveReconnectionSettingsResolver.java) | [SessionResumptionFlowTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java); [LookWebSocketCrossServiceTest.java](../../../services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/LookWebSocketCrossServiceTest.java); [GameSessionWebSocketHandlerIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/websocket/GameSessionWebSocketHandlerIntegrationTest.java); [Telnet cross-service test](../../../services/tcp-proxy-service/src/test/java/crossservice/net/firedevops/firemud/tcpproxy/TelnetGatewayGameSessionAccountCrossServiceIntegrationTest.java) | [Player Experience](./player-experience-commands-and-communication.md); [Shared Runtime](./shared-runtime-contracts-and-persistence.md); [Platform Operations](./platform-operations-and-delivery.md) | Generic resume, bounded semantic context, and edge rebind exist, but the effective disconnected-resume window is resolved without `PLAY` enforcement; namespace-aware binding/transfer, complete authenticated real-service replacement, lifecycle/presence/stalled-input outcomes, first-party post-logout replay suppression, and proof of fresh-edge `LOOK`/prompt behavior are not complete or proved. The earlier first-party post-logout replay defect is historical: current first-party `LOGIN` and `PLAY` deny before legacy effects while the genuine context consumers remain unavailable. Successful post-logout replay suppression and a complete playable flow remain unproved. Fresh edge reconnect must not replay client input/bytes/frames and must end with fresh `LOOK` plus exactly one reconnect prompt when both effective reconnect-prompt settings are enabled, or zero reconnect prompts when either is disabled. Full token refresh, membership-version and membership-authority-generation persistence, revocation, and non-edge restart continuity remain. See AA-2.1 for the finite namespace controller-index migration-driver prefix, its implementation and proof anchors, and the unproved physical PostgreSQL/Redis, final-image, and trusted-bootstrap/execution gates. |
-| `AA-2.3` Takeover, logout, idle expiry, and revocation | `partial` | `drift-found` | [Session behavior](../../architecture/system-architecture-session-behavior.md); [Reconnection](../../architecture/system-architecture-reconnection.md); [ADR 0132](../../architecture/decisions/adr-0132-namespace-scoped-single-character-controller.md) | [PlayCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayCommandHandler.java); [LogoutCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/LogoutCommandHandler.java); [RedisSessionContextService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java); [TelnetServerHandler.java](../../../services/tcp-proxy-service/src/main/java/net/firedevops/firemud/tcpproxy/telnet/TelnetServerHandler.java); [application.yml](../../../services/game-session-service/src/main/resources/application.yml) | [SessionResumptionFlowTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java); [LogoutCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/LogoutCommandHandlerTest.java); [LookWebSocketCrossServiceTest.java](../../../services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/LookWebSocketCrossServiceTest.java) | [Player Experience](./player-experience-commands-and-communication.md); [World Runtime](./world-runtime-and-movement.md); [Gameplay Rules](./gameplay-rules-entities-and-effects.md); [Shared Runtime](./shared-runtime-contracts-and-persistence.md) | Gameplay takeover/LOGOUT and transport idle-close handling exist; target takeover requires namespace-scoped atomic monotonic `bindingGeneration`, old-input fencing, and preservation of already-admitted work as defined by [ADR 0132](../../architecture/decisions/adr-0132-namespace-scoped-single-character-controller.md), while Account control-plane logout/authority-generation workflows, full idle/session expiry convergence, and first-party post-logout replay cleanup are absent. |
+| `AA-2.3` Takeover, logout, idle expiry, and revocation | `partial` | `drift-found` | [Session behavior](../../architecture/system-architecture-session-behavior.md); [Reconnection](../../architecture/system-architecture-reconnection.md); [ADR 0132](../../architecture/decisions/adr-0132-namespace-scoped-single-character-controller.md) | [PlayCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayCommandHandler.java); [LogoutCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/LogoutCommandHandler.java); [RedisSessionContextService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java); [TelnetServerHandler.java](../../../services/tcp-proxy-service/src/main/java/net/firedevops/firemud/tcpproxy/telnet/TelnetServerHandler.java); [application.yml](../../../services/game-session-service/src/main/resources/application.yml); [SessionContext.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionContext.java); [RedisMovementEffectIdempotencyService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyService.java) | [SessionResumptionFlowTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java); [LogoutCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/LogoutCommandHandlerTest.java); [LookWebSocketCrossServiceTest.java](../../../services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/LookWebSocketCrossServiceTest.java); [RedisSessionContextServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextServiceTest.java); [RedisMovementEffectIdempotencyServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyServiceTest.java); [SessionContextSecretAndPresenceRedisIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/impl/SessionContextSecretAndPresenceRedisIntegrationTest.java) | [Player Experience](./player-experience-commands-and-communication.md); [World Runtime](./world-runtime-and-movement.md); [Gameplay Rules](./gameplay-rules-entities-and-effects.md); [Shared Runtime](./shared-runtime-contracts-and-persistence.md) | Gameplay takeover/LOGOUT and transport idle-close handling exist; target takeover requires namespace-scoped atomic monotonic `bindingGeneration`, old-input fencing, and preservation of already-admitted work as defined by [ADR 0132](../../architecture/decisions/adr-0132-namespace-scoped-single-character-controller.md), while Account control-plane logout/authority-generation workflows, full idle/session expiry convergence, and first-party post-logout replay cleanup are absent. The [local secret/presence containment](#session-secret-and-presence-containment) prevents new raw delegation-JWT persistence and projects legacy values without rehydration; physical retained-value cleanup remains open; scoped receiving proof is recorded at that owner. |
The Unit 1A Cycle 8 correction strengthens the current `AA-1.2` / `AA-2.1` boundary without claiming explicit JOIN completion. Account bootstrap character discovery requires membership permitting gameplay admission without an Entity read; connect-token issuance instead returns `AUTH_UNAVAILABLE` before membership or cached-success replay. Pre-membership world and realm discovery remains available. The canonical `JOIN_REQUIRED` eligibility and ordering contract is defined in [Authentication and authorization](../../architecture/system-architecture-authentication.md#play-current-and-target-failure-boundaries). Focused service proof now covers Account-before-roster ordering, strict persisted actor selection, and the Game Session-to-Entity peer allowlist across 124 focused tests. Deployment/mTLS and fresh-image proof remain incomplete, so the targeted `PLAY` ordering work does not complete AA-2.1, explicit JOIN, or `playableSmoke`. Account's Game Session discovery/pointer calls use bounded deadlines and translate only unavailable/deadline transport failures to retryable `AUTH_UNAVAILABLE` / HTTP 503. The admission-pointer producer and consumer reject any `stateScope` other than exact `SHARED` or `ISOLATED`, so malformed authority cannot silently become shared-state admission. Account-owned explicit public-production JOIN writing and operation checks are implemented locally; first-party text JOIN dispatch, lifecycle-aware inactive membership, complete grant/entitlement authority, and target admission-pointer fields remain open as recorded above.
@@ -634,6 +634,12 @@ The lifecycle classes are deliberately distinct:
Replay projection is separate from retained transcript storage. Generic fresh `LOGIN` plus `PLAY` after logout is not reconnect and does not replay the retained output; unexpected transport loss remains reconnect-eligible. Earlier first-party screen-buffer tests exercised a post-logout replay path, but that behavior is historical: current public first-party `LOGIN`/`PLAY` is denied before admission and cannot establish current reconnect eligibility. Revisit the target rule that deliberate logout is not a recovery replay path when the protected first-party receiver is qualified. Partial gameplay shells are not authoritative: `hasGameplayBinding` may identify a shell requiring cleanup/normalization, but full gameplay identity requires positive game-instance and character identity, and gameplay-region readiness additionally requires a room. Logout cleanup and reconnect replay therefore skip partial identity shells rather than trusting them.
+### Session secret and presence containment
+
+The local #2857 receiving group applies the process-local delegation-token rule from [ADR 0031](../../architecture/decisions/adr-0031-revocation-safe-session-token-rotation-and-logout.md) to the current Redis context family. Canonical/index and movement/effect writes serialize `SessionContext.withoutJwt()`; legacy lookup and replay projections remove the token only from returned values. Account UUID, room text, route fields and `firstPartyConnectContext` remain unchanged. Read projection grants no permission to erase old physical values, refresh their TTL, recover a token or authorize a binding. Current raw-token cleanup, complete rotation/rebind/fencing and Account logout authority remain incomplete.
+
+Presence registration, cached read projection and ordinary activity updates use `PLAYER` because no independently verified gameplay-grant carrier exists. The unused gameplay-specific `SessionClaims` helpers and their JWT-to-gameplay shortcut are removed; ordinary control-plane privilege behavior is retained. The [Game Session runtime owner](../../architecture/microservices/game-session-service/runtime-and-data.md#implementation-status) records local storage and projection consequences, while [Player Experience](./player-experience-commands-and-communication.md#communication-social-and-presence) owns detailed WHO/presence status. R1423 executes 137 selected unit cases across Common Security and Game Session plus six real-Redis cases, with zero failures, errors or skips. Physical proof uses the production Redis serializer and commands to inspect all four context/index values, read-only legacy bytes and TTL, movement/effect exact retry, and all three retained-elevation read paths followed by ordinary activity demotion. First-party-context preservation remains unit-qualified; issuer/grant inputs are controlled. The initial aggregate fails only the new integration fixture’s mutable-long static checks; making per-case IDs immutable recovers all six physical executions plus enabled integration analysis, formatting and documentation. Earlier unit/main-analysis results retain their source attribution; this is not a complete service-suite pass. No production grant, issuer, registration, transcript cleanup, admission or activation is supplied.
+
### Reconnect and Continuity
For generic Telnet and WebSocket, reconnect uses current identity and current Account runtime membership/entitlement authority, not only a prior backend token. Revoked membership, removed realm access, unavailable tenant gameplay, stale runtime target, and failed authority reads fail closed as appropriate. Current implementation resolves the effective disconnected-resume window but does not enforce it in `PLAY`; backend authority unavailability remains retryable temporary-unavailable behavior. A fresh `LOOK` redraw is the current-state authority after successful resume or fresh fallback. Reconnect target behavior and proof requirements remain canonical in [Reconnection](../../architecture/system-architecture-reconnection.md).
@@ -672,7 +678,7 @@ The auth/session/routing guardrail family is complete at its current bounded sea
The current numeric-reader guardrail is: numeric identifiers still used by an implemented seam must be present, well-formed, and positive; opaque room ids remain textual. This is not the durable cross-boundary target. [ADR 0020](../../architecture/decisions/adr-0020-scoped-domain-and-operational-identifiers.md) makes durable cross-boundary account, tenant, game-instance, character, and version identities scoped UUIDs, so replacing current numeric forms and proving scope-qualified comparison remains tracked migration work. Malformed or contradictory JWT/signed-token claims reject before identity comparison; partial routing bundles are absent or rejected, never completed by fallback; malformed persisted replay state is ignored/rejected or terminalizes only its affected durable work item; and request validation occurs before replay lookup when malformed shape could otherwise be masked by a stored effect. Malformed persisted Automation tenant identity terminalizes only that work item rather than aborting the batch. Unexpected parser/runtime bugs are not mislabeled as auth failures.
-This includes positive readers for account, tenant, session, game-instance, character, version, item/container, payment, report, formation, and control-plane identities across the participating services; current-account claims that are present but malformed count as authenticated caller context and therefore fail tenant access rather than silently becoming anonymous; and invalid session JWTs used only for presence classification consistently degrade to the ordinary `PLAYER` presence role. The corrected presence classifier ignores global roles and uses explicit current-tenant gameplay roles; broader admission, grant-issuance, and capability qualification remains tracked in [EA-2.3](./player-experience-commands-and-communication.md#communication-social-and-presence). Automation schedule due-point identities reject fractional JSON numbers as `invalid_built_in_payload` before handler, pin, quota, or durable-queue work. Runtime-version, work-item, tenant, and gameplay routing readers reject malformed/non-positive values before lookups or mutation. Entity replay-backed mutations validate expiry, required text, optional container identity, and positive quantity before replay execution so a replay hit cannot hide malformed request shape.
+This includes positive readers for account, tenant, session, game-instance, character, version, item/container, payment, report, formation, and control-plane identities across the participating services; current-account claims that are present but malformed count as authenticated caller context and therefore fail tenant access rather than silently becoming anonymous; and current presence projects only `PLAYER` until an independent gameplay-grant carrier exists. JWT global/scoped role claims and cached elevation supply no gameplay authority; broader admission, grant-issuance, and capability qualification remains tracked in [EA-2.3](./player-experience-commands-and-communication.md#communication-social-and-presence). Automation schedule due-point identities reject fractional JSON numbers as `invalid_built_in_payload` before handler, pin, quota, or durable-queue work. Runtime-version, work-item, tenant, and gameplay routing readers reject malformed/non-positive values before lookups or mutation. Entity replay-backed mutations validate expiry, required text, optional container identity, and positive quantity before replay execution so a replay hit cannot hide malformed request shape.
Replay boundaries validate both read and write sides. The legacy Account connect-token cached-success path is no longer called: `/auth/connect-token` denies after bootstrap/scope validation before any replay read, token mint, or replay/session mutation. Public-production membership replays require valid success/created flags, nonblank required text, and payload identity matching cache-key inputs; otherwise the replay is treated as unavailable rather than as authoritative success. Prepared upgrade and remote-control-plane replays likewise compare request/execution payloads before reuse. Shared control-plane response readers reject malformed or non-positive returned ids instead of projecting them into apparently valid DTOs.
@@ -776,7 +782,7 @@ No competing target state is currently recorded. Future design discussion is req
| Owner | Current responsibility | Primary contract boundary |
| --- | --- | --- |
| Account Service | Global accounts, credentials/challenges, memberships, canonical tenant roles, entitlements, non-public realm grants, account lifecycle, and explicit public-production JOIN; canonical gameplay connect-token production currently fails closed after bootstrap/scope validation | Account REST/gRPC APIs, including `/auth/bootstrap/join` and the local JOIN RPC; `/auth/connect-token` currently returns `AUTH_UNAVAILABLE` before cached-success replay, minting, or replay/session mutation; public Gateway exposure remains blocked, leave remains target-only, and Game Session text JOIN dispatch remains #2898 |
-| Common Security | **Current:** JWT/signed-token claims, current-account and tenant access, gameplay-elevated roles, legacy session attestation, current service-identity handling, and downstream caller authorization. **Target:** certificate-derived mTLS workload identity and method allowlists authorize services, while typed `PlayerExecutionContext` carries player scope | `JwtClaims`, `SessionClaims`, session-context helpers, target `PlayerExecutionContext`, certificate-derived mTLS caller identity, caller allowlists, and shared authorization checks; legacy attestation/service-identity code is implementation debt, not target player authority |
+| Common Security | **Current:** JWT/signed-token claims, current-account and tenant access, control-plane privilege claims, legacy session attestation, current service-identity handling, and downstream caller authorization. **Target:** certificate-derived mTLS workload identity and method allowlists authorize services, while typed `PlayerExecutionContext` carries player scope | `JwtClaims`, `SessionClaims`, session-context helpers, target `PlayerExecutionContext`, certificate-derived mTLS caller identity, caller allowlists, and shared authorization checks; legacy attestation/service-identity code is implementation debt, not target player authority |
| TCP Proxy | Telnet transport, hidden bootstrap envelope, bounded connection-local ordered input buffering during edge rebind, disconnect notification, and Telnet close taxonomy | Telnet bridge; `TelnetRoutingBundle`; Game Session `NotifyDisconnect` |
| Spring Cloud Gateway | Trusted TCP Proxy handshake validation, stable edge socket/session id, upstream gameplay bridge and rebind; public first-party cookie admission and shared pod readiness currently fail closed pending canonical producer/replay/key qualification. The combined readiness hold withdraws both Gateway Service endpoint families; independent route-level Service readiness remains a pre-rollout gap. | `/ws/game/**`; `TrustedTcpProxyIdentity`; current first-party cookie denial and deployment qualification in [Gateway readiness](../../architecture/microservices/spring-cloud-gateway/README.md#readiness-and-liveness) |
| Game Session | Text parser/interpreter, generic login/play/logout, Redis session context, takeover/resume, gameplay presence, admission normalization, command/control-plane routing, and redraw; first-party signed-context/route/private-handle receiving sources are local preparation, while bare first-party LOGIN/PLAY deny before downstream effects; StartSession retains and rechecks the Account-compared owner tuple | Text-command protocol; WebSocket ingress; Game Session gRPC/control plane; Account and World/Entity calls; first-party context consequence in [Authentication and authorization](../../architecture/system-architecture-authentication.md#gateway-to-game-session-connect-context-normative); owner-tuple consequence in [Game Session API Contracts](../../architecture/microservices/game-session-service/api-contracts.md) under [ADR 0047](../../architecture/decisions/adr-0047-logging-admin-as-external-operator-write-ingress.md); implementation/proof status in [AA-1.3](#capability-status) |
diff --git a/design/project-management/implementation-tracking/player-experience-commands-and-communication.md b/design/project-management/implementation-tracking/player-experience-commands-and-communication.md
index c10198a927..0463a7ebc3 100644
--- a/design/project-management/implementation-tracking/player-experience-commands-and-communication.md
+++ b/design/project-management/implementation-tracking/player-experience-commands-and-communication.md
@@ -6,7 +6,7 @@ This is a non-normative implementation tracker for player-facing commands, commu
## Current Status
-This tracker is the permanent reader-facing implementation record for player-facing commands, admission, presentation, communication, presence, and client behavior. Most bounded capabilities are live, including the stored game-authored HELP path; broader command interpretation, rich help authoring/discovery, elevated staff behavior, richer communication, and the independently released static frontend artifact/host boundary remain explicitly incomplete. The Vite frontend build now emits compiled assets under the reserved `frontend-assets` directory, but independently released hosting and browser proof remain absent. The output/reconnect lane remains partial where explicit structured schema versioning, strict complete-byte context bounds, first-party post-logout suppression, and broader client consumption are not yet proven. Deliberate-`LOGOUT` replay suppression remains an unimplemented blocker requiring focused `LOGOUT` → `LOGIN` → `PLAY` proof that no private context is replayed; this tracker does not claim the runtime fix.
+This tracker is the permanent reader-facing implementation record for player-facing commands, admission, presentation, communication, presence, and client behavior. Most bounded capabilities are live, including the stored game-authored HELP path; broader command interpretation, rich help authoring/discovery, elevated staff behavior, richer communication, and the independently released static frontend artifact/host boundary remain explicitly incomplete. Game Session currently has no independently verified gameplay-grant carrier, so newly written and returned presence uses the ordinary `PLAYER` projection; retained elevated cache values are presented as `PLAYER` until an ordinary presence update replaces them. Read-side demotion does not persist a change or extend TTL. R1423 qualifies this bounded receiving projection, with the source and recovery limits recorded below. The Vite frontend build now emits compiled assets under the reserved `frontend-assets` directory, but independently released hosting and browser proof remain absent. The output/reconnect lane remains partial where explicit structured schema versioning, strict complete-byte context bounds, first-party post-logout suppression, and broader client consumption are not yet proven. Deliberate-`LOGOUT` replay suppression remains an unimplemented blocker requiring focused `LOGOUT` → `LOGIN` → `PLAY` proof that no private context is replayed; this tracker does not claim the runtime fix.
Packet 5 moderation/communication/social provenance is represented by [ADR 0146](../../architecture/decisions/adr-0146-owner-local-moderation-enforcement.md), [ADR 0147](../../architecture/decisions/adr-0147-explicit-communication-classes-and-owner-delivery.md), [ADR 0148](../../architecture/decisions/adr-0148-social-relationship-authority-and-entity-owned-value.md), [ADR 0149](../../architecture/decisions/adr-0149-communication-type-specific-history-and-retention.md), and [ADR 0150](../../architecture/decisions/adr-0150-closed-observer-views-and-profile-scoped-shout.md); Packet 6 P0 shared consequences are represented by [ADR 0151](../../architecture/decisions/adr-0151-event-scoped-automated-tier-a-credential-compliance.md), [ADR 0152](../../architecture/decisions/adr-0152-phased-environment-bound-deployment-preflight-and-expected-bindings.md), [ADR 0153](../../architecture/decisions/adr-0153-measured-online-backup-rpo-and-future-pitr-trigger.md), [ADR 0154](../../architecture/decisions/adr-0154-automated-recovery-proof-and-differentiated-traffic-open-gates.md), [ADR 0155](../../architecture/decisions/adr-0155-automated-event-classified-post-restore-trust-reset.md), [ADR 0156](../../architecture/decisions/adr-0156-risk-tiered-progressive-rollout-with-compatibility-bounded-rollback.md), [ADR 0157](../../architecture/decisions/adr-0157-dependency-classified-liveness-readiness-and-route-admission.md), [ADR 0158](../../architecture/decisions/adr-0158-simplified-observability-degradation-without-fallback-alert-authority.md), and [ADR 0159](../../architecture/decisions/adr-0159-profile-dependent-independent-deadman-and-public-path-monitoring.md) where player-facing delivery, history, or privacy boundaries are affected. These links do not upgrade any implementation or verification state.
@@ -15,7 +15,7 @@ Packet 5 moderation/communication/social provenance is represented by [ADR 0146]
- The [Social UUID preparation boundary](#communication-social-and-presence) temporarily rejects parent-issued numeric callers and has incompatible outbound peer readers; final supported UUID behavior is restored through #3360 and #2972, with service-local safety gaps still explicit.
- Friend-presence reads still lack snapshot-bound pagination and bounded-page proof; complete these against the [Friend Presence Privacy Contract](../../architecture/microservices/social-groups-service/api-contracts.md#friend-presence-privacy-contract).
- Friend-presence continuation still needs current friendship and block-state revalidation; complete this against the [Friend Presence Privacy Contract](../../architecture/microservices/social-groups-service/api-contracts.md#target-state-snapshot-chunking-pagination-and-failure-precedence).
-- Production tenant-gameplay-grant qualification and broader runtime authorization/disclosure proof remain incomplete; focused presence classification proof does not establish admission or grant issuance under [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md).
+- Game Session has no independently verified gameplay-grant carrier today, so presence currently uses `PLAYER`; the received correction has not yet had its focused proof executed on this head. Production tenant-gameplay-grant qualification, admission, and broader runtime authorization/disclosure proof remain incomplete under [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md) and the canonical [authentication owner](../../architecture/system-architecture-authentication.md).
## Capability Status
@@ -24,9 +24,9 @@ Packet 5 moderation/communication/social provenance is represented by [ADR 0146]
| EA-1.1 Command vocabulary, stages, parsing, aliases, dispatch, and extension | `partial` - the registry, typed parser/interpreter, stage and capability gates, and admitted authored definitions are live. | `proven` - focused parser, interpreter, registry-collision, authored-registry, and capability tests cover the bounded path. | [Player command model](../../architecture/system-architecture-player-command-model.md); [Game Session protocols](../../architecture/microservices/game-session-service/protocols.md) | [TextCommandParser.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/TextCommandParser.java); [TextCommandInterpreter.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/TextCommandInterpreter.java); [AggregatingTextCommandRegistry.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/AggregatingTextCommandRegistry.java); [AdmittedTextCommandRegistryResolver.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/AdmittedTextCommandRegistryResolver.java); [V23__published_command_definitions.sql](../../../services/game-design-service/src/main/resources/db/migration/V23__published_command_definitions.sql) | [TextCommandParserTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/TextCommandParserTest.java); [TextCommandInterpreterTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/TextCommandInterpreterTest.java); [AggregatingTextCommandRegistryTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/AggregatingTextCommandRegistryTest.java); [AdmittedTextCommandRegistryResolverTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/AdmittedTextCommandRegistryResolverTest.java) | [AA-2.1](./player-access-and-session.md); [GR-4.1](./gameplay-rules-entities-and-effects.md); [AR-1.5](./game-authoring-publishing-and-activation.md); [SF-2.3](./shared-runtime-contracts-and-persistence.md) | NPC targeting, localized aliases, explicit ambiguity behavior, richer schema-driven definitions, and active-registry discovery remain absent. |
| EA-1.2 Structured output, rendering, prompts, and presentation policy | `partial` - structured output, late rendering, prompt coalescing, locale, brief, and Telnet/WebSocket projection are live. | `drift-found` - focused output, renderer, prompt, view, and WebSocket projector tests cover the implemented boundary as bounded evidence, but do not establish the full target. | [Input, output, and presentation](../../architecture/system-architecture-input-output-and-presentation.md); [MCP-01](../../architecture/decisions/adr-0145-plain-text-gameplay-and-deferred-classic-client-extensions.md) | [PlayerOutput.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/PlayerOutput.java); [TextPlayerOutputRenderer.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java); [PromptBurstCoordinator.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/PromptBurstCoordinator.java); [WebSocketOutputProjector.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjector.java); [configuration metadata](../../../services/game-session-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json) | [PlayerOutputTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/presentation/PlayerOutputTest.java); [TextPlayerOutputRendererTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRendererTest.java); [PromptBurstCoordinatorTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/presentation/PromptBurstCoordinatorTest.java); [WebSocketOutputProjectorTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java) | [EA-3.4](./player-experience-commands-and-communication.md); [AA-2.2](./player-access-and-session.md); [GR-2.2](./world-runtime-and-movement.md); [AR-2](./game-authoring-publishing-and-activation.md) | Explicit schema-version compatibility/unsupported-version proof and a production gameplay consumer of the supported versioned `PlayerOutput` semantics remain absent. The current `web-client` only generically JSON-parses WebSocket payloads as `unknown`; it is not that semantic consumer. Classic-client extension support remains deferred and unadvertised; corresponding compatibility proof remains absent. The reconnect handler currently gates prompt composition on `firemud.presentation.prompt.emit-after-reconnect-restore` but not `firemud.presentation.prompt.enabled`; the classic text renderer suppresses disabled prompts, while structured WebSocket projection can still emit one, so focused proof for either disabled reconnect-prompt setting remains missing. Combat-aware brief-on-move behavior, richer configurable prompt composition, and broader optional semantic presentation remain absent. |
| EA-1.3 Resume transcript and durable player command history | `partial` - bounded durable resume transcript retention and separate accepted-command `HISTORY` are live, but replay projection is not fully converged. | `drift-found` - focused history-flow, repository, retention, transcript expiry, and durable rehydration tests prove the implemented storage boundary; first-party post-logout replay still contradicts the canonical termination rule. | [Input, output, and presentation](../../architecture/system-architecture-input-output-and-presentation.md); [Reconnection](../../architecture/system-architecture-reconnection.md); [Player command model](../../architecture/system-architecture-player-command-model.md) | [DurableScreenBufferService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/DurableScreenBufferService.java); [ResumeTranscriptEntryRepository.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/repository/ResumeTranscriptEntryRepository.java); [PlayerCommandHistoryRecorder.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/PlayerCommandHistoryRecorder.java); [PlayerCommandHistoryStorageService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/PlayerCommandHistoryStorageService.java); [Game Session V1__baseline.sql](../../../services/game-session-service/src/main/resources/db/migration/V1__baseline.sql) | [PlayerCommandHistoryFlowTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/PlayerCommandHistoryFlowTest.java); [PlayerCommandHistoryRepositoryIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/PlayerCommandHistoryRepositoryIntegrationTest.java); [ResumeTranscriptEntryRepositoryIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/repository/ResumeTranscriptEntryRepositoryIntegrationTest.java); [DurableResumeTranscriptExpiryJobTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/DurableResumeTranscriptExpiryJobTest.java) | [AA-2.2](./player-access-and-session.md); [EA-1.2](./player-experience-commands-and-communication.md); [SF-2.1](./shared-runtime-contracts-and-persistence.md) | Generic fresh login correctly omits retained output, but the first-party connect-context path still replays retained transcript after deliberate logout. Full transcript archive/export and raw transport-byte replay remain outside this capability. |
-| EA-2.1 Chat, private communication, and mail | `partial` - room `SAY`, same-room `WHISPER`, online `TELL`, Social chat persistence, and mail APIs are live. | `drift-found` - focused Game Session, Game Logic, Social chat, and mail tests cover bounded delivery and persistence, but do not prove the target caller binding or gameplay `WHISPER` scope. | [Social Groups Service API contracts](../../architecture/microservices/social-groups-service/api-contracts.md); [Social Groups runtime/data](../../architecture/microservices/social-groups-service/runtime-and-data.md) | [CommunicationCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/CommunicationCommandHandler.java); [CommunicationAggregationService.java](../../../services/game-logic-service/src/main/java/net/firedevops/firemud/gamelogic/service/CommunicationAggregationService.java); [ChatServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/ChatServiceImpl.java); [MailServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/MailServiceImpl.java); [Social Groups proto](../../../protos/social-groups/v1/social_groups_service.proto); [mail schema](../../../services/social-groups-service/src/main/resources/db/migration/V2__mail.sql) | [CommunicationCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/CommunicationCommandHandlerTest.java); [CommunicationWebSocketCrossServiceTest.java](../../../services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/CommunicationWebSocketCrossServiceTest.java); [CommunicationAggregationServiceTest.java](../../../services/game-logic-service/src/test/java/net/firedevops/firemud/gamelogic/service/CommunicationAggregationServiceTest.java); [ChatServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/ChatServiceImplTest.java); [MailServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/MailServiceImplTest.java) | [GR-2.2](./world-runtime-and-movement.md); [EA-2.3](./player-experience-commands-and-communication.md); [PO-1.2](./platform-operations-and-delivery.md); [SF-1.1](./shared-runtime-contracts-and-persistence.md) | Offline `TELL`, `SHOUT`, configured topology propagation, richer interception, and complete gameplay mail/player-recipient presentation remain absent. Durable chat/mail history currently lacks the target type-specific retention, hold, safety-evidence disposition, and content-free receipt/idempotency lifecycle; current tests do not prove those behaviors. The live Social proto/DTO/entity/schema/key remain account-keyed and do not match the canonical gameplay `WHISPER` projection scope defined in [Social Groups runtime/data](../../architecture/microservices/social-groups-service/runtime-and-data.md). Completing that migration requires cross-service proto/DTO/entity/schema/key changes plus same-account/different-character/different-namespace and authorized-view proof; it remains a tracked implementation gap. The Gateway `/api/social/chat` route is removed/unavailable; direct Social service and gRPC caller binding remain nonconformant. During the [Social UUID preparation](#communication-social-and-presence), parent numeric callers and outbound peers are incompatible; this row does not claim restored end-to-end behavior. |
+| EA-2.1 Chat, private communication, and mail | `partial` - room `SAY`, same-room `WHISPER`, online `TELL`, Social chat persistence, and mail APIs are live. | `drift-found` - focused Game Session, Game Logic, Social chat, and mail tests cover bounded delivery and persistence, but do not prove the target caller binding or gameplay `WHISPER` scope. | [Social Groups Service API contracts](../../architecture/microservices/social-groups-service/api-contracts.md); [Social Groups runtime/data](../../architecture/microservices/social-groups-service/runtime-and-data.md) | [CommunicationCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/CommunicationCommandHandler.java); [CommunicationAggregationService.java](../../../services/game-logic-service/src/main/java/net/firedevops/firemud/gamelogic/service/CommunicationAggregationService.java); [ChatServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/ChatServiceImpl.java); [MailServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/MailServiceImpl.java); [Social Groups proto](../../../protos/social-groups/v1/social_groups_service.proto); [mail schema](../../../services/social-groups-service/src/main/resources/db/migration/V2__mail.sql) | [CommunicationCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/CommunicationCommandHandlerTest.java); [CommunicationWebSocketCrossServiceTest.java](../../../services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/CommunicationWebSocketCrossServiceTest.java); [CommunicationAggregationServiceTest.java](../../../services/game-logic-service/src/test/java/net/firedevops/firemud/gamelogic/service/CommunicationAggregationServiceTest.java); [ChatServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/ChatServiceImplTest.java); [MailServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/MailServiceImplTest.java) | [GR-2.2](./world-runtime-and-movement.md); [EA-2.3](./player-experience-commands-and-communication.md); [PO-1.2](./platform-operations-and-delivery.md); [SF-1.1](./shared-runtime-contracts-and-persistence.md) | Offline `TELL`, `SHOUT`, configured topology propagation, richer interception, and complete gameplay mail/player-recipient presentation remain absent. Durable chat/mail history currently lacks the target type-specific retention, hold, safety-evidence disposition, and content-free receipt/idempotency lifecycle; current tests do not prove those behaviors. The live Social proto/DTO/entity/schema/key remain account-keyed and do not match the canonical gameplay `WHISPER` projection scope defined in [Social Groups runtime/data](../../architecture/microservices/social-groups-service/runtime-and-data.md). Completing that migration requires cross-service proto/DTO/entity/schema/key changes plus same-account/different-character/different-namespace and authorized-view proof; it remains a tracked implementation gap. The Gateway `/api/social/chat` route is removed/unavailable; direct Social service and gRPC caller binding remain nonconformant. The earlier [Social UUID preparation](#communication-social-and-presence) temporarily rejected numeric parent callers and had incompatible peers; the bounded supported UUID flow is restored through #3360 and #2972 as recorded above, without closing these privacy, grant or admission gaps. |
| EA-2.2 Friends, groups, guilds, and social relationships | `partial` - the `FRIENDS` command plus friend, guild, and relationship APIs/storage are live. | `drift-found` - focused Game Session, Social friend, guild, and integration tests cover the bounded command and service paths, including tenant-scoped reciprocal-active reads, but this is legacy tenant-scoped proof and does not establish the target account-pair relationship contract. | [Social Groups Service](../../architecture/microservices/social-groups-service/README.md); [Social Groups API contracts](../../architecture/microservices/social-groups-service/api-contracts.md) | [FriendsCommandHandler.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java); [FriendServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/FriendServiceImpl.java); [GuildServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/GuildServiceImpl.java); [Social Groups proto](../../../protos/social-groups/v1/social_groups_service.proto); [social relationship schema](../../../services/social-groups-service/src/main/resources/db/migration/V7__account_friend_links.sql) | [FriendsCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java); [FriendServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/FriendServiceImplTest.java); [GuildServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/GuildServiceImplTest.java); [FriendControllerTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/controller/FriendControllerTest.java); [SocialGroupsApplicationIntegrationTest.java](../../../services/social-groups-service/src/test/java/integration/net/firedevops/firemud/socialgroups/SocialGroupsApplicationIntegrationTest.java) | [EA-2.3](./player-experience-commands-and-communication.md); [AA-1.1](./player-access-and-session.md); [PO-1.2](./platform-operations-and-delivery.md); [SF-2.1](./shared-runtime-contracts-and-persistence.md) | Current direct service-local reads require tenant-scoped reciprocal `active` links; one-way, inactive-reciprocal, and wrong-tenant endpoint cases are covered by integration proof. The player-facing Gateway `/api/social/friends` route is removed/unavailable; the direct service residual retains reciprocal-active filtering for future/non-edge use. Tenant-free migration/disposition and broader social client integration remain target gaps. During the [Social UUID preparation](#communication-social-and-presence), parent numeric callers and outbound peers are incompatible; this row does not claim restored end-to-end behavior. |
-| EA-2.3 Presence, visibility, and availability | `partial` - live/recent canonical presence, AFK state, filtered friend presence, account visibility, and `WHO` substrate are live. | `audited` - bounded ownership, correlation, role-classification, and player-disclosure corrections have focused source/test evidence; snapshot-bound pagination, current friendship/block revalidation, bounded-page proof, and production tenant-gameplay-grant qualification remain incomplete. | [Authentication and authorization](../../architecture/system-architecture-authentication.md); [Social Groups runtime/data](../../architecture/microservices/social-groups-service/runtime-and-data.md); [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md); [ADR 0046](../../architecture/decisions/adr-0046-bounded-friend-presence-with-private-by-failure-redaction.md) | [DefaultGameplayPresenceLifecycleService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/DefaultGameplayPresenceLifecycleService.java); [GameplayPresenceRoleClassifier.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifier.java); [AccountPresenceQueryServiceImpl.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/AccountPresenceQueryServiceImpl.java); [GameplayPresenceActivityResolver.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/GameplayPresenceActivityResolver.java); [RedisGameplayPresenceService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceService.java); [RedisAccountRecentPresenceService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisAccountRecentPresenceService.java); [AccountClient.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/client/AccountClient.java); [FriendServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/FriendServiceImpl.java); [PresenceProperties.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/PresenceProperties.java); [profile visibility schema](../../../services/account-service/src/main/resources/db/migration/V16__profile_presence_visibility.sql); [Game Session proto](../../../protos/game-session/v1/game_session_service.proto) | [DefaultGameplayPresenceLifecycleServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/DefaultGameplayPresenceLifecycleServiceTest.java); [GameplayPresenceRoleClassifierTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifierTest.java); [AccountPresenceQueryServiceImplTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/AccountPresenceQueryServiceImplTest.java); [GameplayPresenceActivityResolverTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/GameplayPresenceActivityResolverTest.java); [RedisGameplayPresenceServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceServiceTest.java); [RedisAccountRecentPresenceServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisAccountRecentPresenceServiceTest.java); [AccountClientTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/client/AccountClientTest.java); [FriendServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/FriendServiceImplTest.java); [FriendsCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java); [SocialGroupsApplicationIntegrationTest.java](../../../services/social-groups-service/src/test/java/integration/net/firedevops/firemud/socialgroups/SocialGroupsApplicationIntegrationTest.java) | [AA-2.2](./player-access-and-session.md); [AA-1.1](./player-access-and-session.md); [EA-2.2](./player-experience-commands-and-communication.md); [PO-1.2](./platform-operations-and-delivery.md) | Complete snapshot-bound pagination, current relationship/block revalidation, bounded-page proof and production tenant-gameplay-grant qualification; keep in-world concealment under gameplay policy before calling this capability proven. During the [Social UUID preparation](#communication-social-and-presence), parent numeric callers and outbound peers are incompatible; this row does not claim restored end-to-end behavior. |
+| EA-2.3 Presence, visibility, and availability | `partial` - live/recent canonical presence, AFK state, filtered friend presence, account visibility, and `WHO` substrate are live. | `drift-found` - previously recorded focused evidence remains attributed to its original sources; R1423 qualifies PLAYER-only creation/projection, cached-role read projection without persisting demotion or extending presence TTL, and ordinary field-preserving updates. Snapshot-bound pagination, current friendship/block revalidation, bounded-page proof, and production tenant-gameplay-grant qualification also remain incomplete. | [Authentication and authorization](../../architecture/system-architecture-authentication.md); [Game Session runtime and data](../../architecture/microservices/game-session-service/runtime-and-data.md); [Social Groups runtime/data](../../architecture/microservices/social-groups-service/runtime-and-data.md); [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md); [ADR 0046](../../architecture/decisions/adr-0046-bounded-friend-presence-with-private-by-failure-redaction.md) | [DefaultGameplayPresenceLifecycleService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/DefaultGameplayPresenceLifecycleService.java); [AccountPresenceQueryServiceImpl.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/AccountPresenceQueryServiceImpl.java); [GameplayPresenceActivityResolver.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/GameplayPresenceActivityResolver.java); [RedisGameplayPresenceService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceService.java); [RedisAccountRecentPresenceService.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisAccountRecentPresenceService.java); [AccountClient.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/client/AccountClient.java); [FriendServiceImpl.java](../../../services/social-groups-service/src/main/java/net/firedevops/firemud/socialgroups/service/impl/FriendServiceImpl.java); [PresenceProperties.java](../../../services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/config/PresenceProperties.java); [profile visibility schema](../../../services/account-service/src/main/resources/db/migration/V16__profile_presence_visibility.sql); [Game Session proto](../../../protos/game-session/v1/game_session_service.proto) | [DefaultGameplayPresenceLifecycleServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/DefaultGameplayPresenceLifecycleServiceTest.java); [AccountPresenceQueryServiceImplTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/AccountPresenceQueryServiceImplTest.java); [GameplayPresenceActivityResolverTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/GameplayPresenceActivityResolverTest.java); [RedisGameplayPresenceServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceServiceTest.java); [SessionResumptionFlowTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java); [WhoCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/WhoCommandHandlerTest.java); [RedisAccountRecentPresenceServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisAccountRecentPresenceServiceTest.java); [AccountClientTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/client/AccountClientTest.java); [FriendServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/FriendServiceImplTest.java); [FriendsCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java); [SocialGroupsApplicationIntegrationTest.java](../../../services/social-groups-service/src/test/java/integration/net/firedevops/firemud/socialgroups/SocialGroupsApplicationIntegrationTest.java); [SessionContextSecretAndPresenceRedisIntegrationTest.java](../../../services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/impl/SessionContextSecretAndPresenceRedisIntegrationTest.java) | [AA-2.2](./player-access-and-session.md); [AA-1.1](./player-access-and-session.md); [EA-2.2](./player-experience-commands-and-communication.md); [PO-1.2](./platform-operations-and-delivery.md) | Current Game Session has no independently verified gameplay-grant carrier, so new and returned presence uses `PLAYER`; JWT global/scoped claims and retained elevated cache roles do not elevate a presence projection. Read-side role demotion is projection-only and does not persist the role change or extend presence TTL; ordinary activity updates persist `PLAYER` while preserving the other presence fields. R1423 qualifies this bounded behavior through the Redis, WHO/reconnect units and real-Redis cases described below. Complete snapshot-bound pagination, current relationship/block revalidation, bounded-page proof, production tenant-gameplay-grant qualification, and broader authorization/disclosure proof remain open. Keep in-world concealment under gameplay policy before calling this capability proven. During the [Social UUID preparation](#communication-social-and-presence), parent numeric callers and outbound peers are incompatible; this row does not claim restored end-to-end behavior. |
| EA-2.4 Player blocking, reporting, and safety controls | `partial` - bounded internal report persistence and the live synchronous moderation-policy evaluation seam used at enforcement boundaries exist, but owner-local fixed-category restriction state, moderation cases, appeals, and caller-bound player submission remain incomplete; unsafe public administrative report persistence is disabled. | `drift-found` - focused tests prove the bounded internal gRPC persistence and live policy-evaluation seam, plus fail-closed absence of the former public route, not the canonical player-authenticated reporting boundary or target owner-local controls. | [Moderation policies](../../architecture/microservices/logging-admin-service/moderation-policies.md); [ADR 0146](../../architecture/decisions/adr-0146-owner-local-moderation-enforcement.md); [Authorization route matrix](../../architecture/system-architecture-authz-route-matrix.md); [Social Groups runtime/data](../../architecture/microservices/social-groups-service/runtime-and-data.md) | [ReportGrpcService.java](../../../services/logging-admin-service/src/main/java/net/firedevops/firemud/loggingadmin/service/impl/ReportGrpcService.java); [ReportServiceImpl.java](../../../services/logging-admin-service/src/main/java/net/firedevops/firemud/loggingadmin/service/impl/ReportServiceImpl.java); [ModerationServiceImpl.java](../../../services/logging-admin-service/src/main/java/net/firedevops/firemud/loggingadmin/service/impl/ModerationServiceImpl.java); [report proto](../../../protos/logging-admin/v1/report_service.proto); [Logging & Admin V1__baseline.sql](../../../services/logging-admin-service/src/main/resources/db/migration/V1__baseline.sql) | [LoggingAdminApplicationIntegrationTest.java](../../../services/logging-admin-service/src/test/java/integration/net/firedevops/firemud/loggingadmin/LoggingAdminApplicationIntegrationTest.java); [ReportGrpcServiceTest.java](../../../services/logging-admin-service/src/test/java/unit/net/firedevops/firemud/loggingadmin/service/impl/ReportGrpcServiceTest.java); [ModerationServiceImplTest.java](../../../services/logging-admin-service/src/test/java/unit/net/firedevops/firemud/loggingadmin/service/impl/ModerationServiceImplTest.java); [ChatServiceImplTest.java](../../../services/social-groups-service/src/test/java/unit/net/firedevops/firemud/socialgroups/service/impl/ChatServiceImplTest.java) | [PO-1.2](./platform-operations-and-delivery.md); [EA-2.1](./player-experience-commands-and-communication.md); [AA-1.3](./player-access-and-session.md) | The live `BLOCK` command is a combat action-state effect, not social blocking. Player block/mute/ignore and safety UI remain absent; reporting needs canonical administrative authorization/live reference checks before public operator ingress and a distinct player route deriving reporter and tenant identity from authenticated caller context. |
| EA-3.1 Player browser application | `partial` - a React/Vite/MUI/TanStack Query starter and generic WebSocket envelope/JSON consumer that parses payloads as `unknown` exist; Vite now emits the compiled production bundle under the reserved `frontend-assets` asset directory, but this is not the independently released static player application boundary. Native mobile is deferred pending a later product and compatibility decision. | `audited` - `npm run lint` and `npm run build` passed; the build emitted `dist/frontend-assets/react-*.svg`, `index-*.css`, and `index-*.js`. No independently released static host/public-site routing or browser proof was found. | [Frontend architecture](../../architecture/system-architecture-frontend.md); [FRONT-01](../../architecture/decisions/adr-0144-stateless-first-party-frontend-application-boundary.md) | [App.tsx](../../../web-client/src/App.tsx); [main.tsx](../../../web-client/src/main.tsx); [websocket.ts](../../../web-client/src/websocket.ts); [queryClient.ts](../../../web-client/src/api/queryClient.ts); [vite.config.ts](../../../web-client/vite.config.ts); [web-client package](../../../web-client/package.json) | No focused executable proof: `npm run lint` and `npm run build` from the [web-client package](../../../web-client/package.json) passed as general frontend validation and emitted the `dist/frontend-assets/` bundle, but no focused browser or independently released host proof exists. | [EA-1.2](./player-experience-commands-and-communication.md); [EA-3.4](./player-experience-commands-and-communication.md); [AA-2.1](./player-access-and-session.md); [PO-2.1](./platform-operations-and-delivery.md) | Independent immutable artifact/release metadata, unprivileged static host and deployment, reserved-path routing, non-secret runtime configuration, bootstrap/connect-token flow, richer player UX, mobile surface, independent rollback, and browser automation remain absent. |
| EA-3.4 Shared navigation, accessibility, client state, and interaction foundations | `partial` - shared QueryClient, local feature state, and basic socket lifecycle are present. | `audited` - production scaffolding was inspected; no focused navigation, accessibility, or client-state executable proof was found. | [Frontend architecture](../../architecture/system-architecture-frontend.md); [Input, output, and presentation](../../architecture/system-architecture-input-output-and-presentation.md) | [main.tsx](../../../web-client/src/main.tsx); [queryClient.ts](../../../web-client/src/api/queryClient.ts); [websocket.ts](../../../web-client/src/websocket.ts); [App.tsx](../../../web-client/src/App.tsx) | No focused executable proof: the [web-client package](../../../web-client/package.json) exposes general lint, build, formatting, preview, and accessibility scripts, but no focused navigation, accessibility, or client-state test exists. | [EA-1.2](./player-experience-commands-and-communication.md); [AA-2.2](./player-access-and-session.md); [SF-1.1](./shared-runtime-contracts-and-persistence.md) | Shared navigation, accessibility coverage, semantic structured gameplay client integration, reconnect/error state, and durable interaction foundations remain absent. |
@@ -76,11 +76,11 @@ At this preparation stage, Social sends UUIDs to five outbound peer operations w
Focused source proof covers complete Common Security and Social unit suites, native Social application cases, and seven physical PostgreSQL migration/repository cases preserving parent history and refusing populated legacy tables. Later selected proof covers mail caller refusal, Account response correlation and the access guard. The most recent complete unit tasks reused retained results rather than executing freshly; canonical schema, enabled analysis, formatting and documentation checks also pass. Exact run history, failures and recoveries remain in the review records. These separate proofs do not establish whole-composition or real-service gameplay safety. Current-head CI, independent review and fresh-image smoke remain separate obligations; production custody, registration, admission and activation holds remain with [Player Access and Session](./player-access-and-session.md#social-uuid-receiver-preparation).
-- Focused unit, native application and WebSocket composition proof covers the bounded presence-owner correlation, tenant-scoped classification, profile-policy projection and player-facing output corrections. The concrete implementation and executable proof anchors are listed in EA-2.3 above; exact runs, retained results and failed/recovery attribution remain in the review records. These tests use controlled collaborators and do not establish full native-service, production gameplay-grant or admission proof. Snapshot-bound continuation, current relationship/block revalidation and broader authorization/disclosure remain incomplete. [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md) and the [Friend Presence Privacy Contract](../../architecture/microservices/social-groups-service/api-contracts.md#friend-presence-privacy-contract) own the behavior.
+- Previously recorded focused unit, native application and WebSocket composition evidence covers bounded presence-owner correlation, the earlier tenant-scoped classification, profile-policy projection and player-facing output corrections; its exact run attribution remains in the review records. The current receiving source changes make Game Session presence PLAYER-only while no independent gameplay-grant carrier is available, and add cached-role projection plus ordinary-update demotion. R1423 passes 137 selected Common/Game Session units, including Redis presence, WHO and reconnect cases, plus six actual-Redis cases using the production serializer. Its physical cache cases compare retained bytes and TTL through session, game and account reads before field-preserving activity demotion. The initial aggregate fails only new integration-fixture mutable-long analysis; immutable per-case IDs recover all six physical cases and enabled integration static analysis, formatting and documentation. Earlier unit/main-analysis results keep their source attribution; these scoped results do not establish full native-service, production gameplay-grant or admission proof. Snapshot-bound continuation, current relationship/block revalidation and broader authorization/disclosure remain incomplete. [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md), the [authentication owner](../../architecture/system-architecture-authentication.md), and the [Game Session runtime/data owner](../../architecture/microservices/game-session-service/runtime-and-data.md) own the target behavior.
- Guild creation/member lifecycle callbacks emit best-effort operational logs after commit, with no committed lifecycle event on rollback. This logging supplies no durable audit or delivery guarantee. Consolidated receiving R1137 passes all 109 Social unit cases and all 15 selected native application cases, including the 12 `GuildServiceImplTest` cases covering all four actions, commit-versus-rollback context and a scoped throwing-appender regression. Enabled affected main/test/integration analysis, formatting and documentation checks pass. This proves the local dispatch boundary and supported service seams, not durable audit, delivery guarantees or current published-head/fresh-image qualification.
- Current behavior/proof: `SAY`, same-room `WHISPER`, online `TELL`, Social chat persistence, mail APIs, friends, guild APIs, presence reads, privacy settings, recipient delivery, and speech normalization are live at bounded service/API seams; focused communication, social, presence, privacy, moderation, and cross-service tests cover those seams.
- Local gaps linked to [ADR 0147](../../architecture/decisions/adr-0147-explicit-communication-classes-and-owner-delivery.md), [ADR 0148](../../architecture/decisions/adr-0148-social-relationship-authority-and-entity-owned-value.md), [ADR 0149](../../architecture/decisions/adr-0149-communication-type-specific-history-and-retention.md), and [ADR 0150](../../architecture/decisions/adr-0150-closed-observer-views-and-profile-scoped-shout.md) include offline `TELL`, profile-scoped `SHOUT`, richer topology/interception, type-specific history/acknowledgement, entity-owned social value/attachments, closed observer views, cross-pod delivery, first-party recipient presentation, and the canonical gameplay `WHISPER` recipient-scope migration. These ADR links identify gaps; they do not restate target policy.
-- Presence/privacy drift remains tracked against [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md) and [ADR 0046](../../architecture/decisions/adr-0046-bounded-friend-presence-with-private-by-failure-redaction.md). Current `gameplaypresence:*` and `accountrecentpresence:*` Redis shapes, partial-write behavior, reset/readback behavior, storage role, and proof of private-by-failure enforcement for missing, stale, partial, or ambiguous evidence remain implementation/proof gaps. The canonical raw-presence/friend-projection ownership and disclosure rules are in the [Social & Groups Friend Presence Privacy Contract](../../architecture/microservices/social-groups-service/api-contracts.md#friend-presence-privacy-contract); canonical owner/reset details also live in the [Redis reset catalog](../../architecture/system-architecture-redis-reset-and-recovery.md#reset-policy-matrix-prefix-summary). The bounded role, legacy-policy and player-disclosure corrections above do not complete snapshot-bound continuation, broad activity consumers or production gameplay-grant proof.
+- Presence/privacy drift remains tracked against [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md) and [ADR 0046](../../architecture/decisions/adr-0046-bounded-friend-presence-with-private-by-failure-redaction.md). Current `gameplaypresence:*` and `accountrecentpresence:*` Redis shapes, partial-write behavior, reset/readback behavior, storage role, and proof of private-by-failure enforcement for missing, stale, partial, or ambiguous evidence remain implementation/proof gaps. The canonical raw-presence/friend-projection ownership and disclosure rules are in the [Social & Groups Friend Presence Privacy Contract](../../architecture/microservices/social-groups-service/api-contracts.md#friend-presence-privacy-contract); canonical owner/reset details also live in the [Redis reset catalog](../../architecture/system-architecture-redis-reset-and-recovery.md#reset-policy-matrix-prefix-summary). Current Game Session has no independent gameplay-grant carrier, so the received source defaults presence to `PLAYER`; the focused R1423 receiving proof does not establish production grant qualification. This correction does not complete snapshot-bound continuation, broad activity consumers, private-by-failure enforcement, or broader authorization/disclosure proof.
### First-Party Frontend
diff --git a/services/common-security/src/main/java/net/firedevops/firemud/common/security/SessionClaims.java b/services/common-security/src/main/java/net/firedevops/firemud/common/security/SessionClaims.java
index 87381a7bac..6dbacaf48d 100644
--- a/services/common-security/src/main/java/net/firedevops/firemud/common/security/SessionClaims.java
+++ b/services/common-security/src/main/java/net/firedevops/firemud/common/security/SessionClaims.java
@@ -74,23 +74,6 @@ public boolean hasPrivilegedRole() {
return false;
}
- public boolean hasGameplayElevatedRole(String tenantId) {
- if (containsAnyRoleIgnoreCase(globalRoles, "platformAdmin", "moderator", "god")) {
- return true;
- }
- return StringUtils.hasText(tenantId)
- && containsAnyRoleIgnoreCase(scopedRoles.get(tenantId), "tenantAdmin", "moderator", "god");
- }
-
- /** Returns whether a global or requested tenant-scoped role matches a gameplay role. */
- public boolean hasGameplayRole(String tenantId, String... expectedRoles) {
- if (containsAnyRoleIgnoreCase(globalRoles, expectedRoles)) {
- return true;
- }
- return StringUtils.hasText(tenantId)
- && containsAnyRoleIgnoreCase(scopedRoles.get(tenantId), expectedRoles);
- }
-
private static List extractGlobalRoles(Object rawGlobalRoles) {
if (rawGlobalRoles == null) {
return List.of();
@@ -132,22 +115,4 @@ private static List normalizeRoleValues(List> values) {
}
return normalizedRoles;
}
-
- private static boolean containsAnyRoleIgnoreCase(
- Iterable roles, String... expectedRoles) {
- if (roles == null) {
- return false;
- }
- for (String role : roles) {
- if (!StringUtils.hasText(role)) {
- continue;
- }
- for (String expectedRole : expectedRoles) {
- if (role.equalsIgnoreCase(expectedRole)) {
- return true;
- }
- }
- }
- return false;
- }
}
diff --git a/services/common-security/src/test/java/net/firedevops/firemud/common/security/SessionClaimsTest.java b/services/common-security/src/test/java/net/firedevops/firemud/common/security/SessionClaimsTest.java
index ee682b0e38..21451e2463 100644
--- a/services/common-security/src/test/java/net/firedevops/firemud/common/security/SessionClaimsTest.java
+++ b/services/common-security/src/test/java/net/firedevops/firemud/common/security/SessionClaimsTest.java
@@ -110,37 +110,19 @@ private static Jws jwt(Claims payload) {
}
@Test
- void hasGameplayElevatedRoleRecognizesGlobalGodAndScopedModerator() {
- SessionClaims globalGod =
- new SessionClaims("11", List.of("god"), Map.of("7", List.of("player")), false, null, null);
- SessionClaims scopedModerator =
- new SessionClaims("11", List.of(), Map.of("7", List.of("moderator")), false, null, null);
-
- assertTrue(globalGod.hasGameplayElevatedRole("7"));
- assertTrue(scopedModerator.hasGameplayElevatedRole("7"));
- }
-
- @Test
- void hasGameplayElevatedRoleIgnoresUnrelatedTenantScopes() {
+ void hasPrivilegedRoleRecognizesGlobalControlPlaneRole() {
SessionClaims claims =
- new SessionClaims("11", List.of(), Map.of("8", List.of("tenantAdmin")), false, null, null);
+ new SessionClaims("11", List.of("platformAdmin"), Map.of(), false, null, null);
- assertFalse(claims.hasGameplayElevatedRole("7"));
+ assertTrue(claims.hasPrivilegedRole());
}
@Test
- void hasGameplayRoleChecksGlobalAndRequestedTenantScopeOnly() {
+ void hasPrivilegedRoleRecognizesTenantScopedControlPlaneRoles() {
SessionClaims claims =
new SessionClaims(
- "11",
- List.of("platformAdmin"),
- Map.of("7", List.of("moderator"), "8", List.of("god")),
- false,
- null,
- null);
+ "11", List.of(), Map.of("7", List.of("tenantAdmin", "moderator")), false, null, null);
- assertTrue(claims.hasGameplayRole("7", "platformAdmin"));
- assertTrue(claims.hasGameplayRole("7", "moderator"));
- assertFalse(claims.hasGameplayRole("7", "god"));
+ assertTrue(claims.hasPrivilegedRole());
}
}
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbe.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbe.java
index 9b31c88226..a0d300a082 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbe.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbe.java
@@ -55,7 +55,7 @@ public ProbeResult probeSessionContextStore() {
sessionContextService
.findByTenantAndSessionId(PROBE_TENANT_ID, probeSessionId)
.orElseThrow(() -> new IllegalStateException("session context was not persisted"));
- if (!stored.equals(context)) {
+ if (!stored.equals(context.withoutJwt())) {
return ProbeResult.down("stored session context did not round-trip");
}
return ProbeResult.up("ROUND_TRIP_OK");
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionContext.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionContext.java
index e61bc220d6..38a26786eb 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionContext.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/SessionContext.java
@@ -319,6 +319,32 @@ private static String normalizeText(String text) {
return text.trim();
}
+ /** Returns the non-secret Redis projection without changing this process-local context. */
+ public SessionContext withoutJwt() {
+ if (jwt == null) {
+ return this;
+ }
+ return new SessionContext(
+ sessionId,
+ tenantId,
+ accountId,
+ loginName,
+ characterId,
+ characterName,
+ gameInstanceId,
+ roomInstanceId,
+ null,
+ localeTag,
+ bootstrapGameInstanceId,
+ worldSlug,
+ realmSlug,
+ pointerVersion,
+ playableStateScope,
+ connectScopeId,
+ connectRequestId,
+ firstPartyConnectContext);
+ }
+
public boolean hasGameplayIdentity() {
return gameInstanceId > 0 && characterId > 0;
}
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifier.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifier.java
deleted file mode 100644
index cb97af9402..0000000000
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifier.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package net.firedevops.firemud.gamesession.service.impl;
-
-import io.jsonwebtoken.JwtException;
-import java.util.List;
-import net.firedevops.firemud.common.security.JwtUtil;
-import net.firedevops.firemud.common.security.SessionClaims;
-import net.firedevops.firemud.gamesession.service.GameplayPresenceRole;
-import net.firedevops.firemud.gamesession.service.SessionContext;
-import org.slf4j.Logger;
-import org.springframework.util.StringUtils;
-
-final class GameplayPresenceRoleClassifier {
- private GameplayPresenceRoleClassifier() {}
-
- static GameplayPresenceRole classifyRole(SessionContext context, JwtUtil jwtUtil, Logger logger) {
- if (!StringUtils.hasText(context.jwt())) {
- return GameplayPresenceRole.PLAYER;
- }
- try {
- SessionClaims claims = SessionClaims.fromJwt(jwtUtil.parseToken(context.jwt()));
- String tenantId = Long.toString(context.tenantId());
- List gameplayRoles = claims.scopedRoles().getOrDefault(tenantId, List.of());
- if (gameplayRoles.stream().anyMatch("god"::equalsIgnoreCase)) {
- return GameplayPresenceRole.GOD;
- }
- if (gameplayRoles.stream().anyMatch("tenantAdmin"::equalsIgnoreCase)) {
- return GameplayPresenceRole.ADMIN;
- }
- if (gameplayRoles.stream().anyMatch("moderator"::equalsIgnoreCase)) {
- return GameplayPresenceRole.MODERATOR;
- }
- } catch (IllegalArgumentException | JwtException ex) {
- logger.debug(
- "Failed to classify WHO role from JWT for session {} tenant {}",
- context.sessionId(),
- context.tenantId(),
- ex);
- }
- return GameplayPresenceRole.PLAYER;
- }
-}
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceService.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceService.java
index 3067fd2b96..875be79e44 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceService.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceService.java
@@ -12,7 +12,6 @@
import java.util.Set;
import java.util.function.LongSupplier;
import net.firedevops.firemud.common.LoggingUtil;
-import net.firedevops.firemud.common.security.JwtUtil;
import net.firedevops.firemud.gamesession.service.GameplayPresence;
import net.firedevops.firemud.gamesession.service.GameplayPresenceRole;
import net.firedevops.firemud.gamesession.service.GameplayPresenceService;
@@ -47,24 +46,20 @@ public final class RedisGameplayPresenceService implements GameplayPresenceServi
private final RedisTemplate redisTemplate;
private final Duration presenceTtl;
- private final JwtUtil jwtUtil;
private final LongSupplier currentTimeMillisSupplier;
@Autowired
public RedisGameplayPresenceService(
RedisTemplate redisTemplate,
- JwtUtil jwtUtil,
@Value("${FIREMUD_AUTH_SESSION_EXPIRATION_MS:3600000}") long sessionExpirationMs) {
- this(redisTemplate, jwtUtil, sessionExpirationMs, System::currentTimeMillis);
+ this(redisTemplate, sessionExpirationMs, System::currentTimeMillis);
}
RedisGameplayPresenceService(
RedisTemplate redisTemplate,
- JwtUtil jwtUtil,
long sessionExpirationMs,
LongSupplier currentTimeMillisSupplier) {
this.redisTemplate = redisTemplate;
- this.jwtUtil = jwtUtil;
this.presenceTtl = Duration.ofMillis(sessionExpirationMs);
this.currentTimeMillisSupplier = currentTimeMillisSupplier;
}
@@ -96,7 +91,7 @@ public void registerConnected(SessionContext context) {
StringUtils.hasText(context.characterName())
? context.characterName().trim()
: fallbackCharacterName(context),
- classifyRole(context),
+ GameplayPresenceRole.PLAYER,
currentTimeMillisSupplier.getAsLong(),
null,
null,
@@ -137,28 +132,29 @@ public void setExplicitAfk(long sessionId, boolean explicitAfk) {
if (existing == null) {
return;
}
+ GameplayPresence current = playerPresence(existing);
GameplayPresence updated =
new GameplayPresence(
- existing.sessionId(),
- existing.tenantId(),
- existing.gameInstanceId(),
- existing.playableStateScope(),
- existing.worldSlug(),
- existing.realmSlug(),
- existing.pointerVersion(),
- existing.accountId(),
- existing.characterId(),
- existing.characterName(),
- existing.role(),
- existing.connectedAtEpochMs(),
+ current.sessionId(),
+ current.tenantId(),
+ current.gameInstanceId(),
+ current.playableStateScope(),
+ current.worldSlug(),
+ current.realmSlug(),
+ current.pointerVersion(),
+ current.accountId(),
+ current.characterId(),
+ current.characterName(),
+ GameplayPresenceRole.PLAYER,
+ current.connectedAtEpochMs(),
explicitAfk ? Long.valueOf(currentTimeMillisSupplier.getAsLong()) : null,
- existing.lastAcceptedCommandAtEpochMs(),
- existing.lastMeaningfulActivityAtEpochMs());
+ current.lastAcceptedCommandAtEpochMs(),
+ current.lastMeaningfulActivityAtEpochMs());
valueOps.set(presenceKey(sessionId), updated, presenceTtl);
redisTemplate.expire(
- gameInstanceKey(existing.tenantId(), existing.gameInstanceId()), presenceTtl);
- if (StringUtils.hasText(existing.accountId())) {
- redisTemplate.expire(accountKey(existing.tenantId(), existing.accountId()), presenceTtl);
+ gameInstanceKey(current.tenantId(), current.gameInstanceId()), presenceTtl);
+ if (StringUtils.hasText(current.accountId())) {
+ redisTemplate.expire(accountKey(current.tenantId(), current.accountId()), presenceTtl);
}
}
@@ -170,30 +166,31 @@ public void recordCommandActivity(long sessionId, boolean meaningfulGameplayActi
return;
}
long now = currentTimeMillisSupplier.getAsLong();
+ GameplayPresence current = playerPresence(existing);
GameplayPresence updated =
new GameplayPresence(
- existing.sessionId(),
- existing.tenantId(),
- existing.gameInstanceId(),
- existing.playableStateScope(),
- existing.worldSlug(),
- existing.realmSlug(),
- existing.pointerVersion(),
- existing.accountId(),
- existing.characterId(),
- existing.characterName(),
- existing.role(),
- existing.connectedAtEpochMs(),
- existing.explicitAfkSinceEpochMs(),
+ current.sessionId(),
+ current.tenantId(),
+ current.gameInstanceId(),
+ current.playableStateScope(),
+ current.worldSlug(),
+ current.realmSlug(),
+ current.pointerVersion(),
+ current.accountId(),
+ current.characterId(),
+ current.characterName(),
+ GameplayPresenceRole.PLAYER,
+ current.connectedAtEpochMs(),
+ current.explicitAfkSinceEpochMs(),
Long.valueOf(now),
meaningfulGameplayActivity
? Long.valueOf(now)
- : existing.lastMeaningfulActivityAtEpochMs());
+ : current.lastMeaningfulActivityAtEpochMs());
valueOps.set(presenceKey(sessionId), updated, presenceTtl);
redisTemplate.expire(
- gameInstanceKey(existing.tenantId(), existing.gameInstanceId()), presenceTtl);
- if (StringUtils.hasText(existing.accountId())) {
- redisTemplate.expire(accountKey(existing.tenantId(), existing.accountId()), presenceTtl);
+ gameInstanceKey(current.tenantId(), current.gameInstanceId()), presenceTtl);
+ if (StringUtils.hasText(current.accountId())) {
+ redisTemplate.expire(accountKey(current.tenantId(), current.accountId()), presenceTtl);
}
}
@@ -229,7 +226,7 @@ public List listConnectedByGameInstance(long tenantId, long ga
continue;
}
if (presence.tenantId() == tenantId && presence.gameInstanceId() == gameInstanceId) {
- matches.add(presence);
+ matches.add(playerPresence(presence));
}
}
@@ -290,7 +287,7 @@ public Map> listConnectedByAccountIds(
setOps.remove(accountKey, sessionIdText);
continue;
}
- accountMatches.add(presence);
+ accountMatches.add(playerPresence(presence));
}
if (!accountMatches.isEmpty()) {
accountMatches.sort(ACCOUNT_PRESENCE_PREFERENCE.reversed());
@@ -305,12 +302,35 @@ public Optional findConnectedBySessionId(long sessionId) {
ValueOperations valueOps = redisTemplate.opsForValue();
try {
return Optional.ofNullable((GameplayPresence) valueOps.get(presenceKey(sessionId)))
- .filter(presence -> SessionContext.isCanonicalAccountIdentity(presence.accountId()));
+ .filter(presence -> SessionContext.isCanonicalAccountIdentity(presence.accountId()))
+ .map(RedisGameplayPresenceService::playerPresence);
} catch (SerializationException | ClassCastException ex) {
return Optional.empty();
}
}
+ private static GameplayPresence playerPresence(GameplayPresence presence) {
+ if (presence.role() == GameplayPresenceRole.PLAYER) {
+ return presence;
+ }
+ return new GameplayPresence(
+ presence.sessionId(),
+ presence.tenantId(),
+ presence.gameInstanceId(),
+ presence.playableStateScope(),
+ presence.worldSlug(),
+ presence.realmSlug(),
+ presence.pointerVersion(),
+ presence.accountId(),
+ presence.characterId(),
+ presence.characterName(),
+ GameplayPresenceRole.PLAYER,
+ presence.connectedAtEpochMs(),
+ presence.explicitAfkSinceEpochMs(),
+ presence.lastAcceptedCommandAtEpochMs(),
+ presence.lastMeaningfulActivityAtEpochMs());
+ }
+
private String presenceKey(long sessionId) {
return String.format(PRESENCE_KEY_TEMPLATE, sessionId);
}
@@ -347,10 +367,6 @@ private String accountKey(long tenantId, String accountId) {
return String.format(ACCOUNT_SET_TEMPLATE, tenantId, accountId);
}
- private GameplayPresenceRole classifyRole(SessionContext context) {
- return GameplayPresenceRoleClassifier.classifyRole(context, jwtUtil, logger);
- }
-
private String fallbackCharacterName(SessionContext context) {
if (StringUtils.hasText(context.loginName())) {
return context.loginName().trim();
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyService.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyService.java
index 2fdc1cc038..297fd089fd 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyService.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyService.java
@@ -92,7 +92,7 @@ public MoveEffectApplyResult execute(
operations.multi();
deleteIndexes(operations, current);
writeContext(operations, updated);
- operations.opsForValue().set(effectKey, updated, sessionTtl);
+ operations.opsForValue().set(effectKey, updated.withoutJwt(), sessionTtl);
if (operations.exec() != null) {
return new MoveEffectApplyResult(MoveEffectApplyStatus.APPLIED, updated);
}
@@ -116,7 +116,7 @@ private SessionContext updateRoom(SessionContext current, String destinationRoom
current.characterName(),
current.gameInstanceId(),
destinationRoomInstanceId,
- current.jwt(),
+ null,
current.localeTag(),
current.bootstrapGameInstanceId(),
current.worldSlug(),
@@ -142,7 +142,8 @@ private String normalizeRoom(String roomId) {
private SessionContext readContext(
org.springframework.data.redis.core.RedisOperations operations, String key) {
- return (SessionContext) operations.opsForValue().get(key);
+ SessionContext context = (SessionContext) operations.opsForValue().get(key);
+ return context == null ? null : context.withoutJwt();
}
private void addWatchKeys(LinkedHashSet watchKeys, SessionContext context) {
@@ -186,23 +187,32 @@ private void deleteIndexes(
private void writeContext(
org.springframework.data.redis.core.RedisOperations operations,
SessionContext context) {
+ SessionContext persistedContext = context.withoutJwt();
var ops = operations.opsForValue();
ops.set(
- SessionContextRedisKeys.contextKey(context.tenantId(), context.sessionId()),
- context,
+ SessionContextRedisKeys.contextKey(
+ persistedContext.tenantId(), persistedContext.sessionId()),
+ persistedContext,
sessionTtl);
- ops.set(SessionContextRedisKeys.sessionKey(context.sessionId()), context, sessionTtl);
- if (context.hasGameplayIdentity()) {
+ ops.set(
+ SessionContextRedisKeys.sessionKey(persistedContext.sessionId()),
+ persistedContext,
+ sessionTtl);
+ if (persistedContext.hasGameplayIdentity()) {
ops.set(
SessionContextRedisKeys.identityKey(
- context.tenantId(), context.gameInstanceId(), context.characterId()),
- context,
+ persistedContext.tenantId(),
+ persistedContext.gameInstanceId(),
+ persistedContext.characterId()),
+ persistedContext,
sessionTtl);
- if (hasGameplayName(context)) {
+ if (hasGameplayName(persistedContext)) {
ops.set(
SessionContextRedisKeys.nameKey(
- context.tenantId(), context.gameInstanceId(), context.characterName()),
- context,
+ persistedContext.tenantId(),
+ persistedContext.gameInstanceId(),
+ persistedContext.characterName()),
+ persistedContext,
sessionTtl);
}
}
diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java
index 7a765efaa7..38bc9e03d6 100644
--- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java
+++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextService.java
@@ -221,7 +221,7 @@ private SessionContext readContext(
throw new SessionContextUnavailableException(
"Retained session context has a non-canonical Account identity", null);
}
- return context;
+ return context == null ? null : context.withoutJwt();
}
private Optional findContextForLookup(String key) {
@@ -231,7 +231,7 @@ private Optional findContextForLookup(String key) {
throw new SessionContextUnavailableException(
"Retained session context has a non-canonical Account identity", null);
}
- return Optional.ofNullable(context);
+ return Optional.ofNullable(context).map(SessionContext::withoutJwt);
} catch (SerializationException | ClassCastException ex) {
throw new SessionContextUnavailableException("Retained session context is unreadable", ex);
}
@@ -274,18 +274,28 @@ private void deleteIndexes(
private void writeContext(
org.springframework.data.redis.core.RedisOperations operations,
SessionContext context) {
+ SessionContext persistedContext = context.withoutJwt();
var ops = operations.opsForValue();
- ops.set(contextKey(context.tenantId(), context.sessionId()), context, sessionTtl);
- ops.set(sessionKey(context.sessionId()), context, sessionTtl);
- if (context.hasGameplayIdentity()) {
+ ops.set(
+ contextKey(persistedContext.tenantId(), persistedContext.sessionId()),
+ persistedContext,
+ sessionTtl);
+ ops.set(sessionKey(persistedContext.sessionId()), persistedContext, sessionTtl);
+ if (persistedContext.hasGameplayIdentity()) {
ops.set(
- identityKey(context.tenantId(), context.gameInstanceId(), context.characterId()),
- context,
+ identityKey(
+ persistedContext.tenantId(),
+ persistedContext.gameInstanceId(),
+ persistedContext.characterId()),
+ persistedContext,
sessionTtl);
- if (StringUtils.hasText(context.characterName())) {
+ if (StringUtils.hasText(persistedContext.characterName())) {
ops.set(
- nameKey(context.tenantId(), context.gameInstanceId(), context.characterName()),
- context,
+ nameKey(
+ persistedContext.tenantId(),
+ persistedContext.gameInstanceId(),
+ persistedContext.characterName()),
+ persistedContext,
sessionTtl);
}
}
diff --git a/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/impl/SessionContextSecretAndPresenceRedisIntegrationTest.java b/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/impl/SessionContextSecretAndPresenceRedisIntegrationTest.java
new file mode 100644
index 0000000000..7d7864ce0a
--- /dev/null
+++ b/services/game-session-service/src/test/java/integration/net/firedevops/firemud/gamesession/service/impl/SessionContextSecretAndPresenceRedisIntegrationTest.java
@@ -0,0 +1,314 @@
+package net.firedevops.firemud.gamesession.service.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import net.firedevops.firemud.common.config.DatabaseAutoConfiguration;
+import net.firedevops.firemud.common.config.PostgresProperties;
+import net.firedevops.firemud.common.config.RedisProperties;
+import net.firedevops.firemud.gamesession.service.GameplayPresence;
+import net.firedevops.firemud.gamesession.service.GameplayPresenceRole;
+import net.firedevops.firemud.gamesession.service.MovementEffectIdempotencyService.MoveEffectApplyStatus;
+import net.firedevops.firemud.gamesession.service.SessionContext;
+import net.firedevops.firemud.test.TestContainerImages;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+import org.springframework.data.redis.core.RedisCallback;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/** Physical containment proof with controlled records, not issuer, grant or admission authority. */
+@Testcontainers(disabledWithoutDocker = true)
+@SuppressWarnings("resource")
+class SessionContextSecretAndPresenceRedisIntegrationTest {
+ private static final String ACCOUNT = "b8d093f7-cb70-40ed-9fac-3c82d4bf28f1";
+ private static final String RAW_JWT = "private-delegation-jwt-must-remain-process-local";
+ private static final Duration STORE_TTL = Duration.ofMinutes(2);
+ private static final Duration RETAINED_TTL = Duration.ofSeconds(20);
+ private static final AtomicLong SEQUENCE = new AtomicLong(90_000L);
+
+ @Container
+ private static final GenericContainer> REDIS =
+ new GenericContainer<>(TestContainerImages.redis()).withExposedPorts(6379);
+
+ private final List ownedKeys = new ArrayList<>();
+ private LettuceConnectionFactory connectionFactory;
+ private RedisTemplate template;
+ private RedisSessionContextService sessions;
+ private RedisMovementEffectIdempotencyService movement;
+ private final long sessionId = SEQUENCE.incrementAndGet();
+ private final long gameInstanceId = sessionId + 1_000L;
+ private final long characterId = sessionId + 2_000L;
+
+ @BeforeEach
+ void setUp() {
+ connectionFactory =
+ new LettuceConnectionFactory(
+ new RedisStandaloneConfiguration(REDIS.getHost(), REDIS.getMappedPort(6379)));
+ connectionFactory.afterPropertiesSet();
+ template =
+ new DatabaseAutoConfiguration(new PostgresProperties(), new RedisProperties())
+ .redisTemplate(connectionFactory);
+ template.afterPropertiesSet();
+ sessions = new RedisSessionContextService(template, STORE_TTL.toMillis());
+ movement = new RedisMovementEffectIdempotencyService(template, STORE_TTL.toMillis());
+ ownedKeys.addAll(contextKeys());
+ ownedKeys.add(effectKey());
+ ownedKeys.add(presenceKey());
+ ownedKeys.add(gamePresenceKey());
+ ownedKeys.add(accountPresenceKey());
+ }
+
+ @AfterEach
+ void tearDown() {
+ try {
+ if (template != null) {
+ // Only this case's exact keys; no database-wide cleanup or shared Redis ownership.
+ template.delete(ownedKeys);
+ }
+ } finally {
+ if (connectionFactory != null) {
+ connectionFactory.destroy();
+ }
+ }
+ }
+
+ @Test
+ void canonicalAndIndexWritesPhysicallyPersistOnlyTheNoSecretProjection() {
+ SessionContext original = context("R-1021");
+
+ sessions.save(original);
+
+ for (String key : contextKeys()) {
+ assertStoredContext(key, original.withoutJwt());
+ assertThat(remainingTtl(key)).isPositive().isLessThanOrEqualTo(STORE_TTL.toMillis());
+ }
+ assertThat(original.jwt()).isEqualTo(RAW_JWT);
+ }
+
+ @Test
+ void allFourLegacyLookupsScrubOnlyReturnedValuesWithoutChangingBytesOrExtendingTtl() {
+ SessionContext legacy = context("R-1021");
+ for (String key : contextKeys()) {
+ // Seed actual legacy serialization, bypassing the corrected writer intentionally.
+ template.opsForValue().set(key, legacy, RETAINED_TTL);
+ assertThat(new String(rawValue(key), StandardCharsets.ISO_8859_1)).contains(RAW_JWT);
+ }
+ Map retained = snapshot(contextKeys());
+
+ assertThat(sessions.findByTenantAndSessionId(42L, sessionId)).contains(legacy.withoutJwt());
+ assertThat(sessions.findBySessionId(sessionId)).contains(legacy.withoutJwt());
+ assertThat(sessions.findByGameplayIdentity(42L, gameInstanceId, characterId))
+ .contains(legacy.withoutJwt());
+ assertThat(sessions.findByGameplayName(42L, gameInstanceId, "Player"))
+ .contains(legacy.withoutJwt());
+
+ assertRetainedUnchanged(retained);
+ for (String key : contextKeys()) {
+ assertThat(template.opsForValue().get(key)).isEqualTo(legacy);
+ }
+ }
+
+ @Test
+ void movementAndEffectWritesScrubLegacyJwtAndExactRetryPreservesPhysicalValuesAndTtl() {
+ SessionContext legacy = context("R-1021");
+ for (String key : contextKeys()) {
+ template.opsForValue().set(key, legacy, RETAINED_TTL);
+ }
+
+ var applied = movement.apply("physical-move", legacy, "R-2045");
+
+ assertThat(applied.status()).isEqualTo(MoveEffectApplyStatus.APPLIED);
+ SessionContext expected = context("R-2045").withoutJwt();
+ assertThat(applied.context()).isEqualTo(expected);
+ List writtenKeys = new ArrayList<>(contextKeys());
+ writtenKeys.add(effectKey());
+ for (String key : writtenKeys) {
+ assertStoredContext(key, expected);
+ // A shorter real deadline makes any retry refresh to the writer TTL observable.
+ assertThat(template.expire(key, RETAINED_TTL)).isTrue();
+ }
+ Map retained = snapshot(writtenKeys);
+
+ var replayed = movement.apply("physical-move", legacy, "R-2045");
+
+ assertThat(replayed.status()).isEqualTo(MoveEffectApplyStatus.REPLAYED);
+ assertThat(replayed.context()).isEqualTo(expected);
+ assertRetainedUnchanged(retained);
+ assertThat(legacy.jwt()).isEqualTo(RAW_JWT);
+ }
+
+ @ParameterizedTest
+ @EnumSource(
+ value = GameplayPresenceRole.class,
+ names = {"GOD", "ADMIN", "MODERATOR"})
+ void retainedElevationReadsProjectPlayerWithoutMutationAndActivityStoresPlayer(
+ GameplayPresenceRole retainedRole) {
+ GameplayPresence legacy = presence(retainedRole, 1_200L, 1_300L);
+ template.opsForValue().set(presenceKey(), legacy, RETAINED_TTL);
+ template.opsForSet().add(gamePresenceKey(), Long.toString(sessionId));
+ template.opsForSet().add(accountPresenceKey(), Long.toString(sessionId));
+ assertThat(template.expire(gamePresenceKey(), RETAINED_TTL)).isTrue();
+ assertThat(template.expire(accountPresenceKey(), RETAINED_TTL)).isTrue();
+ Map retained = snapshot(List.of(presenceKey()));
+ long gameIndexTtl = remainingTtl(gamePresenceKey());
+ long accountIndexTtl = remainingTtl(accountPresenceKey());
+ var presence = new RedisGameplayPresenceService(template, STORE_TTL.toMillis(), () -> 9_000L);
+ GameplayPresence projected = presence(GameplayPresenceRole.PLAYER, 1_200L, 1_300L);
+
+ assertThat(presence.findConnectedBySessionId(sessionId)).contains(projected);
+ assertThat(presence.listConnectedByGameInstance(42L, gameInstanceId))
+ .containsExactly(projected);
+ assertThat(presence.listConnectedByAccountIds(42L, List.of(ACCOUNT)))
+ .containsExactlyEntriesOf(Map.of(ACCOUNT, List.of(projected)));
+
+ assertRetainedUnchanged(retained);
+ assertThat(template.opsForValue().get(presenceKey())).isEqualTo(legacy);
+ assertThat(remainingTtl(gamePresenceKey())).isPositive().isLessThanOrEqualTo(gameIndexTtl);
+ assertThat(remainingTtl(accountPresenceKey()))
+ .isPositive()
+ .isLessThanOrEqualTo(accountIndexTtl);
+ assertThat(template.opsForSet().members(gamePresenceKey()))
+ .containsExactly(Long.toString(sessionId));
+ assertThat(template.opsForSet().members(accountPresenceKey()))
+ .containsExactly(Long.toString(sessionId));
+
+ presence.recordCommandActivity(sessionId, true);
+
+ assertThat(template.opsForValue().get(presenceKey()))
+ .isEqualTo(presence(GameplayPresenceRole.PLAYER, 9_000L, 9_000L));
+ assertThat(remainingTtl(presenceKey())).isGreaterThan(RETAINED_TTL.toMillis());
+ }
+
+ private SessionContext context(String room) {
+ return new SessionContext(
+ sessionId,
+ 42L,
+ ACCOUNT,
+ "player@example.com",
+ characterId,
+ "Player",
+ gameInstanceId,
+ room,
+ RAW_JWT,
+ "fr",
+ gameInstanceId,
+ "demo",
+ "production",
+ 7L,
+ "SHARED",
+ "retained-scope",
+ "retained-request");
+ }
+
+ private GameplayPresence presence(GameplayPresenceRole role, long accepted, long meaningful) {
+ return new GameplayPresence(
+ sessionId,
+ 42L,
+ gameInstanceId,
+ "SHARED",
+ "demo",
+ "production",
+ 7L,
+ ACCOUNT,
+ characterId,
+ "Player",
+ role,
+ 1_000L,
+ 1_100L,
+ accepted,
+ meaningful);
+ }
+
+ private List contextKeys() {
+ return List.of(
+ SessionContextRedisKeys.contextKey(42L, sessionId),
+ SessionContextRedisKeys.sessionKey(sessionId),
+ SessionContextRedisKeys.identityKey(42L, gameInstanceId, characterId),
+ SessionContextRedisKeys.nameKey(42L, gameInstanceId, "Player"));
+ }
+
+ private String effectKey() {
+ return SessionContextRedisKeys.movementEffectKey(42L, sessionId, "physical-move");
+ }
+
+ private String presenceKey() {
+ return "gameplaypresence:session:" + sessionId;
+ }
+
+ private String gamePresenceKey() {
+ return "gameplaypresence:42:" + gameInstanceId + ":sessions";
+ }
+
+ private String accountPresenceKey() {
+ return "gameplaypresence:42:account:" + ACCOUNT + ":sessions";
+ }
+
+ private void assertStoredContext(String key, SessionContext expected) {
+ assertThat(template.opsForValue().get(key)).isEqualTo(expected);
+ assertThat(new String(rawValue(key), StandardCharsets.ISO_8859_1)).doesNotContain(RAW_JWT);
+ }
+
+ private Map snapshot(List keys) {
+ Map retained = new LinkedHashMap<>();
+ for (String key : keys) {
+ long ttl = remainingTtl(key);
+ assertThat(ttl).isPositive();
+ retained.put(key, new RetainedValue(rawValue(key), ttl));
+ }
+ return retained;
+ }
+
+ private void assertRetainedUnchanged(Map retained) {
+ retained.forEach(
+ (key, value) -> {
+ assertThat(rawValue(key)).containsExactly(value.bytes());
+ assertThat(remainingTtl(key)).isPositive().isLessThanOrEqualTo(value.ttlMillis());
+ });
+ }
+
+ private long remainingTtl(String key) {
+ return Objects.requireNonNull(template.getExpire(key, TimeUnit.MILLISECONDS));
+ }
+
+ private byte[] rawValue(String key) {
+ byte[] serializedKey = serializedKey(key);
+ return Objects.requireNonNull(
+ template.execute(
+ (RedisCallback) connection -> connection.stringCommands().get(serializedKey)));
+ }
+
+ @SuppressWarnings("unchecked")
+ private byte[] serializedKey(String key) {
+ return Objects.requireNonNull(
+ ((RedisSerializer) Objects.requireNonNull(template.getKeySerializer()))
+ .serialize(key));
+ }
+
+ private record RetainedValue(byte[] bytes, long ttlMillis) {
+ private RetainedValue {
+ bytes = bytes.clone();
+ }
+
+ @Override
+ public byte[] bytes() {
+ return bytes.clone();
+ }
+ }
+}
diff --git a/services/game-session-service/src/test/java/net/firedevops/firemud/gamesession/service/impl/FakeGameplayPresenceService.java b/services/game-session-service/src/test/java/net/firedevops/firemud/gamesession/service/impl/FakeGameplayPresenceService.java
index cdb8c9dadd..7af02dc9a4 100644
--- a/services/game-session-service/src/test/java/net/firedevops/firemud/gamesession/service/impl/FakeGameplayPresenceService.java
+++ b/services/game-session-service/src/test/java/net/firedevops/firemud/gamesession/service/impl/FakeGameplayPresenceService.java
@@ -10,23 +10,15 @@
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import net.firedevops.firemud.common.LoggingUtil;
-import net.firedevops.firemud.common.security.JwtUtil;
import net.firedevops.firemud.gamesession.service.GameplayPresence;
+import net.firedevops.firemud.gamesession.service.GameplayPresenceRole;
import net.firedevops.firemud.gamesession.service.GameplayPresenceService;
import net.firedevops.firemud.gamesession.service.SessionContext;
-import org.slf4j.Logger;
import org.springframework.util.StringUtils;
/** Small process-local fake for command tests; production presence is Redis-backed. */
public final class FakeGameplayPresenceService implements GameplayPresenceService {
- private static final Logger logger = LoggingUtil.getLogger(FakeGameplayPresenceService.class);
private final ConcurrentMap presences = new ConcurrentHashMap<>();
- private final JwtUtil jwtUtil;
-
- public FakeGameplayPresenceService(JwtUtil jwtUtil) {
- this.jwtUtil = jwtUtil;
- }
@Override
public void registerConnected(SessionContext context) {
@@ -48,7 +40,7 @@ public void registerConnected(SessionContext context) {
StringUtils.hasText(context.characterName())
? context.characterName().trim()
: fallbackCharacterName(context),
- GameplayPresenceRoleClassifier.classifyRole(context, jwtUtil, logger),
+ GameplayPresenceRole.PLAYER,
System.currentTimeMillis(),
null,
null,
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java
index da3f685796..7d76a692ad 100644
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/SessionResumptionFlowTest.java
@@ -57,6 +57,7 @@
import net.firedevops.firemud.gamesession.service.GameplayAdmissionPointerSnapshot;
import net.firedevops.firemud.gamesession.service.GameplayPresenceActivityResolver;
import net.firedevops.firemud.gamesession.service.GameplayPresenceLifecycleService;
+import net.firedevops.firemud.gamesession.service.GameplayPresenceRole;
import net.firedevops.firemud.gamesession.service.GameplayPresenceService;
import net.firedevops.firemud.gamesession.service.PlayerCommandHistoryStorageService;
import net.firedevops.firemud.gamesession.service.ScriptEventPublisher;
@@ -125,8 +126,9 @@ class SessionResumptionFlowTest {
private final HelpCommandHandler helpHandler = new HelpCommandHandler();
private final CommunicationCommandHandler communicationHandler =
Mockito.mock(CommunicationCommandHandler.class);
- private final GameplayPresenceService gameplayPresenceService =
- new FakeGameplayPresenceService(new JwtUtil("testsecretkeytestsecretkeytest1234", 60_000L));
+ private final JwtUtil gameplayJwtUtil =
+ new JwtUtil("testsecretkeytestsecretkeytest1234", 60_000L);
+ private final GameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService();
private final GameplayPresenceLifecycleService gameplayPresenceLifecycleService =
new DefaultGameplayPresenceLifecycleService(
gameplayPresenceService,
@@ -642,6 +644,36 @@ private static SessionContext bootstrapShell(long sessionId, long bootstrapGameI
null);
}
+ @Test
+ void freshScopedAndGlobalRoleClaimsDoNotElevatePresenceAcrossReconnect() {
+ String jwt =
+ gameplayJwtUtil.generateToken(
+ ACCOUNT_ID,
+ Map.of(
+ "accountId",
+ ACCOUNT_ID,
+ "globalRoles",
+ List.of("platformAdmin", "support", "billingAdmin"),
+ "scopedRoles",
+ Map.of("22", List.of("god", "tenantAdmin", "moderator"))));
+ when(accountClient.authenticate(Mockito.anyString(), Mockito.anyString()))
+ .thenReturn(
+ AuthenticateResponse.newBuilder().setAuthToken(jwt).setAccountId(ACCOUNT_ID).build());
+
+ assertTrue(interpreter.interpret("1", LOGIN_PAYLOAD, false).commandResult().accepted());
+ assertTrue(interpreter.interpret("1", PLAY_PAYLOAD, false).commandResult().accepted());
+ assertEquals(
+ GameplayPresenceRole.PLAYER,
+ gameplayPresenceService.findConnectedBySessionId(1L).orElseThrow().role());
+
+ assertTrue(interpreter.interpret("1", LOGIN_PAYLOAD, false).commandResult().accepted());
+ assertTrue(interpreter.interpret("1", PLAY_PAYLOAD, false).commandResult().accepted());
+ assertEquals(
+ GameplayPresenceRole.PLAYER,
+ gameplayPresenceService.findConnectedBySessionId(1L).orElseThrow().role());
+ assertEquals(1.0, meterRegistry.counter("gamesession.session.resume").count());
+ }
+
private static final class InMemorySessionContextService implements SessionContextService {
private final Map sessionMap = new ConcurrentHashMap<>();
private final Map identityMap = new ConcurrentHashMap<>();
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/TextCommandInterpreterTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/TextCommandInterpreterTest.java
index 7fc3bb6793..d2a3432b95 100644
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/TextCommandInterpreterTest.java
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/TextCommandInterpreterTest.java
@@ -26,7 +26,6 @@
import net.firedevops.firemud.cache.ScreenBufferService;
import net.firedevops.firemud.common.config.FiremudCommandHistoryProperties;
import net.firedevops.firemud.common.gameplay.GameplayCatalogProperties;
-import net.firedevops.firemud.common.security.JwtUtil;
import net.firedevops.firemud.common.settings.ScopedSettingsSnapshot;
import net.firedevops.firemud.entitymanagement.v1.DropItemToRoomResponse;
import net.firedevops.firemud.entitymanagement.v1.EquipmentItem;
@@ -143,8 +142,7 @@ class TextCommandInterpreterTest {
PresentationProperties.ColorMode.NONE,
false,
new PresentationProperties.Prompt(true, true, 150L)));
- private final GameplayPresenceService gameplayPresenceService =
- new FakeGameplayPresenceService(new JwtUtil("testsecretkeytestsecretkeytest1234", 60_000L));
+ private final GameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService();
private final GameplayPresenceLifecycleService gameplayPresenceLifecycleService =
new DefaultGameplayPresenceLifecycleService(
gameplayPresenceService,
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/WhoCommandHandlerTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/WhoCommandHandlerTest.java
index 42619de5ed..08445c1fc2 100644
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/WhoCommandHandlerTest.java
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/WhoCommandHandlerTest.java
@@ -26,7 +26,7 @@ class WhoCommandHandlerTest {
@Test
void whoShowsBoundedEmptyStateWhenNobodyIsConnected() {
- FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService(jwtUtil);
+ FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService();
WhoCommandHandler handler =
new WhoCommandHandler(gameplayPresenceService, activityResolver, scriptEventPublisher);
@@ -49,8 +49,8 @@ void whoShowsBoundedEmptyStateWhenNobodyIsConnected() {
}
@Test
- void whoGroupsElevatedPlayersFirstAndPlayersAfterward() {
- FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService(jwtUtil);
+ void whoPresentsJwtRoleClaimSessionsAsPlayersWithoutGrantEvidence() {
+ FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService();
WhoCommandHandler handler =
new WhoCommandHandler(gameplayPresenceService, activityResolver, scriptEventPublisher);
String godJwt =
@@ -59,8 +59,6 @@ void whoGroupsElevatedPlayersFirstAndPlayersAfterward() {
java.util.Map.of(
"accountId",
net.firedevops.firemud.test.AccountRuntimeStubServer.accountUuidForTestFixture(1L),
- "globalRoles",
- java.util.List.of("platformAdmin"),
"scopedRoles",
java.util.Map.of("22", java.util.List.of("god"))));
@@ -85,13 +83,13 @@ void whoGroupsElevatedPlayersFirstAndPlayersAfterward() {
GameplayPresenceTestFixtures.whoBen("second@example.com"));
assertThat(result.commandResult().accepted()).isTrue();
- assertThat(render(result)).isEqualTo("Gods [2]: Aster, Dara\nPlayers [2]: Ben, Cara");
+ assertThat(render(result)).isEqualTo("Gods [0]: \nPlayers [4]: Aster, Ben, Cara, Dara");
}
@Test
void normallyJoinedGlobalStaffAppearsAsAnOrdinaryPlayer() {
for (String role : java.util.List.of("platformAdmin", "support", "billingAdmin", "god")) {
- FakeGameplayPresenceService presence = new FakeGameplayPresenceService(jwtUtil);
+ FakeGameplayPresenceService presence = new FakeGameplayPresenceService();
String token =
jwtUtil.generateToken(
GameplayPresenceTestFixtures.whoAster("staff@example.com", null).accountId(),
@@ -113,7 +111,7 @@ void normallyJoinedGlobalStaffAppearsAsAnOrdinaryPlayer() {
@Test
void whoOmitsRemovedPresenceAfterLogoutLikeCleanup() {
- FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService(jwtUtil);
+ FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService();
WhoCommandHandler handler =
new WhoCommandHandler(gameplayPresenceService, activityResolver, scriptEventPublisher);
@@ -134,7 +132,7 @@ void whoOmitsRemovedPresenceAfterLogoutLikeCleanup() {
@Test
void whoAnnotatesExplicitAndAutoAfkPlayers() {
- FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService(jwtUtil);
+ FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService();
GameplayPresenceActivityResolver resolver =
Mockito.mock(GameplayPresenceActivityResolver.class);
WhoCommandHandler handler =
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbeTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbeTest.java
index 27892167f1..0178c156d0 100644
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbeTest.java
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/health/GameplayLocalPathReadinessProbeTest.java
@@ -46,7 +46,7 @@ void sessionContextProbeReturnsUpWhenContextRoundTrips() {
PROBE_CHARACTER_ID,
0L,
"readiness-room-" + probeSequence,
- "readiness-probe"));
+ null));
});
GameplayLocalPathReadinessProbe probe =
@@ -102,11 +102,37 @@ void sessionContextProbeUsesCanonicalAccountIdentityAcceptedByRedisLookup() {
assertEquals(UUID.fromString(savedContext.accountId()).toString(), savedContext.accountId());
assertTrue(savedContext.hasAccountIdentity());
assertEquals(
- Optional.of(savedContext),
+ Optional.of(savedContext.withoutJwt()),
strictLookup.findByTenantAndSessionId(savedContext.tenantId(), savedContext.sessionId()));
verify(sessionContextService).deleteBySessionId(0L, savedContext.sessionId());
}
+ @Test
+ void sessionContextProbeRejectsStoredRawJwtAndStillOwnsOnlyItsCanaryCleanup() {
+ SessionContextService sessionContextService = mock(SessionContextService.class);
+ @SuppressWarnings("unchecked")
+ RedisTemplate redisTemplate = mock(RedisTemplate.class);
+ doAnswer(
+ invocation -> {
+ SessionContext context = invocation.getArgument(0, SessionContext.class);
+ when(sessionContextService.findByTenantAndSessionId(0L, context.sessionId()))
+ .thenReturn(Optional.of(context));
+ return null;
+ })
+ .when(sessionContextService)
+ .save(any(SessionContext.class));
+
+ ProbeResult result =
+ new GameplayLocalPathReadinessProbe(sessionContextService, redisTemplate)
+ .probeSessionContextStore();
+
+ assertEquals(false, result.ready());
+ ArgumentCaptor captor = ArgumentCaptor.forClass(SessionContext.class);
+ verify(sessionContextService).save(captor.capture());
+ verify(sessionContextService).deleteBySessionId(0L, captor.getValue().sessionId());
+ verify(redisTemplate, never()).delete(anyString());
+ }
+
@Test
void commandQueueProbeReturnsUpWhenQueueWriteRoundTrips() {
SessionContextService sessionContextService = mock(SessionContextService.class);
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifierTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifierTest.java
deleted file mode 100644
index d994e704e4..0000000000
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/GameplayPresenceRoleClassifierTest.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package net.firedevops.firemud.gamesession.service.impl;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import net.firedevops.firemud.common.security.JwtUtil;
-import net.firedevops.firemud.gamesession.service.GameplayPresenceRole;
-import net.firedevops.firemud.gamesession.service.SessionContext;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-
-class GameplayPresenceRoleClassifierTest {
- private static final JwtUtil JWT_UTIL = new JwtUtil("mysecretkey123456789012345678901", 30_000L);
- private static final String ACCOUNT_UUID = "b8d093f7-cb70-40ed-9fac-3c82d4bf28f1";
-
- @Test
- void classifyRoleReturnsPlayerWhenJwtParserThrowsIllegalArgumentException() {
- JwtUtil jwtUtil = mock(JwtUtil.class);
- Logger logger = mock(Logger.class);
- when(jwtUtil.parseToken("boom-token")).thenThrow(new IllegalArgumentException("bad jwt"));
-
- GameplayPresenceRole role =
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, "102", "player@example.com", 202L, "Ben", 7L, "R-1", "boom-token"),
- jwtUtil,
- logger);
-
- assertEquals(GameplayPresenceRole.PLAYER, role);
- }
-
- @Test
- void classifyRoleReturnsModeratorForScopedModeratorRole() {
- Logger logger = mock(Logger.class);
- String jwt =
- JWT_UTIL.generateToken(
- ACCOUNT_UUID,
- java.util.Map.of(
- "accountId",
- ACCOUNT_UUID,
- "scopedRoles",
- java.util.Map.of("22", java.util.List.of("moderator"))));
-
- GameplayPresenceRole role =
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, ACCOUNT_UUID, "player@example.com", 202L, "Ben", 7L, "R-1", jwt),
- JWT_UTIL,
- logger);
-
- assertEquals(GameplayPresenceRole.MODERATOR, role);
- }
-
- @Test
- void classifyRoleIgnoresGlobalGodRole() {
- Logger logger = mock(Logger.class);
- String jwt =
- JWT_UTIL.generateToken(
- ACCOUNT_UUID,
- java.util.Map.of("accountId", ACCOUNT_UUID, "globalRoles", java.util.List.of("god")));
-
- GameplayPresenceRole role =
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, ACCOUNT_UUID, "player@example.com", 202L, "Ben", 7L, "R-1", jwt),
- JWT_UTIL,
- logger);
-
- assertEquals(GameplayPresenceRole.PLAYER, role);
- }
-
- @Test
- void classifyRoleReturnsAdminForTenantAdminRole() {
- Logger logger = mock(Logger.class);
- String jwt =
- JWT_UTIL.generateToken(
- ACCOUNT_UUID,
- java.util.Map.of(
- "accountId",
- ACCOUNT_UUID,
- "scopedRoles",
- java.util.Map.of("22", java.util.List.of("tenantAdmin"))));
-
- GameplayPresenceRole role =
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, ACCOUNT_UUID, "player@example.com", 202L, "Ben", 7L, "R-1", jwt),
- JWT_UTIL,
- logger);
-
- assertEquals(GameplayPresenceRole.ADMIN, role);
- }
-
- @Test
- void classifyRoleDoesNotLetGlobalRolesOverrideTheTenantGrant() {
- Logger logger = mock(Logger.class);
- String jwt =
- JWT_UTIL.generateToken(
- ACCOUNT_UUID,
- java.util.Map.of(
- "accountId",
- ACCOUNT_UUID,
- "globalRoles",
- java.util.List.of("moderator", "god"),
- "scopedRoles",
- java.util.Map.of("22", java.util.List.of("tenantAdmin"))));
-
- GameplayPresenceRole role =
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, ACCOUNT_UUID, "player@example.com", 202L, "Ben", 7L, "R-1", jwt),
- JWT_UTIL,
- logger);
-
- assertEquals(GameplayPresenceRole.ADMIN, role);
- }
-
- @Test
- void classifyRoleIgnoresGlobalOperationsAndOtherTenants() {
- for (String globalRole :
- java.util.List.of("platformAdmin", "support", "billingAdmin", "moderator", "tenantAdmin")) {
- String jwt =
- JWT_UTIL.generateToken(
- ACCOUNT_UUID,
- java.util.Map.of(
- "accountId",
- ACCOUNT_UUID,
- "globalRoles",
- java.util.List.of(globalRole),
- "scopedRoles",
- java.util.Map.of("23", java.util.List.of("god"))));
- assertEquals(
- GameplayPresenceRole.PLAYER,
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, ACCOUNT_UUID, "player@example.com", 202L, "Ben", 7L, "R-1", jwt),
- JWT_UTIL,
- mock(Logger.class)));
- }
- }
-
- @Test
- void classifyRoleUsesTheHighestExplicitCurrentTenantGrant() {
- String jwt =
- JWT_UTIL.generateToken(
- ACCOUNT_UUID,
- java.util.Map.of(
- "accountId",
- ACCOUNT_UUID,
- "scopedRoles",
- java.util.Map.of("22", java.util.List.of("moderator", "tenantAdmin", "GOD"))));
- assertEquals(
- GameplayPresenceRole.GOD,
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, ACCOUNT_UUID, "player@example.com", 202L, "Ben", 7L, "R-1", jwt),
- JWT_UTIL,
- mock(Logger.class)));
- }
-
- @Test
- void classifyRoleReturnsPlayerWhenScopedRolesClaimIsMalformed() {
- Logger logger = mock(Logger.class);
- String jwt =
- JWT_UTIL.generateToken(
- ACCOUNT_UUID, java.util.Map.of("accountId", ACCOUNT_UUID, "scopedRoles", "bad"));
-
- GameplayPresenceRole role =
- GameplayPresenceRoleClassifier.classifyRole(
- new SessionContext(
- 1L, 22L, ACCOUNT_UUID, "player@example.com", 202L, "Ben", 7L, "R-1", jwt),
- JWT_UTIL,
- logger);
-
- assertEquals(GameplayPresenceRole.PLAYER, role);
- }
-}
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceServiceTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceServiceTest.java
index 3a7acd66bc..d7fe7e55e8 100644
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceServiceTest.java
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceServiceTest.java
@@ -43,7 +43,7 @@ class RedisGameplayPresenceServiceTest {
void setUp() {
when(redisTemplate.opsForValue()).thenReturn(valueOperations);
when(redisTemplate.opsForSet()).thenReturn(setOperations);
- service = new RedisGameplayPresenceService(redisTemplate, jwtUtil, TTL.toMillis());
+ service = new RedisGameplayPresenceService(redisTemplate, TTL.toMillis());
}
@Test
@@ -92,7 +92,7 @@ void registerAndQueryRejectNonCanonicalAccountIdsWithoutPresenceMutation() {
}
@Test
- void registerConnectedClassifiesInvalidJwtAsPlayer() {
+ void registerConnectedStoresPlayerForInvalidJwt() {
SessionContext context =
new SessionContext(
1L, 22L, PLAYER_ACCOUNT_ID, "player@example.com", 202L, "Ben", 7L, "R-1", "not-a-jwt");
@@ -138,22 +138,33 @@ void registerConnectedKeepsGlobalStaffInThePlayerRole() {
}
@Test
- void listConnectedByGameInstanceSortsGodsFirstAndPrunesMissingSessions() {
- String godJwt =
+ void registerConnectedDoesNotPromoteScopedJwtRolesWithoutGameplayGrantEvidence() {
+ String token =
jwtUtil.generateToken(
- GOD_ACCOUNT_ID,
+ OTHER_ACCOUNT_ID,
Map.of(
"accountId",
- GOD_ACCOUNT_ID,
- "globalRoles",
- List.of("platformAdmin"),
+ OTHER_ACCOUNT_ID,
"scopedRoles",
- Map.of("22", List.of("god"))));
- SessionContext godContext =
+ Map.of("22", List.of("god", "tenantAdmin", "moderator"))));
+ service.registerConnected(
new SessionContext(
- 1L, 22L, GOD_ACCOUNT_ID, "god@example.com", 101L, "Aster", 7L, "R-1", godJwt);
- service.registerConnected(godContext);
+ 1L, 22L, OTHER_ACCOUNT_ID, "player@example.com", 202L, "Ben", 7L, "R-1", token));
+ verify(valueOperations)
+ .set(
+ org.mockito.Mockito.eq("gameplaypresence:session:1"),
+ argThat(
+ value ->
+ value instanceof net.firedevops.firemud.gamesession.service.GameplayPresence
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .role()
+ == GameplayPresenceRole.PLAYER),
+ org.mockito.Mockito.eq(TTL));
+ }
+
+ @Test
+ void listConnectedByGameInstanceDemotesCachedElevationAndPrunesMissingSessions() {
when(setOperations.members("gameplaypresence:22:7:sessions"))
.thenReturn(new LinkedHashSet<>(List.of("1", "2")));
when(valueOperations.get("gameplaypresence:session:1"))
@@ -162,24 +173,35 @@ void listConnectedByGameInstanceSortsGodsFirstAndPrunesMissingSessions() {
1L,
22L,
7L,
+ "SHARED",
"demo",
"production",
+ 17L,
GOD_ACCOUNT_ID,
101L,
"Aster",
GameplayPresenceRole.GOD,
70L,
- null,
- null,
- null));
+ 50L,
+ 60L,
+ 65L));
when(valueOperations.get("gameplaypresence:session:2")).thenReturn(null);
var result = service.listConnectedByGameInstance(22L, 7L);
assertEquals(1, result.size());
- assertEquals(GameplayPresenceRole.GOD, result.get(0).role());
+ assertEquals(GameplayPresenceRole.PLAYER, result.get(0).role());
assertEquals("Aster", result.get(0).characterName());
+ assertEquals("SHARED", result.get(0).playableStateScope());
+ assertEquals(17L, result.get(0).pointerVersion());
+ assertEquals(50L, result.get(0).explicitAfkSinceEpochMs());
+ assertEquals(60L, result.get(0).lastAcceptedCommandAtEpochMs());
+ assertEquals(65L, result.get(0).lastMeaningfulActivityAtEpochMs());
verify(setOperations).remove("gameplaypresence:22:7:sessions", "2");
+ Mockito.verify(valueOperations, Mockito.never())
+ .set(Mockito.anyString(), Mockito.any(), Mockito.any(Duration.class));
+ Mockito.verify(redisTemplate, Mockito.never())
+ .expire(Mockito.anyString(), Mockito.any(Duration.class));
}
@Test
@@ -197,7 +219,7 @@ void listConnectedByGameInstancePrunesMalformedSessionIndexEntry() {
GOD_ACCOUNT_ID,
101L,
"Aster",
- GameplayPresenceRole.GOD,
+ GameplayPresenceRole.PLAYER,
70L,
null,
null,
@@ -218,8 +240,10 @@ void removeBySessionIdRemovesValueAndSetMembership() {
3L,
22L,
7L,
+ "ISOLATED",
"demo",
"production",
+ 17L,
PLAYER_ACCOUNT_ID,
202L,
"Ben",
@@ -238,50 +262,70 @@ void removeBySessionIdRemovesValueAndSetMembership() {
}
@Test
- void findConnectedBySessionIdReadsPresenceRecordDirectly() {
+ void findConnectedBySessionIdProjectsCachedElevationWithoutWritingOrRefreshingTtl() {
when(valueOperations.get("gameplaypresence:session:4"))
.thenReturn(
new net.firedevops.firemud.gamesession.service.GameplayPresence(
4L,
22L,
7L,
+ "SHARED",
"demo",
"production",
+ 17L,
OTHER_ACCOUNT_ID,
102L,
"Ben",
- GameplayPresenceRole.PLAYER,
+ GameplayPresenceRole.ADMIN,
70L,
- null,
- null,
- null));
+ 50L,
+ 60L,
+ 65L));
var presence = service.findConnectedBySessionId(4L);
assertEquals(true, presence.isPresent());
assertEquals(4L, presence.get().sessionId());
+ assertEquals(GameplayPresenceRole.PLAYER, presence.get().role());
+ assertEquals(22L, presence.get().tenantId());
+ assertEquals(7L, presence.get().gameInstanceId());
+ assertEquals("SHARED", presence.get().playableStateScope());
+ assertEquals(OTHER_ACCOUNT_ID, presence.get().accountId());
+ assertEquals(102L, presence.get().characterId());
+ assertEquals("Ben", presence.get().characterName());
+ assertEquals(17L, presence.get().pointerVersion());
+ assertEquals(70L, presence.get().connectedAtEpochMs());
+ assertEquals(50L, presence.get().explicitAfkSinceEpochMs());
+ assertEquals(60L, presence.get().lastAcceptedCommandAtEpochMs());
+ assertEquals(65L, presence.get().lastMeaningfulActivityAtEpochMs());
+ Mockito.verify(valueOperations, Mockito.never())
+ .set(Mockito.anyString(), Mockito.any(), Mockito.any(Duration.class));
+ Mockito.verify(redisTemplate, Mockito.never())
+ .expire(Mockito.anyString(), Mockito.any(Duration.class));
}
@Test
void recordCommandActivityRefreshesPresenceAndMeaningfulTimestampOnlyWhenRequested() {
AtomicLong now = new AtomicLong(100L);
- service = new RedisGameplayPresenceService(redisTemplate, jwtUtil, TTL.toMillis(), now::get);
+ service = new RedisGameplayPresenceService(redisTemplate, TTL.toMillis(), now::get);
when(valueOperations.get("gameplaypresence:session:3"))
.thenReturn(
new net.firedevops.firemud.gamesession.service.GameplayPresence(
3L,
22L,
7L,
+ "ISOLATED",
"demo",
"production",
+ 17L,
PLAYER_ACCOUNT_ID,
202L,
"Ben",
- GameplayPresenceRole.PLAYER,
+ GameplayPresenceRole.ADMIN,
80L,
- null,
- null,
- null));
+ 95L,
+ 99L,
+ 90L));
now.set(125L);
service.recordCommandActivity(3L, false);
@@ -292,6 +336,15 @@ void recordCommandActivityRefreshesPresenceAndMeaningfulTimestampOnlyWhenRequest
argThat(
value ->
value instanceof net.firedevops.firemud.gamesession.service.GameplayPresence
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .accountId()
+ .equals(PLAYER_ACCOUNT_ID)
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .playableStateScope()
+ .equals("ISOLATED")
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .pointerVersion()
+ == 17L
&& Long.valueOf(125L)
.equals(
((net.firedevops.firemud.gamesession.service.GameplayPresence)
@@ -299,7 +352,10 @@ void recordCommandActivityRefreshesPresenceAndMeaningfulTimestampOnlyWhenRequest
.lastAcceptedCommandAtEpochMs())
&& ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
.lastMeaningfulActivityAtEpochMs()
- == null),
+ == 90L
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .role()
+ == GameplayPresenceRole.PLAYER),
org.mockito.Mockito.eq(TTL));
verify(redisTemplate).expire("gameplaypresence:22:7:sessions", TTL);
verify(redisTemplate)
@@ -309,23 +365,25 @@ void recordCommandActivityRefreshesPresenceAndMeaningfulTimestampOnlyWhenRequest
@Test
void setExplicitAfkRefreshesPresenceRecord() {
AtomicLong now = new AtomicLong(100L);
- service = new RedisGameplayPresenceService(redisTemplate, jwtUtil, TTL.toMillis(), now::get);
+ service = new RedisGameplayPresenceService(redisTemplate, TTL.toMillis(), now::get);
when(valueOperations.get("gameplaypresence:session:3"))
.thenReturn(
new net.firedevops.firemud.gamesession.service.GameplayPresence(
3L,
22L,
7L,
+ "ISOLATED",
"demo",
"production",
+ 17L,
PLAYER_ACCOUNT_ID,
202L,
"Ben",
- GameplayPresenceRole.PLAYER,
+ GameplayPresenceRole.MODERATOR,
80L,
- null,
- null,
- null));
+ 85L,
+ 90L,
+ 95L));
now.set(145L);
service.setExplicitAfk(3L, true);
@@ -336,11 +394,29 @@ void setExplicitAfkRefreshesPresenceRecord() {
argThat(
value ->
value instanceof net.firedevops.firemud.gamesession.service.GameplayPresence
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .accountId()
+ .equals(PLAYER_ACCOUNT_ID)
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .playableStateScope()
+ .equals("ISOLATED")
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .pointerVersion()
+ == 17L
&& Long.valueOf(145L)
.equals(
((net.firedevops.firemud.gamesession.service.GameplayPresence)
value)
- .explicitAfkSinceEpochMs())),
+ .explicitAfkSinceEpochMs())
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .lastAcceptedCommandAtEpochMs()
+ == 90L
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .lastMeaningfulActivityAtEpochMs()
+ == 95L
+ && ((net.firedevops.firemud.gamesession.service.GameplayPresence) value)
+ .role()
+ == GameplayPresenceRole.PLAYER),
org.mockito.Mockito.eq(TTL));
verify(redisTemplate).expire("gameplaypresence:22:7:sessions", TTL);
verify(redisTemplate)
@@ -364,7 +440,7 @@ void listConnectedByAccountIdsUsesAccountIndexAndReturnsAllMatches() {
PLAYER_ACCOUNT_ID,
202L,
"Ben",
- GameplayPresenceRole.PLAYER,
+ GameplayPresenceRole.ADMIN,
80L,
null,
100L,
@@ -382,7 +458,7 @@ void listConnectedByAccountIdsUsesAccountIndexAndReturnsAllMatches() {
PLAYER_ACCOUNT_ID,
202L,
"Ben",
- GameplayPresenceRole.PLAYER,
+ GameplayPresenceRole.GOD,
90L,
null,
110L,
@@ -392,8 +468,16 @@ void listConnectedByAccountIdsUsesAccountIndexAndReturnsAllMatches() {
assertEquals(1, result.size());
assertEquals(2, result.get(PLAYER_ACCOUNT_ID).size());
+ assertEquals(
+ true,
+ result.get(PLAYER_ACCOUNT_ID).stream()
+ .allMatch(presence -> presence.role() == GameplayPresenceRole.PLAYER));
assertEquals(4L, result.get(PLAYER_ACCOUNT_ID).get(0).sessionId());
assertEquals(3L, result.get(PLAYER_ACCOUNT_ID).get(1).sessionId());
+ Mockito.verify(valueOperations, Mockito.never())
+ .set(Mockito.anyString(), Mockito.any(), Mockito.any(Duration.class));
+ Mockito.verify(redisTemplate, Mockito.never())
+ .expire(Mockito.anyString(), Mockito.any(Duration.class));
}
@Test
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyServiceTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyServiceTest.java
index 6a39fb10fa..c7db98e6f8 100644
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyServiceTest.java
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisMovementEffectIdempotencyServiceTest.java
@@ -1,7 +1,9 @@
package net.firedevops.firemud.gamesession.service.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.never;
@@ -51,7 +53,7 @@ void applyPreservesRoutingBundleWhenUpdatingRoom() {
new SessionContext(
41L,
22L,
- "123",
+ "b8d093f7-cb70-40ed-9fac-3c82d4bf28f1",
"demo@example.com",
7001L,
"demo",
@@ -74,6 +76,9 @@ void applyPreservesRoutingBundleWhenUpdatingRoom() {
SessionContext updated = result.context();
assertNotNull(updated);
assertEquals("R-2045", updated.roomInstanceId());
+ assertNull(updated.jwt());
+ assertEquals("jwt-token", current.jwt());
+ assertFalse(SessionContextSerializationTestSupport.serialize(updated).contains(current.jwt()));
assertEquals(retainedContext, updated.firstPartyConnectContext());
assertEquals("demo", updated.worldSlug());
assertEquals("production", updated.realmSlug());
@@ -94,7 +99,7 @@ void applyReturnsConflictWhenGameplayIdentityMismatch() {
MoveEffectApplyResult result = service.apply("tfx-1", withAccountId(current, 999L), "R-2045");
assertEquals(MoveEffectApplyStatus.CONFLICT, result.status());
- assertEquals(current, result.context());
+ assertEquals(current.withoutJwt(), result.context());
verify(valueOperations, never()).set(anyString(), any(), any(Duration.class));
verify(redisTemplate, never()).delete(anyString());
}
@@ -109,11 +114,30 @@ void applyReturnsReplayedContextWhenReplayAlreadyStored() {
MoveEffectApplyResult result = service.apply("tfx-1", current, "R-2045");
assertEquals(MoveEffectApplyStatus.REPLAYED, result.status());
- assertEquals(replayed, result.context());
+ assertEquals(replayed.withoutJwt(), result.context());
verify(valueOperations, never()).set(anyString(), any(), any(Duration.class));
verify(redisTemplate, never()).delete(anyString());
}
+ @Test
+ void replayProjectsSerializedLegacyJwtOutWithoutWritingOrRefreshingRedis() {
+ SessionContext current = baselineContext();
+ SessionContext legacyReplay =
+ SessionContextSerializationTestSupport.roundTrip(withRoom(current, "R-2045"));
+ when(valueOperations.get("sessionctx:22:41:context")).thenReturn(current);
+ when(valueOperations.get("sessionctx:22:41:movement-effect:tfx-1")).thenReturn(legacyReplay);
+
+ MoveEffectApplyResult result = service.apply("tfx-1", current, "R-2045");
+
+ assertEquals(MoveEffectApplyStatus.REPLAYED, result.status());
+ assertEquals(legacyReplay.withoutJwt(), result.context());
+ assertEquals("jwt-token", legacyReplay.jwt());
+ verify(valueOperations, never()).set(anyString(), any(), any(Duration.class));
+ verify(redisTemplate, never()).delete(anyString());
+ verify(redisTemplate, never()).expire(anyString(), any(Duration.class));
+ verify(redisTemplate, never()).multi();
+ }
+
@Test
void applyRejectsLegacyExpectedRoomBeforeRedisLookup() {
SessionContext legacyExpected = withRoom(baselineContext(), "room-1021");
@@ -133,7 +157,7 @@ void applyRejectsLegacyStoredCurrentRoomBeforeWrite() {
MoveEffectApplyResult result = service.apply("tfx-1", baselineContext(), "R-2045");
assertEquals(MoveEffectApplyStatus.CONFLICT, result.status());
- assertEquals(legacyCurrent, result.context());
+ assertEquals(legacyCurrent.withoutJwt(), result.context());
verify(valueOperations, never()).set(anyString(), any(), any(Duration.class));
}
@@ -147,7 +171,7 @@ void applyRejectsLegacyReplayedRoomBeforeReturningReplay() {
MoveEffectApplyResult result = service.apply("tfx-1", current, "R-2045");
assertEquals(MoveEffectApplyStatus.CONFLICT, result.status());
- assertEquals(legacyReplay, result.context());
+ assertEquals(legacyReplay.withoutJwt(), result.context());
verify(valueOperations, never()).set(anyString(), any(), any(Duration.class));
}
@@ -155,7 +179,7 @@ private SessionContext baselineContext() {
return new SessionContext(
41L,
22L,
- "123",
+ "b8d093f7-cb70-40ed-9fac-3c82d4bf28f1",
"demo@example.com",
7001L,
"demo",
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextServiceTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextServiceTest.java
index 76249f8c88..0e7fd4d202 100644
--- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextServiceTest.java
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisSessionContextServiceTest.java
@@ -1,7 +1,11 @@
package net.firedevops.firemud.gamesession.service.impl;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -89,8 +93,98 @@ void saveStoresContextInSessionAndIdentityKeys() {
verify(redisTemplate).multi();
verify(redisTemplate).exec();
- verify(valueOperations).set("sessionctx:10:1:context", context, TTL);
- verify(valueOperations).set("sessionctx:10:identity:40:30:context", context, TTL);
+ verify(valueOperations).set("sessionctx:10:1:context", context.withoutJwt(), TTL);
+ verify(valueOperations).set("sessionctx:10:identity:40:30:context", context.withoutJwt(), TTL);
+ }
+
+ @Test
+ void saveSerializesOnlyTheNoJwtProjectionAcrossEveryIndex() {
+ var firstParty =
+ new net.firedevops.firemud.gamesession.support.FirstPartyReceivingFixture().context();
+ SessionContext context =
+ new SessionContext(
+ 1L,
+ 10L,
+ ACCOUNT_UUID,
+ "player@example.com",
+ 30L,
+ "Player",
+ 40L,
+ "R-1",
+ "private-delegation-jwt-must-stay-process-local",
+ "fr",
+ 40L,
+ "demo",
+ "production",
+ 7L,
+ "SHARED",
+ "scope",
+ "request")
+ .withFirstPartyConnectContext(firstParty);
+
+ service.save(context);
+
+ var captured = org.mockito.ArgumentCaptor.forClass(SessionContext.class);
+ verify(valueOperations, times(4)).set(Mockito.anyString(), captured.capture(), Mockito.eq(TTL));
+ for (SessionContext stored : captured.getAllValues()) {
+ assertEquals(context.withoutJwt(), stored);
+ assertNull(stored.jwt());
+ assertFalse(SessionContextSerializationTestSupport.serialize(stored).contains(context.jwt()));
+ }
+ assertEquals("private-delegation-jwt-must-stay-process-local", context.jwt());
+ assertSame(firstParty, context.withoutJwt().firstPartyConnectContext());
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"tenant", "session", "identity", "name"})
+ void legacyReadsScrubJwtWithoutMutatingOrRefreshingStoredEvidence(String lookup) {
+ SessionContext original =
+ new SessionContext(
+ 1L,
+ 10L,
+ ACCOUNT_UUID,
+ "player@example.com",
+ 30L,
+ "Player",
+ 40L,
+ "R-1",
+ "retained-private-delegation-jwt",
+ "fr",
+ 40L,
+ "demo",
+ "production",
+ 7L,
+ "SHARED",
+ "scope",
+ "request");
+ SessionContext legacy = SessionContextSerializationTestSupport.roundTrip(original);
+ String key =
+ switch (lookup) {
+ case "tenant" -> "sessionctx:10:1:context";
+ case "session" -> "sessionctx:session:1:context";
+ case "identity" -> "sessionctx:10:identity:40:30:context";
+ case "name" -> "sessionctx:10:identity:40:name:player:context";
+ default -> throw new IllegalArgumentException(lookup);
+ };
+ when(valueOperations.get(key)).thenReturn(legacy);
+
+ Optional result =
+ switch (lookup) {
+ case "tenant" -> service.findByTenantAndSessionId(10L, 1L);
+ case "session" -> service.findBySessionId(1L);
+ case "identity" -> service.findByGameplayIdentity(10L, 40L, 30L);
+ case "name" -> service.findByGameplayName(10L, 40L, "Player");
+ default -> throw new IllegalArgumentException(lookup);
+ };
+
+ assertEquals(Optional.of(original.withoutJwt()), result);
+ assertEquals(original, legacy);
+ assertTrue(SessionContextSerializationTestSupport.serialize(legacy).contains(original.jwt()));
+ verify(valueOperations).get(key);
+ Mockito.verifyNoMoreInteractions(valueOperations);
+ verify(redisTemplate, never()).execute(Mockito.any(SessionCallback.class));
+ verify(redisTemplate, never()).delete(Mockito.anyString());
+ verify(redisTemplate, never()).expire(Mockito.anyString(), Mockito.any(Duration.class));
}
@Test
@@ -102,8 +196,9 @@ void saveRemovesStaleSessionKeyBeforeWritingNewIdentityBinding() {
service.save(replacement);
verify(redisTemplate).delete("sessionctx:10:1:context");
- verify(valueOperations).set("sessionctx:10:2:context", replacement, TTL);
- verify(valueOperations).set("sessionctx:10:identity:40:30:context", replacement, TTL);
+ verify(valueOperations).set("sessionctx:10:2:context", replacement.withoutJwt(), TTL);
+ verify(valueOperations)
+ .set("sessionctx:10:identity:40:30:context", replacement.withoutJwt(), TTL);
}
@Test
@@ -125,8 +220,8 @@ void savePreservesForeignTenantIndexesFromSessionAlias() {
verify(redisTemplate, never())
.watch(
Mockito.argThat((Collection keys) -> keys.contains("sessionctx:99:1:context")));
- verify(valueOperations).set("sessionctx:10:1:context", incoming, TTL);
- verify(valueOperations).set("sessionctx:session:1:context", incoming, TTL);
+ verify(valueOperations).set("sessionctx:10:1:context", incoming.withoutJwt(), TTL);
+ verify(valueOperations).set("sessionctx:session:1:context", incoming.withoutJwt(), TTL);
}
@Test
@@ -148,8 +243,8 @@ void savePreservesForeignSessionIndexesFromSessionAlias() {
verify(redisTemplate, never())
.watch(
Mockito.argThat((Collection keys) -> keys.contains("sessionctx:10:2:context")));
- verify(valueOperations).set("sessionctx:10:1:context", incoming, TTL);
- verify(valueOperations).set("sessionctx:session:1:context", incoming, TTL);
+ verify(valueOperations).set("sessionctx:10:1:context", incoming.withoutJwt(), TTL);
+ verify(valueOperations).set("sessionctx:session:1:context", incoming.withoutJwt(), TTL);
}
@Test
@@ -175,8 +270,8 @@ void saveCleansDistinctSessionAliasIndexesForSameTenantAndSession() {
Mockito.argThat(
(Collection keys) ->
keys.contains("sessionctx:10:identity:42:32:context")));
- verify(valueOperations).set("sessionctx:10:1:context", incoming, TTL);
- verify(valueOperations).set("sessionctx:session:1:context", incoming, TTL);
+ verify(valueOperations).set("sessionctx:10:1:context", incoming.withoutJwt(), TTL);
+ verify(valueOperations).set("sessionctx:session:1:context", incoming.withoutJwt(), TTL);
}
@Test
@@ -186,7 +281,7 @@ void findByTenantAndSessionIdReturnsPersistedContext() {
Optional result = service.findByTenantAndSessionId(10L, 1L);
- assertEquals(Optional.of(context), result);
+ assertEquals(Optional.of(context.withoutJwt()), result);
}
@Test
@@ -196,7 +291,7 @@ void findByGameplayIdentityReturnsPersistedContext() {
Optional result = service.findByGameplayIdentity(10L, 40L, 30L);
- assertEquals(Optional.of(context), result);
+ assertEquals(Optional.of(context.withoutJwt()), result);
}
@Test
@@ -217,8 +312,8 @@ void unreadableRetainedContextFailsClosedWithoutTreatingItAsAbsence() {
2L, 10L, ACCOUNT_UUID, "demo@example.com", 0L, null, 0L, null, "fresh-jwt");
service.save(reauthenticated);
- verify(valueOperations).set("sessionctx:10:2:context", reauthenticated, TTL);
- verify(valueOperations).set("sessionctx:session:2:context", reauthenticated, TTL);
+ verify(valueOperations).set("sessionctx:10:2:context", reauthenticated.withoutJwt(), TTL);
+ verify(valueOperations).set("sessionctx:session:2:context", reauthenticated.withoutJwt(), TTL);
verify(redisTemplate, never()).delete(retainedKey);
verify(redisTemplate, never()).delete("sessionctx:1");
}
@@ -309,7 +404,7 @@ void savePreservesLocaleTagInStoredContext() {
service.save(context);
- verify(valueOperations).set("sessionctx:10:1:context", context, TTL);
+ verify(valueOperations).set("sessionctx:10:1:context", context.withoutJwt(), TTL);
assertEquals("fr", context.localeTag());
}
}
diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/SessionContextSerializationTestSupport.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/SessionContextSerializationTestSupport.java
new file mode 100644
index 0000000000..1a805615c0
--- /dev/null
+++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/SessionContextSerializationTestSupport.java
@@ -0,0 +1,38 @@
+package net.firedevops.firemud.gamesession.service.impl;
+
+import static org.mockito.Mockito.mock;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+import net.firedevops.firemud.common.config.DatabaseAutoConfiguration;
+import net.firedevops.firemud.common.config.PostgresProperties;
+import net.firedevops.firemud.common.config.RedisProperties;
+import net.firedevops.firemud.gamesession.service.SessionContext;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.serializer.RedisSerializer;
+
+/** Uses the value serializer installed by the production Redis template configuration. */
+final class SessionContextSerializationTestSupport {
+ private SessionContextSerializationTestSupport() {}
+
+ static String serialize(SessionContext context) {
+ return new String(
+ Objects.requireNonNull(serializer().serialize(context)), StandardCharsets.ISO_8859_1);
+ }
+
+ static SessionContext roundTrip(SessionContext context) {
+ RedisSerializer