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
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ For every forwarded owner-mutation family, ADR 0048's canonical complete `postAu

For human StartSession, Account returns the complete original canonical post-authorization tuple in its authenticated ISSUE, RECOVER, and REDEEM replies, deriving it from its retained original issuance and authority capture independently of the caller. Logging and Admin compares and preserves those exact bytes through completion, recovery, and handoff. Game Session compares its incoming tuple with the independently returned Account tuple at redemption, retains that owner evidence, and compares it again at launch. This comparison includes all four authority-bundle reference fields: `bundleVersion`, `sourceVersion`, `sourceFence`, and `linearization`; `sourceFence` is distinct from `issuanceFence`. Schema and bundle-version integrity alone do not establish owner binding. The returned evidence grants no separate authority and does not replace exact workload/namespace, reference, claim, attempt/fence, currentness, or expiry checks. Existing issued bundle/reference and encrypted recovery-envelope bytes remain unchanged. Retained scalar projections lacking the complete Account tuple remain historical evidence only and fail closed for current execution; no inferred backfill upgrades them.

Within ADR 0048's `postAuthorizationExecutionTuple/v1`, production encoding of `reservationClaimFence` uses a number for positive values through `9007199254740991` and the canonical decimal string for larger values through `9223372036854775807`; each value has exactly one accepted spelling. Small-value strings, unsafe JSON numbers (including exactly `9007199254740992`), malformed strings, and values outside the signed 64-bit range fail closed for current execution. Consumers preserve all original stored bytes and do not reconstruct, upgrade, or infer a canonical value from historical JSON spelling; historical tuples with unsafe numeric fence values are not current-execution evidence. This representation rule applies only to `reservationClaimFence`: the other authority-tuple fields and independent `membershipVersion` retain their own exact source guards. It does not change the tuple version or authorize SQL changes, backfill, JWT scalar conversion, or authority-map shape changes; ADR 0048 remains the owner of the complete tuple definition.

Within `authorityEvidenceBundle/v1`, `actionFamilyRequestIdentity` is the canonical tagged representation of the applicable domain action/idempotency identity: it contains exactly one `requestIdentityKind` and its corresponding `requestId`. At typed request and durable-record boundaries, that kind selects the corresponding named action-family field rather than creating a generic substitute. For non-moderation mutations, the tag carries `controlPlaneRequestId`, which is the canonical logical request name across HTTP, Java/domain contracts, ADRs, and audit records; the current automation issuance branch is non-moderation-only and therefore uses that arm. Moderation policy intent and owner enforcement use their dedicated `policyIntentRequestId` and `ownerEnforcementRequestId` identities. For those moderation flows, `controlPlaneRequestId` remains the stable ADR 0048 orchestration/reservation/lookup identity and correlation across forwarding, but is correlation-only for domain idempotency and is not an alias or substitute for either dedicated identity. Neither identity authorizes the domain mutation: authorization comes from the Account-issued reference and the owner-side validation and fencing rules. Protobuf contracts may use the language-standard wire spelling `control_plane_request_id`, which maps directly to that same identifier and does not introduce a second identity.

