From 267d8a0af86df83c59a6743e96d72445af270985 Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Thu, 1 Oct 2026 14:59:31 +1300 Subject: [PATCH 1/5] Carry canonical UUID requests through fenced membership candidates --- .../dto/RuntimeMembershipSnapshotDto.java | 25 ++-- .../AccountTenantIdentityResolver.java | 37 ++++- ...ovedLegacyTenantAssociationRepository.java | 58 +++++--- ...countMembershipAuthorityEventProducer.java | 93 +++++++++++- .../service/impl/AccountGrpcService.java | 24 ++-- ...UuidMembershipSnapshotIntegrationTest.java | 89 ++++++++++++ .../AccountJoinPostgresIntegrationTest.java | 12 +- .../AccountTenantIdentityResolverTest.java | 69 ++++++++- ...tMembershipAuthorityEventProducerTest.java | 33 +++++ .../service/impl/AccountGrpcServiceTest.java | 132 +++++++++++++++--- .../gamesession/client/AccountClient.java | 22 ++- .../gamesession/client/AccountClientTest.java | 107 +++++++++++--- 12 files changed, 610 insertions(+), 91 deletions(-) diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeMembershipSnapshotDto.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeMembershipSnapshotDto.java index 5a30374651..79a1a7dd26 100644 --- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeMembershipSnapshotDto.java +++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/dto/RuntimeMembershipSnapshotDto.java @@ -12,8 +12,8 @@ /** Same-fence Account snapshot candidate for the denied runtime membership RPC. */ public record RuntimeMembershipSnapshotDto( - Long requestAccountId, - Long requestTenantId, + String requestAccountUuid, + String requestTenantUuid, String accountUuid, String tenantUuid, boolean membershipExists, @@ -27,15 +27,14 @@ public record RuntimeMembershipSnapshotDto( List outboxSourceEvidence, MembershipEvent sourceEvent) { public RuntimeMembershipSnapshotDto { - if (requestAccountId == null - || requestAccountId <= 0L - || requestTenantId == null - || requestTenantId <= 0L) { - throw new IllegalArgumentException( - "Runtime membership account and tenant IDs must be positive"); - } + requestAccountUuid = requireCanonicalUuid(requestAccountUuid, "requested Account UUID"); + requestTenantUuid = requireCanonicalUuid(requestTenantUuid, "requested tenant UUID"); accountUuid = requireCanonicalUuid(accountUuid, "Account UUID"); tenantUuid = requireCanonicalUuid(tenantUuid, "tenant UUID"); + if (!requestAccountUuid.equals(accountUuid) || !requestTenantUuid.equals(tenantUuid)) { + throw new IllegalArgumentException( + "Runtime membership request identity differs from its verified Account snapshot"); + } Objects.requireNonNull(membershipBaseline, "unchanged membership baseline is required"); roles = List.copyOf(roles); Objects.requireNonNull(authorityTuple, "complete membership authority tuple is required"); @@ -152,11 +151,13 @@ private static MembershipEvent requireConsistentSourceEvent( private static String requireCanonicalUuid(String value, String field) { Objects.requireNonNull(value, field + " is required"); try { - if (!java.util.UUID.fromString(value).toString().equals(value)) { - throw new IllegalArgumentException(field + " must be a canonical lowercase UUID"); + java.util.UUID parsed = java.util.UUID.fromString(value); + if (parsed.equals(new java.util.UUID(0L, 0L)) || !parsed.toString().equals(value)) { + throw new IllegalArgumentException(field + " must be a non-nil canonical lowercase UUID"); } } catch (IllegalArgumentException exception) { - throw new IllegalArgumentException(field + " must be a canonical lowercase UUID", exception); + throw new IllegalArgumentException( + field + " must be a non-nil canonical lowercase UUID", exception); } return value; } diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolver.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolver.java index 261a856e26..c4c4869458 100644 --- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolver.java +++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolver.java @@ -2,15 +2,14 @@ import java.util.Objects; import java.util.Optional; +import java.util.UUID; import net.firedevops.firemud.accountservice.repository.ApprovedLegacyTenantAssociationRepository.ApprovedAssociation; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -/** - * Resolves retained numeric tenant keys through an approved, provenance-backed UUID association. - */ +/** Resolves retained tenant identity through its approved, provenance-backed UUID association. */ @Repository public class AccountTenantIdentityResolver { private final ApprovedLegacyTenantAssociationRepository associations; @@ -59,4 +58,36 @@ public ApprovedAssociation resolve(long legacyTenantId) { } return association; } + + /** + * Resolves an exact canonical tenant UUID only through its approved retained association and + * current source-evidence digest. Fresh UUIDs are resolved by their separate V38 repository. + */ + @Transactional(propagation = Propagation.MANDATORY) + public ApprovedAssociation resolve(UUID canonicalTenantId) { + if (canonicalTenantId == null || canonicalTenantId.equals(new UUID(0L, 0L))) { + throw new IllegalArgumentException("non-nil canonical tenant UUID is required"); + } + if (workloadNamespace == null || workloadNamespace.isBlank()) { + throw new IllegalStateException("Account workload namespace is not configured"); + } + + Optional stored = associations.findByCanonicalTenantId(canonicalTenantId); + if (stored.isEmpty()) { + throw new IllegalStateException("approved Account tenant association is absent"); + } + ApprovedAssociation association = stored.orElseThrow(); + if (association.legacyTenantId() <= 0L + || !canonicalTenantId.equals(association.canonicalTenantId()) + || !workloadNamespace.equals(association.targetNamespace())) { + throw new IllegalStateException("approved Account tenant association is mismatched"); + } + + String currentEvidenceDigest = sourceEvidence.digest(association.legacyTenantId()); + if (!Objects.equals(association.accountEvidenceDigest(), currentEvidenceDigest)) { + throw new IllegalStateException( + "approved Account source evidence differs from retained rows"); + } + return association; + } } diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/ApprovedLegacyTenantAssociationRepository.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/ApprovedLegacyTenantAssociationRepository.java index 7fe9d53d71..e2486b0e40 100644 --- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/ApprovedLegacyTenantAssociationRepository.java +++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/repository/ApprovedLegacyTenantAssociationRepository.java @@ -103,25 +103,45 @@ public Optional findByLegacyTenantId(long legacyTenantId) { + "manifest_schema_version " + "FROM account_approved_legacy_tenant_associations WHERE legacy_tenant_id = ?", legacyTenantId); - return Optional.ofNullable(row) - .map( - result -> - new ApprovedAssociation( - result.get(0, Long.class), - result.get(1, UUID.class), - result.get(2, String.class), - result.get(3, Long.class), - result.get(4, String.class), - result.get(5, UUID.class), - result.get(6, String.class), - result.get(7, String.class), - result.get(8, String.class), - result.get(9, String.class), - result.get(10, String.class), - result.get(11, String.class), - result.get(12, String.class), - result.get(13, Integer.class), - result.get(14, Integer.class))); + return Optional.ofNullable(row).map(this::toAssociation); + } + + /** Exact reverse lookup for an approved retained canonical tenant identity. */ + @Transactional(readOnly = true) + public Optional findByCanonicalTenantId(UUID canonicalTenantId) { + if (canonicalTenantId == null || canonicalTenantId.equals(new UUID(0L, 0L))) { + return Optional.empty(); + } + Record row = + dsl.fetchOne( + "SELECT legacy_tenant_id, canonical_tenant_id, source_legacy_game_tenant_id, " + + "source_game_row_id, account_evidence_digest, operation_id, manifest_digest, " + + "manifest_signature, target_namespace, signer_key_id, approved_by, " + + "approval_reference, signed_at, operation_entry_count, " + + "manifest_schema_version " + + "FROM account_approved_legacy_tenant_associations " + + "WHERE canonical_tenant_id = ? AND identity_kind = 'APPROVED_RETAINED'", + canonicalTenantId); + return Optional.ofNullable(row).map(this::toAssociation); + } + + private ApprovedAssociation toAssociation(Record result) { + return new ApprovedAssociation( + result.get(0, Long.class), + result.get(1, UUID.class), + result.get(2, String.class), + result.get(3, Long.class), + result.get(4, String.class), + result.get(5, UUID.class), + result.get(6, String.class), + result.get(7, String.class), + result.get(8, String.class), + result.get(9, String.class), + result.get(10, String.class), + result.get(11, String.class), + result.get(12, String.class), + result.get(13, Integer.class), + result.get(14, Integer.class)); } private ApprovedAssociation requireExactResponse( diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducer.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducer.java index 8e7a64ed63..944a5ce7b8 100644 --- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducer.java +++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducer.java @@ -327,8 +327,8 @@ public RuntimeMembershipSnapshotDto readRuntimeMembershipSnapshot( PositiveMembershipSnapshot positive = readCurrentPairBoundPositiveMembershipSnapshot(accountId, legacyTenantId); return new RuntimeMembershipSnapshotDto( - accountId, - legacyTenantId, + positive.accountId(), + positive.tenantId(), positive.accountId(), positive.tenantId(), positive.membershipExists(), @@ -349,8 +349,8 @@ public RuntimeMembershipSnapshotDto readRuntimeMembershipSnapshot( NeverJoinedMembershipSnapshot absent = readNeverJoinedMembershipSnapshot(accountId, legacyTenantId); return new RuntimeMembershipSnapshotDto( - accountId, - legacyTenantId, + absent.accountId(), + absent.tenantId(), absent.accountId(), absent.tenantId(), absent.membershipExists(), @@ -368,6 +368,91 @@ public RuntimeMembershipSnapshotDto readRuntimeMembershipSnapshot( null); } + /** + * Resolves canonical Account and tenant UUIDs to one owner-fenced runtime membership snapshot. + * Fresh tenants use only their immutable V38 association and never receive a numeric alias; + * retained tenants must resolve through the exact approved UUID association and source digest. + */ + @Transactional(propagation = Propagation.MANDATORY) + public RuntimeMembershipSnapshotDto readRuntimeMembershipSnapshot( + UUID accountUuid, UUID tenantUuid) { + requireActiveOwnerTransaction(); + requireCanonicalUuidInput(accountUuid, "Account UUID"); + requireCanonicalUuidInput(tenantUuid, "tenant UUID"); + + Account initialAccount = + accountRepository + .findByAccountUuid(accountUuid) + .orElseThrow(() -> new IllegalStateException("Runtime snapshot Account row is absent")); + requirePersistedAccountIdentity(initialAccount, accountUuid); + long accountId = initialAccount.getId(); + + // The persisted Account row is the owner fence for every subsequent identity/history read. + joinOperationRepository.lockAccount(accountId); + Account fencedAccount = + accountRepository + .findByAccountUuid(accountUuid) + .orElseThrow( + () -> + new IllegalStateException( + "Runtime snapshot Account row disappeared at its fence")); + requirePersistedAccountIdentity(fencedAccount, accountUuid); + if (!Objects.equals(initialAccount.getId(), fencedAccount.getId()) + || initialAccount.getAccountUuidProvenance() != fencedAccount.getAccountUuidProvenance() + || !Objects.equals( + initialAccount.getAccountUuidSourceNumericId(), + fencedAccount.getAccountUuidSourceNumericId())) { + throw new IllegalStateException("Runtime snapshot Account identity changed at its row fence"); + } + + Optional freshAssociation = + freshTenantIdentityAssociationRepository.read(tenantUuid); + if (freshAssociation.isPresent()) { + NeverJoinedMembershipSnapshot absent = + readFreshNeverJoinedMembershipSnapshot(accountUuid, tenantUuid); + return toRuntimeMembershipSnapshot(absent); + } + + ApprovedAssociation retainedAssociation = tenantIdentityResolver.resolve(tenantUuid); + if (retainedAssociation.legacyTenantId() <= 0L + || !tenantUuid.equals(retainedAssociation.canonicalTenantId())) { + throw new IllegalStateException( + "Retained tenant UUID has no exact private numeric association"); + } + RuntimeMembershipSnapshotDto retained = + readRuntimeMembershipSnapshot(accountId, retainedAssociation.legacyTenantId()); + if (!accountUuid.toString().equals(retained.accountUuid()) + || !tenantUuid.toString().equals(retained.tenantUuid()) + || !accountUuid.toString().equals(retained.requestAccountUuid()) + || !tenantUuid.toString().equals(retained.requestTenantUuid())) { + throw new IllegalStateException( + "Retained numeric membership readback differs from its exact canonical UUID request"); + } + return retained; + } + + private RuntimeMembershipSnapshotDto toRuntimeMembershipSnapshot( + NeverJoinedMembershipSnapshot absent) { + return new RuntimeMembershipSnapshotDto( + absent.accountId(), + absent.tenantId(), + absent.accountId(), + absent.tenantId(), + false, + false, + new RuntimeMembershipSnapshotDto.MembershipBaseline( + absent.membershipLifecycleState(), + absent.membershipVersion(), + absent.membershipAuthorityGeneration()), + List.of(), + absent.authorityTuple(), + absent.issuanceFence(), + absent.evaluatedAt(), + absent.outboxCheckpoints(), + absent.outboxSourceEvidence(), + null); + } + /** * Reads an explicit sequence-zero checkpoint only from a durable verified pair baseline, after * the no-membership and no-committed-history proof under one Account-row fence. It never admits diff --git a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java index 61fee41c9a..3a74714a20 100644 --- a/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java +++ b/services/account-service/src/main/java/net/firedevops/firemud/accountservice/service/impl/AccountGrpcService.java @@ -457,10 +457,8 @@ static GetTenantMembershipForRuntimeResponse encodeRuntimeMembershipCandidate( net.firedevops.firemud.shared.v1.PlayerExecutionContext playerContext, RuntimeMembershipSnapshotDto snapshot) { requireCompleteRuntimePlayerContext(playerContext); - long requestAccountId = parseCanonicalPositiveId(playerContext.getAccountId(), "account ID"); - long requestTenantId = parseCanonicalPositiveId(playerContext.getTenantId(), "tenant ID"); - if (requestAccountId != snapshot.requestAccountId() - || requestTenantId != snapshot.requestTenantId()) { + if (!playerContext.getAccountId().equals(snapshot.requestAccountUuid()) + || !playerContext.getTenantId().equals(snapshot.requestTenantUuid())) { throw new IllegalArgumentException( "Runtime membership producer result differs from its caller target"); } @@ -525,9 +523,11 @@ private static void requireCompleteRuntimePlayerContext( && !"ISOLATED".equals(playerContext.getPlayableStateScope())) { throw new IllegalArgumentException("Runtime membership target scope is invalid"); } - parseCanonicalPositiveId(playerContext.getAccountId(), "account ID"); - parseCanonicalPositiveId(playerContext.getTenantId(), "tenant ID"); - parseCanonicalPositiveId(playerContext.getGameInstanceId(), "game instance ID"); + requireCanonicalUuid(playerContext.getAccountId(), "account UUID"); + requireCanonicalUuid(playerContext.getTenantId(), "tenant UUID"); + requireCanonicalUuid( + playerContext.getPlayableStateNamespaceId(), "playable-state namespace UUID"); + requireCanonicalUuid(playerContext.getGameInstanceId(), "game instance UUID"); parseCanonicalPositiveId(playerContext.getSessionId(), "session ID"); } @@ -708,9 +708,17 @@ private static long parseCanonicalPositiveId(String value, String field) { } private static void requireCanonicalUuid(String value, String field) { - if (!hasText(value) || !UUID.fromString(value).toString().equals(value)) { + if (!hasText(value)) { throw new IllegalArgumentException("Runtime membership " + field + " is invalid"); } + try { + UUID uuid = UUID.fromString(value); + if (uuid.equals(new UUID(0L, 0L)) || !uuid.toString().equals(value)) { + throw new IllegalArgumentException("Runtime membership " + field + " is invalid"); + } + } catch (IllegalArgumentException exception) { + throw new IllegalArgumentException("Runtime membership " + field + " is invalid", exception); + } } private static boolean hasText(String value) { diff --git a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountFreshUuidMembershipSnapshotIntegrationTest.java b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountFreshUuidMembershipSnapshotIntegrationTest.java index 4b0ecc029e..7d64c0f600 100644 --- a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountFreshUuidMembershipSnapshotIntegrationTest.java +++ b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountFreshUuidMembershipSnapshotIntegrationTest.java @@ -23,6 +23,7 @@ import net.firedevops.firemud.accountservice.client.EntityManagementClient; import net.firedevops.firemud.accountservice.client.GameSessionClient; import net.firedevops.firemud.accountservice.client.LoggingAdminClient; +import net.firedevops.firemud.accountservice.dto.RuntimeMembershipSnapshotDto; import net.firedevops.firemud.accountservice.repository.AccountAuthorityGenerationRepository; import net.firedevops.firemud.accountservice.repository.AccountAuthorityOutboxRepository; import net.firedevops.firemud.accountservice.repository.AccountJoinOperationRepository; @@ -173,6 +174,88 @@ void freshUuidSnapshotEnrollsExactNonAdmittingBaselineAndRetriesWithoutSideEffec assertThat(issuanceFence(account.accountUuid())).isEqualTo(originalIssuanceFence); } + @Test + void canonicalRuntimeReadUsesFreshUuidAssociationWithoutInventingRetainedAlias() { + AccountFixture account = accountFixture(); + UUID tenantUuid = UUID.randomUUID(); + FreshTenantCreationEvidence evidence = importFreshTenantAssociation(tenantUuid); + long originalIssuanceFence = issuanceFence(account.accountUuid()); + + RuntimeMembershipSnapshotDto first = + readRuntimeMembershipSnapshot(account.accountUuid(), tenantUuid); + + assertThat(first.requestAccountUuid()).isEqualTo(account.accountUuid().toString()); + assertThat(first.requestTenantUuid()).isEqualTo(tenantUuid.toString()); + assertThat(first.accountUuid()).isEqualTo(account.accountUuid().toString()); + assertThat(first.tenantUuid()).isEqualTo(tenantUuid.toString()); + assertThat(first.membershipExists()).isFalse(); + assertThat(first.gameplayAdmissionAllowed()).isFalse(); + assertThat(first.membershipBaseline().membershipLifecycleState()).isEqualTo("MISSING"); + assertThat(first.membershipBaseline().membershipVersion()) + .isEqualTo(Map.of(tenantUuid.toString(), "1")); + assertThat(first.membershipBaseline().membershipAuthorityGeneration()).isEqualTo("1"); + assertThat(first.authorityTuple().issuerAuthGeneration()).isEqualTo("1"); + assertThat(first.authorityTuple().accountAuthorityGeneration()).isEqualTo("1"); + assertThat(first.authorityTuple().tenantAuthorityGeneration()) + .isEqualTo(Map.of(tenantUuid.toString(), "1")); + assertThat(first.authorityTuple().membershipAuthorityGeneration()) + .isEqualTo(Map.of(tenantUuid.toString(), "1")); + assertThat(first.authorityTuple().privateRealmGrantVersions()).isEmpty(); + assertThat(first.issuanceFence()).isEqualTo(Long.toString(originalIssuanceFence)); + assertThat(first.evaluatedAt()).isNotNull(); + assertThat(first.outboxCheckpoints()) + .containsExactlyElementsOf(expectedCheckpoints(account.accountUuid(), tenantUuid)); + assertThat(first.outboxSourceEvidence()).isEmpty(); + assertThat(first.sourceEvent()).isNull(); + assertThat(first.roles()).isEmpty(); + assertThat(membershipPairAuthorityRow(account.accountUuid(), tenantUuid)) + .containsEntry("legacy_tenant_id", null) + .containsEntry("tenant_provenance_kind", "FRESH_GAME_DESIGN") + .containsEntry("tenant_source_operation_id", evidence.operationId()) + .containsEntry("tenant_provenance_digest", evidence.evidenceDigest()) + .containsEntry("membership_exists", false) + .containsEntry("membership_version", 1L) + .containsEntry("membership_authority_generation", 1L) + .containsEntry("last_event_sequence", 0L); + assertThat(countApprovedAssociationForCanonicalTenant(tenantUuid)).isZero(); + assertThat(countMembershipsForAccount(account.accountId())).isZero(); + assertThat(countMembershipTransitionReceiptsForAccount(account.accountId())).isZero(); + assertThat(countAuthorityEvents(membershipStreamKey(account.accountUuid(), tenantUuid))) + .isZero(); + assertThat(countAuthorityStreams(membershipStreamKey(account.accountUuid(), tenantUuid))) + .isZero(); + assertThat(issuanceFence(account.accountUuid())).isEqualTo(originalIssuanceFence); + + RuntimeMembershipSnapshotDto retry = + readRuntimeMembershipSnapshot(account.accountUuid(), tenantUuid); + assertThat(retry.requestAccountUuid()).isEqualTo(first.requestAccountUuid()); + assertThat(retry.requestTenantUuid()).isEqualTo(first.requestTenantUuid()); + assertThat(retry.membershipBaseline()).isEqualTo(first.membershipBaseline()); + assertThat(retry.authorityTuple()).isEqualTo(first.authorityTuple()); + assertThat(retry.issuanceFence()).isEqualTo(first.issuanceFence()); + assertThat(retry.outboxCheckpoints()).isEqualTo(first.outboxCheckpoints()); + assertThat(retry.outboxSourceEvidence()).isEmpty(); + assertThat(countMembershipPairAuthorities(account.accountUuid(), tenantUuid)).isEqualTo(1L); + assertThat(countMembershipAuthorityGenerations(account.accountUuid(), tenantUuid)) + .isEqualTo(1L); + } + + @Test + void canonicalRuntimeReadRejectsUnmappedTenantUuidWithoutEnrollment() { + AccountFixture account = accountFixture(); + UUID unmappedTenantUuid = UUID.randomUUID(); + + assertThatThrownBy( + () -> readRuntimeMembershipSnapshot(account.accountUuid(), unmappedTenantUuid)) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("approved Account tenant association is absent"); + assertThat(countMembershipPairAuthorities(account.accountUuid(), unmappedTenantUuid)).isZero(); + assertThat(countMembershipAuthorityGenerations(account.accountUuid(), unmappedTenantUuid)) + .isZero(); + assertThat(countMembershipsForAccount(account.accountId())).isZero(); + assertThat(countMembershipTransitionReceiptsForAccount(account.accountId())).isZero(); + } + @Test void freshUuidSnapshotRejectsUnmappedTenantWithoutEnrollment() { AccountFixture account = accountFixture(); @@ -491,6 +574,12 @@ private FreshTenantCreationEvidence importFreshTenantAssociation(UUID canonicalT status -> producer.readFreshNeverJoinedMembershipSnapshot(accountUuid, tenantUuid)); } + private RuntimeMembershipSnapshotDto readRuntimeMembershipSnapshot( + UUID accountUuid, UUID tenantUuid) { + return new TransactionTemplate(transactionManager) + .execute(status -> producer.readRuntimeMembershipSnapshot(accountUuid, tenantUuid)); + } + private Map membershipPairAuthorityRow(UUID accountUuid, UUID tenantUuid) { var row = dsl.resultQuery( diff --git a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java index 7b9188b4ec..e105dfe561 100644 --- a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java +++ b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java @@ -1104,8 +1104,8 @@ void runtimeMembershipSnapshotKeepsAbsenceAndFirstJoinEvidenceInOneFencedResult( var absent = readRuntimeMembershipSnapshot(fixture); Map baselineRow = membershipPairAuthorityRow(fixture); - assertThat(absent.requestAccountId()).isEqualTo(fixture.accountId()); - assertThat(absent.requestTenantId()).isEqualTo(fixture.tenantId()); + assertThat(absent.requestAccountUuid()).isEqualTo(fixture.accountUuid().toString()); + assertThat(absent.requestTenantUuid()).isEqualTo(fixture.tenantUuid().toString()); assertThat(absent.accountUuid()).isEqualTo(fixture.accountUuid().toString()); assertThat(absent.tenantUuid()).isEqualTo(fixture.tenantUuid().toString()); assertThat(absent.membershipExists()).isFalse(); @@ -1285,7 +1285,7 @@ void concurrentFirstJoinCannotMixWithCompleteFencedRuntimeMembershipSnapshot() t status -> { capturedSnapshot.set( membershipAuthorityEventProducer.readRuntimeMembershipSnapshot( - fixture.accountId(), fixture.tenantId())); + fixture.accountUuid(), fixture.tenantUuid())); snapshotBackendPid.set( dsl.resultQuery("SELECT pg_backend_pid()") .fetchOne(0, Integer.class)); @@ -1343,8 +1343,8 @@ void concurrentFirstJoinCannotMixWithCompleteFencedRuntimeMembershipSnapshot() t RuntimeMembershipSnapshotDto absent = capturedSnapshot.get(); assertThat(absent).isNotNull(); - assertThat(absent.requestAccountId()).isEqualTo(fixture.accountId()); - assertThat(absent.requestTenantId()).isEqualTo(fixture.tenantId()); + assertThat(absent.requestAccountUuid()).isEqualTo(fixture.accountUuid().toString()); + assertThat(absent.requestTenantUuid()).isEqualTo(fixture.tenantUuid().toString()); assertThat(absent.accountUuid()).isEqualTo(fixture.accountUuid().toString()); assertThat(absent.tenantUuid()).isEqualTo(fixture.tenantUuid().toString()); assertThat(absent.membershipExists()).isFalse(); @@ -1573,7 +1573,7 @@ private void prepareRuntimeSnapshotAuthority(JoinFixture fixture) { .execute( status -> membershipAuthorityEventProducer.readRuntimeMembershipSnapshot( - fixture.accountId(), fixture.tenantId())); + fixture.accountUuid(), fixture.tenantUuid())); } private AccountMembershipAuthorityEventProducer.PositiveMembershipSnapshot diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolverTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolverTest.java index 3741b1f5c1..db0548da4a 100644 --- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolverTest.java +++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/repository/AccountTenantIdentityResolverTest.java @@ -18,6 +18,10 @@ class AccountTenantIdentityResolverTest { private static final long LEGACY_TENANT_ID = 41L; private static final String NAMESPACE = "proof"; private static final String EVIDENCE_DIGEST = "sha256:" + "a".repeat(64); + private static final UUID CANONICAL_TENANT_UUID = + UUID.fromString("22222222-2222-4222-8222-222222222222"); + private static final UUID OTHER_TENANT_UUID = + UUID.fromString("33333333-3333-4333-8333-333333333333"); private final ApprovedLegacyTenantAssociationRepository associations = mock(ApprovedLegacyTenantAssociationRepository.class); @@ -32,6 +36,11 @@ void resolverRequiresCallerOwnedSnapshotTransaction() throws NoSuchMethodExcepti .getMethod("resolve", long.class) .getAnnotation(Transactional.class); assertThat(boundary.propagation()).isEqualTo(Propagation.MANDATORY); + Transactional uuidBoundary = + AccountTenantIdentityResolver.class + .getMethod("resolve", UUID.class) + .getAnnotation(Transactional.class); + assertThat(uuidBoundary.propagation()).isEqualTo(Propagation.MANDATORY); } @Test @@ -55,6 +64,60 @@ void resolvesCanonicalIdentityWithRetainedProvenanceAfterExactEvidenceReadback() verify(sourceEvidence).digest(LEGACY_TENANT_ID); } + @Test + void resolvesCanonicalUuidThroughExactRetainedReverseLookupAndSourceDigest() { + ApprovedAssociation association = association(); + when(associations.findByCanonicalTenantId(CANONICAL_TENANT_UUID)) + .thenReturn(Optional.of(association)); + when(sourceEvidence.digest(LEGACY_TENANT_ID)).thenReturn(EVIDENCE_DIGEST); + + ApprovedAssociation resolved = resolver.resolve(CANONICAL_TENANT_UUID); + + assertThat(resolved).isSameAs(association); + assertThat(resolved.legacyTenantId()).isEqualTo(LEGACY_TENANT_ID); + assertThat(resolved.canonicalTenantId()).isEqualTo(CANONICAL_TENANT_UUID); + assertThat(resolved.sourceGameRowId()).isEqualTo(7L); + verify(associations).findByCanonicalTenantId(CANONICAL_TENANT_UUID); + verify(sourceEvidence).digest(LEGACY_TENANT_ID); + } + + @Test + void canonicalUuidReverseLookupRejectsUnmappedAssociation() { + when(associations.findByCanonicalTenantId(CANONICAL_TENANT_UUID)).thenReturn(Optional.empty()); + assertThatThrownBy(() -> resolver.resolve(CANONICAL_TENANT_UUID)) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("association is absent"); + verify(sourceEvidence, never()).digest(LEGACY_TENANT_ID); + } + + @Test + void canonicalUuidReverseLookupRejectsConflictingAssociationBeforeSourceRead() { + when(associations.findByCanonicalTenantId(CANONICAL_TENANT_UUID)) + .thenReturn(Optional.of(association(OTHER_TENANT_UUID, NAMESPACE))); + assertThatThrownBy(() -> resolver.resolve(CANONICAL_TENANT_UUID)) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("association is mismatched"); + verify(sourceEvidence, never()).digest(LEGACY_TENANT_ID); + } + + @Test + void canonicalUuidReverseLookupRejectsChangedRetainedSourceDigest() { + when(associations.findByCanonicalTenantId(CANONICAL_TENANT_UUID)) + .thenReturn(Optional.of(association())); + when(sourceEvidence.digest(LEGACY_TENANT_ID)).thenReturn("sha256:" + "c".repeat(64)); + + assertThatThrownBy(() -> resolver.resolve(CANONICAL_TENANT_UUID)) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("evidence differs"); + } + + @Test + void nilCanonicalUuidIsRejectedBeforeReverseLookup() { + assertThatThrownBy(() -> resolver.resolve(new UUID(0L, 0L))) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("non-nil canonical tenant UUID"); + } + @Test void missingAssociationFailsClosedBeforeReadingRetainedEvidence() { when(associations.findByLegacyTenantId(LEGACY_TENANT_ID)).thenReturn(Optional.empty()); @@ -114,9 +177,13 @@ private static ApprovedAssociation association() { } private static ApprovedAssociation association(String targetNamespace) { + return association(CANONICAL_TENANT_UUID, targetNamespace); + } + + private static ApprovedAssociation association(UUID canonicalTenantUuid, String targetNamespace) { return new ApprovedAssociation( LEGACY_TENANT_ID, - UUID.fromString("22222222-2222-4222-8222-222222222222"), + canonicalTenantUuid, "legacy-game-7", 7L, EVIDENCE_DIGEST, diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducerTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducerTest.java index 4efaec3bf0..46208ce39d 100644 --- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducerTest.java +++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/AccountMembershipAuthorityEventProducerTest.java @@ -46,4 +46,37 @@ void freshSnapshotRequiresOwnerTransactionBeforeRepositoryReads() { .hasMessageContaining("active owner transaction"); verifyNoInteractions(joinOperationRepository, accountRepository, freshAssociationRepository); } + + @Test + void canonicalRuntimeSnapshotRequiresOwnerTransactionBeforeIdentityReads() { + AccountJoinOperationRepository joinOperationRepository = + mock(AccountJoinOperationRepository.class); + AccountRepository accountRepository = mock(AccountRepository.class); + AccountTenantIdentityResolver tenantIdentityResolver = + mock(AccountTenantIdentityResolver.class); + FreshTenantIdentityAssociationRepository freshAssociationRepository = + mock(FreshTenantIdentityAssociationRepository.class); + AccountMembershipAuthorityEventProducer producer = + new AccountMembershipAuthorityEventProducer( + joinOperationRepository, + mock(AccountMembershipPairAuthorityRepository.class), + accountRepository, + tenantIdentityResolver, + freshAssociationRepository, + mock(AccountAuthorityGenerationRepository.class), + mock(AccountAuthorityOutboxRepository.class), + mock(AccountMembershipTransitionReceiptRepository.class), + mock(AccountTenantMembershipRepository.class), + mock(AccountTenantMembershipRoleSnapshotRepository.class)); + + assertThatThrownBy( + () -> producer.readRuntimeMembershipSnapshot(UUID.randomUUID(), UUID.randomUUID())) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("active owner transaction"); + verifyNoInteractions( + joinOperationRepository, + accountRepository, + tenantIdentityResolver, + freshAssociationRepository); + } } diff --git a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java index e5a4b3da1d..86f0f63b82 100644 --- a/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java +++ b/services/account-service/src/test/java/unit/net/firedevops/firemud/accountservice/service/impl/AccountGrpcServiceTest.java @@ -78,7 +78,11 @@ class AccountGrpcServiceTest { private static final String REALM_ID = "4c4b57d8-e3a2-48fe-9977-e7df0fdce901"; private static final String OTHER_REALM_ID = "57c58f36-c5ea-4aa8-8ef7-91a45e407f01"; private static final String ACCOUNT_UUID = "04ef66b4-c0ad-3d5b-b3b2-0e8510e72001"; + private static final String OTHER_ACCOUNT_UUID = "04ef66b4-c0ad-3d5b-b3b2-0e8510e72003"; private static final String TENANT_UUID = "04ef66b4-c0ad-3d5b-b3b2-0e8510e72002"; + private static final String OTHER_TENANT_UUID = "04ef66b4-c0ad-3d5b-b3b2-0e8510e72004"; + private static final String PLAYABLE_NAMESPACE_UUID = "04ef66b4-c0ad-3d5b-b3b2-0e8510e72005"; + private static final String GAME_INSTANCE_UUID = "04ef66b4-c0ad-3d5b-b3b2-0e8510e72006"; private static final GrpcPeerIdentity GAME_SESSION_PEER = new GrpcPeerIdentity( "spiffe://firemud/ns/test/sa/game-session-service", @@ -104,25 +108,39 @@ private static PlayerExecutionContext validPlayerContext() { } private static PlayerExecutionContext validRuntimeMembershipContext() { + return validRuntimeMembershipContext(ACCOUNT_UUID, TENANT_UUID); + } + + private static PlayerExecutionContext validRuntimeMembershipContext( + String accountUuid, String tenantUuid) { + return validRuntimeMembershipContext( + accountUuid, tenantUuid, PLAYABLE_NAMESPACE_UUID, GAME_INSTANCE_UUID); + } + + private static PlayerExecutionContext validRuntimeMembershipContext( + String accountUuid, + String tenantUuid, + String playableNamespaceUuid, + String gameInstanceUuid) { return PlayerExecutionContext.newBuilder() - .setAccountId("10") - .setTenantId("20") + .setAccountId(accountUuid) + .setTenantId(tenantUuid) .setRealmId(REALM_ID) - .setPlayableStateNamespaceId("realm-state-30") + .setPlayableStateNamespaceId(playableNamespaceUuid) .setPlayableStateScope("SHARED") - .setGameInstanceId("40") + .setGameInstanceId(gameInstanceUuid) .setSessionId("50") .setRequestId("membership-read-1") .build(); } private static RuntimeMembershipSnapshotDto runtimeMembershipSnapshot( - long requestAccountId, + String requestAccountUuid, boolean membershipExists, List checkpoints, List sourceEvidence) { return runtimeMembershipSnapshot( - requestAccountId, + requestAccountUuid, membershipExists, checkpoints, sourceEvidence, @@ -130,14 +148,14 @@ private static RuntimeMembershipSnapshotDto runtimeMembershipSnapshot( } private static RuntimeMembershipSnapshotDto runtimeMembershipSnapshot( - long requestAccountId, + String requestAccountUuid, boolean membershipExists, List checkpoints, List sourceEvidence, MembershipEvent sourceEvent) { return new RuntimeMembershipSnapshotDto( - requestAccountId, - 20L, + requestAccountUuid, + TENANT_UUID, ACCOUNT_UUID, TENANT_UUID, membershipExists, @@ -1800,7 +1818,10 @@ public void onCompleted() {} void encodeRuntimeMembershipCandidateEncodesCompleteActivePositiveSnapshot() { RuntimeMembershipSnapshotDto snapshot = runtimeMembershipSnapshot( - 10L, true, runtimeMembershipCheckpoints("1"), runtimeMembershipSourceEvidence()); + ACCOUNT_UUID, + true, + runtimeMembershipCheckpoints("1"), + runtimeMembershipSourceEvidence()); GetTenantMembershipForRuntimeResponse response = AccountGrpcService.encodeRuntimeMembershipCandidate( @@ -1808,8 +1829,8 @@ void encodeRuntimeMembershipCandidateEncodesCompleteActivePositiveSnapshot() { assertEquals(ACCOUNT_UUID, response.getAccountId()); assertEquals(TENANT_UUID, response.getTenantId()); - assertEquals("10", response.getRequestAccountId()); - assertEquals("20", response.getRequestTenantId()); + assertEquals(ACCOUNT_UUID, response.getRequestAccountId()); + assertEquals(TENANT_UUID, response.getRequestTenantId()); assertEquals("membership-read-1", response.getRequestId()); assertTrue(response.getMembershipExists()); assertTrue(response.getGameplayAdmissionAllowed()); @@ -1833,7 +1854,8 @@ void encodeRuntimeMembershipCandidateEncodesCompleteActivePositiveSnapshot() { @Test void encodeRuntimeMembershipCandidateEncodesNeverJoinedSequenceZeroSnapshot() { RuntimeMembershipSnapshotDto snapshot = - runtimeMembershipSnapshot(10L, false, runtimeMembershipCheckpoints("0"), List.of()); + runtimeMembershipSnapshot( + ACCOUNT_UUID, false, runtimeMembershipCheckpoints("0"), List.of()); GetTenantMembershipForRuntimeResponse response = AccountGrpcService.encodeRuntimeMembershipCandidate( @@ -1858,13 +1880,87 @@ void encodeRuntimeMembershipCandidateEncodesNeverJoinedSequenceZeroSnapshot() { void encodeRuntimeMembershipCandidateRejectsWrongCallerTarget() { RuntimeMembershipSnapshotDto snapshot = runtimeMembershipSnapshot( - 11L, true, runtimeMembershipCheckpoints("1"), runtimeMembershipSourceEvidence()); + ACCOUNT_UUID, + true, + runtimeMembershipCheckpoints("1"), + runtimeMembershipSourceEvidence()); + + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext(OTHER_ACCOUNT_UUID, TENANT_UUID), snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext(ACCOUNT_UUID, OTHER_TENANT_UUID), snapshot)); + } + + @Test + void encodeRuntimeMembershipCandidateRejectsNumericAndNoncanonicalUuidInputs() { + RuntimeMembershipSnapshotDto snapshot = + runtimeMembershipSnapshot( + ACCOUNT_UUID, + true, + runtimeMembershipCheckpoints("1"), + runtimeMembershipSourceEvidence()); assertThrows( IllegalArgumentException.class, () -> AccountGrpcService.encodeRuntimeMembershipCandidate( - validRuntimeMembershipContext(), snapshot)); + validRuntimeMembershipContext("10", TENANT_UUID), snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext("00000000-0000-0000-0000-000000000000", TENANT_UUID), + snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext(ACCOUNT_UUID.toUpperCase(), TENANT_UUID), snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext(ACCOUNT_UUID, "20"), snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext( + ACCOUNT_UUID, TENANT_UUID, "realm-state-30", GAME_INSTANCE_UUID), + snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext( + ACCOUNT_UUID, TENANT_UUID, PLAYABLE_NAMESPACE_UUID, "40"), + snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext( + ACCOUNT_UUID, + TENANT_UUID, + PLAYABLE_NAMESPACE_UUID.toUpperCase(), + GAME_INSTANCE_UUID), + snapshot)); + assertThrows( + IllegalArgumentException.class, + () -> + AccountGrpcService.encodeRuntimeMembershipCandidate( + validRuntimeMembershipContext( + ACCOUNT_UUID, + TENANT_UUID, + PLAYABLE_NAMESPACE_UUID, + GAME_INSTANCE_UUID.toUpperCase()), + snapshot)); } @Test @@ -1872,7 +1968,7 @@ void encodeRuntimeMembershipCandidateRejectsIncompleteCheckpointOrSourceEvidence List completeCheckpoints = runtimeMembershipCheckpoints("1"); RuntimeMembershipSnapshotDto missingCheckpoint = runtimeMembershipSnapshot( - 10L, + ACCOUNT_UUID, true, completeCheckpoints.subList(0, completeCheckpoints.size() - 1), runtimeMembershipSourceEvidence()); @@ -1883,7 +1979,7 @@ void encodeRuntimeMembershipCandidateRejectsIncompleteCheckpointOrSourceEvidence validRuntimeMembershipContext(), missingCheckpoint)); assertThrows( IllegalArgumentException.class, - () -> runtimeMembershipSnapshot(10L, true, completeCheckpoints, List.of())); + () -> runtimeMembershipSnapshot(ACCOUNT_UUID, true, completeCheckpoints, List.of())); } @Test @@ -1920,7 +2016,7 @@ void runtimeMembershipSnapshotRejectsSourceEventContentThatDiffersFromSnapshot() IllegalArgumentException.class, () -> runtimeMembershipSnapshot( - 10L, + ACCOUNT_UUID, true, runtimeMembershipCheckpoints("1"), runtimeMembershipSourceEvidence(inconsistent), diff --git a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/AccountClient.java b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/AccountClient.java index b70eb08eda..3046e16ead 100644 --- a/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/AccountClient.java +++ b/services/game-session-service/src/main/java/net/firedevops/firemud/gamesession/client/AccountClient.java @@ -4,6 +4,7 @@ import io.grpc.StatusRuntimeException; import jakarta.annotation.PostConstruct; import java.util.Objects; +import java.util.UUID; import java.util.concurrent.TimeUnit; import net.firedevops.firemud.account.AuthenticationErrorCodes; import net.firedevops.firemud.account.v1.AccountServiceGrpc; @@ -292,13 +293,16 @@ private JoinPublicProductionMembershipResponse joinError(String code, String mes public GetTenantMembershipForRuntimeResponse getTenantMembershipForRuntime( PlayerExecutionContext playerContext) { + if (playerContext == null + || !isCanonicalNonNilUuid(playerContext.getAccountId()) + || !isCanonicalNonNilUuid(playerContext.getTenantId())) { + return membershipAuthorityUnavailable(); + } if (stub() == null) { return membershipAuthorityUnavailable(); } GetTenantMembershipForRuntimeRequest request = - GetTenantMembershipForRuntimeRequest.newBuilder() - .setPlayerContext(Objects.requireNonNull(playerContext, "playerContext is required")) - .build(); + GetTenantMembershipForRuntimeRequest.newBuilder().setPlayerContext(playerContext).build(); try { return callStub().getTenantMembershipForRuntime(request); } catch (StatusRuntimeException ex) { @@ -321,6 +325,18 @@ public GetTenantMembershipForRuntimeResponse getTenantMembershipForRuntime( return membershipAuthorityUnavailable(); } + private static boolean isCanonicalNonNilUuid(String value) { + if (value == null || value.isEmpty()) { + return false; + } + try { + UUID parsed = UUID.fromString(value); + return !parsed.equals(new UUID(0L, 0L)) && parsed.toString().equals(value); + } catch (IllegalArgumentException ex) { + return false; + } + } + private GetTenantMembershipForRuntimeResponse membershipAuthorityUnavailable() { return GetTenantMembershipForRuntimeResponse.newBuilder() .setError( diff --git a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/client/AccountClientTest.java b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/client/AccountClientTest.java index c541eecf50..6ff042ab8c 100644 --- a/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/client/AccountClientTest.java +++ b/services/game-session-service/src/test/java/unit/net/firedevops/firemud/gamesession/client/AccountClientTest.java @@ -8,6 +8,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import io.grpc.ManagedChannel; @@ -41,6 +42,7 @@ import net.firedevops.firemud.shared.v1.PlayerExecutionContext; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; @@ -317,25 +319,28 @@ void emailLoginChallengeRequestHasNoTenantScopeField() throws Exception { @Test void runtimeMembershipCallerUsesCanonicalAccountTenantRequest() throws Exception { + String accountId = "9b80a81b-7971-44af-bd6b-18079027f47a"; + String tenantId = "cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1"; AccountServiceGrpc.AccountServiceBlockingStub stub = mock(AccountServiceGrpc.AccountServiceBlockingStub.class); when(stub.withDeadlineAfter(5L, TimeUnit.SECONDS)).thenReturn(stub); GetTenantMembershipForRuntimeResponse expected = GetTenantMembershipForRuntimeResponse.newBuilder() - .setAccountId("00000000-0000-0000-0000-000000000042") - .setTenantId("00000000-0000-0000-0000-000000000007") + .setAccountId(accountId) + .setTenantId(tenantId) .setMembershipExists(true) .setGameplayAdmissionAllowed(true) - .putMembershipVersion("00000000-0000-0000-0000-000000000007", "12") + .putMembershipVersion(tenantId, "12") .setMembershipAuthorityGeneration("4") - .setRequestAccountId("42") - .setRequestTenantId("7") + .setRequestAccountId(accountId) + .setRequestTenantId(tenantId) .setEvaluatedAt("2026-07-31T00:00:00Z") .build(); when(stub.getTenantMembershipForRuntime(any(GetTenantMembershipForRuntimeRequest.class))) .thenReturn(expected); AccountClient client = newClient(stub); - PlayerExecutionContext playerContext = runtimeMembershipContext("42", "7", "request-1"); + PlayerExecutionContext playerContext = + runtimeMembershipContext(accountId, tenantId, "request-1"); GetTenantMembershipForRuntimeResponse actual = client.getTenantMembershipForRuntime(playerContext); @@ -347,11 +352,58 @@ void runtimeMembershipCallerUsesCanonicalAccountTenantRequest() throws Exception assertThat(actual).isEqualTo(expected); } + @ParameterizedTest + @CsvSource({ + "42, cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "9b80a81b-7971-44af-bd6b-18079027f47a, 7", + "not-a-uuid, cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "9b80a81b-7971-44af-bd6b-18079027f47a, malformed", + "9B80A81B-7971-44AF-BD6B-18079027F47A, cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "9b80a81b-7971-44af-bd6b-18079027f47a, CC5E6D40-88C0-4F91-A6D3-A738F4F2F0A1", + "00000000-0000-0000-0000-000000000000, cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "9b80a81b-7971-44af-bd6b-18079027f47a, 00000000-0000-0000-0000-000000000000", + "'', cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "9b80a81b-7971-44af-bd6b-18079027f47a, ''" + }) + void runtimeMembershipRejectsInvalidScopeBeforeStubOrChannelUse(String accountId, String tenantId) + throws Exception { + AccountServiceGrpc.AccountServiceBlockingStub stub = + mock(AccountServiceGrpc.AccountServiceBlockingStub.class); + GrpcChannelFactory channelFactory = mock(GrpcChannelFactory.class); + AccountClient client = newClient(stub, channelFactory); + + GetTenantMembershipForRuntimeResponse response = + client.getTenantMembershipForRuntime( + runtimeMembershipContext(accountId, tenantId, "request-1")); + + assertThat(response.getError().getCode()).isEqualTo(AuthenticationErrorCodes.UNAVAILABLE); + assertThat(response.getError().getMessage()).isEqualTo("Membership authority unavailable"); + verifyNoInteractions(stub, channelFactory); + } + + @Test + void runtimeMembershipRejectsNullContextBeforeStubOrChannelUse() throws Exception { + AccountServiceGrpc.AccountServiceBlockingStub stub = + mock(AccountServiceGrpc.AccountServiceBlockingStub.class); + GrpcChannelFactory channelFactory = mock(GrpcChannelFactory.class); + AccountClient client = newClient(stub, channelFactory); + + GetTenantMembershipForRuntimeResponse response = client.getTenantMembershipForRuntime(null); + + assertThat(response.getError().getCode()).isEqualTo(AuthenticationErrorCodes.UNAVAILABLE); + assertThat(response.getError().getMessage()).isEqualTo("Membership authority unavailable"); + verifyNoInteractions(stub, channelFactory); + } + @Test void runtimeMembershipReturnsCanonicalUnavailableWhenStubIsMissing() throws Exception { GetTenantMembershipForRuntimeResponse response = newClient(null) - .getTenantMembershipForRuntime(runtimeMembershipContext("42", "7", "request-1")); + .getTenantMembershipForRuntime( + runtimeMembershipContext( + "9b80a81b-7971-44af-bd6b-18079027f47a", + "cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "request-1")); assertThat(response.getError().getCode()).isEqualTo(AuthenticationErrorCodes.UNAVAILABLE); assertThat(response.getError().getMessage()).isEqualTo("Membership authority unavailable"); @@ -375,11 +427,11 @@ void runtimeMembershipRetriesOnceAfterUnavailableAndPreservesSuccess() throws Ex .thenThrow(new StatusRuntimeException(Status.UNAVAILABLE)); GetTenantMembershipForRuntimeResponse expected = GetTenantMembershipForRuntimeResponse.newBuilder() - .setAccountId("00000000-0000-0000-0000-000000000042") - .setTenantId("00000000-0000-0000-0000-000000000007") + .setAccountId("9b80a81b-7971-44af-bd6b-18079027f47a") + .setTenantId("cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1") .setMembershipExists(true) .setGameplayAdmissionAllowed(true) - .putMembershipVersion("00000000-0000-0000-0000-000000000007", "12") + .putMembershipVersion("cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", "12") .build(); when(fixture .retryStub() @@ -389,13 +441,26 @@ void runtimeMembershipRetriesOnceAfterUnavailableAndPreservesSuccess() throws Ex GetTenantMembershipForRuntimeResponse actual = fixture .client() - .getTenantMembershipForRuntime(runtimeMembershipContext("42", "7", "request-1")); + .getTenantMembershipForRuntime( + runtimeMembershipContext( + "9b80a81b-7971-44af-bd6b-18079027f47a", + "cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "request-1")); assertThat(actual).isEqualTo(expected); - verify(fixture.initialStub()) - .getTenantMembershipForRuntime(any(GetTenantMembershipForRuntimeRequest.class)); - verify(fixture.retryStub()) - .getTenantMembershipForRuntime(any(GetTenantMembershipForRuntimeRequest.class)); + ArgumentCaptor firstCaptor = + ArgumentCaptor.forClass(GetTenantMembershipForRuntimeRequest.class); + ArgumentCaptor retryCaptor = + ArgumentCaptor.forClass(GetTenantMembershipForRuntimeRequest.class); + verify(fixture.initialStub()).getTenantMembershipForRuntime(firstCaptor.capture()); + verify(fixture.retryStub()).getTenantMembershipForRuntime(retryCaptor.capture()); + assertThat(firstCaptor.getValue()).isEqualTo(retryCaptor.getValue()); + assertThat(firstCaptor.getValue().getPlayerContext()) + .isEqualTo( + runtimeMembershipContext( + "9b80a81b-7971-44af-bd6b-18079027f47a", + "cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "request-1")); verify(fixture.channelFactory()).buildChannel(anyString(), anyInt(), any(), anyBoolean()); } @@ -414,7 +479,11 @@ void runtimeMembershipNormalizesExhaustedUnavailableToCanonicalUnavailable() thr GetTenantMembershipForRuntimeResponse response = fixture .client() - .getTenantMembershipForRuntime(runtimeMembershipContext("42", "7", "request-1")); + .getTenantMembershipForRuntime( + runtimeMembershipContext( + "9b80a81b-7971-44af-bd6b-18079027f47a", + "cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "request-1")); assertThat(response.getError().getCode()).isEqualTo(AuthenticationErrorCodes.UNAVAILABLE); assertThat(response.getError().getMessage()).isEqualTo("Membership authority unavailable"); @@ -493,7 +562,11 @@ void runtimeMembershipNormalizesInitialInternalWithoutRetryOrChannelRebuild() th AccountClient client = newClient(stub, channelFactory); GetTenantMembershipForRuntimeResponse response = - client.getTenantMembershipForRuntime(runtimeMembershipContext("42", "7", "request-1")); + client.getTenantMembershipForRuntime( + runtimeMembershipContext( + "9b80a81b-7971-44af-bd6b-18079027f47a", + "cc5e6d40-88c0-4f91-a6d3-a738f4f2f0a1", + "request-1")); assertThat(response.getError().getCode()).isEqualTo(AuthenticationErrorCodes.UNAVAILABLE); assertThat(response.getError().getMessage()).isEqualTo("Membership authority unavailable"); From 7862a2604c9eca849e231749b54c756cc34a2465 Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:05:55 +1300 Subject: [PATCH 2/5] Document canonical membership boundary and require UUID database proof --- .github/workflows/ci.yml | 2 ++ .../microservices/account-service/runtime-and-data.md | 2 +- .../microservices/game-session-service/runtime-and-data.md | 2 ++ .../implementation-tracking/player-access-and-session.md | 2 ++ protos/account/v1/account_service.proto | 6 ++++-- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34a02f2b73..30b7cbfa66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1020,6 +1020,8 @@ jobs: --require-case 'net.firedevops.firemud.accountservice.AccountFreshUuidMembershipSnapshotIntegrationTest#freshUuidSnapshotEnrollsExactNonAdmittingBaselineAndRetriesWithoutSideEffects()' \ --require-case 'net.firedevops.firemud.accountservice.AccountFreshUuidMembershipSnapshotIntegrationTest#freshUuidSnapshotRejectsAdvancedTenantGenerationAndRollsBackBaselineWrites()' \ --require-case 'net.firedevops.firemud.accountservice.AccountFreshUuidMembershipSnapshotIntegrationTest#concurrentFreshUuidSnapshotCallsInitializeOneExactPairBaseline()' \ + --require-case 'net.firedevops.firemud.accountservice.AccountFreshUuidMembershipSnapshotIntegrationTest#canonicalRuntimeReadUsesFreshUuidAssociationWithoutInventingRetainedAlias()' \ + --require-case 'net.firedevops.firemud.accountservice.AccountFreshUuidMembershipSnapshotIntegrationTest#canonicalRuntimeReadRejectsUnmappedTenantUuidWithoutEnrollment()' \ account-service - name: 🔎 Verify Game Session PostgreSQL proof case diff --git a/design/architecture/microservices/account-service/runtime-and-data.md b/design/architecture/microservices/account-service/runtime-and-data.md index 803fa78eef..c1d2b1fbc0 100644 --- a/design/architecture/microservices/account-service/runtime-and-data.md +++ b/design/architecture/microservices/account-service/runtime-and-data.md @@ -34,7 +34,7 @@ The latest local Unit 1B source checkpoint also rejects both cached idempotent r The next unwired Account component reads an original successful V35 connect-issuance operation and its exact purpose-bound encrypted response envelope under the Account row fence. Its local successful-envelope payload is the strict UTF-8 compact Account JWT, not a reconstructed token or a second credential. It verifies the independently signed Gateway context, the exact Game Session workload identity, Account UUID provenance and approved retained tenant mapping, the stored token hash and identity, the original Account signature/profile, and complete original source/context correspondence. It rechecks the unchanged source and context deadlines after any fence wait. Its immutable result is original-source evidence only: stored authority/postcondition digest binding is not proof of current authority, registry readiness, or admission. This component is not registered as a runtime credential producer or RPC handler; fresh tenant handoff, complete Account-authenticated evidence, current-authority and registry consumption, protected key delivery, and end-to-end exchange remain separate activation gates. Focused proof status is recorded in the [player access and session tracker](../../../project-management/implementation-tracking/player-access-and-session.md). -The current `application.yml` and `application-prod.yml` no longer classify `GetTenantMembershipForRuntime` or `GetTenantEntitlementsForRuntime` as gRPC public methods. The membership request now carries typed `PlayerExecutionContext`, and Game Session sends that typed context; Account's handler still denies before producer/data access with `FAILED_PRECONDITION`. The held-back candidate producer/consumer path remains incomplete, so this typed request is not a working admission path or proof of the target membership/entitlement snapshot. The entitlement and realm-grant reads retain their local request shapes and must likewise remain denied until their exact caller/target contracts are carried and verified. +The current `application.yml` and `application-prod.yml` no longer classify `GetTenantMembershipForRuntime` or `GetTenantEntitlementsForRuntime` as gRPC public methods. The membership request carries typed `PlayerExecutionContext` with exact canonical Account/tenant UUIDs rather than private numeric row keys. Its held-back encoder validates the canonical selected target and exact identity echoes; the unwired producer resolves fresh UUIDs only through V38 evidence and retained UUIDs through the approved association and current source digest under the Account fence. Game Session rejects invalid Account/tenant UUID selectors before making the call. Account's handler still denies before producer/data access with `FAILED_PRECONDITION`: the canonical session/catalog handoff and authenticated complete producer/consumer proof remain incomplete. This typed request is not a working admission path. The entitlement and realm-grant reads retain their local request shapes and likewise remain denied until their exact caller/target contracts are carried and verified. Detailed proof and activation gates remain in the [Player Access tracker](../../../project-management/implementation-tracking/player-access-and-session.md). An unwired Account membership-snapshot reader now forms an exact one-tenant version map, a complete ordered four-stream checkpoint set, and separate positive membership source-event evidence only from a fenced local transaction. Its issuer, account, and tenant streams can presently prove sequence zero only while their durable generation and source-version baselines remain at one and no committed outbox head exists; advanced upstream history fails closed until its source-event proof is implemented. A never-joined pair's positive version/generation baseline and absence history are read under the same fence; a changed account-local issuance fence is preserved. This reader is not the gRPC response, does not authenticate the runtime caller, and does not enable the denied method or Game Session admission. diff --git a/design/architecture/microservices/game-session-service/runtime-and-data.md b/design/architecture/microservices/game-session-service/runtime-and-data.md index a6bdc412a0..e079f13ac1 100644 --- a/design/architecture/microservices/game-session-service/runtime-and-data.md +++ b/design/architecture/microservices/game-session-service/runtime-and-data.md @@ -12,6 +12,8 @@ The sections below define the target-state runtime contract. Current implementat - The shared Gateway connect-context codec now declares and verifies the complete signed-context shape and has local vectors, but first-party runtime parsing remains fail-closed. It does not admit the target context until the independent Gateway Ed25519 verification key is published, Account-to-tenant UUID mapping is available, and the real Account exchange/source-evidence path is proved. Codec and vector presence is not a live issuer/consumer handoff or gameplay-admission proof. +- The Account membership client rejects noncanonical, nil or numeric Account/tenant selectors before stub/channel use and preserves exact UUID request echoes. This is boundary validation, not Account authorization. The current numeric session/catalog carriers still lack the proved canonical UUID handoff required by the [Identifier Glossary](../../system-architecture-identifier-glossary.md#identifier-format-conventions); numeric stringification cannot satisfy that handoff. The complete signed-context parser, Account runtime RPC and credential producer remain denied; component and runtime proof are tracked in [Player Access](../../../project-management/implementation-tracking/player-access-and-session.md). + - The current effective-settings HTTP read is admitted by the service-wide `PRIVILEGED` role requirement, whose shared classifier accepts any global privileged role or any tenant-scoped `tenantAdmin`/`moderator` claim. `EffectiveSettingsController` then trusts query tenant/game selectors and session ids: it can synthesize a requested tenant scope without binding it to the caller's scoped role, or resolve a persisted session without checking that its tenant is authorized by the caller. The current controller/integration tests do not prove denial of a tenant-A caller reading tenant-B settings. - **Target effective-settings boundary:** keep this as a read-only operator surface but make authorization route-aware. Bind a tenant-scoped role to the exact target tenant and require persisted session tenant ownership/equality; allow a global `platformAdmin` branch to select a tenant only with current operator authorization, target-tenant generation, and `privileged_control`. Reject ambiguous/missing target authority, tenant/session mismatches, and unavailable owner/session evidence before invoking any resolver. The negative proof must cover scoped cross-tenant synthetic and persisted-session reads and the global branch without privileged control. - Script pin/epoch rollout remains partial: the authoritative `{scriptPatchVersion, scriptPinEpoch, controlPlaneRequestId}` owner read, CAS-backed pin transition, and instance-bound Automation admission epoch validation are live. Local instance-scoped Automation admission, duplicate replay, durable tick staging/replay, and final Game Session execution now compare the complete tuple; the live ledger is still limited to current atomic request/result rows, and bounded rollout-history readback plus complete source/target remote command identity and final-effect fencing remain gaps. See the [canonical runtime-execution owner](../../system-architecture-scripting-runtime-execution.md#normative-target-contract) and the [Game Session runtime and tick coordination tracker](../../../project-management/implementation-tracking/game-session-runtime-and-tick-coordination.md#active-gaps). diff --git a/design/project-management/implementation-tracking/player-access-and-session.md b/design/project-management/implementation-tracking/player-access-and-session.md index 9adc3d912b..4d42a00b7c 100644 --- a/design/project-management/implementation-tracking/player-access-and-session.md +++ b/design/project-management/implementation-tracking/player-access-and-session.md @@ -6,6 +6,8 @@ This is a non-normative implementation tracker for player access and session. Ca ## Current Status +The next unactivated canonical membership-request slice carries exact non-nil Account/tenant UUIDs through the snapshot DTO and response echoes. Account resolves retained UUIDs through the approved reverse association and current source digest, fresh UUIDs only through immutable V38 evidence, then performs owner-fenced readback; private numeric keys never appear as request identities. Game Session rejects invalid/numeric selectors before any stub/channel interaction. Final composed Account/Game Session full checks and both JARs passed after normal parent fixture propagation (154 tasks, 93 executed/61 up-to-date), with formatting, static checks and documentation clean: 441 Account unit cases executed; Game Session's 1,722 unit cases had 1,705 executed and 17 skipped, plus 18 integration and one cross-service case executed. All 125 Account PostgreSQL, 111 Game Session integration and 33 Game Session cross-service cases skipped without Docker. Actionlint and all 23 CI-scope contracts passed. No PostgreSQL or authenticated handoff success is claimed. Canonical session/catalog identity propagation, positive fresh membership, advanced/INACTIVE event proof, complete current authority and credential/registry composition remain required. The membership RPC, signed-context parser and credential paths remain denied and the ring mount unpublished. + PR #2917's snapshot failure-injection fixture now stubs the underlying Mockito target instead of entering the Spring transaction proxy during setup. The actual producer call still traverses that original proxy inside its owner transaction and executes the real mutation before the injected failure; neither `MANDATORY` propagation nor the explicit repository guard is weakened. The correction's local Account full check/JAR, formatting and static analysis passed, with unchanged 426 unit results up-to-date and all 123 PostgreSQL cases skipped without Docker. Documentation validation is rerun after the final status edit. Corrected runtime execution of both failed cases remains required; the failed exact-head CI below is incident evidence, not replaced by local skips. Exact #2915 head `910d0a6f41d60ee7214b610d56f89c51db260413` [CI 36796087279](https://github.com/benhook1013/FireMUD/actions/runs/36796087279) executed and passed all six Account fresh-association and seven Game Design creation PostgreSQL cases with zero skips, failures or errors; every strictly required retry/concurrency/rollback case executed once. These counts come from the strict JUnit XML-verifier logs, not JaCoCo; retained artifacts contain HTML but not raw JUnit XML. Account, Game Design and shared-core unit tasks ran with build/configuration caches disabled. Account's check and JAR passed; Game Design's check failed on the unchanged Entity baseline-migration fixture already routed to #2872 and its hosted JAR step skipped. Automation formatting, shared Ruff and the dev-demo summary validator also keep aggregate CI red. This supersedes the earlier failed creation-fixture proof below, not its incident evidence. Database component proof does not establish live mTLS/SPIFFE, certificate rotation, fresh-image boot, a deployed cross-owner handoff or activation. diff --git a/protos/account/v1/account_service.proto b/protos/account/v1/account_service.proto index 1439b9b939..c4976178fa 100644 --- a/protos/account/v1/account_service.proto +++ b/protos/account/v1/account_service.proto @@ -139,6 +139,8 @@ message VerifyEmailLoginOtpRequest { message GetTenantMembershipForRuntimeRequest { reserved 1, 2, 3; reserved "account_id", "tenant_id", "request_id"; + // account_id and tenant_id are exact canonical UUIDs, never private numeric row keys. + // The complete selected target is checked separately; this unsigned context is not authority. shared.v1.PlayerExecutionContext player_context = 4; } @@ -158,8 +160,8 @@ message GetTenantMembershipForRuntimeResponse { repeated RuntimeOutboxSourceEvidence outbox_source_evidence = 14; repeated string roles = 15; RuntimeMembershipBaseline membership_baseline = 17; - string request_account_id = 18; - string request_tenant_id = 19; + string request_account_id = 18; // Exact canonical UUID echo of player_context.account_id. + string request_tenant_id = 19; // Exact canonical UUID echo of player_context.tenant_id. string request_id = 20; } From 68358f7d227651e36826b97a38a7db70b2f6e4d1 Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:07:51 +1300 Subject: [PATCH 3/5] Index published Unit 1B recovery and UUID request prerequisites --- design/project-management/design-alignment/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/design/project-management/design-alignment/README.md b/design/project-management/design-alignment/README.md index e18ec8ac43..534373ed8d 100644 --- a/design/project-management/design-alignment/README.md +++ b/design/project-management/design-alignment/README.md @@ -29,7 +29,7 @@ The preserved 5B implementation work was rebuilt into #2826 Schema, the dependen | Section | Original scope | Status | Main PR | Evidence / routed work | | --- | --- | --- | --- | --- | | 1A | Identity, entitlement, and hosted terms | Provisional; earlier broad discovery closed by judgment, required implementation and proof open | [#2840](https://github.com/benhook1013/FireMUD/pull/2840) | The refreshed 29-source unit had no taper finding; #2846–#2848 are stacked correction drafts, not merge or activation proof. #2848 contains Account gRPC/provider fail-closed boundaries, atomic recovery-token claims, disabled deletion/legacy export, and bounded evidence-only JOIN reconciliation. The [Player Access tracker](../implementation-tracking/player-access-and-session.md#unit-1a-section-exit-dispositions) names each current correction, pre-v1 Account successor, Unit 1B consumer, and activation gate. PostgreSQL concurrency/lost-acknowledgement, composed cross-service/certificate CI, direct text-to-Logging delivery, retained-data disposition, and billing/hosted-terms authority remain open; locally skipped tests do not close them. | -| 1B | Admission, session continuity, and reconnect | Provisional; required producer/consumer implementation and proof open | [#2857](https://github.com/benhook1013/FireMUD/pull/2857), [#2861](https://github.com/benhook1013/FireMUD/pull/2861), [#2873](https://github.com/benhook1013/FireMUD/pull/2873) → [#2876](https://github.com/benhook1013/FireMUD/pull/2876) → [#2880](https://github.com/benhook1013/FireMUD/pull/2880) → [#2881](https://github.com/benhook1013/FireMUD/pull/2881) → [#2911](https://github.com/benhook1013/FireMUD/pull/2911) → [#2914](https://github.com/benhook1013/FireMUD/pull/2914) → [#2915](https://github.com/benhook1013/FireMUD/pull/2915) → [#2917](https://github.com/benhook1013/FireMUD/pull/2917) | Provisional; #2915's corrected creation and Account association database proof passed; #2917 adds the fresh UUID-only pair/snapshot prerequisite, with database proof pending. Complete authenticated snapshot, current authority, credential/delegation/registry, protected ring delivery, durable reconnect, and HTTPS/mail/abuse/browser gates remain open. Database component proof is not a live owner handoff or activation proof. Membership RPC and credentials stay denied; ring mount unpublished. See the [Player Access tracker](../implementation-tracking/player-access-and-session.md) for exact proof and handoffs. | +| 1B | Admission, session continuity, and reconnect | Provisional; required producer/consumer implementation and proof open | [#2857](https://github.com/benhook1013/FireMUD/pull/2857), [#2861](https://github.com/benhook1013/FireMUD/pull/2861), [#2873](https://github.com/benhook1013/FireMUD/pull/2873) → [#2876](https://github.com/benhook1013/FireMUD/pull/2876) → [#2880](https://github.com/benhook1013/FireMUD/pull/2880) → [#2881](https://github.com/benhook1013/FireMUD/pull/2881) → [#2911](https://github.com/benhook1013/FireMUD/pull/2911) → [#2914](https://github.com/benhook1013/FireMUD/pull/2914) → [#2915](https://github.com/benhook1013/FireMUD/pull/2915) → [#2917](https://github.com/benhook1013/FireMUD/pull/2917) → [#2918](https://github.com/benhook1013/FireMUD/pull/2918) → [#2919](https://github.com/benhook1013/FireMUD/pull/2919) | Provisional; #2915's corrected creation and Account association database proof passed; #2917 adds the fresh UUID pair/snapshot prerequisite, with corrected PostgreSQL execution pending after fixture repair; #2918 adds historical-context/encrypted-result framing and #2919 the canonical UUID request/producer candidate. None enables the exchange. Complete authenticated snapshot, current authority, credential/delegation/registry, protected ring delivery, durable reconnect, and HTTPS/mail/abuse/browser gates remain open. Database component proof is not a live owner handoff or activation proof. Membership RPC and credentials stay denied; ring mount unpublished. See the [Player Access tracker](../implementation-tracking/player-access-and-session.md) for exact proof and handoffs. | | 1C | Commands, output, and frontend presentation | Queued | — | — | | 1D | Social, communication, and moderation-facing UX | Queued | — | — | | 2A | Tick scheduling and region authority | Queued | — | — | From 1cb1178438ae3bdf918f4664c2d95a0253365111 Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:44:12 +1300 Subject: [PATCH 4/5] Use valid workload namespace in retained snapshot fixtures --- .../accountservice/AccountJoinPostgresIntegrationTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java index e105dfe561..208ef24400 100644 --- a/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java +++ b/services/account-service/src/test/java/integration/net/firedevops/firemud/accountservice/AccountJoinPostgresIntegrationTest.java @@ -80,9 +80,10 @@ GatewayTestProperties.FIREMUD_GRPC_CERT_CHAIN_PATH, GatewayTestProperties.FIREMUD_GRPC_PRIVATE_KEY_PATH, GatewayTestProperties.FIREMUD_GRPC_CA_CERT_PATH, - "firemud.grpc.workload-namespace=account_service" + "firemud.grpc.workload-namespace=" + AccountJoinPostgresIntegrationTest.WORKLOAD_NAMESPACE }) class AccountJoinPostgresIntegrationTest { + static final String WORKLOAD_NAMESPACE = "account-service-test"; private static final UUID REALM_ID = UUID.fromString("4c4b57d8-e3a2-48fe-9977-e7df0fdce901"); private static final String WORLD_SLUG = "join-proof-world"; private static final String REALM_SLUG = "production"; @@ -1839,7 +1840,7 @@ private ResolveLegacyAccountTenantAssociationResponse approvedTenantAssociation( .setOperationId(UUID.randomUUID().toString()) .setManifestDigest("sha256:" + "b".repeat(64)) .setManifestSignature(Base64.getEncoder().encodeToString(new byte[64])) - .setTargetNamespace("account_service") + .setTargetNamespace(WORKLOAD_NAMESPACE) .setSignerKeyId("game-design-owner-test") .setApprovedBy("owner@example.test") .setApprovalReference("unit-1b-postgres-fixture") From a65200c1e4bf9c28eb157a4e2ca34f44234e17b4 Mon Sep 17 00:00:00 2001 From: Ben Hook <5009589+benhook1013@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:51:53 +1300 Subject: [PATCH 5/5] Record composed UUID database proof and retained fixture limits --- .../implementation-tracking/player-access-and-session.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/design/project-management/implementation-tracking/player-access-and-session.md b/design/project-management/implementation-tracking/player-access-and-session.md index f29d43f0a9..db031812fe 100644 --- a/design/project-management/implementation-tracking/player-access-and-session.md +++ b/design/project-management/implementation-tracking/player-access-and-session.md @@ -6,7 +6,7 @@ This is a non-normative implementation tracker for player access and session. Ca ## Current Status -The next unactivated canonical membership-request slice carries exact non-nil Account/tenant UUIDs through the snapshot DTO and response echoes. Account resolves retained UUIDs through the approved reverse association and current source digest, fresh UUIDs only through immutable V38 evidence, then performs owner-fenced readback; private numeric keys never appear as request identities. Game Session rejects invalid/numeric selectors before any stub/channel interaction. Final composed Account/Game Session full checks and both JARs passed after normal parent fixture propagation (154 tasks, 93 executed/61 up-to-date), with formatting, static checks and documentation clean: 441 Account unit cases executed; Game Session's 1,722 unit cases had 1,705 executed and 17 skipped, plus 18 integration and one cross-service case executed. All 125 Account PostgreSQL, 111 Game Session integration and 33 Game Session cross-service cases skipped without Docker. Actionlint and all 23 CI-scope contracts passed. No PostgreSQL or authenticated handoff success is claimed. Canonical session/catalog identity propagation, positive fresh membership, advanced/INACTIVE event proof, complete current authority and credential/registry composition remain required. The membership RPC, signed-context parser and credential paths remain denied and the ring mount unpublished. +The unactivated canonical membership-request slice carries exact non-nil Account/tenant UUIDs through the snapshot DTO and response echoes. Account resolves retained UUIDs through the approved reverse association and current source digest, fresh UUIDs only through immutable V38 evidence, then performs owner-fenced readback; private numeric keys never appear as request identities. Game Session rejects invalid/numeric selectors before any stub/channel interaction. After normal propagation of #2918's historical-source correction and the retained fixture repair, composed Account/Game Session full checks, both JARs and docs passed (154 tasks, 28 executed/126 up-to-date): 444 Account unit cases executed with no skips/failures and all 129 Account PostgreSQL cases skipped without Docker. Unchanged Game Session checks were up-to-date from their earlier executed local gate (1,705 unit, 18 integration and one cross-service executed; 17 unit, 111 integration and 33 cross-service skipped). Actionlint and all 23 CI-scope contracts passed. Earlier executed database proof is separately scoped below; corrected retained-path and new historical-readback execution remain required. Canonical session/catalog identity propagation, positive fresh membership, advanced/INACTIVE event proof, complete current authority and credential/registry composition remain required. The membership RPC, signed-context parser and credential paths remain denied and the ring mount unpublished. Composed [CI 36804479170](https://github.com/benhook1013/FireMUD/actions/runs/36804479170) on #2919 `68358f7d227651e36826b97a38a7db70b2f6e4d1` supersedes the local-skip limit for the strictly attested suites: all ten fresh UUID snapshot, eight pair-authority, six fresh-association and seven Game Design creation PostgreSQL cases executed and passed without skips, including the corrected rollback fixture and both canonical UUID cases. Account's broader 129-case integration run failed five retained snapshot/JOIN cases because the test workload namespace `account_service` is not a valid DNS namespace. The fixture now uses one matching `account-service-test` workload/approval namespace while preserving the `account_service` database schema and all production guards; corrected retained execution remains required. The source-seven strict step skipped and Game Session was cancelled, so this run supplies neither source nor Script Pin/WebSocket proof. Aggregate shared failures remain separately owned. Counts come from strict verifier logs; uploaded artifacts contain HTML, not raw XML. This is database component proof, not authenticated runtime or live admission proof.