@wildshard/engine 0.1.20 → 0.1.22

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 (94) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/lint/engine-sides.json +4 -0
  3. package/lint/shardfile-boundaries.mjs +4 -2
  4. package/lint/wildshard-plugin.js +1 -1
  5. package/package.json +3 -1
  6. package/scripts/audio-download-proof.mjs +1 -1
  7. package/scripts/chaos-proxy-core.mjs +14 -1
  8. package/scripts/chaos-proxy-proof.mjs +22 -0
  9. package/scripts/check-spelled-paths.mjs +6 -3
  10. package/scripts/committed-fast-checks.mjs +2 -2
  11. package/scripts/failmode-cases.d.mts +8 -0
  12. package/scripts/failmode-cases.mjs +97 -0
  13. package/scripts/failmode-proof.mjs +556 -0
  14. package/scripts/grid-crossing-nightly.mjs +5 -4
  15. package/scripts/grid-crossing-report.mjs +5 -2
  16. package/scripts/grid-crossing-tour.mjs +25 -8
  17. package/scripts/grid-crossing-walk-proof.mjs +3 -3
  18. package/scripts/hover-speed-probe.mjs +136 -0
  19. package/scripts/mmo-bots.mjs +7 -3
  20. package/scripts/net-lag-proof.mjs +4 -3
  21. package/scripts/online-rig.mjs +11 -9
  22. package/scripts/parity/boot-smoke.mjs +1 -1
  23. package/scripts/release-cook.mjs +113 -0
  24. package/scripts/test-products.json +0 -21
  25. package/scripts/vps/cook-follow.d.mts +6 -0
  26. package/scripts/vps/cook-follow.mjs +45 -0
  27. package/scripts/vps/harden-apply.sh +10 -1
  28. package/scripts/vps/rebuild.sh +120 -26
  29. package/scripts/vps/wildshard-apply.mjs +5 -1
  30. package/scripts/vps/wildshard-config +117 -3
  31. package/src/client/app/entry.ts +2 -3
  32. package/src/client/engine/boot/contentRead.ts +78 -9
  33. package/src/client/engine/boot/downloadGiveUp.ts +34 -0
  34. package/src/client/engine/boot/gpuFiles.ts +3 -3
  35. package/src/client/engine/boot/leaveAfterPaint.ts +4 -1
  36. package/src/client/engine/combat/EquipmentService.ts +2 -0
  37. package/src/client/engine/core/Game.ts +6 -2
  38. package/src/client/engine/core/shadowLayer.ts +18 -0
  39. package/src/client/engine/explore/pick.ts +13 -1
  40. package/src/client/engine/net/predictor.ts +12 -4
  41. package/src/client/engine/player/TouchControls.ts +3 -2
  42. package/src/client/engine/render/families/sceneSurface.ts +3 -1
  43. package/src/client/engine/telemetry/browserErrors.ts +3 -1
  44. package/src/client/engine/ui/ErrorModal.ts +1 -1
  45. package/src/client/engine/ui/Loading.ts +14 -2
  46. package/src/client/engine/ui/downloadFailed.ts +54 -0
  47. package/src/client/engine/ui/errorScreen.ts +51 -9
  48. package/src/client/engine/ui/hoverBoost.ts +31 -4
  49. package/src/client/engine/ui/styles/touch.css +6 -0
  50. package/src/client/game/boot/spawnDownload.ts +56 -7
  51. package/src/client/game/grid/copyPrompts.ts +3 -4
  52. package/src/client/game/grid/dataCellKit.ts +91 -0
  53. package/src/client/game/grid/enteredEquipment.ts +11 -2
  54. package/src/client/game/grid/live.ts +11 -301
  55. package/src/client/game/grid/liveSession.ts +33 -10
  56. package/src/client/game/grid/neighbourLife.ts +50 -32
  57. package/src/client/game/grid/reveal.ts +7 -2
  58. package/src/client/game/grid/session.ts +6 -70
  59. package/src/client/game/grid/shardfileFar.ts +13 -2
  60. package/src/client/game/plugin/weaponFamily.ts +6 -0
  61. package/src/client/game/shardfile/clientSource.ts +7 -3
  62. package/src/client/game/shardfile/clientWorker.ts +17 -7
  63. package/src/client/game/shardfile/groundMerge.ts +5 -3
  64. package/src/client/host/online/linkScreens.ts +12 -6
  65. package/src/client/host/online/reconnectStrip.ts +3 -2
  66. package/src/client/host/online/release.ts +87 -16
  67. package/src/client/host/online/releaseScreens.ts +108 -0
  68. package/src/client/host/online/shell.ts +46 -12
  69. package/src/client/host/online/voice.ts +45 -1
  70. package/src/client/host/online/voiceUi.ts +24 -6
  71. package/src/server/engine/sim/playerSim.ts +1 -1
  72. package/src/server/game/grid/room.ts +2 -38
  73. package/src/server/game/grid/simulation.ts +12 -6
  74. package/src/server/game/shardfile/declaredKitItems.ts +8 -2
  75. package/src/server/host/dedicated/cellHost.ts +9 -2
  76. package/src/server/host/dedicated/cellProtocol.ts +1 -1
  77. package/src/server/host/dedicated/cellWorker.ts +2 -2
  78. package/src/server/host/dedicated/dedicatedRoom.ts +22 -4
  79. package/src/server/host/dedicated/gridCells.ts +5 -3
  80. package/src/server/host/dedicated/main.ts +6 -4
  81. package/src/server/host/dedicated/roadRoom.ts +3 -0
  82. package/src/server/host/dedicated/workerTable.ts +0 -10
  83. package/src/server/host/dedicated/world.ts +39 -5
  84. package/src/server/host/standalone/cellWorld.ts +1 -1
  85. package/src/server/host/standalone/gridServer.ts +1 -1
  86. package/src/shared/engine/boot/loadingWaits.ts +10 -2
  87. package/src/shared/engine/core/config.ts +3 -0
  88. package/src/shared/engine/player/hoverSpeed.ts +3 -3
  89. package/src/shared/engine/saves/shape.ts +17 -2
  90. package/src/shared/engine/strings.ts +22 -1
  91. package/src/shared/game/grid/placementRows.ts +4 -3
  92. package/src/shared/game/grid/rules.ts +12 -0
  93. package/src/client/game/grid/cellLoading.ts +0 -110
  94. package/src/client/game/grid/cellScreens.ts +0 -48
