castle-web-cli 0.4.238 → 0.4.239

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.
Files changed (51) hide show
  1. package/dist/castle-host/host.js +55 -0
  2. package/dist/index.js +16 -0
  3. package/dist/init.js +1 -1
  4. package/dist/multiplayerDoc.d.ts +1 -1
  5. package/dist/multiplayerDoc.js +9 -0
  6. package/dist/platformDoc.js +2 -1
  7. package/dist/playPagePolicy.d.ts +1 -0
  8. package/dist/playPagePolicy.js +8 -3
  9. package/dist/roomLogs.d.ts +39 -0
  10. package/dist/roomLogs.js +166 -0
  11. package/kits/base/CLAUDE.md +1 -0
  12. package/kits/base/castle.json +1 -1
  13. package/kits/base/sdk/README.md +66 -2
  14. package/kits/base/sdk/castle.d.ts +3 -1
  15. package/kits/base/sdk/castle.js +1 -0
  16. package/kits/base/sdk/commands.d.ts +31 -0
  17. package/kits/base/sdk/multiplayer.js +30 -0
  18. package/kits/base/sdk/rooms.d.ts +11 -0
  19. package/kits/base/sdk/rooms.js +22 -0
  20. package/kits/base/sdk/store.d.ts +8 -2
  21. package/kits/base/sdk/store.js +5 -1
  22. package/kits/hub-game/castle.json +4 -4
  23. package/kits/hub-game/code/client/chrome.js +3 -2
  24. package/kits/hub-game/code/client/menuRows.js +8 -2
  25. package/kits/hub-game/code/client/vehicle.js +3 -1
  26. package/kits/hub-game/code/client/worldLabels.js +10 -1
  27. package/kits/hub-game/code/server/analytics.js +5 -12
  28. package/kits/hub-game/code/server/doorAnalytics.js +2 -5
  29. package/kits/hub-game/code/server/hub.js +3 -0
  30. package/kits/hub-game/code/server/loadAbandon.js +2 -5
  31. package/kits/hub-game/code/server/trackQueue.js +29 -0
  32. package/kits/hub-game/code/systems/hub.js +10 -3
  33. package/kits/hub-game/docs/analytics.md +4 -1
  34. package/kits/hub-game/package.json +1 -1
  35. package/kits/hub-game/scripts/test-analytics.mjs +1 -1
  36. package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
  37. package/kits/hub-game/scripts/test-hub-ops.mjs +28 -0
  38. package/kits/hub-game/scripts/test-hub-trip.mjs +20 -1
  39. package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
  40. package/kits/hub-game/scripts/test-menu-client.mjs +1 -1
  41. package/kits/hub-game/scripts/test-resync.mjs +13 -0
  42. package/kits/hub-game/scripts/test-role-client.mjs +8 -2
  43. package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
  44. package/kits/hub-game/scripts/test-vehicle-client.mjs +9 -0
  45. package/kits/hub-game/scripts/test-world-labels.mjs +40 -0
  46. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +12 -0
  47. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +12 -2
  48. package/kits/multiplayer-3d/castle.json +4 -4
  49. package/kits/physics-3d/castle.json +2 -2
  50. package/kits/real-time/castle.json +2 -2
  51. package/package.json +1 -1
@@ -19,9 +19,25 @@ export interface StoreAllowance {
19
19
  byteCount: number;
20
20
  byteLimit: number;
21
21
  }
22
+ /** One storage rate window: what was spent in the current second, and its limits. */
23
+ export interface StoreRateBudget {
24
+ opsUsed: number;
25
+ opsLimit: number;
26
+ bytesUsed: number;
27
+ bytesLimit: number;
28
+ }
29
+ /** The storage rate windows a call is charged against. */
30
+ export interface StoreRateUsage {
31
+ /** Which caller bucket answered: "client", "server", "session" or "town-layer". */
32
+ callerClass: string;
33
+ caller: StoreRateBudget;
34
+ deck: StoreRateBudget;
35
+ }
22
36
  export interface StoreAllowances {
23
37
  player: StoreAllowance;
24
38
  shared: StoreAllowance;
39
+ /** Absent from a host older than the rate field. */
40
+ rate?: StoreRateUsage;
25
41
  }
