Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ The continuation may read and exactly replay the existing immutable association

Historical original-operation reconciliation is separate from that live continuation. The local, unregistered historical read returns the exact retained StartSession tuple, actual original attempt/fence, attached Account projection, immutable first selection, and existing descriptor/release association after lease or reference expiry. Its producer accepts only exact same-namespace World or Account workload callers without end-user context. The read creates no claim, renewal, redemption, reselection, pointer/audit mutation, admission authority, current-hold proof, or terminal outcome; missing, conflicting, or malformed retained evidence fails closed. The separate current STARTING association read still requires an unexpired pending lease and is not an after-expiry endpoint. Cross-owner recovery composition and deployed recovery remain open.

The separate local, unregistered `ReadOriginalStartSessionCurrentAttempt` RPC is an Account-facing reconciliation observation. It returns the exact original pending attempt only while both its database-clock owner lease and original Account reference remain unexpired; the owner claim credential never leaves the repository. Account continues to own authorization under its [operator-authorization-reference contract](../account-service/api-contracts.md#operator-authorization-references). The read does not renew the attempt or admit a player and is not registered for production use.

### gRPC Outcome Handling

Game Session follows the [canonical gRPC outcome and transport classification](../../system-architecture-grpc.md#outcome-and-transport-classification). A successfully produced command, control-plane, or read outcome uses its typed response contract; a failure that prevents producing that domain result uses canonical non-OK status with bounded structured details. Game Session preserves stable mutation request identities and reconciles ambiguous timeouts or transport failures before replaying work. Current handlers use a mixture of response-level `ErrorDetail` and transport failures, so exact per-RPC classifications and focused migration proof remain implementation gaps rather than a new service contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Focused unit tests cover immutable replay, descriptor comparison, certificate-pi

This tracker consolidates the live Game Session execution substrate by capability. The recorded boundaries describe current implementation status and bounded follow-up work.

Local Game Session producer code includes an unregistered historical original-StartSession evidence read for exact same-namespace World or Account workloads and an unregistered World-only initial-admission owner-proof read bound to the configured namespace and full hold tuple. The latter returns a point-in-time `PENDING` snapshot or a terminal result backed by a positive `COMMITTED` pointer with matching audit or a durable `ABORTED` outcome. Exact-head [Validation run 38049505627](https://github.com/benhook1013/FireMUD/actions/runs/38049505627) on `efcd23e428393e71d10eb406838cee030d283cf6` executed 2,054 unit, 234 integration, and 39 cross-service Game Session cases; all 2,327 cases passed with zero skips, failures, or errors. Its JUnit artifact includes the owner-proof and original-owner tests plus the PostgreSQL-backed owner-attempt, association, descriptor, and initial-admission fixtures. Neither endpoint is deployed; these results do not establish continuous hold protection through cross-owner commit, terminal composition, restart recovery, production activation, or playable-state closure.
Local Game Session producer code includes an unregistered historical original-StartSession evidence read for exact same-namespace World or Account workloads, an unregistered World-only initial-admission owner-proof read bound to the configured namespace and full hold tuple, and a separate source-only Account-facing current-attempt read. The latter returns the exact original pending attempt only while its owner lease and Account reference are live. Its composed Common/Game Session checks, generated SQL model, migration-version and documentation checks passed locally; PostgreSQL execution remains pending because the local database-dependent cases skipped. The RPC is not registered or deployed. The initial-admission owner-proof read returns a point-in-time `PENDING` snapshot or a terminal result backed by a positive `COMMITTED` pointer with matching audit or a durable `ABORTED` outcome. Exact-head [Validation run 38049505627](https://github.com/benhook1013/FireMUD/actions/runs/38049505627) on `efcd23e428393e71d10eb406838cee030d283cf6` executed 2,054 unit, 234 integration, and 39 cross-service Game Session cases; all 2,327 cases passed with zero skips, failures, or errors. Its JUnit artifact includes the owner-proof and original-owner tests plus the PostgreSQL-backed owner-attempt, association, descriptor, and initial-admission fixtures. Neither existing endpoint is deployed; those results do not establish continuous hold protection through cross-owner commit, terminal composition, restart recovery, production activation, or playable-state closure.

Gameplay-session context remains on the implementation-local `sessionctx:*` keys and per-instance binding identity. The target authenticated `session:game:{tenantGameplayTag}:...` family, persisted tenant-tag allocation, and namespace-qualified controller uniqueness are not implemented or end-to-end proved; the canonical tenancy and focused-isolation requirements remain in [Multi-Tenancy](../../architecture/system-architecture-multi-tenancy.md#data-separation-per-service).

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
syntax = "proto3";

package game_session.v1;

import "google/protobuf/timestamp.proto";

option java_package = "net.firedevops.firemud.gamesession.v1";
option java_multiple_files = true;

// Unregistered, observation-only read of one exact live original StartSession owner attempt.
// It exposes no claimant credential and grants no mutation, renewal, redemption, or admission authority.
service OriginalStartSessionCurrentAttemptReadService {
rpc ReadOriginalStartSessionCurrentAttempt(
ReadOriginalStartSessionCurrentAttemptRequest)
returns (ReadOriginalStartSessionCurrentAttemptResponse);
}

message ReadOriginalStartSessionCurrentAttemptRequest {
int32 schema_version = 1;
// Fresh correlation UUID for this observation; it is not a durable mutation identity.
string read_request_id = 2;
string target_namespace = 3;
bytes canonical_post_authorization_tuple = 4;
string expected_owner_attempt_id = 5;
string expected_owner_mutation_id = 6;
int64 expected_owner_fence = 7;
}

message ReadOriginalStartSessionCurrentAttemptResponse {
ReadOriginalStartSessionCurrentAttemptRequest request = 1;
string phase_state = 2;
google.protobuf.Timestamp original_lease_expires_at = 3;
bytes account_redemption_projection = 4;
// Raw lowercase SHA-256 of account_redemption_projection.
string account_redemption_projection_digest = 5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package net.firedevops.firemud.common.gamesession;

import io.grpc.ManagedChannel;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLException;
import net.firedevops.firemud.common.config.ServiceEndpointsProperties;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Request;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Result;
import net.firedevops.firemud.common.grpc.AbstractReloadingBlockingGrpcClient;
import net.firedevops.firemud.common.grpc.CommonGrpcClientProperties;
import net.firedevops.firemud.common.grpc.GrpcChannelFactory;
import net.firedevops.firemud.common.grpc.GrpcPeerIdentity;
import net.firedevops.firemud.common.grpc.GrpcServerPeerIdentityCallCredentials;
import net.firedevops.firemud.common.grpc.GrpcServerPeerIdentityClientInterceptor;
import net.firedevops.firemud.gamesession.v1.OriginalStartSessionCurrentAttemptReadServiceGrpc;
import org.springframework.transaction.support.TransactionSynchronizationManager;

/**
* Explicit file-backed mTLS client for the unregistered Account-authenticated Game Session read.
*/
public final class GrpcOriginalStartSessionCurrentAttemptClient
extends AbstractReloadingBlockingGrpcClient<
OriginalStartSessionCurrentAttemptReadServiceGrpc
.OriginalStartSessionCurrentAttemptReadServiceBlockingStub>
implements OriginalStartSessionCurrentAttemptClient {
private static final long CALL_DEADLINE_SECONDS = 5L;

private final String workloadNamespace;
private volatile boolean initialized;
private volatile boolean closed;

public GrpcOriginalStartSessionCurrentAttemptClient(
ServiceEndpointsProperties endpoints,
CommonGrpcClientProperties tlsProperties,
GrpcChannelFactory channelFactory,
String workloadNamespace) {
super(
endpoints,
requireFileBackedMtls(tlsProperties),
channelFactory,
GrpcOriginalStartSessionCurrentAttemptClient.class);
if (!GrpcPeerIdentity.isValidNamespace(workloadNamespace)) {
throw new IllegalArgumentException("Workload namespace must be one canonical DNS label");
}
this.workloadNamespace = workloadNamespace;
}

/** Initializes only when an owning caller explicitly starts this client. */
public synchronized void init() throws SSLException, IOException {
if (closed) {
throw new IllegalStateException("Current original StartSession attempt client is closed");
}
if (initialized) {
return;
}
initReloadingClient();
if (stub() == null) {
throw new IllegalStateException(
"Current original StartSession attempt client has no gRPC stub");
}
initialized = true;
}

/** Reads one bounded live-attempt observation outside all ambient SQL transaction state. */
@Override
public Result read(Request request) {
if (TransactionSynchronizationManager.isActualTransactionActive()
|| TransactionSynchronizationManager.isSynchronizationActive()) {
throw new IllegalStateException(
"Current original StartSession attempt read requires no ambient transaction or synchronization");
}
Objects.requireNonNull(request, "current original StartSession attempt request");
if (!workloadNamespace.equals(request.targetNamespace())) {
throw new IllegalArgumentException(
"Current original StartSession attempt must use the configured workload namespace");
}
var response =
requireStub()
.withDeadlineAfter(CALL_DEADLINE_SECONDS, TimeUnit.SECONDS)
.readOriginalStartSessionCurrentAttempt(
OriginalStartSessionCurrentAttemptEvidenceGrpcCodec.toRequest(request));
try {
return OriginalStartSessionCurrentAttemptEvidenceGrpcCodec.fromResponse(request, response);
} catch (IllegalArgumentException invalid) {
throw new IllegalStateException(
"Game Session returned invalid current original StartSession attempt evidence", invalid);
}
}

@Override
protected String configuredTarget(ServiceEndpointsProperties endpoints) {
return endpoints.getGameSessionService();
}

@Override
protected String defaultTarget() {
return "game-session-service:6565";
}

@Override
protected OriginalStartSessionCurrentAttemptReadServiceGrpc
.OriginalStartSessionCurrentAttemptReadServiceBlockingStub
buildStub(ManagedChannel channel) {
String expectedPeerUri =
"spiffe://firemud/ns/" + workloadNamespace + "/sa/game-session-service";
return OriginalStartSessionCurrentAttemptReadServiceGrpc.newBlockingStub(channel)
.withMaxInboundMessageSize(
OriginalStartSessionCurrentAttemptEvidenceGrpcCodec.MAX_RESPONSE_BYTES)
.withCallCredentials(new GrpcServerPeerIdentityCallCredentials(expectedPeerUri))
.withInterceptors(new GrpcServerPeerIdentityClientInterceptor(expectedPeerUri))
.withCompression("gzip");
}

@Override
public synchronized void close() throws IOException {
closed = true;
initialized = false;
super.close();
}

private OriginalStartSessionCurrentAttemptReadServiceGrpc
.OriginalStartSessionCurrentAttemptReadServiceBlockingStub
requireStub() {
var currentStub = stub();
if (closed || !initialized || currentStub == null) {
throw new IllegalStateException(
"Current original StartSession attempt client is not initialized and available");
}
return currentStub;
}

private static CommonGrpcClientProperties requireFileBackedMtls(
CommonGrpcClientProperties tlsProperties) {
if (tlsProperties == null || tlsProperties.isPlaintext()) {
throw new IllegalArgumentException(
"Current original StartSession attempt reads require workload mTLS");
}
requireReadableFile(tlsProperties.getCertChain(), "certificate chain");
requireReadableFile(tlsProperties.getPrivateKey(), "private key");
requireReadableFile(tlsProperties.getCaCert(), "CA certificate");
return tlsProperties;
}

private static void requireReadableFile(String configuredPath, String label) {
if (configuredPath == null || configuredPath.isBlank()) {
throw new IllegalArgumentException(
"Current original StartSession attempt reads require file-backed certificate, key, and CA material");
}
String pathText = configuredPath.trim();
if (pathText.startsWith("classpath:")) {
throw new IllegalArgumentException(
"Current original StartSession attempt reads require file-backed certificate, key, and CA material");
}
Path path;
try {
path = Path.of(pathText);
} catch (RuntimeException invalid) {
throw new IllegalArgumentException(
"Current original StartSession attempt " + label + " must be a readable file-backed path",
invalid);
}
if (!Files.isRegularFile(path) || !Files.isReadable(path)) {
throw new IllegalArgumentException(
"Current original StartSession attempt " + label + " must be an existing readable file");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.firedevops.firemud.common.gamesession;

import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Request;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Result;

/** Reads one exact current original Game Session attempt as a point-in-time observation. */
public interface OriginalStartSessionCurrentAttemptClient {
/**
* Returns an observation only. The result is not a transferable claim, lease renewal, or
* continuous authorization to redeem, execute, or admit.
*/
Result read(Request request);
}
Loading
Loading