For moderation, the linked records have two distinct lookup roles. The ADR 0048 orchestration/reservation/reconciliation record is located solely by the stable `controlPlaneRequestId`; its phase-appropriate tuple is then exact-compared against the stored record. After issuance, Account's domain-issuance idempotency record and the selected domain owner's mutation/result record are located by the tagged dedicated action-family identity (`policyIntentRequestId` for policy intent or `ownerEnforcementRequestId` for owner enforcement) and then validated against the complete tuple and digest. The owner never uses `controlPlaneRequestId` as its domain idempotency lookup. The same `controlPlaneRequestId` with a changed orchestration tuple conflicts with the ADR 0048 record; a different `controlPlaneRequestId` normally names a distinct orchestration attempt, but for moderation it may carry the same dedicated domain ID, which must still deduplicate or conflict according to the Account/domain record and complete domain tuple. The same tagged dedicated action-family identity with a changed domain tuple conflicts with that domain record. A correlation-only ID change cannot alias or create a second domain mutation, and neither identity grants authority.
Expand Down
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 StartSession redemption client compares the complete independently returned Account tuple before attaching redemption evidence. The retained projection is that exact canonical tuple stored once within the existing 256 KiB bound; bundle, fingerprint, and issuance identity are read from it. Current attempt, continuation, association, and launch paths verify the retained owner tuple again. Historical readers preserve original scalar-v1 projection bytes without granting current continuation; a current-use read of those older projections fails closed. [ADR 0047](../../decisions/adr-0047-logging-admin-as-external-operator-write-ingress.md) owns the binding rule. This source correction does not register or enable the operator path.

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
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import net.firedevops.firemud.accountservice.repository.AccountStartSessionWorldParticipationRepository.StoredParticipation;
import net.firedevops.firemud.common.account.startsession.StartSessionAccountRedemptionProjection;
import net.firedevops.firemud.common.authoring.DraftAuthorizationFenceBinding.SourceEvidence;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Request;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Result;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidenceGrpcCodec;
import net.firedevops.firemud.common.json.Rfc8785CanonicalJson;
import net.firedevops.firemud.common.operator.StartSessionAuthorityEvidenceBundle;
import net.firedevops.firemud.common.operator.StartSessionPostAuthorizationExecutionTuple;
import net.firedevops.firemud.gamesession.v1.ReadOriginalStartSessionCurrentAttemptResponse;
import org.jooq.DSLContext;
Expand All @@ -32,7 +30,6 @@
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import tools.jackson.databind.json.JsonMapper;

