Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6ac431a
feat(account): prepare canonical request-bound gameplay login owner
benhook1013 Oct 6, 2026
861bf39
Merge branch 'codex/account-tenant-authority-source-foundation' into …
benhook1013 Oct 6, 2026
16f67f9
Compose request-bound Account LOGIN facade and protected owner graph
benhook1013 Oct 6, 2026
5461497
Fix canonical LOGIN envelope generation and finite Redis client setup
benhook1013 Oct 6, 2026
8da7f25
Reconcile validated Account source-currentness parent into canonical …
benhook1013 Oct 6, 2026
0dd5312
Close canonical Account LOGIN static and focused proof gates
benhook1013 Oct 7, 2026
c02ad24
fix(account): bind canonical security events to committed owner receipts
benhook1013 Oct 7, 2026
e18a5c0
fix(account): validate Redis CA envelopes in linear time
benhook1013 Oct 7, 2026
5d34557
fix(account): align canonical delegation guards and executed CI proof
benhook1013 Oct 7, 2026
867ce77
Repair Account physical-CI transaction and retained-source fixtures
benhook1013 Oct 7, 2026
3948c59
fix(account): repair auth-evidence checkpoint SQL and physical proof …
benhook1013 Oct 7, 2026
f1039f5
Fix remaining Account PostgreSQL proof bindings and signer fixture
benhook1013 Oct 7, 2026
ff82a6a
Prove idempotent readiness cleanup and expose safe physical test stages
benhook1013 Oct 7, 2026
bcb46bb
fix(account): preserve capture locks and real fixture transactions
benhook1013 Oct 7, 2026
eeaa6ba
fix(account): remove receipt lock upgrades and repair Redis CAS fixtures
benhook1013 Oct 7, 2026
d69aca3
Merge branch 'codex/account-tenant-authority-source-foundation' into …
benhook1013 Oct 7, 2026
9bfd27a
test(account): model persistent authority projection and retained bun…
benhook1013 Oct 7, 2026
5349437
Bind Account committed issuance to its exact bundle source fence
benhook1013 Oct 7, 2026
09c012f
Resume exact pending login candidates and share issuer authority locks
benhook1013 Oct 7, 2026
781ffbe
Assert current encrypted retry and source-fence rejection guards
benhook1013 Oct 7, 2026
7985e8a
test(account): assert unsupported source event retry denial
benhook1013 Oct 7, 2026
b68e644
Qualify retained login and signer storage failure boundaries
benhook1013 Oct 31, 2026
92125cf
Merge commit '7985e8a6f6354587f5c01649ede3d0cecde9fde2' into codex/ga…
benhook1013 Oct 31, 2026
ce75256
Merge commit '91cb3e0583e44f5ff2a2c6a5f1b25d484cf76d97' into codex/ga…
benhook1013 Oct 31, 2026
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 @@ -350,6 +350,12 @@ This preparation is owned by AA-1.3 in [Capability Status](#capability-status),

The added `AccountDraftSourceCompositionService`, `AccountControlUiAuthority`, and `AccountControlUiSigningSpec` remain unregistered and transaction-bound source preparation. They do not issue a JWT, authorize receiver execution, or establish runtime currentness/readiness.

### Account retained-login and signer storage proof receiving

The receiving #3047 batch preserves current production and migration owners and restores useful proof from its retained source into four existing PostgreSQL suites. It covers exact revocation retry and immutable retained evidence, admission blocked behind revocation on independent database connections, full Account/source/outbox immutability, independent malformed signer enrollment and promotion writes, retained generation/observation/result refusal, generation-result lock retention and rollback after protected trust moves. The readiness producer case uses the complete V2 inventory: eight probes and twelve Pod receipts, competing one-shot claims, committed ISSUED readback before delivery, verified receipt readback before a controlled callback failure, sanitized errors and wiped transient bytes, operation-wide ABORTED/CLEANED retention, and refusal of redelivery, resurrection or reclaim.

R1378's initial native four-suite run passes 34 of 35 PostgreSQL cases; its aggregate remains failed because the new readiness case expected the producer's inner delivery exception rather than the mounted signer's deliberately sanitized outer exception. After correcting only that expectation and adding an explicit final verified-readback marker, the exact case passes with zero failures, errors or skips; affected enabled integration Checkstyle/SpotBugs, full Java formatting and documentation checks pass. Together these results qualify all 35 selected cases at their stated iterations, rather than claiming a fresh successful aggregate. The current stronger signer, V2 inventory and per-Pod receipt assertions remain intact. These are manually composed storage fixtures with controlled trust and transport collaborators, not live Kubernetes enrollment, real PKI/custody, protected Redis provisioning, default runtime registration, public admission or activation. The original retained source remains preserved; its obsolete schema names and held configuration paths are not restored.

### Account–Game Session JWT readiness receiver source preparation

The existing Account-owned signer/readiness preparation now has a matching unregistered Account-to-Game Session receiver source boundary. The source adds a manual, unregistered, read-only Account readiness-owner RPC adapter; Game Session rereads that exact owner evidence before and after local JWT verification, binds the observation to its protected local identity and JWKS source, and uses the existing workload mTLS identity and method guard. The receiver remains non-authorizing: it creates no authentication context, admission, application operation, or protected effect. These sources implement only the receiver seam described by accepted [ADR 0014](../../architecture/decisions/adr-0014-phased-jwt-signing-key-rotation-and-readiness.md) and [ADR 0038](../../architecture/decisions/adr-0038-explicit-jwt-profiles-and-mtls-workload-identity.md); they do not implement the pending ADR 0185 CSR enrollment, approval, issuer, or rotation proposal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -341,6 +343,35 @@ void freshAccountGenericSecurityEventsRemainNonCurrentWithExactSourceEvidence()
assertThat(rolledBackEvent).isEmpty();
Account lifecycleUpdate = accounts.findByAccountUuid(account.getAccountUuid()).orElseThrow();
lifecycleUpdate.setLifecycleState(AccountLifecycleState.SECURITY_LOCKED);
var accountBeforeLifecycleRejection =
Objects.requireNonNull(
dsl.fetchOne(
"SELECT *, xmin::TEXT AS row_version FROM accounts WHERE account_uuid = ?",
account.getAccountUuid()),
"expected Account before lifecycle rejection")
.intoMap();
var generationsBeforeLifecycleRejection =
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_generations "
+ "WHERE scope_kind = 'ACCOUNT' AND account_uuid = ?",
account.getAccountUuid())
.intoMaps();
var fencesBeforeLifecycleRejection =
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_issuance_fences WHERE account_uuid = ?",
account.getAccountUuid())
.intoMaps();
var sourceRowsBeforeLifecycleRejection =
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_source_records WHERE account_uuid = ?",
account.getAccountUuid())
.intoMaps();
var outboxRowsBeforeLifecycleRejection =
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_outbox_events WHERE outbox_stream_key = ? "
+ "ORDER BY outbox_sequence",
accountStream)
.intoMaps();
assertThatThrownBy(
() -> transaction.executeWithoutResult(status -> accounts.save(lifecycleUpdate)))
.isInstanceOf(IllegalStateException.class)
Expand All @@ -359,6 +390,44 @@ void freshAccountGenericSecurityEventsRemainNonCurrentWithExactSourceEvidence()
.isEqualTo(account.getPasswordHash());
assertThat(lifecycleUpdate.getLifecycleState())
.isEqualTo(AccountLifecycleState.SECURITY_LOCKED);
assertThat(
Objects.requireNonNull(
dsl.fetchOne(
"SELECT *, xmin::TEXT AS row_version FROM accounts WHERE account_uuid = ?",
account.getAccountUuid()),
"expected Account after lifecycle rejection")
.intoMap())
.usingRecursiveComparison()
.isEqualTo(accountBeforeLifecycleRejection);
assertThat(
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_generations "
+ "WHERE scope_kind = 'ACCOUNT' AND account_uuid = ?",
account.getAccountUuid())
.intoMaps())
.usingRecursiveComparison()
.isEqualTo(generationsBeforeLifecycleRejection);
assertThat(
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_issuance_fences WHERE account_uuid = ?",
account.getAccountUuid())
.intoMaps())
.usingRecursiveComparison()
.isEqualTo(fencesBeforeLifecycleRejection);
assertThat(
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_source_records WHERE account_uuid = ?",
account.getAccountUuid())
.intoMaps())
.usingRecursiveComparison()
.isEqualTo(sourceRowsBeforeLifecycleRejection);
assertOutboxRowsEqual(
outboxRowsBeforeLifecycleRejection,
dsl.fetch(
"SELECT *, xmin::TEXT AS row_version FROM account_authority_outbox_events WHERE outbox_stream_key = ? "
+ "ORDER BY outbox_sequence",
accountStream)
.intoMaps());
assertThat(afterLifecycleUpdate.generation()).isEqualTo(3L);
assertThat(afterLifecycleUpdate.sourceVersion()).isEqualTo(3L);
assertThat(afterLifecycleUpdate.issuanceFence().value()).isEqualTo(3L);
Expand Down Expand Up @@ -882,6 +951,26 @@ private static void await(CountDownLatch latch, String failureMessage) {
}
}

