feat(game): canonical gameId in POST /api/v1/admin/init
Engine no longer mints its own game UUID. The orchestrator (backend)
generates the game UUID at game-create time and passes it in the
admin/init request body as the required `gameId` field, so the value
that names the engine container and host bind-mount directory also
ends up inside the engine's state.json.
The engine rejects the zero UUID with 400 and any init that conflicts
with an existing state.json with 409 (a second init on the same gameId
is also a conflict; full idempotency is not part of the contract).
Updates rest.InitRequest, openapi.yaml (schema + 409 response),
controller.GenerateGame/NewGame/buildGameOnMap signatures, the engine
HTTP handler/executor, the backend runtime worker, and the relevant
unit and contract tests. Documentation in game/README.md,
docs/ARCHITECTURE.md, backend/README.md, and backend/docs/{runtime,flows}.md
is updated in the same patch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -187,11 +187,23 @@ func TestGameOpenAPISpecFreezesInitRequest(t *testing.T) {
|
||||
assertSchemaRef(t, requestSchemaRef(t, operation), "#/components/schemas/InitRequest", "init request schema")
|
||||
|
||||
schema := componentSchemaRef(t, doc, "InitRequest")
|
||||
assertRequiredFields(t, schema, "races")
|
||||
assertRequiredFields(t, schema, "gameId", "races")
|
||||
|
||||
gameIDSchema := schema.Value.Properties["gameId"]
|
||||
require.NotNil(t, gameIDSchema, "InitRequest.gameId schema must exist")
|
||||
require.True(t, gameIDSchema.Value.Type.Is("string"), "InitRequest.gameId must be string")
|
||||
require.Equal(t, "uuid", gameIDSchema.Value.Format, "InitRequest.gameId format must be uuid")
|
||||
|
||||
racesSchema := schema.Value.Properties["races"]
|
||||
require.NotNil(t, racesSchema, "InitRequest.races schema must exist")
|
||||
require.Equal(t, uint64(10), racesSchema.Value.MinItems, "InitRequest.races minItems must be 10")
|
||||
|
||||
if operation.Responses == nil {
|
||||
require.FailNow(t, "init operation is missing responses")
|
||||
}
|
||||
conflict := operation.Responses.Status(http.StatusConflict)
|
||||
require.NotNil(t, conflict, "init operation must declare 409 response")
|
||||
require.NotNil(t, conflict.Value, "init 409 response must have a value")
|
||||
}
|
||||
|
||||
func TestGameOpenAPISpecFreezesAdminOperationIDs(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user