/**
* Immutable storage for the exact observation of the original live Game Session StartSession
Expand Down Expand Up @@ -69,7 +66,6 @@ public class AccountStartSessionWorldOriginalAttemptEvidenceRepository {
"original_response_digest");
private static final Set<String> SOURCE_COLUMNS =
Set.of("participation_id", "source_key", "source_evidence");
private static final JsonMapper JSON = JsonMapper.builder().build();

private final DSLContext dsl;

Expand Down Expand Up @@ -146,6 +142,12 @@ public Optional<StoredEvidence> findCurrentExact(
if (row == null) return Optional.empty();
StoredEvidence stored = decodeStoredEvidence(row, locked);
requireSameSemanticRequest(expectedRequest, stored.result().request());
try {
StartSessionAccountRedemptionProjection.requireCurrentBinding(
stored.result().accountRedemptionProjection(), expectedRequest.originalTuple());
} catch (IllegalArgumentException missingOwnerEvidence) {
throw unavailable();
}
requireLeaseCurrent(stored.originalLeaseExpiresAt());
return Optional.of(stored);
}
Expand Down Expand Up @@ -353,7 +355,8 @@ private static Result decodeResponseFromStoredBytes(
Request echoedRequest =
OriginalStartSessionCurrentAttemptEvidenceGrpcCodec.fromRequest(response.getRequest());
Result result =
OriginalStartSessionCurrentAttemptEvidenceGrpcCodec.fromResponse(echoedRequest, response);
OriginalStartSessionCurrentAttemptEvidenceGrpcCodec.fromRetainedHistoricalResponse(
echoedRequest, response);
if (!Arrays.equals(
OriginalStartSessionCurrentAttemptEvidenceGrpcCodec.toResponse(result).toByteArray(),
responseBytes)) {
Expand Down Expand Up @@ -416,28 +419,9 @@ static void requireSameSemanticRequest(Request expected, Request actual) {
private static boolean accountProjectionMatches(
StartSessionPostAuthorizationExecutionTuple tuple, byte[] projectionBytes) {
try {
StartSessionAuthorityEvidenceBundle bundle =
StartSessionAuthorityEvidenceBundle.decode(tuple.authorityEvidenceBundleBytes());
long issuanceFence = Long.parseLong(tuple.issuanceFence());
if (issuanceFence <= 0L) return false;
byte[] expected =
Rfc8785CanonicalJson.canonicalizeUtf8(
JSON.writeValueAsString(
Map.of(
"projectionSchemaId",
"accountStartSessionRedemptionProjection",
"projectionSchemaVersion",
"1",
"authorizationReferenceFingerprint",
tuple.authorizationReferenceFingerprint(),
"authorityEvidenceBundle",
bundle.jsonValue(),
"issuanceOperationId",
bundle.issuanceOperationId().toString(),
"issuanceFence",
issuanceFence)));
return Arrays.equals(expected, projectionBytes);
} catch (IOException | RuntimeException malformed) {
StartSessionAccountRedemptionProjection.requireHistoricalBinding(projectionBytes, tuple);
return true;
} catch (RuntimeException malformed) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,22 +584,7 @@ private static Request request(Fixture fixture, UUID readId) {
}

private static byte[] accountProjection(StartSessionPostAuthorizationExecutionTuple tuple) {
StartSessionAuthorityEvidenceBundle bundle =
StartSessionAuthorityEvidenceBundle.decode(tuple.authorityEvidenceBundleBytes());
return AccountControlUiAuthority.canonical(
Map.of(
"projectionSchemaId",
"accountStartSessionRedemptionProjection",
"projectionSchemaVersion",
"1",
"authorizationReferenceFingerprint",
tuple.authorizationReferenceFingerprint(),
"authorityEvidenceBundle",
bundle.jsonValue(),
"issuanceOperationId",
bundle.issuanceOperationId().toString(),
"issuanceFence",
9L));
return tuple.canonicalBytes();
}

private static Instant databaseNow(DSLContext dsl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import net.firedevops.firemud.accountservice.authordraft.AccountControlUiAuthority;
import net.firedevops.firemud.accountservice.repository.AccountStartSessionWorldOriginalAttemptEvidenceRepository.StoredEvidence;
import net.firedevops.firemud.accountservice.repository.AccountStartSessionWorldParticipationRepository.StoredParticipation;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Request;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidence.Result;
import net.firedevops.firemud.common.gamesession.OriginalStartSessionCurrentAttemptEvidenceGrpcCodec;
import net.firedevops.firemud.common.operator.StartSessionAuthorityEvidenceBundle;
import net.firedevops.firemud.common.operator.StartSessionAuthorityEvidenceBundle.BundleReference;
import net.firedevops.firemud.common.operator.StartSessionAuthorityEvidenceBundleFixture;
import net.firedevops.firemud.common.operator.StartSessionAuthorityEvidenceBundleFixture.Values;
Expand Down Expand Up @@ -292,22 +289,7 @@ private static byte[] authorityBundle(StartSessionPreAuthorizationReservationTup
}

private static byte[] accountProjection(StartSessionPostAuthorizationExecutionTuple tuple) {
StartSessionAuthorityEvidenceBundle bundle =
StartSessionAuthorityEvidenceBundle.decode(tuple.authorityEvidenceBundleBytes());
return AccountControlUiAuthority.canonical(
Map.of(
"projectionSchemaId",
"accountStartSessionRedemptionProjection",
"projectionSchemaVersion",
"1",
"authorizationReferenceFingerprint",
tuple.authorizationReferenceFingerprint(),
"authorityEvidenceBundle",
bundle.jsonValue(),
"issuanceOperationId",
bundle.issuanceOperationId().toString(),
"issuanceFence",
9L));
return tuple.canonicalBytes();
}

private static String sha256Hex(byte[] bytes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,8 @@ private static byte[] authorityBundle(StartSessionPreAuthorizationReservationTup

private static byte[] projection(
StartSessionPostAuthorizationExecutionTuple tuple, Map<String, Object> additionalFields) {
var bundle = StartSessionAuthorityEvidenceBundle.decode(tuple.authorityEvidenceBundleBytes());
Map<String, Object> projection =
Map.of(
"projectionSchemaId", "accountStartSessionRedemptionProjection",
"projectionSchemaVersion", "1",
"authorizationReferenceFingerprint", tuple.authorizationReferenceFingerprint(),
"authorityEvidenceBundle", bundle.jsonValue(),
"issuanceOperationId", bundle.issuanceOperationId().toString(),
"issuanceFence", Long.parseLong(tuple.issuanceFence()));
JSON.readValue(tuple.canonicalJson(), new tools.jackson.core.type.TypeReference<>() {});
if (additionalFields.isEmpty()) {
try {
return Rfc8785CanonicalJson.canonicalizeUtf8(JSON.writeValueAsString(projection));
Expand Down
Loading
Loading