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 @@ -28,4 +28,18 @@ The target publication boundary treats object-store export as a durable candidat

## Local Development Notes

### Historical Entity digest baseline migration

**Current implementation status:** The one-shot Game Design maintenance Job and guarded owner-local v1→v2 baseline transition are implemented, but no retained row set or live certificate/consumer/readback outcome has been verified by this document. The Job is disabled in ordinary Helm releases and must be invoked only from a trusted operator context, using a reviewed immutable Game Design image digest. It is not a public API, a general admin role, or a PR-controlled executor. Its dedicated `game-design-baseline-migrator` Kubernetes service account has no Kubernetes API verbs, and its separate client certificate may read only Entity Management's bound `GetDraftDesignDigest` RPC. No Game Design, Account, or Game Session mutation API is delegated to that identity. The Job only writes Game Design's own baseline and audit tables through its guarded service operation; it never accesses Entity's database.

Use a controlled pre-v1 publication window for the affected Entity v1 full-version scopes. Drain in-flight publication and prevent new publication on those scopes before comparing rows or deploying the writer. Deploy the migration-capable Game Design reader/reconciler image first so retained stored v1 and v2 baseline shapes can be inspected; its publish gate still requires v2 and never compares v1 content with v2 content. Then deploy Entity's v2 producer image. Because #2872 already has a v2-only gate, deploying it alone may temporarily block affected v1 publication; this is an accepted fail-closed maintenance window, not seamless dual-reader availability. Verify actual service image digests and deployment order before proceeding; if the image topology cannot maintain that sequence, stop instead of relaxing the gate. The current Entity applied-commit token is synthetic `version:<versionId>` and does not prove durable applied-revision convergence.

Before invoking a Job, verify the exact Kubernetes context and namespace, the authorized operator identity and approved maintenance window, both current service image digests, database backup/recovery posture, completed in-flight publication drain, and the dedicated migrator certificate's issuer, `Ready` state, URI SAN, trust chain, projected Secret, and actual mTLS acceptance at Entity. The hosted trust/controller admission policy includes a narrow runtime-namespace exception for this identity; it does not make the migrator one of the controller's permanent certificate consumers. A trusted certificate writer must explicitly invoke `ensure-standalone-transport-certificates.sh --migrator <runtime-namespace>`; a separately authorized Secret-read operator then invokes `--verify-migrator <runtime-namespace>` before the Job is enabled. The certificate writer's service account has no Secret-read permission. These opt-in operations do not alter ordinary preview transport-certificate rollout. A rendered Certificate or Secret name alone is not issuance or served-identity proof. The trusted operator must create an immutable expected-source ConfigMap or Secret from a read-only exact database row, including baseline ID, tenant, `FULL_VERSION`, `ENTITY_MANAGEMENT`, null base version, version scope, applied commit, digest, schema `1`, and both workflow IDs and timestamps. Do not place this manifest, credentials, or raw retained row values in a PR or CI artifact. Check that the source object is immutable before applying the Job. The Job's `targetNamespace`, tenant/version, operation ID, actor identity, and expected-source object are all fixed for that invocation; a changed command gets a new operation ID, never a reinterpretation of the old one.

The chart's `previewStack.entityDigestBaselineMigration` values are disabled by default. From the trusted operator revision, supply an image pinned as `repository@sha256:<digest>`, exact `targetNamespace`, the dedicated `firemud-grpc-game-design-baseline-migrator` Secret, and `mode`. `enumerate` returns at most 500 Entity schema-v1 full-version rows after one baseline ID; repeat with its returned keyset cursor until an empty page proves no more rows at the quiesced snapshot. `preflight` classifies one exact tenant/version as v1, v2, absent, ambiguous, or unsupported, and refuses a missing or script-only Version. `migrate` requires one stable operation ID, exact tenant/version, actor identity, and the immutable expected-source object. The Java runner verifies its namespace, dedicated service account, and certificate URI identity before reading or writing. A missing identity, policy, input, row, version, exact-old match, or v2 Entity response fails closed. Render and inspect the operator overlay before installation; do not leave `enabled: true` in the ordinary chart values or an unattended release upgrade. Completed Jobs are deliberately not Helm hooks, so an unchanged upgrade does not rerun them; a changed immutable Job spec is rejected and needs an explicit trusted disposition.

