Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9908dd8
Package non-activating Game Session namespace migration owner
benhook1013 Oct 8, 2026
6f038be
Fix explicit cross-service reset for canonical instance descendants
benhook1013 Oct 8, 2026
84fb811
Keep immutable launch guard enabled outside disposable fixture reset
benhook1013 Oct 8, 2026
2f7ea43
Fix migration runtime tenant fence and PostgreSQL fixture scope
benhook1013 Oct 8, 2026
cf6d919
fix(game-session): align prepared binding insert parameters
benhook1013 Oct 8, 2026
2f290fa
Fix canonical issuer reservation INSERT value alignment
benhook1013 Oct 8, 2026
51ba0a1
fix(game-session): prove inventory insert arity across all branches
benhook1013 Oct 8, 2026
c10f0b3
fix(gamesession): preserve migration and admission integrity
benhook1013 Oct 8, 2026
516cfb7
Reconcile develop and refuse unproved Redis migration topology
benhook1013 Oct 8, 2026
df81fdf
Bound JWKS refreshes and preserve unavailable verification outcomes
benhook1013 Oct 8, 2026
05ac5e0
fix: close migration driver and authority profile review gaps
benhook1013 Oct 8, 2026
0c8f124
Merge develop and retain migration-driver socket dependency
benhook1013 Oct 8, 2026
1a8eefe
Isolate migration protocol diagnostics and bind cutoff scopes
benhook1013 Oct 8, 2026
12a9f26
Fix migration inventory topology and review integrity gaps
benhook1013 Oct 8, 2026
275d66c
docs: restore player admission capability status anchors
benhook1013 Oct 8, 2026
14ec5ee
Fix typed admission timestamp and bound invalid JWKS retries
benhook1013 Oct 8, 2026
f009387
Fix migration image build permissions before non-root runtime
benhook1013 Oct 8, 2026
bcb8680
Serialize lease decisions with runtime row mutations
benhook1013 Oct 8, 2026
153113d
test(game-session): assert exact migration and runtime fences
benhook1013 Oct 8, 2026
1bef8e9
Declare migration-driver test classpath as a Gradle input
benhook1013 Oct 8, 2026
f60a1b0
fix(game-session): finish admission and migration-driver review corre…
benhook1013 Oct 8, 2026
fe15a31
Merge remote-tracking branch 'origin/develop' into codex/gameplay-gs-…
benhook1013 Oct 8, 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 @@ -10,6 +10,12 @@ Target state commits a successful exact script pin, its resulting monotonic epoc

