@voltro/plugin-engine-servers 0.0.0-stage → 0.91.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,1244 @@
1
+ import { Context } from 'effect';
2
+ import { DataStore } from '@voltro/database';
3
+ import { EconomyService } from '@voltro/plugin-economy';
4
+ import { Effect } from 'effect';
5
+ import { HotStoreShape } from '@voltro/kv/hot/contract';
6
+ import { InventoryService } from '@voltro/plugin-inventory';
7
+ import { LeaderboardAdministrationService } from '@voltro/plugin-leaderboards/server';
8
+ import { ProgressionService } from '@voltro/plugin-progression';
9
+ import { QuestService } from '@voltro/plugin-progression';
10
+ import { Schema } from 'effect';
11
+ import { SessionSecrets } from '@voltro/protocol/session';
12
+ import { VoltroPlugin } from '@voltro/protocol';
13
+ import { YieldableError } from 'effect/Cause';
14
+
15
+ /** `unknown` means no provider assessed the player (the port is a no-op without one). */
16
+ export declare const ANTICHEAT_STATUSES: readonly ["verified", "unverified", "violation", "unknown"];
17
+
18
+ export declare type AntiCheatReceipt = typeof AntiCheatReceiptSchema.Type;
19
+
20
+ declare const AntiCheatReceiptSchema: Schema.Struct<{
21
+ readonly playerId: Schema.NonEmptyString;
22
+ readonly status: Schema.Literals<readonly ["verified", "unverified", "violation", "unknown"]>;
23
+ /** False without a provider: nothing is stored. */
24
+ readonly recorded: Schema.Boolean;
25
+ /** True when a violation became a trusted Sanctions signal. */
26
+ readonly signal: Schema.Boolean;
27
+ }>;
28
+
29
+ export declare type AntiCheatReportInput = typeof AntiCheatReportInputSchema.Type;
30
+
31
+ declare const AntiCheatReportInputSchema: Schema.Struct<{
32
+ readonly token: Schema.NonEmptyString;
33
+ readonly sessionId: Schema.NonEmptyString;
34
+ readonly eventId: Schema.NonEmptyString;
35
+ readonly playerId: Schema.NonEmptyString;
36
+ /** What the server-side anti-cheat SDK reported; the configured provider decides the stored status. */
37
+ readonly status: Schema.Literals<readonly ["verified", "unverified", "violation"]>;
38
+ readonly evidence: Schema.optionalKey<Schema.NonEmptyString>;
39
+ }>;
40
+
41
+ export declare type AntiCheatStatus = typeof ANTICHEAT_STATUSES[number];
42
+
43
+ /** One seat of a backfill request. */
44
+ export declare interface BackfillSeat {
45
+ readonly subject: SeatSubject;
46
+ readonly partyId?: string | null;
47
+ readonly team?: string | null;
48
+ readonly attributes?: SeatAttributes;
49
+ }
50
+
51
+ /** One source per pool, so each pool rotates or revokes its bootstrap credential on its own. */
52
+ export declare const bootstrapByPool: (sources: Readonly<Record<string, EngineServerBootstrapSource>>) => EngineServerBootstrapSource;
53
+
54
+ /** Current credential plus an optional previous one, accepted during a rotation. */
55
+ export declare interface BootstrapSecrets {
56
+ readonly current: string;
57
+ readonly previous?: string;
58
+ }
59
+
60
+ export 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
+ export 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
+ /** Declare one engine-server pool. Throws a TypeError on an invalid declaration. */
87
+ export declare const defineEngineServerPool: (input: EngineServerPoolInput) => EngineServerPool;
88
+
89
+ /**
90
+ * Pool declarations are plain, browser-safe data: which engine builds may run,
91
+ * where, how many players one server holds and what its service identity may do.
92
+ * Authority is resolved from this declaration on every request, never signed
93
+ * into a token.
94
+ */
95
+ export declare const ENGINE_KINDS: readonly ["unreal", "unity", "godot", "custom"];
96
+
97
+ /** `servers:register` covers register, heartbeat, drain and deregister of the caller's own server;
98
+ * `sessions:backfill` lets a server ask Matchmaking for players for the free seats of its session;
99
+ * `sessions:lifecycle` reports session and player events; `matches:report` stores one result per session. */
100
+ export declare const ENGINE_SERVER_BASE_SCOPES: readonly ["servers:register", "sessions:verify", "sessions:backfill", "sessions:lifecycle", "matches:report"];
101
+
102
+ /** `recovered`: the server was suspended and another server of its pool took its session over from the latest checkpoint. */
103
+ export declare const ENGINE_SERVER_GONE_REASONS: readonly ["deregistered", "lease_expired", "revoked", "recovered"];
104
+
105
+ /**
106
+ * Accepted lifecycle events. The registry itself records `session.recovering` when it hands a session to a new
107
+ * server; servers never send it. The new server sends `session.recovered` once it restored the checkpoint.
108
+ */
109
+ export declare const ENGINE_SERVER_LIFECYCLE_EVENTS: readonly ["session.started", "player.joined", "player.left", "session.recovering", "session.recovered", "session.ended"];
110
+
111
+ /** States a server can hold a lease in; `suspended` returns to one of them. */
112
+ export declare const ENGINE_SERVER_LIVE_STATES: readonly ["starting", "ready", "allocated", "draining"];
113
+
114
+ export declare const ENGINE_SERVER_POOL_LIMITS: Readonly<{
115
+ builds: 64;
116
+ regions: 64;
117
+ playersPerServer: 4096;
118
+ heartbeatTtlMs: {
119
+ min: number;
120
+ max: number;
121
+ default: number;
122
+ };
123
+ tokenTtlMs: {
124
+ min: number;
125
+ max: number;
126
+ default: number;
127
+ };
128
+ ticketTtlMs: {
129
+ min: number;
130
+ max: number;
131
+ default: number;
132
+ };
133
+ reconnectWindowMs: {
134
+ min: number;
135
+ max: number;
136
+ default: number;
137
+ };
138
+ /** 0 switches resuming off; otherwise at least one heartbeat TTL. */
139
+ resumeWindowMs: {
140
+ min: number;
141
+ max: number;
142
+ default: number;
143
+ };
144
+ /** Writes per server and write kind per minute (HotStore sliding window). */
145
+ writesPerMinute: {
146
+ min: number;
147
+ max: number;
148
+ default: number;
149
+ };
150
+ /** Crash recovery (`recovery`); off unless a pool declares it. */
151
+ recovery: Readonly<{
152
+ /** Suspended this long before another server may take the session over. */
153
+ afterMs: {
154
+ min: number;
155
+ max: number;
156
+ default: number;
157
+ };
158
+ /** How long recovery looks for a free server before the session ends (`lease_expired`). */
159
+ waitMs: {
160
+ min: number;
161
+ max: number;
162
+ default: number;
163
+ };
164
+ /** Largest checkpoint, UTF-8 bytes. */
165
+ checkpointBytes: {
166
+ min: number;
167
+ max: number;
168
+ default: number;
169
+ };
170
+ /** Checkpoint writes per server per minute (HotStore sliding window). */
171
+ checkpointsPerMinute: {
172
+ min: number;
173
+ max: number;
174
+ default: number;
175
+ };
176
+ /** Recoveries of one session; a build that crashes on its own checkpoint stops here. */
177
+ maxRecoveries: {
178
+ min: number;
179
+ max: number;
180
+ default: number;
181
+ };
182
+ }>;
183
+ }>;
184
+
185
+ export declare const ENGINE_SERVER_PROTOCOLS: readonly ["udp", "tcp", "websocket", "webtransport", "quic"];
186
+
187
+ /** Every scope. Write scopes and `anticheat:report` are never granted by default. */
188
+ export 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"];
189
+
190
+ /**
191
+ * `running` after `session.started`; `waiting` while its server is suspended (back to `running` when the server
192
+ * resumes); `recovering` once another server took the session over (back to `running` when that server reports
193
+ * `session.recovered`); `ended` after `session.ended`; `abandoned` when the server left or the session was released without an end.
194
+ */
195
+ export declare const ENGINE_SERVER_SESSION_STATES: readonly ["running", "waiting", "recovering", "ended", "abandoned"];
196
+
197
+ /**
198
+ * `starting → ready → allocated → draining → gone`; `allocated → ready` on release. A server whose lease
199
+ * lapsed in a pool with a resume window is `suspended` until its own process resumes it (back to the state
200
+ * it had), a pool with `recovery` hands its session to another server (`gone`, `recovered`) or the window
201
+ * passes (`gone`, `lease_expired`).
202
+ */
203
+ export declare const ENGINE_SERVER_STATES: readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"];
204
+
205
+ /** `dedicated`: servers the studio runs. `host`: a player hosts the session, so its results are untrusted. */
206
+ export declare const ENGINE_SERVER_TRUST_LEVELS: readonly ["dedicated", "host"];
207
+
208
+ /** Systems an engine server may write to through `engineServers.sessions.write`. Each needs its own scope. */
209
+ export declare const ENGINE_SERVER_WRITE_KINDS: readonly ["inventory", "economy", "progression", "leaderboards", "telemetry"];
210
+
211
+ export declare const ENGINE_SERVER_WRITE_SCOPES: readonly ["writes:inventory", "writes:economy", "writes:progression", "writes:leaderboards", "writes:telemetry"];
212
+
213
+ /** Every refusal of the engine-server contract. Codes are stable wire values. */
214
+ export declare const ENGINE_SERVERS_ERROR_CODES: 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"];
215
+
216
+ export declare type EngineKind = typeof ENGINE_KINDS[number];
217
+
218
+ export declare type EngineServer = typeof EngineServerSchema.Type;
219
+
220
+ export declare type EngineServerActivity = typeof EngineServerActivitySchema.Type;
221
+
222
+ /** "In session" for Presence: where a player plays and whether the session takes more players. */
223
+ declare const EngineServerActivitySchema: Schema.Struct<{
224
+ readonly serverId: Schema.NonEmptyString;
225
+ readonly pool: Schema.NonEmptyString;
226
+ readonly sessionId: Schema.NonEmptyString;
227
+ /** Joined and not left, as the server reported it. */
228
+ readonly connected: Schema.Boolean;
229
+ /** The session runs on an `allocated` server of a pool with `sessions:backfill` and has a free seat. */
230
+ readonly joinable: Schema.Boolean;
231
+ readonly freeSeats: Schema.Number;
232
+ }>;
233
+
234
+ /** What the provider decided for one report. `confidence` (0 to 1) goes to Sanctions with a violation. */
235
+ export declare interface EngineServerAntiCheatAssessment {
236
+ readonly status: Exclude<AntiCheatStatus, 'unknown'>;
237
+ readonly confidence: number;
238
+ }
239
+
240
+ /**
241
+ * Port for a client anti-cheat vendor. Voltro ships no client anti-cheat; without a provider
242
+ * `engineServers.anticheat.report` is a no-op that stores nothing.
243
+ */
244
+ export declare interface EngineServerAntiCheatProvider {
245
+ /** Stored with the status, e.g. `eac`. Lowercase letters, digits and dashes. */
246
+ readonly name: string;
247
+ readonly assess: (report: EngineServerAntiCheatReport) => Effect.Effect<EngineServerAntiCheatAssessment, unknown>;
248
+ }
249
+
250
+ export declare interface EngineServerAntiCheatReport {
251
+ readonly tenantId: string;
252
+ readonly subjectId: string;
253
+ readonly serverId: string;
254
+ readonly pool: string;
255
+ readonly sessionId: string;
256
+ /** What the server-side anti-cheat SDK reported. */
257
+ readonly reported: Exclude<AntiCheatStatus, 'unknown'>;
258
+ readonly evidence: string | null;
259
+ }
260
+
261
+ /** What a bootstrap source proves about a presented credential: which tenant's pool it may join. */
262
+ export declare interface EngineServerBootstrapGrant {
263
+ readonly tenantId: string;
264
+ }
265
+
266
+ /**
267
+ * Port: turns a bootstrap credential an engine server presents into a pool grant.
268
+ * `null` means "not a credential of this pool" (callers receive `unauthenticated`).
269
+ * A managed platform supplies its own source; `staticBootstrapSource` reads a project secret.
270
+ */
271
+ export declare interface EngineServerBootstrapSource {
272
+ readonly name: string;
273
+ readonly verify: (input: {
274
+ readonly pool: string;
275
+ readonly credential: string;
276
+ }) => Effect.Effect<EngineServerBootstrapGrant | null, EngineServersError>;
277
+ /** Called while the plugin binds; throws when a required secret is missing so boot fails. */
278
+ readonly check?: () => void;
279
+ }
280
+
281
+ /** The installed economy plugin (`economyPlugin(...)`) or anything with its trusted transfer. */
282
+ export declare interface EngineServerEconomySource {
283
+ readonly economy: {
284
+ readonly service: () => Pick<EconomyService, 'transfer'>;
285
+ };
286
+ }
287
+
288
+ export declare type EngineServerGoneReason = typeof ENGINE_SERVER_GONE_REASONS[number];
289
+
290
+ /** The installed inventory plugin (`inventoryPlugin(...)`) or anything with its trusted grant and consume. */
291
+ export declare interface EngineServerInventorySource {
292
+ readonly inventory: {
293
+ readonly service: () => Pick<InventoryService, 'grant' | 'consume'>;
294
+ };
295
+ }
296
+
297
+ /** The installed leaderboards plugin: service-only submissions and rating matches. */
298
+ export declare interface EngineServerLeaderboardsSource {
299
+ readonly leaderboards: {
300
+ readonly service: () => Pick<LeaderboardAdministrationService, 'submit' | 'prepareRatingMatch' | 'applyRatingMatch'>;
301
+ };
302
+ }
303
+
304
+ export declare type EngineServerLifecycleEventType = typeof ENGINE_SERVER_LIFECYCLE_EVENTS[number];
305
+
306
+ export declare type EngineServerLiveState = typeof ENGINE_SERVER_LIVE_STATES[number];
307
+
308
+ /**
309
+ * Port for a fleet orchestrator (Agones, a Cloud fleet, a custom scaler). It starts servers; they still join the
310
+ * pool through `authenticate` + `register`, so a started server is only reserved once it reports `ready`.
311
+ * The framework ships no vendor implementation.
312
+ */
313
+ export declare interface EngineServerOrchestrator {
314
+ readonly requestServer: (request: EngineServerRequest) => Effect.Effect<void, unknown>;
315
+ }
316
+
317
+ export declare interface EngineServerPool {
318
+ readonly name: string;
319
+ readonly engine: EngineKind;
320
+ readonly trust: EngineServerTrust;
321
+ readonly builds: ReadonlyArray<string>;
322
+ readonly regions: ReadonlyArray<string>;
323
+ readonly capacity: {
324
+ readonly players: number;
325
+ };
326
+ readonly scopes: ReadonlyArray<EngineServerScope>;
327
+ readonly writeLimits: Readonly<Record<EngineServerWriteKind, EngineServerWriteLimit>>;
328
+ readonly protocols: ReadonlyArray<EngineServerProtocol>;
329
+ readonly heartbeatTtlMs: number;
330
+ readonly tokenTtlMs: number;
331
+ readonly ticketTtlMs: number;
332
+ readonly reconnectWindowMs: number;
333
+ readonly resumeWindowMs: number;
334
+ /** Null: sessions of this pool are never recovered on another server. */
335
+ readonly recovery: EngineServerRecovery | null;
336
+ }
337
+
338
+ export declare interface EngineServerPoolInput {
339
+ /** Pool identity, e.g. `arena-eu`. Lowercase, digits and dashes. */
340
+ readonly name: string;
341
+ readonly engine: EngineKind;
342
+ /** Build ids a server may register with. A server reporting any other build is refused. */
343
+ readonly builds: ReadonlyArray<string>;
344
+ readonly regions: ReadonlyArray<string>;
345
+ /** Upper bound per server; a server may register with less. */
346
+ readonly capacity: {
347
+ readonly players: number;
348
+ };
349
+ /** Default `dedicated`. A `host` pool marks every result untrusted and may not declare value-writing scopes. */
350
+ readonly trust?: EngineServerTrust;
351
+ /** What a server of this pool may do. Default: the base scopes; write scopes and `anticheat:report` only when listed. */
352
+ readonly scopes?: ReadonlyArray<EngineServerScope>;
353
+ /** Rate and plausibility limits per write kind. */
354
+ readonly writeLimits?: Readonly<Partial<Record<EngineServerWriteKind, EngineServerWriteLimitInput>>>;
355
+ /** Transports a server may announce. Default: every protocol. */
356
+ readonly protocols?: ReadonlyArray<EngineServerProtocol>;
357
+ /** A server that misses its heartbeat for this long is gone. Default 30 s: a single API process may
358
+ * then take up to 19 s from exiting to being ready again (TTL − TTL/3 − the host's 1 s retry) without
359
+ * ending a session. Lower is faster dead-server detection, higher survives slower restarts. */
360
+ readonly heartbeatTtlMs?: number;
361
+ /** Lifetime of a service token. Default 1 h; heartbeats renew it. */
362
+ readonly tokenTtlMs?: number;
363
+ /** How long a join ticket may wait before its first redemption. Default 60 s. */
364
+ readonly ticketTtlMs?: number;
365
+ /** How long a redeemed ticket stays valid for reconnects to the same server. Default 30 s. */
366
+ readonly reconnectWindowMs?: number;
367
+ /**
368
+ * How long a server whose lease lapsed (an API or HotStore outage longer than `heartbeatTtlMs`) stays
369
+ * `suspended` and may resume its own session, counted from the lease's end. Its seats stay held, nothing is
370
+ * written for it and matchmaking sends it nobody; only the process holding the lease proof `register` gave it
371
+ * resumes. Default 5 min, at most 30 min, at least `heartbeatTtlMs`; 0 ends the session at once (`lease_lost`).
372
+ */
373
+ readonly resumeWindowMs?: number;
374
+ /**
375
+ * Crash recovery, off by default. A suspended server's session moves to another `ready` server of this pool
376
+ * (same region, enough capacity) once the server stayed suspended for `afterMs`, if the session has a
377
+ * checkpoint (`engineServers.sessions.checkpoint`). The new server continues from the latest checkpoint and
378
+ * becomes the only authority; the old one's proof, token and tickets stop working. Needs a resume window
379
+ * (`afterMs + waitMs` must fit in it) and a `dedicated` pool: a player-run host is not trusted to hand a session on.
380
+ * Omitted or null: off.
381
+ */
382
+ readonly recovery?: EngineServerRecoveryInput | null;
383
+ }
384
+
385
+ /** The installed progression plugin: XP, stats and quest signals. */
386
+ export declare interface EngineServerProgressionSource {
387
+ readonly progression: {
388
+ readonly service: () => Pick<ProgressionService, 'applyXp' | 'applyStat'>;
389
+ readonly quests: () => Pick<QuestService, 'record'>;
390
+ };
391
+ }
392
+
393
+ export declare type EngineServerProtocol = typeof ENGINE_SERVER_PROTOCOLS[number];
394
+
395
+ export declare interface EngineServerRecovery {
396
+ readonly afterMs: number;
397
+ readonly waitMs: number;
398
+ readonly checkpointBytes: number;
399
+ readonly checkpointsPerMinute: number;
400
+ readonly maxRecoveries: number;
401
+ }
402
+
403
+ export declare interface EngineServerRecoveryInput {
404
+ /** Suspended this long before recovery starts; until then only the original process may resume. Default 30 s. */
405
+ readonly afterMs?: number;
406
+ /** How long recovery looks for a free server before the session ends like a lost lease. Default 60 s. */
407
+ readonly waitMs?: number;
408
+ /** Largest checkpoint in UTF-8 bytes. Default 64 KiB, at most 1 MiB. */
409
+ readonly checkpointBytes?: number;
410
+ /** Checkpoint writes per server per minute. Default 60. */
411
+ readonly checkpointsPerMinute?: number;
412
+ /** How often one session may be recovered. Default 3. */
413
+ readonly maxRecoveries?: number;
414
+ }
415
+
416
+ /** The trusted server-side surface. Engine servers reach the routed half through RPC. */
417
+ declare interface EngineServerRegistry extends EngineServerSessionAuthority {
418
+ readonly authenticate: (input: {
419
+ readonly pool: string;
420
+ readonly credential: string;
421
+ }) => Effect.Effect<ServiceToken, EngineServersError>;
422
+ readonly register: (input: RegisterInput) => Effect.Effect<RegisterOutput, EngineServersError>;
423
+ /**
424
+ * Give a `suspended` server (or one whose lease lapsed unnoticed) back to the process that registered it, inside
425
+ * the pool's resume window: a fresh pool token plus the lease proof `register` returned. Same server, session,
426
+ * seats and tickets; the run continues. `lease_lost` once the server is gone, the window passed or the proof differs.
427
+ */
428
+ readonly resume: (input: ResumeInput) => Effect.Effect<ResumeOutput, EngineServersError>;
429
+ readonly heartbeat: (input: {
430
+ readonly token: string;
431
+ readonly ready?: boolean;
432
+ }) => Effect.Effect<HeartbeatOutput, EngineServersError>;
433
+ readonly drainSelf: (input: {
434
+ readonly token: string;
435
+ }) => Effect.Effect<EngineServer, EngineServersError>;
436
+ readonly deregister: (input: {
437
+ readonly token: string;
438
+ }) => Effect.Effect<void, EngineServersError>;
439
+ readonly verifySeat: (input: {
440
+ readonly token: string;
441
+ readonly ticket: string;
442
+ }) => Effect.Effect<VerifiedSeat, EngineServersError>;
443
+ /** Authenticate a server token with `sessions:backfill` and return the session the `allocated` server holds. */
444
+ readonly authorizeSession: (input: {
445
+ readonly token: string;
446
+ }) => Effect.Effect<EngineServerSession, EngineServersError>;
447
+ readonly issueTicket: (input: IssueTicketInput) => Effect.Effect<IssuedTicket, EngineServersError>;
448
+ /** Supersede a ticket and issue a follow-up for the same seat while its server still holds the session. */
449
+ readonly reissueTicket: (input: {
450
+ readonly tenantId: string;
451
+ readonly ticketId: string;
452
+ }) => Effect.Effect<IssuedTicket, EngineServersError>;
453
+ readonly revokeTicket: (input: {
454
+ readonly tenantId: string;
455
+ readonly ticketId: string;
456
+ }) => Effect.Effect<boolean, EngineServersError>;
457
+ /**
458
+ * Issue the tickets of one backfill request in one transaction, fenced by the server row's `version`:
459
+ * all seats fit the session's free seats or none is issued (`no_capacity`), and a repeated `requestKey` is not seated twice.
460
+ */
461
+ readonly seatBackfill: (input: SeatBackfillInput) => Effect.Effect<SeatedBackfill, EngineServersError>;
462
+ /**
463
+ * Free the seats of a backfill request nobody recorded: when the key's tickets are all still unused after
464
+ * {@link BACKFILL_RECORD_MS}, revoke them and forget the key, so a repeat of the request seats again.
465
+ * Returns how many held seats it freed (expired tickets no longer held one); 0 when the key is absent, too
466
+ * young or one of its tickets was used, and then the key stays.
467
+ */
468
+ readonly reclaimBackfill: (input: ServerRef & {
469
+ readonly sessionId: string;
470
+ readonly requestKey: string;
471
+ }) => Effect.Effect<number, EngineServersError>;
472
+ /**
473
+ * Revoke a backfill request's tickets and forget its key, so a retry can seat again. With `ticketIds`, only
474
+ * when the key still holds exactly those tickets (a later seating of the key stays). False when nothing was withdrawn.
475
+ */
476
+ readonly withdrawBackfill: (input: ServerRef & {
477
+ readonly sessionId: string;
478
+ readonly requestKey: string;
479
+ readonly ticketIds?: ReadonlyArray<string>;
480
+ }) => Effect.Effect<boolean, EngineServersError>;
481
+ /** Atomically move one live `ready` server to `allocated` for a session. Idempotent per session. */
482
+ readonly reserve: (input: ReserveInput) => Effect.Effect<EngineServer, EngineServersError>;
483
+ /** End a session on a server: `allocated → ready`, `draining` stays. Outstanding tickets are revoked. */
484
+ readonly release: (input: ServerRef & {
485
+ readonly sessionId: string;
486
+ }) => Effect.Effect<EngineServer, EngineServersError>;
487
+ readonly drain: (input: ServerRef) => Effect.Effect<EngineServer, EngineServersError>;
488
+ readonly revokeServer: (input: ServerRef) => Effect.Effect<boolean, EngineServersError>;
489
+ /** Revoke every token of a pool and remove its servers. Rotate the bootstrap secret to stop new ones. */
490
+ readonly revokePool: (input: {
491
+ readonly tenantId: string;
492
+ readonly pool: string;
493
+ }) => Effect.Effect<number, EngineServersError>;
494
+ readonly get: (input: ServerRef) => Effect.Effect<EngineServer | null, EngineServersError>;
495
+ readonly list: (input: {
496
+ readonly tenantId: string;
497
+ readonly pool?: string;
498
+ readonly states?: ReadonlyArray<EngineServerState>;
499
+ readonly limit?: number;
500
+ }) => Effect.Effect<ReadonlyArray<EngineServer>, EngineServersError>;
501
+ /**
502
+ * Free the seats these join tickets hold in sessions whose server is `suspended` (the player searched again or left
503
+ * the match): revokes them, so the seat is free and the ticket no longer admits. Returns how many it freed. Tickets of
504
+ * live servers, ended sessions or unknown ids are left alone: a live server reports its own players.
505
+ */
506
+ readonly vacateWaitingSeats: (input: {
507
+ readonly tenantId: string;
508
+ readonly ticketIds: ReadonlyArray<string>;
509
+ }) => Effect.Effect<number, EngineServersError>;
510
+ /**
511
+ * Suspend servers whose lease expired (or mark them `gone` when their pool has no resume window) and end suspended
512
+ * servers whose window passed; returns how many changed. Runs lazily on register/reserve too.
513
+ */
514
+ readonly sweep: (input?: {
515
+ readonly tenantId?: string;
516
+ readonly pool?: string;
517
+ }) => Effect.Effect<number, EngineServersError>;
518
+ /**
519
+ * A trusted caller (operator tooling, the orchestrator that saw the process exit) reports a server's process is gone.
520
+ * The lease is dropped at once, so the server is suspended (or gone without a resume window) instead of waiting out its
521
+ * TTL, and a pool with `recovery` hands its session over without waiting `afterMs`. Never routed: a server credential
522
+ * cannot report another server dead. False when the server was already gone.
523
+ */
524
+ readonly reportExit: (input: ServerRef) => Effect.Effect<boolean, EngineServersError>;
525
+ readonly exportSubject: (input: {
526
+ readonly tenantId: string;
527
+ readonly subjectId: string;
528
+ }) => Effect.Effect<EngineServerSubjectExport, EngineServersError>;
529
+ readonly eraseSubject: (input: {
530
+ readonly tenantId: string;
531
+ readonly subjectId: string;
532
+ }) => Effect.Effect<void, EngineServersError>;
533
+ }
534
+
535
+ export declare type EngineServerReport = typeof EngineServerReportSchema.Type;
536
+
537
+ declare const EngineServerReportSchema: Schema.Struct<{
538
+ readonly reportId: Schema.NonEmptyString;
539
+ readonly serverId: Schema.NonEmptyString;
540
+ readonly pool: Schema.NonEmptyString;
541
+ readonly sessionId: Schema.NonEmptyString;
542
+ readonly trust: Schema.Literals<readonly ["dedicated", "host"]>;
543
+ readonly trusted: Schema.Boolean;
544
+ readonly outcome: Schema.Literals<readonly ["completed", "aborted"]>;
545
+ readonly standings: Schema.$Array<Schema.Struct<{
546
+ readonly playerId: Schema.NullOr<Schema.NonEmptyString>;
547
+ readonly rank: Schema.Number;
548
+ readonly team: Schema.NullOr<Schema.NonEmptyString>;
549
+ readonly score: Schema.NullOr<Schema.String>;
550
+ }>>;
551
+ readonly stats: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>;
552
+ readonly digest: Schema.NonEmptyString;
553
+ readonly reportedAt: Schema.Number;
554
+ }>;
555
+
556
+ /** What Matchmaking asks an orchestrator for when no `ready` server matches. */
557
+ export declare interface EngineServerRequest {
558
+ readonly tenantId: string;
559
+ readonly pool: string;
560
+ readonly region: string | null;
561
+ readonly labels: Readonly<Record<string, string>>;
562
+ /** Seats the waiting proposal needs. */
563
+ readonly players: number;
564
+ /** Stable per proposal: a retry of the same proposal repeats this id, so the request must be idempotent per id. */
565
+ readonly requestId: string;
566
+ }
567
+
568
+ /** One registered server as the registry reports it. Carries no lease or credential. */
569
+ declare const EngineServerSchema: Schema.Struct<{
570
+ readonly id: Schema.NonEmptyString;
571
+ readonly pool: Schema.NonEmptyString;
572
+ readonly region: Schema.NonEmptyString;
573
+ readonly buildId: Schema.NonEmptyString;
574
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
575
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
576
+ readonly port: Schema.NullOr<Schema.Number>;
577
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
578
+ readonly capacity: Schema.Number;
579
+ readonly labels: Schema.$Record<Schema.String, Schema.String>;
580
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
581
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
582
+ readonly registeredAt: Schema.Number;
583
+ readonly lastHeartbeatAt: Schema.Number;
584
+ readonly stateChangedAt: Schema.Number;
585
+ readonly goneReason: Schema.NullOr<Schema.Literals<readonly ["deregistered", "lease_expired", "revoked", "recovered"]>>;
586
+ }>;
587
+
588
+ export declare type EngineServerScope = typeof ENGINE_SERVER_SCOPES[number];
589
+
590
+ /**
591
+ * `lease_suspended`: the server's lease lapsed and the server waits inside its pool's resume window; only its own
592
+ * process resumes it (`engineServers.resume`). `rejected` carries the refusing system's own error code in `reason` (for example `insufficient_funds`).
593
+ */
594
+ export declare class EngineServersError extends EngineServersError_base {
595
+ }
596
+
597
+ declare const EngineServersError_base: Schema.Class<EngineServersError, Schema.TaggedStruct<"EngineServersError", {
598
+ 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"]>;
599
+ readonly reason: Schema.optionalKey<Schema.String>;
600
+ }>, YieldableError>;
601
+
602
+ export declare type EngineServersErrorCode = typeof ENGINE_SERVERS_ERROR_CODES[number];
603
+
604
+ /** The session an engine server holds, as its own service token proves it. */
605
+ export declare interface EngineServerSession {
606
+ readonly tenantId: string;
607
+ readonly serverId: string;
608
+ readonly pool: string;
609
+ readonly sessionId: string;
610
+ readonly capacity: number;
611
+ /** Seats still taken: issued tickets before their redeem-by, redeemed ones not left or inside the reconnect window. */
612
+ readonly seated: number;
613
+ readonly connect: IssuedTicket['connect'];
614
+ }
615
+
616
+ /** The server-authored half of a session: lifecycle, writes, result and anti-cheat status. */
617
+ declare interface EngineServerSessionAuthority {
618
+ readonly event: (input: SessionEventInput) => Effect.Effect<SessionEventReceipt, EngineServersError>;
619
+ readonly write: (input: SessionWriteInput) => Effect.Effect<SessionWriteReceipt, EngineServersError>;
620
+ readonly report: (input: MatchReportInput) => Effect.Effect<MatchReportReceipt, EngineServersError>;
621
+ readonly antiCheat: (input: AntiCheatReportInput) => Effect.Effect<AntiCheatReceipt, EngineServersError>;
622
+ readonly getReport: (input: SessionRef) => Effect.Effect<EngineServerReport | null, EngineServersError>;
623
+ readonly antiCheatStatus: (input: {
624
+ readonly tenantId: string;
625
+ readonly subjectId: string;
626
+ }) => Effect.Effect<{
627
+ readonly status: AntiCheatStatus;
628
+ readonly provider: string | null;
629
+ readonly updatedAt: number | null;
630
+ }, EngineServersError>;
631
+ readonly activity: (input: {
632
+ readonly tenantId: string;
633
+ readonly subjectId: string;
634
+ }) => Effect.Effect<EngineServerActivity | null, EngineServersError>;
635
+ /** Store the session's latest checkpoint: fenced on the server row, monotonic by `revision`, bounded by the pool's `recovery`. */
636
+ readonly checkpoint: (input: CheckpointInput) => Effect.Effect<CheckpointReceipt, EngineServersError>;
637
+ /** What a recovery server continues from; only the server that now holds a recovered session reads it. */
638
+ readonly recovery: (input: RecoveryInput) => Effect.Effect<Recovery, EngineServersError>;
639
+ }
640
+
641
+ /** A session recovery moved to another server, as the handover transaction committed it. Carries no ticket or token. */
642
+ export declare interface EngineServerSessionMove {
643
+ readonly tenantId: string;
644
+ readonly pool: string;
645
+ readonly sessionId: string;
646
+ /** The crashed server, now `gone` (`recovered`). */
647
+ readonly from: string;
648
+ /** The server that runs the session now. */
649
+ readonly serverId: string;
650
+ readonly connect: IssuedTicket['connect'];
651
+ /** Every kept seat: the crashed server's ticket id and the new server's; `reissueTicket(to)` mints the player's follow-up ticket. */
652
+ readonly seats: ReadonlyArray<{
653
+ readonly subjectId: string;
654
+ readonly from: string;
655
+ readonly to: string;
656
+ }>;
657
+ }
658
+
659
+ /** Runs inside the handover transaction with its `write` store, so a seat record moves together with the session or not at all. */
660
+ export declare type EngineServerSessionMoveListener = (write: DataStore, move: EngineServerSessionMove) => Promise<void>;
661
+
662
+ export declare type EngineServerSessionState = typeof ENGINE_SERVER_SESSION_STATES[number];
663
+
664
+ /** The trusted half of the registry: what app code (and S2's allocator) calls. Engine servers use the RPC routes. */
665
+ export declare type EngineServersFacade = Pick<EngineServerRegistry, 'authorizeSession' | 'issueTicket' | 'reissueTicket' | 'revokeTicket' | 'reserve' | 'release' | 'drain' | 'revokeServer' | 'revokePool' | 'get' | 'list' | 'sweep' | 'seatBackfill' | 'reclaimBackfill' | 'withdrawBackfill' | 'vacateWaitingSeats' | 'getReport' | 'antiCheatStatus' | 'activity' | 'reportExit'> & {
666
+ /**
667
+ * Run `listener` inside every crash-recovery handover transaction (Matchmaking moves its seat records there). A
668
+ * failing listener rolls the handover back; the next sweep retries. Returns the unsubscribe function.
669
+ */
670
+ readonly onSessionMoved: (listener: EngineServerSessionMoveListener) => () => void;
671
+ };
672
+
673
+ export declare interface EngineServersPlugin extends VoltroPlugin {
674
+ /** Trusted server facade (tickets, reservation, drain, revocation). Never a client route. */
675
+ readonly engineServers: EngineServersFacade;
676
+ }
677
+
678
+ /** Engine-neutral service identity, server registry and single-use join tickets for authoritative engine servers. */
679
+ export declare const engineServersPlugin: (options: EngineServersPluginOptions) => EngineServersPlugin;
680
+
681
+ export declare interface EngineServersPluginOptions {
682
+ /** Pools from `defineEngineServerPool`; names are unique. */
683
+ readonly pools: ReadonlyArray<EngineServerPool>;
684
+ /** Verifies bootstrap credentials (`staticBootstrapSource`, `bootstrapByPool` or a platform source). */
685
+ readonly bootstrap: EngineServerBootstrapSource;
686
+ /** Signs service tokens. Read at bind (a missing secret fails boot) and on every call. */
687
+ readonly tokenSecrets: () => SessionSecrets;
688
+ /** Signs join tickets; a different secret than `tokenSecrets`. */
689
+ readonly ticketSecrets: () => SessionSecrets;
690
+ readonly now?: () => number;
691
+ /**
692
+ * Installed systems a pool with `writes:<kind>` writes through (`inventory`, `economy` with its system
693
+ * account, `progression`, `leaderboards`). Telemetry goes to the app's analytics sink and needs none.
694
+ */
695
+ readonly writes?: EngineServerWriteSources;
696
+ /** Anti-cheat vendor port; omit it and `anticheat.report` is a no-op. Voltro ships no client anti-cheat. */
697
+ readonly antiCheat?: EngineServerAntiCheatProvider;
698
+ /** Fixture seam: use this HotStore instead of the app's. Refused when the process reports replicas. */
699
+ readonly hotStore?: HotStoreShape;
700
+ }
701
+
702
+ export declare class EngineServersPort extends EngineServersPort_base {
703
+ }
704
+
705
+ declare const EngineServersPort_base: Context.ServiceClass<EngineServersPort, "@voltro/EngineServersPort", EngineServersFacade>;
706
+
707
+ export declare type EngineServerState = typeof ENGINE_SERVER_STATES[number];
708
+
709
+ /** A subject's engine-server records, as the privacy export returns them. */
710
+ declare interface EngineServerSubjectExport {
711
+ readonly engineServerTickets: ReadonlyArray<Record<string, unknown>>;
712
+ readonly engineServerSessionEvents: ReadonlyArray<Record<string, unknown>>;
713
+ readonly engineServerReports: ReadonlyArray<Record<string, unknown>>;
714
+ readonly engineServerAntiCheat: Record<string, unknown> | null;
715
+ }
716
+
717
+ export declare type EngineServerTrust = typeof ENGINE_SERVER_TRUST_LEVELS[number];
718
+
719
+ export declare type EngineServerWriteKind = typeof ENGINE_SERVER_WRITE_KINDS[number];
720
+
721
+ export declare interface EngineServerWriteLimit {
722
+ readonly perMinute: number;
723
+ readonly maxAmount: number | null;
724
+ }
725
+
726
+ export declare interface EngineServerWriteLimitInput {
727
+ /** Writes per server per minute. Default 600. */
728
+ readonly perMinute?: number;
729
+ /** Largest amount one write may carry (item quantity, currency amount, XP, stat operand, absolute score). No extra cap when omitted or null. */
730
+ readonly maxAmount?: number | null;
731
+ }
732
+
733
+ /**
734
+ * Systems an engine server writes through. Each write still needs the pool scope (`writes:<kind>`);
735
+ * the target system keeps its own validation and idempotency. Telemetry needs no source: it goes to
736
+ * the app's analytics sink.
737
+ */
738
+ export declare interface EngineServerWriteSources {
739
+ readonly inventory?: EngineServerInventorySource;
740
+ /** Currency grants are paid from, and charges paid into, this system account. */
741
+ readonly economy?: {
742
+ readonly plugin: EngineServerEconomySource;
743
+ readonly systemAccount: string;
744
+ };
745
+ readonly progression?: EngineServerProgressionSource;
746
+ readonly leaderboards?: EngineServerLeaderboardsSource;
747
+ }
748
+
749
+ export declare type HeartbeatOutput = typeof HeartbeatOutputSchema.Type;
750
+
751
+ declare const HeartbeatOutputSchema: Schema.Struct<{
752
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
753
+ readonly drain: Schema.Boolean;
754
+ readonly heartbeatIntervalMs: Schema.Number;
755
+ /** A fresh service token once the current one has used half its lifetime; switch to it. */
756
+ readonly renewed: Schema.NullOr<Schema.Struct<{
757
+ readonly token: Schema.NonEmptyString;
758
+ readonly expiresAt: Schema.Number;
759
+ }>>;
760
+ /** The session the server is allocated to; null while `ready`. */
761
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
762
+ /** True when `sessionId` was taken over from a crashed server: read `engineServers.sessions.recovery` before anything else. */
763
+ readonly recovery: Schema.Boolean;
764
+ }>;
765
+
766
+ export declare type IssuedTicket = typeof IssuedTicketSchema.Type;
767
+
768
+ declare const IssuedTicketSchema: Schema.Struct<{
769
+ readonly ticket: Schema.NonEmptyString;
770
+ readonly ticketId: Schema.NonEmptyString;
771
+ readonly serverId: Schema.NonEmptyString;
772
+ readonly redeemBy: Schema.Number;
773
+ readonly connect: Schema.Struct<{
774
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
775
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
776
+ readonly port: Schema.NullOr<Schema.Number>;
777
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
778
+ }>;
779
+ }>;
780
+
781
+ export declare interface IssueTicketInput {
782
+ readonly tenantId: string;
783
+ readonly serverId: string;
784
+ readonly sessionId: string;
785
+ readonly subject: SeatSubject;
786
+ readonly partyId?: string | null;
787
+ readonly team?: string | null;
788
+ readonly attributes?: SeatAttributes;
789
+ }
790
+
791
+ export declare type LifecycleEvent = typeof LifecycleEventSchema.Type;
792
+
793
+ /** Ordered per session: `session.started` is sequence 1, every next event is the previous sequence + 1. */
794
+ declare const LifecycleEventSchema: Schema.Union<readonly [Schema.Struct<{
795
+ readonly type: Schema.Literal<"session.started">;
796
+ }>, Schema.Struct<{
797
+ readonly type: Schema.Literal<"player.joined">;
798
+ readonly playerId: Schema.NonEmptyString;
799
+ }>, Schema.Struct<{
800
+ readonly type: Schema.Literal<"player.left">;
801
+ readonly playerId: Schema.NonEmptyString;
802
+ readonly reconnect: Schema.optionalKey<Schema.Boolean>;
803
+ }>, Schema.Struct<{
804
+ readonly type: Schema.Literal<"session.recovered">;
805
+ }>, Schema.Struct<{
806
+ readonly type: Schema.Literal<"session.ended">;
807
+ readonly reason: Schema.optionalKey<Schema.NonEmptyString>;
808
+ }>]>;
809
+
810
+ export declare type MatchReportInput = typeof MatchReportInputSchema.Type;
811
+
812
+ declare const MatchReportInputSchema: Schema.Struct<{
813
+ readonly token: Schema.NonEmptyString;
814
+ readonly sessionId: Schema.NonEmptyString;
815
+ readonly outcome: Schema.Literals<readonly ["completed", "aborted"]>;
816
+ readonly standings: Schema.$Array<Schema.Struct<{
817
+ readonly playerId: Schema.NonEmptyString;
818
+ readonly rank: Schema.Number;
819
+ readonly team: Schema.optionalKey<Schema.NonEmptyString>;
820
+ readonly score: Schema.optionalKey<Schema.String>;
821
+ }>>;
822
+ readonly stats: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
823
+ /** Apply the standings to this Leaderboards rating pool. Needs `writes:leaderboards`, a completed outcome and a `dedicated` pool. */
824
+ readonly ratings: Schema.optionalKey<Schema.Struct<{
825
+ readonly pool: Schema.NonEmptyString;
826
+ }>>;
827
+ }>;
828
+
829
+ export declare type MatchReportReceipt = typeof MatchReportReceiptSchema.Type;
830
+
831
+ declare const MatchReportReceiptSchema: Schema.Struct<{
832
+ readonly reportId: Schema.NonEmptyString;
833
+ readonly sessionId: Schema.NonEmptyString;
834
+ /** False for a `host` pool: the result is stored for display and review, never applied to ratings. */
835
+ readonly trusted: Schema.Boolean;
836
+ readonly digest: Schema.NonEmptyString;
837
+ readonly replay: Schema.Boolean;
838
+ readonly ratings: Schema.Literals<readonly ["applied", "skipped"]>;
839
+ }>;
840
+
841
+ export declare type MatchStanding = typeof MatchStandingSchema.Type;
842
+
843
+ declare const MatchStandingSchema: Schema.Struct<{
844
+ readonly playerId: Schema.NonEmptyString;
845
+ readonly rank: Schema.Number;
846
+ readonly team: Schema.optionalKey<Schema.NonEmptyString>;
847
+ readonly score: Schema.optionalKey<Schema.String>;
848
+ }>;
849
+
850
+ export declare type Recovery = typeof RecoverySchema.Type;
851
+
852
+ export declare type RecoveryInput = typeof RecoveryInputSchema.Type;
853
+
854
+ declare const RecoveryInputSchema: Schema.Struct<{
855
+ readonly token: Schema.NonEmptyString;
856
+ readonly sessionId: Schema.NonEmptyString;
857
+ }>;
858
+
859
+ /** What a recovery server continues from: the session's last accepted lifecycle sequence and its latest checkpoint. */
860
+ declare const RecoverySchema: Schema.Struct<{
861
+ readonly sessionId: Schema.NonEmptyString;
862
+ /** The last accepted lifecycle sequence (the registry's `session.recovering`); the next event uses this + 1. */
863
+ readonly sequence: Schema.Number;
864
+ /** How often this session was recovered, this time included. */
865
+ readonly recoveries: Schema.Number;
866
+ readonly checkpoint: Schema.Struct<{
867
+ readonly revision: Schema.Number;
868
+ readonly schemaVersion: Schema.Number;
869
+ readonly data: Schema.String;
870
+ readonly writtenAt: Schema.Number;
871
+ }>;
872
+ }>;
873
+
874
+ export declare type RegisterInput = typeof RegisterInputSchema.Type;
875
+
876
+ declare const RegisterInputSchema: Schema.Struct<{
877
+ readonly token: Schema.NonEmptyString;
878
+ readonly region: Schema.NonEmptyString;
879
+ readonly buildId: Schema.NonEmptyString;
880
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
881
+ readonly address: Schema.optionalKey<Schema.NonEmptyString>;
882
+ readonly port: Schema.optionalKey<Schema.Number>;
883
+ readonly relay: Schema.optionalKey<Schema.NonEmptyString>;
884
+ readonly capacity: Schema.optionalKey<Schema.Number>;
885
+ readonly labels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
886
+ }>;
887
+
888
+ export declare type RegisterOutput = typeof RegisterOutputSchema.Type;
889
+
890
+ declare const RegisterOutputSchema: Schema.Struct<{
891
+ readonly server: Schema.Struct<{
892
+ readonly id: Schema.NonEmptyString;
893
+ readonly pool: Schema.NonEmptyString;
894
+ readonly region: Schema.NonEmptyString;
895
+ readonly buildId: Schema.NonEmptyString;
896
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
897
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
898
+ readonly port: Schema.NullOr<Schema.Number>;
899
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
900
+ readonly capacity: Schema.Number;
901
+ readonly labels: Schema.$Record<Schema.String, Schema.String>;
902
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
903
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
904
+ readonly registeredAt: Schema.Number;
905
+ readonly lastHeartbeatAt: Schema.Number;
906
+ readonly stateChangedAt: Schema.Number;
907
+ readonly goneReason: Schema.NullOr<Schema.Literals<readonly ["deregistered", "lease_expired", "revoked", "recovered"]>>;
908
+ }>;
909
+ readonly token: Schema.NonEmptyString;
910
+ readonly expiresAt: Schema.Number;
911
+ readonly heartbeatIntervalMs: Schema.Number;
912
+ /** Keep it in memory only and never log it: `engineServers.resume` needs it after a suspension. */
913
+ readonly lease: Schema.NonEmptyString;
914
+ }>;
915
+
916
+ export declare interface ReserveInput {
917
+ readonly tenantId: string;
918
+ readonly pool: string;
919
+ readonly sessionId: string;
920
+ /** Seats the session needs; only servers with at least this capacity qualify. */
921
+ readonly players: number;
922
+ readonly region?: string;
923
+ /** Every label must match exactly. */
924
+ readonly labels?: Readonly<Record<string, string>>;
925
+ }
926
+
927
+ export declare type ResumeInput = typeof ResumeInputSchema.Type;
928
+
929
+ /** A fresh pool token from `engineServers.authenticate`, the server id and the lease proof `register` returned. */
930
+ declare const ResumeInputSchema: Schema.Struct<{
931
+ readonly token: Schema.NonEmptyString;
932
+ readonly serverId: Schema.NonEmptyString;
933
+ readonly lease: Schema.NonEmptyString;
934
+ }>;
935
+
936
+ export declare type ResumeOutput = typeof ResumeOutputSchema.Type;
937
+
938
+ declare const ResumeOutputSchema: Schema.Struct<{
939
+ readonly server: Schema.Struct<{
940
+ readonly id: Schema.NonEmptyString;
941
+ readonly pool: Schema.NonEmptyString;
942
+ readonly region: Schema.NonEmptyString;
943
+ readonly buildId: Schema.NonEmptyString;
944
+ readonly protocol: Schema.Literals<readonly ["udp", "tcp", "websocket", "webtransport", "quic"]>;
945
+ readonly address: Schema.NullOr<Schema.NonEmptyString>;
946
+ readonly port: Schema.NullOr<Schema.Number>;
947
+ readonly relay: Schema.NullOr<Schema.NonEmptyString>;
948
+ readonly capacity: Schema.Number;
949
+ readonly labels: Schema.$Record<Schema.String, Schema.String>;
950
+ readonly state: Schema.Literals<readonly ["starting", "ready", "allocated", "draining", "suspended", "gone"]>;
951
+ readonly sessionId: Schema.NullOr<Schema.NonEmptyString>;
952
+ readonly registeredAt: Schema.Number;
953
+ readonly lastHeartbeatAt: Schema.Number;
954
+ readonly stateChangedAt: Schema.Number;
955
+ readonly goneReason: Schema.NullOr<Schema.Literals<readonly ["deregistered", "lease_expired", "revoked", "recovered"]>>;
956
+ }>;
957
+ readonly token: Schema.NonEmptyString;
958
+ readonly expiresAt: Schema.Number;
959
+ readonly heartbeatIntervalMs: Schema.Number;
960
+ }>;
961
+
962
+ export declare type SeatAttributes = typeof SeatAttributesSchema.Type;
963
+
964
+ declare const SeatAttributesSchema: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>;
965
+
966
+ export declare interface SeatBackfillInput {
967
+ readonly tenantId: string;
968
+ readonly serverId: string;
969
+ readonly sessionId: string;
970
+ /** Stable per backfill request of this session; a repeat returns the first call's tickets. */
971
+ readonly requestKey: string;
972
+ readonly seats: ReadonlyArray<BackfillSeat>;
973
+ }
974
+
975
+ export declare interface SeatedBackfill {
976
+ /** Subject id → ticket id of each seat. */
977
+ readonly tickets: Readonly<Record<string, string>>;
978
+ /** True when `requestKey` was already seated: `tickets` are the first call's. */
979
+ readonly replayed: boolean;
980
+ /** Unix ms by which the caller records these seats; a later record must withdraw them instead. */
981
+ readonly recordBy: number;
982
+ }
983
+
984
+ export declare type SeatSubject = typeof SeatSubjectSchema.Type;
985
+
986
+ declare const SeatSubjectSchema: Schema.Struct<{
987
+ readonly id: Schema.NonEmptyString;
988
+ readonly type: Schema.Literals<readonly ["user", "apiKey", "serviceAccount"]>;
989
+ readonly kind: Schema.optionalKey<Schema.Literal<"guest">>;
990
+ }>;
991
+
992
+ export declare interface ServerRef {
993
+ readonly tenantId: string;
994
+ readonly serverId: string;
995
+ }
996
+
997
+ /**
998
+ * Provider for servers that already verify the vendor result server-side (for example EAC's
999
+ * server SDK): the status the server reports is stored as is. Only `dedicated` pools may report
1000
+ * anti-cheat status at all, so a player-hosted server never reaches this.
1001
+ */
1002
+ export declare const serverReportedAntiCheat: (name: string, options?: {
1003
+ readonly violationConfidence?: number;
1004
+ }) => EngineServerAntiCheatProvider;
1005
+
1006
+ export declare type ServiceToken = typeof ServiceTokenSchema.Type;
1007
+
1008
+ declare const ServiceTokenSchema: Schema.Struct<{
1009
+ readonly token: Schema.NonEmptyString;
1010
+ readonly expiresAt: Schema.Number;
1011
+ }>;
1012
+
1013
+ /** Purpose of a join ticket. Shared by every engine that verifies seats online. */
1014
+ export declare const SESSION_SEAT_PURPOSE: "voltro.sessions.seat.v1";
1015
+
1016
+ export declare type SessionEventInput = typeof SessionEventInputSchema.Type;
1017
+
1018
+ declare const SessionEventInputSchema: Schema.Struct<{
1019
+ readonly token: Schema.NonEmptyString;
1020
+ readonly sessionId: Schema.NonEmptyString;
1021
+ readonly sequence: Schema.Number;
1022
+ readonly event: Schema.Union<readonly [Schema.Struct<{
1023
+ readonly type: Schema.Literal<"session.started">;
1024
+ }>, Schema.Struct<{
1025
+ readonly type: Schema.Literal<"player.joined">;
1026
+ readonly playerId: Schema.NonEmptyString;
1027
+ }>, Schema.Struct<{
1028
+ readonly type: Schema.Literal<"player.left">;
1029
+ readonly playerId: Schema.NonEmptyString;
1030
+ readonly reconnect: Schema.optionalKey<Schema.Boolean>;
1031
+ }>, Schema.Struct<{
1032
+ readonly type: Schema.Literal<"session.recovered">;
1033
+ }>, Schema.Struct<{
1034
+ readonly type: Schema.Literal<"session.ended">;
1035
+ readonly reason: Schema.optionalKey<Schema.NonEmptyString>;
1036
+ }>]>;
1037
+ }>;
1038
+
1039
+ export declare type SessionEventReceipt = typeof SessionEventReceiptSchema.Type;
1040
+
1041
+ declare const SessionEventReceiptSchema: Schema.Struct<{
1042
+ readonly sessionId: Schema.NonEmptyString;
1043
+ readonly sequence: Schema.Number;
1044
+ /** True when this sequence was already accepted with the same event; nothing ran twice. */
1045
+ readonly replay: Schema.Boolean;
1046
+ readonly state: Schema.Literals<readonly ["running", "waiting", "recovering", "ended", "abandoned"]>;
1047
+ }>;
1048
+
1049
+ declare interface SessionRef {
1050
+ readonly tenantId: string;
1051
+ readonly serverId: string;
1052
+ readonly sessionId: string;
1053
+ }
1054
+
1055
+ export declare type SessionWrite = typeof SessionWriteSchema.Type;
1056
+
1057
+ export declare type SessionWriteInput = typeof SessionWriteInputSchema.Type;
1058
+
1059
+ declare const SessionWriteInputSchema: Schema.Struct<{
1060
+ readonly token: Schema.NonEmptyString;
1061
+ readonly sessionId: Schema.NonEmptyString;
1062
+ /** Unique per session; a retry with the same id reaches the target system with the same request id. */
1063
+ readonly eventId: Schema.NonEmptyString;
1064
+ readonly write: Schema.Union<readonly [Schema.Struct<{
1065
+ readonly kind: Schema.Literal<"inventory.grant">;
1066
+ readonly playerId: Schema.NonEmptyString;
1067
+ readonly itemId: Schema.NonEmptyString;
1068
+ readonly qty: Schema.Number;
1069
+ readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1070
+ readonly reason: Schema.NonEmptyString;
1071
+ }>, Schema.Struct<{
1072
+ readonly kind: Schema.Literal<"inventory.consume">;
1073
+ readonly playerId: Schema.NonEmptyString;
1074
+ readonly instanceId: Schema.NonEmptyString;
1075
+ readonly qty: Schema.Number;
1076
+ readonly reason: Schema.NonEmptyString;
1077
+ }>, Schema.Struct<{
1078
+ readonly kind: Schema.Literal<"economy.grant">;
1079
+ readonly playerId: Schema.NonEmptyString;
1080
+ readonly currency: Schema.NonEmptyString;
1081
+ readonly amount: Schema.String;
1082
+ readonly reason: Schema.NonEmptyString;
1083
+ }>, Schema.Struct<{
1084
+ readonly kind: Schema.Literal<"economy.charge">;
1085
+ readonly playerId: Schema.NonEmptyString;
1086
+ readonly currency: Schema.NonEmptyString;
1087
+ readonly amount: Schema.String;
1088
+ readonly reason: Schema.NonEmptyString;
1089
+ }>, Schema.Struct<{
1090
+ readonly kind: Schema.Literal<"progression.xp">;
1091
+ readonly playerId: Schema.NonEmptyString;
1092
+ readonly trackId: Schema.NonEmptyString;
1093
+ readonly amount: Schema.String;
1094
+ }>, Schema.Struct<{
1095
+ readonly kind: Schema.Literal<"progression.stat">;
1096
+ readonly playerId: Schema.NonEmptyString;
1097
+ readonly stat: Schema.NonEmptyString;
1098
+ readonly period: Schema.Literals<readonly ["lifetime", "season"]>;
1099
+ readonly seasonId: Schema.optionalKey<Schema.NonEmptyString>;
1100
+ readonly operator: Schema.Literals<readonly ["increment", "max", "min", "set"]>;
1101
+ readonly operand: Schema.String;
1102
+ }>, Schema.Struct<{
1103
+ readonly kind: Schema.Literal<"progression.quest">;
1104
+ readonly playerId: Schema.NonEmptyString;
1105
+ readonly poolId: Schema.NonEmptyString;
1106
+ readonly windowId: Schema.NonEmptyString;
1107
+ readonly signal: Schema.Union<readonly [Schema.Struct<{
1108
+ readonly kind: Schema.Literal<"stat">;
1109
+ readonly stat: Schema.NonEmptyString;
1110
+ readonly delta: Schema.String;
1111
+ }>, Schema.Struct<{
1112
+ readonly kind: Schema.Literal<"event">;
1113
+ readonly event: Schema.NonEmptyString;
1114
+ readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1115
+ }>]>;
1116
+ }>, Schema.Struct<{
1117
+ readonly kind: Schema.Literal<"leaderboards.submit">;
1118
+ readonly playerId: Schema.NonEmptyString;
1119
+ readonly board: Schema.NonEmptyString;
1120
+ readonly score: Schema.String;
1121
+ readonly subscore: Schema.optionalKey<Schema.String>;
1122
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1123
+ }>, Schema.Struct<{
1124
+ readonly kind: Schema.Literal<"telemetry.track">;
1125
+ readonly name: Schema.NonEmptyString;
1126
+ readonly playerId: Schema.optionalKey<Schema.NonEmptyString>;
1127
+ readonly properties: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1128
+ }>]>;
1129
+ }>;
1130
+
1131
+ export declare type SessionWriteReceipt = typeof SessionWriteReceiptSchema.Type;
1132
+
1133
+ declare const SessionWriteReceiptSchema: Schema.Struct<{
1134
+ readonly eventId: Schema.NonEmptyString;
1135
+ readonly kind: Schema.String;
1136
+ /** The idempotency key the target system received. */
1137
+ readonly requestId: Schema.NonEmptyString;
1138
+ /** Operation or transaction id of the target system; null for telemetry. */
1139
+ readonly operationId: Schema.NullOr<Schema.String>;
1140
+ }>;
1141
+
1142
+ /** One authoritative write. `playerId` must hold a redeemed ticket of the caller's session. */
1143
+ declare const SessionWriteSchema: Schema.Union<readonly [Schema.Struct<{
1144
+ readonly kind: Schema.Literal<"inventory.grant">;
1145
+ readonly playerId: Schema.NonEmptyString;
1146
+ readonly itemId: Schema.NonEmptyString;
1147
+ readonly qty: Schema.Number;
1148
+ readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1149
+ readonly reason: Schema.NonEmptyString;
1150
+ }>, Schema.Struct<{
1151
+ readonly kind: Schema.Literal<"inventory.consume">;
1152
+ readonly playerId: Schema.NonEmptyString;
1153
+ readonly instanceId: Schema.NonEmptyString;
1154
+ readonly qty: Schema.Number;
1155
+ readonly reason: Schema.NonEmptyString;
1156
+ }>, Schema.Struct<{
1157
+ readonly kind: Schema.Literal<"economy.grant">;
1158
+ readonly playerId: Schema.NonEmptyString;
1159
+ readonly currency: Schema.NonEmptyString;
1160
+ readonly amount: Schema.String;
1161
+ readonly reason: Schema.NonEmptyString;
1162
+ }>, Schema.Struct<{
1163
+ readonly kind: Schema.Literal<"economy.charge">;
1164
+ readonly playerId: Schema.NonEmptyString;
1165
+ readonly currency: Schema.NonEmptyString;
1166
+ readonly amount: Schema.String;
1167
+ readonly reason: Schema.NonEmptyString;
1168
+ }>, Schema.Struct<{
1169
+ readonly kind: Schema.Literal<"progression.xp">;
1170
+ readonly playerId: Schema.NonEmptyString;
1171
+ readonly trackId: Schema.NonEmptyString;
1172
+ readonly amount: Schema.String;
1173
+ }>, Schema.Struct<{
1174
+ readonly kind: Schema.Literal<"progression.stat">;
1175
+ readonly playerId: Schema.NonEmptyString;
1176
+ readonly stat: Schema.NonEmptyString;
1177
+ readonly period: Schema.Literals<readonly ["lifetime", "season"]>;
1178
+ readonly seasonId: Schema.optionalKey<Schema.NonEmptyString>;
1179
+ readonly operator: Schema.Literals<readonly ["increment", "max", "min", "set"]>;
1180
+ readonly operand: Schema.String;
1181
+ }>, Schema.Struct<{
1182
+ readonly kind: Schema.Literal<"progression.quest">;
1183
+ readonly playerId: Schema.NonEmptyString;
1184
+ readonly poolId: Schema.NonEmptyString;
1185
+ readonly windowId: Schema.NonEmptyString;
1186
+ readonly signal: Schema.Union<readonly [Schema.Struct<{
1187
+ readonly kind: Schema.Literal<"stat">;
1188
+ readonly stat: Schema.NonEmptyString;
1189
+ readonly delta: Schema.String;
1190
+ }>, Schema.Struct<{
1191
+ readonly kind: Schema.Literal<"event">;
1192
+ readonly event: Schema.NonEmptyString;
1193
+ readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1194
+ }>]>;
1195
+ }>, Schema.Struct<{
1196
+ readonly kind: Schema.Literal<"leaderboards.submit">;
1197
+ readonly playerId: Schema.NonEmptyString;
1198
+ readonly board: Schema.NonEmptyString;
1199
+ readonly score: Schema.String;
1200
+ readonly subscore: Schema.optionalKey<Schema.String>;
1201
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1202
+ }>, Schema.Struct<{
1203
+ readonly kind: Schema.Literal<"telemetry.track">;
1204
+ readonly name: Schema.NonEmptyString;
1205
+ readonly playerId: Schema.optionalKey<Schema.NonEmptyString>;
1206
+ readonly properties: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>>;
1207
+ }>]>;
1208
+
1209
+ /** A project-owned shared secret, compared in constant time. Mint it per project with `envVar.secret`. */
1210
+ export declare const staticBootstrapSource: (options: StaticBootstrapSourceOptions) => EngineServerBootstrapSource;
1211
+
1212
+ export declare interface StaticBootstrapSourceOptions {
1213
+ /** Tenant the engine servers of these pools belong to. There is no default. */
1214
+ readonly tenantId: string;
1215
+ /** Read lazily at bind time and on each check, so rotation needs no code change. */
1216
+ readonly secrets: () => BootstrapSecrets;
1217
+ /** Restrict to these pool names. Omitted: every declared pool. */
1218
+ readonly pools?: ReadonlyArray<string>;
1219
+ }
1220
+
1221
+ export declare type VerifiedSeat = typeof VerifiedSeatSchema.Type;
1222
+
1223
+ /** What `sessions.verify` hands the engine server for one admitted player. */
1224
+ declare const VerifiedSeatSchema: Schema.Struct<{
1225
+ readonly ticketId: Schema.NonEmptyString;
1226
+ readonly serverId: Schema.NonEmptyString;
1227
+ readonly sessionId: Schema.NonEmptyString;
1228
+ readonly subject: Schema.Struct<{
1229
+ readonly id: Schema.NonEmptyString;
1230
+ readonly type: Schema.Literals<readonly ["user", "apiKey", "serviceAccount"]>;
1231
+ readonly kind: Schema.optionalKey<Schema.Literal<"guest">>;
1232
+ }>;
1233
+ readonly partyId: Schema.NullOr<Schema.NonEmptyString>;
1234
+ readonly team: Schema.NullOr<Schema.NonEmptyString>;
1235
+ readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.Null]>>;
1236
+ /** True when this ticket was already redeemed and is used again inside the reconnect window. */
1237
+ readonly reconnect: Schema.Boolean;
1238
+ /** The reconnect window of this ticket ends here (epoch ms). */
1239
+ readonly reconnectUntil: Schema.Number;
1240
+ /** True when the session was taken over from a crashed server; a player can arrive before the next heartbeat says so. */
1241
+ readonly recovery: Schema.Boolean;
1242
+ }>;
1243
+
1244
+ export { }