For each affected scope, retain the preflight row ID and complete source tuple privately, run `migrate`, and require its reported operation/audit/baseline IDs and disposition. The Game Design transaction conditionally replaces the exact old row and inserts an immutable before/after audit atomically. The live row retains its original and last real publish-workflow IDs and timestamps; only the audit's operation ID and committed time describe the maintenance transition. An exact retry of the same operation reads the existing audit and baseline rather than writing again; a lost acknowledgement is resolved by that same operation identity and exact readback. A changed source, ambiguous scope, different actor/workload binding, mismatched Entity v2 schema/scope/digest/commit, or unproved write outcome is a stop condition. Independently read back `publish_recorded_participant_digest` by baseline ID and `entity_digest_baseline_migration_audit` by operation ID from Game Design's PostgreSQL schema; compare the new schema/digest/commit and preserved publish provenance, complete old tuple, observed v2 tuple, migration operation, actor/workload, outcome, and timestamp exactly. Never count Job completion alone as database proof. Keep the before/after records with the private migration log, excluding secrets and certificate keys.

If no retained Entity v1 rows exist, record the exact namespace, database/schema, query time, quiescence evidence, and an empty bounded enumeration through its terminal page; separately preflight every affected known tenant/version scope and record its state. This is a no-data boundary, not a claim that migration ran. If a migration fails or proof is incomplete, leave affected publication closed and retain the old row/audit evidence; do not restore a v1 hash over an audited v2 row or weaken the v2 publish gate. Resume only after an exact retry/readback or an explicit database recovery decision with equivalent provenance. Reopen publication only after every enumerated v1 row has a verified v2 baseline and audit (or the scoped no-data proof), the Entity v2 producer and Game Design reader remain healthy, and the normal v2 publish gate succeeds. After the approved work and readback are complete, disable the Helm migration Job and have an authorized `system:masters` operator explicitly retire its exact dedicated Certificate and Secret; the scoped writer cannot delete them. Retain the database audit and private operation evidence. Do not leave the one-shot workload identity provisioned as an ordinary Game Design credential. Live retained data, PostgreSQL readback, certificate bootstrap, served mTLS, and identity retirement proof must be reported separately from local fixtures and static Helm renders.

`TestDataSeeder` populates a demo game, template, revision and version only when explicit smoke/runtime seeding is enabled through deployment config (`FIREMUD_SMOKE_SEED_DEMO_RUNTIME_ENABLED=true` in the local Compose smoke stack). Run `services/game-design-service/smoke-test.sh` to verify both REST and gRPC endpoints. The lightweight maintained application smoke now lives under `src/test/java/integration`; the old disabled GHCR-based cross-service placeholder was removed because it did not prove a meaningful current contract.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ services as the source of truth for the current Draft template graphs:

#### Owner-to-owner digest authorization and tenant identity

`GetDraftDesignDigest` is a read-only owner-to-owner publication read across World Management, Entity Management, Game Logic, and Automation & Scripting. Every receiver uses the shared [Security Architecture](../../system-architecture-security.md) and [Authentication & Authorization](../../system-architecture-authentication.md) workload and method-allowlist rules: only the authenticated Game Design workload identity may call the publication method, and other internal workloads plus user/admin JWTs are denied. The invocation binds exact `{tenantId, scope}` (`versionId` for full publish or the complete `{baseVersionId, scriptPatchVersion}` pair for script patch), stable `publishRequestId`, derived workflow identity, and canonical `requestDigest`; missing, changed, or omitted binding evidence fails closed before a digest is returned. This context is owner-authentication and replay evidence, not an end-user role and not part of the content digest. Temporal activities never propagate the human operator JWT; operator authority ends when Game Design starts or attaches to the workflow. Each response's tenant and complete scope tuple must be exact-compared by Game Design before recording or gating the attestation; Game Design remains publication coordinator and each participant remains owner of its digest.
`GetDraftDesignDigest` is a read-only owner-to-owner publication read across World Management, Entity Management, Game Logic, and Automation & Scripting. Every receiver uses the shared [Security Architecture](../../system-architecture-security.md) and [Authentication & Authorization](../../system-architecture-authentication.md) workload and method-allowlist rules: only the authenticated Game Design workload identity may call the publication method, and other internal workloads plus user/admin JWTs are denied. The one narrow exception is the dedicated `game-design-baseline-migrator` certificate identity, which may call only Entity Management's digest-read method during the protected historical-baseline migration; it has no access to the other three publication reads or a public mutation route. The invocation binds exact `{tenantId, scope}` (`versionId` for full publish or the complete `{baseVersionId, scriptPatchVersion}` pair for script patch), stable `publishRequestId`, derived workflow identity, and canonical `requestDigest`; missing, changed, or omitted binding evidence fails closed before a digest is returned. This context is owner-authentication and replay evidence, not an end-user role and not part of the content digest. Temporal activities never propagate the human operator JWT; operator authority ends when Game Design starts or attaches to the workflow. Each response's tenant and complete scope tuple must be exact-compared by Game Design before recording or gating the attestation; Game Design remains publication coordinator and each participant remains owner of its digest.