Current script-transition observability is narrower: patch/request convergence reads, instance-scoped pause/resume, region-epoch fencing, and existing version-fence paths do not yet provide complete `scriptPinEpoch` coverage across logs, traces, and control-plane reads. See the [Game Session implementation status](./README.md#implementation-status) and [runtime and tick coordination tracker](../../../project-management/implementation-tracking/game-session-runtime-and-tick-coordination.md#active-gaps).

### Namespace controller-index migration driver

The namespace-qualified controller-index migration gate remains owned by [Session Behavior](../../system-architecture-session-behavior.md#legacy-controller-index-migration-gate). The `gameSessionMigrationDriverDist` task packages the normal Game Session jar and runtime classpath with a finite launcher; the driver does not start Spring or bind a gameplay listener. PostgreSQL access uses the co-located Unix socket, with no TCP fallback. The image source uses the Game Session service's pinned base image and a fixed unprivileged entrypoint. Each bounded observation round-trip to the trusted factory carries a fresh nonce and the cohort, fence, and storage identities; the driver checks the reply and re-reads local PostgreSQL and Redis identity and TLS state before continuing.

Source and packaging proof do not authorize execution or establish immutable final-image authority. Non-empty retained binding conversion remains unsupported by this finite source path. The [player-access tracker](../../../project-management/implementation-tracking/player-access-and-session.md#current-status) records the actual implementation and proof limits; this section is not an invocation or provisioning procedure.

### Base-provenance admission cutover

Before deploying the new Game Session admission validation, Automation must already send a positive `script_patch_base_version_id` with every instance-bound Automation script command handoff, including local enqueue and remote follow-up scheduling. Migrations V3 and V4 add the provenance columns but leave legacy pinned and gameplay-command rows with an unknown base (`NULL`); Game Session must not backfill that history from mutable runtime state. An affected active pin may be repaired only by an explicitly authorized repin through the normal `expectedCurrentPin=EXPECT_EPOCH(scriptPinEpoch)` path, after the target publication and readiness checks succeed. Do not perform an automatic or blind repin. During the cutover, monitor `STALE_TIMELINE`, `INVALID_ARGUMENT`, and `game_session_script_event_publish_skips_total{reason="missing_base"}`, keep script admission fail-closed when provenance is missing or inconsistent, and keep ordinary gameplay admission and ticks available.
Expand Down

Large diffs are not rendered by default.

190 changes: 190 additions & 0 deletions dev-tools/tests/game-session-migration-driver-image-contract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#!/usr/bin/env bash
set -euo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"

python3 - "$repo_root" <<'PY'
from pathlib import Path
import re
import sys
import zipfile


root = Path(sys.argv[1])
dockerfile = root / "k8s/game-session-migration-driver/Dockerfile"
launcher_rel = "bin/game-session-migration-driver"
launcher_path = "/opt/firemud/game-session-migration-driver/" + launcher_rel
distribution = root / "services/game-session-service/build/distributions/game-session-migration-driver"


def require(condition: bool, message: str) -> None:
if not condition:
raise SystemExit(f"FAIL: {message}")


def compare_resource_entries(expected_entries: list[tuple[str, bytes]], packaged_entries: list[tuple[str, bytes]], description: str) -> None:
def indexed(entries: list[tuple[str, bytes]], source: str) -> dict[str, bytes]:
result: dict[str, bytes] = {}
for name, content in entries:
if name in result:
raise ValueError(f"{description}: duplicate {source} entry {name}")
result[name] = content
return result

expected = indexed(expected_entries, "source")
packaged = indexed(packaged_entries, "packaged")
missing = sorted(expected.keys() - packaged.keys())
extra = sorted(packaged.keys() - expected.keys())
if missing or extra:
raise ValueError(f"{description}: resource set differs (missing={missing}, extra={extra})")
mismatched = sorted(name for name in expected if expected[name] != packaged[name])
if mismatched:
raise ValueError(f"{description}: resource bytes differ for {mismatched}")


def expect_resource_comparison_failure(expected: list[tuple[str, bytes]], packaged: list[tuple[str, bytes]], case: str) -> None:
try:
compare_resource_entries(expected, packaged, case)
except ValueError:
return
raise SystemExit(f"FAIL: synthetic {case} packaging defect was accepted")


# Keep the comparison's failure modes covered without mutating packaged artifacts.
synthetic_resource = "db/migration/V1__baseline.sql"
compare_resource_entries([(synthetic_resource, b"migration")], [(synthetic_resource, b"migration")], "synthetic matching resources")
expect_resource_comparison_failure([(synthetic_resource, b"migration")], [], "missing SQL")
expect_resource_comparison_failure([(synthetic_resource, b"migration")], [(synthetic_resource, b"changed")], "changed bytes")
expect_resource_comparison_failure(
[(synthetic_resource, b"migration")],
[(synthetic_resource, b"migration"), (synthetic_resource, b"migration")],
"duplicate jar entry",
)


docker_text = dockerfile.read_text(encoding="utf-8")
docker_lines = [line.strip() for line in docker_text.splitlines() if line.strip()]
service_dockerfile = root / "services/game-session-service/Dockerfile"
service_text = service_dockerfile.read_text(encoding="utf-8")
service_base_match = re.search(r"^ARG BASE_IMAGE=(\S+)$", service_text, re.MULTILINE)
require(service_base_match is not None, "game-session service Dockerfile must declare its BASE_IMAGE")
service_base = service_base_match.group(1)
require(re.search(r"@sha256:[0-9a-f]{64}$", service_base) is not None, "game-session service BASE_IMAGE must use a lowercase SHA-256 digest pin")
migration_base_match = re.search(r"^ARG BASE_IMAGE=(\S+)$", docker_text, re.MULTILINE)
require(migration_base_match is not None, "migration-driver Dockerfile must declare its BASE_IMAGE")
require(migration_base_match.group(1) == service_base, "migration-driver Dockerfile base image must match the game-session service pin")
require("FROM ${BASE_IMAGE}" in docker_lines, "Dockerfile must use the BASE_IMAGE argument")
require(
"COPY --chown=0:0 services/game-session-service/build/distributions/game-session-migration-driver/ "
"/opt/firemud/game-session-migration-driver/" in docker_lines,
"Dockerfile must copy the packaged distribution from the repository-root build context with root ownership",
)
permission_step_lines = [
"RUN chmod -R a+rX /opt/firemud/game-session-migration-driver \\",
"&& chmod -R a-w /opt/firemud/game-session-migration-driver \\",
"&& chmod a+x /opt/firemud/game-session-migration-driver/bin/game-session-migration-driver",
]
require(
[line for line in docker_lines if line.startswith(("RUN ", "&& "))] == permission_step_lines,
"Dockerfile must make the root-owned distribution readable/executable and non-writable before runtime",
)
require("USER 999:999" in docker_lines, "image default user must be uid/gid 999")
require(
[line for line in docker_lines if line.startswith("USER ")] == ["USER 0:0", "USER 999:999"],
"image must select root only for distribution permissions, then return to uid/gid 999",
)
require(
docker_lines.index("USER 0:0") < docker_lines.index(permission_step_lines[0])
< docker_lines.index("USER 999:999") < docker_lines.index(f'ENTRYPOINT ["{launcher_path}"]'),
"distribution permissions must run as root before the non-root runtime entrypoint",
)
require(
f'ENTRYPOINT ["{launcher_path}"]' in docker_lines,
"image entrypoint must be the fixed finite migration-driver launcher",
)
require(
not any(line.startswith(("EXPOSE ", "CMD ")) for line in docker_lines),
"image must not add a startup command, port, or second default command",
)
require(not re.search(r"\b(?:PGDATA|serviceAccount|kubeconfig|password|secret)\b", docker_text, re.IGNORECASE), "Dockerfile must not configure storage, cluster credentials, or secrets")

if not distribution.is_dir():
print("PASS: Dockerfile source contract; packaged distribution unavailable, artifact checks deferred")
raise SystemExit(0)

launcher = distribution / launcher_rel
require(launcher.is_file(), f"packaged launcher is missing: {launcher_rel}")
require(launcher.stat().st_mode & 0o111, "packaged launcher must be executable")
launcher_text = launcher.read_text(encoding="utf-8")
launcher_class = (
"net.firedevops.firemud.gamesession.repository.CanonicalGameplayMigrationDriverLauncher"
)
implementation_main_class = (
"net.firedevops.firemud.gamesession.repository.CanonicalGameplayMigrationDriverMain"
)
require(
launcher_class in launcher_text,
"packaged launcher must invoke the stdout-isolating driver launcher class",
)
for dependency in (
"flyway-core-",
"flyway-database-postgresql-",
"postgresql-",
"junixsocket-common-",
"junixsocket-native-common-",
):
require(dependency in launcher_text, f"packaged launcher classpath must include {dependency.rstrip('-')}")

libraries = distribution / "lib"
require(libraries.is_dir(), "distribution lib directory is missing")
for dependency in (
"flyway-core-",
"flyway-database-postgresql-",
"postgresql-",
"junixsocket-common-",
"junixsocket-native-common-",
"netty-transport-native-unix-common-",
):
require(any(path.name.startswith(dependency) for path in libraries.glob("*.jar")), f"distribution is missing {dependency.rstrip('-')} jar")

app_jars = list(libraries.glob("game-session-service-*-plain.jar"))
require(len(app_jars) == 1, "distribution must contain one game-session plain application jar")
game_session_migration_root = root / "services/game-session-service/src/main/resources/db/migration"
game_session_source_entries = [
(path.relative_to(game_session_migration_root.parent.parent).as_posix(), path.read_bytes())
for path in sorted(game_session_migration_root.rglob("*.sql"))
]
with zipfile.ZipFile(app_jars[0]) as app_jar:
app_entries = app_jar.namelist()
require(
launcher_class.replace(".", "/") + ".class" in app_entries,
"application jar is missing the stdout-isolating driver launcher class",
)
require(
implementation_main_class.replace(".", "/") + ".class" in app_entries,
"application jar is missing the finite migration-driver implementation class",
)
game_session_packaged_entries = [
(entry, app_jar.read(entry))
for entry in app_entries
if entry.startswith("db/migration/") and entry.endswith(".sql")
]
compare_resource_entries(game_session_source_entries, game_session_packaged_entries, "game-session migration resources")

common_saga_jars = list(libraries.glob("common-saga-*.jar"))
require(len(common_saga_jars) == 1, "distribution must contain exactly one common-saga jar")
common_saga_migration_root = root / "services/common-saga/src/main/resources/db/migration"
common_saga_source_entries = [
(path.relative_to(common_saga_migration_root.parent.parent).as_posix(), path.read_bytes())
for path in sorted(common_saga_migration_root.rglob("*.sql"))
]
with zipfile.ZipFile(common_saga_jars[0]) as common_saga_jar:
common_saga_packaged_entries = [
(entry, common_saga_jar.read(entry))
for entry in common_saga_jar.namelist()
if entry.startswith("db/migration/") and entry.endswith(".sql")
]
compare_resource_entries(common_saga_source_entries, common_saga_packaged_entries, "common-saga migration resources")

print("PASS: pinned image source contract and packaged finite-driver distribution contents")
PY
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ junit-platform = "6.1.3"
temporal = "1.40.0"
spring-grpc = "1.0.3"
postgresql = "42.7.14"
junixsocket = "2.11.1"
springdoc-openapi = "3.1.1"
stripe-java = "34.0.0"
spring-cloud-gateway = "5.0.3"
Expand Down Expand Up @@ -91,6 +92,8 @@ argon2 = { module = "de.mkammerer:argon2-jvm", version.ref = "argon2" }

grpc-spring-boot-starter = { module = "org.springframework.grpc:spring-grpc-spring-boot-starter", version.ref = "spring-grpc" }
postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" }
junixsocket-common = { module = "com.kohlschutter.junixsocket:junixsocket-common", version.ref = "junixsocket" }
junixsocket-native-common = { module = "com.kohlschutter.junixsocket:junixsocket-native-common", version.ref = "junixsocket" }
aws-sdk-s3 = { module = "software.amazon.awssdk:s3", version.ref = "aws-sdk" }
h2 = { module = "com.h2database:h2", version.ref = "h2" }

Expand Down
12 changes: 12 additions & 0 deletions k8s/game-session-migration-driver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG BASE_IMAGE=ghcr.io/benhook1013/firemud-base:latest@sha256:a7309b5c6c785ea9cf220faa672080cf386a414e458fc8a544b882a00e57f7ec
FROM ${BASE_IMAGE}

WORKDIR /opt/firemud
COPY --chown=0:0 services/game-session-service/build/distributions/game-session-migration-driver/ /opt/firemud/game-session-migration-driver/
USER 0:0
RUN chmod -R a+rX /opt/firemud/game-session-migration-driver \
&& chmod -R a-w /opt/firemud/game-session-migration-driver \
&& chmod a+x /opt/firemud/game-session-migration-driver/bin/game-session-migration-driver
Comment thread
benhook1013 marked this conversation as resolved.
Resolved

USER 999:999
ENTRYPOINT ["/opt/firemud/game-session-migration-driver/bin/game-session-migration-driver"]
Loading
Loading