@@ -3,17 +3,44 @@ import { captureBrowserError, engineScreenTags } from '../telemetry/browserError
3
3
  import { beginLoadingWait, finishLoadingWait } from '../../../shared/engine/boot/loadingWaits';
4
4
  import { currentLoadingTimeline } from '../../../shared/engine/boot/timeline';
5
5
  import { bootProgress } from '../../../shared/engine/boot/timing';
6
+ import { diagnosticNow } from '../../../shared/engine/core/clock';
7
+ import { clearDownloadGiveUp, downloadGiveUp, onDownloadGiveUp, type DownloadGiveUp } from './downloadGiveUp';
6
8
 
7
9
  /** A missing or interrupted transport, never a parsed-content or admission refusal. */
8
10
  export class ContentReadError extends Error {
9
11
  readonly url: string;
10
12
  /** RL8: the server answered that the file is not there (404, or the HTML fallback): a retry of the same URL can't help */
11
13
  readonly missing: boolean;
12
- constructor(url: string, detail: string, cause?: unknown, missing = false) {
14
+ /** FM6: the HTTP status the server answered, its `Retry-After` in ms (seconds or a date, at most 10 min), and whether the bytes
15
+ * arrived but failed their length check (mode 44). Null and false when not measured. */
16
+ readonly status: number | null;
17
+ readonly retryAfterMs: number | null;
18
+ readonly broken: boolean;
19
+ constructor(url: string, detail: string, cause?: unknown, missing = false, measured: { status?: number; retryAfterMs?: number | null; broken?: boolean } = {}) {
13
20
  super(`Read failed: ${new URL(url, 'https://content.invalid').pathname} · ${detail}`, { cause });
14
21
  this.name = 'ContentReadError'; this.url = url; this.missing = missing;
22
+ this.status = measured.status ?? null; this.retryAfterMs = measured.retryAfterMs ?? null; this.broken = measured.broken ?? false;
15
23
  }
16
24
  }
25
+ /** FM6 mode 34: a `Retry-After` of seconds or an HTTP date, in ms from `now`; anything else (or past 10 min) is no answer. */
26
+ export function contentRetryAfterMs(header: string | null, now: number = Date.now()): number | null {
27
+ if (header === null) return null;
28
+ const text = header.trim(), ms = /^\d{1,6}$/u.test(text) ? Number(text) * 1000 : /[a-z]/iu.test(text) ? Date.parse(text) - now : Number.NaN;
29
+ return Number.isFinite(ms) && ms >= 0 && ms <= 600_000 ? Math.round(ms) : null;
30
+ }
31
+ /** The spawn book (`assets/spawn/packs-<build>.json`): mode 35 names it apart from the packs it lists. */
32
+ const BOOK = /(?:^|\/)assets\/spawn\/packs-[^/]+\.json$/u;
33
+ /** FM6: the catalogue's ids for a failed read, and the line a player reads (meta MMO-FAILURE-MODES-PLAN modes 33 to 35, 44). The
34
+ * address and raw detail stay in the error for Copy diagnostics. */
35
+ export function contentFailure(error: ContentReadError): { readonly failmode: string; readonly line: string } {
36
+ const book = BOOK.test(new URL(error.url, 'https://content.invalid').pathname);
37
+ if (book) return { failmode: 'book-5xx', line: 'The world\'s book didn\'t arrive' };
38
+ if (error.status === 429) return { failmode: 'packs-429', line: 'Download paused · the server is busy' };
39
+ if (error.broken) return { failmode: 'packs-5xx pack-broken', line: 'Download paused · a file didn\'t verify' };
40
+ if (error.missing) return { failmode: 'packs-5xx', line: 'Download paused · a file isn\'t there' };
41
+ if (error.status !== null) return { failmode: 'packs-5xx', line: 'Download paused · the server had an error' };
42
+ return { failmode: 'packs-5xx', line: 'Download paused · the connection dropped' };
43
+ }
17
44
  export interface ContentReadOptions {
18
45
  fetch: (url: string, init: RequestInit) => Promise<Response>;
19
46
  signal?: AbortSignal;
@@ -38,10 +65,11 @@ function html(bytes: Uint8Array): boolean {
38
65
  async function body(response: Response, url: string, maximum: number, read?: (bytes: number) => void, expected?: number,
39
66
  received?: (response: Response) => void): Promise<Uint8Array<ArrayBuffer>> {
40
67
  const sizeError = (): Error => expected === undefined ? new Error('Content wire size exceeds cap')
41
- : new ContentReadError(url, 'byte length differs from manifest');
68
+ : new ContentReadError(url, 'byte length differs from manifest', undefined, false, { broken: true });
42
69
  if (!response.ok || /\btext\/html\b/iu.test(response.headers.get('content-type') ?? '')) {
43
70
  await response.body?.cancel().catch(() => undefined);
44
- throw new ContentReadError(url, response.ok ? 'missing content (HTML response)' : `HTTP ${response.status}`, undefined, response.ok || response.status === 404);
71
+ throw new ContentReadError(url, response.ok ? 'missing content (HTML response)' : `HTTP ${response.status}`, undefined, response.ok || response.status === 404,
72
+ response.ok ? {} : { status: response.status, retryAfterMs: contentRetryAfterMs(response.headers.get('retry-after')) });
45
73
  }
46
74
  const length = response.headers.get('content-length');
47
75
  if (length !== null && (!/^\d+$/u.test(length) || Number(length) > maximum)) {
@@ -94,7 +122,13 @@ function shellRetry(scope: Scope, error: ContentReadError, retry: () => void): v
94
122
  const button = document.querySelector<HTMLButtonElement>('.ws-load .ws-load-retry');
95
123
  if (button === null) return;
96
124
  const foot = document.querySelector<HTMLElement>('.ws-load [data-el="foot"]');
97
- if (foot !== null) foot.textContent = error.message;
125
+ // FM6: the shell's foot says what failed in a player's words with the catalogue's id, as Loading's does (the FM3 proof caught
126
+ // START's boot tables showing their address and HTTP status here); the address stays in the error for Copy diagnostics
127
+ if (foot !== null) {
128
+ const failure = contentFailure(error);
129
+ foot.textContent = failure.line; foot.dataset['failmode'] = failure.failmode;
130
+ scope.onDispose(() => { if (foot.dataset['failmode'] === failure.failmode) delete foot.dataset['failmode']; });
131
+ }
98
132
  button.hidden = false;
99
133
  scope.listen(button, 'click', retry);
100
134
  }
@@ -107,7 +141,10 @@ function reportStall(target: Document, error: ContentReadError, step: string | n
107
141
  try { captureBrowserError(error, engineScreenTags('loading-stall', 'content-read', step ?? 'loading', { url: error.url })); }
108
142
  catch { /* a report never holds the retry */ }
109
143
  }
110
- async function retryFromCard(error: ContentReadError, signal?: AbortSignal): Promise<void> {
144
+ /** FM6 mode 36: how long a read may wait on RETRY, with nothing left that reads again by itself, before its line becomes the
145
+ * download-failed page. The line (modes 33 to 35) is the pause; the page says the download stopped, with what to do. */
146
+ export const DOWNLOAD_GIVE_UP_MS = 30_000;
147
+ async function retryFromCard(error: ContentReadError, signal?: AbortSignal, reads = 2): Promise<void> {
111
148
  if (typeof document === 'undefined') throw error;
112
149
  const target = document, timeline = currentLoadingTimeline(), scope = new Scope('content-read-button');
113
150
  let group = retryGroups.get(target);
@@ -122,8 +159,20 @@ async function retryFromCard(error: ContentReadError, signal?: AbortSignal): Pro
122
159
  reportStall(target, error, timeline?.snapshot().current ?? null);
123
160
  id = beginLoadingWait(error.message, { kind: 'file', resource: error.url,
124
161
  owner: timeline?.waitOwner ?? null, step: timeline?.snapshot().current ?? null,
125
- retry: () => {for (const retry of pending) retry();}, retryNavigation: false });
162
+ retry: () => {for (const retry of pending) retry();}, retryNavigation: false, ...contentFailure(error) });
126
163
  shellRetry(scope, error, () => {for (const retry of pending) retry();});
164
+ // FM6 mode 36: the download gave up (before or while this read waits), so nothing more arrives by itself: the page says so
165
+ const page = (given: DownloadGiveUp): void => { void (async () => {
166
+ const { downloadFailedPage } = await import('../ui/downloadFailed');
167
+ if (!scope.disposed) downloadFailedPage(scope, given, `${error.url} · ${error.message}`, () => {for (const retry of pending) retry();});
168
+ })(); };
169
+ // or this read itself has waited DOWNLOAD_GIVE_UP_MS with every read it makes by itself spent (RETRY adds no new counter)
170
+ const given = downloadGiveUp();
171
+ if (given !== null) page(given);
172
+ else {
173
+ scope.onDispose(onDownloadGiveUp(page));
174
+ scope.timeout(DOWNLOAD_GIVE_UP_MS, () => { page({ attempts: reads, status: error.status, detail: error.url }); });
175
+ }
127
176
  });
128
177
  } finally {
129
178
  if (id !== undefined) finishLoadingWait(id);
@@ -133,24 +182,44 @@ async function retryFromCard(error: ContentReadError, signal?: AbortSignal): Pro
133
182
  }
134
183
  }