The publication read uses its own `publicationDigestRequest/v1` SHA-256 contract, not ADR 0047's operator-mutation digest. Let `segment(bytes)` be ADR 0047's unsigned canonical ASCII byte count, `:`, then those exact bytes; let `field(name, value) = segment(utf8(name)) + segment(utf8(value))`. The preimage is `segment(utf8("publicationDigestRequest/v1"))` followed, in this fixed order, by fields `tenantId`, `scopeKind`, `versionId`, `baseVersionId`, `scriptPatchVersion`, `publishRequestId`, and `derivedWorkflowIdentity`. `scopeKind` is exactly `FULL_VERSION` or `SCRIPT_PATCH`. A full request has a canonical positive-decimal `versionId` and empty `baseVersionId`/`scriptPatchVersion`; a patch has an empty `versionId`, canonical positive-decimal `baseVersionId`, and nonempty `scriptPatchVersion`. Empty inactive fields are framed, not omitted. Text fields are nonempty Unicode NFC without malformed scalar values or surrounding whitespace, except for the explicitly empty inactive scope fields; tenant and publish-request IDs also reject `:` so the existing workflow-ID derivation cannot alias two tuples. The digest is the lowercase 64-hex-character SHA-256 of the preimage. The derived workflow identity is `publish:<tenantId>:publish-request:<publishRequestId>` for full publish and `publish-script-patch:<tenantId>:publish-request:<publishRequestId>` for script patch; receivers recompute and compare it before comparing the digest. Neither notes nor a digest of content is an input: notes belong to Game Design's separate control-plane content digest. The script-patch command must carry and retain a stable caller-supplied `publishRequestId`, rather than generating one during publication. Shared golden vectors cover both scope branches, non-ASCII and delimiter-bearing patch values, and changed/omitted-field rejection; producers and all four receivers use the same grammar rather than local string joins.

Expand Down Expand Up @@ -216,6 +216,8 @@ Rules:

### Digest Schema Migration

**Current implementation status:** Entity's digest producer and Game Design's publish gate use schema v2, while retained schema-v1 Entity full-version baselines are not automatically rewritten by an ordinary publish. A protected, one-shot Game Design maintenance operation enumerates those old baselines, obtains exact-scope v2 evidence from Entity, and conditionally replaces one complete expected-old tuple together with an immutable before/after audit in a single database transaction. It changes the digest, schema, and applied-commit evidence while retaining the live row's original and last publish-workflow provenance; the separate audit records the migration operation and time. It reports success only after exact baseline and audit readback. This reader/reconciler understands both stored baseline schemas; it never compares v1 content with v2 content for publication, and the v2-only gate remains fail closed. Deployment requires the controlled publication window and exact operator preflight in [Game Design operations](./operations.md). No live retained-row migration or no-data proof is implied by code or test fixtures. Entity's current `version:<versionId>` applied-commit token remains synthetic and does not establish an applied-revision ledger.

Digest semantics are part of the publish safety contract. Changing which rows/fields participate in a domain digest, or how they are canonicalized, requires an explicit migration plan:

1. **Introduce the new digest semantics**
Expand Down
5 changes: 5 additions & 0 deletions design/project-management/ai-observations.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,8 @@ Entry format:
- Context: a Game Session correction rejected unowned or ambiguous `PLAY` actors, while a shared Docker-backed WebSocket integration fixture still returned actor rows with protobuf-default playable scope.
- Observation: local integration tests skipped without Docker, but CI executed them and many otherwise unrelated scenarios failed at the first `PLAY` with `PLAY_IDENTITY_UNAVAILABLE`; the fixture's missing scope and bare selection obscured the intended assertions.
- Expected pattern: when actor-entry validation changes, update shared fixtures with complete tenant, account, actor, and playable-scope evidence; use explicit selection for success cases and retain a separate ambiguity-denial case. Treat compiled/skipped local tests as unproved until the composed CI cases execute.

- `2026-09-26`: One-shot certificate issuance and readback require separate proof
- Context: the Entity baseline migrator needs a short-lived dedicated client identity without giving its certificate writer general Secret-read or deletion privileges.
- Observation: a leaf verifying against the CA bundled in the same Secret is only self-consistent; it does not show that the namespace trusts that CA, and static issuance tests do not show the live Entity server accepts the identity.
- Expected pattern: keep issuance opt-in and narrowly admitted, verify the projected leaf and chain against the namespace's independent trust projection under a separately authorized reader, then report live served-mTLS acceptance and later identity retirement as distinct proof.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ AR-1.5 full-version publication now reserves its Draft version and PENDING attem

The publication proof recorded in this tracker remains limited to local gate, release-bundle, participant-digest, and transaction-unit seams. V28 now corrects V13-inferred full-version publication state without deleting retained rows: focused source-shape proof covers the exact epoch-1 marker, exact tenant/version bundle correlation, preservation of bundled and script-only rows, and idempotent epoch/timestamp quarantine, while PostgreSQL retained-row execution remains outstanding. It does not prove the end-to-end Temporal activity-to-owner path, database rollback/ambiguous-commit recovery, or live workload-certificate admission. This migration correction is separate from the still-open arbitrary `CompareAndSetVersionState` transition gap recorded below.

`AR-3.2` Entity digest-schema catch-up now has a dedicated historical-baseline migration path in the Game Design owner: bounded v1 full-version enumeration, exact tenant/version and expected-old preflight, v2 Entity recomputation, atomic guarded baseline/audit write, and exact persisted readback/retry. It is a protected one-shot Job, not ordinary publication or a public operator API. This code and its synthetic test rows do not prove that deployed retained v1 rows were migrated or that the live scoped row set is empty. The controlled readers-first publication window, dedicated migrator certificate issuance, live PostgreSQL readback, and later review remain rollout gates; Entity's `version:<versionId>` commit token still does not prove applied-revision convergence. Keep the capability partial until those boundaries have actual evidence.

Asset lifecycle status remains partial: publication and artifact services provide the current bounded release-bundle and asset-storage seams, but the destructive lifecycle operations (`TombstoneVersionAssets`, `BeginPurgeVersionAssets`, `FinalizePurgeVersionAssets`, and `RepairPublishedVersionAssets`) still lack proved durable operation handling and owner-local epoch/CAS protection. `BeginPurgeVersionAssets` currently mints a random workflow identity, and artifact and Version saves lack DB epoch predicates/affected-row proof. The canonical lifecycle and operation contract is owned by [Asset Storage](../../architecture/microservices/game-design-service/asset-storage.md#implementation-status), with [ADR 0048](../../architecture/decisions/adr-0048-durable-idempotent-operator-write-execution.md) providing provenance.

The live `CompareAndSetVersionState` path has an additional transition-safety gap: it accepts any non-null lifecycle enum after its in-memory epoch check, without requiring a committed release bundle/artifact for `DRAFT -> PUBLISHED` or enforcing active-instance/template/in-flight-activation predicates before retirement. It must not be rated as activation- or retirement-safe until the legal transition matrix, guards, and focused proof are implemented. Purge failure status is likewise not durable today: `FinalizePurgeVersionAssets` saves `PURGE_FAILED`/failed-workflow markers and rethrows inside `@Transactional`, so rollback can discard those markers after object deletion, leaving durable `PURGE_IN_PROGRESS` without reliable resume evidence. Target recovery needs an independent durable failure/reconciliation boundary (or equivalent non-rollback record) and focused deletion/post-delete-save proof.
Expand Down
Loading
Loading