@voltro/plugin-engine-servers 0.0.0-stage → 0.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1365 @@
1
+ import { ColumnBuilder } from '@voltro/database';
2
+ import { DataStore } from '@voltro/database';
3
+ import { EconomyService } from '@voltro/plugin-economy';
4
+ import { Effect } from 'effect';
5
+ import { FieldDefinitions } from '@voltro/database';
6
+ import { HotStoreShape } from '@voltro/kv/hot/contract';
7
+ import { InventoryService } from '@voltro/plugin-inventory';
8
+ import { LeaderboardAdministrationService } from '@voltro/plugin-leaderboards/server';
9
+ import { ProgressionService } from '@voltro/plugin-progression';
10
+ import { QuestService } from '@voltro/plugin-progression';
11
+ import { Schema } from 'effect';
12
+ import { SessionSecrets } from '@voltro/protocol/session';
13
+ import { Table } from '@voltro/database';
14
+ import { YieldableError } from 'effect/Cause';
15
+
16
+ /** `unknown` means no provider assessed the player (the port is a no-op without one). */
17
+ declare const ANTICHEAT_STATUSES: readonly ["verified", "unverified", "violation", "unknown"];
18
+
19
+ declare type AntiCheatReceipt = typeof AntiCheatReceiptSchema.Type;
20
+
21
+ declare const AntiCheatReceiptSchema: Schema.Struct<{
22
+ readonly playerId: Schema.NonEmptyString;
23
+ readonly status: Schema.Literals<readonly ["verified", "unverified", "violation", "unknown"]>;
24
+ /** False without a provider: nothing is stored. */
25
+ readonly recorded: Schema.Boolean;
26
+ /** True when a violation became a trusted Sanctions signal. */
27
+ readonly signal: Schema.Boolean;
28
+ }>;
29
+
30
+ declare type AntiCheatReportInput = typeof AntiCheatReportInputSchema.Type;
31
+
32
+ declare const AntiCheatReportInputSchema: Schema.Struct<{
33
+ readonly token: Schema.NonEmptyString;
34
+ readonly sessionId: Schema.NonEmptyString;
35
+ readonly eventId: Schema.NonEmptyString;
36
+ readonly playerId: Schema.NonEmptyString;
37
+ /** What the server-side anti-cheat SDK reported; the configured provider decides the stored status. */
38
+ readonly status: Schema.Literals<readonly ["verified", "unverified", "violation"]>;
39
+ readonly evidence: Schema.optionalKey<Schema.NonEmptyString>;
40
+ }>;
41
+
42
+ declare type AntiCheatStatus = typeof ANTICHEAT_STATUSES[number];
43
+
44
+ /**
45
+ * How long the seats of a backfill request stay bound to its key while nobody uses them. The caller
46
+ * records the seats before {@link SeatedBackfill.recordBy} (half of this). After the whole window, seats
47
+ * that are all still unused (issued, never redeemed, never reissued) belong to a caller that died between
48
+ * seating and recording: `reclaimBackfill` frees them so a repeat of the request seats again.
49
+ */
50
+ export declare const BACKFILL_RECORD_MS = 60000;
51
+
52
+ /** One seat of a backfill request. */
53
+ export declare interface BackfillSeat {
54
+ readonly subject: SeatSubject;
55
+ readonly partyId?: string | null;
56
+ readonly team?: string | null;
57
+ readonly attributes?: SeatAttributes;
58
+ }
59
+
60
+ declare type CheckpointInput = typeof CheckpointInputSchema.Type;
61
+
62
+ /**
63
+ * The latest progress of the session the server holds, for a recovery server to continue from. Opaque to the
64
+ * registry: `data` is whatever the game encodes (JSON, base64), never logged or shown. `revision` grows with every
65
+ * write; `schemaVersion` is the game's own format version, so a new build can refuse a checkpoint it cannot read.
66
+ */
67
+ declare const CheckpointInputSchema: Schema.Struct<{
68
+ readonly token: Schema.NonEmptyString;
69
+ readonly sessionId: Schema.NonEmptyString;
70
+ readonly revision: Schema.Number;
71
+ readonly schemaVersion: Schema.Number;
72
+ readonly data: Schema.String;
73
+ }>;
74
+
75
+ declare type CheckpointReceipt = typeof CheckpointReceiptSchema.Type;
76
+
77
+ declare const CheckpointReceiptSchema: Schema.Struct<{
78
+ readonly sessionId: Schema.NonEmptyString;
79
+ readonly revision: Schema.Number;
80
+ /** UTF-8 bytes stored. */
81
+ readonly bytes: Schema.Number;
82
+ /** True when this revision was already stored with the same content; nothing changed. */
83
+ readonly replay: Schema.Boolean;
84
+ }>;
85
+
86
+ /**
87
+ * Pool declarations are plain, browser-safe data: which engine builds may run,
88
+ * where, how many players one server holds and what its service identity may do.
89
+ * Authority is resolved from this declaration on every request, never signed
90
+ * into a token.
91
+ */
92
+ declare const ENGINE_KINDS: readonly ["unreal", "unity", "godot", "custom"];
93
+
94
+ declare const ENGINE_SERVER_PROTOCOLS: readonly ["udp", "tcp", "websocket", "webtransport", "quic"];
95
+
96
+ /** Every scope. Write scopes and `anticheat:report` are never granted by default. */
97
+ declare const ENGINE_SERVER_SCOPES: readonly ["servers:register", "sessions:verify", "sessions:backfill", "sessions:lifecycle", "matches:report", "writes:inventory", "writes:economy", "writes:progression", "writes:leaderboards", "writes:telemetry", "anticheat:report"];
98
+
99
+ /**
100
+ * `starting → ready → allocated → draining → gone`; `allocated → ready` on release. A server whose lease
101
+ * lapsed in a pool with a resume window is `suspended` until its own process resumes it (back to the state
102
+ * it had), a pool with `recovery` hands its session to another server (`gone`, `recovered`) or the window
103
+ * passes (`gone`, `lease_expired`).
104
+ */
105
+ declare const ENGINE_SERVER_STATES: readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"];
106
+
107
+ /** `dedicated`: servers the studio runs. `host`: a player hosts the session, so its results are untrusted. */
108
+ declare const ENGINE_SERVER_TRUST_LEVELS: readonly ["dedicated", "host"];
109
+
110
+ /** Systems an engine server may write to through `engineServers.sessions.write`. Each needs its own scope. */
111
+ declare const ENGINE_SERVER_WRITE_KINDS: readonly ["inventory", "economy", "progression", "leaderboards", "telemetry"];
112
+
113
+ declare type EngineKind = typeof ENGINE_KINDS[number];
114
+
115
+ declare type EngineServer = typeof EngineServerSchema.Type;
116
+
117
+ declare type EngineServerActivity = typeof EngineServerActivitySchema.Type;
118
+
119
+ /** "In session" for Presence: where a player plays and whether the session takes more players. */
120
+ declare const EngineServerActivitySchema: Schema.Struct<{
121
+ readonly serverId: Schema.NonEmptyString;
122
+ readonly pool: Schema.NonEmptyString;
123
+ readonly sessionId: Schema.NonEmptyString;
124
+ /** Joined and not left, as the server reported it. */
125
+ readonly connected: Schema.Boolean;
126
+ /** The session runs on an `allocated` server of a pool with `sessions:backfill` and has a free seat. */
127
+ readonly joinable: Schema.Boolean;
128
+ readonly freeSeats: Schema.Number;
129
+ }>;
130
+
131
+ /** What the provider decided for one report. `confidence` (0 to 1) goes to Sanctions with a violation. */
132
+ declare interface EngineServerAntiCheatAssessment {
133
+ readonly status: Exclude<AntiCheatStatus, 'unknown'>;
134
+ readonly confidence: number;
135
+ }
136
+
137
+ /**
138
+ * Port for a client anti-cheat vendor. Voltro ships no client anti-cheat; without a provider
139
+ * `engineServers.anticheat.report` is a no-op that stores nothing.
140
+ */
141
+ declare interface EngineServerAntiCheatProvider {
142
+ /** Stored with the status, e.g. `eac`. Lowercase letters, digits and dashes. */
143
+ readonly name: string;
144
+ readonly assess: (report: EngineServerAntiCheatReport) => Effect.Effect<EngineServerAntiCheatAssessment, unknown>;
145
+ }
146
+
147
+ declare interface EngineServerAntiCheatReport {
148
+ readonly tenantId: string;
149
+ readonly subjectId: string;
150
+ readonly serverId: string;
151
+ readonly pool: string;
152
+ readonly sessionId: string;
153
+ /** What the server-side anti-cheat SDK reported. */
154
+ readonly reported: Exclude<AntiCheatStatus, 'unknown'>;
155
+ readonly evidence: string | null;
156
+ }
157
+
158
+ /** Last anti-cheat status per player, as the configured provider assessed it. Absent without a provider. */
159
+ export declare const engineServerAntiCheatTable: Table<"_voltro_engine_server_anticheat", FieldDefinitions<{
160
+ readonly id: ColumnBuilder<string, "id", boolean>;
161
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
162
+ readonly subjectId: ColumnBuilder<string, "text", boolean>;
163
+ readonly status: ColumnBuilder<"unknown" | "unverified" | "verified" | "violation", "text", boolean>;
164
+ readonly provider: ColumnBuilder<string, "text", boolean>;
165
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
166
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
167
+ readonly updatedAt: ColumnBuilder<Date, "timestamp", boolean>;
168
+ }>, true, never>;
169
+
170
+ /**
171
+ * One row per backfill request a session took. The unique key (all columns NOT NULL, so MSSQL's
172
+ * NULL-equal uniques never apply) refuses a concurrent repeat; ticket ids only, no subject ids.
173
+ */
174
+ export declare const engineServerBackfillsTable: Table<"_voltro_engine_server_backfills", FieldDefinitions<{
175
+ readonly id: ColumnBuilder<string, "id", boolean>;
176
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
177
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
178
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
179
+ readonly requestKey: ColumnBuilder<string, "text", boolean>;
180
+ readonly ticketIds: ColumnBuilder<unknown, "json", boolean>;
181
+ readonly createdAt: ColumnBuilder<Date, "timestamp", boolean>;
182
+ }>, true, never>;
183
+
184
+ /** What a bootstrap source proves about a presented credential: which tenant's pool it may join. */
185
+ declare interface EngineServerBootstrapGrant {
186
+ readonly tenantId: string;
187
+ }
188
+
189
+ /**
190
+ * Port: turns a bootstrap credential an engine server presents into a pool grant.
191
+ * `null` means "not a credential of this pool" (callers receive `unauthenticated`).
192
+ * A managed platform supplies its own source; `staticBootstrapSource` reads a project secret.
193
+ */
194
+ declare interface EngineServerBootstrapSource {
195
+ readonly name: string;
196
+ readonly verify: (input: {
197
+ readonly pool: string;
198
+ readonly credential: string;
199
+ }) => Effect.Effect<EngineServerBootstrapGrant | null, EngineServersError>;
200
+ /** Called while the plugin binds; throws when a required secret is missing so boot fails. */
201
+ readonly check?: () => void;
202
+ }
203
+
204
+ /**
205
+ * The latest checkpoint of an open session run, one row per run, deleted when the run closes. `data` is the
206
+ * game's opaque progress: never selected by inspection, never logged; erasing a subject drops the checkpoints of
207
+ * sessions the subject played in, because their content may name players.
208
+ */
209
+ export declare const engineServerCheckpointsTable: Table<"_voltro_engine_server_checkpoints", FieldDefinitions<{
210
+ readonly id: ColumnBuilder<string, "id", boolean>;
211
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
212
+ readonly runId: ColumnBuilder<string, "text", boolean>;
213
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
214
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
215
+ readonly revision: ColumnBuilder<number, "integer", boolean>;
216
+ readonly schemaVersion: ColumnBuilder<number, "integer", boolean>;
217
+ readonly bytes: ColumnBuilder<number, "integer", boolean>;
218
+ readonly digest: ColumnBuilder<string, "text", boolean>;
219
+ readonly data: ColumnBuilder<string, "text", boolean>;
220
+ readonly writtenAt: ColumnBuilder<Date, "timestamp", boolean>;
221
+ }>, true, "byEngineServerCheckpointSession">;
222
+
223
+ /** One row per issued service token. Every call checks it online: revocation is immediate. */
224
+ export declare const engineServerCredentialsTable: Table<"_voltro_engine_server_credentials", FieldDefinitions<{
225
+ readonly id: ColumnBuilder<string, "id", boolean>;
226
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
227
+ readonly pool: ColumnBuilder<string, "text", boolean>;
228
+ /** Null for the pool token `engineServers.authenticate` returns; set once a server registered with it. */
229
+ readonly serverId: ColumnBuilder<string | null, "text", boolean>;
230
+ readonly issuedAt: ColumnBuilder<Date, "timestamp", boolean>;
231
+ readonly expiresAt: ColumnBuilder<Date, "timestamp", boolean>;
232
+ readonly revokedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
233
+ }>, true, "byEngineServerCredentialPool" | "byEngineServerCredentialServer">;
234
+
235
+ /** The installed economy plugin (`economyPlugin(...)`) or anything with its trusted transfer. */
236
+ declare interface EngineServerEconomySource {
237
+ readonly economy: {
238
+ readonly service: () => Pick<EconomyService, 'transfer'>;
239
+ };
240
+ }
241
+
242
+ /** The installed inventory plugin (`inventoryPlugin(...)`) or anything with its trusted grant and consume. */
243
+ declare interface EngineServerInventorySource {
244
+ readonly inventory: {
245
+ readonly service: () => Pick<InventoryService, 'grant' | 'consume'>;
246
+ };
247
+ }
248
+
249
+ /** The installed leaderboards plugin: service-only submissions and rating matches. */
250
+ declare interface EngineServerLeaderboardsSource {
251
+ readonly leaderboards: {
252
+ readonly service: () => Pick<LeaderboardAdministrationService, 'submit' | 'prepareRatingMatch' | 'applyRatingMatch'>;
253
+ };
254
+ }
255
+
256
+ declare interface EngineServerPool {
257
+ readonly name: string;
258
+ readonly engine: EngineKind;
259
+ readonly trust: EngineServerTrust;
260
+ readonly builds: ReadonlyArray<string>;
261
+ readonly regions: ReadonlyArray<string>;
262
+ readonly capacity: {
263
+ readonly players: number;
264
+ };
265
+ readonly scopes: ReadonlyArray<EngineServerScope>;
266
+ readonly writeLimits: Readonly<Record<EngineServerWriteKind, EngineServerWriteLimit>>;
267
+ readonly protocols: ReadonlyArray<EngineServerProtocol>;
268
+ readonly heartbeatTtlMs: number;
269
+ readonly tokenTtlMs: number;
270
+ readonly ticketTtlMs: number;
271
+ readonly reconnectWindowMs: number;
272
+ readonly resumeWindowMs: number;
273
+ /** Null: sessions of this pool are never recovered on another server. */
274
+ readonly recovery: EngineServerRecovery | null;
275
+ }
276
+
277
+ /** The installed progression plugin: XP, stats and quest signals. */
278
+ declare interface EngineServerProgressionSource {
279
+ readonly progression: {
280
+ readonly service: () => Pick<ProgressionService, 'applyXp' | 'applyStat'>;
281
+ readonly quests: () => Pick<QuestService, 'record'>;
282
+ };
283
+ }
284
+
285
+ declare type EngineServerProtocol = typeof ENGINE_SERVER_PROTOCOLS[number];
286
+
287
+ declare interface EngineServerRecovery {
288
+ readonly afterMs: number;
289
+ readonly waitMs: number;
290
+ readonly checkpointBytes: number;
291
+ readonly checkpointsPerMinute: number;
292
+ readonly maxRecoveries: number;
293
+ }
294
+
295
+ /** The trusted server-side surface. Engine servers reach the routed half through RPC. */
296
+ export declare interface EngineServerRegistry extends EngineServerSessionAuthority {
297
+ readonly authenticate: (input: {
298
+ readonly pool: string;
299
+ readonly credential: string;
300
+ }) => Effect.Effect<ServiceToken, EngineServersError>;
301
+ readonly register: (input: RegisterInput) => Effect.Effect<RegisterOutput, EngineServersError>;
302
+ /**
303
+ * Give a `suspended` server (or one whose lease lapsed unnoticed) back to the process that registered it, inside
304
+ * the pool's resume window: a fresh pool token plus the lease proof `register` returned. Same server, session,
305
+ * seats and tickets; the run continues. `lease_lost` once the server is gone, the window passed or the proof differs.
306
+ */
307
+ readonly resume: (input: ResumeInput) => Effect.Effect<ResumeOutput, EngineServersError>;
308
+ readonly heartbeat: (input: {
309
+ readonly token: string;
310
+ readonly ready?: boolean;
311
+ }) => Effect.Effect<HeartbeatOutput, EngineServersError>;
312
+ readonly drainSelf: (input: {
313
+ readonly token: string;
314
+ }) => Effect.Effect<EngineServer, EngineServersError>;
315
+ readonly deregister: (input: {
316
+ readonly token: string;
317
+ }) => Effect.Effect<void, EngineServersError>;
318
+ readonly verifySeat: (input: {
319
+ readonly token: string;
320
+ readonly ticket: string;
321
+ }) => Effect.Effect<VerifiedSeat, EngineServersError>;
322
+ /** Authenticate a server token with `sessions:backfill` and return the session the `allocated` server holds. */
323
+ readonly authorizeSession: (input: {
324
+ readonly token: string;
325
+ }) => Effect.Effect<EngineServerSession, EngineServersError>;
326
+ readonly issueTicket: (input: IssueTicketInput) => Effect.Effect<IssuedTicket, EngineServersError>;
327
+ /** Supersede a ticket and issue a follow-up for the same seat while its server still holds the session. */
328
+ readonly reissueTicket: (input: {
329
+ readonly tenantId: string;
330
+ readonly ticketId: string;
331
+ }) => Effect.Effect<IssuedTicket, EngineServersError>;
332
+ readonly revokeTicket: (input: {
333
+ readonly tenantId: string;
334
+ readonly ticketId: string;
335
+ }) => Effect.Effect<boolean, EngineServersError>;
336
+ /**
337
+ * Issue the tickets of one backfill request in one transaction, fenced by the server row's `version`:
338
+ * all seats fit the session's free seats or none is issued (`no_capacity`), and a repeated `requestKey` is not seated twice.
339
+ */
340
+ readonly seatBackfill: (input: SeatBackfillInput) => Effect.Effect<SeatedBackfill, EngineServersError>;
341
+ /**
342
+ * Free the seats of a backfill request nobody recorded: when the key's tickets are all still unused after
343
+ * {@link BACKFILL_RECORD_MS}, revoke them and forget the key, so a repeat of the request seats again.
344
+ * Returns how many held seats it freed (expired tickets no longer held one); 0 when the key is absent, too
345
+ * young or one of its tickets was used, and then the key stays.
346
+ */
347
+ readonly reclaimBackfill: (input: ServerRef & {
348
+ readonly sessionId: string;
349
+ readonly requestKey: string;
350
+ }) => Effect.Effect<number, EngineServersError>;
351
+ /**
352
+ * Revoke a backfill request's tickets and forget its key, so a retry can seat again. With `ticketIds`, only
353
+ * when the key still holds exactly those tickets (a later seating of the key stays). False when nothing was withdrawn.
354
+ */
355
+ readonly withdrawBackfill: (input: ServerRef & {
356
+ readonly sessionId: string;
357
+ readonly requestKey: string;
358
+ readonly ticketIds?: ReadonlyArray<string>;
359
+ }) => Effect.Effect<boolean, EngineServersError>;
360
+ /** Atomically move one live `ready` server to `allocated` for a session. Idempotent per session. */
361
+ readonly reserve: (input: ReserveInput) => Effect.Effect<EngineServer, EngineServersError>;
362
+ /** End a session on a server: `allocated → ready`, `draining` stays. Outstanding tickets are revoked. */
363
+ readonly release: (input: ServerRef & {
364
+ readonly sessionId: string;
365
+ }) => Effect.Effect<EngineServer, EngineServersError>;
366
+ readonly drain: (input: ServerRef) => Effect.Effect<EngineServer, EngineServersError>;
367
+ readonly revokeServer: (input: ServerRef) => Effect.Effect<boolean, EngineServersError>;
368
+ /** Revoke every token of a pool and remove its servers. Rotate the bootstrap secret to stop new ones. */
369
+ readonly revokePool: (input: {
370
+ readonly tenantId: string;
371
+ readonly pool: string;
372
+ }) => Effect.Effect<number, EngineServersError>;
373
+ readonly get: (input: ServerRef) => Effect.Effect<EngineServer | null, EngineServersError>;
374
+ readonly list: (input: {
375
+ readonly tenantId: string;
376
+ readonly pool?: string;
377
+ readonly states?: ReadonlyArray<EngineServerState>;
378
+ readonly limit?: number;
379
+ }) => Effect.Effect<ReadonlyArray<EngineServer>, EngineServersError>;
380
+ /**
381
+ * Free the seats these join tickets hold in sessions whose server is `suspended` (the player searched again or left
382
+ * the match): revokes them, so the seat is free and the ticket no longer admits. Returns how many it freed. Tickets of
383
+ * live servers, ended sessions or unknown ids are left alone: a live server reports its own players.
384
+ */
385
+ readonly vacateWaitingSeats: (input: {
386
+ readonly tenantId: string;
387
+ readonly ticketIds: ReadonlyArray<string>;
388
+ }) => Effect.Effect<number, EngineServersError>;
389
+ /**
390
+ * Suspend servers whose lease expired (or mark them `gone` when their pool has no resume window) and end suspended
391
+ * servers whose window passed; returns how many changed. Runs lazily on register/reserve too.
392
+ */
393
+ readonly sweep: (input?: {
394
+ readonly tenantId?: string;
395
+ readonly pool?: string;
396
+ }) => Effect.Effect<number, EngineServersError>;
397
+ /**
398
+ * A trusted caller (operator tooling, the orchestrator that saw the process exit) reports a server's process is gone.
399
+ * The lease is dropped at once, so the server is suspended (or gone without a resume window) instead of waiting out its
400
+ * TTL, and a pool with `recovery` hands its session over without waiting `afterMs`. Never routed: a server credential
401
+ * cannot report another server dead. False when the server was already gone.
402
+ */
403
+ readonly reportExit: (input: ServerRef) => Effect.Effect<boolean, EngineServersError>;
404
+ readonly exportSubject: (input: {
405
+ readonly tenantId: string;
406
+ readonly subjectId: string;
407
+ }) => Effect.Effect<EngineServerSubjectExport, EngineServersError>;
408
+ readonly eraseSubject: (input: {
409
+ readonly tenantId: string;
410
+ readonly subjectId: string;
411
+ }) => Effect.Effect<void, EngineServersError>;
412
+ }
413
+
414
+ export declare interface EngineServerRegistryOptions {
415
+ readonly pools: ReadonlyArray<EngineServerPool>;
416
+ readonly bootstrap: EngineServerBootstrapSource;
417
+ /** Signs service tokens. Read on every call so rotation applies without a restart. */
418
+ readonly tokenSecrets: () => SessionSecrets;
419
+ /** Signs join tickets; must differ from `tokenSecrets`. */
420
+ readonly ticketSecrets: () => SessionSecrets;
421
+ readonly now?: () => number;
422
+ /** Systems a pool's `writes:<kind>` scopes write through. */
423
+ readonly writes?: EngineServerWriteSources;
424
+ /** Anti-cheat vendor port; without one `anticheat.report` stores nothing. */
425
+ readonly antiCheat?: EngineServerAntiCheatProvider;
426
+ /** Called inside every recovery handover transaction; a failure rolls the handover back (the next sweep retries). */
427
+ readonly sessionMoved?: EngineServerSessionMoveListener;
428
+ /** How long one HotStore call may take before it counts as unreachable (`unavailable`, reason `hot_store`). Default 2000 ms. */
429
+ readonly hotTimeoutMs?: number;
430
+ }
431
+
432
+ declare type EngineServerReport = typeof EngineServerReportSchema.Type;
433
+
434
+ declare const EngineServerReportSchema: Schema.Struct<{
435
+ readonly reportId: Schema.NonEmptyString;
436
+ readonly serverId: Schema.NonEmptyString;
437
+ readonly pool: Schema.NonEmptyString;
438
+ readonly sessionId: Schema.NonEmptyString;
439
+ readonly trust: Schema.Literals<readonly ["dedicated", "host"]>;
440
+ readonly trusted: Schema.Boolean;
441
+ readonly outcome: Schema.Literals<readonly ["completed", "aborted"]>;
442
+ readonly standings: Schema.$Array<Schema.Struct<{
443
+ readonly playerId: Schema.NullOr<Schema.NonEmptyString>;
444
+ readonly rank: Schema.Number;
445
+ readonly team: Schema.NullOr<Schema.NonEmptyString>;
446
+ readonly score: Schema.NullOr<Schema.String>;
447
+ }>>;
448
+ readonly stats: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>;
449
+ readonly digest: Schema.NonEmptyString;
450
+ readonly reportedAt: Schema.Number;
451
+ }>;
452
+
453
+ /** One result per session run, bound to the service credential that reported it. */
454
+ export declare const engineServerReportsTable: Table<"_voltro_engine_server_reports", FieldDefinitions<{
455
+ readonly id: ColumnBuilder<string, "id", boolean>;
456
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
457
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
458
+ readonly pool: ColumnBuilder<string, "text", boolean>;
459
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
460
+ readonly trust: ColumnBuilder<"host" | "dedicated", "text", boolean>;
461
+ readonly trusted: ColumnBuilder<boolean, "boolean", boolean>;
462
+ readonly credentialId: ColumnBuilder<string, "text", boolean>;
463
+ readonly outcome: ColumnBuilder<"aborted" | "completed", "text", boolean>;
464
+ /** Standings and stats; player ids are personal data (export and erase rewrite them). */
465
+ readonly result: ColumnBuilder<unknown, "json", boolean>;
466
+ readonly digest: ColumnBuilder<string, "text", boolean>;
467
+ readonly reportedAt: ColumnBuilder<Date, "timestamp", boolean>;
468
+ }>, true, never>;
469
+
470
+ /** One registered server as the registry reports it. Carries no lease or credential. */
471
+ declare const EngineServerSchema: Schema.Struct<{
472
+ readonly id: Schema.NonEmptyString;
473
+ readonly pool: Schema.NonEmptyString;
474
+ readonly region: Schema.NonEmptyString;
475
+ readonly buildId: Schema.NonEmptyString;
476
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
477
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
478
+ readonly port: Schema.NullOr<Schema.Number>;
479
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
480
+ readonly capacity: Schema.Number;
481
+ readonly labels: Schema.$Record<Schema.String, Schema.String>;
482
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
483
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
484
+ readonly registeredAt: Schema.Number;
485
+ readonly lastHeartbeatAt: Schema.Number;
486
+ readonly stateChangedAt: Schema.Number;
487
+ readonly goneReason: Schema.NullOr<Schema.Literals<readonly ["deregistered", "lease_expired", "revoked", "recovered"]>>;
488
+ }>;
489
+
490
+ declare type EngineServerScope = typeof ENGINE_SERVER_SCOPES[number];
491
+
492
+ /**
493
+ * `lease_suspended`: the server's lease lapsed and the server waits inside its pool's resume window; only its own
494
+ * process resumes it (`engineServers.resume`). `rejected` carries the refusing system's own error code in `reason` (for example `insufficient_funds`).
495
+ */
496
+ declare class EngineServersError extends EngineServersError_base {
497
+ }
498
+
499
+ declare const EngineServersError_base: Schema.Class<EngineServersError, Schema.TaggedStruct<"EngineServersError", {
500
+ readonly code: Schema.Literals<readonly ["invalid_input", "unauthenticated", "forbidden", "not_found", "unavailable", "conflict", "lease_lost", "lease_suspended", "revoked", "expired", "replayed", "wrong_server", "no_capacity", "invalid_ticket", "out_of_order", "rate_limited", "implausible", "not_seated", "rejected"]>;
501
+ readonly reason: Schema.optionalKey<Schema.String>;
502
+ }>, YieldableError>;
503
+
504
+ /** The session an engine server holds, as its own service token proves it. */
505
+ export declare interface EngineServerSession {
506
+ readonly tenantId: string;
507
+ readonly serverId: string;
508
+ readonly pool: string;
509
+ readonly sessionId: string;
510
+ readonly capacity: number;
511
+ /** Seats still taken: issued tickets before their redeem-by, redeemed ones not left or inside the reconnect window. */
512
+ readonly seated: number;
513
+ readonly connect: IssuedTicket['connect'];
514
+ }
515
+
516
+ /** The server-authored half of a session: lifecycle, writes, result and anti-cheat status. */
517
+ export declare interface EngineServerSessionAuthority {
518
+ readonly event: (input: SessionEventInput) => Effect.Effect<SessionEventReceipt, EngineServersError>;
519
+ readonly write: (input: SessionWriteInput) => Effect.Effect<SessionWriteReceipt, EngineServersError>;
520
+ readonly report: (input: MatchReportInput) => Effect.Effect<MatchReportReceipt, EngineServersError>;
521
+ readonly antiCheat: (input: AntiCheatReportInput) => Effect.Effect<AntiCheatReceipt, EngineServersError>;
522
+ readonly getReport: (input: SessionRef) => Effect.Effect<EngineServerReport | null, EngineServersError>;
523
+ readonly antiCheatStatus: (input: {
524
+ readonly tenantId: string;
525
+ readonly subjectId: string;
526
+ }) => Effect.Effect<{
527
+ readonly status: AntiCheatStatus;
528
+ readonly provider: string | null;
529
+ readonly updatedAt: number | null;
530
+ }, EngineServersError>;
531
+ readonly activity: (input: {
532
+ readonly tenantId: string;
533
+ readonly subjectId: string;
534
+ }) => Effect.Effect<EngineServerActivity | null, EngineServersError>;
535
+ /** Store the session's latest checkpoint: fenced on the server row, monotonic by `revision`, bounded by the pool's `recovery`. */
536
+ readonly checkpoint: (input: CheckpointInput) => Effect.Effect<CheckpointReceipt, EngineServersError>;
537
+ /** What a recovery server continues from; only the server that now holds a recovered session reads it. */
538
+ readonly recovery: (input: RecoveryInput) => Effect.Effect<Recovery, EngineServersError>;
539
+ }
540
+
541
+ /** Accepted lifecycle events; the unique key makes a sequence number count once. Only the payload digest is kept. */
542
+ export declare const engineServerSessionEventsTable: Table<"_voltro_engine_server_session_events", FieldDefinitions<{
543
+ readonly id: ColumnBuilder<string, "id", boolean>;
544
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
545
+ readonly runId: ColumnBuilder<string, "text", boolean>;
546
+ readonly sequence: ColumnBuilder<number, "integer", boolean>;
547
+ readonly type: ColumnBuilder<"session.started" | "player.joined" | "player.left" | "session.recovering" | "session.recovered" | "session.ended", "text", boolean>;
548
+ readonly subjectId: ColumnBuilder<string | null, "text", boolean>;
549
+ readonly digest: ColumnBuilder<string, "text", boolean>;
550
+ readonly at: ColumnBuilder<Date, "timestamp", boolean>;
551
+ }>, true, "byEngineServerSessionEventSubject">;
552
+
553
+ /** A session recovery moved to another server, as the handover transaction committed it. Carries no ticket or token. */
554
+ export declare interface EngineServerSessionMove {
555
+ readonly tenantId: string;
556
+ readonly pool: string;
557
+ readonly sessionId: string;
558
+ /** The crashed server, now `gone` (`recovered`). */
559
+ readonly from: string;
560
+ /** The server that runs the session now. */
561
+ readonly serverId: string;
562
+ readonly connect: IssuedTicket['connect'];
563
+ /** Every kept seat: the crashed server's ticket id and the new server's; `reissueTicket(to)` mints the player's follow-up ticket. */
564
+ readonly seats: ReadonlyArray<{
565
+ readonly subjectId: string;
566
+ readonly from: string;
567
+ readonly to: string;
568
+ }>;
569
+ }
570
+
571
+ /** Runs inside the handover transaction with its `write` store, so a seat record moves together with the session or not at all. */
572
+ export declare type EngineServerSessionMoveListener = (write: DataStore, move: EngineServerSessionMove) => Promise<void>;
573
+
574
+ /** One row per session a server ran. `sequence` is the last accepted lifecycle event; the next one CASes on it. */
575
+ export declare const engineServerSessionsTable: Table<"_voltro_engine_server_sessions", FieldDefinitions<{
576
+ readonly id: ColumnBuilder<string, "id", boolean>;
577
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
578
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
579
+ readonly pool: ColumnBuilder<string, "text", boolean>;
580
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
581
+ readonly trust: ColumnBuilder<"host" | "dedicated", "text", boolean>;
582
+ readonly state: ColumnBuilder<"waiting" | "abandoned" | "running" | "recovering" | "ended", "text", boolean>;
583
+ readonly sequence: ColumnBuilder<number, "integer", boolean>;
584
+ readonly startedAt: ColumnBuilder<Date, "timestamp", boolean>;
585
+ readonly endedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
586
+ readonly endReason: ColumnBuilder<string | null, "text", boolean>;
587
+ /** When the run last started `waiting` (its server was suspended), and when its server last resumed it. */
588
+ readonly waitingSince: ColumnBuilder<Date | null, "timestamp", boolean>;
589
+ readonly resumedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
590
+ /** How often the run's server resumed it. */
591
+ readonly resumes: ColumnBuilder<number, "integer", true>;
592
+ /** How often the session moved to another server (crash recovery), and when the latest new server restored it. */
593
+ readonly recoveries: ColumnBuilder<number, "integer", true>;
594
+ readonly recoveredAt: ColumnBuilder<Date | null, "timestamp", boolean>;
595
+ }>, true, "byEngineServerSessionState">;
596
+
597
+ /** One row per registered server. Liveness is the HotStore lease; the row is the durable record. */
598
+ export declare const engineServersTable: Table<"_voltro_engine_servers", FieldDefinitions<{
599
+ readonly id: ColumnBuilder<string, "id", boolean>;
600
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
601
+ readonly pool: ColumnBuilder<string, "text", boolean>;
602
+ readonly region: ColumnBuilder<string, "text", boolean>;
603
+ readonly buildId: ColumnBuilder<string, "text", boolean>;
604
+ readonly protocol: ColumnBuilder<"websocket" | "udp" | "tcp" | "webtransport" | "quic", "text", boolean>;
605
+ readonly address: ColumnBuilder<string | null, "text", boolean>;
606
+ readonly port: ColumnBuilder<number | null, "integer", boolean>;
607
+ readonly relay: ColumnBuilder<string | null, "text", boolean>;
608
+ readonly capacity: ColumnBuilder<number, "integer", boolean>;
609
+ readonly labels: ColumnBuilder<unknown, "json", boolean>;
610
+ readonly state: ColumnBuilder<"ready" | "suspended" | "starting" | "allocated" | "draining" | "gone", "text", boolean>;
611
+ /**
612
+ * SHA-256 digest of the lease proof, also the HotStore lease value: only its holder may renew or release the
613
+ * lease, and only the process that presents the proof itself may resume a suspended server.
614
+ */
615
+ readonly leaseId: ColumnBuilder<string, "text", boolean>;
616
+ /** The state a `suspended` server returns to when it resumes; null otherwise. */
617
+ readonly resumeState: ColumnBuilder<"ready" | "starting" | "allocated" | "draining" | null, "text", boolean>;
618
+ readonly sessionId: ColumnBuilder<string | null, "text", boolean>;
619
+ /** Bumped by every state transition; transitions compare it. */
620
+ readonly version: ColumnBuilder<number, "integer", true>;
621
+ readonly registeredAt: ColumnBuilder<Date, "timestamp", boolean>;
622
+ readonly lastHeartbeatAt: ColumnBuilder<Date, "timestamp", boolean>;
623
+ readonly stateChangedAt: ColumnBuilder<Date, "timestamp", boolean>;
624
+ readonly goneReason: ColumnBuilder<string | null, "text", boolean>;
625
+ /** Set while the server runs a session it took over from a crashed server: the server that started the session. */
626
+ readonly sessionOrigin: ColumnBuilder<string | null, "text", boolean>;
627
+ /** When a trusted caller (operator or orchestrator) reported the process exited; recovery need not wait `afterMs`. */
628
+ readonly exitedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
629
+ }>, true, "byEngineServerPoolState" | "byEngineServerHeartbeat" | "byEngineServerSession">;
630
+
631
+ declare type EngineServerState = typeof ENGINE_SERVER_STATES[number];
632
+
633
+ /** A subject's engine-server records, as the privacy export returns them. */
634
+ export declare interface EngineServerSubjectExport {
635
+ readonly engineServerTickets: ReadonlyArray<Record<string, unknown>>;
636
+ readonly engineServerSessionEvents: ReadonlyArray<Record<string, unknown>>;
637
+ readonly engineServerReports: ReadonlyArray<Record<string, unknown>>;
638
+ readonly engineServerAntiCheat: Record<string, unknown> | null;
639
+ }
640
+
641
+ /** Tables holding subject ids; subject export and erase cover each. */
642
+ export declare const engineServerSubjectTables: readonly [ Table<"_voltro_engine_servers", FieldDefinitions<{
643
+ readonly id: ColumnBuilder<string, "id", boolean>;
644
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
645
+ readonly pool: ColumnBuilder<string, "text", boolean>;
646
+ readonly region: ColumnBuilder<string, "text", boolean>;
647
+ readonly buildId: ColumnBuilder<string, "text", boolean>;
648
+ readonly protocol: ColumnBuilder<"websocket" | "udp" | "tcp" | "webtransport" | "quic", "text", boolean>;
649
+ readonly address: ColumnBuilder<string | null, "text", boolean>;
650
+ readonly port: ColumnBuilder<number | null, "integer", boolean>;
651
+ readonly relay: ColumnBuilder<string | null, "text", boolean>;
652
+ readonly capacity: ColumnBuilder<number, "integer", boolean>;
653
+ readonly labels: ColumnBuilder<unknown, "json", boolean>;
654
+ readonly state: ColumnBuilder<"ready" | "suspended" | "starting" | "allocated" | "draining" | "gone", "text", boolean>;
655
+ /**
656
+ * SHA-256 digest of the lease proof, also the HotStore lease value: only its holder may renew or release the
657
+ * lease, and only the process that presents the proof itself may resume a suspended server.
658
+ */
659
+ readonly leaseId: ColumnBuilder<string, "text", boolean>;
660
+ /** The state a `suspended` server returns to when it resumes; null otherwise. */
661
+ readonly resumeState: ColumnBuilder<"ready" | "starting" | "allocated" | "draining" | null, "text", boolean>;
662
+ readonly sessionId: ColumnBuilder<string | null, "text", boolean>;
663
+ /** Bumped by every state transition; transitions compare it. */
664
+ readonly version: ColumnBuilder<number, "integer", true>;
665
+ readonly registeredAt: ColumnBuilder<Date, "timestamp", boolean>;
666
+ readonly lastHeartbeatAt: ColumnBuilder<Date, "timestamp", boolean>;
667
+ readonly stateChangedAt: ColumnBuilder<Date, "timestamp", boolean>;
668
+ readonly goneReason: ColumnBuilder<string | null, "text", boolean>;
669
+ /** Set while the server runs a session it took over from a crashed server: the server that started the session. */
670
+ readonly sessionOrigin: ColumnBuilder<string | null, "text", boolean>;
671
+ /** When a trusted caller (operator or orchestrator) reported the process exited; recovery need not wait `afterMs`. */
672
+ readonly exitedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
673
+ }>, true, "byEngineServerPoolState" | "byEngineServerHeartbeat" | "byEngineServerSession">, Table<"_voltro_engine_server_credentials", FieldDefinitions<{
674
+ readonly id: ColumnBuilder<string, "id", boolean>;
675
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
676
+ readonly pool: ColumnBuilder<string, "text", boolean>;
677
+ /** Null for the pool token `engineServers.authenticate` returns; set once a server registered with it. */
678
+ readonly serverId: ColumnBuilder<string | null, "text", boolean>;
679
+ readonly issuedAt: ColumnBuilder<Date, "timestamp", boolean>;
680
+ readonly expiresAt: ColumnBuilder<Date, "timestamp", boolean>;
681
+ readonly revokedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
682
+ }>, true, "byEngineServerCredentialPool" | "byEngineServerCredentialServer">, Table<"_voltro_engine_server_tickets", FieldDefinitions<{
683
+ readonly id: ColumnBuilder<string, "id", boolean>;
684
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
685
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
686
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
687
+ readonly subjectId: ColumnBuilder<string, "text", boolean>;
688
+ readonly subjectKind: ColumnBuilder<"user" | "guest", "text", boolean>;
689
+ readonly digest: ColumnBuilder<string, "text", boolean>;
690
+ readonly state: ColumnBuilder<"expired" | "superseded" | "revoked" | "issued" | "redeemed", "text", boolean>;
691
+ readonly issuedAt: ColumnBuilder<Date, "timestamp", boolean>;
692
+ readonly redeemBy: ColumnBuilder<Date, "timestamp", boolean>;
693
+ readonly redeemedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
694
+ readonly redemptions: ColumnBuilder<number, "integer", true>;
695
+ /** `player.joined` sets it and clears `leftAt`; `player.left` sets `leftAt`, which anchors the reconnect window. */
696
+ readonly joinedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
697
+ readonly leftAt: ColumnBuilder<Date | null, "timestamp", boolean>;
698
+ /** Party, team and seat attributes the app resolved; needed to reissue a follow-up ticket. */
699
+ readonly claims: ColumnBuilder<unknown, "json", boolean>;
700
+ }>, true, "byEngineServerTicketSubject" | "byEngineServerTicketSession">, Table<"_voltro_engine_server_sessions", FieldDefinitions<{
701
+ readonly id: ColumnBuilder<string, "id", boolean>;
702
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
703
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
704
+ readonly pool: ColumnBuilder<string, "text", boolean>;
705
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
706
+ readonly trust: ColumnBuilder<"host" | "dedicated", "text", boolean>;
707
+ readonly state: ColumnBuilder<"waiting" | "abandoned" | "running" | "recovering" | "ended", "text", boolean>;
708
+ readonly sequence: ColumnBuilder<number, "integer", boolean>;
709
+ readonly startedAt: ColumnBuilder<Date, "timestamp", boolean>;
710
+ readonly endedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
711
+ readonly endReason: ColumnBuilder<string | null, "text", boolean>;
712
+ /** When the run last started `waiting` (its server was suspended), and when its server last resumed it. */
713
+ readonly waitingSince: ColumnBuilder<Date | null, "timestamp", boolean>;
714
+ readonly resumedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
715
+ /** How often the run's server resumed it. */
716
+ readonly resumes: ColumnBuilder<number, "integer", true>;
717
+ /** How often the session moved to another server (crash recovery), and when the latest new server restored it. */
718
+ readonly recoveries: ColumnBuilder<number, "integer", true>;
719
+ readonly recoveredAt: ColumnBuilder<Date | null, "timestamp", boolean>;
720
+ }>, true, "byEngineServerSessionState">, Table<"_voltro_engine_server_session_events", FieldDefinitions<{
721
+ readonly id: ColumnBuilder<string, "id", boolean>;
722
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
723
+ readonly runId: ColumnBuilder<string, "text", boolean>;
724
+ readonly sequence: ColumnBuilder<number, "integer", boolean>;
725
+ readonly type: ColumnBuilder<"session.started" | "player.joined" | "player.left" | "session.recovering" | "session.recovered" | "session.ended", "text", boolean>;
726
+ readonly subjectId: ColumnBuilder<string | null, "text", boolean>;
727
+ readonly digest: ColumnBuilder<string, "text", boolean>;
728
+ readonly at: ColumnBuilder<Date, "timestamp", boolean>;
729
+ }>, true, "byEngineServerSessionEventSubject">, Table<"_voltro_engine_server_reports", FieldDefinitions<{
730
+ readonly id: ColumnBuilder<string, "id", boolean>;
731
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
732
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
733
+ readonly pool: ColumnBuilder<string, "text", boolean>;
734
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
735
+ readonly trust: ColumnBuilder<"host" | "dedicated", "text", boolean>;
736
+ readonly trusted: ColumnBuilder<boolean, "boolean", boolean>;
737
+ readonly credentialId: ColumnBuilder<string, "text", boolean>;
738
+ readonly outcome: ColumnBuilder<"aborted" | "completed", "text", boolean>;
739
+ /** Standings and stats; player ids are personal data (export and erase rewrite them). */
740
+ readonly result: ColumnBuilder<unknown, "json", boolean>;
741
+ readonly digest: ColumnBuilder<string, "text", boolean>;
742
+ readonly reportedAt: ColumnBuilder<Date, "timestamp", boolean>;
743
+ }>, true, never>, Table<"_voltro_engine_server_anticheat", FieldDefinitions<{
744
+ readonly id: ColumnBuilder<string, "id", boolean>;
745
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
746
+ readonly subjectId: ColumnBuilder<string, "text", boolean>;
747
+ readonly status: ColumnBuilder<"unknown" | "unverified" | "verified" | "violation", "text", boolean>;
748
+ readonly provider: ColumnBuilder<string, "text", boolean>;
749
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
750
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
751
+ readonly updatedAt: ColumnBuilder<Date, "timestamp", boolean>;
752
+ }>, true, never>];
753
+
754
+ export declare const engineServerTables: readonly [ Table<"_voltro_engine_servers", FieldDefinitions<{
755
+ readonly id: ColumnBuilder<string, "id", boolean>;
756
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
757
+ readonly pool: ColumnBuilder<string, "text", boolean>;
758
+ readonly region: ColumnBuilder<string, "text", boolean>;
759
+ readonly buildId: ColumnBuilder<string, "text", boolean>;
760
+ readonly protocol: ColumnBuilder<"websocket" | "udp" | "tcp" | "webtransport" | "quic", "text", boolean>;
761
+ readonly address: ColumnBuilder<string | null, "text", boolean>;
762
+ readonly port: ColumnBuilder<number | null, "integer", boolean>;
763
+ readonly relay: ColumnBuilder<string | null, "text", boolean>;
764
+ readonly capacity: ColumnBuilder<number, "integer", boolean>;
765
+ readonly labels: ColumnBuilder<unknown, "json", boolean>;
766
+ readonly state: ColumnBuilder<"ready" | "suspended" | "starting" | "allocated" | "draining" | "gone", "text", boolean>;
767
+ /**
768
+ * SHA-256 digest of the lease proof, also the HotStore lease value: only its holder may renew or release the
769
+ * lease, and only the process that presents the proof itself may resume a suspended server.
770
+ */
771
+ readonly leaseId: ColumnBuilder<string, "text", boolean>;
772
+ /** The state a `suspended` server returns to when it resumes; null otherwise. */
773
+ readonly resumeState: ColumnBuilder<"ready" | "starting" | "allocated" | "draining" | null, "text", boolean>;
774
+ readonly sessionId: ColumnBuilder<string | null, "text", boolean>;
775
+ /** Bumped by every state transition; transitions compare it. */
776
+ readonly version: ColumnBuilder<number, "integer", true>;
777
+ readonly registeredAt: ColumnBuilder<Date, "timestamp", boolean>;
778
+ readonly lastHeartbeatAt: ColumnBuilder<Date, "timestamp", boolean>;
779
+ readonly stateChangedAt: ColumnBuilder<Date, "timestamp", boolean>;
780
+ readonly goneReason: ColumnBuilder<string | null, "text", boolean>;
781
+ /** Set while the server runs a session it took over from a crashed server: the server that started the session. */
782
+ readonly sessionOrigin: ColumnBuilder<string | null, "text", boolean>;
783
+ /** When a trusted caller (operator or orchestrator) reported the process exited; recovery need not wait `afterMs`. */
784
+ readonly exitedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
785
+ }>, true, "byEngineServerPoolState" | "byEngineServerHeartbeat" | "byEngineServerSession">, Table<"_voltro_engine_server_credentials", FieldDefinitions<{
786
+ readonly id: ColumnBuilder<string, "id", boolean>;
787
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
788
+ readonly pool: ColumnBuilder<string, "text", boolean>;
789
+ /** Null for the pool token `engineServers.authenticate` returns; set once a server registered with it. */
790
+ readonly serverId: ColumnBuilder<string | null, "text", boolean>;
791
+ readonly issuedAt: ColumnBuilder<Date, "timestamp", boolean>;
792
+ readonly expiresAt: ColumnBuilder<Date, "timestamp", boolean>;
793
+ readonly revokedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
794
+ }>, true, "byEngineServerCredentialPool" | "byEngineServerCredentialServer">, Table<"_voltro_engine_server_tickets", FieldDefinitions<{
795
+ readonly id: ColumnBuilder<string, "id", boolean>;
796
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
797
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
798
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
799
+ readonly subjectId: ColumnBuilder<string, "text", boolean>;
800
+ readonly subjectKind: ColumnBuilder<"user" | "guest", "text", boolean>;
801
+ readonly digest: ColumnBuilder<string, "text", boolean>;
802
+ readonly state: ColumnBuilder<"expired" | "superseded" | "revoked" | "issued" | "redeemed", "text", boolean>;
803
+ readonly issuedAt: ColumnBuilder<Date, "timestamp", boolean>;
804
+ readonly redeemBy: ColumnBuilder<Date, "timestamp", boolean>;
805
+ readonly redeemedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
806
+ readonly redemptions: ColumnBuilder<number, "integer", true>;
807
+ /** `player.joined` sets it and clears `leftAt`; `player.left` sets `leftAt`, which anchors the reconnect window. */
808
+ readonly joinedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
809
+ readonly leftAt: ColumnBuilder<Date | null, "timestamp", boolean>;
810
+ /** Party, team and seat attributes the app resolved; needed to reissue a follow-up ticket. */
811
+ readonly claims: ColumnBuilder<unknown, "json", boolean>;
812
+ }>, true, "byEngineServerTicketSubject" | "byEngineServerTicketSession">, Table<"_voltro_engine_server_sessions", FieldDefinitions<{
813
+ readonly id: ColumnBuilder<string, "id", boolean>;
814
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
815
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
816
+ readonly pool: ColumnBuilder<string, "text", boolean>;
817
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
818
+ readonly trust: ColumnBuilder<"host" | "dedicated", "text", boolean>;
819
+ readonly state: ColumnBuilder<"waiting" | "abandoned" | "running" | "recovering" | "ended", "text", boolean>;
820
+ readonly sequence: ColumnBuilder<number, "integer", boolean>;
821
+ readonly startedAt: ColumnBuilder<Date, "timestamp", boolean>;
822
+ readonly endedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
823
+ readonly endReason: ColumnBuilder<string | null, "text", boolean>;
824
+ /** When the run last started `waiting` (its server was suspended), and when its server last resumed it. */
825
+ readonly waitingSince: ColumnBuilder<Date | null, "timestamp", boolean>;
826
+ readonly resumedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
827
+ /** How often the run's server resumed it. */
828
+ readonly resumes: ColumnBuilder<number, "integer", true>;
829
+ /** How often the session moved to another server (crash recovery), and when the latest new server restored it. */
830
+ readonly recoveries: ColumnBuilder<number, "integer", true>;
831
+ readonly recoveredAt: ColumnBuilder<Date | null, "timestamp", boolean>;
832
+ }>, true, "byEngineServerSessionState">, Table<"_voltro_engine_server_session_events", FieldDefinitions<{
833
+ readonly id: ColumnBuilder<string, "id", boolean>;
834
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
835
+ readonly runId: ColumnBuilder<string, "text", boolean>;
836
+ readonly sequence: ColumnBuilder<number, "integer", boolean>;
837
+ readonly type: ColumnBuilder<"session.started" | "player.joined" | "player.left" | "session.recovering" | "session.recovered" | "session.ended", "text", boolean>;
838
+ readonly subjectId: ColumnBuilder<string | null, "text", boolean>;
839
+ readonly digest: ColumnBuilder<string, "text", boolean>;
840
+ readonly at: ColumnBuilder<Date, "timestamp", boolean>;
841
+ }>, true, "byEngineServerSessionEventSubject">, Table<"_voltro_engine_server_reports", FieldDefinitions<{
842
+ readonly id: ColumnBuilder<string, "id", boolean>;
843
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
844
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
845
+ readonly pool: ColumnBuilder<string, "text", boolean>;
846
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
847
+ readonly trust: ColumnBuilder<"host" | "dedicated", "text", boolean>;
848
+ readonly trusted: ColumnBuilder<boolean, "boolean", boolean>;
849
+ readonly credentialId: ColumnBuilder<string, "text", boolean>;
850
+ readonly outcome: ColumnBuilder<"aborted" | "completed", "text", boolean>;
851
+ /** Standings and stats; player ids are personal data (export and erase rewrite them). */
852
+ readonly result: ColumnBuilder<unknown, "json", boolean>;
853
+ readonly digest: ColumnBuilder<string, "text", boolean>;
854
+ readonly reportedAt: ColumnBuilder<Date, "timestamp", boolean>;
855
+ }>, true, never>, Table<"_voltro_engine_server_anticheat", FieldDefinitions<{
856
+ readonly id: ColumnBuilder<string, "id", boolean>;
857
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
858
+ readonly subjectId: ColumnBuilder<string, "text", boolean>;
859
+ readonly status: ColumnBuilder<"unknown" | "unverified" | "verified" | "violation", "text", boolean>;
860
+ readonly provider: ColumnBuilder<string, "text", boolean>;
861
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
862
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
863
+ readonly updatedAt: ColumnBuilder<Date, "timestamp", boolean>;
864
+ }>, true, never>, Table<"_voltro_engine_server_backfills", FieldDefinitions<{
865
+ readonly id: ColumnBuilder<string, "id", boolean>;
866
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
867
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
868
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
869
+ readonly requestKey: ColumnBuilder<string, "text", boolean>;
870
+ readonly ticketIds: ColumnBuilder<unknown, "json", boolean>;
871
+ readonly createdAt: ColumnBuilder<Date, "timestamp", boolean>;
872
+ }>, true, never>, Table<"_voltro_engine_server_checkpoints", FieldDefinitions<{
873
+ readonly id: ColumnBuilder<string, "id", boolean>;
874
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
875
+ readonly runId: ColumnBuilder<string, "text", boolean>;
876
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
877
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
878
+ readonly revision: ColumnBuilder<number, "integer", boolean>;
879
+ readonly schemaVersion: ColumnBuilder<number, "integer", boolean>;
880
+ readonly bytes: ColumnBuilder<number, "integer", boolean>;
881
+ readonly digest: ColumnBuilder<string, "text", boolean>;
882
+ readonly data: ColumnBuilder<string, "text", boolean>;
883
+ readonly writtenAt: ColumnBuilder<Date, "timestamp", boolean>;
884
+ }>, true, "byEngineServerCheckpointSession">];
885
+
886
+ /** One row per join ticket. Only the SHA-256 digest of the bearer is stored. */
887
+ export declare const engineServerTicketsTable: Table<"_voltro_engine_server_tickets", FieldDefinitions<{
888
+ readonly id: ColumnBuilder<string, "id", boolean>;
889
+ readonly tenantId: ColumnBuilder<string, "text", boolean>;
890
+ readonly serverId: ColumnBuilder<string, "text", boolean>;
891
+ readonly sessionId: ColumnBuilder<string, "text", boolean>;
892
+ readonly subjectId: ColumnBuilder<string, "text", boolean>;
893
+ readonly subjectKind: ColumnBuilder<"user" | "guest", "text", boolean>;
894
+ readonly digest: ColumnBuilder<string, "text", boolean>;
895
+ readonly state: ColumnBuilder<"expired" | "superseded" | "revoked" | "issued" | "redeemed", "text", boolean>;
896
+ readonly issuedAt: ColumnBuilder<Date, "timestamp", boolean>;
897
+ readonly redeemBy: ColumnBuilder<Date, "timestamp", boolean>;
898
+ readonly redeemedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
899
+ readonly redemptions: ColumnBuilder<number, "integer", true>;
900
+ /** `player.joined` sets it and clears `leftAt`; `player.left` sets `leftAt`, which anchors the reconnect window. */
901
+ readonly joinedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
902
+ readonly leftAt: ColumnBuilder<Date | null, "timestamp", boolean>;
903
+ /** Party, team and seat attributes the app resolved; needed to reissue a follow-up ticket. */
904
+ readonly claims: ColumnBuilder<unknown, "json", boolean>;
905
+ }>, true, "byEngineServerTicketSubject" | "byEngineServerTicketSession">;
906
+
907
+ declare type EngineServerTrust = typeof ENGINE_SERVER_TRUST_LEVELS[number];
908
+
909
+ declare type EngineServerWriteKind = typeof ENGINE_SERVER_WRITE_KINDS[number];
910
+
911
+ declare interface EngineServerWriteLimit {
912
+ readonly perMinute: number;
913
+ readonly maxAmount: number | null;
914
+ }
915
+
916
+ /**
917
+ * Systems an engine server writes through. Each write still needs the pool scope (`writes:<kind>`);
918
+ * the target system keeps its own validation and idempotency. Telemetry needs no source: it goes to
919
+ * the app's analytics sink.
920
+ */
921
+ declare interface EngineServerWriteSources {
922
+ readonly inventory?: EngineServerInventorySource;
923
+ /** Currency grants are paid from, and charges paid into, this system account. */
924
+ readonly economy?: {
925
+ readonly plugin: EngineServerEconomySource;
926
+ readonly systemAccount: string;
927
+ };
928
+ readonly progression?: EngineServerProgressionSource;
929
+ readonly leaderboards?: EngineServerLeaderboardsSource;
930
+ }
931
+
932
+ declare type HeartbeatOutput = typeof HeartbeatOutputSchema.Type;
933
+
934
+ declare const HeartbeatOutputSchema: Schema.Struct<{
935
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
936
+ readonly drain: Schema.Boolean;
937
+ readonly heartbeatIntervalMs: Schema.Number;
938
+ /** A fresh service token once the current one has used half its lifetime; switch to it. */
939
+ readonly renewed: Schema.NullOr<Schema.Struct<{
940
+ readonly token: Schema.NonEmptyString;
941
+ readonly expiresAt: Schema.Number;
942
+ }>>;
943
+ /** The session the server is allocated to; null while `ready`. */
944
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
945
+ /** True when `sessionId` was taken over from a crashed server: read `engineServers.sessions.recovery` before anything else. */
946
+ readonly recovery: Schema.Boolean;
947
+ }>;
948
+
949
+ declare type IssuedTicket = typeof IssuedTicketSchema.Type;
950
+
951
+ declare const IssuedTicketSchema: Schema.Struct<{
952
+ readonly ticket: Schema.NonEmptyString;
953
+ readonly ticketId: Schema.NonEmptyString;
954
+ readonly serverId: Schema.NonEmptyString;
955
+ readonly redeemBy: Schema.Number;
956
+ readonly connect: Schema.Struct<{
957
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
958
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
959
+ readonly port: Schema.NullOr<Schema.Number>;
960
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
961
+ }>;
962
+ }>;
963
+
964
+ export declare interface IssueTicketInput {
965
+ readonly tenantId: string;
966
+ readonly serverId: string;
967
+ readonly sessionId: string;
968
+ readonly subject: SeatSubject;
969
+ readonly partyId?: string | null;
970
+ readonly team?: string | null;
971
+ readonly attributes?: SeatAttributes;
972
+ }
973
+
974
+ export declare const leaseKey: (tenantId: string, serverId: string) => string;
975
+
976
+ /** Count live seats of a session; flip stale tickets to `expired` on the way (CAS on state and time). */
977
+ export declare const liveSeats: (store: DataStore, at: number, pool: EngineServerPool, ref: SessionRef, capacity: number) => Promise<number>;
978
+
979
+ /** DataStore holds the durable record; the HotStore lease is the liveness truth. */
980
+ export declare const makeEngineServerRegistry: (store: DataStore, hotStore: HotStoreShape, options: EngineServerRegistryOptions) => EngineServerRegistry;
981
+
982
+ declare type MatchReportInput = typeof MatchReportInputSchema.Type;
983
+
984
+ declare const MatchReportInputSchema: Schema.Struct<{
985
+ readonly token: Schema.NonEmptyString;
986
+ readonly sessionId: Schema.NonEmptyString;
987
+ readonly outcome: Schema.Literals<readonly ["completed", "aborted"]>;
988
+ readonly standings: Schema.$Array<Schema.Struct<{
989
+ readonly playerId: Schema.NonEmptyString;
990
+ readonly rank: Schema.Number;
991
+ readonly team: Schema.optionalKey<Schema.NonEmptyString>;
992
+ readonly score: Schema.optionalKey<Schema.String>;
993
+ }>>;
994
+ readonly stats: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
995
+ /** Apply the standings to this Leaderboards rating pool. Needs `writes:leaderboards`, a completed outcome and a `dedicated` pool. */
996
+ readonly ratings: Schema.optionalKey<Schema.Struct<{
997
+ readonly pool: Schema.NonEmptyString;
998
+ }>>;
999
+ }>;
1000
+
1001
+ declare type MatchReportReceipt = typeof MatchReportReceiptSchema.Type;
1002
+
1003
+ declare const MatchReportReceiptSchema: Schema.Struct<{
1004
+ readonly reportId: Schema.NonEmptyString;
1005
+ readonly sessionId: Schema.NonEmptyString;
1006
+ /** False for a `host` pool: the result is stored for display and review, never applied to ratings. */
1007
+ readonly trusted: Schema.Boolean;
1008
+ readonly digest: Schema.NonEmptyString;
1009
+ readonly replay: Schema.Boolean;
1010
+ readonly ratings: Schema.Literals<readonly ["applied", "skipped"]>;
1011
+ }>;
1012
+
1013
+ /** Redemptions of one ticket inside its reconnect window, including the first. */
1014
+ export declare const MAX_TICKET_REDEMPTIONS = 16;
1015
+
1016
+ declare type Recovery = typeof RecoverySchema.Type;
1017
+
1018
+ declare type RecoveryInput = typeof RecoveryInputSchema.Type;
1019
+
1020
+ declare const RecoveryInputSchema: Schema.Struct<{
1021
+ readonly token: Schema.NonEmptyString;
1022
+ readonly sessionId: Schema.NonEmptyString;
1023
+ }>;
1024
+
1025
+ /** What a recovery server continues from: the session's last accepted lifecycle sequence and its latest checkpoint. */
1026
+ declare const RecoverySchema: Schema.Struct<{
1027
+ readonly sessionId: Schema.NonEmptyString;
1028
+ /** The last accepted lifecycle sequence (the registry's `session.recovering`); the next event uses this + 1. */
1029
+ readonly sequence: Schema.Number;
1030
+ /** How often this session was recovered, this time included. */
1031
+ readonly recoveries: Schema.Number;
1032
+ readonly checkpoint: Schema.Struct<{
1033
+ readonly revision: Schema.Number;
1034
+ readonly schemaVersion: Schema.Number;
1035
+ readonly data: Schema.String;
1036
+ readonly writtenAt: Schema.Number;
1037
+ }>;
1038
+ }>;
1039
+
1040
+ declare type RegisterInput = typeof RegisterInputSchema.Type;
1041
+
1042
+ declare const RegisterInputSchema: Schema.Struct<{
1043
+ readonly token: Schema.NonEmptyString;
1044
+ readonly region: Schema.NonEmptyString;
1045
+ readonly buildId: Schema.NonEmptyString;
1046
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
1047
+ readonly address: Schema.optionalKey<Schema.NonEmptyString>;
1048
+ readonly port: Schema.optionalKey<Schema.Number>;
1049
+ readonly relay: Schema.optionalKey<Schema.NonEmptyString>;
1050
+ readonly capacity: Schema.optionalKey<Schema.Number>;
1051
+ readonly labels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
1052
+ }>;
1053
+
1054
+ declare type RegisterOutput = typeof RegisterOutputSchema.Type;
1055
+
1056
+ declare const RegisterOutputSchema: Schema.Struct<{
1057
+ readonly server: Schema.Struct<{
1058
+ readonly id: Schema.NonEmptyString;
1059
+ readonly pool: Schema.NonEmptyString;
1060
+ readonly region: Schema.NonEmptyString;
1061
+ readonly buildId: Schema.NonEmptyString;
1062
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
1063
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
1064
+ readonly port: Schema.NullOr<Schema.Number>;
1065
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
1066
+ readonly capacity: Schema.Number;
1067
+ readonly labels: Schema.$Record<Schema.String, Schema.String>;
1068
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
1069
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
1070
+ readonly registeredAt: Schema.Number;
1071
+ readonly lastHeartbeatAt: Schema.Number;
1072
+ readonly stateChangedAt: Schema.Number;
1073
+ readonly goneReason: Schema.NullOr<Schema.Literals<readonly ["deregistered", "lease_expired", "revoked", "recovered"]>>;
1074
+ }>;
1075
+ readonly token: Schema.NonEmptyString;
1076
+ readonly expiresAt: Schema.Number;
1077
+ readonly heartbeatIntervalMs: Schema.Number;
1078
+ /** Keep it in memory only and never log it: `engineServers.resume` needs it after a suspension. */
1079
+ readonly lease: Schema.NonEmptyString;
1080
+ }>;
1081
+
1082
+ export declare interface ReserveInput {
1083
+ readonly tenantId: string;
1084
+ readonly pool: string;
1085
+ readonly sessionId: string;
1086
+ /** Seats the session needs; only servers with at least this capacity qualify. */
1087
+ readonly players: number;
1088
+ readonly region?: string;
1089
+ /** Every label must match exactly. */
1090
+ readonly labels?: Readonly<Record<string, string>>;
1091
+ }
1092
+
1093
+ declare type ResumeInput = typeof ResumeInputSchema.Type;
1094
+
1095
+ /** A fresh pool token from `engineServers.authenticate`, the server id and the lease proof `register` returned. */
1096
+ declare const ResumeInputSchema: Schema.Struct<{
1097
+ readonly token: Schema.NonEmptyString;
1098
+ readonly serverId: Schema.NonEmptyString;
1099
+ readonly lease: Schema.NonEmptyString;
1100
+ }>;
1101
+
1102
+ declare type ResumeOutput = typeof ResumeOutputSchema.Type;
1103
+
1104
+ declare const ResumeOutputSchema: Schema.Struct<{
1105
+ readonly server: Schema.Struct<{
1106
+ readonly id: Schema.NonEmptyString;
1107
+ readonly pool: Schema.NonEmptyString;
1108
+ readonly region: Schema.NonEmptyString;
1109
+ readonly buildId: Schema.NonEmptyString;
1110
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
1111
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
1112
+ readonly port: Schema.NullOr<Schema.Number>;
1113
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
1114
+ readonly capacity: Schema.Number;
1115
+ readonly labels: Schema.$Record<Schema.String, Schema.String>;
1116
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
1117
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
1118
+ readonly registeredAt: Schema.Number;
1119
+ readonly lastHeartbeatAt: Schema.Number;
1120
+ readonly stateChangedAt: Schema.Number;
1121
+ readonly goneReason: Schema.NullOr<Schema.Literals<readonly ["deregistered", "lease_expired", "revoked", "recovered"]>>;
1122
+ }>;
1123
+ readonly token: Schema.NonEmptyString;
1124
+ readonly expiresAt: Schema.Number;
1125
+ readonly heartbeatIntervalMs: Schema.Number;
1126
+ }>;
1127
+
1128
+ declare type SeatAttributes = typeof SeatAttributesSchema.Type;
1129
+
1130
+ declare const SeatAttributesSchema: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>;
1131
+
1132
+ export declare interface SeatBackfillInput {
1133
+ readonly tenantId: string;
1134
+ readonly serverId: string;
1135
+ readonly sessionId: string;
1136
+ /** Stable per backfill request of this session; a repeat returns the first call's tickets. */
1137
+ readonly requestKey: string;
1138
+ readonly seats: ReadonlyArray<BackfillSeat>;
1139
+ }
1140
+
1141
+ export declare type SeatClaims = Omit<typeof SeatClaimsSchema.Type, 'purpose' | 'nonce'>;
1142
+
1143
+ declare const SeatClaimsSchema: Schema.Struct<{
1144
+ readonly purpose: Schema.Literal<"voltro.sessions.seat.v1">;
1145
+ readonly ticketId: Schema.NonEmptyString;
1146
+ readonly tenantId: Schema.NonEmptyString;
1147
+ readonly serverId: Schema.NonEmptyString;
1148
+ readonly sessionId: Schema.NonEmptyString;
1149
+ readonly subjectId: Schema.NonEmptyString;
1150
+ readonly subjectType: Schema.Literals<readonly ["user", "apiKey", "serviceAccount"]>;
1151
+ readonly subjectKind: Schema.optionalKey<Schema.Literal<"guest">>;
1152
+ readonly partyId: Schema.NullOr<Schema.NonEmptyString>;
1153
+ readonly team: Schema.NullOr<Schema.NonEmptyString>;
1154
+ readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>;
1155
+ readonly redeemBy: Schema.Number;
1156
+ readonly nonce: Schema.NonEmptyString;
1157
+ }>;
1158
+
1159
+ export declare interface SeatedBackfill {
1160
+ /** Subject id → ticket id of each seat. */
1161
+ readonly tickets: Readonly<Record<string, string>>;
1162
+ /** True when `requestKey` was already seated: `tickets` are the first call's. */
1163
+ readonly replayed: boolean;
1164
+ /** Unix ms by which the caller records these seats; a later record must withdraw them instead. */
1165
+ readonly recordBy: number;
1166
+ }
1167
+
1168
+ declare type SeatSubject = typeof SeatSubjectSchema.Type;
1169
+
1170
+ declare const SeatSubjectSchema: Schema.Struct<{
1171
+ readonly id: Schema.NonEmptyString;
1172
+ readonly type: Schema.Literals<readonly ["user", "apiKey", "serviceAccount"]>;
1173
+ readonly kind: Schema.optionalKey<Schema.Literal<"guest">>;
1174
+ }>;
1175
+
1176
+ export declare interface ServerRef {
1177
+ readonly tenantId: string;
1178
+ readonly serverId: string;
1179
+ }
1180
+
1181
+ export declare type ServiceClaims = Omit<typeof ServiceClaimsSchema.Type, 'purpose'> & {
1182
+ readonly tenantId: string;
1183
+ };
1184
+
1185
+ declare const ServiceClaimsSchema: Schema.Struct<{
1186
+ readonly purpose: Schema.Literal<"voltro.engine-servers.service.v1">;
1187
+ readonly credentialId: Schema.NonEmptyString;
1188
+ readonly pool: Schema.NonEmptyString;
1189
+ readonly serverId: Schema.NullOr<Schema.NonEmptyString>;
1190
+ }>;
1191
+
1192
+ declare type ServiceToken = typeof ServiceTokenSchema.Type;
1193
+
1194
+ declare const ServiceTokenSchema: Schema.Struct<{
1195
+ readonly token: Schema.NonEmptyString;
1196
+ readonly expiresAt: Schema.Number;
1197
+ }>;
1198
+
1199
+ declare type SessionEventInput = typeof SessionEventInputSchema.Type;
1200
+
1201
+ declare const SessionEventInputSchema: Schema.Struct<{
1202
+ readonly token: Schema.NonEmptyString;
1203
+ readonly sessionId: Schema.NonEmptyString;
1204
+ readonly sequence: Schema.Number;
1205
+ readonly event: Schema.Union<readonly [Schema.Struct<{
1206
+ readonly type: Schema.Literal<"session.started">;
1207
+ }>, Schema.Struct<{
1208
+ readonly type: Schema.Literal<"player.joined">;
1209
+ readonly playerId: Schema.NonEmptyString;
1210
+ }>, Schema.Struct<{
1211
+ readonly type: Schema.Literal<"player.left">;
1212
+ readonly playerId: Schema.NonEmptyString;
1213
+ readonly reconnect: Schema.optionalKey<Schema.Boolean>;
1214
+ }>, Schema.Struct<{
1215
+ readonly type: Schema.Literal<"session.recovered">;
1216
+ }>, Schema.Struct<{
1217
+ readonly type: Schema.Literal<"session.ended">;
1218
+ readonly reason: Schema.optionalKey<Schema.NonEmptyString>;
1219
+ }>]>;
1220
+ }>;
1221
+
1222
+ declare type SessionEventReceipt = typeof SessionEventReceiptSchema.Type;
1223
+
1224
+ declare const SessionEventReceiptSchema: Schema.Struct<{
1225
+ readonly sessionId: Schema.NonEmptyString;
1226
+ readonly sequence: Schema.Number;
1227
+ /** True when this sequence was already accepted with the same event; nothing ran twice. */
1228
+ readonly replay: Schema.Boolean;
1229
+ readonly state: Schema.Literals<readonly ["running", "waiting", "recovering", "ended", "abandoned"]>;
1230
+ }>;
1231
+
1232
+ declare interface SessionRef {
1233
+ readonly tenantId: string;
1234
+ readonly serverId: string;
1235
+ readonly sessionId: string;
1236
+ }
1237
+
1238
+ declare type SessionWriteInput = typeof SessionWriteInputSchema.Type;
1239
+
1240
+ declare const SessionWriteInputSchema: Schema.Struct<{
1241
+ readonly token: Schema.NonEmptyString;
1242
+ readonly sessionId: Schema.NonEmptyString;
1243
+ /** Unique per session; a retry with the same id reaches the target system with the same request id. */
1244
+ readonly eventId: Schema.NonEmptyString;
1245
+ readonly write: Schema.Union<readonly [Schema.Struct<{
1246
+ readonly kind: Schema.Literal<"inventory.grant">;
1247
+ readonly playerId: Schema.NonEmptyString;
1248
+ readonly itemId: Schema.NonEmptyString;
1249
+ readonly qty: Schema.Number;
1250
+ readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1251
+ readonly reason: Schema.NonEmptyString;
1252
+ }>, Schema.Struct<{
1253
+ readonly kind: Schema.Literal<"inventory.consume">;
1254
+ readonly playerId: Schema.NonEmptyString;
1255
+ readonly instanceId: Schema.NonEmptyString;
1256
+ readonly qty: Schema.Number;
1257
+ readonly reason: Schema.NonEmptyString;
1258
+ }>, Schema.Struct<{
1259
+ readonly kind: Schema.Literal<"economy.grant">;
1260
+ readonly playerId: Schema.NonEmptyString;
1261
+ readonly currency: Schema.NonEmptyString;
1262
+ readonly amount: Schema.String;
1263
+ readonly reason: Schema.NonEmptyString;
1264
+ }>, Schema.Struct<{
1265
+ readonly kind: Schema.Literal<"economy.charge">;
1266
+ readonly playerId: Schema.NonEmptyString;
1267
+ readonly currency: Schema.NonEmptyString;
1268
+ readonly amount: Schema.String;
1269
+ readonly reason: Schema.NonEmptyString;
1270
+ }>, Schema.Struct<{
1271
+ readonly kind: Schema.Literal<"progression.xp">;
1272
+ readonly playerId: Schema.NonEmptyString;
1273
+ readonly trackId: Schema.NonEmptyString;
1274
+ readonly amount: Schema.String;
1275
+ }>, Schema.Struct<{
1276
+ readonly kind: Schema.Literal<"progression.stat">;
1277
+ readonly playerId: Schema.NonEmptyString;
1278
+ readonly stat: Schema.NonEmptyString;
1279
+ readonly period: Schema.Literals<readonly ["lifetime", "season"]>;
1280
+ readonly seasonId: Schema.optionalKey<Schema.NonEmptyString>;
1281
+ readonly operator: Schema.Literals<readonly ["increment", "max", "min", "set"]>;
1282
+ readonly operand: Schema.String;
1283
+ }>, Schema.Struct<{
1284
+ readonly kind: Schema.Literal<"progression.quest">;
1285
+ readonly playerId: Schema.NonEmptyString;
1286
+ readonly poolId: Schema.NonEmptyString;
1287
+ readonly windowId: Schema.NonEmptyString;
1288
+ readonly signal: Schema.Union<readonly [Schema.Struct<{
1289
+ readonly kind: Schema.Literal<"stat">;
1290
+ readonly stat: Schema.NonEmptyString;
1291
+ readonly delta: Schema.String;
1292
+ }>, Schema.Struct<{
1293
+ readonly kind: Schema.Literal<"event">;
1294
+ readonly event: Schema.NonEmptyString;
1295
+ readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1296
+ }>]>;
1297
+ }>, Schema.Struct<{
1298
+ readonly kind: Schema.Literal<"leaderboards.submit">;
1299
+ readonly playerId: Schema.NonEmptyString;
1300
+ readonly board: Schema.NonEmptyString;
1301
+ readonly score: Schema.String;
1302
+ readonly subscore: Schema.optionalKey<Schema.String>;
1303
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1304
+ }>, Schema.Struct<{
1305
+ readonly kind: Schema.Literal<"telemetry.track">;
1306
+ readonly name: Schema.NonEmptyString;
1307
+ readonly playerId: Schema.optionalKey<Schema.NonEmptyString>;
1308
+ readonly properties: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1309
+ }>]>;
1310
+ }>;
1311
+
1312
+ declare type SessionWriteReceipt = typeof SessionWriteReceiptSchema.Type;
1313
+
1314
+ declare const SessionWriteReceiptSchema: Schema.Struct<{
1315
+ readonly eventId: Schema.NonEmptyString;
1316
+ readonly kind: Schema.String;
1317
+ /** The idempotency key the target system received. */
1318
+ readonly requestId: Schema.NonEmptyString;
1319
+ /** Operation or transaction id of the target system; null for telemetry. */
1320
+ readonly operationId: Schema.NullOr<Schema.String>;
1321
+ }>;
1322
+
1323
+ /** The join ticket: the ordinary session HMAC with its own purpose; only its digest is stored. */
1324
+ export declare const signSeatTicket: (claims: SeatClaims, secrets: SessionSecrets, nowMs: number, validUntil: number) => string;
1325
+
1326
+ /** A `serviceAccount` identity naming the credential row; scopes are resolved per call from the pool. */
1327
+ export declare const signServiceToken: (claims: ServiceClaims, secrets: SessionSecrets, nowMs: number, expiresAt: number) => string;
1328
+
1329
+ export declare const tokenDigest: (token: string) => string;
1330
+
1331
+ declare type VerifiedSeat = typeof VerifiedSeatSchema.Type;
1332
+
1333
+ /** What `sessions.verify` hands the engine server for one admitted player. */
1334
+ declare const VerifiedSeatSchema: Schema.Struct<{
1335
+ readonly ticketId: Schema.NonEmptyString;
1336
+ readonly serverId: Schema.NonEmptyString;
1337
+ readonly sessionId: Schema.NonEmptyString;
1338
+ readonly subject: Schema.Struct<{
1339
+ readonly id: Schema.NonEmptyString;
1340
+ readonly type: Schema.Literals<readonly ["user", "apiKey", "serviceAccount"]>;
1341
+ readonly kind: Schema.optionalKey<Schema.Literal<"guest">>;
1342
+ }>;
1343
+ readonly partyId: Schema.NullOr<Schema.NonEmptyString>;
1344
+ readonly team: Schema.NullOr<Schema.NonEmptyString>;
1345
+ readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>;
1346
+ /** True when this ticket was already redeemed and is used again inside the reconnect window. */
1347
+ readonly reconnect: Schema.Boolean;
1348
+ /** The reconnect window of this ticket ends here (epoch ms). */
1349
+ readonly reconnectUntil: Schema.Number;
1350
+ /** True when the session was taken over from a crashed server; a player can arrive before the next heartbeat says so. */
1351
+ readonly recovery: Schema.Boolean;
1352
+ }>;
1353
+
1354
+ export declare const verifySeatTicket: (ticket: string, secrets: SessionSecrets, nowMs: number) => SeatClaims | null;
1355
+
1356
+ export declare const verifyServiceToken: (token: string, secrets: SessionSecrets, nowMs: number) => ServiceClaims | null;
1357
+
1358
+ /**
1359
+ * Idempotency key a target system receives for one server write. `ref.serverId` is the server that STARTED the
1360
+ * session: a recovery server replaying an event id the crashed server already wrote reaches the target with the
1361
+ * same key, so the write lands once.
1362
+ */
1363
+ export declare const writeRequestId: (ref: SessionRef, eventId: string) => string;
1364
+
1365
+ export { }