Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion design/grpc-docs/grpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ for conventions on schema evolution and error handling. See each service's
- [ReconnectionSettingsOverride](#gamedesign-v1-ReconnectionSettingsOverride)
- [RepairPublishedVersionAssetsRequest](#gamedesign-v1-RepairPublishedVersionAssetsRequest)
- [RepairPublishedVersionAssetsResponse](#gamedesign-v1-RepairPublishedVersionAssetsResponse)
- [ResolveCanonicalTenantRequest](#gamedesign-v1-ResolveCanonicalTenantRequest)
- [ResolveCanonicalTenantResponse](#gamedesign-v1-ResolveCanonicalTenantResponse)
- [ResolveHelpTopicRequest](#gamedesign-v1-ResolveHelpTopicRequest)
- [ResolveHelpTopicResponse](#gamedesign-v1-ResolveHelpTopicResponse)
- [ResolveLaunchDescriptorRequest](#gamedesign-v1-ResolveLaunchDescriptorRequest)
Expand Down Expand Up @@ -1947,7 +1949,7 @@ Result of a CreateAccount call.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| tenant_id | [string](#string) | | |
| tenant_id | [string](#string) | | Canonical tenant UUID. |
| request_id | [string](#string) | | |


Expand Down Expand Up @@ -11224,6 +11226,37 @@ Complete immutable registration receipt, without another RPC's transient rea



<a name="gamedesign-v1-ResolveCanonicalTenantRequest"></a>

### ResolveCanonicalTenantRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| tenant_id | [string](#string) | | |






<a name="gamedesign-v1-ResolveCanonicalTenantResponse"></a>

### ResolveCanonicalTenantResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| canonical_tenant_id | [string](#string) | | |
| error | [shared.v1.ErrorDetail](#shared-v1-ErrorDetail) | | |






<a name="gamedesign-v1-ResolveHelpTopicRequest"></a>

### ResolveHelpTopicRequest
Expand Down Expand Up @@ -11805,6 +11838,7 @@ Standalone, unregistered exact version-state read for an already-intaken authore
| GetDesignControlPlaneDigest | [GetDesignControlPlaneDigestRequest](#gamedesign-v1-GetDesignControlPlaneDigestRequest) | [GetDesignControlPlaneDigestResponse](#gamedesign-v1-GetDesignControlPlaneDigestResponse) | |
| GetPublishedReleaseBundle | [GetPublishedReleaseBundleRequest](#gamedesign-v1-GetPublishedReleaseBundleRequest) | [GetPublishedReleaseBundleResponse](#gamedesign-v1-GetPublishedReleaseBundleResponse) | |
| GetVersionState | [GetVersionStateRequest](#gamedesign-v1-GetVersionStateRequest) | [GetVersionStateResponse](#gamedesign-v1-GetVersionStateResponse) | |
| ResolveCanonicalTenant | [ResolveCanonicalTenantRequest](#gamedesign-v1-ResolveCanonicalTenantRequest) | [ResolveCanonicalTenantResponse](#gamedesign-v1-ResolveCanonicalTenantResponse) | Canonical tenant UUID for a Game Design tenant key; Game Design owns tenant identity. |
| CompareAndSetVersionState | [CompareAndSetVersionStateRequest](#gamedesign-v1-CompareAndSetVersionStateRequest) | [CompareAndSetVersionStateResponse](#gamedesign-v1-CompareAndSetVersionStateResponse) | |
| ResolveLaunchDescriptor | [ResolveLaunchDescriptorRequest](#gamedesign-v1-ResolveLaunchDescriptorRequest) | [ResolveLaunchDescriptorResponse](#gamedesign-v1-ResolveLaunchDescriptorResponse) | |
| GetLaunchDescriptor | [GetLaunchDescriptorRequest](#gamedesign-v1-GetLaunchDescriptorRequest) | [GetLaunchDescriptorResponse](#gamedesign-v1-GetLaunchDescriptorResponse) | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Under ADR 0185 (no data carry-over before v1, proposed in #3459), Compose smoke
| Waived gate | Owed before v1 |
| --- | --- |
| Gateway `gameplayRouteReadiness` reports ready | Canonical Account connect-context production, shared replay fencing and dedicated Gateway signing keys |
| Account runtime entitlement grants a tenant UUID that has no Account tenant source (script-seeded preview tenants) | Seeded tenants created through the real Game Design to Account tenant-creation flow, giving each an Account demo or paid source |
| Direct-text PLAY runs on the existing direct LOGIN until the authenticated LOGIN, WORLDS, REALMS and JOIN receiver lands (stacked straight after UUID PLAY is green) | Deployed Account JWT signer materializer and public-JWKS API binding, protected Coordination Redis (TLS, ACL, AOF acknowledgement) and the external Coordination qualification authority, then PLAY moved onto the authenticated receiver |

### Direct-text scope and JOIN identifier cutover

Expand Down
1 change: 1 addition & 0 deletions protos/account/v1/account_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ message GetRealmAccessGrantForRuntimeResponse {
}

message GetTenantEntitlementsForRuntimeRequest {
// Canonical tenant UUID.
string tenant_id = 1;
string request_id = 2;
}
Expand Down
11 changes: 11 additions & 0 deletions protos/game-design/v1/game_design_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ service GameDesignService {
rpc GetPublishedReleaseBundle(GetPublishedReleaseBundleRequest)
returns (GetPublishedReleaseBundleResponse);
rpc GetVersionState(GetVersionStateRequest) returns (GetVersionStateResponse);
// Canonical tenant UUID for a Game Design tenant key; Game Design owns tenant identity.
rpc ResolveCanonicalTenant(ResolveCanonicalTenantRequest) returns (ResolveCanonicalTenantResponse);
rpc CompareAndSetVersionState(CompareAndSetVersionStateRequest)
returns (CompareAndSetVersionStateResponse);
rpc ResolveLaunchDescriptor(ResolveLaunchDescriptorRequest)
Expand Down Expand Up @@ -332,6 +334,15 @@ message GetPublishedReleaseBundleResponse {
shared.v1.ErrorDetail error = 2;
}

message ResolveCanonicalTenantRequest {
string tenant_id = 1;
}

message ResolveCanonicalTenantResponse {
string canonical_tenant_id = 1;
shared.v1.ErrorDetail error = 2;
}

message GetVersionStateRequest {
string tenant_id = 1;
int64 version_id = 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.firedevops.firemud.accountservice.dto;

import java.util.UUID;

public record RuntimeEntitlementsDto(
Long tenantId,
UUID tenantId,
boolean gameplayAvailable,
boolean allowPublicJoin,
long entitlementVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.firedevops.firemud.common.tenant.FreshTenantCreationEvidence;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.impl.DSL;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -57,6 +58,17 @@ public AccountTenantAuthorityEventRepository(
this.generations = Objects.requireNonNull(generations);
}

/** Whether any current tenant source row exists; it grants no entitlement authority. */
@Transactional(propagation = Propagation.MANDATORY)
public boolean hasCurrentSource(UUID tenantId) {
requireTransaction();
requireTenant(tenantId);
return dsl.fetchExists(
dsl.selectOne()
.from(DSL.table(DSL.name("account_tenant_authority_source_records")))
.where(DSL.field(DSL.name("tenant_uuid"), UUID.class).eq(tenantId)));
}

/** Data-only routing hint over the exact current source; it grants no entitlement authority. */
@Transactional(propagation = Propagation.MANDATORY)
public SourceSelection readCurrentSourceSelection(UUID tenantId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ RealmAccessGrantResult getRealmAccessGrantForRuntime(

void revokeRealmAccess(Long accountId, Long tenantId, String worldSlug, String realmSlug);

RuntimeEntitlementsDto getTenantEntitlementsForRuntime(Long tenantId, String requestId);
RuntimeEntitlementsDto getTenantEntitlementsForRuntime(UUID tenantId, String requestId);

ProfileDto getProfile(Long tenantId, Long accountId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,12 @@ public void getTenantEntitlementsForRuntime(
StreamObserver<GetTenantEntitlementsForRuntimeResponse> responseObserver) {
try {
requireRuntimeEntitlementsPeer();
long tenantId = requirePositiveRequestId(request.getTenantId(), "tenantId");
UUID tenantId = requireCanonicalUuid(request.getTenantId(), "tenantId");
String requestId = requireText(request.getRequestId(), "requestId");
var dto = accountService.getTenantEntitlementsForRuntime(tenantId, requestId);
GetTenantEntitlementsForRuntimeResponse response =
GetTenantEntitlementsForRuntimeResponse.newBuilder()
.setTenantId(String.valueOf(dto.tenantId()))
.setTenantId(dto.tenantId().toString())
.setGameplayAvailable(dto.gameplayAvailable())
.setAllowPublicJoin(dto.allowPublicJoin())
.setEntitlementVersion(dto.entitlementVersion())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
import net.firedevops.firemud.common.gamesession.CanonicalGameplayAdmissionDecisionReadGrpcCodec.PublishedRealmEvidence;
import net.firedevops.firemud.common.gamesession.CanonicalGameplayAdmissionDecisionReadGrpcCodec.RetainedTargetSelector;
import net.firedevops.firemud.common.gamesession.CanonicalGameplayAdmissionDecisionReadGrpcCodec.Target;
import net.firedevops.firemud.common.prev1.PreV1GateWaivers;
import net.firedevops.firemud.common.security.JwtAuthProperties;
import net.firedevops.firemud.common.security.JwtClaims;
import net.firedevops.firemud.common.security.JwtUtil;
Expand Down Expand Up @@ -170,6 +171,7 @@ public class AccountServiceImpl implements AccountService {
private volatile AccountCanonicalPublicRealmScopeOwner canonicalPublicRealmScopeOwner;
private volatile CanonicalScopeConsumers canonicalScopeConsumers;
private volatile AccountBootstrapRosterReadClient accountBootstrapRosterReadClient;
private volatile RuntimeEntitlementSources runtimeEntitlementSources;

private final AccountRepository accountRepository;
private final AccountAuthorityGenerationRepository accountAuthorityGenerationRepository;
Expand Down Expand Up @@ -475,6 +477,24 @@ public List<BootstrapWorldDto> listBootstrapWorlds(String bootstrapToken) {
return owner.listWorlds(bootstrapToken);
}

/** Canonical tenant entitlement sources for the runtime PLAY read, keyed by tenant UUID. */
@Autowired(required = false)
public void setRuntimeEntitlementSources(
AccountTenantAuthorityEventRepository tenantSources,
AccountDemoTenantEntitlementRepository demos,
PreV1GateWaivers waivers) {
runtimeEntitlementSources =
new RuntimeEntitlementSources(
Objects.requireNonNull(tenantSources),
Objects.requireNonNull(demos),
Objects.requireNonNull(waivers));
}

private record RuntimeEntitlementSources(
AccountTenantAuthorityEventRepository tenantSources,
AccountDemoTenantEntitlementRepository demos,
PreV1GateWaivers waivers) {}

/**
* Explicit held composition; the owner retains the signed V2 selector before publication. Its
* direct-text entry point authenticates the existing Game Session caller separately.
Expand Down Expand Up @@ -1240,12 +1260,47 @@ private String responseAccountUuid(Account account, Long accountId) {
}
}

private RuntimeEntitlementsDto readTenantEntitlements(long tenantId, boolean lockSubscription) {
// Retained numeric rows cannot supply canonical identity, provider provenance, current-row
// selection, or a committed billing checkpoint. Deny before any historical evidence read.
throw new AuthenticationException(
"ENTITLEMENT_UNAVAILABLE",
"Canonical tenant entitlement authority is unavailable; retry later");
private RuntimeEntitlementsDto readTenantEntitlements(UUID tenantId) {
RuntimeEntitlementSources sources = runtimeEntitlementSources;
if (sources == null) {
throw new AuthenticationException(
"ENTITLEMENT_UNAVAILABLE",
"Canonical tenant entitlement authority is unavailable; retry later");
}
try {
return Objects.requireNonNull(
joinTransactionTemplate.execute(status -> readTenantEntitlements(sources, tenantId)));
} catch (AuthenticationException denied) {
throw denied;
} catch (RuntimeException failure) {
throw new AuthenticationException(
"ENTITLEMENT_UNAVAILABLE",
"Canonical tenant entitlement authority is unavailable; retry later",
failure);
}
}

private RuntimeEntitlementsDto readTenantEntitlements(
RuntimeEntitlementSources sources, UUID tenantId) {
if (sources.waivers().enabled() && !sources.tenantSources().hasCurrentSource(tenantId)) {
// Pre-v1 waiver (ADR 0185): script-seeded preview tenants have no Account tenant-creation
// source yet, so they are entitled for gameplay without one.
return new RuntimeEntitlementsDto(tenantId, true, true, 1L, 1L, Instant.now().toString());
}
SourceSelection source = sources.tenantSources().readCurrentSourceSelection(tenantId);
if (source.kind() != AccountTenantAuthorityEventRepository.SourceKind.NON_PAID_DEMO) {
// Paid hosting needs the provider observation outside SQL; it is not composed here yet.
throw new AuthenticationException(
"ENTITLEMENT_UNAVAILABLE", "Paid tenant entitlement read is unavailable; retry later");
}
var demo = sources.demos().readCurrent(tenantId);
return new RuntimeEntitlementsDto(
tenantId,
demo.gameplayAvailable(),
demo.allowPublicJoin(),
demo.entitlementVersion(),
demo.tenantBillingSequence(),
Instant.now().toString());
}

@Override
Expand Down Expand Up @@ -1350,10 +1405,9 @@ public void revokeRealmAccess(Long accountId, Long tenantId, String worldSlug, S
}

@Override
@Transactional(readOnly = true)
@Timed(value = "account.runtime_entitlements")
public RuntimeEntitlementsDto getTenantEntitlementsForRuntime(Long tenantId, String requestId) {
return readTenantEntitlements(tenantId, false);
public RuntimeEntitlementsDto getTenantEntitlementsForRuntime(UUID tenantId, String requestId) {
return readTenantEntitlements(Objects.requireNonNull(tenantId, "tenantId"));
}

private BootstrapContext requireBootstrapContext(String bootstrapToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class AccountRuntimeEntitlementNoWriteIntegrationTest {
"account_tenant_capacity_recovery_evidence");
private static final GetTenantEntitlementsForRuntimeRequest REQUEST =
GetTenantEntitlementsForRuntimeRequest.newBuilder()
.setTenantId("1")
.setTenantId("5b8d4c0e-3a1f-4f6e-9b2d-7c1e0a9f3d21")
.setRequestId("default-runtime-entitlement-no-write")
.build();

Expand Down
Loading
Loading