135
184
 
185
+ /** FM6 mode 34: the server's own wait, on the card as `packs-429` with its countdown; the read's signal cancels it. */
186
+ async function busyWait(error: ContentReadError, ms: number, signal?: AbortSignal): Promise<void> {
187
+ const scope = new Scope('content-read-busy'), timeline = currentLoadingTimeline();
188
+ const id = typeof document === 'undefined' ? undefined : beginLoadingWait(error.message, { kind: 'file', resource: error.url, owner: timeline?.waitOwner ?? null,
189
+ step: timeline?.snapshot().current ?? null, ...contentFailure(error), dueAt: diagnosticNow() + ms });
190
+ try {
191
+ await new Promise<void>((resolve, reject) => {
192
+ if (signal?.aborted === true) { reject(abortReason(signal)); return; }
193
+ if (signal !== undefined) scope.listen(signal, 'abort', () => { reject(abortReason(signal)); }, { once: true });
194
+ scope.timeout(ms, resolve);
195
+ });
196
+ } finally { if (id !== undefined) finishLoadingWait(id); scope.dispose(); }
197
+ }
198
+
136
199
  /** Read a complete bounded file. Retry one confirmed lost/missing transport immediately,
137
200
  * then leave the same load pending on RETRY. An optional first-party manifest
138
201
  * length shares this recovery; ordinary caps, parsing and hashes stay strict. */