26
42
  export interface StoreBoardEntry {
27
43
  subject: string;
@@ -96,6 +112,19 @@ export interface SocialPresence extends SocialFriend {
96
112
  slot?: string;
97
113
  updatedAt: string;
98
114
  }
115
+ /** One public room of the current deck, as Castle last counted it. */
116
+ export interface RoomSummary {
117
+ sessionId: string;
118
+ routeId?: string;
119
+ slot?: string;
120
+ players: number;
121
+ maxPlayers: number;
122
+ }
123
+ export interface RoomsListResult {
124
+ /** Players across every room listed. */
125
+ total: number;
126
+ rooms: RoomSummary[];
127
+ }
99
128
  export type PartyStatus = "invited" | "joined" | "rejected" | "left" | "party_closed" | "banned";
100
129
  export interface PartySummary {
101
130
  partyId: string;
@@ -799,6 +828,7 @@ export interface CommandParams {
799
828
  subject?: string | null;
800
829
  };
801
830
  "cauldronStorage.usage": Record<string, never>;
831
+ "rooms.list": Record<string, never>;
802
832
  "lifecycle.restoreState": Record<string, never>;
803
833
  "localCache.get": {
804
834
  key: string;
@@ -956,6 +986,7 @@ export interface CommandResult {
956
986
  "cauldronStorage.usage": {
957
987
  usage: StoreAllowances;
958
988
  };
989
+ "rooms.list": RoomsListResult | null;
959
990
  "lifecycle.restoreState": LifecycleRestoreStateResult;
960
991
  "localCache.get": {
961
992
  value: ArrayBuffer | string | null;
@@ -75,6 +75,9 @@ async function join(options) {
75
75
  // The host answers `unavailable` while ghost is busy with this player; the
76
76
  // trip stays pending there, so asking again is safe.
77
77
  const HUB_COMMIT_RETRY_MS = [1_000, 2_000, 4_000, 8_000];
78
+ // A hub join's tries of the same nonce while the proxy cannot route the new
79
+ // session yet (`openHubSocket`), well inside the nonce's unconsumed life.
80
+ const HUB_UNROUTED_RETRY_MS = [500, 1_000, 2_000];
78
81
  async function commitHubTrip(nonce, sessionId) {
79
82
  for (let attempt = 0;; attempt++) {
80
83
  let status;
@@ -458,8 +461,35 @@ class MultiplayerConnectionImpl {
458
461
  if (savedToken && await this.restoreDevReconnect(savedToken))
459
462
  return;
460
463
  this.assertOpen();
464
+ if (this.request.command === "hub") {
465
+ await this.openHubSocket(result.nonce);
466
+ return;
467
+ }
461
468
  await this.openSocket("nonce", result.nonce);
462
469
  }
470
+ // A hub session ghost has just started can be refused by the play proxy
471
+ // before its route is readable there (4404, before any hello). The proxy
472
+ // refuses before the session sees the nonce, so the nonce is still good:
473
+ // try it again for a few seconds before the trip is given back.
474
+ async openHubSocket(nonce) {
475
+ for (let attempt = 0;; attempt++) {
476
+ try {
477
+ await this.openSocket("nonce", nonce);
478
+ return;
479
+ }
480
+ catch (error) {
481
+ const delay = HUB_UNROUTED_RETRY_MS[attempt];
482
+ if (!(error instanceof SocketClosedError) ||
483
+ error.code !== PROXY_SESSION_ENDED_CLOSE_CODE ||
484
+ delay === undefined) {
485
+ throw error;
486
+ }
487
+ this.assertOpen();
488
+ await pause(delay);
489
+ this.assertOpen();
490
+ }
491
+ }
492
+ }
463
493
  async restoreDevReconnect(token) {
464
494
  this.assertOpen();
465
495
  const budget = this.reconnectBudget = new ReconnectBudget();
@@ -0,0 +1,11 @@
1
+ import type { RoomsListResult } from "./commands";
2
+ export type { RoomSummary, RoomsListResult } from "./commands";
3
+ export interface CastleRoomsApi {
4
+ /**
5
+ * This deck's public rooms with their player counts, or null when Castle
6
+ * will not list them for this player or the app running the deck predates
7
+ * the call. Null is "not available", never "no rooms".
8
+ */
9
+ list(): Promise<RoomsListResult | null>;
10
+ }
11
+ export declare const Rooms: CastleRoomsApi;
@@ -0,0 +1,22 @@
1
+ // Rooms — the current deck's public multiplayer rooms and how many players are
2
+ // in each, for a lobby or a "players online" line. Castle always lists them
3
+ // to the deck's owner and Castle admins, to other players only as far as its
4
+ // presence rollout reaches, and never to a player under 13 or kept out of
5
+ // multiplayer; anyone it will not list them for gets null.
6
+ //
7
+ // Counts come from a rollup Castle refreshes about every 10 seconds, so a
8
+ // player who just joined or left may not show yet. Private, party and named
9
+ // rooms are not listed.
10
+ import { CastleError } from "./errors";
11
+ import { hostRequest } from "./transport";
12
+ async function list() {
13
+ try {
14
+ return await hostRequest("rooms.list", {});
15
+ }
16
+ catch (error) {
17
+ if (error instanceof CastleError && error.code === "UNKNOWN_COMMAND")
18
+ return null;
19
+ throw error;
20
+ }
21
+ }
22
+ export const Rooms = Object.freeze({ list });
@@ -1,4 +1,4 @@
1
- import type { StoreAllowance } from "./commands";
1
+ import type { StoreAllowance, StoreRateBudget, StoreRateUsage } from "./commands";
2
2
  import type { Json } from "./types";
3
3
  import { type SaveApi, type SaveBucketApi } from "./save";
4
4
  export interface StoreListOptions {
@@ -54,7 +54,7 @@ export interface StoreBoardApi {
54
54
  /** One player's score, defaulting to the current player. Null if unset. */
55
55
  get(userId?: string): Promise<StoreBoardScore | null>;
56
56
  }
57
- export type { StoreAllowance };
57
+ export type { StoreAllowance, StoreRateBudget, StoreRateUsage };
58
58
  export interface StoreUsage {
59
59
  /**
60
60
  * The current player's own data in this deck: their `Store.me` and
@@ -63,6 +63,12 @@ export interface StoreUsage {
63
63
  player: StoreAllowance;
64
64
  /** `Store.deck`: one allowance shared by every player of the deck. */
65
65
  shared: StoreAllowance;
66
+ /**
67
+ * How much of the current second's call and byte rate limits is spent, for
68
+ * the current player (`caller`) and for every player of the deck together
69
+ * (`deck`). Counts this usage call. Absent when the app is too old to report it.
70
+ */
71
+ rate?: StoreRateUsage;
66
72
  }
67
73
  export interface CastleStoreApi extends SaveApi {
68
74
  /** Shared by everyone playing the deck. */
@@ -309,7 +309,11 @@ async function usage() {
309
309
  // caller.
310
310
  await Promise.all(Array.from(buckets.values(), (bucket) => flushBucket(bucket, false)));
311
311
  const { usage: allowances } = await hostRequest("cauldronStorage.usage", {});
312
- return { player: allowances.player, shared: allowances.shared };
312
+ const result = { player: allowances.player, shared: allowances.shared };
313
+ // An app built before the rate field answers without it.
314
+ if (allowances.rate)
315
+ result.rate = allowances.rate;
316
+ return result;
313
317
  }
314
318
  // Saves skip the write coalescing above: each is one request, sent at once.
315
319
  const saveApi = createSaveApi((verb, input) => hostRequest(`cauldronStorage.${verb}`, input));
@@ -6,15 +6,15 @@
6
6
  "imports": {
7
7
  "castle.multiplayer-3d": {
8
8
  "deckId": "ZwA_P_-VO-Qh",
9
- "version": "2026-10-18T06:47:00.410Z"
9
+ "version": "2026-10-23T12:15:36.617Z"
10
10
  },
11
11
  "castle.real-time": {
12
12
  "deckId": "xFVr-afOLuUQ",
13
- "version": "2026-10-18T06:38:41.691Z"
13
+ "version": "2026-10-23T12:14:35.623Z"
14
14
  },
15
15
  "castle.physics-3d": {
16
16
  "deckId": "JH0SclbPVP0y",
17
- "version": "2026-10-18T06:40:58.918Z",
17
+ "version": "2026-10-23T12:14:42.092Z",
18
18
  "via": "castle.multiplayer-3d"
19
19
  },
20
20
  "castle.physics-2d": {
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "castle.base": {
26
26
  "deckId": "yRcmH4_aYllE",
27
- "version": "2026-10-18T10:34:27.709Z"
27
+ "version": "2026-10-23T12:08:44.010Z"
28
28
  }
29
29
  },
30
30
  "autoUpdateWhenImported": true,
@@ -2995,8 +2995,9 @@ export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount,
2995
2995
  surface('cabinet', cabinet, 'card', true), surface('feed', feed, 'text', true, { left: 10 }),
2996
2996
  surface('stats', stats, 'text', true, { right: 8, top: 8 }), surface('stuck', stuckChip, 'pointer', true),
2997
2997
  ...[...labelNodes].map(([id, node]) => ({ ...surface(`label:${id}`, node, 'label', true),
2998
- // A role chip belongs under its name tag, which is drawn over the viewer's body anyway.
2999
- ignoreObstacle: id.startsWith('role:') ? worldAvatar : null })),
2998
+ // A role chip belongs under its name tag, and a place's tag (`hub.mark`) over a head,
2999
+ // the viewer's own included; both are drawn over the viewer's body anyway.
3000
+ ignoreObstacle: id.startsWith('role:') || id.startsWith('mark:') ? worldAvatar : null })),
3000
3001
  ...[...pointerNodes].map(([id, item]) => surface(`pointer:${id}`, item.chip, 'pointer', true)),
3001
3002
  ...externalEntries().map(([id, item]) => ({ ...surface(id, item.node, item.kind, item.kind === 'text'), ...item.placement, ...(id === 'engine-shift-lock' ? { stack: 4 } : {}) })),
3002
3003
  ...(actionOverflow?.surfaces?.() ?? []).map((node, i) => surface(`action-overflow:${i}`, node, 'control')),
@@ -6,7 +6,7 @@ export function drawMenuRows({ el, sheet, scroll, spec, signal, pick }) {
6
6
  const readOnly = spec.readOnly === true || item.readOnly === true;
7
7
  const row = el(readOnly ? 'div' : 'button', {
8
8
  width: '100%', boxSizing: 'border-box', minHeight: '32px', padding: '6px 8px',
9
- display: 'grid', gridTemplateColumns: item.columns ? 'minmax(0, 1fr) minmax(0, 4fr) minmax(0, 2fr)' : '1fr',
9
+ display: 'grid', gridTemplateColumns: item.columns ? 'minmax(0, 6em) minmax(4em, 1fr) minmax(0, max-content)' : '1fr',
10
10
  alignItems: 'center', gap: '8px', textAlign: 'left',
11
11
  color: 'inherit', font: 'inherit', lineHeight: '20px', background: 'transparent',
12
12
  border: '0', borderBottom: '1px solid var(--castle-border-2, rgba(255,255,255,.25))',
@@ -14,8 +14,14 @@ export function drawMenuRows({ el, sheet, scroll, spec, signal, pick }) {
14
14
  }, scroll);
15
15
  row.dataset.menuRow = '';
16
16
  row.dataset.id = item.id;
17
+ // The outer columns break between words where they can, so a narrow
18
+ // sheet (a phone held sideways) does not split a short name: the left
19
+ // one is a steady 6em so the middles line up, the right one takes its
20
+ // own width, and both shrink rather than overflow. The middle column
21
+ // keeps at least 4em, gets the rest and wraps anywhere.
17
22
  for (const [index, text] of (item.columns ?? [item.label]).entries()) {
18
- el('span', { minWidth: '0', whiteSpace: 'normal', ...(index === 2 ? { textAlign: 'right' } : {}) }, row).textContent = text;
23
+ const outer = item.columns && index !== 1;
24
+ el('span', { minWidth: '0', whiteSpace: 'normal', ...(outer ? { overflowWrap: 'break-word' } : {}), ...(index === 2 ? { textAlign: 'right' } : {}) }, row).textContent = text;
19
25
  }
20
26
  if (!readOnly) {
21
27
  row.type = 'button';
@@ -118,7 +118,9 @@ export function makeVehicle() {
118
118
  installed = { scene, seam, previous: scene.playerDrive, player, camera: saved };
119
119
  scene.playerDrive = seam;
120
120
  }
121
- const signature = JSON.stringify({ ...car, riders: undefined });
121
+ // A new look or paint alone (a role car's lights) keeps the car's speed;
122
+ // any change to how it drives starts it from rest.
123
+ const signature = JSON.stringify({ ...car, riders: undefined, look: undefined, color: undefined });
122
124
  if (lastCar !== signature) {carState = null; lastCar = signature;}
123
125
  player.camDistance = car.cam?.distance ?? saved.distance * 1.4;
124
126
  player.camHeight = car.cam?.height ?? saved.height * 1.4;
@@ -155,6 +155,9 @@ export function makeWorldLayout(entries, view, obstacles = () => [], geometry =
155
155
  for (const parent of walked) {ancestorHidden.set(parent, result);}
156
156
  return result;
157
157
  };
158
+ // Safe layout's `!important` translate outranks the inline one written
159
+ // here, so its rect is already where the node is drawn.
160
+ const safeMoved = (node) => node.hasAttribute?.('data-hub-safe-translate') === true;
158
161
  const visible = ({ node }) => {
159
162
  if (!node || node.isConnected === false) {return null;}
160
163
  // The node's own last-pass hide is ignored; an ancestor's is not.
@@ -162,7 +165,7 @@ export function makeWorldLayout(entries, view, obstacles = () => [], geometry =
162
165
  if (own?.display === 'none' || (own?.visibility === 'hidden' && !hidden.has(node)) || own?.opacity === '0') {return null;}
163
166
  if (chainHidden(node.parentElement ?? node.parent)) {return null;}
164
167
  let box = geometry.rect(node);
165
- if (shifted.has(node)) {
168
+ if (shifted.has(node) && !safeMoved(node)) {
166
169
  const [dx, dy] = node.style.translate.split(' ').map(Number.parseFloat);
167
170
  const original = shifted.get(node) || '0 0';
168
171
  const [ox, oy = '0'] = original.split(' ');
@@ -181,6 +184,12 @@ export function makeWorldLayout(entries, view, obstacles = () => [], geometry =
181
184
  const viewport = view();
182
185
  const captions = ['hud-prompt', 'engine-look'].flatMap((id) => measured.filter((entry) => entry.id === id));
183
186
  for (const caption of captions) {
187
+ // A caption safe layout already placed keeps that place and is cleared
188
+ // where it is drawn. One laid out wholly off-screen (a parked engine
189
+ // node) is not on show; pulling it into a band would only make world
190
+ // labels clear it.
191
+ const { box: at } = caption;
192
+ if (safeMoved(caption.node) || at.bottom <= 0 || at.top >= viewport.h || at.right <= 0 || at.left >= viewport.w) {continue;}
184
193
  const controls = measured.filter((entry) => entry !== caption &&
185
194
  entry.kind !== 'label' && entry.kind !== 'pointer').map((entry) => entry.box)
186
195
  .concat(reservedCorners({ ...viewport, insets: viewport.insets ?? { top: 0, right: 0, bottom: 0, left: 0 } })
@@ -1,4 +1,5 @@
1
1
  // v1.93: server only. A place without analytics creates no state or messages.
2
+ import { send } from './trackQueue.js';
2
3
  export const EVENTS = Object.freeze({ arrive: 1, door_enter: 2, door_exit: 3, game_result: 4,
3
4
  activity_start: 5, activity_end: 6, outcome: 7, first_play: 8, pointer_stage: 9,
4
5
  reconnect: 10, session_end: 11, furniture_placed: 12, furniture_moved: 13,
@@ -19,11 +20,7 @@ export function track(h, playerId, name, props = {}) {
19
20
  if (!Number.isSafeInteger(n) || n < 0 || n > max) {return false;}
20
21
  event[key] = n;
21
22
  }
22
- try {
23
- const pending = h.session?.hub?.track?.(playerId, event);
24
- if (pending && typeof pending.catch === 'function') {pending.catch(() => {});}
25
- return pending !== undefined && pending !== false;
26
- } catch { return false; }
23
+ return send(h.session, playerId, event);
27
24
  }
28
25
  export function arrive(h, group) {
29
26
  const a = h.analytics, now = h.sim.timeMs;
@@ -123,11 +120,7 @@ export function fps(h, session, player, data) {
123
120
  const field = data.final ? 'fpsFinalAt' : 'fpsAt';
124
121
  if (entry[field] !== undefined && now - entry[field] < 60000) {return false;}
125
122
  entry[field] = now;
126
- try {
127
- const pending = h.session?.hub?.track?.(player.playerId, {
128
- kind: 26, subject: data.tier, value: data.median * 4096 + data.p10, result: data.avatars, flags: 0,
129
- });
130
- pending?.catch?.(() => {});
131
- return pending !== undefined && pending !== false;
132
- } catch { return false; }
123
+ return send(h.session, player.playerId, {
124
+ kind: 26, subject: data.tier, value: data.median * 4096 + data.p10, result: data.avatars, flags: 0,
125
+ });
133
126
  }
@@ -1,14 +1,11 @@
1
+ import { send } from './trackQueue.js';
1
2
  // Numeric door telemetry. Ghost stamps the subject from the committed trip;
2
3
  // the client's door id and the authored server's subject are never trusted.
3
4
  export const EVENTS = Object.freeze({ round_start: 28, round_end: 29, door_progress: 30, door_error: 31 });
4
5
  export const ERROR_INTERVAL_MS = 10000;
5
6
  function emit(h, playerId, name, value, result) {
6
7
  if (!h.players.get(playerId)?.arrived) {return false;}
7
- try {
8
- const pending = h.session?.hub?.track?.(playerId, { kind: EVENTS[name], value, result });
9
- pending?.catch?.(() => {});
10
- return pending !== undefined && pending !== false;
11
- } catch {return false;}
8
+ return send(h.session, playerId, { kind: EVENTS[name], value, result });
12
9
  }
13
10
  export function track(h, playerId, name, props = {}) {
14
11
  const entry = h.players.get(playerId);
@@ -2441,6 +2441,9 @@ function arrivals(h) {
2441
2441
  const entry = h.players.get(playerId);
2442
2442
  if (houseResume(h) && h.session?.hub?.owner && entry?.userId !== h.session.hub.owner) {delete entry.coldPose;}
2443
2443
  if (entry?.coldPose && entry.invited && entry.near) {delete entry.coldPose;}
2444
+ // A player ghost placed through a door (a House's Back, a host's trip)
2445
+ // arrives at that door, not where an earlier visit was left standing.
2446
+ if (entry?.coldPose && platformHub(h)?.arrival(playerId)?.doorId) {delete entry.coldPose;}
2444
2447
  if (entry?.coldPose) {
2445
2448
  restorePose(h, playerId, entry.coldPose.at, entry.coldPose.facing);
2446
2449
  settle(h, playerId);
@@ -8,6 +8,7 @@
8
8
  // arrived, LOAD_ABANDON_TIMEOUT_MS after it joined). A timeout suppresses the
9
9
  // later close; an arrival suppresses both.
10
10
  import { LOAD_STAGES, CLIENT_LOAD_STAGES, LOAD_REASONS } from '../shared/loadStages.js';
11
+ import { send } from './trackQueue.js';
11
12
  export { LOAD_STAGES, CLIENT_LOAD_STAGES, LOAD_REASONS };
12
13
 
13
14
  export const LOAD_ABANDONED_KIND = 27;
@@ -29,11 +30,7 @@ function loads(h) {
29
30
  function emit(h, playerId, load, result, now) {
30
31
  load.done = true;
31
32
  const value = Math.max(0, Math.min(LOAD_ABANDON_MAX_MS, Math.round(now - load.at)));
32
- try {
33
- const pending = h.session?.hub?.track?.(playerId, { kind: LOAD_ABANDONED_KIND, subject: load.stage, value, result, flags: 0 });
34
- pending?.catch?.(() => {});
35
- return pending !== undefined && pending !== false;
36
- } catch {return false;}
33
+ return send(h.session, playerId, { kind: LOAD_ABANDONED_KIND, subject: load.stage, value, result, flags: 0 });
37
34
  }
38
35
 
39
36
  // The furthest stage the server can see now; never lowers a recorded one.
@@ -0,0 +1,29 @@
1
+ // The cauldron host refuses a hubTrack while two are in flight per session, and
2
+ // a refused row is lost. Every server row goes through here: two in flight per
3
+ // session, the rest wait in order, and past the bound a row is refused at once
4
+ // so a runaway deck cannot grow memory.
5
+ export const TRACK_IN_FLIGHT = 2;
6
+ export const TRACK_QUEUE_MAX = 256;
7
+ const queues = new WeakMap();
8
+ // Whether the row was sent or queued; false when the host has no track.
9
+ export function send(session, playerId, event) {
10
+ if (typeof session?.hub?.track !== 'function') {return false;}
11
+ let q = queues.get(session);
12
+ if (!q) {queues.set(session, q = { inFlight: 0, waiting: [] });}
13
+ if (q.inFlight < TRACK_IN_FLIGHT) {return start(session, q, playerId, event);}
14
+ if (q.waiting.length >= TRACK_QUEUE_MAX) {return false;}
15
+ q.waiting.push([playerId, event]);
16
+ return true;
17
+ }
18
+ function start(session, q, playerId, event) {
19
+ let pending;
20
+ try { pending = session.hub.track(playerId, event); } catch { return false; }
21
+ if (typeof pending?.then !== 'function') {return pending !== undefined && pending !== false;}
22
+ q.inFlight += 1;
23
+ const done = () => {
24
+ q.inFlight -= 1;
25
+ while (q.inFlight < TRACK_IN_FLIGHT && q.waiting.length > 0) {start(session, q, ...q.waiting.shift());}
26
+ };
27
+ pending.then(done, done);
28
+ return true;
29
+ }
@@ -119,6 +119,10 @@ const GOAL_NEAR_M = 6;
119
119
  // A way back the host refused as unavailable is asked again once, this long
120
120
  // after, before the door stays shut.
121
121
  const BACK_RETRY_MS = 1500;
122
+ // A door whose destination the proxy could not route yet (4404 before hello)
123
+ // is acquired again when the join failed within this long of the handoff. The
124
+ // SDK has already tried the same nonce for a few seconds by then.
125
+ const DOOR_RETRY_WINDOW_MS = 10000;
122
126
  // How many times one way somewhere recovers from a hub join lost before the
123
127
  // session placed the player (`lostJoin`) before it gives up and uncovers.
124
128
  const LOST_TRIES_MAX = 2;
@@ -1674,7 +1678,7 @@ class HubSystem {
1674
1678
  });
1675
1679
  if (msg) {
1676
1680
  console.log(`[hub-host-go] ${JSON.stringify({ door: msg.door, party: msg.party, owner: Boolean(msg.owner) })}`);
1677
- this.goHub(scene, msg);
1681
+ this.goHub(scene, { ...msg, host: true });
1678
1682
  }
1679
1683
  }
1680
1684
 
@@ -1782,7 +1786,10 @@ class HubSystem {
1782
1786
  scene: null,
1783
1787
  content: undefined,
1784
1788
  deck: msg.title ?? msg.door,
1785
- retryDoor: msg.door,
1789
+ // A host's Go rides an acquisition the host made from its own session:
1790
+ // asked again from this one, whose player never stood on the pad, ghost
1791
+ // refuses it, so a host's trip has no door retry.
1792
+ retryDoor: msg.host ? null : msg.door,
1786
1793
  retryOwner: msg.owner ?? null,
1787
1794
  pending: this.resolveHub(scene, () => hubGo(msg.door, msg.owner)),
1788
1795
  join: null,
@@ -2956,7 +2963,7 @@ class HubSystem {
2956
2963
  } else if (state === 'failed') {
2957
2964
  const age = now - trip.target.acquiredAt;
2958
2965
  if (trip.target.retryDoor && !trip.doorRetried && mp.joinFailure?.closeCode === 4404 &&
2959
- mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <= 5000) {
2966
+ mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <= DOOR_RETRY_WINDOW_MS) {
2960
2967
  trip.doorRetried = true;
2961
2968
  trip.retryDoorAt = now + 2500;
2962
2969
  trip.phase = 'retrying-door';
@@ -14,7 +14,10 @@ sent through authored `hub.track` calls.
14
14
 
15
15
  The server context gains `hub.track(playerId, eventName, properties = {})`.
16
16
  It returns whether a best-effort delivery was attempted. Delivery failures never
17
- interrupt gameplay. Older SDKs/hosts silently do nothing. Numeric properties are
17
+ interrupt gameplay. The host takes two rows in flight per session and refuses a
18
+ third, so the kit sends two at a time and queues the rest in order
19
+ (`code/server/trackQueue.js`, at most 256 waiting; past that a row is refused and
20
+ `track` returns false). A deck that fires several rows in one tick loses none. Older SDKs/hosts silently do nothing. Numeric properties are
18
21
  `subject` (0..65535), `value` (0..2147483647), `result` (0..255), and `flags` (0..3).
19
22
  Unknown fields, strings, nulls, nonintegers, other identities and unknown players
20
23
  are refused. The platform stamps identity and town attribution and owns flags;
@@ -5,7 +5,7 @@
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "precheck": "node scripts/test-back-visibility.mjs && node scripts/test-landscape-layout.mjs && node scripts/test-safe-layout.mjs && node scripts/test-action-observers.mjs && node scripts/test-crowd-names.mjs && node scripts/test-default-environment.mjs && node scripts/test-default-environment-root.mjs",
8
- "check": "eslint . && npm run test:anonymous-entry && node scripts/test-manifest.mjs && node scripts/test-push-visit.mjs && node scripts/test-act.mjs && node scripts/test-act-client.mjs && node scripts/test-act-core.mjs && node scripts/test-loading-cover.mjs && node scripts/test-frame-batch.mjs && node scripts/test-invites.mjs && node scripts/test-invites-client.mjs && node scripts/test-analytics.mjs && node scripts/test-device-class.mjs && node scripts/test-door-analytics.mjs && node scripts/test-fps-telemetry.mjs && node scripts/test-load-abandon.mjs && node scripts/test-build.mjs && node scripts/test-decor.mjs && node scripts/test-actions.mjs && node scripts/test-resume-action-order.mjs && node scripts/test-actions-client.mjs && node scripts/test-action-layout.mjs && node scripts/test-ask-slot.mjs && node scripts/test-placement-cache.mjs && node scripts/test-ask.mjs && node scripts/test-ask-client.mjs && node scripts/test-menu.mjs && node scripts/test-menu-client.mjs && node scripts/test-companion.mjs && node scripts/test-companion-chat.mjs && node scripts/test-companion-client.mjs && node scripts/test-visibility.mjs && node scripts/test-rehello.mjs && node scripts/test-resync.mjs && node scripts/test-resume-pose.mjs && node scripts/test-resume-held.mjs && node scripts/test-arrival-pose.mjs && node scripts/test-arrival-pose-server.mjs && node scripts/test-arrival-pose-server.mjs clinic && node scripts/test-arrival-pose-server.mjs cove && node scripts/test-arrival-pose-server.mjs fishing && node scripts/test-arrival-pose-server.mjs plot && node scripts/test-arrival-pose-server.mjs runway && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs clinic && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs cove && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs fishing && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs plot && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs runway && POSE_REPLACE=1 POSE_PLAIN=1 POSE_RESULT=1 node scripts/test-arrival-pose-server.mjs && POSE_LINE=1 node scripts/test-arrival-pose-server.mjs && node scripts/test-resume-pose-server.mjs && node scripts/test-resume-pose-server.mjs same-layer && node scripts/test-progress-reset.mjs && node scripts/test-decor-client.mjs && node scripts/test-yours.mjs && node scripts/test-yours-chrome.mjs && node scripts/test-npcs.mjs && node scripts/test-avatar.mjs && node scripts/test-avatar-colors.mjs && node scripts/test-avatar-models.mjs && node scripts/test-avatar-wire.mjs && node scripts/test-avatar-share.mjs && node scripts/test-far-avatars.mjs && node scripts/test-avatar-cap.mjs && node scripts/test-picker.mjs && node scripts/test-friend-bests.mjs && node scripts/test-hub-ops.mjs && node scripts/test-storage-limit.mjs && node scripts/test-hub-leaving.mjs && node scripts/test-standing.mjs && node scripts/test-observed.mjs && node scripts/test-actors.mjs && node scripts/test-grab.mjs && node scripts/test-grab-client.mjs && node scripts/test-grab-orbit.mjs && node scripts/test-idle.mjs && node scripts/test-car.mjs && node scripts/test-vehicle.mjs && node scripts/test-vehicle-client.mjs && node scripts/test-emote-bubble.mjs && node scripts/test-emote-wheel.mjs && node scripts/test-shot.mjs && node scripts/test-vis.mjs && node scripts/test-keys.mjs && node scripts/test-attention.mjs && node scripts/test-hub-trip.mjs && node scripts/test-hub-entry.mjs && node scripts/test-host-go.mjs && node scripts/test-no-trips.mjs && node scripts/test-pack.mjs && node scripts/test-interest.mjs && node scripts/test-relations-among.mjs && node scripts/test-relations-refresh.mjs && node scripts/test-fresh-friends.mjs && node scripts/test-cells.mjs && node scripts/test-interest-cells.mjs && node scripts/test-interest-cap.mjs && node scripts/test-object-entry.mjs && node scripts/test-interest-client.mjs && node scripts/test-blocks.mjs && node scripts/test-ban-join.mjs && node scripts/test-door.mjs && node scripts/test-door-jump.mjs && node scripts/test-together.mjs && node scripts/test-hub-controls.mjs && node scripts/test-party.mjs && node scripts/test-say.mjs && node scripts/test-ballot.mjs && node scripts/test-chat.mjs && node scripts/test-no-forms.mjs && node scripts/test-classic.mjs && node scripts/test-actor-budget.mjs && node scripts/test-quality.mjs && node scripts/test-high-only.mjs && node scripts/test-tiers.mjs && node scripts/test-tiers-render.mjs && node scripts/test-tier-cells.mjs && node scripts/test-hats.mjs && node scripts/test-try-on.mjs && node scripts/test-role.mjs && node scripts/test-role-client.mjs && node scripts/test-earned.mjs && node scripts/test-earned-client.mjs && node scripts/test-spin.mjs && node scripts/test-hud-clear.mjs && node scripts/test-labels.mjs && node scripts/test-world-labels.mjs && node scripts/test-pad-occupancy.mjs && node scripts/test-pad-cues.mjs && node scripts/test-stuck.mjs && node scripts/test-toast-band.mjs && node scripts/test-soundscape.mjs && node scripts/test-weakest-tier.mjs && node scripts/test-hud-rate.mjs && node scripts/test-ui-tree.mjs && node scripts/test-hud-surface.mjs && node scripts/test-talk-surface.mjs && node scripts/test-apply-deck.mjs && node tools/hubScene/test/export-fixture.mjs && node --test tools/hubScene/test/upload.test.mjs && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
8
+ "check": "eslint . && npm run test:anonymous-entry && node scripts/test-manifest.mjs && node scripts/test-push-visit.mjs && node scripts/test-act.mjs && node scripts/test-act-client.mjs && node scripts/test-act-core.mjs && node scripts/test-loading-cover.mjs && node scripts/test-frame-batch.mjs && node scripts/test-invites.mjs && node scripts/test-invites-client.mjs && node scripts/test-analytics.mjs && node scripts/test-device-class.mjs && node scripts/test-door-analytics.mjs && node scripts/test-fps-telemetry.mjs && node scripts/test-load-abandon.mjs && node scripts/test-track-queue.mjs && node scripts/test-build.mjs && node scripts/test-decor.mjs && node scripts/test-actions.mjs && node scripts/test-resume-action-order.mjs && node scripts/test-actions-client.mjs && node scripts/test-action-layout.mjs && node scripts/test-ask-slot.mjs && node scripts/test-placement-cache.mjs && node scripts/test-ask.mjs && node scripts/test-ask-client.mjs && node scripts/test-menu.mjs && node scripts/test-menu-client.mjs && node scripts/test-companion.mjs && node scripts/test-companion-chat.mjs && node scripts/test-companion-client.mjs && node scripts/test-visibility.mjs && node scripts/test-rehello.mjs && node scripts/test-resync.mjs && node scripts/test-resume-pose.mjs && node scripts/test-resume-held.mjs && node scripts/test-arrival-pose.mjs && node scripts/test-arrival-pose-server.mjs && node scripts/test-arrival-pose-server.mjs clinic && node scripts/test-arrival-pose-server.mjs cove && node scripts/test-arrival-pose-server.mjs fishing && node scripts/test-arrival-pose-server.mjs plot && node scripts/test-arrival-pose-server.mjs runway && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs clinic && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs cove && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs fishing && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs plot && POSE_REPLACE=1 node scripts/test-arrival-pose-server.mjs runway && POSE_REPLACE=1 POSE_PLAIN=1 POSE_RESULT=1 node scripts/test-arrival-pose-server.mjs && POSE_LINE=1 node scripts/test-arrival-pose-server.mjs && node scripts/test-resume-pose-server.mjs && node scripts/test-resume-pose-server.mjs same-layer && node scripts/test-progress-reset.mjs && node scripts/test-decor-client.mjs && node scripts/test-yours.mjs && node scripts/test-yours-chrome.mjs && node scripts/test-npcs.mjs && node scripts/test-avatar.mjs && node scripts/test-avatar-colors.mjs && node scripts/test-avatar-models.mjs && node scripts/test-avatar-wire.mjs && node scripts/test-avatar-share.mjs && node scripts/test-far-avatars.mjs && node scripts/test-avatar-cap.mjs && node scripts/test-picker.mjs && node scripts/test-friend-bests.mjs && node scripts/test-hub-ops.mjs && node scripts/test-storage-limit.mjs && node scripts/test-hub-leaving.mjs && node scripts/test-standing.mjs && node scripts/test-observed.mjs && node scripts/test-actors.mjs && node scripts/test-grab.mjs && node scripts/test-grab-client.mjs && node scripts/test-grab-orbit.mjs && node scripts/test-idle.mjs && node scripts/test-car.mjs && node scripts/test-vehicle.mjs && node scripts/test-vehicle-client.mjs && node scripts/test-emote-bubble.mjs && node scripts/test-emote-wheel.mjs && node scripts/test-shot.mjs && node scripts/test-vis.mjs && node scripts/test-keys.mjs && node scripts/test-attention.mjs && node scripts/test-hub-trip.mjs && node scripts/test-hub-entry.mjs && node scripts/test-host-go.mjs && node scripts/test-no-trips.mjs && node scripts/test-pack.mjs && node scripts/test-interest.mjs && node scripts/test-relations-among.mjs && node scripts/test-relations-refresh.mjs && node scripts/test-fresh-friends.mjs && node scripts/test-cells.mjs && node scripts/test-interest-cells.mjs && node scripts/test-interest-cap.mjs && node scripts/test-object-entry.mjs && node scripts/test-interest-client.mjs && node scripts/test-blocks.mjs && node scripts/test-ban-join.mjs && node scripts/test-door.mjs && node scripts/test-door-jump.mjs && node scripts/test-together.mjs && node scripts/test-hub-controls.mjs && node scripts/test-party.mjs && node scripts/test-say.mjs && node scripts/test-ballot.mjs && node scripts/test-chat.mjs && node scripts/test-no-forms.mjs && node scripts/test-classic.mjs && node scripts/test-actor-budget.mjs && node scripts/test-quality.mjs && node scripts/test-high-only.mjs && node scripts/test-tiers.mjs && node scripts/test-tiers-render.mjs && node scripts/test-tier-cells.mjs && node scripts/test-hats.mjs && node scripts/test-try-on.mjs && node scripts/test-role.mjs && node scripts/test-role-client.mjs && node scripts/test-earned.mjs && node scripts/test-earned-client.mjs && node scripts/test-spin.mjs && node scripts/test-hud-clear.mjs && node scripts/test-labels.mjs && node scripts/test-world-labels.mjs && node scripts/test-pad-occupancy.mjs && node scripts/test-pad-cues.mjs && node scripts/test-stuck.mjs && node scripts/test-toast-band.mjs && node scripts/test-soundscape.mjs && node scripts/test-weakest-tier.mjs && node scripts/test-hud-rate.mjs && node scripts/test-ui-tree.mjs && node scripts/test-hud-surface.mjs && node scripts/test-talk-surface.mjs && node scripts/test-apply-deck.mjs && node tools/hubScene/test/export-fixture.mjs && node --test tools/hubScene/test/upload.test.mjs && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
9
9
  "format": "prettier --write \"code/**/*.js\" \"scripts/**/*.mjs\" castle.json package.json",
10
10
  "test:anonymous-entry": "node scripts/test-signin-client.mjs && node scripts/test-anonymous-entry.mjs"
11
11
  },
@@ -20,7 +20,7 @@ for (const analyticsV111 of [false, 1, 'true', {}, null]) assert(readManifest(ca
20
20
  const calls = [];
21
21
  const device = encodeDeviceClass({ lowMemory: true, cores: 4, dpr: 2, width: 360, height: 800, deviceMemory: 2 });
22
22
  const h = { place: { analytics: true }, manifest: {}, sim: { timeMs: 0 }, players: new Map([['p', { arrived: true }]]),
23
- session: { hub: { track: (id, event) => { calls.push([id, event]); return Promise.resolve(true); } } }, analytics: A.create() };
23
+ session: { hub: { track: (id, event) => { calls.push([id, event]); return true; } } }, analytics: A.create() };
24
24
  A.arrive(h, [{ playerId: 'p', userId: '42' }]);
25
25
  assert.equal(calls.at(-1)[1].kind, A.EVENTS.arrive);
26
26
  assert.equal(calls.at(-1)[1].value, 0, 'missing device records unknown');
@@ -4,7 +4,7 @@ import { readManifest, publicPlace } from '../code/server/manifest.js';
4
4
  import { makeDoorErrors } from '../code/client/doorErrors.js';
5
5
  const calls = [], entry = { arrived: true };
6
6
  const h = { place: { result: {} }, sim: { timeMs: 1000 }, players: new Map([['p', entry]]),
7
- session: { hub: { track: (id, e) => { calls.push([id, e]); return Promise.resolve(true); } } } };
7
+ session: { hub: { track: (id, e) => { calls.push([id, e]); return true; } } } };
8
8
  D.arrive(h, [{ playerId: 'p' }]);
9
9
  D.arrive(h, [{ playerId: 'p' }]);
10
10
  assert.equal(calls.length, 1);
@@ -1650,6 +1650,34 @@ await test('authored visit results/end do not finish an interrupted competitive
1650
1650
  world.players.delete('p1'); s.session.players = s.session.players.filter(p=>p.playerId!=='p1'); h.place(world);
1651
1651
  assert.deepEqual(events.filter(([,e])=>e.kind===29).map(([,e])=>e.result),[3],'disconnect closes interrupted round');
1652
1652
  });
1653
+ await test('a stored resume pose is not restored for an arrival ghost placed through a door', async () => {
1654
+ const { store } = await import('../code/server/resumePose.js');
1655
+ const { poseStorage } = await import('./pose-storage-fixture.mjs');
1656
+ const p = platformHub();
1657
+ const s = session({ hub: p.hub });
1658
+ s.session.storage = { deck: poseStorage() };
1659
+ const cold = { at: { x: -7, y: 1, z: 9 }, facing: 0.5 };
1660
+ // Both accounts left the Town earlier and each has a stored pose.
1661
+ for (const userId of ['101', '102']) {
1662
+ const earlier = store(s.session, 'main');
1663
+ await earlier.take(userId);
1664
+ await earlier.end(userId, cold);
1665
+ }
1666
+ const json = { ...castleJson, hub: { ...castleJson.hub, resumePose: true } };
1667
+ const { h, world, arrived } = boot(s, {}, json);
1668
+ // p1 comes back through the race door (ghost's arrival); p2 rejoins with none.
1669
+ hello(h, s, 'p1');
1670
+ hello(h, s, 'p2');
1671
+ for (let i = 0; i < 10 && arrived.length < 2; i++) {
1672
+ await flush();
1673
+ h.place(world);
1674
+ }
1675
+ assert.equal(arrived.length, 2);
1676
+ const at = (id) => world.players.get(id).at;
1677
+ assert.ok(Math.hypot(at('p1').x - cold.at.x, at('p1').z - cold.at.z) > 1, `door arrival left at the stored pose ${JSON.stringify(at('p1'))}`);
1678
+ assert.ok(Math.hypot(at('p2').x - cold.at.x, at('p2').z - cold.at.z) < 0.01, `rejoin without a door keeps its stored pose ${JSON.stringify(at('p2'))}`);
1679
+ });
1680
+
1653
1681
  console.log(`hub ops: ${n} tests passed`);
1654
1682
 
1655
1683
  // Opt-in exists after actual layer construction, before authored hooks run.
@@ -3663,7 +3663,7 @@ await test('early proxy not_running retries the same door once with a fresh acqu
3663
3663
  mp.state = 'joined'; system.stepTrip(scene, mp, null, 4002);
3664
3664
  assert.equal(scene.persistent.hubDepth, 1);
3665
3665
  });
3666
- for (const [code, age, retried] of [[4401, 1000, false], [1013, 1000, false], [4404, 5001, false], [4404, 1000, true]]) {
3666
+ for (const [code, age, retried] of [[4401, 1000, false], [1013, 1000, false], [4404, 10001, false], [4404, 1000, true]]) {
3667
3667
  await test(`door retry limit: close ${code}, age ${age}, already retried ${retried}`, async () => {
3668
3668
  const { system, scene } = setup(); const mp = mpStub(scene);
3669
3669
  answers.go = handoff(); system.goHub(scene, { door: 'race' }); await toSwitch(system, scene, mp);
@@ -3674,6 +3674,25 @@ for (const [code, age, retried] of [[4401, 1000, false], [1013, 1000, false], [4
3674
3674
  assert.equal(calls.filter(c => c[0] === 'go').length, 1);
3675
3675
  });
3676
3676
  }
3677
+ await test('early proxy not_running still retries a door 8 s after its handoff (the SDK tried its nonce meanwhile)', async () => {
3678
+ const { system, scene } = setup(); const mp = mpStub(scene);
3679
+ answers.go = handoff(); system.goHub(scene, { door: 'race' }); await toSwitch(system, scene, mp);
3680
+ system.trip.target.acquiredAt = 0;
3681
+ mp.state = 'failed'; mp.joinFailure = { code: 'MULTIPLAYER_CONNECTION_FAILED', closeCode: 4404 };
3682
+ system.stepTrip(scene, mp, null, 8000);
3683
+ assert.equal(system.trip.phase, 'retrying-door');
3684
+ });
3685
+ await test("a host's Go is never acquired again from this session after an early not_running", async () => {
3686
+ const { system, scene } = setup(); const mp = mpStub(scene);
3687
+ answers.go = handoff(); system.goHub(scene, { door: 'race', title: 'Foot Race', host: true });
3688
+ await toSwitch(system, scene, mp);
3689
+ const trip = system.trip; trip.target.acquiredAt = 0;
3690
+ mp.state = 'failed'; mp.joinFailure = { code: 'MULTIPLAYER_CONNECTION_FAILED', closeCode: 4404 };
3691
+ system.stepTrip(scene, mp, null, 1500);
3692
+ assert.notEqual(system.trip?.phase, 'retrying-door');
3693
+ system.stepTrip(scene, mp, null, 5000); await flush();
3694
+ assert.equal(calls.filter(c => c[0] === 'go').length, 1);
3695
+ });
3677
3696
  console.log(`hub trips with retry: ${n} tests passed`);
3678
3697
 
3679
3698
  for (const failure of ['refused', 'pack', 'timeout']) {
@@ -14,7 +14,7 @@ function world(ids, place = ON, now = T0) {
14
14
  const calls = [];
15
15
  const roster = [];
16
16
  const h = { place: { ...place }, manifest: {}, players: new Map(), sim: { players: new Map() },
17
- session: { players: roster, hub: { track: (id, event) => { calls.push([id, event]); return Promise.resolve(true); } } } };
17
+ session: { players: roster, hub: { track: (id, event) => { calls.push([id, event]); return true; } } } };
18
18
  const join = (id, at = now) => { roster.push({ playerId: id }); L.join(h, h.session, id, at); };
19
19
  const leave = (id, at) => { roster.splice(roster.findIndex((p) => p.playerId === id), 1); L.leave(h, id, at); };
20
20
  for (const id of ids) {join(id);}
@@ -197,7 +197,7 @@ function townServer() {
197
197
  const session = { sessionId: 's-1', place: null, players: roster, send: (id, d) => sent.push([id, d]), broadcast() {},
198
198
  hub: { place: 'main', title: 'Town', result: null, arrival: () => null,
199
199
  async readResults() { return { players: {}, boards: {} }; },
200
- track: (id, e) => { tracked.push([id, e]); return Promise.resolve(true); } } };
200
+ track: (id, e) => { tracked.push([id, e]); return true; } } };
201
201
  const h = layer({ server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Town', ...ON } }, { arrive() {} }, {}, (s) => s === 'scenes/main.scene', () => null);
202
202
  h.sceneFor(session);
203
203
  const join = (playerId, userId) => { roster.push({ playerId, userId, username: playerId, isAnonymous: false }); h.transportJoin(session, { playerId }); };