@series-inc/rundot-syncplay 6.0.0-rc.83 → 6.0.0-rc.85

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.
@@ -36,7 +36,7 @@ export const physicsProfileWasmMetadata = Object.freeze({
36
36
  "sourceHash": "dac3f2ab1dd7348052bbae1ba83c2ba6c6950e8cb5e86ada6de9a025bc541280",
37
37
  "wasmSha256": "f08bddbc71c520ba0d7394b0fc33a38673cbeaffa00a079fe8d960941cd46105",
38
38
  "artifact": "profile",
39
- "packageVersion": "6.0.0-rc.83",
39
+ "packageVersion": "6.0.0-rc.85",
40
40
  "compilerFlags": [
41
41
  "-std=c++20",
42
42
  "-O3",
@@ -36,7 +36,7 @@ export const physicsWasmMetadata = Object.freeze({
36
36
  "sourceHash": "00c81d3088e594a61154d57b39f5f44e0ca42b43822946da0191c7cac27da7a0",
37
37
  "wasmSha256": "29f5ee181a1b958577a76211015bd08dbbdfed9c074c15a40cf725430895baae",
38
38
  "artifact": "production",
39
- "packageVersion": "6.0.0-rc.83",
39
+ "packageVersion": "6.0.0-rc.85",
40
40
  "compilerFlags": [
41
41
  "-std=c++20",
42
42
  "-O3",
@@ -50,7 +50,7 @@ export const physics2dWasmMetadata = Object.freeze({
50
50
  "sourceHash": "c982f7b72b0494c8892d40b5fbf1a67ac94a7f20dea1f160abb888f4ccb313c0",
51
51
  "wasmSha256": "49cb90541deed40f5fff1015bb578e13ec9a793d51931c1227e3e5a11bbfa3f7",
52
52
  "artifact": "production",
53
- "packageVersion": "6.0.0-rc.83",
53
+ "packageVersion": "6.0.0-rc.85",
54
54
  "compilerFlags": [
55
55
  "-std=c++20",
56
56
  "-O3",
@@ -447,9 +447,12 @@ export interface DeterministicAuthorityRoom {
447
447
  * A player's transport re-attached inside the host's grace window (socket
448
448
  * swap; no leave/join fired). Re-unicasts the confirmed-input history so any
449
449
  * frames missed while offline are refilled — clients dedupe already-applied
450
- * ticks, so this is idempotent.
450
+ * ticks, so this is idempotent. Pass `reinitializeSession: true` when a fresh
451
+ * cold-started client took over the seat and needs `session-start` first.
451
452
  */
452
- onPlayerReconnected(playerId: string): void;
453
+ onPlayerReconnected(playerId: string, options?: {
454
+ readonly reinitializeSession?: boolean;
455
+ }): void;
453
456
  /**
454
457
  * A player's transport dropped and their seat entered the host's grace
455
458
  * window. The slot stays reserved and keeps being substituted, so release
@@ -6,7 +6,7 @@ import { createDeterministicLocalAuthoritySnapshotChunkEnvelope, createDetermini
6
6
  import { DEFAULT_SNAPSHOT_CHUNK_SIZE, createSnapshotTransferCollector, createSnapshotTransferFromBytes, decodeDeterministicStateSnapshot, encodeDeterministicStateSnapshot, deterministicRoomDescriptorHash, } from './session-snapshot.js';
7
7
  import { MAX_KINETIX_SESSION_CONFIG_BYTES, MAX_SYNCPLAY_COMMAND_PAYLOAD_BYTES, MAX_SYNCPLAY_EPHEMERAL_PAYLOAD_BYTES, decodeDeterministicSessionMessage, encodeDeterministicSessionMessage, } from './session-wire.js';
8
8
  import { createSyncplaySecretAuthority, } from './secret-authority.js';
9
- import { DEFAULT_SEAT_POLICY, validateSeatPolicy, createInitialSeatControlState, allocatable, findAvailableSeat, applyTransition, createSeatCheckpoint, restoreSeatControlState, } from './seat-control.js';
9
+ import { DEFAULT_SEAT_POLICY, validateSeatPolicy, createInitialSeatControlState, allocatable, findAvailableSeat, applyTransition, expireSeatHolds, createSeatCheckpoint, restoreSeatControlState, } from './seat-control.js';
10
10
  const DEFAULT_SESSION_MSG_TYPE = 'rdm';
11
11
  const DEFAULT_SECRET_MSG_TYPE = 'rdm-secret';
12
12
  /** One hour at 60 Hz — see DeterministicAuthorityRoomConfig.historyRetentionTicks. */
@@ -106,7 +106,7 @@ export function createDeterministicAuthorityRoom(transport, config) {
106
106
  let seatControlState = config.restoreFrom?.seatCheckpoint !== undefined
107
107
  ? restoreSeatControlState(config.restoreFrom.seatCheckpoint)
108
108
  : createInitialSeatControlState(config.playerCount, seatPolicy ?? DEFAULT_SEAT_POLICY, config.seatPolicy === undefined ? { legacyBotSlots: [...botSlotSet] } : undefined);
109
- let hasStartedLobby = false;
109
+ let hasStartedLobby = (config.restoreFrom?.now ?? -1) >= 0;
110
110
  if (config.restoreFrom?.seatCheckpoint !== undefined) {
111
111
  for (let slot = 0; slot < config.playerCount; slot++) {
112
112
  const seat = seatControlState.seats[slot];
@@ -998,7 +998,7 @@ export function createDeterministicAuthorityRoom(transport, config) {
998
998
  if (slot !== undefined)
999
999
  authority.neutralizeSlot(slot);
1000
1000
  }
1001
- function onPlayerReconnected(playerId) {
1001
+ function onPlayerReconnected(playerId, options) {
1002
1002
  const wasDisconnected = disconnectedPlayers.delete(playerId);
1003
1003
  if (wasDisconnected) {
1004
1004
  membershipEpoch += 1;
@@ -1021,15 +1021,16 @@ export function createDeterministicAuthorityRoom(transport, config) {
1021
1021
  }
1022
1022
  const slot = slotByPlayer.get(playerId);
1023
1023
  if (slot === undefined) {
1024
- if (reconnectedSlot !== undefined) {
1024
+ const hasPriorSeatClaim = reconnectedSlot !== undefined ||
1025
+ (config.seatPolicy !== undefined && seatControlState.rejoinRecords.some((r) => r.playerId === playerId));
1026
+ if (hasPriorSeatClaim) {
1025
1027
  onPlayerJoin(playerId);
1026
1028
  }
1027
1029
  return;
1028
1030
  }
1029
- // Post-restore, a reattaching client's timeline forked past the restored
1030
- // frontier — re-greet it so the client takes its full-reset + re-hydrate
1031
- // path rather than stalling on ticks that will re-confirm differently.
1032
- if (restoredRoom) {
1031
+ // Post-restore or on a cold-start seat takeover, the client's local session
1032
+ // needs a fresh `session-start` before secret proof context and catch-up.
1033
+ if (restoredRoom || options?.reinitializeSession === true) {
1033
1034
  sendSessionStart(playerId, slot);
1034
1035
  }
1035
1036
  // Socket swapped mid-match: refill anything missed while offline. The
@@ -1282,6 +1283,12 @@ export function createDeterministicAuthorityRoom(transport, config) {
1282
1283
  else if (seat.control.kind === "bot") {
1283
1284
  const nextEpoch = seat.control.controlEpoch + 1;
1284
1285
  const botLeaseId = `lease-${slot}-${nextEpoch}`;
1286
+ const rebasedClaim = seat.retainedClaim?.holdExpiresAtTick !== undefined
1287
+ ? {
1288
+ ...seat.retainedClaim,
1289
+ holdExpiresAtTick: Math.max(0, seat.retainedClaim.holdExpiresAtTick - Math.max(0, now + 1)),
1290
+ }
1291
+ : seat.retainedClaim;
1285
1292
  const updatedSeat = {
1286
1293
  ...seat,
1287
1294
  control: {
@@ -1289,6 +1296,7 @@ export function createDeterministicAuthorityRoom(transport, config) {
1289
1296
  controlEpoch: nextEpoch,
1290
1297
  botLeaseId,
1291
1298
  },
1299
+ retainedClaim: rebasedClaim,
1292
1300
  };
1293
1301
  seatControlState = {
1294
1302
  ...seatControlState,
@@ -1305,6 +1313,19 @@ export function createDeterministicAuthorityRoom(transport, config) {
1305
1313
  activeBotLeaseBySlot.set(slot, newLease);
1306
1314
  lastBotSequenceByLease.set(botLeaseId, 0);
1307
1315
  }
1316
+ else if (seat.retainedClaim?.holdExpiresAtTick !== undefined) {
1317
+ const updatedSeat = {
1318
+ ...seat,
1319
+ retainedClaim: {
1320
+ ...seat.retainedClaim,
1321
+ holdExpiresAtTick: Math.max(0, seat.retainedClaim.holdExpiresAtTick - Math.max(0, now + 1)),
1322
+ },
1323
+ };
1324
+ seatControlState = {
1325
+ ...seatControlState,
1326
+ seats: seatControlState.seats.map((s, idx) => (idx === slot ? updatedSeat : s)),
1327
+ };
1328
+ }
1308
1329
  }
1309
1330
  }
1310
1331
  membershipEpoch += 1;
@@ -1672,7 +1693,7 @@ export function createDeterministicAuthorityRoom(transport, config) {
1672
1693
  }
1673
1694
  authority.neutralizeSlotFrom(slot, effectiveTick);
1674
1695
  slotByPlayer.delete(playerId);
1675
- if (seatPolicy.recycleVacatedSeats) {
1696
+ if (seatPolicy.recycleVacatedSeats && res.nextState.seats[slot].retainedClaim === null) {
1676
1697
  everSlotByPlayer.delete(playerId);
1677
1698
  }
1678
1699
  if (seatPolicy.onHumanLeave === "bot") {
@@ -1823,19 +1844,61 @@ export function createDeterministicAuthorityRoom(transport, config) {
1823
1844
  // via the history replay in onPlayerJoin. `assignedSlots` is monotonic, so
1824
1845
  // a mid-match leave never re-pauses a started room.
1825
1846
  if (config.waitForFullRoom === true && !hasStartedLobby) {
1826
- if (config.seatPolicy !== undefined) {
1827
- const activeCount = seatControlState.seats.filter((s) => s.control.kind === "human" || s.control.kind === "bot").length;
1828
- if (activeCount < config.playerCount)
1829
- return;
1830
- hasStartedLobby = true;
1831
- }
1832
- else {
1833
- if (assignedSlots < config.playerCount)
1834
- return;
1835
- hasStartedLobby = true;
1847
+ const activeCount = config.seatPolicy !== undefined
1848
+ ? seatControlState.seats.filter((s) => s.control.kind === "human" || s.control.kind === "bot").length
1849
+ : assignedSlots;
1850
+ if (activeCount < config.playerCount) {
1851
+ if (config.seatPolicy !== undefined && seatControlState.policy.seatHoldTicks !== undefined) {
1852
+ let decayed = false;
1853
+ const decayedSeats = seatControlState.seats.map((seat) => {
1854
+ if (seat.control.kind !== "human" &&
1855
+ seat.retainedClaim?.holdExpiresAtTick !== undefined) {
1856
+ decayed = true;
1857
+ return {
1858
+ ...seat,
1859
+ retainedClaim: {
1860
+ ...seat.retainedClaim,
1861
+ holdExpiresAtTick: Math.max(0, seat.retainedClaim.holdExpiresAtTick - 1),
1862
+ },
1863
+ };
1864
+ }
1865
+ return seat;
1866
+ });
1867
+ if (decayed) {
1868
+ seatControlState = { ...seatControlState, seats: decayedSeats };
1869
+ const holdRes = expireSeatHolds(seatControlState, 0);
1870
+ if (holdRes.expired.length > 0) {
1871
+ seatControlState = holdRes.nextState;
1872
+ membershipEpoch += 1;
1873
+ for (const rel of holdRes.expired) {
1874
+ secretAuthority?.onPlayerLeft(rel.playerId, rel.slot, {
1875
+ releaseMode: rel.releaseMode,
1876
+ reason: 'leave',
1877
+ });
1878
+ everSlotByPlayer.delete(rel.playerId);
1879
+ }
1880
+ }
1881
+ }
1882
+ }
1883
+ return;
1836
1884
  }
1885
+ hasStartedLobby = true;
1837
1886
  }
1838
1887
  now += 1;
1888
+ if (config.seatPolicy !== undefined && seatControlState.policy.seatHoldTicks !== undefined) {
1889
+ const holdRes = expireSeatHolds(seatControlState, now);
1890
+ if (holdRes.expired.length > 0) {
1891
+ seatControlState = holdRes.nextState;
1892
+ membershipEpoch += 1;
1893
+ for (const rel of holdRes.expired) {
1894
+ secretAuthority?.onPlayerLeft(rel.playerId, rel.slot, {
1895
+ releaseMode: rel.releaseMode,
1896
+ reason: 'leave',
1897
+ });
1898
+ everSlotByPlayer.delete(rel.playerId);
1899
+ }
1900
+ }
1901
+ }
1839
1902
  for (const [schedTick, slots] of scheduledEvacuations.entries()) {
1840
1903
  if (schedTick <= now) {
1841
1904
  for (const slot of slots) {
@@ -152,7 +152,10 @@ export interface NetworkedSyncplayClientOptions<State, Input, Checkpoint = unkno
152
152
  * driving `pumpPaced`.
153
153
  */
154
154
  readonly inputDelay?: NetworkedSyncplayClientInputDelayOptions;
155
- /** Monotonic-enough clock for RTT measurement and donor upload pacing. Default Date.now. NEVER used by the sim. */
155
+ /**
156
+ * Monotonic-enough clock for RTT measurement, donor upload pacing and ephemeral coalescing. Default Date.now.
157
+ * NEVER used by the sim. The confirmation and resimulation duration stats do not read it: they measure host time.
158
+ */
156
159
  readonly now?: () => number;
157
160
  readonly playerId?: string;
158
161
  readonly secretCrypto?: SyncplaySecretBrowserCrypto;
@@ -199,9 +202,12 @@ export interface NetworkedSyncplayClientNetStats {
199
202
  readonly inputDelayTicks: number;
200
203
  readonly rollbacks: number;
201
204
  readonly maxRollbackDepth: number;
202
- /** Wall-clock time in ms spent during the most recent rollback resimulation loop. */
205
+ /**
206
+ * Host time in ms spent during the most recent rollback resimulation loop. Measured with performance.now() (or
207
+ * Date.now() where it does not exist), never with the `now` option.
208
+ */
203
209
  readonly lastResimulationDurationMs: number;
204
- /** Cumulative wall-clock time in ms spent resimulating rolled-back frames. */
210
+ /** Cumulative host time in ms spent resimulating rolled-back frames. Measured as lastResimulationDurationMs. */
205
211
  readonly accumulatedResimulationDurationMs: number;
206
212
  /** Histogram counts of rollback depths binned into: [0 (predictions confirmed without rollback), 1-2, 3-4, 5-8, 9+]. */
207
213
  readonly rollbackDepthHistogram: readonly [number, number, number, number, number];
@@ -221,7 +227,12 @@ export interface NetworkedSyncplayClientNetStats {
221
227
  readonly recoveryPhase?: 'idle' | 'catching-up' | 'hydrating' | 'live';
222
228
  readonly recoveryBacklogTicks?: number;
223
229
  readonly lastSnapshotSelectedTick?: number;
230
+ /**
231
+ * Host time in ms spent applying the most recent confirmed-frame batch. Measured with performance.now() (or
232
+ * Date.now() where it does not exist), never with the `now` option.
233
+ */
224
234
  readonly lastConfirmationDurationMs?: number;
235
+ /** Cumulative host time in ms spent applying confirmed frames. Measured as lastConfirmationDurationMs. */
225
236
  readonly accumulatedConfirmationDurationMs?: number;
226
237
  readonly retainedSnapshots?: number;
227
238
  readonly snapshotBufferCapacity?: number;
@@ -78,6 +78,10 @@ function createTokenBucket(capacity, tokensPerMs, now) {
78
78
  * closed window of W ms holds at most TRANSFER_ENVELOPES_PER_TICK * (1 + W * tickRateHz / 1000) envelopes.
79
79
  * The drain timer is armed only when the queue is not empty, for the time when the bucket next holds a token. It
80
80
  * drains a paused or hidden page that never pumps.
81
+ * When the timer runs and the client clock did not move since the timer was armed, the timer sends what the bucket
82
+ * holds and does not arm again: a stepped test clock cannot refill the bucket. The next pump() or pumpPaced() drains
83
+ * the queue. Where the runtime gives `unref()` (Node), the timer is unref'd, so a pending drain does not keep the
84
+ * event loop alive.
81
85
  */
82
86
  function createDonorUploadPacer(config) {
83
87
  if (!Number.isFinite(config.tickRateHz) || config.tickRateHz <= 0) {
@@ -91,21 +95,30 @@ function createDonorUploadPacer(config) {
91
95
  function armTimer() {
92
96
  if (timer !== undefined || disposed || queue.length === 0)
93
97
  return;
98
+ const armedAtMs = config.now();
94
99
  timer = setTimeout(() => {
95
100
  timer = undefined;
96
- flush();
101
+ const clockMoved = config.now() !== armedAtMs;
102
+ if (drain() && clockMoved)
103
+ armTimer();
97
104
  }, Math.max(1, bucket.msUntilToken()));
105
+ unrefTimer(timer);
98
106
  }
99
- function flush() {
107
+ /** Sends what the bucket allows. False when the pacer must not arm the timer: disposed, or the client cannot send. */
108
+ function drain() {
100
109
  if (disposed || queue.length === 0 || !config.canSend())
101
- return;
110
+ return false;
102
111
  for (let text = queue[0]; text !== undefined && bucket.take(); text = queue[0]) {
103
112
  queue.shift();
104
113
  config.send(text);
105
114
  if (disposed || !config.canSend())
106
- return;
115
+ return false;
107
116
  }
108
- armTimer();
117
+ return true;
118
+ }
119
+ function flush() {
120
+ if (drain())
121
+ armTimer();
109
122
  }
110
123
  return {
111
124
  enqueue(envelopes) {
@@ -125,6 +138,23 @@ function createDonorUploadPacer(config) {
125
138
  },
126
139
  };
127
140
  }
141
+ /** Lets a pending timer not keep the event loop alive, where the runtime gives `unref()` (Node). */
142
+ function unrefTimer(handle) {
143
+ if (typeof handle !== 'object' || handle === null)
144
+ return;
145
+ const unref = handle.unref;
146
+ if (typeof unref === 'function')
147
+ unref.call(handle);
148
+ }
149
+ /**
150
+ * The monotonic clock of the host, for the CPU duration stats only: performance.now() where it exists, else
151
+ * Date.now(). The client option `now` can be a logical clock (a simulated match steps it), so it cannot measure CPU
152
+ * time.
153
+ */
154
+ function hostDurationClockMs() {
155
+ const performanceClock = globalThis.performance;
156
+ return typeof performanceClock?.now === 'function' ? performanceClock.now() : Date.now();
157
+ }
128
158
  /** Outbound ephemeral coalescing: at most one send per 50 ms (20 Hz), latest wins. */
129
159
  const EPHEMERAL_MIN_SEND_INTERVAL_MS = 50;
130
160
  function equalBytes(left, right) {
@@ -1611,7 +1641,7 @@ export function createNetworkedSyncplayClient(options) {
1611
1641
  const firstNewTick = frames.find((frame) => frame.tick > appliedThrough)?.tick;
1612
1642
  const presentationWasLive = caughtUp;
1613
1643
  const freshRoomFirstFrame = appliedThrough === -1 && firstNewTick === 0 && authorityTick === 0;
1614
- const confirmStartMs = wallClock();
1644
+ const confirmStartMs = hostDurationClockMs();
1615
1645
  latestAuthorityTick = Math.max(latestAuthorityTick, authorityTick);
1616
1646
  for (const frame of frames) {
1617
1647
  if (frame.tick > appliedThrough) {
@@ -1667,7 +1697,7 @@ export function createNetworkedSyncplayClient(options) {
1667
1697
  }
1668
1698
  batchRolledBack = true;
1669
1699
  batchPredictedThroughBeforeRollback = predictedThrough;
1670
- batchRollbackStartMs = wallClock();
1700
+ batchRollbackStartMs = hostDurationClockMs();
1671
1701
  session?.restoreToFrame(tick);
1672
1702
  stepConfirmedOrPredictedRange(tick, tick + 1);
1673
1703
  predictedThrough = tick + 1;
@@ -1741,7 +1771,7 @@ export function createNetworkedSyncplayClient(options) {
1741
1771
  stepConfirmedOrPredictedRange(appliedThrough + 1, targetPredictThrough);
1742
1772
  }
1743
1773
  predictedThrough = Math.max(appliedThrough + 1, targetPredictThrough);
1744
- const duration = Math.max(0, wallClock() - batchRollbackStartMs);
1774
+ const duration = Math.max(0, hostDurationClockMs() - batchRollbackStartMs);
1745
1775
  lastResimulationDurationMs = duration;
1746
1776
  accumulatedResimulationDurationMs += duration;
1747
1777
  }
@@ -1754,7 +1784,7 @@ export function createNetworkedSyncplayClient(options) {
1754
1784
  }
1755
1785
  timelineMinTick = pruneBeforeTick;
1756
1786
  }
1757
- const confirmDuration = Math.max(0, wallClock() - confirmStartMs);
1787
+ const confirmDuration = Math.max(0, hostDurationClockMs() - confirmStartMs);
1758
1788
  lastConfirmationDurationMs = confirmDuration;
1759
1789
  accumulatedConfirmationDurationMs += confirmDuration;
1760
1790
  skipConfirmedOwnTicks();
@@ -1965,54 +1995,59 @@ export function createNetworkedSyncplayClient(options) {
1965
1995
  schemaHash,
1966
1996
  ...(requestConfigHash !== undefined ? { configHash: requestConfigHash } : {}),
1967
1997
  };
1968
- let buildFailure;
1969
- try {
1970
- if (reportedTicks.includes(minTick)) {
1971
- const tick = minTick;
1972
- const snapshot = active.peekSnapshot(tick + 1);
1973
- const confirmedAtTick = timeline[tick]?.inputs;
1974
- const confirmedSeatsAtTick = timeline[tick]?.seats;
1975
- if (snapshot !== undefined && confirmedAtTick !== undefined) {
1976
- // A room without a valid tick rate has no upload budget: refuse with this reason before any donor state moves.
1977
- const upload = donorUpload;
1978
- if (upload === undefined)
1979
- throw new Error('SYNCPLAY_DONOR_UPLOAD_TICK_RATE_INVALID');
1980
- const runtimeBytes = active.getSnapshotBytes(snapshot.frame);
1981
- const fields = {
1982
- tick,
1983
- sessionFrame: tick + 1,
1984
- runtimeBytes: bytesToBase64(runtimeBytes),
1985
- runtimeIdentity: active.schemaIdentity,
1986
- sessionConfigDigest: schemaHash,
1987
- stateChecksum: active.getWireStateChecksum(snapshot.frame),
1988
- confirmedInputs: confirmedAtTick.map((input) => cloneCanonical(input)),
1989
- ...(confirmedSeatsAtTick !== undefined ? { confirmedSeats: confirmedSeatsAtTick } : {}),
1990
- };
1991
- const bytes = encodeDeterministicStateSnapshot(active.schemaIdentity.stateDigestDomain === 'syncplay.state-report/2'
1992
- ? { ...fields, v: 3, runtimePayloadChecksum: sha256Hex(runtimeBytes), witnesses: 1 }
1993
- : { ...fields, v: 2 });
1994
- donorTransferCounter += 1;
1995
- lastSnapshotSelectedTick = tick;
1996
- const transfer = createSnapshotTransferFromBytes(bytes, {
1997
- identity: offerIdentity,
1998
- frame: tick + 1,
1999
- transferId: `donor:${slot}:${tick}:${donorTransferCounter}`,
2000
- });
2001
- let sequence = donorTransferCounter * 1000;
2002
- options.transport.send(createDeterministicLocalAuthoritySnapshotOfferEnvelope(sequence++, transfer));
2003
- const envelopes = [];
2004
- for (let index = 0; index < transfer.chunks.length; index += 1) {
2005
- envelopes.push(createDeterministicLocalAuthoritySnapshotChunkEnvelope(sequence++, transfer, index));
2006
- }
2007
- envelopes.push(createDeterministicLocalAuthoritySnapshotCompleteEnvelope(sequence++, transfer.transferId));
2008
- upload.enqueue(envelopes);
1998
+ if (reportedTicks.includes(minTick)) {
1999
+ const tick = minTick;
2000
+ const snapshot = active.peekSnapshot(tick + 1);
2001
+ const confirmedAtTick = timeline[tick]?.inputs;
2002
+ const confirmedSeatsAtTick = timeline[tick]?.seats;
2003
+ if (snapshot !== undefined && confirmedAtTick !== undefined) {
2004
+ // A room without a valid tick rate has no upload budget: refuse with this reason before any donor state moves.
2005
+ const upload = donorUpload;
2006
+ if (upload === undefined) {
2007
+ sendSnapshotRefusal(minTick, minFrame, offerIdentity, 'SYNCPLAY_DONOR_UPLOAD_TICK_RATE_INVALID');
2009
2008
  return;
2010
2009
  }
2010
+ // A failure from here on is a donor failure, not an unavailable snapshot. It leaves this handler, so the
2011
+ // donor sends no refusal, and no refusal can follow the offer.
2012
+ const runtimeBytes = active.getSnapshotBytes(snapshot.frame);
2013
+ const fields = {
2014
+ tick,
2015
+ sessionFrame: tick + 1,
2016
+ runtimeBytes: bytesToBase64(runtimeBytes),
2017
+ runtimeIdentity: active.schemaIdentity,
2018
+ sessionConfigDigest: schemaHash,
2019
+ stateChecksum: active.getWireStateChecksum(snapshot.frame),
2020
+ confirmedInputs: confirmedAtTick.map((input) => cloneCanonical(input)),
2021
+ ...(confirmedSeatsAtTick !== undefined ? { confirmedSeats: confirmedSeatsAtTick } : {}),
2022
+ };
2023
+ const bytes = encodeDeterministicStateSnapshot(active.schemaIdentity.stateDigestDomain === 'syncplay.state-report/2'
2024
+ ? { ...fields, v: 3, runtimePayloadChecksum: sha256Hex(runtimeBytes), witnesses: 1 }
2025
+ : { ...fields, v: 2 });
2026
+ donorTransferCounter += 1;
2027
+ lastSnapshotSelectedTick = tick;
2028
+ const transfer = createSnapshotTransferFromBytes(bytes, {
2029
+ identity: offerIdentity,
2030
+ frame: tick + 1,
2031
+ transferId: `donor:${slot}:${tick}:${donorTransferCounter}`,
2032
+ });
2033
+ let sequence = donorTransferCounter * 1000;
2034
+ options.transport.send(createDeterministicLocalAuthoritySnapshotOfferEnvelope(sequence++, transfer));
2035
+ const envelopes = [];
2036
+ for (let index = 0; index < transfer.chunks.length; index += 1) {
2037
+ envelopes.push(createDeterministicLocalAuthoritySnapshotChunkEnvelope(sequence++, transfer, index));
2038
+ }
2039
+ envelopes.push(createDeterministicLocalAuthoritySnapshotCompleteEnvelope(sequence++, transfer.transferId));
2040
+ upload.enqueue(envelopes);
2041
+ return;
2011
2042
  }
2012
2043
  }
2013
- catch (error) {
2014
- buildFailure = error;
2015
- }
2044
+ sendSnapshotRefusal(minTick, minFrame, offerIdentity, undefined);
2045
+ }
2046
+ /**
2047
+ * Donor role: the one refusal for a request. A refusal without a reason means that the donor holds no snapshot
2048
+ * for the tick. A failure to build or send a snapshot is never a refusal.
2049
+ */
2050
+ function sendSnapshotRefusal(minTick, minFrame, offerIdentity, reason) {
2016
2051
  donorTransferCounter += 1;
2017
2052
  const refusalTransferId = `donor:${slot}:${minTick}:unavailable:${donorTransferCounter}`;
2018
2053
  const sequence = donorTransferCounter * 1000;
@@ -2028,9 +2063,7 @@ export function createNetworkedSyncplayClient(options) {
2028
2063
  totalBytes: 0,
2029
2064
  chunkChecksums: [],
2030
2065
  unavailable: true,
2031
- ...(buildFailure !== undefined
2032
- ? { reason: buildFailure instanceof Error ? buildFailure.message : String(buildFailure) }
2033
- : {}),
2066
+ ...(reason !== undefined ? { reason } : {}),
2034
2067
  },
2035
2068
  }));
2036
2069
  }
@@ -40,6 +40,15 @@ export interface SyncplayOccupancySnapshot {
40
40
  readonly full: boolean;
41
41
  readonly locked: boolean;
42
42
  }
43
+ export interface SyncplaySettlementReport {
44
+ /**
45
+ * Optional per-run identifier (`[A-Za-z0-9._:-]{1,64}`) used by multi-wave or
46
+ * persistent deterministic rooms to settle each run idempotently.
47
+ */
48
+ readonly runId?: string;
49
+ readonly roomInputs?: Readonly<Record<string, unknown>>;
50
+ readonly playerInputs?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
51
+ }
43
52
  export interface SyncplayRoomTransport extends NetworkedClientTransport {
44
53
  /** The shareable room code (e.g. "HX9KWR"). */
45
54
  readonly roomCode: string;
@@ -59,6 +68,11 @@ export interface SyncplayRoomTransport extends NetworkedClientTransport {
59
68
  onConnectionEvent(handler: (event: SyncplayConnectionEvent) => void): void;
60
69
  onOccupancyChange(handler: (snapshot: SyncplayOccupancySnapshot) => void): () => void;
61
70
  setSeatingOpen(open: boolean): void;
71
+ /**
72
+ * Submit a deterministic run-settlement report for quorum agreement across
73
+ * connected peers into `simulationHooks.settleRecipeId`.
74
+ */
75
+ reportSettlement(report: SyncplaySettlementReport): void;
62
76
  }
63
77
  /**
64
78
  * Join an existing deterministic room by its 6-char code and return a transport
@@ -12,11 +12,14 @@
12
12
  * carries the session envelope verbatim; the typed-message path would spread a
13
13
  * raw string and corrupt it, which is why the raw channel exists.
14
14
  */
15
+ import { canonicalStringify } from './canonical.js';
15
16
  import { detectCoarseRegion } from './coarse-region.js';
16
17
  import { encodeDeterministicSessionMessage } from './session-wire.js';
17
18
  /** Wire envelope msgType the deterministic session protocol travels under. */
18
19
  const SESSION_MSG_TYPE = 'rdm';
19
20
  const SECRET_MSG_TYPE = 'rdm-secret';
21
+ const SETTLEMENT_MSG_TYPE = 'rdm-settle';
22
+ const RUN_ID_PATTERN = /^[A-Za-z0-9._:-]{1,64}$/;
20
23
  /** Room type the platform registers the generic deterministic room under. */
21
24
  const SYNCPLAY_ROOM_TYPE = 'deterministic';
22
25
  const SYNCPLAY_MAX_PLAYERS_CRITERION = '__syncplay.maxPlayers';
@@ -28,6 +31,9 @@ function isUint8Array(value) {
28
31
  return ArrayBuffer.isView(value)
29
32
  && Object.prototype.toString.call(value) === '[object Uint8Array]';
30
33
  }
34
+ function isPlainRecord(value) {
35
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
36
+ }
31
37
  /**
32
38
  * Session traffic buffered between transport creation and the engine attaching
33
39
  * its onMessage handler (a game may await asset loads in between). ~4.5 min of
@@ -166,6 +172,35 @@ function toTransport(room) {
166
172
  };
167
173
  },
168
174
  setSeatingOpen: (open) => room.setSeatingOpen(open),
175
+ reportSettlement: (report) => {
176
+ if (!isPlainRecord(report)) {
177
+ throw new TypeError('SyncplaySettlementReport must be a plain object');
178
+ }
179
+ if (report.runId !== undefined && (typeof report.runId !== 'string' || !RUN_ID_PATTERN.test(report.runId))) {
180
+ throw new TypeError('SyncplaySettlementReport.runId must match /^[A-Za-z0-9._:-]{1,64}$/');
181
+ }
182
+ if (report.roomInputs !== undefined && !isPlainRecord(report.roomInputs)) {
183
+ throw new TypeError('SyncplaySettlementReport.roomInputs must be a plain object');
184
+ }
185
+ if (report.playerInputs !== undefined) {
186
+ if (!isPlainRecord(report.playerInputs)) {
187
+ throw new TypeError('SyncplaySettlementReport.playerInputs must be a plain object');
188
+ }
189
+ for (const [profileId, inputs] of Object.entries(report.playerInputs)) {
190
+ if (!profileId || !isPlainRecord(inputs)) {
191
+ throw new TypeError('SyncplaySettlementReport.playerInputs values must be plain objects');
192
+ }
193
+ }
194
+ }
195
+ const payload = {};
196
+ if (report.runId !== undefined)
197
+ payload.runId = report.runId;
198
+ if (report.roomInputs !== undefined)
199
+ payload.roomInputs = report.roomInputs;
200
+ if (report.playerInputs !== undefined)
201
+ payload.playerInputs = report.playerInputs;
202
+ room.sendRaw(SETTLEMENT_MSG_TYPE, canonicalStringify(payload));
203
+ },
169
204
  };
170
205
  }
171
206
  /**
@@ -46,11 +46,18 @@ export interface SeatPolicy {
46
46
  readonly allowHumanClaimBot: boolean;
47
47
  readonly onHumanLeave: 'empty' | 'bot';
48
48
  readonly initialBotSlots: readonly SlotIndex[];
49
+ /**
50
+ * Optional tick count to hold a vacated seat exclusively for the departing
51
+ * player before releasing it to `rejoinRecords` for human backfill when
52
+ * `recycleVacatedSeats` is true.
53
+ */
54
+ readonly seatHoldTicks?: number;
49
55
  }
50
56
  export interface HumanClaim {
51
57
  readonly playerId: PlayerId;
52
58
  readonly claimId: HumanClaimId;
53
59
  readonly slot: SlotIndex;
60
+ readonly holdExpiresAtTick?: number;
54
61
  }
55
62
  export interface StagedReservation {
56
63
  readonly playerId: PlayerId;
@@ -135,6 +142,10 @@ export declare function applyTransition(state: SeatControlState, intent: SeatTra
135
142
  nextState: SeatControlState;
136
143
  effects: TransitionEffects;
137
144
  };
145
+ export declare function expireSeatHolds(state: SeatControlState, tick: number): {
146
+ readonly nextState: SeatControlState;
147
+ readonly expired: readonly NonNullable<TransitionEffects['secretRelease']>[];
148
+ };
138
149
  export interface SeatCheckpoint {
139
150
  readonly v: 1;
140
151
  readonly playerCount: number;
@@ -11,7 +11,13 @@ export function validateSeatPolicy(input, playerCount) {
11
11
  }
12
12
  invariant(typeof input === 'object' && input !== null, 'seatPolicy must be an object', 'seat-control.invalid-policy');
13
13
  const record = input;
14
- const allowedKeys = new Set(['recycleVacatedSeats', 'allowHumanClaimBot', 'onHumanLeave', 'initialBotSlots']);
14
+ const allowedKeys = new Set([
15
+ 'recycleVacatedSeats',
16
+ 'allowHumanClaimBot',
17
+ 'onHumanLeave',
18
+ 'initialBotSlots',
19
+ 'seatHoldTicks',
20
+ ]);
15
21
  for (const key of Object.keys(record)) {
16
22
  invariant(allowedKeys.has(key), `seatPolicy contains unknown key: ${key}`, 'seat-control.unknown-key');
17
23
  }
@@ -38,11 +44,17 @@ export function validateSeatPolicy(input, playerCount) {
38
44
  }
39
45
  initialBotSlots = [...seen].sort((a, b) => a - b);
40
46
  }
47
+ let seatHoldTicks;
48
+ if (record.seatHoldTicks !== undefined) {
49
+ invariant(typeof record.seatHoldTicks === 'number' && Number.isInteger(record.seatHoldTicks) && record.seatHoldTicks >= 1, 'seatHoldTicks must be an integer >= 1', 'seat-control.invalid-policy');
50
+ seatHoldTicks = record.seatHoldTicks;
51
+ }
41
52
  return {
42
53
  recycleVacatedSeats,
43
54
  allowHumanClaimBot,
44
55
  onHumanLeave,
45
56
  initialBotSlots,
57
+ ...(seatHoldTicks !== undefined ? { seatHoldTicks } : {}),
46
58
  };
47
59
  }
48
60
  export function validateSeatRecord(record) {
@@ -52,9 +64,13 @@ export function validateSeatRecord(record) {
52
64
  invariant(record.retainedClaim.playerId === record.control.playerId, 'retainedClaim playerId must match human control playerId', 'seat-control.player-mismatch');
53
65
  invariant(record.retainedClaim.claimId === record.control.claimId, 'retainedClaim claimId must match human control claimId', 'seat-control.claim-mismatch');
54
66
  invariant(record.retainedClaim.slot === record.slot, 'retainedClaim slot must match seat slot', 'seat-control.slot-mismatch');
67
+ invariant(record.retainedClaim.holdExpiresAtTick === undefined, 'active human control cannot carry holdExpiresAtTick', 'seat-control.invalid-hold-expiry');
55
68
  }
56
69
  if (record.retainedClaim !== null) {
57
70
  invariant(record.retainedClaim.slot === record.slot, 'retainedClaim slot must match seat slot', 'seat-control.slot-mismatch');
71
+ if (record.retainedClaim.holdExpiresAtTick !== undefined) {
72
+ invariant(Number.isInteger(record.retainedClaim.holdExpiresAtTick) && record.retainedClaim.holdExpiresAtTick >= 0, 'holdExpiresAtTick must be a non-negative integer', 'seat-control.invalid-hold-expiry');
73
+ }
58
74
  }
59
75
  if (record.reservation !== null) {
60
76
  invariant(record.reservation.slot === record.slot, 'reservation slot must match seat slot', 'seat-control.slot-mismatch');
@@ -411,10 +427,11 @@ export function applyTransition(state, intent) {
411
427
  const departingClaimId = currentSeat.control.claimId;
412
428
  const isEvacuation = intent.reason === 'evacuation';
413
429
  const isRecycling = state.policy.recycleVacatedSeats;
430
+ const holdTicks = !isEvacuation && isRecycling ? state.policy.seatHoldTicks : undefined;
414
431
  if (isEvacuation) {
415
432
  nextEvacuatedSlots.add(slot);
416
433
  }
417
- const releaseMode = isEvacuation || isRecycling ? 'retire' : 'retain';
434
+ const releaseMode = isEvacuation || (isRecycling && holdTicks === undefined) ? 'retire' : 'retain';
418
435
  secretRelease = {
419
436
  playerId: departingPlayerId,
420
437
  slot,
@@ -422,7 +439,15 @@ export function applyTransition(state, intent) {
422
439
  reason: intent.reason,
423
440
  };
424
441
  let retainedClaim = currentSeat.retainedClaim;
425
- if (isRecycling || isEvacuation) {
442
+ if (holdTicks !== undefined) {
443
+ retainedClaim = {
444
+ playerId: departingPlayerId,
445
+ claimId: departingClaimId,
446
+ slot,
447
+ holdExpiresAtTick: intent.effectiveTick + holdTicks,
448
+ };
449
+ }
450
+ else if (isRecycling || isEvacuation) {
426
451
  retainedClaim = null;
427
452
  const existingIdx = nextRejoinRecords.findIndex((r) => r.playerId === departingPlayerId);
428
453
  const record = {
@@ -458,10 +483,13 @@ export function applyTransition(state, intent) {
458
483
  const isEvacuation = intent.reason === 'evacuation';
459
484
  const isStagedAbort = intent.reason === 'staged-abort';
460
485
  const isRecycling = state.policy.recycleVacatedSeats;
486
+ const holdTicks = !isStagedAbort && !isEvacuation && isRecycling ? state.policy.seatHoldTicks : undefined;
461
487
  if (isEvacuation) {
462
488
  nextEvacuatedSlots.add(slot);
463
489
  }
464
- const releaseMode = isStagedAbort ? 'retain' : (isEvacuation || isRecycling ? 'retire' : 'retain');
490
+ const releaseMode = isStagedAbort
491
+ ? 'retain'
492
+ : (isEvacuation || (isRecycling && holdTicks === undefined) ? 'retire' : 'retain');
465
493
  secretRelease = {
466
494
  playerId: departingPlayerId,
467
495
  slot,
@@ -469,7 +497,15 @@ export function applyTransition(state, intent) {
469
497
  reason: intent.reason,
470
498
  };
471
499
  let retainedClaim = currentSeat.retainedClaim;
472
- if (!isStagedAbort && (isRecycling || isEvacuation)) {
500
+ if (holdTicks !== undefined) {
501
+ retainedClaim = {
502
+ playerId: departingPlayerId,
503
+ claimId: departingClaimId,
504
+ slot,
505
+ holdExpiresAtTick: intent.effectiveTick + holdTicks,
506
+ };
507
+ }
508
+ else if (!isStagedAbort && (isRecycling || isEvacuation)) {
473
509
  retainedClaim = null;
474
510
  const existingIdx = nextRejoinRecords.findIndex((r) => r.playerId === departingPlayerId);
475
511
  const record = {
@@ -514,6 +550,58 @@ export function applyTransition(state, intent) {
514
550
  },
515
551
  };
516
552
  }
553
+ export function expireSeatHolds(state, tick) {
554
+ let changed = false;
555
+ const nextSeats = [...state.seats];
556
+ const nextRejoinRecords = [...state.rejoinRecords];
557
+ const expired = [];
558
+ for (let slot = 0; slot < state.playerCount; slot += 1) {
559
+ const seat = state.seats[slot];
560
+ if (seat.control.kind !== 'human' &&
561
+ seat.retainedClaim !== null &&
562
+ seat.retainedClaim.holdExpiresAtTick !== undefined &&
563
+ seat.retainedClaim.holdExpiresAtTick <= tick) {
564
+ changed = true;
565
+ const claim = seat.retainedClaim;
566
+ nextSeats[slot] = {
567
+ ...seat,
568
+ retainedClaim: null,
569
+ };
570
+ const existingIdx = nextRejoinRecords.findIndex((r) => r.playerId === claim.playerId);
571
+ const record = {
572
+ playerId: claim.playerId,
573
+ formerSlot: slot,
574
+ formerClaimId: claim.claimId,
575
+ replacedByHuman: false,
576
+ };
577
+ if (existingIdx !== -1) {
578
+ nextRejoinRecords[existingIdx] = record;
579
+ }
580
+ else {
581
+ nextRejoinRecords.push(record);
582
+ }
583
+ expired.push({
584
+ playerId: claim.playerId,
585
+ slot,
586
+ releaseMode: 'retire',
587
+ reason: 'hold-expired',
588
+ });
589
+ }
590
+ }
591
+ if (!changed) {
592
+ return { nextState: state, expired };
593
+ }
594
+ const nextState = {
595
+ playerCount: state.playerCount,
596
+ policy: state.policy,
597
+ seats: nextSeats,
598
+ rejoinRecords: nextRejoinRecords,
599
+ evacuatedSlots: state.evacuatedSlots,
600
+ legacyBotSlots: state.legacyBotSlots,
601
+ };
602
+ validateInvariants(nextState);
603
+ return { nextState, expired };
604
+ }
517
605
  export function createSeatCheckpoint(state, policyDigest) {
518
606
  return {
519
607
  v: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@series-inc/rundot-syncplay",
3
- "version": "6.0.0-rc.83",
3
+ "version": "6.0.0-rc.85",
4
4
  "description": "Kinetix orchestration, rollback, replay, late-join, and deterministic networking for RUN.game",
5
5
  "repository": {
6
6
  "type": "git",
@@ -261,7 +261,7 @@
261
261
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
262
262
  "test": "npm run test:core && npm run test:capability-restoration && npm run test:unit-control && npm run test:entity-registry",
263
263
  "test:module-promotion": "node --expose-gc --import tsx --test tests/module-promotion.test.ts tests/module-docs.test.ts tests/module-bundle-budget.test.ts scripts/prove-module-promotion.test.mjs scripts/lib/proof-source-closure.test.mjs",
264
- "test:core": "node --expose-gc --experimental-test-module-mocks --import tsx --test --test-concurrency=1 tests/canonical.test.ts tests/canonical-portability.test.ts tests/runtime-session.test.ts tests/kinetix-runtime-session.test.ts tests/runtime-support.test.ts tests/runtime-guards.test.ts tests/r3f-render-adapter.test.ts tests/snapshot-cost.test.ts tests/sdkSession.test.ts tests/input-authority.test.ts tests/session-wire.test.ts tests/runtime-room-metadata.test.ts tests/session-snapshot.test.ts tests/authority-room.test.ts tests/networked-client-snapshot.test.ts tests/runner.test.ts tests/testing.test.ts tests/browser-session.test.ts tests/secret-config.test.ts tests/secret-protocol.test.ts tests/secret-authority.test.ts tests/secret-client.test.ts tests/secret-holder-release.test.ts tests/seat-control-parity.test.ts tests/seat-control.test.ts tests/seat-control-runtime.test.ts tests/late-join-checksum.test.ts tests/late-join-input-backfill.test.ts tests/replay-scoring.test.ts tests/bot-backfill.test.ts tests/latency-simulation.test.ts tests/production-input-budget.test.ts tests/time-sync.test.ts tests/match-log.test.ts tests/spectator.test.ts tests/synctest.test.ts tests/instant-replay.test.ts tests/session-promotion.test.ts tests/entrypoints.test.ts tests/physics-profile-bundle.test.ts tests/physics-profile-init.test.ts tests/export-surface.test.ts tests/creator-facing-names.test.ts tests/module-seam.test.ts tests/module-contract-portability.test.ts tests/module-identity.test.ts tests/module-corpus.test.ts tests/component-model.test.ts tests/component-model-rollback.test.ts tests/component-model-integration.test.ts tests/actors-ai.test.ts tests/character-3d.test.ts tests/character-3d-certification.test.ts tests/combat-modules.test.ts tests/combat-modules-integration.test.ts tests/firearm.test.ts tests/gameplay-effects.test.ts tests/spatial-interaction.test.ts tests/stats-abilities.test.ts tests/inventory-equipment.test.ts tests/inventory-equipment-certification.test.ts tests/platformer-2d.test.ts tests/platformer-2d-certification.test.ts tests/module-promotion.test.ts tests/module-docs.test.ts tests/module-bundle-budget.test.ts tests/published-side-effects.test.ts tests/host-timing.test.ts tests/test-manifest.test.ts tests/coarse-region.test.ts tests/input-codec.test.ts tests/command-ingress.test.ts tests/session-reconfigure.test.ts tests/prediction-mode.test.ts tests/ephemeral-channel.test.ts tests/runner-surface.test.ts tests/runner-harness.test.ts tests/effects-adapter-bounds.test.ts tests/simulated-match-secrets.test.ts core/tests/core-boundary.test.mjs tests/math-core-parity.test.ts tests/periodic-math.test.ts tests/periodic-noise.test.ts tests/periodic-render.test.ts tests/periodic-grid.test.ts tests/physics-periodic-queries.test.ts tests/math-profile.test.ts tests/movement3d-kcc-unit-contract.test.ts tests/movement3d-static-ground.test.ts tests/physical-assembly.test.ts tests/physical-assembly-determinism.test.ts tests/physical-assembly-certification.test.ts tests/physical-assembly-multiplayer.test.ts tests/state-digest.test.ts tests/large-blob-state.test.ts tests/math-installation-order.test.ts tests/networked-blob-state.test.ts tests/networked-checksum-burst.test.ts tests/networked-runtime-commit.test.ts tests/physics-helper-motion-reads.test.ts tests/physics-unit-conversions.test.ts tests/portal-physics.test.ts tests/physics-checkpoint-capacity.test.ts tests/runner-cleanup.test.ts tests/runtime-release-outcome.test.ts tests/session-checkpoint-budget.test.ts tests/session-owned-cleanup.test.ts tests/history-retention-memory.test.ts tests/mobile-settings-recovery.test.ts tests/confirmed-frame-budget.test.ts tests/tool-owned-adapter.test.ts tests/tool-runtime-lifetime.test.ts tests/movement3d-revision1-baseline.test.ts tests/movement3d-revision1-corpus.test.ts tests/legacy-query-revision1-corpus.test.ts tests/physics-support-boundary.test.ts tests/kcc-corpus-encoding.test.ts tests/voxel-swept-quad-paint.test.ts tests/physics-support-artifact.test.ts tests/physics-si-pulley-runtime.test.ts tests/vehicle-2d.test.ts tests/vehicle-2d-rollback.test.ts tests/vehicle-state3d.test.ts tests/vehicle-state3d-artifact.test.ts tests/partner-rc22-codecs-units.test.ts tests/vehicle-acceptance-matrix.test.ts tests/vehicle-loose-debris.test.ts tests/partner-tarball-closure.test.ts tests/packed-exports.test.ts tests/extraction-fingerprint.test.mjs tests/physics-si-rope-gear-powertrain-runtime.test.ts tests/voxel-body-state.test.ts tests/voxel-carve-cell-sizes.test.ts tests/wreck-yard-d-features.test.ts tests/wreck-yard-regression.test.ts tests/wreck-yard-rc33-gaps.test.ts tests/wreck-yard-rc55-findings.test.ts tests/wreck-yard-rc59-findings.test.ts tests/wreck-yard-rc60-findings.test.ts tests/wreck-yard-rc62-findings.test.ts tests/stack-solver-momentum.test.ts tests/vite-plugin-wasm.test.ts tests/portal-parity-ratchet.test.ts tests/solver-storage-memory-guard.test.ts tests/query-index-parity.test.ts tests/query-index-maintenance.test.ts tests/query-index-churn.test.ts tests/query-index-drift.test.ts tests/query-index-rollback.test.ts tests/portal-render3d.test.ts tests/portal-view-budget.test.ts tests/portal-queries-inside.test.ts tests/portal-render-state.test.ts tests/portal-host-walls.test.ts tests/portal-queries.test.ts tests/portal-placement.test.ts tests/portal-proxies.test.ts tests/portal-a7.test.ts tests/portal-review.test.ts tests/portal-physics-gaps.test.ts tests/extraction.test.ts tests/plugin-lifecycle.test.ts tests/core-zero-io-boundary.test.ts tests/movement3d-revision3-standing.test.mjs tests/movement3d-revision3-recovery.test.mjs tests/coop-shaped-offline.test.ts tests/physics-debug-overlay.test.ts tests/collider-preparation.test.ts tests/navmesh-geometry-cooking.test.ts tests/presentation-ik.test.ts tests/lag-compensation-history.test.ts tests/js-hotpath-regression.test.ts tests/physics-materials-boundary.test.ts tests/physics-materials.test.ts tests/portal-moved-only-tracking.test.ts tests/starved-client-own-input.test.ts tests/connected-catchup-input.test.ts tests/engine-native-math.test.ts tests/body-activity-counts.test.ts tests/physics-wake-on-remove.test.ts tests/box3d-host-filter-ccd.test.ts tests/box3d-public-kcc-vehicle-route.test.ts tests/box3d-sleep-restore-identity.test.ts tests/box3d-support-substep-route.test.ts tests/box3d-backend-contact-materials.test.ts tests/box3d-backend-filter-rules.test.ts tests/box3d-backend-joint-records.test.ts tests/box3d-backend-six-dof.test.ts tests/box3d-checkpoint-continuation.test.ts tests/box3d-deformable-checkpoint.test.ts tests/box3d-deformable-cloth.test.ts tests/box3d-deformable-fracture.test.ts tests/box3d-deformable-particles.test.ts tests/box3d-deformable-rope.test.ts tests/box3d-deformable-sdf.test.ts tests/box3d-deformable-soft-body.test.ts tests/box3d-deformable-integrity.test.ts tests/box3d-deformable-world-registry.test.ts tests/box3d-support-rollback.test.ts tests/box3d-rollback-replay-sweep.test.ts tests/box3d-read-purity.test.ts tests/box3d-restore-forced-sleep.test.ts tests/box3d-wake-digest.test.ts tests/portal-slice-route.test.ts tests/box3d-multi-world-independence.test.ts tests/box3d-on-demand-contacts.test.ts tests/box3d-portal-clone-queries.test.ts tests/box3d-dense-ids-after-removal.test.ts tests/box3d-joint-read-restore.test.ts tests/box3d-joint-read-frame.test.ts tests/box3d-joint-reaction-getters.test.ts tests/box3d-recreated-body-events.test.ts tests/box3d-end-on-removal.test.ts tests/box3d-sensor-shape-pairs.test.ts tests/box3d-event-capacity.test.ts tests/box3d-shared-shape-events.test.ts tests/box3d-adapter-stay-rows.test.ts tests/box3d-step-reads-checked.test.ts tests/box3d-edit-keeps-sleep-time.test.ts tests/donor-transfer-pacing.test.ts tests/box3d-restore-exact-state.test.ts tests/box3d-failed-step-atomic.test.ts tests/box3d-failed-step-post-publication.test.ts tests/box3d-support-read-purity.test.ts tests/box3d-portal-step-exclusions.test.ts tests/box3d-filter-flags-after-removal.test.ts tests/physics-replace-body-key.test.ts tests/box3d-portal-clone-filters.test.ts tests/box3d-portal-plan-ids.test.ts tests/box3d-recreated-pair-closure.test.ts tests/box3d-edit-net-shape-events.test.ts tests/box3d-restored-world-options.test.ts tests/checkpoint-latest-frame-inputs.test.ts tests/frame-bound-reads.test.mjs tests/physics-edit-call-order.test.ts",
264
+ "test:core": "node --expose-gc --experimental-test-module-mocks --import tsx --test --test-concurrency=1 tests/canonical.test.ts tests/canonical-portability.test.ts tests/runtime-session.test.ts tests/kinetix-runtime-session.test.ts tests/runtime-support.test.ts tests/runtime-guards.test.ts tests/r3f-render-adapter.test.ts tests/snapshot-cost.test.ts tests/sdkSession.test.ts tests/input-authority.test.ts tests/session-wire.test.ts tests/runtime-room-metadata.test.ts tests/session-snapshot.test.ts tests/authority-room.test.ts tests/networked-client-snapshot.test.ts tests/runner.test.ts tests/testing.test.ts tests/browser-session.test.ts tests/secret-config.test.ts tests/secret-protocol.test.ts tests/secret-authority.test.ts tests/secret-client.test.ts tests/secret-holder-release.test.ts tests/seat-control-parity.test.ts tests/seat-control.test.ts tests/seat-control-runtime.test.ts tests/late-join-checksum.test.ts tests/late-join-input-backfill.test.ts tests/replay-scoring.test.ts tests/bot-backfill.test.ts tests/latency-simulation.test.ts tests/production-input-budget.test.ts tests/time-sync.test.ts tests/match-log.test.ts tests/spectator.test.ts tests/synctest.test.ts tests/instant-replay.test.ts tests/session-promotion.test.ts tests/entrypoints.test.ts tests/physics-profile-bundle.test.ts tests/physics-profile-init.test.ts tests/export-surface.test.ts tests/creator-facing-names.test.ts tests/module-seam.test.ts tests/module-contract-portability.test.ts tests/module-identity.test.ts tests/module-corpus.test.ts tests/component-model.test.ts tests/component-model-rollback.test.ts tests/component-model-integration.test.ts tests/actors-ai.test.ts tests/character-3d.test.ts tests/character-3d-certification.test.ts tests/combat-modules.test.ts tests/combat-modules-integration.test.ts tests/firearm.test.ts tests/gameplay-effects.test.ts tests/spatial-interaction.test.ts tests/stats-abilities.test.ts tests/inventory-equipment.test.ts tests/inventory-equipment-certification.test.ts tests/platformer-2d.test.ts tests/platformer-2d-certification.test.ts tests/module-promotion.test.ts tests/module-docs.test.ts tests/module-bundle-budget.test.ts tests/published-side-effects.test.ts tests/host-timing.test.ts tests/test-manifest.test.ts tests/coarse-region.test.ts tests/input-codec.test.ts tests/command-ingress.test.ts tests/session-reconfigure.test.ts tests/prediction-mode.test.ts tests/ephemeral-channel.test.ts tests/runner-surface.test.ts tests/runner-harness.test.ts tests/effects-adapter-bounds.test.ts tests/simulated-match-secrets.test.ts core/tests/core-boundary.test.mjs tests/math-core-parity.test.ts tests/periodic-math.test.ts tests/periodic-noise.test.ts tests/periodic-render.test.ts tests/periodic-grid.test.ts tests/physics-periodic-queries.test.ts tests/math-profile.test.ts tests/movement3d-kcc-unit-contract.test.ts tests/movement3d-static-ground.test.ts tests/physical-assembly.test.ts tests/physical-assembly-determinism.test.ts tests/physical-assembly-certification.test.ts tests/physical-assembly-multiplayer.test.ts tests/state-digest.test.ts tests/large-blob-state.test.ts tests/math-installation-order.test.ts tests/networked-blob-state.test.ts tests/networked-checksum-burst.test.ts tests/networked-runtime-commit.test.ts tests/physics-helper-motion-reads.test.ts tests/physics-unit-conversions.test.ts tests/portal-physics.test.ts tests/physics-checkpoint-capacity.test.ts tests/runner-cleanup.test.ts tests/runtime-release-outcome.test.ts tests/session-checkpoint-budget.test.ts tests/session-owned-cleanup.test.ts tests/history-retention-memory.test.ts tests/mobile-settings-recovery.test.ts tests/confirmed-frame-budget.test.ts tests/tool-owned-adapter.test.ts tests/tool-runtime-lifetime.test.ts tests/movement3d-revision1-baseline.test.ts tests/movement3d-revision1-corpus.test.ts tests/legacy-query-revision1-corpus.test.ts tests/physics-support-boundary.test.ts tests/kcc-corpus-encoding.test.ts tests/voxel-swept-quad-paint.test.ts tests/physics-support-artifact.test.ts tests/physics-si-pulley-runtime.test.ts tests/vehicle-2d.test.ts tests/vehicle-2d-rollback.test.ts tests/vehicle-state3d.test.ts tests/vehicle-state3d-artifact.test.ts tests/partner-rc22-codecs-units.test.ts tests/vehicle-acceptance-matrix.test.ts tests/vehicle-loose-debris.test.ts tests/partner-tarball-closure.test.ts tests/packed-exports.test.ts tests/extraction-fingerprint.test.mjs tests/physics-si-rope-gear-powertrain-runtime.test.ts tests/voxel-body-state.test.ts tests/voxel-carve-cell-sizes.test.ts tests/wreck-yard-d-features.test.ts tests/wreck-yard-regression.test.ts tests/wreck-yard-rc33-gaps.test.ts tests/wreck-yard-rc55-findings.test.ts tests/wreck-yard-rc59-findings.test.ts tests/wreck-yard-rc60-findings.test.ts tests/wreck-yard-rc62-findings.test.ts tests/stack-solver-momentum.test.ts tests/vite-plugin-wasm.test.ts tests/portal-parity-ratchet.test.ts tests/solver-storage-memory-guard.test.ts tests/query-index-parity.test.ts tests/query-index-maintenance.test.ts tests/query-index-churn.test.ts tests/query-index-drift.test.ts tests/query-index-rollback.test.ts tests/portal-render3d.test.ts tests/portal-view-budget.test.ts tests/portal-queries-inside.test.ts tests/portal-render-state.test.ts tests/portal-host-walls.test.ts tests/portal-queries.test.ts tests/portal-placement.test.ts tests/portal-proxies.test.ts tests/portal-a7.test.ts tests/portal-review.test.ts tests/portal-physics-gaps.test.ts tests/extraction.test.ts tests/plugin-lifecycle.test.ts tests/core-zero-io-boundary.test.ts tests/movement3d-revision3-standing.test.mjs tests/movement3d-revision3-recovery.test.mjs tests/coop-shaped-offline.test.ts tests/physics-debug-overlay.test.ts tests/collider-preparation.test.ts tests/navmesh-geometry-cooking.test.ts tests/presentation-ik.test.ts tests/lag-compensation-history.test.ts tests/js-hotpath-regression.test.ts tests/physics-materials-boundary.test.ts tests/physics-materials.test.ts tests/portal-moved-only-tracking.test.ts tests/starved-client-own-input.test.ts tests/connected-catchup-input.test.ts tests/engine-native-math.test.ts tests/body-activity-counts.test.ts tests/physics-wake-on-remove.test.ts tests/box3d-host-filter-ccd.test.ts tests/box3d-public-kcc-vehicle-route.test.ts tests/box3d-sleep-restore-identity.test.ts tests/box3d-support-substep-route.test.ts tests/box3d-backend-contact-materials.test.ts tests/box3d-backend-filter-rules.test.ts tests/box3d-backend-joint-records.test.ts tests/box3d-backend-six-dof.test.ts tests/box3d-checkpoint-continuation.test.ts tests/box3d-deformable-checkpoint.test.ts tests/box3d-deformable-cloth.test.ts tests/box3d-deformable-fracture.test.ts tests/box3d-deformable-particles.test.ts tests/box3d-deformable-rope.test.ts tests/box3d-deformable-sdf.test.ts tests/box3d-deformable-soft-body.test.ts tests/box3d-deformable-integrity.test.ts tests/box3d-deformable-world-registry.test.ts tests/box3d-support-rollback.test.ts tests/box3d-rollback-replay-sweep.test.ts tests/box3d-read-purity.test.ts tests/box3d-restore-forced-sleep.test.ts tests/box3d-wake-digest.test.ts tests/portal-slice-route.test.ts tests/box3d-multi-world-independence.test.ts tests/box3d-on-demand-contacts.test.ts tests/box3d-portal-clone-queries.test.ts tests/box3d-dense-ids-after-removal.test.ts tests/box3d-joint-read-restore.test.ts tests/box3d-joint-read-frame.test.ts tests/box3d-joint-reaction-getters.test.ts tests/box3d-recreated-body-events.test.ts tests/box3d-end-on-removal.test.ts tests/box3d-sensor-shape-pairs.test.ts tests/box3d-event-capacity.test.ts tests/box3d-shared-shape-events.test.ts tests/box3d-adapter-stay-rows.test.ts tests/box3d-step-reads-checked.test.ts tests/box3d-edit-keeps-sleep-time.test.ts tests/donor-transfer-pacing.test.ts tests/donor-snapshot-refusal.test.ts tests/donor-drain-timer.test.ts tests/client-duration-clock.test.ts tests/box3d-restore-exact-state.test.ts tests/box3d-failed-step-atomic.test.ts tests/box3d-failed-step-post-publication.test.ts tests/box3d-support-read-purity.test.ts tests/box3d-portal-step-exclusions.test.ts tests/box3d-filter-flags-after-removal.test.ts tests/physics-replace-body-key.test.ts tests/box3d-portal-clone-filters.test.ts tests/box3d-portal-plan-ids.test.ts tests/box3d-recreated-pair-closure.test.ts tests/box3d-edit-net-shape-events.test.ts tests/box3d-restored-world-options.test.ts tests/checkpoint-latest-frame-inputs.test.ts tests/frame-bound-reads.test.mjs tests/physics-edit-call-order.test.ts",
265
265
  "test:sdk-contract": "node --import tsx --test tests/sdk-runtime-contract.test.ts",
266
266
  "test:soak": "tsx --test tests/runtime-soak.test.ts",
267
267
  "test:extended": "node --expose-gc --import tsx --test --test-concurrency=1 tests/performance-primitives.test.ts tests/js-hotpath-perf-guard.test.ts tests/portal-straddler-mesh-cost.test.ts tests/active-voxel-stack.test.ts && tsx --test tests/animation.test.ts tests/asset-cooking.test.ts tests/backend-proof-checksum-vectors.test.ts tests/bot-documents.test.ts tests/bot-primitives.test.ts tests/collision.test.ts tests/command-timeline.test.ts tests/config-bundle.test.ts tests/deterministic-primitives.test.ts tests/ecs-lite.test.ts tests/effects-adapter.test.ts tests/engine-runtime.test.ts tests/errors.test.ts tests/events.test.ts tests/input-button.test.ts tests/load-128-players.test.ts tests/math.test.ts tests/movement.test.ts tests/movement3d.test.ts tests/multiclient-authority.test.ts tests/navigation.test.ts tests/noise.test.ts tests/physics3d-geometry-limits.test.ts tests/physics3d-shared.test.ts tests/physics3d-static-memoization.test.ts tests/random.test.ts tests/rollback-history.test.ts tests/schema-artifacts.test.ts tests/schema-codegen.test.ts tests/schema-dsl-binary.test.ts tests/schema.test.ts tests/signals.test.ts tests/sparse-set.test.ts tests/static-checker.test.ts tests/system-lifecycle.test.ts tests/wire-canonical-sentinels.test.ts tests/ws-frame.test.ts tests/wreck-yard-defects.test.ts tests/wreck-yard-performance-harness.test.ts tests/wreck-yard-partner-verification-rc15.test.ts tests/yawed-crate-stack-settling.test.ts tests/tilted-crate-stack-settling.test.ts tests/query-index-cost.test.ts tests/wreck-yard-vehicle-batch.test.ts tests/engine-runtime-free-list.test.ts",