139
202
  export async function readContent(url: string, maximum: number, options: ContentReadOptions): Promise<Uint8Array<ArrayBuffer>> {
140
203
  if (!Number.isSafeInteger(maximum) || maximum < 0 || maximum > 25_000_000) throw new Error('Invalid content wire cap');
141
204
  if (options.expectedBytes !== undefined && (!Number.isSafeInteger(options.expectedBytes) || options.expectedBytes < 0 || options.expectedBytes > maximum)) throw new Error('Invalid expected content length');
142
- let retried = false;
205
+ let retried = false, reads = 0;
143
206
  for (;;) {
144
207
  options.signal?.throwIfAborted();
208
+ reads++;
145
209
  try {
146
210
  let response: Response;
147
211
  try { response = await options.fetch(url, { ...(retried ? { cache: 'reload' } : {}), ...(options.signal === undefined ? {} : { signal: options.signal }) }); }
148
212
  catch (error) { options.signal?.throwIfAborted(); throw new ContentReadError(url, 'connection unavailable', error); }
149
- return await body(response, url, maximum, options.read, options.expectedBytes, options.response);
213
+ const bytes = await body(response, url, maximum, options.read, options.expectedBytes, options.response);
214
+ // FM6 mode 36: a read that waited on RETRY now arrives, so the download works again: a later stall shows the card's line first
215
+ if (reads > 2) clearDownloadGiveUp();
216
+ return bytes;
150
217
  } catch (error) {
151
218
  options.signal?.throwIfAborted();
152
219
  if (!(error instanceof ContentReadError)) throw error;
153
220
  if (error.missing && options.missingThrows === true) throw error;
221
+ // FM6 mode 34: a 429 that says when waits that long before the retry the budget already allows; the count is unchanged
222
+ if (error.retryAfterMs !== null && error.retryAfterMs > 0) await busyWait(error, error.retryAfterMs, options.signal);
154
223
  if (!retried) { retried = true; }
155
224
  else {
156
225
  if (options.instead !== undefined && await options.instead(error)) throw error;
@@ -159,7 +228,7 @@ export async function readContent(url: string, maximum: number, options: Content
159
228
  // Instead of RETRY forever, the page reloads past its worker into the live build (once per build and tab).
160
229
  if (options.retry === undefined && error.missing && typeof document !== 'undefined'
161
230
  && await (await import('./browserChunkRecovery')).reloadIfStaleBuild()) await new Promise<void>(() => { /* never settles: the page is navigating */ });
162
- await (options.retry === undefined ? retryFromCard(error, options.signal) : options.retry(error)); retried = false;
231
+ await (options.retry === undefined ? retryFromCard(error, options.signal, reads) : options.retry(error)); retried = false;
163
232
  }
164
233
  }
165
234
  }
@@ -0,0 +1,34 @@
1
+ // FM6 mode 36 (meta docs/plans/MMO-FAILURE-MODES-PLAN.md): the world's download gave up. The spawn download is the load's one bounded
2
+ // operation: each part gets its reads (spawnDownload.ts PART_READS), then the job refuses and its waits fall through to the
3
+ // network. When a read that falls through then waits on the card's RETRY too, nothing more will arrive by itself, so the card's
4
+ // line (modes 33 to 35) becomes the `download-failed` page (contentRead.ts). A read that waits on RETRY for
5
+ // DOWNLOAD_GIVE_UP_MS (the spawn manifest's own read, say) gives up the same way. Dependency-free, so the spawn download and the content
6
+ // read share it without either pulling the other in. One page document holds one load's fact.
7
+
8
+ /** What was measured when the download gave up, never a guess. The address and status are for Details and Copy diagnostics only. */
9
+ export interface DownloadGiveUp {
10
+ /** reads of the file or part that refused, its last one included (a RETRY round's reads add to the same count) */
11
+ readonly attempts: number;
12
+ /** the last HTTP status the part answered, null for no HTTP response */
13
+ readonly status: number | null;
14
+ /** what failed, with its address */
15
+ readonly detail: string;
16
+ }
17
+
18
+ let fact: DownloadGiveUp | null = null;
19
+ const listeners = new Set<(given: DownloadGiveUp) => void>();
20
+
21
+ /** The spawn download's job refused (not a cancel). Every read waiting on the card hears it. */
22
+ export function noteDownloadGiveUp(given: DownloadGiveUp): void {
23
+ fact = given;
24
+ for (const listen of listeners) listen(given);
25
+ }
26
+ /** A new download starts: the last one's refusal is over. */
27
+ export function clearDownloadGiveUp(): void { fact = null; }
28
+ /** The refusal of this page's download, if it gave up. */
29
+ export function downloadGiveUp(): DownloadGiveUp | null { return fact; }
30
+ /** Hear a refusal from now on; returns the unsubscribe. */
31
+ export function onDownloadGiveUp(listen: (given: DownloadGiveUp) => void): () => void {
32
+ listeners.add(listen);
33
+ return () => { listeners.delete(listen); };
34
+ }
@@ -44,7 +44,7 @@
44
44
  import { GPU_FILES as ENGINE_GPU_FILES } from './ktx2.generated';
45
45
  import { TIER } from '../core/tier';
46
46
  import { pageURL } from './contentBase';
47
- import { CONTENT_CAPS, PAGE_LEVEL } from '../../../shared/engine/core/config';
47
+ import { PAGE_LEVEL, PHONE_PLAYING_BYTES } from '../../../shared/engine/core/config';
48
48
  import { harnessPins } from '../../../shared/engine/app/identity';
49
49
  import { ktx2Probe, ktx2ProbeResult, type Ktx2Probe } from '../render/ktx2Probe';
50
50
 
@@ -106,8 +106,8 @@ export function setDeviceTexForm(memory: DeviceTexForm | null): void { deviceFor
106
106
  /** G188's automatic tier policy: measured over-cap phone builds use KTX2 before the first visit, never desktop. */
107
107
  export function autoTexturePolicy(mode: TexMode | undefined, imagesFirstPlayingBytes?: number): { mode: TexMode; why: string } | undefined {
108
108
  if (imagesFirstPlayingBytes !== undefined && (!Number.isSafeInteger(imagesFirstPlayingBytes) || imagesFirstPlayingBytes < 0)) throw new RangeError('Invalid images-first playing estimate');
109
- if (TIER === 'phone' && imagesFirstPlayingBytes !== undefined && imagesFirstPlayingBytes > CONTENT_CAPS.playing) {
110
- return { mode: 'ktx2', why: `auto: images-first playing estimate ${imagesFirstPlayingBytes} exceeds ${CONTENT_CAPS.playing}` };
109
+ if (TIER === 'phone' && imagesFirstPlayingBytes !== undefined && imagesFirstPlayingBytes > PHONE_PLAYING_BYTES) {
110
+ return { mode: 'ktx2', why: `auto: images-first playing estimate ${imagesFirstPlayingBytes} exceeds ${PHONE_PLAYING_BYTES}` };
111
111
  }
112
112
  return mode === undefined ? undefined : { mode, why: 'auto: level tier texture policy' };
113
113
  }
@@ -1,4 +1,5 @@
1
1
  import { pageScope } from '../../../shared/engine/app/resources';
2
+ import { framesAvailable } from '../../../shared/engine/app/scopeEnvironment';
2
3
 
3
4
  /** iOS Simulator, 2026-11-09: WebKit stops painting a page as soon as a navigation starts in the same turn, so the load
4
5
  * failure screen's RELOAD showed no cover at all. Every reload the player asked for navigates one painted frame after the
@@ -11,6 +12,8 @@ export function leaveAfterPaint(go: () => void): void {
11
12
  if (pageScope.disposed || pageScope.disposing) { go(); return; }
12
13
  let gone = false;
13
14
  const once = (): void => { if (gone) return; gone = true; go(); };
14
- pageScope.raf(() => { pageScope.timeout(0, once); });
15
+ // FM3's proof (version-skew Reload, 2026-11-15): the online shell's graph runs this with no browser frame environment
16
+ // installed, and the bare frame throws, so Reload sat at RELOADING under 'Something broke'. No frames: the timer alone goes.
17
+ if (framesAvailable()) pageScope.raf(() => { pageScope.timeout(0, once); });
15
18
  pageScope.timeout(LEAVE_FRAME_MS, once);
16
19
  }
@@ -355,6 +355,8 @@ export class EquipmentService implements WeaponHooks {
355
355
  get reach(): number | undefined { return this.current.reach; }
356
356
 
357
357
  /** Give every weapon its line to the server (P1-E5.3-E1). */
358
+ /** The server's weapon wire this page's kit is bound to (TC-E1b: an entered data cell's kit takes the road's). */
359
+ get boundWire(): WeaponWire | null { return this.serverWire; }
358
360
  bindWire(wire: WeaponWire | null): void { this.serverWire = wire; for (const w of this.list) w.wire = wire; wire?.equip(this.current.row.id); }
359
361
  /** A named interaction the server must judge: nothing, where no server owns the player. */
360
362
  interact(id: string): void { this.serverWire?.interact(id); }
@@ -360,6 +360,7 @@ export class Game {
360
360
  * they hold) go with their row; a re-registered id starts a fresh record. */
361
361
  private readonly faultSystems = new WeakMap<object, GameSystem<(dt: number, t: number) => void>>();
362
362
  private anonymous = 0;
363
+ private observers = 0;
363
364
  /** E357 F2: list order is the execution order; observation never registers a system. */
364
365
  systemLabels(): Record<'input' | 'fixed.pre' | 'fixed.step' | 'fixed.post' | 'update' | 'late', string[]> {
365
366
  const phases = this.app.systemsByPhase();
@@ -904,10 +905,13 @@ export class Game {
904
905
  onUpdate(fn: (dt: number, t: number) => void, label?: string, core = false): void { this.register('update', fn, label, core); }
905
906
  /** One player-owned callback survives world-frame changes and ends with the original player scope. */
906
907
  onPlayerUpdate(fn: (dt: number, t: number) => void, label: string): void { this.register('update', fn, label, false, this.playerScope, false); }
907
- /** E357 F2: a temporary harness observer of simulation frames, removed when its walk finishes. */
908
+ /**
909
+ * E357 F2: a temporary harness observer of simulation frames, removed when its walk finishes. Each has its own system id:
910
+ * the dev hook holds several at once (its ground sweep, each part's lamps and water), and one shared id threw on the second.
911
+ */
908
912
  watchFrames(fn: (dt: number) => void): () => void {
909
913
  const scope = this.levelScope.child('observer');
910
- this.register('update', fn, 'harness.walk', false, scope, false);
914
+ this.register('update', fn, `harness.walk.${String(this.observers++)}`, false, scope, false);
911
915
  return () => { scope.dispose(); };
912
916
  }
913
917
  /** First in the frame: read controls into intents the fixed steps consume (the player's move, a queued jump). */
@@ -1,3 +1,5 @@
1
+ import type { Layers, Object3D } from 'three';
2
+
1
3
  /**
2
4
  * The layer of shadow-only casters: meshes drawn into the sun's shadow map and nowhere else (Cabin.ts's static depth
3
5
  * proxies, animalShadow.ts's one-draw animal casters). three.js tests a caster's layers against the VIEW camera in the
@@ -6,3 +8,19 @@
6
8
  * and only then. PINE-HOLLOW-REMASTER PH-P1 / P2.
7
9
  */
8
10
  export const SHADOW_LAYER = 9;
11
+
12
+ /**
13
+ * SHARD-SOURCE ss4d: the `userData` mark on a mesh that sits on SHADOW_LAYER only because a merge draws it for the view
14
+ * (`groundMerge.ts` `mergeView`, AP8's merged props). It is still a real surface: a tap in the World Explorer picks it
15
+ * (`explore/pick.ts`), where a true shadow-only caster (a cabin's depth proxy) stays unpickable.
16
+ */
17
+ export const MERGED_VIEW = 'mergedView';
18
+ /** The name of a merge's own view mesh (AP8): it stands in for its members, so a pick reads the member, never it. */
19
+ export const MERGED_COPY = 'props.merged';
20
+
21
+ /** Whether a raycast hit on `object` is a drawn surface for a raycaster on `view`'s layers: on one of them, or a merged
22
+ * member its merge draws. */
23
+ export function drawnSurface(object: Object3D, view: Layers): boolean {
24
+ if (object.name === MERGED_COPY) return false;
25
+ return object.layers.test(view) || object.userData[MERGED_VIEW] === true;
26
+ }
@@ -21,6 +21,7 @@
21
21
  * pickups do) is a few pixels wide, and the finger lands on the roof beside it.
22
22
  */
23
23
  import * as THREE from 'three';
24
+ import { drawnSurface, SHADOW_LAYER } from '../core/shadowLayer';
24
25
 
25
26
  /** something a tap can hit: an object (or a batch mesh) and how it maps to a catalog entry + a box */
26
27
  export interface SelectTarget {
@@ -55,6 +56,17 @@ const volume = (b: THREE.Box3): number => { b.getSize(_size); return _size.x * _
55
56
  export const MIN_PICK = 0.75;
56
57
  const tiny = (b: THREE.Box3): boolean => { b.getSize(_size); return Math.max(_size.x, _size.y, _size.z) <= MIN_PICK; };
57
58
 
59
+ /**
60
+ * The nearest drawn surface of `object` under the ray. SHARD-SOURCE ss4d: a merged prop (AP8) draws through its merge and
61
+ * keeps its own mesh on SHADOW_LAYER, which a raycaster on the view layer skips: the ray tests that layer too for the
62
+ * one call, and keeps only the hits on drawn surfaces (a shadow-only depth proxy is not one).
63
+ */
64
+ function drawnHit(ray: THREE.Raycaster, object: THREE.Object3D): THREE.Intersection | undefined {
65
+ const view = new THREE.Layers(); view.mask = ray.layers.mask;
66
+ ray.layers.enable(SHADOW_LAYER);
67
+ try { return ray.intersectObject(object, true).find((hit) => drawnSurface(hit.object, view)); } finally { ray.layers.mask = view.mask; }
68
+ }
69
+
58
70
  /** the target under the ray, or null (nothing hit, or a surface no target claims) */
59
71
  export function pickTarget(ray: THREE.Raycaster, targets: readonly SelectTarget[]): Picked | null {
60
72
  const byObject = new Map<THREE.Object3D, SelectTarget[]>();
@@ -65,7 +77,7 @@ export function pickTarget(ray: THREE.Raycaster, targets: readonly SelectTarget[
65
77
  let near: { mesh: THREE.Object3D; point: THREE.Vector3; d: number } | null = null;
66
78
  for (const object of byObject.keys()) {
67
79
  if (!shown(object)) continue;
68
- const hit = ray.intersectObject(object, true)[0];
80
+ const hit = drawnHit(ray, object);
69
81
  if (hit && (!near || hit.distance < near.d)) near = { mesh: hit.object, point: hit.point.clone(), d: hit.distance };
70
82
  }
71
83
  // a small copy the ray passes through before the surface it hits (E345: the minimum pick size)
@@ -97,6 +97,8 @@ function ownerTable(columns: readonly NetColumn<never>[]): OwnerTable {
97
97
  export class Predictor {
98
98
  /** Corrections taken, and steps replayed for them: what a proof page reports. */
99
99
  corrections = 0; replays = 0;
100
+ /** Server-owned transitions, kept separate from a failed local prediction in proof output. */
101
+ readonly authoritative = { leadEnds: 0, resets: 0 };
100
102
  /** What each correction disagreed on, and the widest gap at the acknowledged step. */
101
103
  readonly missed = { position: 0, grounded: 0, board: 0, swim: 0, ride: 0, gap: 0 };
102
104
  readonly misses: number[][] = [];
@@ -160,7 +162,8 @@ export class Predictor {
160
162
  if ((acked !== null && seqAfter(acked, lastSeq)) || (this.body.ride === null) !== (ridden === null)) return false;
161
163
  const led = this.flag(table.led, owner) === 1, resets = this.value(table.resets, owner);
162
164
  const boarded = (ridden !== null) !== this.aboard; // getting on or off is the server's word, not a wrong guess
163
- const forced = led || this.led || boarded || (this.resets !== null && this.resets !== resets);
165
+ const leadEnded = this.led && !led, reset = this.resets !== null && this.resets !== resets;
166
+ const forced = led || this.led || boarded || reset;
164
167
  this.led = led; this.resets = resets; this.aboard = ridden !== null;
165
168
  if (!forced && acked === lastSeq) return false;
166
169
  const { body, seqs, states, count, head } = this, offset = count === 0 ? -1 : (lastSeq - (seqs[head] ?? 0)) & 0xffff;
@@ -182,12 +185,17 @@ export class Predictor {
182
185
  this.save(run);
183
186
  }
184
187
  s.yaw = yaw; // the view is this client's own: the server sends it back later than the thumb has moved
185
- if (!led && !boarded) this.corrections++;
188
+ // The end of a server-led move and a server teleport must take the authoritative pose, but neither says the
189
+ // page predicted a command incorrectly. Counting them as corrections made Far Reach's boost report a false B2 miss.
190
+ if (leadEnded) this.authoritative.leadEnds++;
191
+ if (reset) this.authoritative.resets++;
192
+ const corrected = !forced && !led && !boarded;
193
+ if (corrected) this.corrections++;
186
194
  const offsetX = x - feet.x, offsetY = y - feet.y, offsetZ = z - feet.z, far = offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ > PREDICTION_SNAP * PREDICTION_SNAP;
187
195
  body.renderOffset.set(far ? 0 : offsetX, far ? 0 : offsetY, far ? 0 : offsetZ);
188
196
  this.glide = glidePace(body.renderOffset.length());
189
- if(!led&&!boarded)this.corrected?.({tick:tick??s.tick,mode:ride!==null?'ride':s.board.on?'board':s.swim.on?'swim':'foot',offset:Math.hypot(offsetX,offsetY,offsetZ),snapped:far});
190
- return !led && !boarded;
197
+ if(corrected)this.corrected?.({tick:tick??s.tick,mode:ride!==null?'ride':s.board.on?'board':s.swim.on?'swim':'foot',offset:Math.hypot(offsetX,offsetY,offsetZ),snapped:far});
198
+ return corrected;
191
199
  }
192
200
 
193
201
  /** A session's first frame: this body stands where the server says, with nothing to compare it to. */
@@ -1,5 +1,5 @@
1
1
  import { mountUi } from '../ui/ownership';
2
- import { mountBoostLook } from '../ui/hoverBoost';
2
+ import { mountBoostLook, mountBoostTag } from '../ui/hoverBoost';
3
3
  import { app } from '../app/runtime';
4
4
  import { capturePointer, listenDom, listenPage } from '../input/dom';
5
5
  import type { Action, TouchStack, TouchVerbSpec } from '../input/InputService';
@@ -155,7 +155,8 @@ export class TouchControls {
155
155
  this.weapons = weapons;
156
156
  this.lock = lock;
157
157
  this.active = force || IS_TOUCH;
158
- if (!this.active) return;
158
+ // QA 11-15 row 9: a keyboard page has no HOVER tab, so BOOST stands on the left edge by itself while boost is on
159
+ if (!this.active) { mountBoostTag(document.getElementById('hud') ?? document.body, player, app.events, this.scope); return; }
159
160
  const hud = document.getElementById('hud') ?? document.body;
160
161
  hud.classList.add('touch');
161
162
  const root = document.createElement('div');
@@ -41,7 +41,9 @@ const SWAY_VERTEX = /* glsl */`
41
41
  vec3 wsSwayAt = ( wsSwayM * vec4( transformed, 1.0 ) ).xyz;
42
42
  float wsSwayPh = wsSceneTime * wsSwayWind.z * 6.2831853 + wsSwayAt.x * 0.37 + wsSwayAt.z * 0.29;
43
43
  float wsSwayAmt = wsSway * ( 0.7 * sin( wsSwayPh ) + 0.3 * sin( wsSwayPh * 2.3 + 1.7 ) );
44
- vec3 wsSwayDir = transpose( mat3( wsSwayM ) ) * vec3( wsSwayWind.x, 0.0, wsSwayWind.y );
44
+ // the wind is a world direction and wsSway world metres: back into the mesh's own frame by the inverse, which (unlike
45
+ // the transpose) also undoes the mesh's scale, so a scaled frond still moves its declared metres
46
+ vec3 wsSwayDir = inverse( mat3( wsSwayM ) ) * vec3( wsSwayWind.x, 0.0, wsSwayWind.y );
45
47
  transformed += wsSwayDir * wsSwayAmt;
46
48
  }
47
49
  `;
@@ -45,11 +45,13 @@ export interface BrowserErrorTags {
45
45
  * once per cell a session; warning
46
46
  * map-tile-missing a full-map cell the world map atlas has no tile for, drawn as a plain plot or its own map instead
47
47
  * (game/grid/mapAtlas.ts; QA-FEEDBACK 2026-11-13 row 44), once per slug a page; warning
48
+ * release-unsigned FM5 mode 39's page, "Couldn't check the world": the release file failed its signature, so the page dials
49
+ * nothing (host/online/releaseScreens.ts), once a page
48
50
  * Not screens of a fault, so never reported: the player's own reload, back or exit (QA 11-12 row 35), "Playing somewhere else",
49
51
  * "The world is full", the reconnect banner (counted in `net` telemetry), title refusal lines and the Connection doctor.
50
52
  */
51
53
  export const ERROR_SCREENS = ['error-modal', 'stuck-step', 'glitch-chip', 'load-failure', 'title-drop', 'link-lost', 'link-refused', 'stale-build',
52
- 'loading-stall', 'stale-reload', 'self-reload', 'save-failed', 'cell-unavailable', 'map-tile-missing'] as const;
54
+ 'loading-stall', 'stale-reload', 'self-reload', 'save-failed', 'cell-unavailable', 'map-tile-missing', 'release-unsigned'] as const;
53
55
  /** S18: screens common enough on a bad network that each is a Sentry warning, never an error */
54
56
  export const WARNING_SCREENS: readonly ErrorScreen[] = ['loading-stall', 'stale-reload', 'self-reload', 'cell-unavailable', 'map-tile-missing'];
55
57
  export type ErrorScreen = typeof ERROR_SCREENS[number];
@@ -159,7 +159,7 @@ function build(): HTMLElement {
159
159
  const doctor = document.createElement('button');
160
160
  doctor.type = 'button'; doctor.className = 'doctor'; doctor.textContent = engineString('s_doctor_failed');
161
161
  q(el, '.title').after(doctor);
162
- scope.listen(doctor, 'click', () => { doctor.disabled = true; openDoctorPage('failed-join'); });
162
+ scope.listen(doctor, 'click', () => { doctor.disabled = true; void openDoctorPage('failed-join').then(left => { doctor.disabled = left; return left; }); });
163
163
  }
164
164
  // a dead loop can't be played on: KEEP PLAYING only acts while the loop still runs (it is hidden otherwise)
165
165
  scope.listen(q(el, '.keep'), 'click', () => { if (loopState() !== 'running') return; closeFatal(); document.dispatchEvent(new Event('ws:error-keep')); });
@@ -14,7 +14,7 @@ import { loadShellTemplate, START_STEPS, stopShellClock } from '../boot/shell';
14
14
  import { appIdentity } from '../../../shared/engine/app/identity';
15
15
  import { recordBootCheckpoint, recordBootProgress, startBoot } from '../boot/bootTrace';
16
16
  import { adoptLoadingWait } from '../boot/download';
17
- import { beginLoadingWait, reportLoadingWait, finishLoadingWait, loadingWaitState } from '../../../shared/engine/boot/loadingWaits';
17
+ import { beginLoadingWait, reportLoadingWait, finishLoadingWait, loadingWaitState, type LoadingWaitEntry } from '../../../shared/engine/boot/loadingWaits';
18
18
  import { loadingCacheText, loadingDownloadText, loadingDownloadFraction, loadingPrefetchFraction, loadingPrefetchText, type LoadingPrefetchSnapshot, type LoadingDownloadSnapshot } from '../boot/loadingDownloadText';
19
19
  import { LoadingTimeline, installLoadingTimeline, type LoadingPath, type LoadingRow, type LoadingGap } from '../../../shared/engine/boot/timeline';
20
20
  import {loadingFraction} from '../boot/weights';
@@ -579,7 +579,7 @@ export class Loading {
579
579
 
580
580
  private paintWaiting(timeline: TimelineSnapshot): void {
581
581
  if (this.view?.error || this.failedReason !== null) return;
582
- if (this.finished) { set(this.els.foot, ''); this.els.retry.hidden = true; setData(this.root, 'stalled', 'false'); return; }
582
+ if (this.finished) { set(this.els.foot, ''); delete this.els.foot.dataset['failmode']; this.els.retry.hidden = true; setData(this.root, 'stalled', 'false'); return; }
583
583
  const pending = this.scoped ? [] : loadingStepWaits(bootWaits(), timeline.display, timeline.current, this.timeline.waitOwner).filter(wait => wait.id !== this.waitId);
584
584
  const files = pending.filter(wait => wait.kind === 'file');
585
585
  // The outer admission promise has no file identity. Let the current
@@ -615,6 +615,18 @@ export class Loading {
615
615
  // A quiet phase still reports its actual age, without advancing a byte,
616
616
  // file or setup credit. Only an explicit failed-read retry capability offers
617
617
  // an action; a long pending operation remains pending.
618
+ // FM6 (meta MMO-FAILURE-MODES-PLAN modes 33 to 35, 43, 44): a failed read says what failed in a player's words, how long it has
619
+ // waited, and the retry actually scheduled; the catalogue's ids ride on the line. A RETRY wait wins over a note (storage full).
620
+ const said = (row: LoadingWaitEntry): boolean => row.failmode !== undefined && row.line !== undefined;
621
+ const pick = (rows: readonly LoadingWaitEntry[]): LoadingWaitEntry | undefined => rows.find(row => row.retry !== null) ?? rows.find(row => row.dueAt !== undefined) ?? rows[0];
622
+ const fault = pick(pending.filter(said)) ?? (stalled ? undefined : pick([...loadingWaitState().pending.values()].filter(row => said(row) && row.owner === null)));
623
+ if (fault?.failmode !== undefined && fault.line !== undefined) {
624
+ const due = fault.dueAt === undefined ? '' : ` · next try in ${String(Math.max(0, Math.ceil((fault.dueAt - now) / 1000)))} s`;
625
+ this.els.foot.dataset['failmode'] = fault.failmode;
626
+ set(this.els.foot, `${fault.line} · ${String(Math.floor(Math.max(0, now - fault.startedAt) / 1000))} s${due}`);
627
+ return;
628
+ }
629
+ delete this.els.foot.dataset['failmode'];
618
630
  set(this.els.foot, stalled ? `Waiting for ${label} · ${(quietMs / 1000).toFixed(1)} s` : !this.finished && quietMs >= 500
619
631
  ? `No reported progress for ${(quietMs / 1000).toFixed(1)} s · ${detail}` : detail);
620
632
  }
@@ -0,0 +1,54 @@
1
+ // FM6 mode 36 (meta docs/plans/MMO-FAILURE-MODES-PLAN.md): "The world didn't download". A page (the plan's first style) over the
2
+ // loading card, shown while a read the given-up download fell through to waits on RETRY. Try again is that same RETRY (the existing
3
+ // recovery path, no new counter); the downloaded files are kept, so it is quicker. It closes when the wait it belongs to settles.
4
+ // Primary copy has no address or status: Details and Copy diagnostics hold them.
5
+ import type { Scope } from '../../../shared/engine/app/scope';
6
+ import type { DownloadGiveUp } from '../boot/downloadGiveUp';
7
+ import { copyText, diagnosticsSource } from './diagnosticsCopy';
8
+ import { mountUi } from './ownership';
9
+ import { engineString } from '../../../shared/engine/strings';
10
+
11
+ const PAGE = 'position:fixed;inset:0;z-index:2147482600;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(4,9,14,.86);color:#e6f2f8;font:12px/1.5 "JetBrains Mono",Menlo,monospace';
12
+ const BOX = 'width:min(440px,100%);padding:22px 18px 16px;background:rgba(13,27,38,.92);border:1px solid rgba(255,120,120,.45);border-top:2px solid #ff7878;display:flex;flex-direction:column;gap:10px';
13
+ const BUTTON = 'min-height:48px;padding:13px 16px;cursor:pointer;font:700 12px/1 "JetBrains Mono",Menlo,monospace;letter-spacing:.22em;text-transform:uppercase;border:1px solid rgba(143,227,255,.35);background:rgba(13,27,38,.6);color:#e6f2f8';
14
+
15
+ /** The one page on screen: a second waiting read shares it, and takes it over if the first read's wait ends alone (a cancel). */
16
+ let open: Scope | null = null;
17
+ const queued: (() => void)[] = [];
18
+
19
+ /** Show the page for `owner`'s wait (its disposal closes it). `retry` is the card's RETRY; `measured` is the read's own failure. */
20
+ export function downloadFailedPage(owner: Scope, given: DownloadGiveUp, measured: string, retry: () => void): void {
21
+ if (open !== null && !open.disposed) {
22
+ const again = (): void => { if (!owner.disposed) downloadFailedPage(owner, given, measured, retry); };
23
+ queued.push(again);
24
+ owner.onDispose(() => { const at = queued.indexOf(again); if (at !== -1) queued.splice(at, 1); });
25
+ return;
26
+ }
27
+ const page = owner.child('download-failed');
28
+ open = page;
29
+ const root = document.createElement('div'), box = document.createElement('div'), tag = document.createElement('p'), title = document.createElement('h1'), body = document.createElement('p');
30
+ const again = document.createElement('button'), check = document.createElement('button'), copy = document.createElement('button');
31
+ const details = document.createElement('details'), summary = document.createElement('summary'), fact = document.createElement('p');
32
+ root.dataset['failmode'] = 'download-failed'; root.dataset['tone'] = 'bad'; root.setAttribute('role', 'alertdialog'); root.setAttribute('aria-modal', 'true');
33
+ root.setAttribute('aria-label', engineString('s_download_failed_title')); root.style.cssText = PAGE; box.style.cssText = BOX;
34
+ tag.textContent = engineString('s_download_failed_tag'); tag.style.cssText = 'margin:0;font-size:10.5px;letter-spacing:.3em;text-transform:uppercase;color:#ff9a9a';
35
+ title.textContent = engineString('s_download_failed_title'); title.style.cssText = 'margin:0;font:700 24px/1.1 Rajdhani,Bahnschrift,sans-serif;letter-spacing:.1em;text-transform:uppercase;color:#fff';
36
+ body.textContent = engineString('s_download_failed_body', [given.attempts]);
37
+ body.style.margin = '0';
38
+ again.type = 'button'; again.className = 'go'; again.textContent = engineString('s_download_failed_retry'); again.style.cssText = `${BUTTON};border-color:#8fe3ff;background:rgba(143,227,255,.18)`;
39
+ check.type = 'button'; check.textContent = engineString('s_download_failed_check'); check.style.cssText = BUTTON;
40
+ copy.type = 'button'; copy.textContent = engineString('s_download_failed_copy'); copy.style.cssText = BUTTON;
41
+ const said = `${given.detail}${given.status === null ? ' · no HTTP response' : ` · HTTP ${String(given.status)}`} × ${String(given.attempts)}; then ${measured}`;
42
+ summary.textContent = engineString('s_download_failed_details'); fact.textContent = said; fact.style.cssText = 'margin:8px 0 0;opacity:.6;overflow-wrap:anywhere';
43
+ details.append(summary, fact);
44
+ page.listen(again, 'click', () => { again.disabled = true; again.textContent = engineString('s_download_failed_trying'); retry(); });
45
+ page.listen(check, 'click', () => { document.dispatchEvent(new CustomEvent('ws:doctor', { detail: 'download-failed' })); });
46
+ page.listen(copy, 'click', () => {
47
+ const report = diagnosticsSource();
48
+ void (async () => { copy.textContent = await copyText(`${said}\n\n${report === null ? '' : report()}`) ? engineString('s_download_failed_copied') : engineString('s_download_failed_refused'); })();
49
+ });
50
+ page.onDispose(() => { root.remove(); if (open === page) open = null; queued.shift()?.(); });
51
+ box.append(tag, title, body, again, check, copy, details); root.append(box);
52
+ mountUi(root, page, document.body);
53
+ again.focus();
54
+ }