private static void assertOutboxRowsEqual(
List<Map<String, Object>> expected, List<Map<String, Object>> actual) {
assertThat(actual).hasSize(expected.size());
for (int index = 0; index < expected.size(); index++) {
Map<String, Object> expectedRow = expected.get(index);
Map<String, Object> actualRow = actual.get(index);
assertThat(actualRow.keySet()).isEqualTo(expectedRow.keySet());
for (Map.Entry<String, Object> entry : expectedRow.entrySet()) {
String field = entry.getKey();
Object expectedValue = entry.getValue();
Object actualValue = actualRow.get(field);
if ("payload".equals(field)) {
assertThat((byte[]) actualValue).containsExactly((byte[]) expectedValue);
} else {
assertThat(actualValue).isEqualTo(expectedValue);
}
}
}
}

private static void awaitLockWait(DSLContext dsl, Integer waitingPid, Integer... blockerPids)
throws InterruptedException {
if (blockerPids.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import net.firedevops.firemud.accountservice.repository.AccountGameplayDelegationResponseEnvelopeRepository.CallerIdentity;
import net.firedevops.firemud.accountservice.repository.AccountGameplayDelegationResponseEnvelopeRepository.SealedCandidateObservation;
import net.firedevops.firemud.accountservice.repository.AccountGameplayTokenIdentityFenceRepository;
import net.firedevops.firemud.accountservice.repository.AccountGameplayTokenIdentityFenceRepository.TokenRevokedException;
import net.firedevops.firemud.accountservice.repository.AccountRepository;
import net.firedevops.firemud.accountservice.repository.AccountSecurityStateOperationRepository;
import net.firedevops.firemud.accountservice.repository.AccountSecurityStateOperationRepository.Capture;
Expand Down Expand Up @@ -951,6 +952,196 @@ void realCommittedIssuanceEstablishesExactSqlFenceAndIndependentRetryReadback()
.isEqualTo(1L);
}

@Test
void durableExactRevocationIntentDeniesAdmissionAndCommitRecoveryWithoutRecreation()
throws Exception {
CommitHarness harness = newCommitHarness(CommitHook.NONE, false);
assertThat(harness.service().commitPendingCandidate(harness.pending().requestId()).outcome())
.isEqualTo(AccountGameplayDelegationIssuanceCommitService.Outcome.COMMITTED);
TokenIdentity identity = tokenFenceIdentity(harness);
AccountGameplayTokenIdentityFenceRepository fences =
new AccountGameplayTokenIdentityFenceRepository(harness.dsl());
UUID requestId = UUID.randomUUID();
String digest =
AccountGameplayTokenIdentityFenceRepository.revocationDigest(identity, requestId);

var pending =
inTransaction(
harness.context(), () -> fences.beginRevocationIntent(identity, requestId, digest));
assertThat(pending.state()).isEqualTo(State.PENDING);
assertThat(pending.tokenIdentityFence()).isEqualTo(2L);
assertThat(
inTransaction(
harness.context(), () -> fences.beginRevocationIntent(identity, requestId, digest)))
.isEqualTo(pending);
Record pendingFence =
Objects.requireNonNull(
harness
.dsl()
.fetchOne(
"SELECT * FROM account_gameplay_token_identity_fences WHERE operation_id = ?",
identity.operationId()),
"pending token identity fence must be retained");
Map<String, Object> pendingFenceImage = pendingFence.intoMap();

assertThatThrownBy(
() -> inTransaction(harness.context(), () -> fences.requireActiveForUpdate(identity)))
.isInstanceOf(TokenRevokedException.class);
assertThatThrownBy(() -> harness.issuance().readCommittedProof(identity.issuanceRequestId()))
.isInstanceOf(TokenRevokedException.class);
assertThatThrownBy(() -> harness.service().commitPendingCandidate(identity.issuanceRequestId()))
.isInstanceOf(
AccountGameplayDelegationIssuanceCommitService.IssuanceCommitUnavailableException.class)
.hasNoCause();

UUID conflictingRequest = UUID.randomUUID();
assertThatThrownBy(
() ->
inTransaction(
harness.context(),
() ->
fences.beginRevocationIntent(
identity,
conflictingRequest,
AccountGameplayTokenIdentityFenceRepository.revocationDigest(
identity, conflictingRequest))))
.isInstanceOf(
AccountGameplayTokenIdentityFenceRepository.RevocationConflictException.class);
assertThatThrownBy(
() ->
inTransaction(
harness.context(),
() ->
harness
.dsl()
.execute(
"UPDATE account_gameplay_token_identity_fences SET state = 'ACTIVE', "
+ "token_identity_fence = 1, revocation_request_id = NULL, "
+ "revocation_digest = NULL WHERE operation_id = ?",
identity.operationId())))
.isInstanceOf(DataAccessException.class);
assertThatThrownBy(
() ->
inTransaction(
harness.context(),
() ->
harness
.dsl()
.execute(
"DELETE FROM account_gameplay_token_identity_fences "
+ "WHERE operation_id = ?",
identity.operationId())))
.isInstanceOf(DataAccessException.class);

assertThat(
Objects.requireNonNull(
harness
.dsl()
.fetchOne(
"SELECT * FROM account_gameplay_token_identity_fences "
+ "WHERE operation_id = ?",
identity.operationId()),
"the exact pending token identity fence must not be deleted or recreated")
.intoMap())
.isEqualTo(pendingFenceImage);
assertThat(
inTransaction(
harness.context(), () -> fences.beginRevocationIntent(identity, requestId, digest)))
.isEqualTo(pending);
}

@Test
void racingAdmissionWaitsForAccountRevocationTransactionThenObservesPendingFence()
throws Exception {
CommitHarness harness = newCommitHarness(CommitHook.NONE, false);
harness.service().commitPendingCandidate(harness.pending().requestId());
TokenIdentity identity = tokenFenceIdentity(harness);
AccountGameplayTokenIdentityFenceRepository fences =
new AccountGameplayTokenIdentityFenceRepository(harness.dsl());
CountDownLatch pendingWritten = new CountDownLatch(1);
CountDownLatch releaseRevocation = new CountDownLatch(1);
CountDownLatch readerPidCaptured = new CountDownLatch(1);
AtomicInteger revocationPid = new AtomicInteger();
AtomicInteger readerPid = new AtomicInteger();
var executor = Executors.newFixedThreadPool(2);
try {
var revocation =
executor.submit(
() ->
inTransaction(
harness.context(),
() -> {
revocationPid.set(
Objects.requireNonNull(
harness.dsl().fetchOne("SELECT pg_backend_pid()"),
"revocation transaction must have a PostgreSQL backend")
.get(0, Integer.class));
UUID requestId = UUID.randomUUID();
var pending =
fences.beginRevocationIntent(
identity,
requestId,
AccountGameplayTokenIdentityFenceRepository.revocationDigest(
identity, requestId));
pendingWritten.countDown();
try {
if (!releaseRevocation.await(30, TimeUnit.SECONDS)) {
throw new IllegalStateException(
"Timed out waiting to release Account revocation transaction");
}
} catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
throw new IllegalStateException(
"Interrupted waiting to release Account revocation transaction",
interrupted);
}
return pending;
}));
assertThat(pendingWritten.await(10, TimeUnit.SECONDS)).isTrue();

var admission =
executor.submit(
() ->
inTransaction(
harness.context(),
() -> {
readerPid.set(
Objects.requireNonNull(
harness.dsl().fetchOne("SELECT pg_backend_pid()"),
"admission transaction must have a PostgreSQL backend")
.get(0, Integer.class));
readerPidCaptured.countDown();
return fences.requireActiveForUpdate(identity);
}));
assertThat(readerPidCaptured.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(revocationPid.get()).isPositive();
assertThat(readerPid.get()).isPositive().isNotEqualTo(revocationPid.get());
assertThat(
waitUntilBlockedBy(
harness.dsl(),
readerPid.get(),
revocationPid.get(),
TimeUnit.SECONDS.toNanos(10)))
.as("admission must block on the Account row held by the uncommitted revocation")
.isTrue();
assertThat(admission.isDone()).isFalse();
assertThat(revocation.isDone()).isFalse();

releaseRevocation.countDown();
assertThat(revocation.get(10, TimeUnit.SECONDS).state()).isEqualTo(State.PENDING);
assertThatThrownBy(() -> admission.get(10, TimeUnit.SECONDS))
.isInstanceOf(java.util.concurrent.ExecutionException.class)
.hasCauseInstanceOf(TokenRevokedException.class);
} finally {
releaseRevocation.countDown();
executor.shutdown();
if (!executor.awaitTermination(15, TimeUnit.SECONDS)) {
executor.shutdownNow();
assertThat(executor.awaitTermination(10, TimeUnit.SECONDS)).isTrue();
}
}
}

@Test
void concurrentDifferentAccountIssuerSnapshotsAndPendingIssuanceShareGlobalRows()
throws Exception {
Expand Down Expand Up @@ -2330,6 +2521,27 @@ private static void awaitLatch(CountDownLatch latch, String description) {
}
}

private static boolean waitUntilBlockedBy(
DSLContext dsl, int waitingPid, int blockingPid, long timeoutNanos)
throws InterruptedException {
long deadline = System.nanoTime() + timeoutNanos;
while (System.nanoTime() < deadline) {
Boolean blocked =
Objects.requireNonNull(
dsl.fetchOne(
"SELECT EXISTS (SELECT 1 FROM pg_stat_activity "
+ "WHERE pid = ? AND wait_event_type = 'Lock' "
+ "AND ? = ANY(pg_blocking_pids(pid)))",
waitingPid,
blockingPid),
"PostgreSQL lock-wait readback must return a row")
.get(0, Boolean.class);
if (Boolean.TRUE.equals(blocked)) return true;
Thread.sleep(10L);
}
return false;
}

private record TestContext(
TransactionTemplate transaction,
PlatformTransactionManager manager,
Expand Down
Loading
Loading