From 93c2cd1c6a95061cf537c51f69ec029c610babbd Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Thu, 24 Sep 2026 23:04:03 +1200 Subject: [PATCH 1/3] Constrain gameplay presence roles and redact legacy friend visibility --- ...r-experience-commands-and-communication.md | 6 +- .../common/security/SessionClaims.java | 8 +- .../common/security/SessionClaimsTest.java | 26 ++- .../command/text/FriendsCommandHandler.java | 113 ++++++----- .../command/text/HelpCommandHandler.java | 4 +- .../FriendPresenceViewOutput.java | 4 +- .../FriendRosterSummaryViewOutput.java | 2 - .../TextPlayerOutputRenderer.java | 24 ++- .../impl/GameplayPresenceRoleClassifier.java | 2 +- .../text/FriendsCommandHandlerTest.java | 179 +++++++++++++++--- .../command/text/HelpCommandHandlerTest.java | 4 +- .../command/text/WhoCommandHandlerTest.java | 30 ++- .../GameplayPresenceRoleClassifierTest.java | 33 +++- .../RedisGameplayPresenceServiceTest.java | 4 +- .../WebSocketOutputProjectorTest.java | 63 +++++- 15 files changed, 381 insertions(+), 121 deletions(-) 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 6a5faac8cc..902f64d6ca 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 @@ -12,8 +12,8 @@ Packet 5 moderation/communication/social provenance is represented by [ADR 0146] ## Current Gaps -- Gameplay presence role classification still maps global `platformAdmin` and legacy global `god` into in-game `ADMIN` and `GOD`; reconcile this against [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md). -- Profile-policy surfaces still accept `HIDDEN_STAFF` and fail closed to `PRIVATE` during projection; reconcile the vocabulary against [ADR 0046](../../architecture/decisions/adr-0046-bounded-friend-presence-with-private-by-failure-redaction.md). +- Gameplay presence role classification now ignores global roles and elevates only from matching tenant-scoped gameplay grants, with focused proof against [ADR 0026](../../architecture/decisions/adr-0026-global-roles-do-not-grant-gameplay-authority.md); broader presence/privacy gaps remain below. +- Account and Social profile-policy inputs still accept the legacy `HIDDEN_STAFF` value; Game Session now removes it from player command/output vocabulary and redacts legacy or unknown friend-presence entries. Reconcile the remaining owner surfaces against [ADR 0046](../../architecture/decisions/adr-0046-bounded-friend-presence-with-private-by-failure-redaction.md). - Player-facing presence responses still expose disconnect disposition; reconcile the response shape against [ADR 0046](../../architecture/decisions/adr-0046-bounded-friend-presence-with-private-by-failure-redaction.md). ## Capability Status @@ -25,7 +25,7 @@ Packet 5 moderation/communication/social provenance is represented by [ADR 0146] | 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. | | 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. | -| 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` - focused tests cover the shipped bounded substrate, but current gameplay-role classification translates global `platformAdmin` and legacy global `god` inputs into gameplay roles contrary to ADR 0026, while payload/policy surfaces retain `HIDDEN_STAFF` and player-facing disconnect disposition contrary to ADR 0046. | [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); [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); [FriendsCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.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) | Remove global-role inputs from presence/capability resolution, remove `HIDDEN_STAFF` from account-profile presence policy, suppress disconnect disposition from player responses, add private-by-failure and bounded-page proof, and keep in-world concealment under gameplay policy before calling this capability proven. | +| 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` - focused role tests now prove global `platformAdmin`/`support`/`billingAdmin`/legacy `god`/`moderator` claims remain ordinary players while matching tenant-scoped gameplay grants elevate; payload/policy surfaces still retain `HIDDEN_STAFF` and player-facing disconnect disposition contrary to ADR 0046. | [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); [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); [FriendsCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.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) | Remove `HIDDEN_STAFF` from account-profile presence policy, suppress disconnect disposition from player responses, add private-by-failure and bounded-page proof, and keep in-world concealment under gameplay policy before calling this capability proven. | | 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. | 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 9be0d460e1..9e92141690 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 @@ -66,18 +66,12 @@ public boolean hasPrivilegedRole() { } 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. */ + /** Returns whether a 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); } 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 3097b0f1b7..44a3b5fc19 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 @@ -10,13 +10,19 @@ class SessionClaimsTest { @Test - void hasGameplayElevatedRoleRecognizesGlobalGodAndScopedModerator() { - SessionClaims globalGod = - new SessionClaims("11", List.of("god"), Map.of("7", List.of("player")), false, null, null); + void hasGameplayElevatedRoleIgnoresGlobalRolesAndRecognizesScopedModerator() { + SessionClaims globalRoles = + new SessionClaims( + "11", + List.of("platformAdmin", "support", "billingAdmin", "god", "moderator"), + 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")); + assertFalse(globalRoles.hasGameplayElevatedRole("7")); assertTrue(scopedModerator.hasGameplayElevatedRole("7")); } @@ -29,7 +35,7 @@ void hasGameplayElevatedRoleIgnoresUnrelatedTenantScopes() { } @Test - void hasGameplayRoleChecksGlobalAndRequestedTenantScopeOnly() { + void hasGameplayRoleChecksRequestedTenantScopeOnly() { SessionClaims claims = new SessionClaims( "11", @@ -39,8 +45,16 @@ void hasGameplayRoleChecksGlobalAndRequestedTenantScopeOnly() { null, null); - assertTrue(claims.hasGameplayRole("7", "platformAdmin")); + assertFalse(claims.hasGameplayRole("7", "platformAdmin")); assertTrue(claims.hasGameplayRole("7", "moderator")); assertFalse(claims.hasGameplayRole("7", "god")); } + + @Test + void hasPrivilegedRoleRetainsControlPlaneGlobalRoleBehavior() { + SessionClaims claims = + new SessionClaims("11", List.of("platformAdmin"), Map.of(), false, null, null); + + assertTrue(claims.hasPrivilegedRole()); + } } diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java index 1efb1f3de5..a4cbb18be3 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java @@ -273,9 +273,9 @@ private TextCommandInterpretationResult handleSummary( response.getSummary().getRecentCount(), response.getSummary().getPublicCount(), response.getSummary().getFriendsOnlyCount(), - response.getSummary().getPrivateCount(), - response.getSummary().getHiddenStaffCount(), - response.getSummary().getUnspecifiedVisibilityCount(), + response.getSummary().getPrivateCount() + + response.getSummary().getHiddenStaffCount() + + response.getSummary().getUnspecifiedVisibilityCount(), response.getSummary().getSharedCount(), response.getSummary().getIsolatedCount(), response.getSummary().getUnspecifiedScopeCount())))); @@ -310,12 +310,6 @@ private TextCommandInterpretationResult handleVisibilityUpdate( if (visibilityPolicy == null) { return invalidUsage("FRIENDS VISIBILITY "); } - if (visibilityPolicy - == net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy - .FRIEND_PRESENCE_VISIBILITY_POLICY_HIDDEN_STAFF) { - return friendTargetError( - "INVALID_ARGUMENT", "HIDDEN_STAFF is reserved and cannot be set from gameplay"); - } UpdateFriendPresencePolicyResponse response = socialGroupsClient.updateFriendPresencePolicy( context.tenantId(), context.accountId(), visibilityPolicy); @@ -437,6 +431,13 @@ private FriendPresenceViewOutput toView(ListFriendsResponse response, FriendList private FriendPresenceViewOutput.Entry toEntry(int ordinal, FriendRosterEntry entry) { FriendPresenceEntry presence = entry.getPresence(); long friendAccountId = requireFriendAccountId(entry.getFriendAccountId()); + if (!isPlayerDisclosablePolicy(presence.getVisibilityPolicy())) { + return redactedEntry( + ordinal, + entry, + friendAccountId, + "Friend #" + friendAccountId); + } String characterName = presence.getCharacterName().isBlank() ? null : presence.getCharacterName().trim(); return new FriendPresenceViewOutput.Entry( @@ -460,6 +461,42 @@ private FriendPresenceViewOutput.Entry toEntry(int ordinal, FriendRosterEntry en visibilityPolicy(presence.getVisibilityPolicy())); } + private FriendPresenceViewOutput.Entry redactedEntry( + int ordinal, + FriendRosterEntry entry, + long friendAccountId, + String displayName) { + return new FriendPresenceViewOutput.Entry( + ordinal, + parseOptionalLong(entry.getFriendLinkId()), + friendAccountId, + blankToNull(entry.getStatus()), + entry.getCreatedAtMs() > 0 ? entry.getCreatedAtMs() : null, + displayName, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + } + + private boolean isPlayerDisclosablePolicy( + net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy policy) { + return policy + == net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC + || policy + == net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_FRIENDS_ONLY; + } + private String activityState(FriendPresenceActivityState activityState) { return switch (activityState) { case FRIEND_PRESENCE_ACTIVITY_STATE_ACTIVE -> "ACTIVE"; @@ -516,7 +553,6 @@ private String visibilityPolicy( case FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC -> "PUBLIC"; case FRIEND_PRESENCE_VISIBILITY_POLICY_FRIENDS_ONLY -> "FRIENDS_ONLY"; case FRIEND_PRESENCE_VISIBILITY_POLICY_PRIVATE -> "PRIVATE"; - case FRIEND_PRESENCE_VISIBILITY_POLICY_HIDDEN_STAFF -> "HIDDEN_STAFF"; default -> null; }; } @@ -558,16 +594,10 @@ private FriendAction parseAction(TextCommand command) { FriendActionKind.LIST, "LIST", FriendListFilter.FRIENDS_ONLY, null, null); case "PRIVATE" -> new FriendAction(FriendActionKind.LIST, "LIST", FriendListFilter.PRIVATE, null, null); - case "HIDDEN_STAFF", "HIDDEN-STAFF", "HIDDEN" -> - new FriendAction( - FriendActionKind.LIST, "LIST", FriendListFilter.HIDDEN_STAFF, null, null); case "SHARED" -> new FriendAction(FriendActionKind.LIST, "LIST", FriendListFilter.SHARED, null, null); case "ISOLATED" -> new FriendAction(FriendActionKind.LIST, "LIST", FriendListFilter.ISOLATED, null, null); - case "UNSPECIFIED", "UNKNOWN", "UNSPECIFIED_VISIBILITY" -> - new FriendAction( - FriendActionKind.LIST, "LIST", FriendListFilter.UNSPECIFIED_VISIBILITY, null, null); case "UNSCOPED", "UNKNOWN_SCOPE", "UNSPECIFIED_SCOPE" -> new FriendAction( FriendActionKind.LIST, "LIST", FriendListFilter.UNSPECIFIED_SCOPE, null, null); @@ -577,7 +607,7 @@ private FriendAction parseAction(TextCommand command) { "INVALID", FriendListFilter.ALL, null, - "FRIENDS [ADD|REMOVE|SHOW|SUMMARY|VISIBILITY|ONLINE|OFFLINE|RECENT|PUBLIC|FRIENDS_ONLY|PRIVATE|HIDDEN_STAFF|UNSPECIFIED_VISIBILITY|SHARED|ISOLATED|UNSPECIFIED_SCOPE]"); + "FRIENDS [ADD|REMOVE|SHOW|SUMMARY|VISIBILITY|ONLINE|OFFLINE|RECENT|PUBLIC|FRIENDS_ONLY|PRIVATE|SHARED|ISOLATED|UNSPECIFIED_SCOPE]"); }; } @@ -680,8 +710,6 @@ private FriendRosterFilter mapRosterFilter(FriendListFilter filter) { case PUBLIC -> FriendRosterFilter.FRIEND_ROSTER_FILTER_PUBLIC; case FRIENDS_ONLY -> FriendRosterFilter.FRIEND_ROSTER_FILTER_FRIENDS_ONLY; case PRIVATE -> FriendRosterFilter.FRIEND_ROSTER_FILTER_PRIVATE; - case HIDDEN_STAFF -> FriendRosterFilter.FRIEND_ROSTER_FILTER_HIDDEN_STAFF; - case UNSPECIFIED_VISIBILITY -> FriendRosterFilter.FRIEND_ROSTER_FILTER_UNSPECIFIED_VISIBILITY; case SHARED -> FriendRosterFilter.FRIEND_ROSTER_FILTER_SHARED; case ISOLATED -> FriendRosterFilter.FRIEND_ROSTER_FILTER_ISOLATED; case UNSPECIFIED_SCOPE -> FriendRosterFilter.FRIEND_ROSTER_FILTER_UNSPECIFIED_SCOPE; @@ -716,37 +744,35 @@ private String notFoundMessage(String targetToken) { private FriendPresencePolicyViewOutput friendPresencePolicyView( net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy current) { + net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy effectiveCurrent = + isPlayerDisclosablePolicy(current) + ? current + : net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PRIVATE; return new FriendPresencePolicyViewOutput( - visibilityPolicy(current), + visibilityPolicy(effectiveCurrent), List.of( new FriendPresencePolicyViewOutput.Option( "PUBLIC", "Show the normal bounded friend-presence payload to approved social consumers.", - current + effectiveCurrent == net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC, true), new FriendPresencePolicyViewOutput.Option( "FRIENDS_ONLY", "Expose richer live identity only to approved friends.", - current + effectiveCurrent == net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy .FRIEND_PRESENCE_VISIBILITY_POLICY_FRIENDS_ONLY, true), new FriendPresencePolicyViewOutput.Option( "PRIVATE", - "Suppress current live character identity and expose only coarse online or recent activity.", - current + "Do not expose current presence, recent activity, or location details.", + effectiveCurrent == net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy .FRIEND_PRESENCE_VISIBILITY_POLICY_PRIVATE, - true), - new FriendPresencePolicyViewOutput.Option( - "HIDDEN_STAFF", - "Reserved for staff-hidden role clamps and not set directly from gameplay.", - current - == net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy - .FRIEND_PRESENCE_VISIBILITY_POLICY_HIDDEN_STAFF, - false))); + true))); } private net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy @@ -765,9 +791,6 @@ private FriendPresencePolicyViewOutput friendPresencePolicyView( case "PRIVATE" -> net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy .FRIEND_PRESENCE_VISIBILITY_POLICY_PRIVATE; - case "HIDDEN_STAFF" -> - net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy - .FRIEND_PRESENCE_VISIBILITY_POLICY_HIDDEN_STAFF; default -> null; }; } @@ -792,19 +815,19 @@ boolean matches(FriendPresenceViewOutput.Entry entry) { ONLINE { @Override boolean matches(FriendPresenceViewOutput.Entry entry) { - return entry.online(); + return Boolean.TRUE.equals(entry.online()); } }, OFFLINE { @Override boolean matches(FriendPresenceViewOutput.Entry entry) { - return !entry.online(); + return Boolean.FALSE.equals(entry.online()); } }, RECENT { @Override boolean matches(FriendPresenceViewOutput.Entry entry) { - return !entry.online() && entry.lastSeenAtEpochMs() != null; + return Boolean.FALSE.equals(entry.online()) && entry.lastSeenAtEpochMs() != null; } }, PUBLIC { @@ -822,13 +845,7 @@ boolean matches(FriendPresenceViewOutput.Entry entry) { PRIVATE { @Override boolean matches(FriendPresenceViewOutput.Entry entry) { - return "PRIVATE".equals(entry.visibilityPolicy()); - } - }, - HIDDEN_STAFF { - @Override - boolean matches(FriendPresenceViewOutput.Entry entry) { - return "HIDDEN_STAFF".equals(entry.visibilityPolicy()); + return !StringUtils.hasText(entry.visibilityPolicy()); } }, SHARED { @@ -843,12 +860,6 @@ boolean matches(FriendPresenceViewOutput.Entry entry) { return "ISOLATED".equals(entry.playableStateScope()); } }, - UNSPECIFIED_VISIBILITY { - @Override - boolean matches(FriendPresenceViewOutput.Entry entry) { - return !StringUtils.hasText(entry.visibilityPolicy()); - } - }, UNSPECIFIED_SCOPE { @Override boolean matches(FriendPresenceViewOutput.Entry entry) { diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/HelpCommandHandler.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/HelpCommandHandler.java index ee8e3b095e..c2b27f73a5 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/HelpCommandHandler.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/HelpCommandHandler.java @@ -115,13 +115,13 @@ public TextCommandInterpretationResult handle( "FRIENDS\n" + "List your linked friends with bounded cross-game presence.\n" + "FRIENDS SUMMARY shows canonical linked/online/offline/recent counts.\n" - + "FRIENDS ONLINE, FRIENDS OFFLINE, FRIENDS RECENT, FRIENDS PUBLIC, FRIENDS FRIENDS_ONLY, FRIENDS PRIVATE, FRIENDS HIDDEN_STAFF, FRIENDS UNSPECIFIED_VISIBILITY, FRIENDS SHARED, FRIENDS ISOLATED, and FRIENDS UNSPECIFIED_SCOPE filter the same canonical roster without widening WHO.\n" + + "FRIENDS ONLINE, FRIENDS OFFLINE, FRIENDS RECENT, FRIENDS PUBLIC, FRIENDS FRIENDS_ONLY, FRIENDS PRIVATE, FRIENDS SHARED, FRIENDS ISOLATED, and FRIENDS UNSPECIFIED_SCOPE filter the same canonical roster without widening WHO.\n" + "FRIENDS SHOW shows one canonical friend roster entry in detail, including #entryNumber lookups from the rendered roster.\n" + "FRIENDS ADD links another account-scoped friend.\n" + "FRIENDS REMOVE removes an existing account-scoped friend, including canonical #entryNumber removal.\n" + "FRIENDS VISIBILITY shows your current cross-game friend-presence policy, and FRIENDS VISIBILITY updates it.\n" + "Visible entries show current world/realm labels, character name, and activity state when policy allows.\n" - + "Private or hidden-staff friends stay conservative."); + + "Private friends stay conservative."); case "INVENTORY" -> success( "INVENTORY shows what you are carrying.\n" diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendPresenceViewOutput.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendPresenceViewOutput.java index b31bff8ecb..93c10a2264 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendPresenceViewOutput.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendPresenceViewOutput.java @@ -1,5 +1,6 @@ package net.firedevops.firemud.gamesession.presentation; +import com.fasterxml.jackson.annotation.JsonInclude; import java.util.List; public record FriendPresenceViewOutput( @@ -9,6 +10,7 @@ public record FriendPresenceViewOutput( friends = List.copyOf(friends); } + @JsonInclude(JsonInclude.Include.NON_NULL) public record Entry( int ordinal, Long friendLinkId, @@ -16,7 +18,7 @@ public record Entry( String status, Long linkedAtEpochMs, String displayName, - boolean online, + Boolean online, String worldSlug, String worldDisplayName, String realmSlug, diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendRosterSummaryViewOutput.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendRosterSummaryViewOutput.java index 44b477188c..f028ffbff8 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendRosterSummaryViewOutput.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/FriendRosterSummaryViewOutput.java @@ -8,8 +8,6 @@ public record FriendRosterSummaryViewOutput( int publicCount, int friendsOnlyCount, int privateCount, - int hiddenStaffCount, - int unspecifiedVisibilityCount, int sharedCount, int isolatedCount, int unspecifiedScopeCount) diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java index 7402d8bbe2..f47696cc42 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java @@ -555,10 +555,6 @@ private String renderFriendRosterSummaryView(FriendRosterSummaryViewOutput outpu + output.friendsOnlyCount() + "\nVisibility private: " + output.privateCount() - + "\nVisibility hidden-staff: " - + output.hiddenStaffCount() - + "\nVisibility unspecified: " - + output.unspecifiedVisibilityCount() + "\nScope shared: " + output.sharedCount() + "\nScope isolated: " @@ -595,7 +591,10 @@ private String renderFriendStatusSuffix(FriendPresenceViewOutput.Entry entry) { } private String renderFriendStatus(FriendPresenceViewOutput.Entry entry) { - if (entry.online()) { + if (isRedactedFriendPresence(entry)) { + return "presence unavailable"; + } + if (Boolean.TRUE.equals(entry.online())) { StringBuilder line = new StringBuilder("online"); String location = renderFriendLocation(entry); if (StringUtils.hasText(location)) { @@ -626,6 +625,21 @@ private String renderFriendStatus(FriendPresenceViewOutput.Entry entry) { return "offline"; } + private boolean isRedactedFriendPresence(FriendPresenceViewOutput.Entry entry) { + return !StringUtils.hasText(entry.visibilityPolicy()) + && !Boolean.TRUE.equals(entry.online()) + && entry.lastSeenAtEpochMs() == null + && !StringUtils.hasText(entry.worldSlug()) + && !StringUtils.hasText(entry.worldDisplayName()) + && !StringUtils.hasText(entry.realmSlug()) + && !StringUtils.hasText(entry.realmDisplayName()) + && !StringUtils.hasText(entry.characterName()) + && !StringUtils.hasText(entry.playableStateScope()) + && entry.pointerVersion() == null + && !StringUtils.hasText(entry.activityState()) + && !StringUtils.hasText(entry.recentDisposition()); + } + private String renderFriendLocation(FriendPresenceViewOutput.Entry entry) { if (StringUtils.hasText(entry.worldDisplayName()) && StringUtils.hasText(entry.realmDisplayName())) { 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 index e5fe41710a..6cd543d2a3 100644 --- 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 @@ -21,7 +21,7 @@ static GameplayPresenceRole classifyRole(SessionContext context, JwtUtil jwtUtil if (claims.hasGameplayRole(tenantId, "god")) { return GameplayPresenceRole.GOD; } - if (claims.hasGameplayRole(tenantId, "platformAdmin", "tenantAdmin")) { + if (claims.hasGameplayRole(tenantId, "tenantAdmin")) { return GameplayPresenceRole.ADMIN; } if (claims.hasGameplayRole(tenantId, "moderator")) { diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java index c7dd4a3e8f..edc61b6e2c 100644 --- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java +++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java @@ -21,6 +21,7 @@ import net.firedevops.firemud.socialgroups.v1.AddFriendResponse; import net.firedevops.firemud.socialgroups.v1.FriendPresenceActivityState; import net.firedevops.firemud.socialgroups.v1.FriendPresenceEntry; +import net.firedevops.firemud.socialgroups.v1.FriendPresenceVisibilityPolicy; import net.firedevops.firemud.socialgroups.v1.FriendRecentPresenceDisposition; import net.firedevops.firemud.socialgroups.v1.FriendRosterEntry; import net.firedevops.firemud.socialgroups.v1.FriendRosterFilter; @@ -86,6 +87,9 @@ void friendsMapsVisiblePresenceToTypedViewAndText() { .setWorldDisplayName("Demo World") .setRealmSlug("production") .setRealmDisplayName("Live Realm") + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC) .setActivityState( FriendPresenceActivityState .FRIEND_PRESENCE_ACTIVITY_STATE_AUTO_AFK) @@ -158,6 +162,9 @@ void friendsFallsBackToBoundedOfflineLabelWhenDetailsAreSuppressed() { .setRecentDisposition( FriendRecentPresenceDisposition .FRIEND_RECENT_PRESENCE_DISPOSITION_LOGOUT) + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC) .build()) .build()) .build()); @@ -244,6 +251,9 @@ void friendsOnlineFiltersCanonicalRosterWithoutRenumbering() { .setFriendAccountId("77") .setOnline(true) .setCharacterName("Sora") + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC) .build()) .build()) .build()); @@ -291,7 +301,8 @@ void friendsPrivateFiltersCanonicalRosterByVisibilityPolicy() { .setPresence( FriendPresenceEntry.newBuilder() .setFriendAccountId("88") - .setOnline(false) + .setOnline(true) + .setCharacterName("Secret") .setVisibilityPolicy( net.firedevops.firemud.socialgroups.v1 .FriendPresenceVisibilityPolicy @@ -317,17 +328,102 @@ void friendsPrivateFiltersCanonicalRosterByVisibilityPolicy() { entry -> { assertThat(entry.ordinal()).isEqualTo(2); assertThat(entry.friendAccountId()).isEqualTo(88L); - assertThat(entry.visibilityPolicy()).isEqualTo("PRIVATE"); + assertThat(entry.online()).isNull(); + assertThat(entry.characterName()).isNull(); + assertThat(entry.displayName()).isEqualTo("Friend #88"); + assertThat(entry.visibilityPolicy()).isNull(); }); assertThat( new TextPlayerOutputRenderer( new net.firedevops.firemud.gamesession.config.PresentationProperties()) .render(result.outputs().getFirst())) - .contains("Friends PRIVATE [1/2]:"); + .contains("Friends PRIVATE [1/2]:") + .contains("presence unavailable") + .doesNotContain("Secret"); Mockito.verify(socialGroupsClient) .listFriends(1L, 41L, FriendRosterFilter.FRIEND_ROSTER_FILTER_PRIVATE); } + @Test + void friendsRedactsLegacyHiddenStaffEntryButPreservesRelationshipRow() { + SocialGroupsClient socialGroupsClient = Mockito.mock(SocialGroupsClient.class); + EntityManagementClient entityManagementClient = Mockito.mock(EntityManagementClient.class); + FriendsCommandHandler handler = + newHandler( + socialGroupsClient, entityManagementClient, Mockito.mock(ScriptEventPublisher.class)); + when(socialGroupsClient.listFriends(1L, 41L)) + .thenReturn( + ListFriendsResponse.newBuilder() + .addFriends( + FriendRosterEntry.newBuilder() + .setOrdinal(4) + .setFriendLinkId("12") + .setFriendAccountId("77") + .setStatus("active") + .setCreatedAtMs(1_744_336_000_000L) + .setPresence( + FriendPresenceEntry.newBuilder() + .setFriendAccountId("77") + .setOnline(true) + .setCharacterId("99") + .setCharacterName("Sora") + .setWorldSlug("demo") + .setWorldDisplayName("Demo World") + .setRealmSlug("production") + .setRealmDisplayName("Live Realm") + .setPlayableStateScope(PlayableStateScope.PLAYABLE_STATE_SCOPE_SHARED) + .setPointerVersion(17L) + .setActivityState( + FriendPresenceActivityState + .FRIEND_PRESENCE_ACTIVITY_STATE_ACTIVE) + .setLastSeenAtMs(1_744_336_000_000L) + .setRecentDisposition( + FriendRecentPresenceDisposition + .FRIEND_RECENT_PRESENCE_DISPOSITION_LOGOUT) + .setVisibilityPolicy( + net.firedevops.firemud.socialgroups.v1 + .FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_HIDDEN_STAFF) + .build()) + .build()) + .build()); + + TextCommandInterpretationResult result = + handler.handle( + new TextCommand(TextCommandType.FRIENDS, java.util.List.of(), "FRIENDS"), + GAMEPLAY_CONTEXT); + + FriendPresenceViewOutput.Entry entry = + ((FriendPresenceViewOutput) result.outputs().getFirst().payload()).friends().getFirst(); + assertThat(entry.ordinal()).isEqualTo(4); + assertThat(entry.friendLinkId()).isEqualTo(12L); + assertThat(entry.friendAccountId()).isEqualTo(77L); + assertThat(entry.status()).isEqualTo("active"); + assertThat(entry.linkedAtEpochMs()).isEqualTo(1_744_336_000_000L); + assertThat(entry.displayName()).isEqualTo("Friend #77"); + assertThat(entry.online()).isNull(); + assertThat(entry.worldSlug()).isNull(); + assertThat(entry.worldDisplayName()).isNull(); + assertThat(entry.realmSlug()).isNull(); + assertThat(entry.realmDisplayName()).isNull(); + assertThat(entry.characterName()).isNull(); + assertThat(entry.playableStateScope()).isNull(); + assertThat(entry.pointerVersion()).isNull(); + assertThat(entry.activityState()).isNull(); + assertThat(entry.lastSeenAtEpochMs()).isNull(); + assertThat(entry.recentDisposition()).isNull(); + assertThat(entry.visibilityPolicy()).isNull(); + assertThat( + new TextPlayerOutputRenderer( + new net.firedevops.firemud.gamesession.config.PresentationProperties()) + .render(result.outputs().getFirst())) + .contains("Friend #77") + .contains("presence unavailable") + .doesNotContain("Sora") + .doesNotContain("Demo World") + .doesNotContain("HIDDEN_STAFF"); + } + @Test void friendsSharedFiltersCanonicalRosterByPlayableStateScope() { SocialGroupsClient socialGroupsClient = Mockito.mock(SocialGroupsClient.class); @@ -352,6 +448,9 @@ void friendsSharedFiltersCanonicalRosterByPlayableStateScope() { .setCharacterName("Sora") .setPlayableStateScope( PlayableStateScope.PLAYABLE_STATE_SCOPE_SHARED) + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC) .build()) .build()) .build()); @@ -406,6 +505,9 @@ void friendsRecentFiltersOfflineEntriesWithRecentPresence() { .setOnline(false) .setLastSeenAtMs( Instant.parse("2026-04-11T06:15:30Z").toEpochMilli()) + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC) .build()) .build()) .build()); @@ -444,8 +546,8 @@ void friendsSummaryUsesCanonicalRosterSummarySurface() { .setPublicCount(1) .setFriendsOnlyCount(2) .setPrivateCount(1) - .setHiddenStaffCount(0) - .setUnspecifiedVisibilityCount(0) + .setHiddenStaffCount(2) + .setUnspecifiedVisibilityCount(2) .setSharedCount(2) .setIsolatedCount(1) .setUnspecifiedScopeCount(1) @@ -471,9 +573,7 @@ void friendsSummaryUsesCanonicalRosterSummarySurface() { assertThat(view.recentCount()).isEqualTo(2); assertThat(view.publicCount()).isEqualTo(1); assertThat(view.friendsOnlyCount()).isEqualTo(2); - assertThat(view.privateCount()).isEqualTo(1); - assertThat(view.hiddenStaffCount()).isZero(); - assertThat(view.unspecifiedVisibilityCount()).isZero(); + assertThat(view.privateCount()).isEqualTo(5); assertThat(view.sharedCount()).isEqualTo(2); assertThat(view.isolatedCount()).isEqualTo(1); assertThat(view.unspecifiedScopeCount()).isEqualTo(1); @@ -488,7 +588,9 @@ void friendsSummaryUsesCanonicalRosterSummarySurface() { .contains("Recent offline: 2") .contains("Visibility public: 1") .contains("Visibility friends-only: 2") - .contains("Visibility private: 1") + .contains("Visibility private: 5") + .doesNotContain("hidden") + .doesNotContain("Visibility unspecified") .contains("Scope shared: 2") .contains("Scope isolated: 1"); Mockito.verify(socialGroupsClient).getFriendRosterSummary(1L, 41L); @@ -625,6 +727,9 @@ void friendsRemoveByOrdinalUsesCanonicalRemoveSurface() { FriendPresenceEntry.newBuilder() .setFriendAccountId("77") .setCharacterName("Sora") + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC) .build()) .build()) .build()); @@ -712,6 +817,9 @@ void friendsShowReturnsCanonicalFriendDetailView() { .setPlayableStateScope( PlayableStateScope.PLAYABLE_STATE_SCOPE_SHARED) .setPointerVersion(17L) + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_PUBLIC) .setActivityState( FriendPresenceActivityState .FRIEND_PRESENCE_ACTIVITY_STATE_AUTO_AFK) @@ -1005,6 +1113,8 @@ void friendsVisibilityShowsCurrentCanonicalPolicy() { FriendPresencePolicyViewOutput view = (FriendPresencePolicyViewOutput) result.outputs().getFirst().payload(); assertThat(view.currentPolicy()).isEqualTo("FRIENDS_ONLY"); + assertThat(view.options()) + .noneMatch(option -> option.policy().equals("HIDDEN_STAFF")); assertThat(view.options()) .anySatisfy( option -> { @@ -1166,8 +1276,8 @@ void friendsVisibilityRejectsReservedHiddenStaffPolicy() { assertThat(result.outputs()) .singleElement() .extracting(PlayerOutput::text) - .isEqualTo( - "ERROR INVALID_ARGUMENT HIDDEN_STAFF is reserved and cannot be set from gameplay"); + .isEqualTo("ERROR INVALID_ARGUMENT FRIENDS VISIBILITY "); + assertThat(result.outputs().getFirst().text()).doesNotContain("HIDDEN_STAFF"); Mockito.verify(socialGroupsClient, Mockito.never()) .updateFriendPresencePolicy(Mockito.anyLong(), Mockito.anyLong(), Mockito.any()); } @@ -1191,24 +1301,42 @@ void friendsUnknownSubcommandFailsClosedWithUsage() { .singleElement() .extracting(PlayerOutput::text) .isEqualTo( - "ERROR INVALID_ARGUMENT FRIENDS [ADD|REMOVE|SHOW|SUMMARY|VISIBILITY|ONLINE|OFFLINE|RECENT|PUBLIC|FRIENDS_ONLY|PRIVATE|HIDDEN_STAFF|UNSPECIFIED_VISIBILITY|SHARED|ISOLATED|UNSPECIFIED_SCOPE]"); + "ERROR INVALID_ARGUMENT FRIENDS [ADD|REMOVE|SHOW|SUMMARY|VISIBILITY|ONLINE|OFFLINE|RECENT|PUBLIC|FRIENDS_ONLY|PRIVATE|SHARED|ISOLATED|UNSPECIFIED_SCOPE]"); Mockito.verifyNoInteractions(socialGroupsClient); } @Test - void friendsUnspecifiedVisibilityUsesCanonicalFilterAlias() { + void friendsDoesNotAcceptLegacyHiddenStaffFilter() { SocialGroupsClient socialGroupsClient = Mockito.mock(SocialGroupsClient.class); EntityManagementClient entityManagementClient = Mockito.mock(EntityManagementClient.class); FriendsCommandHandler handler = newHandler( socialGroupsClient, entityManagementClient, Mockito.mock(ScriptEventPublisher.class)); - when(socialGroupsClient.listFriends( - 1L, 41L, FriendRosterFilter.FRIEND_ROSTER_FILTER_UNSPECIFIED_VISIBILITY)) - .thenReturn( - ListFriendsResponse.newBuilder() - .setFilter(FriendRosterFilter.FRIEND_ROSTER_FILTER_UNSPECIFIED_VISIBILITY) - .build()); + TextCommandInterpretationResult result = + handler.handle( + new TextCommand( + TextCommandType.FRIENDS, + java.util.List.of("HIDDEN_STAFF"), + "FRIENDS HIDDEN_STAFF"), + GAMEPLAY_CONTEXT); + + assertThat(result.commandResult().accepted()).isFalse(); + assertThat(result.commandResult().errorCode()).isEqualTo("INVALID_ARGUMENT"); + assertThat(result.outputs().getFirst().text()) + .isEqualTo( + "ERROR INVALID_ARGUMENT FRIENDS [ADD|REMOVE|SHOW|SUMMARY|VISIBILITY|ONLINE|OFFLINE|RECENT|PUBLIC|FRIENDS_ONLY|PRIVATE|SHARED|ISOLATED|UNSPECIFIED_SCOPE]") + .doesNotContain("HIDDEN_STAFF"); + Mockito.verifyNoInteractions(socialGroupsClient); + } + + @Test + void friendsDoesNotAcceptUnspecifiedVisibilityFilter() { + SocialGroupsClient socialGroupsClient = Mockito.mock(SocialGroupsClient.class); + EntityManagementClient entityManagementClient = Mockito.mock(EntityManagementClient.class); + FriendsCommandHandler handler = + newHandler( + socialGroupsClient, entityManagementClient, Mockito.mock(ScriptEventPublisher.class)); TextCommandInterpretationResult result = handler.handle( new TextCommand( @@ -1217,11 +1345,12 @@ void friendsUnspecifiedVisibilityUsesCanonicalFilterAlias() { "FRIENDS UNSPECIFIED_VISIBILITY"), GAMEPLAY_CONTEXT); - assertThat(result.commandResult().accepted()).isTrue(); - FriendPresenceViewOutput view = - (FriendPresenceViewOutput) result.outputs().getFirst().payload(); - assertThat(view.filter()).isEqualTo("UNSPECIFIED_VISIBILITY"); - Mockito.verify(socialGroupsClient) - .listFriends(1L, 41L, FriendRosterFilter.FRIEND_ROSTER_FILTER_UNSPECIFIED_VISIBILITY); + assertThat(result.commandResult().accepted()).isFalse(); + assertThat(result.commandResult().errorCode()).isEqualTo("INVALID_ARGUMENT"); + assertThat(result.outputs().getFirst().text()) + .isEqualTo( + "ERROR INVALID_ARGUMENT FRIENDS [ADD|REMOVE|SHOW|SUMMARY|VISIBILITY|ONLINE|OFFLINE|RECENT|PUBLIC|FRIENDS_ONLY|PRIVATE|SHARED|ISOLATED|UNSPECIFIED_SCOPE]") + .doesNotContain("UNSPECIFIED_VISIBILITY"); + Mockito.verifyNoInteractions(socialGroupsClient); } } diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/HelpCommandHandlerTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/HelpCommandHandlerTest.java index feeccfb89c..0e9dd6a666 100644 --- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/HelpCommandHandlerTest.java +++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/HelpCommandHandlerTest.java @@ -74,9 +74,11 @@ void helpFriendsTopicExplainsVisibilityReadAndWriteSurface() { .text() .contains( "FRIENDS VISIBILITY shows your current cross-game friend-presence policy, and FRIENDS VISIBILITY updates it.")); - assertTrue(result.outputs().get(0).text().contains("FRIENDS UNSPECIFIED_VISIBILITY")); + assertFalse(result.outputs().get(0).text().contains("FRIENDS UNSPECIFIED_VISIBILITY")); assertTrue(result.outputs().get(0).text().contains("FRIENDS UNSPECIFIED_SCOPE")); assertTrue(result.outputs().get(0).text().contains("#entryNumber removal")); + assertFalse(result.outputs().get(0).text().contains("HIDDEN_STAFF")); + assertFalse(result.outputs().get(0).text().contains("hidden-staff")); } @Test 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 3e893d2545..b098f3f8ed 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 @@ -59,10 +59,8 @@ void whoGroupsElevatedPlayersFirstAndPlayersAfterward() { java.util.Map.of( "accountId", "1", - "globalRoles", - java.util.List.of("platformAdmin"), "scopedRoles", - java.util.Map.of())); + java.util.Map.of("22", java.util.List.of("god")))); gameplayPresenceService.registerConnected( new SessionContext(1L, 22L, 1L, "god@example.com", 101L, "Aster", 7L, "R-1", godJwt)); @@ -91,6 +89,32 @@ void whoGroupsElevatedPlayersFirstAndPlayersAfterward() { assertThat(render(result)).isEqualTo("Gods [2]: Aster, Dara\nPlayers [2]: Ben, Cara"); } + @Test + void whoShowsGlobalOnlyRolesAsPlayers() { + FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService(jwtUtil); + WhoCommandHandler handler = + new WhoCommandHandler(gameplayPresenceService, activityResolver, scriptEventPublisher); + String globalOnlyJwt = + jwtUtil.generateToken( + "1", + java.util.Map.of( + "accountId", + "1", + "globalRoles", + java.util.List.of("platformAdmin", "support", "billingAdmin", "god", "moderator"))); + + gameplayPresenceService.registerConnected( + new SessionContext(1L, 22L, 1L, "staff@example.com", 101L, "Aster", 7L, "R-1", globalOnlyJwt)); + + TextCommandInterpretationResult result = + handler.handle( + new TextCommand(TextCommandType.WHO, java.util.List.of(), "WHO"), + new SessionContext(2L, 22L, 2L, "second@example.com", 102L, "Ben", 7L, "R-1", null)); + + assertThat(result.commandResult().accepted()).isTrue(); + assertThat(render(result)).isEqualTo("Gods [0]: \nPlayers [1]: Aster"); + } + @Test void whoOmitsRemovedPresenceAfterLogoutLikeCleanup() { FakeGameplayPresenceService gameplayPresenceService = new FakeGameplayPresenceService(jwtUtil); 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 index dcc166d305..53cbbfa63f 100644 --- 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 @@ -51,11 +51,16 @@ void classifyRoleReturnsModeratorForScopedModeratorRole() { } @Test - void classifyRoleReturnsGodForGlobalGodRole() { + void classifyRoleReturnsPlayerForGlobalRolesWithoutTenantGrant() { Logger logger = mock(Logger.class); String jwt = JWT_UTIL.generateToken( - "202", java.util.Map.of("accountId", "202", "globalRoles", java.util.List.of("god"))); + "202", + java.util.Map.of( + "accountId", + "202", + "globalRoles", + java.util.List.of("platformAdmin", "support", "billingAdmin", "god", "moderator"))); GameplayPresenceRole role = GameplayPresenceRoleClassifier.classifyRole( @@ -63,7 +68,7 @@ void classifyRoleReturnsGodForGlobalGodRole() { JWT_UTIL, logger); - assertEquals(GameplayPresenceRole.GOD, role); + assertEquals(GameplayPresenceRole.PLAYER, role); } @Test @@ -96,10 +101,8 @@ void classifyRoleUsesTheHighestAvailableGameplayRole() { java.util.Map.of( "accountId", "202", - "globalRoles", - java.util.List.of("moderator", "god"), "scopedRoles", - java.util.Map.of("22", java.util.List.of("tenantAdmin")))); + java.util.Map.of("22", java.util.List.of("moderator", "tenantAdmin", "god")))); GameplayPresenceRole role = GameplayPresenceRoleClassifier.classifyRole( @@ -124,4 +127,22 @@ void classifyRoleReturnsPlayerWhenScopedRolesClaimIsMalformed() { assertEquals(GameplayPresenceRole.PLAYER, role); } + + @Test + void classifyRoleReturnsGodForScopedGodRole() { + Logger logger = mock(Logger.class); + String jwt = + JWT_UTIL.generateToken( + "202", + java.util.Map.of( + "accountId", "202", "scopedRoles", java.util.Map.of("22", java.util.List.of("god")))); + + GameplayPresenceRole role = + GameplayPresenceRoleClassifier.classifyRole( + new SessionContext(1L, 22L, 202L, "player@example.com", 202L, "Ben", 7L, "R-1", jwt), + JWT_UTIL, + logger); + + assertEquals(GameplayPresenceRole.GOD, 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 2d391f44db..5e4d79242f 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 @@ -89,10 +89,8 @@ void listConnectedByGameInstanceSortsGodsFirstAndPrunesMissingSessions() { Map.of( "accountId", "1", - "globalRoles", - List.of("platformAdmin"), "scopedRoles", - Map.of())); + Map.of("22", List.of("god")))); SessionContext godContext = new SessionContext(1L, 22L, 1L, "god@example.com", 101L, "Aster", 7L, "R-1", godJwt); service.registerConnected(godContext); diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java index e6d4c63271..33d4122202 100644 --- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java +++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java @@ -620,6 +620,56 @@ void firstPartyWebProjectsFriendDetailViewPayloads() throws Exception { .isEqualTo(17L); } + @Test + void firstPartyWebOmitsRedactedFriendPresenceFields() throws Exception { + WebSocketSession session = mock(WebSocketSession.class); + when(session.getAttributes()) + .thenReturn( + Map.of( + GameSessionWebSocketHandshakeInterceptor.CONNECTION_MODE_ATTR, "first_party_web")); + + FriendPresenceViewOutput.Entry redactedEntry = + new FriendPresenceViewOutput.Entry( + 4, + 12L, + 77L, + "active", + 1_744_336_000_000L, + "Friend #77", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + String payload = + projector.projectPlayerOutput( + session, + PlayerOutput.view(new FriendDetailViewOutput(redactedEntry)), + "en-NZ", + presentation); + + JsonNode friend = + objectMapper.readTree(payload).path("outputs").get(0).path("payload").path("friend"); + assertThat(friend.path("friendAccountId").asLong()).isEqualTo(77L); + assertThat(friend.path("friendLinkId").asLong()).isEqualTo(12L); + assertThat(friend.path("status").asText()).isEqualTo("active"); + assertThat(friend.path("displayName").asText()).isEqualTo("Friend #77"); + assertThat(friend.has("online")).isFalse(); + assertThat(friend.has("worldSlug")).isFalse(); + assertThat(friend.has("characterName")).isFalse(); + assertThat(friend.has("activityState")).isFalse(); + assertThat(friend.has("lastSeenAtEpochMs")).isFalse(); + assertThat(friend.has("recentDisposition")).isFalse(); + assertThat(friend.has("visibilityPolicy")).isFalse(); + } + @Test void firstPartyWebProjectsFriendRosterSummaryViewPayloads() throws Exception { WebSocketSession session = mock(WebSocketSession.class); @@ -636,10 +686,10 @@ void firstPartyWebProjectsFriendRosterSummaryViewPayloads() throws Exception { CommandEnqueueResult.success(), List.of( PlayerOutput.view( - new FriendRosterSummaryViewOutput(4, 1, 3, 2, 1, 2, 1, 0, 0, 2, 1, 1)))), + new FriendRosterSummaryViewOutput(4, 1, 3, 2, 1, 2, 1, 2, 1, 1)))), List.of( PlayerOutput.view( - new FriendRosterSummaryViewOutput(4, 1, 3, 2, 1, 2, 1, 0, 0, 2, 1, 1))), + new FriendRosterSummaryViewOutput(4, 1, 3, 2, 1, 2, 1, 2, 1, 1))), "en-NZ", presentation); @@ -654,6 +704,9 @@ void firstPartyWebProjectsFriendRosterSummaryViewPayloads() throws Exception { .isEqualTo(2); assertThat(json.path("outputs").get(0).path("payload").path("privateCount").asInt()) .isEqualTo(1); + assertThat(json.path("outputs").get(0).path("payload").has("hiddenStaffCount")).isFalse(); + assertThat(json.path("outputs").get(0).path("payload").has("unspecifiedVisibilityCount")) + .isFalse(); assertThat(json.path("outputs").get(0).path("payload").path("sharedCount").asInt()) .isEqualTo(2); assertThat(json.path("outputs").get(0).path("payload").path("isolatedCount").asInt()) @@ -676,9 +729,7 @@ void firstPartyWebProjectsFriendPresencePolicyViewPayloads() throws Exception { "PUBLIC", "Normal bounded payload.", false, true), new FriendPresencePolicyViewOutput.Option( "FRIENDS_ONLY", "Approved friends only.", true, true), - new FriendPresencePolicyViewOutput.Option("PRIVATE", "Coarse only.", false, true), - new FriendPresencePolicyViewOutput.Option( - "HIDDEN_STAFF", "Reserved.", false, false))); + new FriendPresencePolicyViewOutput.Option("PRIVATE", "Coarse only.", false, true))); String payload = projector.projectCommandResponse( @@ -696,6 +747,8 @@ void firstPartyWebProjectsFriendPresencePolicyViewPayloads() throws Exception { .isEqualTo("friend_presence_policy_view"); assertThat(json.path("outputs").get(0).path("payload").path("currentPolicy").asText()) .isEqualTo("FRIENDS_ONLY"); + assertThat(json.path("outputs").get(0).path("payload").path("options")) + .allMatch(option -> !option.path("policy").asText().equals("HIDDEN_STAFF")); } @Test From 7423278c94f82d31df4e850ee3f4d88378330cb1 Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Fri, 25 Sep 2026 18:42:19 +1200 Subject: [PATCH 2/3] Correct presence tracker proof link after join --- .../player-experience-commands-and-communication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0f73f67e20..b1fa5dde35 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 @@ -25,7 +25,7 @@ Packet 5 moderation/communication/social provenance is represented by [ADR 0146] | 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; focused fresh first-party post-logout replay suppression is proved locally, but durable episode and race/retry proof remains absent. | [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 and fresh first-party `PLAY` after deliberate logout omit retained output; durable episode fencing and concurrent/delayed replay proof remain absent. 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. | | 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. | -| 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` - focused role tests prove global `platformAdmin`, `support`, `billingAdmin`, legacy `god`, and `moderator` claims remain ordinary players, while only matching tenant-scoped gameplay grants elevate. Game Session removes legacy `HIDDEN_STAFF` from player command/output vocabulary and redacts legacy or unknown friend-presence entries; Account and Social profile-policy inputs still accept `HIDDEN_STAFF`, and player-facing payloads still expose disconnect disposition contrary to ADR 0046. This does not establish Account end-to-end admission. | [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); [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/impl/GameplayPresenceActivityResolverTest.java); [RedisGameplayPresenceServiceTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/service/impl/RedisGameplayPresenceServiceTest.java); [FriendsCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.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) | Account end-to-end admission remains unproven. Remove `HIDDEN_STAFF` from Account and Social profile-policy inputs, suppress disconnect disposition from player responses, add private-by-failure and bounded-page proof, and keep in-world concealment under gameplay policy before calling this capability proven. | +| 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` - focused role tests prove global `platformAdmin`, `support`, `billingAdmin`, legacy `god`, and `moderator` claims remain ordinary players, while only matching tenant-scoped gameplay grants elevate. Game Session removes legacy `HIDDEN_STAFF` from player command/output vocabulary and redacts legacy or unknown friend-presence entries; Account and Social profile-policy inputs still accept `HIDDEN_STAFF`, and player-facing payloads still expose disconnect disposition contrary to ADR 0046. This does not establish Account end-to-end admission. | [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); [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); [FriendsCommandHandlerTest.java](../../../services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.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) | Account end-to-end admission remains unproven. Remove `HIDDEN_STAFF` from Account and Social profile-policy inputs, suppress disconnect disposition from player responses, add private-by-failure and bounded-page proof, and keep in-world concealment under gameplay policy before calling this capability proven. | | 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, and an opt-in unprivileged static-host/preview-route slice is prepared but disabled; this is not an independently released player application. 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`. Opt-in Helm chart lint/render passed; no static image has been published, deployed, or browser-proved. | [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); [static host Dockerfile](../../../web-client/Dockerfile); [preview frontend template](../../../k8s/helm/firemud/templates/frontend.yaml) | `npm run lint` and `npm run build` passed and emitted `dist/frontend-assets/`; opt-in Helm lint/render passed, but no image build, running-host checks, or deployed browser journey executed. | [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, enabled static-host deployment and public 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. | From 1439441f84144f808efa7c0d0f6207c5d1e48750 Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Sat, 26 Sep 2026 21:50:51 +1200 Subject: [PATCH 3/3] Prove friend privacy in cross-service gameplay flows --- .../command/text/FriendsCommandHandler.java | 11 +-- .../TextPlayerOutputRenderer.java | 3 + ...ommunicationWebSocketCrossServiceTest.java | 68 +++++++++++++++++++ .../text/FriendsCommandHandlerTest.java | 29 ++++++-- .../command/text/WhoCommandHandlerTest.java | 8 +-- .../GameplayPresenceRoleClassifierTest.java | 5 +- .../RedisGameplayPresenceServiceTest.java | 7 +- .../WebSocketOutputProjectorTest.java | 3 +- 8 files changed, 104 insertions(+), 30 deletions(-) diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java index a4cbb18be3..14257ef208 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandler.java @@ -432,11 +432,7 @@ private FriendPresenceViewOutput.Entry toEntry(int ordinal, FriendRosterEntry en FriendPresenceEntry presence = entry.getPresence(); long friendAccountId = requireFriendAccountId(entry.getFriendAccountId()); if (!isPlayerDisclosablePolicy(presence.getVisibilityPolicy())) { - return redactedEntry( - ordinal, - entry, - friendAccountId, - "Friend #" + friendAccountId); + return redactedEntry(ordinal, entry, friendAccountId, "Friend #" + friendAccountId); } String characterName = presence.getCharacterName().isBlank() ? null : presence.getCharacterName().trim(); @@ -462,10 +458,7 @@ private FriendPresenceViewOutput.Entry toEntry(int ordinal, FriendRosterEntry en } private FriendPresenceViewOutput.Entry redactedEntry( - int ordinal, - FriendRosterEntry entry, - long friendAccountId, - String displayName) { + int ordinal, FriendRosterEntry entry, long friendAccountId, String displayName) { return new FriendPresenceViewOutput.Entry( ordinal, parseOptionalLong(entry.getFriendLinkId()), diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java index f47696cc42..7d4aca4c18 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/presentation/TextPlayerOutputRenderer.java @@ -652,6 +652,9 @@ private String renderFriendLocation(FriendPresenceViewOutput.Entry entry) { } private String renderFriendActivity(String activityState) { + if (!StringUtils.hasText(activityState)) { + return null; + } return switch (activityState) { case "AUTO_AFK" -> "idle"; case "EXPLICIT_AFK" -> "AFK"; diff --git a/services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/CommunicationWebSocketCrossServiceTest.java b/services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/CommunicationWebSocketCrossServiceTest.java index 38eb8d2216..46bc398992 100644 --- a/services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/CommunicationWebSocketCrossServiceTest.java +++ b/services/game-session-service/src/test/java/crossservice/net/firedevops/firemud/gamesession/CommunicationWebSocketCrossServiceTest.java @@ -299,6 +299,71 @@ void freshGameplayBaselineReappliesConfiguredFriendPresenceBaseline() throws Exc + "] - online in Demo World / Live Realm (idle)")); } + @Test + void websocketFriendsMissingPolicyRedactsPresenceWithoutDisconnecting() throws Exception { + ensureTestServicesStarted(); + long sessionId = prepareGameInstance(); + FriendPresenceEntry missingPolicyPresence = + FriendPresenceEntry.newBuilder() + .setFriendAccountId(Long.toString(SORA_ACCOUNT_ID)) + .setOnline(true) + .setCharacterId(ChatTestFixtures.PLAYER_SORA) + .setCharacterName("Sora") + .setPlayableStateScope( + net.firedevops.firemud.entitymanagement.v1.PlayableStateScope + .PLAYABLE_STATE_SCOPE_SHARED) + .setWorldSlug("demo") + .setWorldDisplayName("Demo World") + .setRealmSlug("production") + .setRealmDisplayName("Live Realm") + .setActivityState(FriendPresenceActivityState.FRIEND_PRESENCE_ACTIVITY_STATE_AUTO_AFK) + .build(); + socialStub().setFriendPresenceEntries(List.of(missingPolicyPresence)); + + try (GameplayWebSocketDriver client = + openFirstPartyGameplayClient("friends-missing-policy-first-party")) { + int baseline = client.responses().size(); + client.send("FRIENDS"); + JsonNode friends = awaitStructuredCommand(client, baseline, "FRIENDS"); + JsonNode friendsPayload = requirePayload(friends, "friends_view"); + assertThat(friendsPayload.path("friends")).hasSize(1); + JsonNode entry = friendsPayload.path("friends").get(0); + assertThat(entry.path("friendAccountId").asLong()).isEqualTo(SORA_ACCOUNT_ID); + assertThat(entry.path("displayName").asText()).isEqualTo("Friend #" + SORA_ACCOUNT_ID); + for (String field : + List.of( + "online", + "worldSlug", + "worldDisplayName", + "realmSlug", + "realmDisplayName", + "characterName", + "playableStateScope", + "pointerVersion", + "activityState", + "lastSeenAtEpochMs", + "recentDisposition", + "visibilityPolicy")) { + assertThat(entry.has(field)).as("redacted field %s", field).isFalse(); + } + } + + sessionId = prepareGameInstance(); + socialStub().setFriendPresenceEntries(List.of(missingPolicyPresence)); + try (GameplayWebSocketDriver client = + openReadySessionClient(sessionId, "friends-missing-policy-detail")) { + int baseline = client.responses().size(); + client.send("FRIENDS SHOW #1"); + client.awaitContains("Presence: presence unavailable"); + assertThat(client.responses().subList(baseline, client.responses().size())) + .noneMatch( + response -> + response.contains("Sora") + || response.contains("Demo World") + || response.contains("Live Realm")); + } + } + @Test void websocketFriendsMutationFlowUsesCanonicalRosterSurface() throws Exception { ensureTestServicesStarted(); @@ -900,6 +965,9 @@ private static synchronized void ensureTestServicesStarted() throws Exception { .setPlayableStateScope( net.firedevops.firemud.entitymanagement.v1.PlayableStateScope .PLAYABLE_STATE_SCOPE_SHARED) + .setVisibilityPolicy( + FriendPresenceVisibilityPolicy + .FRIEND_PRESENCE_VISIBILITY_POLICY_FRIENDS_ONLY) .setWorldSlug("demo") .setWorldDisplayName("Demo World") .setRealmSlug("production") diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java index edc61b6e2c..e976031574 100644 --- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java +++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/command/text/FriendsCommandHandlerTest.java @@ -371,7 +371,8 @@ void friendsRedactsLegacyHiddenStaffEntryButPreservesRelationshipRow() { .setWorldDisplayName("Demo World") .setRealmSlug("production") .setRealmDisplayName("Live Realm") - .setPlayableStateScope(PlayableStateScope.PLAYABLE_STATE_SCOPE_SHARED) + .setPlayableStateScope( + PlayableStateScope.PLAYABLE_STATE_SCOPE_SHARED) .setPointerVersion(17L) .setActivityState( FriendPresenceActivityState @@ -855,7 +856,7 @@ void friendsShowReturnsCanonicalFriendDetailView() { } @Test - void friendsShowByOrdinalUsesCanonicalDetailSurface() { + void friendsShowByOrdinalRedactsMissingPolicyAndRendersDetail() { SocialGroupsClient socialGroupsClient = Mockito.mock(SocialGroupsClient.class); EntityManagementClient entityManagementClient = Mockito.mock(EntityManagementClient.class); FriendsCommandHandler handler = @@ -871,7 +872,12 @@ void friendsShowByOrdinalUsesCanonicalDetailSurface() { .setPresence( FriendPresenceEntry.newBuilder() .setFriendAccountId("77") + .setOnline(true) .setCharacterName("Sora") + .setWorldDisplayName("Demo World") + .setActivityState( + FriendPresenceActivityState + .FRIEND_PRESENCE_ACTIVITY_STATE_AUTO_AFK) .build()) .build()) .build()); @@ -885,6 +891,18 @@ void friendsShowByOrdinalUsesCanonicalDetailSurface() { assertThat(result.commandResult().accepted()).isTrue(); FriendDetailViewOutput detail = (FriendDetailViewOutput) result.outputs().getFirst().payload(); assertThat(detail.friend().ordinal()).isEqualTo(1); + assertThat(detail.friend().displayName()).isEqualTo("Friend #77"); + assertThat(detail.friend().online()).isNull(); + assertThat(detail.friend().characterName()).isNull(); + assertThat(detail.friend().worldDisplayName()).isNull(); + assertThat(detail.friend().activityState()).isNull(); + assertThat( + new TextPlayerOutputRenderer( + new net.firedevops.firemud.gamesession.config.PresentationProperties()) + .render(result.outputs().getFirst())) + .contains("Presence: presence unavailable") + .contains("Roster entry: #1") + .doesNotContain("Sora", "Demo World", "online", "idle"); Mockito.verify(socialGroupsClient).getFriendByOrdinal(1L, 41L, 1); } @@ -1113,8 +1131,7 @@ void friendsVisibilityShowsCurrentCanonicalPolicy() { FriendPresencePolicyViewOutput view = (FriendPresencePolicyViewOutput) result.outputs().getFirst().payload(); assertThat(view.currentPolicy()).isEqualTo("FRIENDS_ONLY"); - assertThat(view.options()) - .noneMatch(option -> option.policy().equals("HIDDEN_STAFF")); + assertThat(view.options()).noneMatch(option -> option.policy().equals("HIDDEN_STAFF")); assertThat(view.options()) .anySatisfy( option -> { @@ -1316,9 +1333,7 @@ void friendsDoesNotAcceptLegacyHiddenStaffFilter() { TextCommandInterpretationResult result = handler.handle( new TextCommand( - TextCommandType.FRIENDS, - java.util.List.of("HIDDEN_STAFF"), - "FRIENDS HIDDEN_STAFF"), + TextCommandType.FRIENDS, java.util.List.of("HIDDEN_STAFF"), "FRIENDS HIDDEN_STAFF"), GAMEPLAY_CONTEXT); assertThat(result.commandResult().accepted()).isFalse(); 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 b098f3f8ed..f41613d0c4 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 @@ -57,10 +57,7 @@ void whoGroupsElevatedPlayersFirstAndPlayersAfterward() { jwtUtil.generateToken( "1", java.util.Map.of( - "accountId", - "1", - "scopedRoles", - java.util.Map.of("22", java.util.List.of("god")))); + "accountId", "1", "scopedRoles", java.util.Map.of("22", java.util.List.of("god")))); gameplayPresenceService.registerConnected( new SessionContext(1L, 22L, 1L, "god@example.com", 101L, "Aster", 7L, "R-1", godJwt)); @@ -104,7 +101,8 @@ void whoShowsGlobalOnlyRolesAsPlayers() { java.util.List.of("platformAdmin", "support", "billingAdmin", "god", "moderator"))); gameplayPresenceService.registerConnected( - new SessionContext(1L, 22L, 1L, "staff@example.com", 101L, "Aster", 7L, "R-1", globalOnlyJwt)); + new SessionContext( + 1L, 22L, 1L, "staff@example.com", 101L, "Aster", 7L, "R-1", globalOnlyJwt)); TextCommandInterpretationResult result = handler.handle( 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 index 3fb2e9d849..8c03ef384a 100644 --- 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 @@ -158,7 +158,10 @@ void classifyRoleReturnsGodForTenantScopedGodRole() { JWT_UTIL.generateToken( "202", java.util.Map.of( - "accountId", "202", "scopedRoles", java.util.Map.of("22", java.util.List.of("god")))); + "accountId", + "202", + "scopedRoles", + java.util.Map.of("22", java.util.List.of("god")))); GameplayPresenceRole role = GameplayPresenceRoleClassifier.classifyRole( 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 5e4d79242f..bee45bc8a1 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 @@ -85,12 +85,7 @@ void registerConnectedClassifiesInvalidJwtAsPlayer() { void listConnectedByGameInstanceSortsGodsFirstAndPrunesMissingSessions() { String godJwt = jwtUtil.generateToken( - "1", - Map.of( - "accountId", - "1", - "scopedRoles", - Map.of("22", List.of("god")))); + "1", Map.of("accountId", "1", "scopedRoles", Map.of("22", List.of("god")))); SessionContext godContext = new SessionContext(1L, 22L, 1L, "god@example.com", 101L, "Aster", 7L, "R-1", godJwt); service.registerConnected(godContext); diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java index 33d4122202..cea7a9d73c 100644 --- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java +++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/websocket/WebSocketOutputProjectorTest.java @@ -688,8 +688,7 @@ void firstPartyWebProjectsFriendRosterSummaryViewPayloads() throws Exception { PlayerOutput.view( new FriendRosterSummaryViewOutput(4, 1, 3, 2, 1, 2, 1, 2, 1, 1)))), List.of( - PlayerOutput.view( - new FriendRosterSummaryViewOutput(4, 1, 3, 2, 1, 2, 1, 2, 1, 1))), + PlayerOutput.view(new FriendRosterSummaryViewOutput(4, 1, 3, 2, 1, 2, 1, 2, 1, 1))), "en-NZ", presentation);