@wildshard/engine 0.1.15 → 0.1.18

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 (262) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/index.html +157 -11
  3. package/lint/engine-sides.json +23 -0
  4. package/lint/host-callback-syntax.mjs +2 -1
  5. package/lint/host-callbacks.mjs +3 -3
  6. package/lint/host-files.mjs +5 -4
  7. package/lint/host-register.json +496 -0
  8. package/lint/no-base64.mjs +3 -1
  9. package/lint/ratchet.json +2 -2
  10. package/lint/shard-imports.d.mts +1 -0
  11. package/lint/shard-imports.mjs +60 -13
  12. package/lint/shard-source.d.mts +9 -0
  13. package/lint/shard-source.mjs +91 -0
  14. package/lint/shardfile-boundaries.mjs +10 -8
  15. package/lint/sim-closure.mjs +6 -3
  16. package/lint/wildshard-plugin.d.ts +4 -0
  17. package/lint/wildshard-plugin.js +44 -27
  18. package/package.json +24 -6
  19. package/scripts/app-build/buildIdentity.d.mts +3 -1
  20. package/scripts/app-build/buildIdentity.mjs +25 -5
  21. package/scripts/app-build/builtAt.d.mts +4 -0
  22. package/scripts/app-build/builtAt.mjs +21 -0
  23. package/scripts/app-build/outputProducts.d.mts +3 -0
  24. package/scripts/app-build/outputProducts.mjs +31 -0
  25. package/scripts/app-build/serviceWorker.ts +16 -2
  26. package/scripts/app-build/versionFiles.ts +2 -1
  27. package/scripts/app-build-pipeline.mjs +7 -1
  28. package/scripts/audio-download-proof.mjs +843 -0
  29. package/scripts/build-app.mjs +4 -0
  30. package/scripts/build-mirror.d.mts +2 -0
  31. package/scripts/build-mirror.mjs +5 -4
  32. package/scripts/built-product.mjs +3 -3
  33. package/scripts/cell-mem/metrics-preload.mjs +65 -0
  34. package/scripts/cell-mem-bench.mjs +130 -0
  35. package/scripts/check-chunks.mjs +2 -1
  36. package/scripts/check-devserver.mjs +1 -1
  37. package/scripts/chromium-keychain-check.mjs +4 -2
  38. package/scripts/chromium-keychain.mjs +3 -1
  39. package/scripts/cook.mjs +7 -3
  40. package/scripts/devices.d.mts +4 -0
  41. package/scripts/devices.mjs +39 -0
  42. package/scripts/devserver-client.d.mts +7 -0
  43. package/scripts/devserver-client.mjs +85 -0
  44. package/scripts/doctor-proof.mjs +1 -1
  45. package/scripts/e2e-faults.mjs +159 -0
  46. package/scripts/engine-ci-budget.ts +7 -1
  47. package/scripts/format-lock.mjs +20 -11
  48. package/scripts/generate-title-launch.mjs +3 -2
  49. package/scripts/grid-crossing-walk-proof.mjs +30 -11
  50. package/scripts/heavy-lane.py +25 -1
  51. package/scripts/host-ruler/register-migrate.mjs +242 -0
  52. package/scripts/host-ruler/register.d.mts +36 -0
  53. package/scripts/host-ruler/register.mjs +116 -0
  54. package/scripts/host-ruler/roots.d.mts +29 -0
  55. package/scripts/host-ruler/roots.mjs +333 -0
  56. package/scripts/host-ruler/server-roots.d.mts +23 -0
  57. package/scripts/host-ruler/server-roots.mjs +272 -0
  58. package/scripts/main-watch.d.mts +1 -1
  59. package/scripts/main-watch.mjs +10 -6
  60. package/scripts/map-hash.mjs +3 -6
  61. package/scripts/memory-proof.mjs +158 -0
  62. package/scripts/mmo-bots.mjs +2 -2
  63. package/scripts/offline-proof-rules.d.mts +5 -2
  64. package/scripts/offline-proof-rules.mjs +43 -6
  65. package/scripts/offline-proof.mjs +15 -6
  66. package/scripts/online-rig.mjs +4 -4
  67. package/scripts/page-release/flow.d.mts +1 -0
  68. package/scripts/page-release/flow.mjs +6 -2
  69. package/scripts/page-release.mjs +5 -1
  70. package/scripts/physics-route.json +0 -71
  71. package/scripts/pins-catalogue.ts +103 -0
  72. package/scripts/pins-reuse.mjs +3 -1
  73. package/scripts/pins.ts +22 -14
  74. package/scripts/preview-grid.ts +203 -0
  75. package/scripts/road-preload-proof.mjs +167 -0
  76. package/scripts/server-release/publish.mjs +2 -2
  77. package/scripts/server-release/served-slug.d.mts +2 -0
  78. package/scripts/server-release/served-slug.mjs +10 -0
  79. package/scripts/server-release/sign.d.mts +1 -0
  80. package/scripts/server-release/sign.mjs +3 -7
  81. package/scripts/shard-components.mjs +0 -2
  82. package/scripts/shard-outputs.d.mts +8 -0
  83. package/scripts/shard-outputs.mjs +45 -11
  84. package/scripts/side-parity.d.mts +2 -1
  85. package/scripts/side-parity.mjs +25 -4
  86. package/scripts/test-amber.d.mts +1 -0
  87. package/scripts/test-amber.mjs +10 -0
  88. package/scripts/test-products.json +3 -3
  89. package/scripts/tier-textures-proof.mjs +101 -0
  90. package/scripts/tier-textures.mjs +60 -0
  91. package/scripts/tracked-public.d.mts +1 -0
  92. package/scripts/tracked-public.mjs +17 -0
  93. package/scripts/tsconfig.json +1 -0
  94. package/scripts/vps/wildshard-config +79 -23
  95. package/scripts/worker-client-play.mjs +1 -0
  96. package/scripts/worker-client-proof.mjs +1 -1
  97. package/scripts/worker-client-slug.mjs +44 -0
  98. package/src/cli/engine.mjs +8 -0
  99. package/src/client/app/bootRoute.ts +4 -1
  100. package/src/client/app/dropModal.ts +15 -2
  101. package/src/client/app/entry.ts +96 -13
  102. package/src/client/app/slugPath.ts +5 -0
  103. package/src/client/engine/audio/Audio.ts +20 -2
  104. package/src/client/engine/boot/bakedTextures.ts +3 -2
  105. package/src/client/engine/boot/bootTrace.ts +6 -1
  106. package/src/client/engine/boot/bytes.ts +4 -3
  107. package/src/client/engine/boot/clearDownloads.ts +1 -1
  108. package/src/client/engine/boot/contentRead.ts +4 -0
  109. package/src/client/engine/boot/dropNotice.ts +20 -6
  110. package/src/client/engine/boot/gpuFiles.ts +25 -2
  111. package/src/client/engine/boot/lastEnd.ts +8 -2
  112. package/src/client/engine/boot/parsedPages.ts +127 -58
  113. package/src/client/engine/boot/shardPrefetch.ts +7 -1
  114. package/src/client/engine/boot/sw.ts +19 -0
  115. package/src/client/engine/build.d.ts +2 -0
  116. package/src/client/engine/core/Game.ts +29 -3
  117. package/src/client/engine/core/GpuRecovery.ts +7 -0
  118. package/src/client/engine/core/Volumetrics.ts +5 -0
  119. package/src/client/engine/core/assets.ts +27 -20
  120. package/src/client/engine/core/bootstrap.ts +5 -3
  121. package/src/client/engine/core/ktx2.ts +84 -11
  122. package/src/client/engine/debug/probe.ts +18 -1
  123. package/src/client/engine/explore/Compare.ts +2 -2
  124. package/src/client/engine/explore/TouchFly.ts +3 -5
  125. package/src/client/engine/fx/LightPool.ts +41 -1
  126. package/src/client/engine/input/dom.ts +12 -0
  127. package/src/client/engine/net/predictor.ts +6 -2
  128. package/src/client/engine/player/Player.ts +10 -2
  129. package/src/client/engine/player/TouchControls.ts +12 -4
  130. package/src/client/engine/pwa/sw.js +59 -11
  131. package/src/client/engine/render/drawCheck.ts +96 -0
  132. package/src/client/engine/render/precompile.ts +20 -14
  133. package/src/client/engine/saves/staleBuildNote.ts +46 -0
  134. package/src/client/engine/telemetry/browserErrors.ts +161 -21
  135. package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
  136. package/src/client/engine/telemetry/screenOutbox.ts +61 -0
  137. package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
  138. package/src/client/engine/ui/DeathFade.ts +99 -11
  139. package/src/client/engine/ui/ErrorModal.ts +13 -6
  140. package/src/client/engine/ui/Feedback.ts +2 -1
  141. package/src/client/engine/ui/Loading.ts +10 -6
  142. package/src/client/engine/ui/Map.ts +2 -1
  143. package/src/client/engine/ui/WeaponStrip.ts +2 -1
  144. package/src/client/engine/ui/backGuard.ts +104 -0
  145. package/src/client/engine/ui/hudAdapters.ts +30 -4
  146. package/src/client/engine/ui/loading.css +17 -0
  147. package/src/client/engine/ui/namePrompt.ts +6 -5
  148. package/src/client/engine/ui/styles/combat.css +12 -0
  149. package/src/client/engine/ui/styles/namePrompt.css +4 -2
  150. package/src/client/game/boot/audio.generated.ts +0 -396
  151. package/src/client/game/boot/bytes.generated.ts +42 -71
  152. package/src/client/game/boot/versions.generated.ts +0 -13
  153. package/src/client/game/compendium/keepsakes.ts +16 -6
  154. package/src/client/game/grapple/tool.ts +10 -7
  155. package/src/client/game/grid/area.ts +38 -0
  156. package/src/client/game/grid/cellLoading.ts +23 -12
  157. package/src/client/game/grid/cellScreens.ts +39 -74
  158. package/src/client/game/grid/live.ts +28 -2
  159. package/src/client/game/grid/liveSession.ts +54 -10
  160. package/src/client/game/grid/menu.ts +4 -0
  161. package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
  162. package/src/client/game/grid/nearPlaceholderView.ts +9 -3
  163. package/src/client/game/grid/neighbourPanels.ts +10 -1
  164. package/src/client/game/grid/oneWayIn.ts +92 -27
  165. package/src/client/game/grid/pageEntry.ts +19 -0
  166. package/src/client/game/grid/pageShell.ts +1 -1
  167. package/src/client/game/grid/placedCards.ts +55 -0
  168. package/src/client/game/grid/placedCells.ts +131 -0
  169. package/src/client/game/grid/plotAudio.ts +114 -0
  170. package/src/client/game/grid/products.ts +55 -5
  171. package/src/client/game/grid/regionalRuntime.ts +6 -0
  172. package/src/client/game/grid/regionalWorld.ts +15 -2
  173. package/src/client/game/grid/roadCull.ts +44 -14
  174. package/src/client/game/grid/roadLookPlatform.ts +2 -2
  175. package/src/client/game/grid/roadTileBacking.ts +13 -3
  176. package/src/client/game/grid/session.ts +47 -22
  177. package/src/client/game/grid/shardfileFar.ts +9 -3
  178. package/src/client/game/grid/spawnGround.ts +68 -0
  179. package/src/client/game/grid/voidLook.ts +29 -23
  180. package/src/client/game/loot/runtime.ts +3 -1
  181. package/src/client/game/mainMenu.ts +14 -6
  182. package/src/client/game/riding/hud.ts +6 -4
  183. package/src/client/game/session/finish.ts +22 -4
  184. package/src/client/game/session/play.ts +8 -2
  185. package/src/client/game/session/session.ts +4 -1
  186. package/src/client/game/shard/titleList.ts +6 -2
  187. package/src/client/game/shardfile/clientWorker.ts +43 -13
  188. package/src/client/game/shardfile/serverRoute.ts +10 -22
  189. package/src/client/game/slugPage.css +11 -0
  190. package/src/client/game/slugPage.ts +84 -0
  191. package/src/client/game/systems/viewmodel/heldView.ts +6 -3
  192. package/src/client/game/titleDeck.ts +56 -32
  193. package/src/client/host/online/doctor.ts +7 -6
  194. package/src/client/host/online/linkScreens.ts +16 -0
  195. package/src/client/host/online/release.ts +51 -5
  196. package/src/client/host/online/shell.ts +62 -27
  197. package/src/client/host/standalone/shell.ts +7 -3
  198. package/src/cook/game/audioReport.ts +57 -0
  199. package/src/cook/game/entryTotals.ts +26 -6
  200. package/src/cook/game/installedRuntimeReads.ts +3 -0
  201. package/src/cook/game/shardCook.ts +38 -8
  202. package/src/cook/game/tierTextures.ts +276 -0
  203. package/src/e2e/smoke/game.ts +19 -14
  204. package/src/e2e/smoke/page-globals.d.ts +9 -8
  205. package/src/e2e/smoke/template2.spec.ts +8 -7
  206. package/src/server/engine/sim/respawn.ts +6 -1
  207. package/src/server/engine/sim.ts +3 -0
  208. package/src/server/game/grid/simulation.ts +35 -0
  209. package/src/server/game/loot/harvest.ts +2 -0
  210. package/src/server/game/loot/keepsakeProgression.ts +40 -0
  211. package/src/server/game/loot/playerOwned.ts +5 -1
  212. package/src/server/game/plugin/simulation.ts +4 -0
  213. package/src/server/game/population/nativeBake.ts +2 -1
  214. package/src/server/game/quest/chapterRecords.ts +2 -0
  215. package/src/server/game/quest/serverChapters.ts +4 -0
  216. package/src/server/game/quest/serverDoors.ts +11 -5
  217. package/src/server/game/roomRespawn.ts +4 -0
  218. package/src/server/game/shardfile/installedSides.ts +18 -0
  219. package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
  220. package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
  221. package/src/server/host/bake/headlessWorker.ts +5 -1
  222. package/src/server/host/dedicated/cellHost.ts +98 -29
  223. package/src/server/host/dedicated/cellProtocol.ts +11 -1
  224. package/src/server/host/dedicated/cellWorker.ts +9 -3
  225. package/src/server/host/dedicated/crossing.ts +6 -2
  226. package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
  227. package/src/server/host/dedicated/gridCells.ts +52 -9
  228. package/src/server/host/dedicated/main.ts +31 -12
  229. package/src/server/host/dedicated/placementFile.ts +56 -0
  230. package/src/server/host/dedicated/releaseFile.ts +17 -10
  231. package/src/server/host/dedicated/roadRoom.ts +21 -5
  232. package/src/server/host/dedicated/socketTransport.ts +2 -1
  233. package/src/server/host/dedicated/workerTable.ts +13 -1
  234. package/src/server/host/dedicated/world.ts +111 -10
  235. package/src/server/host/headlessRuntime.ts +10 -5
  236. package/src/server/host/installers.ts +62 -0
  237. package/src/server/host/openWorld.ts +59 -0
  238. package/src/server/host/ropeDecks.ts +2 -0
  239. package/src/server/host/standalone/cellWorld.ts +25 -19
  240. package/src/server/host/standalone/fallFloor.ts +2 -2
  241. package/src/server/host/standalone/gridServer.ts +7 -4
  242. package/src/server/host/standalone/roadWorld.ts +41 -4
  243. package/src/shared/engine/audio/bootAudio.ts +33 -0
  244. package/src/shared/engine/level/spec.ts +3 -3
  245. package/src/shared/engine/net/acts.ts +3 -0
  246. package/src/shared/engine/net/deviceWord.ts +138 -0
  247. package/src/shared/engine/net/socketFrames.ts +7 -4
  248. package/src/shared/engine/physics/query.ts +27 -0
  249. package/src/shared/engine/physics/terrain.ts +19 -28
  250. package/src/shared/engine/saves/saves.lock.json +15 -0
  251. package/src/shared/engine/sim/actRoutes.ts +2 -0
  252. package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
  253. package/src/shared/game/grid/catalogue.ts +12 -5
  254. package/src/shared/game/grid/catalogueSlot.ts +18 -0
  255. package/src/shared/game/grid/farProxy.ts +6 -5
  256. package/src/shared/game/grid/pageMode.ts +1 -1
  257. package/src/shared/game/grid/placementRows.ts +33 -0
  258. package/src/shared/game/grid/roadLayout.ts +26 -3
  259. package/src/shared/game/grid/singleplayer.json +0 -13
  260. package/src/shared/game/grid/voidFloor.ts +122 -0
  261. package/src/shared/game/strings.ts +15 -0
  262. package/src/shared/host/standalone/netInput.ts +2 -1
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ // S12 (J330): a shard's phone textures cooked from its masters by mip trim, measured against what phones read today.
3
+ // node --import ./scripts/bake-loader.mjs scripts/tier-textures.mjs out/pine-hollow [--max=512] [--out=tmp/<lane>/phone]
4
+ // Reads an opened product dir (`out/<slug>`: discovery.json's KTX2 table and mounts/), no shardfile upload, no network.
5
+ // For every row of the shard's phone table it prints three columns: today's phone file (a hand-made 6×6 / 512 set or a
6
+ // GPU twin), the desktop master trimmed to --max by `trimKtx2`/`tierGlb` (what a trim-only cook would ship), and today's
7
+ // phone file trimmed to --max. Bytes are file bytes; GPU is `ktx2GpuBytes`, mips included. --out writes the trimmed
8
+ // phone files at their URL paths, for a browser to load.
9
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
10
+ import { dirname, join, resolve } from 'node:path';
11
+
12
+ const { glbImages, isKtx2, ktx2GpuBytes, tierGlb, trimKtx2 } = await import('../src/cook/game/tierTextures.ts');
13
+
14
+ const args = process.argv.slice(2), flag = (/** @type {string} */ name) => args.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3);
15
+ const product = args.find(arg => !arg.startsWith('--'));
16
+ if (product === undefined) throw new Error('usage: tier-textures <product-dir> [--max=512] [--out=dir]');
17
+ const max = Number(flag('max') ?? 512), out = flag('out');
18
+ const slug = product.replace(/\/$/u, '').split('/').pop() ?? '';
19
+ const discovery = JSON.parse(readFileSync(join(product, 'mounts/shardfiles', slug, 'discovery.json'), 'utf8'));
20
+ /** @type {{phone: Record<string, string>, desktop: Record<string, string>}} */
21
+ const table = discovery.native.ktx2.args[0].shard;
22
+ /** @param {string} url @returns {Uint8Array | undefined} */
23
+ const read = url => { const path = join(product, 'mounts', url); return existsSync(path) ? new Uint8Array(readFileSync(path)) : undefined; };
24
+ /** @param {string} url @param {Uint8Array} bytes @returns {Uint8Array} */
25
+ const trim = (url, bytes) => (url.endsWith('.glb') ? tierGlb(bytes, max) : trimKtx2(bytes, max));
26
+ /** @param {string} url @param {Uint8Array} bytes @returns {number} */
27
+ const gpu = (url, bytes) => {
28
+ if (url.endsWith('.ktx2')) return isKtx2(bytes) ? ktx2GpuBytes(bytes) : 0;
29
+ if (url.endsWith('.glb')) return glbImages(bytes).reduce((total, image) => total + (isKtx2(image.bytes) ? ktx2GpuBytes(image.bytes) : 0), 0);
30
+ return 0;
31
+ };
32
+ /** The desktop master of a phone source: the same source, or its name without the `.phone` / `-phone` mark. */
33
+ /** @param {string} source @returns {string | undefined} */
34
+ const master = source => table.desktop[source] ?? table.desktop[source.replace(/\.phone\./u, '.')] ?? table.desktop[source.replace(/-phone\./u, '.')];
35
+
36
+ /** @type {Record<string, [number, number]>} */
37
+ const sum = { today: [0, 0], master: [0, 0], cooked: [0, 0], trimmed: [0, 0] };
38
+ let rows = 0, missing = 0, mastered = 0;
39
+ for (const [source, phoneUrl] of Object.entries(table.phone)) {
40
+ if (!/\.(?:glb|ktx2)$/u.test(phoneUrl)) continue;
41
+ const phone = read(phoneUrl);
42
+ if (phone === undefined) { missing++; continue; }
43
+ rows++;
44
+ const masterUrl = master(source), masterBytes = masterUrl === undefined ? undefined : read(masterUrl);
45
+ const cooked = masterBytes === undefined || masterUrl === undefined ? trim(phoneUrl, phone) : trim(masterUrl, masterBytes);
46
+ if (masterBytes !== undefined) mastered++;
47
+ const trimmed = trim(phoneUrl, phone);
48
+ /** @param {string} key @param {string} url @param {Uint8Array} bytes */
49
+ const add = (key, url, bytes) => { const row = sum[key] ?? [0, 0]; row[0] += bytes.length; row[1] += gpu(url, bytes); sum[key] = row; };
50
+ add('today', phoneUrl, phone);
51
+ add('master', masterUrl ?? phoneUrl, masterBytes ?? phone);
52
+ add('cooked', masterUrl ?? phoneUrl, cooked);
53
+ add('trimmed', phoneUrl, trimmed);
54
+ if (out !== undefined) { const path = resolve(out, `.${phoneUrl}`); mkdirSync(dirname(path), { recursive: true }); writeFileSync(path, trimmed); }
55
+ }
56
+ const mb = (/** @type {number} */ n) => (n / 1e6).toFixed(2);
57
+ console.log(`${slug} phone table: ${rows} KTX2/GLB rows (${mastered} with a desktop master, ${missing} not in the product), --max=${max}`);
58
+ for (const [key, label] of [['today', 'phone today'], ['master', 'desktop masters'], ['cooked', `masters trimmed to ${max}`], ['trimmed', `phone today trimmed to ${max}`]]) {
59
+ console.log(`${label.padEnd(28)} file ${mb(sum[key]?.[0] ?? 0).padStart(7)} MB GPU ${mb(sum[key]?.[1] ?? 0).padStart(7)} MB`);
60
+ }
@@ -0,0 +1 @@
1
+ export function trackedPublic(env?: NodeJS.ProcessEnv, cwd?: string): ReadonlySet<string>;
@@ -0,0 +1,17 @@
1
+ // The engine's tracked public/ files, which a pinned product's KTX2 table may name (pins.ts, S11). In a checkout git reads them
2
+ // from the work tree's index. A build-mirror slot (build-mirror.mjs) has no .git and stops git discovery at the slot on purpose,
3
+ // so `git ls-files` there failed and the set came back empty: every tracked engine KTX2 a product names looked missing, and a
4
+ // `serve-build.sh --head` build refused Driftwood (`lm-ao.phone-9f6766dc.ktx2`). The mirror names its own index, which holds
5
+ // exactly the commit it synced, and that is read instead.
6
+ import { execFileSync } from 'node:child_process';
7
+
8
+ /** @param {NodeJS.ProcessEnv} [env] @param {string} [cwd] @returns {ReadonlySet<string>} */
9
+ export function trackedPublic(env = process.env, cwd = process.cwd()) {
10
+ const { WS_MIRROR_REPO: repo, WS_MIRROR_INDEX: index } = env;
11
+ const mirror = repo !== undefined && repo !== '' && index !== undefined && index !== '';
12
+ try {
13
+ return new Set(execFileSync('git', ['ls-files', '-z', 'public'], { cwd: mirror ? repo : cwd, env: mirror ? { ...env, GIT_INDEX_FILE: index } : env, encoding: 'utf8', maxBuffer: 1 << 28, stdio: ['ignore', 'pipe', 'ignore'] }).split('\0').filter(Boolean));
14
+ } catch {
15
+ return new Set();
16
+ }
17
+ }
@@ -567,6 +567,7 @@
567
567
  "worker-client-play.mjs",
568
568
  "worker-client-proof.mjs",
569
569
  "worker-client-saves.mjs",
570
+ "worker-client-slug.mjs",
570
571
  "**/*.test.*"
571
572
  ],
572
573
  "files": [
@@ -1,12 +1,16 @@
1
1
  #!/usr/bin/python3 -I
2
2
  # MMO-SERVER-PLAN MS3.5 (J266): the agents' one way to change a game server's settings, through sudo with no password.
3
3
  # wildshard-config show <channel> print the channel's settings file
4
- # wildshard-config set <channel> <KEY> <value> [--production] write one setting, restart the channel, roll back if it
5
- # does not come up healthy
4
+ # wildshard-config set <channel> <KEY> <value> [<KEY> <value>]... [--production]
5
+ # write the settings, restart the channel once, roll back if
6
+ # it does not come up healthy
6
7
  # wildshard-config split <channel> setup.sh's: move the settings out of <channel>.env, once
7
8
  # Settings live in /etc/wildshard/<channel>.settings (640 root:wildshard-<channel>), which the units read after <channel>.env.
8
- # Secrets stay in the root-only .env, and this never reads one out or writes one: only the keys in SETTINGS below, each
9
+ # Secrets stay in the root-only .env, and this never prints one or writes one (it reads only the placement rows there, for
10
+ # the pair check below): only the keys in SETTINGS below, each
9
11
  # checked by its own rule. A production change needs --production, so no one changes the live world by a slip.
12
+ # The two placement keys (SA33, GC33) go together: the server throws at boot on one without the other, so a `set` that would
13
+ # leave the channel with one is refused before anything is written; set both in one call.
10
14
  # Installed root-owned as /usr/local/sbin/wildshard-config by harden.sh; the sudo allowlist names that path only.
11
15
  import os, re, subprocess, sys, tempfile, time, urllib.request
12
16
 
@@ -14,9 +18,20 @@ CHANNELS = {'production': {'port': 8790, 'cpus': 9, 'host': 0}, 'staging': {'por
14
18
  # The pages that open the game (engine doorTrust DEFAULT_ALLOWED_ORIGINS); each channel's own is at its 'host' index.
15
19
  GAME_HOSTS = ('https://play.wildshard.io', 'https://staging.wildshard.io', 'https://preview.wildshard.io')
16
20
  CELL = r'[a-z0-9][a-z0-9-]{0,63}'
21
+ # SA33a: the API's placement key, public half as SPKI DER hex; equal to engine scripts/preview-grid.ts PLACEMENT_PUBLIC_KEY (the
22
+ # engine's test holds them equal). Pinned, so an agent can point a channel at the API's own signed file and nothing else.
23
+ PLACEMENT_PUBLIC_KEY = '302a300506032b65700321004afd39342aac6a4de6066cb72e9df54cbd3d4eb522e5e6e175a17954ab98f25e'
24
+ PLACEMENT_PAIR = ('PLACEMENT_URL', 'PLACEMENT_PUBLIC_KEY')
25
+
26
+
27
+ def placements(channel):
28
+ """The one signed placement file a channel reads: the API writes only releases/<channel>-placements.json (SA33a)."""
29
+ return f'https://packs.wildshard.io/releases/{channel}-placements.json'
30
+
17
31
  # Each allowed key and its rule. Anything else is refused: secrets (SEAT_SECRET, SENTRY_DSN, DATABASE_URL), the trust roots
18
32
  # (RELEASE_URL, RELEASE_PUBLIC_KEY, BUNDLE_ORIGIN, PACK_ORIGIN, TELEMETRY_URL, ERRORS_URL) and exposure (HOST, PORT,
19
- # TRUST_PROXY) are root's, by hand or by a reviewed script. ALLOWED_ORIGINS may only narrow (MS3.4): a set of the game's three
33
+ # TRUST_PROXY) are root's, by hand or by a reviewed script. The placement pair is a trust root too, so each takes one
34
+ # exact value (the channel's own file, the API's pinned key) or blank, which the server reads as unset (Jake, 2026-11-13). ALLOWED_ORIGINS may only narrow (MS3.4): a set of the game's three
20
35
  # hosts that keeps the channel's own, so an agent can drop a page but never add one or lock its own players out.
21
36
  SETTINGS = {
22
37
  'WORLD_CELLS': lambda value, channel: value == 'grid' or (re.fullmatch(f'{CELL}(,{CELL}){{0,63}}', value) is not None
@@ -26,12 +41,18 @@ SETTINGS = {
26
41
  'RECORD_TAG': lambda value, channel: re.fullmatch(r'[A-Za-z0-9._-]{0,64}', value) is not None,
27
42
  'ALLOWED_ORIGINS': lambda value, channel: (set(value.split(',')) <= set(GAME_HOSTS) and len(set(value.split(','))) == len(value.split(','))
28
43
  and GAME_HOSTS[CHANNELS[channel]['host']] in value.split(',')),
44
+ 'WORLD_CROSSING': lambda value, channel: value in ('off', 'worker'),
45
+ 'PLACEMENT_URL': lambda value, channel: value in ('', placements(channel)),
46
+ 'PLACEMENT_PUBLIC_KEY': lambda value, channel: value in ('', PLACEMENT_PUBLIC_KEY),
29
47
  }
30
48
  RULES = {'WORLD_CELLS': "'grid' or comma-separated cell names (a-z, 0-9, -), none twice",
31
49
  'WORLD_WORKERS': 'a whole number from 1 to the channel\'s pinned CPUs (production 9, staging 4)',
32
50
  'WORLD_SEATS': 'a whole number from 1 to 2000', 'RECORD_TAG': 'up to 64 of A-Z a-z 0-9 . _ -',
33
51
  'ALLOWED_ORIGINS': "comma-separated, none twice, from https://play.wildshard.io, https://staging.wildshard.io and "
34
- "https://preview.wildshard.io, keeping the channel's own (production play, staging staging)"}
52
+ "https://preview.wildshard.io, keeping the channel's own (production play, staging staging)",
53
+ 'WORLD_CROSSING': 'off or worker',
54
+ 'PLACEMENT_URL': "https://packs.wildshard.io/releases/<channel>-placements.json for this channel, or blank",
55
+ 'PLACEMENT_PUBLIC_KEY': f'the API placement key {PLACEMENT_PUBLIC_KEY}, or blank'}
35
56
 
36
57
  # The engine's tests hand it a made-up /etc and no systemctl; never as root, so sudo (which drops the environment anyway) cannot.
37
58
  TEST = os.geteuid() != 0 and os.environ.get('WILDSHARD_CONFIG_TEST_ROOT')
@@ -60,6 +81,31 @@ def key_of(row):
60
81
  return match.group(1) if match else None
61
82
 
62
83
 
84
+ def plain(row):
85
+ """A row's value as systemd reads it: one pair of matching quotes stripped."""
86
+ value = row.split('=', 1)[1].strip()
87
+ if len(value) >= 2 and value[0] == value[-1] and value[0] in '"\'':
88
+ value = value[1:-1]
89
+ return value
90
+
91
+
92
+ def effective(rows, keys):
93
+ """What the server reads for these keys: the last assignment wins, as systemd reads it (spaces around the key and =)."""
94
+ seen = {}
95
+ for row in rows:
96
+ match = re.match(r'^\s*([A-Z_][A-Z0-9_]*)\s*=', row)
97
+ if match and match.group(1) in keys:
98
+ seen[match.group(1)] = plain(row[match.end() - 1:])
99
+ return seen
100
+
101
+
102
+ def pair_broken(env_rows, settings_rows):
103
+ """True when the server would start with one placement key and not the other (main.ts throws). The settings file is
104
+ read after the .env, and a blank value is unset. Only these two keys are read from the .env."""
105
+ seen = effective(env_rows + settings_rows, PLACEMENT_PAIR)
106
+ return (seen.get('PLACEMENT_URL', '') == '') != (seen.get('PLACEMENT_PUBLIC_KEY', '') == '')
107
+
108
+
63
109
  def write_rows(path, rows, channel):
64
110
  """Atomic, never through a link, 640 root:wildshard-<channel>."""
65
111
  folder = os.path.dirname(path)
@@ -121,7 +167,7 @@ def main(argv):
121
167
  production = '--production' in argv
122
168
  args = [arg for arg in argv if arg != '--production']
123
169
  if not args or args[0] not in ('show', 'set', 'split'):
124
- stop('usage: wildshard-config show <channel> | set <channel> <KEY> <value> [--production] | split <channel>')
170
+ stop('usage: wildshard-config show <channel> | set <channel> <KEY> <value> [<KEY> <value>]... [--production] | split <channel>')
125
171
  verb = args[0]
126
172
  if len(args) < 2 or args[1] not in CHANNELS:
127
173
  stop('the channel is production or staging')
@@ -148,11 +194,6 @@ def main(argv):
148
194
  stop('usage: wildshard-config split <channel>')
149
195
  env_rows = read_rows(env_path)
150
196
  # systemd strips one pair of matching quotes; a value that still fails its rule stays in the .env, never dropped.
151
- def plain(row):
152
- value = row.split('=', 1)[1].strip()
153
- if len(value) >= 2 and value[0] == value[-1] and value[0] in '"\'':
154
- value = value[1:-1]
155
- return value
156
197
  # The last assignment of a key is the one systemd uses; a key moves only if that one passes its rule, and then all of
157
198
  # its rows move, so the precedence never changes (Codex J206).
158
199
  last = {key_of(row): row for row in env_rows if key_of(row) in SETTINGS}
@@ -170,30 +211,45 @@ def main(argv):
170
211
  print(f'doing move {", ".join(sorted(keys))} from {channel}.env to {channel}.settings')
171
212
  return 0
172
213
 
173
- if len(args) != 4:
174
- stop('usage: wildshard-config set <channel> <KEY> <value> [--production]')
175
- key, value = args[2], args[3]
176
- if key not in SETTINGS:
177
- stop(f'{key} is not a setting an agent may change; allowed: {", ".join(SETTINGS)}')
178
- if not SETTINGS[key](value, channel):
179
- stop(f'{key} must be {RULES[key]}')
214
+ if len(args) < 4 or len(args) % 2 != 0:
215
+ stop('usage: wildshard-config set <channel> <KEY> <value> [<KEY> <value>]... [--production]')
216
+ pairs = list(zip(args[2::2], args[3::2]))
217
+ keys = [key for key, _ in pairs]
218
+ if len(set(keys)) != len(keys):
219
+ stop('each key once per set')
220
+ for key, value in pairs:
221
+ if key not in SETTINGS:
222
+ stop(f'{key} is not a setting an agent may change; allowed: {", ".join(SETTINGS)}')
223
+ if not SETTINGS[key](value, channel):
224
+ stop(f'{key} must be {RULES[key]}')
180
225
  if channel == 'production' and not production:
181
226
  stop('a production change needs --production')
182
227
  before = read_rows(settings_path)
183
228
  rows = list(before) or list(HEADER)
184
- rows = [row for row in rows if key_of(row) != key] + [f'{key}={value}']
229
+ rows = [row for row in rows if key_of(row) not in keys] + [f'{key}={value}' for key, value in pairs]
230
+ change = ' '.join(f'{key}={value}' for key, value in pairs)
185
231
  if rows == before:
186
- print(f'ok {channel} {key} is already {value}')
232
+ print(f'ok {channel} already has {change}')
187
233
  return 0
234
+ # Checked against what the server would read, the .env included, so no restart can boot into main.ts's throw.
235
+ env_rows = read_rows(env_path)
236
+ if pair_broken(env_rows, rows):
237
+ if pair_broken(env_rows, before):
238
+ stop(f'{channel} already holds only one of PLACEMENT_URL and PLACEMENT_PUBLIC_KEY (in its .env or .settings), so '
239
+ 'its server cannot start; set both in one call, both set or both blank')
240
+ stop('PLACEMENT_URL and PLACEMENT_PUBLIC_KEY go together: set both in one call, both set or both blank')
241
+ placing = effective(env_rows + rows, PLACEMENT_PAIR + ('WORLD_CELLS',))
242
+ if any(key in PLACEMENT_PAIR for key in keys) and placing.get('PLACEMENT_URL', '') != '' and placing.get('WORLD_CELLS', '').strip() != 'grid':
243
+ print(f'note {channel} WORLD_CELLS is not grid, so the server reads no placement file (main.ts)')
188
244
  was_running = running(channel)
189
245
  write_rows(settings_path, rows, channel)
190
- print(f'doing {channel} {key}={value}')
246
+ print(f'doing {channel} {change}')
191
247
  if not was_running:
192
248
  # A channel still waiting for its first release keeps its health stub; the setting takes effect when it starts.
193
- print(f'skip wildshard-server@{channel} is not running; {key}={value} takes effect when it starts')
249
+ print(f'skip wildshard-server@{channel} is not running; {change} takes effect when it starts')
194
250
  return 0
195
251
  if restart(channel):
196
- print(f'ok {channel} is healthy with {key}={value}')
252
+ print(f'ok {channel} is healthy with {change}')
197
253
  return 0
198
254
  # It did not come back: put the old file back and start the old settings, so a bad value never leaves a channel down.
199
255
  if before:
@@ -116,6 +116,7 @@ export async function play(browser, phone, base, only = '') {
116
116
  if (runs('hurt')) { const { hurt } = await import('./worker-client-hurt.mjs'); await hurt(browser, phone, base, step); }
117
117
  if (runs('windup')) { const { windup } = await import('./worker-client-windup.mjs'); await windup(browser, phone, base, step); }
118
118
  if (runs('grid-entry')) { const { gridEntry } = await import('./worker-client-grid-entry.mjs'); await gridEntry(browser, phone, base, step); }
119
+ if (runs('slug')) { const { slugEntry } = await import('./worker-client-slug.mjs'); await slugEntry(browser, phone, base, step, process.argv.find(value => value.startsWith('--slug='))?.slice(7)); }
119
120
  if (runs('recovery-menu')) { const { recoveryMenu } = await import('./worker-client-grid-entry.mjs'); await recoveryMenu(browser, phone, base, step); }
120
121
  if (runs('death-order')) { const { deathOrder } = await import('./worker-client-death-return.mjs'); await deathOrder(browser, phone, base, step); }
121
122
  if (runs('death')) { const { driftwoodDeath } = await import('./worker-client-death.mjs'); await driftwoodDeath(browser, phone, base, step); }
@@ -4,7 +4,7 @@
4
4
  // Then it reloads on the cache that walk left (Chromium refuses a whole-cache query that size), and with the link cut. --chunk= proves a one-shard page.
5
5
  // --play is the flip's checklist: one playthrough on the row, a line for every step, and it fails on any step that didn't work.
6
6
  // --hook on a chunk with a grapple proves the claw: LOCK and JUMP pressed on the page, and the server's bite and zip carrying the body.
7
- // scripts/browser-lane.sh node scripts/worker-client-proof.mjs --base=http://127.0.0.1:4401/ [--seconds=150] [--crossings=2] [--route=x,z;x,z] [--chunk=slug] [--play [--only=movers|sky-trails|data-shard|driftwood|nalati|riding|nine|shards|grid|fights|roc|rocfall|rooms|elite|sky|sunscar|farreach|isle|pine|lantern|rig|sweep]] [--hook]
7
+ // scripts/browser-lane.sh node scripts/worker-client-proof.mjs --base=http://127.0.0.1:4401/ [--seconds=150] [--crossings=2] [--route=x,z;x,z] [--chunk=slug] [--play [--only=slug [--slug=<slug>]|movers|sky-trails|data-shard|driftwood|nalati|riding|nine|shards|grid|fights|roc|rocfall|rooms|elite|sky|sunscar|farreach|isle|pine|lantern|rig|sweep]] [--hook]
8
8
  import { chromium, webkit, devices } from 'playwright';
9
9
  import { saveFixture } from './debug-settings.mjs';
10
10
  import { floorGridBenchmarkUrl, FLOOR_GRID_ENTER } from './frame-floor-navigation.mjs';
@@ -0,0 +1,44 @@
1
+ // SA37 (meta SHARD-AUTHORING-PLAN): the `/slug/<slug>` link an author shares, on a world build. The page is the shard's one card;
2
+ // its PLAY leaves for `/?chunk=<slug>`, and that page enters the world's grid at the shard's cell, as a Shard select tap does.
3
+ // Passes when the server seats the body in that cell, the page stands inside it and plays, with no page error.
4
+ // scripts/browser-lane.sh node scripts/worker-client-proof.mjs --base=<a world build> --play --only=slug [--slug=driftwood-isle]
5
+ /** @typedef {import('./types/worker-page').WorkerWindow} WorkerWindow */
6
+ import { saveFixture } from './debug-settings.mjs';
7
+ import { entered, settled } from './worker-client-grid-entry.mjs';
8
+
9
+ /** @param {import('playwright').Browser} browser @param {import('playwright').BrowserContextOptions} phone @param {string} base
10
+ * @param {import('./types/worker-page').ProofStep} step @param {string} [slug] */
11
+ export async function slugEntry(browser, phone, base, step, slug = 'driftwood-isle') {
12
+ const context = await browser.newContext(phone), page = await context.newPage(), errors = /** @type {string[]} */ ([]);
13
+ page.on('pageerror', error => { errors.push(error.message.slice(0, 300)); });
14
+ await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
15
+ try {
16
+ await step(`slug: /slug/${slug} shows the shard's one card with PLAY`, async () => {
17
+ await page.goto(new URL(`/slug/${slug}?mute=1&nolock=1`, base).href, { waitUntil: 'load' });
18
+ const play = page.locator('.ws-slug .ws-menu-play');
19
+ await play.waitFor({ timeout: 60_000 });
20
+ const card = await page.evaluate(() => {
21
+ const root = /** @type {HTMLElement | null} */ (document.querySelector('.ws-slug'));
22
+ return { slug: root?.dataset.slug, placed: root?.dataset.placed,
23
+ name: document.querySelector('.ws-slug .ws-menu-card b')?.textContent, play: document.querySelector('.ws-slug .ws-menu-play b')?.textContent, path: location.pathname };
24
+ });
25
+ return { ok: card.slug === slug && card.placed === 'true' && card.play === 'Play', ...card };
26
+ });
27
+ await step(`slug: PLAY enters the world's grid at ${slug}'s cell`, async () => {
28
+ await Promise.all([page.waitForEvent('domcontentloaded', { timeout: 60_000 }).catch(() => undefined), (async () => {
29
+ await page.locator('.ws-slug .ws-menu-play').click();
30
+ // a device's first PLAY asks for the Name once (MP2.4)
31
+ const name = page.locator('#ws-name-box input');
32
+ if (await name.waitFor({ timeout: 5000 }).then(() => true, () => false)) {
33
+ await name.fill('Slug');
34
+ await page.locator('#ws-name-box button[type=submit]').click();
35
+ }
36
+ })()]);
37
+ await entered(page);
38
+ const out = await settled(page, slug);
39
+ const url = new URL(page.url());
40
+ // the grid page keeps `/` once it is in (its address is the grid, not the shard), so the cell is read from the server's seat
41
+ return { ok: out.server === slug && out.current === slug && out.inside === slug && out.ready === true && !url.pathname.startsWith('/slug/') && errors.length === 0, path: url.pathname, server: out.server, inside: out.inside, home: out.home, ready: out.ready, frames: out.frames, closed: out.closed, errors: errors.slice(0, 4) };
42
+ });
43
+ } finally { await context.close(); }
44
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ // The npm bin. Node refuses to strip types under node_modules, so an installed engine could not run main.ts itself.
3
+ // The format hook strips our own @wildshard packages' .ts there (J82). main.ts is a dynamic import: a static one
4
+ // would link its whole graph before the hook registers.
5
+ // oxlint-disable-next-line import/no-unassigned-import -- the hook must register before main.ts loads (J82)
6
+ import '../../scripts/format-hook.mjs'
7
+
8
+ await import('./main.ts')
@@ -22,6 +22,9 @@ export function bootRoute(search: URLSearchParams, previous: { readonly line: st
22
22
  * already skips the title asks for it. A reopened tab, a bookmark or a crashed session lands on the title, and nothing joins.
23
23
  */
24
24
  export function onlineTitleFirst(search: URLSearchParams, online: boolean, tapped: boolean): boolean {
25
- if (!online || tapped || search.has('skipintro') || search.has('tour')) return false;
25
+ // ?glreload is the engine's own reload back into the world (GPU recovery, RELOAD HERE, the reload prompt; play.ts strips it once
26
+ // read, so a reopened tab has none): QA-FEEDBACK-2026-11-13 rows 6 and 13 (WILDSHARD-GAME-8H), a GPU process restart on an
27
+ // Android phone sent the player to the title instead
28
+ if (!online || tapped || search.has('skipintro') || search.has('tour') || search.has('glreload')) return false;
26
29
  return !bootRoute(search, { line: '', level: '' }).titleOnly;
27
30
  }
@@ -6,6 +6,17 @@
6
6
  import type { Scope } from '@wildshard/engine/app/scope';
7
7
  import type { Drop } from '@wildshard/engine/boot/dropNotice';
8
8
  import { mountUi } from '@wildshard/engine/ui/ownership';
9
+ import { captureBrowserError } from '@wildshard/engine/telemetry/browserErrors';
10
+
11
+ /** SENTRY-TRIAGE S13: the drop modal's one Sentry event (`screen:title-drop`), durable through the screen outbox */
12
+ export function reportDrop(drop: Drop, report: typeof captureBrowserError = captureBrowserError): void {
13
+ try {
14
+ const error = new Error(`${drop.what}: ${drop.reason}`);
15
+ if (drop.stack !== '') error.stack = drop.stack;
16
+ report(error, { system: 'title-drop', build: drop.build, shard: drop.world, bootStage: drop.step, fatal: true, screen: 'title-drop',
17
+ diagnostic: { kind: drop.kind, message: drop.message, code: drop.code, end: drop.end, trail: drop.trail, route: drop.routeStack.slice(0, 1500) } });
18
+ } catch { /* telemetry never stops the modal */ }
19
+ }
9
20
 
10
21
  const STYLE = `
11
22
  #wsdrop { position: fixed; inset: 0; z-index: var(--ws-layer-error, 2147482500); display: flex; align-items: center; justify-content: center; box-sizing: border-box; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(4, 9, 14, 0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #e6f2f8; font: 12px/1.5 "JetBrains Mono", ui-monospace, Menlo, monospace; }
@@ -48,8 +59,10 @@ function make<K extends keyof HTMLElementTagNameMap>(tag: K, className: string,
48
59
  return el;
49
60
  }
50
61
 
51
- /** Show the drop over the title. `dev`: the real error too. Returns the close. */
52
- export function showDropModal(drop: Drop, scope: Scope, options: { readonly dev: boolean; readonly extra?: readonly string[]; readonly parent?: HTMLElement }): () => void {
62
+ /** Show the drop over the title and report it (S13). `dev`: the real error too. `report`: a test's own. Returns the close. */
63
+ export function showDropModal(drop: Drop, scope: Scope, options: { readonly dev: boolean; readonly extra?: readonly string[]; readonly parent?: HTMLElement;
64
+ readonly report?: typeof captureBrowserError }): () => void {
65
+ reportDrop(drop, options.report);
53
66
  if (document.getElementById('wsdrop-style') === null) {
54
67
  const style = make('style', ''); style.id = 'wsdrop-style'; style.textContent = STYLE; document.head.append(style);
55
68
  }
@@ -37,6 +37,7 @@ import { lastEnd } from '@wildshard/engine/boot/lastEnd';
37
37
  import { installDropNotes, markDropStep, recordDrop, takeDrop } from '@wildshard/engine/boot/dropNotice';
38
38
  import { consumeCrashResume, type CrashResume } from '@wildshard/engine/game/session/crashResume';
39
39
  import { bootAwait, bootMark, bootTask, bootTiming, endBootOperation } from '@wildshard/engine/boot/timing';
40
+ import { slugOfPath } from './slugPath';
40
41
 
41
42
 
42
43
  declare const __BUILD_ID__: string;
@@ -52,6 +53,9 @@ const entryScope = new Scope('entry');
52
53
  let crashResume: CrashResume | null = null;
53
54
  let selectedImages: Scope | undefined;
54
55
  const task = (): Promise<void> => new Promise((resolve) => { entryScope.timeout(0, resolve); });
56
+ const UNLISTED = 'This world is not listed. Choose a world from the list.';
57
+ /** How long the boot waits for the placement file (`placedCells.ts`'s own deadline, GO4's 3 s), its chunk's import included. */
58
+ const PLACED_DEADLINE_MS = 3000;
55
59
  /** The plain home URL paints only the title. No renderer, world, or Three.js is imported until a shard is chosen. */
56
60
  // RL3: the static module graph has arrived and run; index.html's 12 s self-reload stands down (only a hung module
57
61
  // fetch, which never gets here, reloads by itself; anything after this is guardBoot's)
@@ -63,6 +67,9 @@ installDropNotes();
63
67
  installInlineCatalogue(document);
64
68
  const titleRows = withCatalogueHeads(readTitleRows(document));
65
69
  installTitleManifests(titleRows);
70
+ // SA33 to SA35, the page half: a released page adds the cells the API placed after its build (its channel's signed placement file) to the
71
+ // catalogue before anything reads the grid; `enterPage` waits for it (3 s at most), and any failure keeps the build's grid.
72
+ const placedCells = learnPlacedCellsOnce();
66
73
  // G727 / I9: Settings' "Download everything"; the prefetch loads only when the player opens or presses it
67
74
  installOfflineDownload({
68
75
  size: async owner => (await import('@wildshard/engine/game/grid/prefetch')).remainingDownloadBytes(owner),
@@ -96,13 +103,36 @@ function serverSites(): Promise<readonly { readonly site: string | null | undefi
96
103
  const late = new Promise<undefined>(resolve => { entryScope.timeout(SERVER_SITES_MS, () => { resolve(undefined); }); });
97
104
  return Promise.race([read, late]).catch(() => undefined);
98
105
  }
106
+ /** The page's placement file read, started at once; it never rejects and settles inside `PLACED_DEADLINE_MS` (3 s) of the entry's
107
+ * start, chunk import included. Past that the boot goes on with the build's grid and a late answer installs nothing. A page with no
108
+ * world (preview, solo) reads none. */
109
+ function learnPlacedCellsOnce(): Promise<void> {
110
+ const late = new AbortController();
111
+ const read = (async (): Promise<void> => {
112
+ try {
113
+ const { learnPlacedCells, placementsOf } = await import('@wildshard/engine/game/grid/placedCells');
114
+ const url = placementsOf(globalThis as { __WS_WORLD__?: unknown; __WS_PLACEMENTS__?: unknown });
115
+ if (url === null || late.signal.aborted) return;
116
+ const answer = await bootTask('app:placed-cells', () => learnPlacedCells(url, { signal: late.signal }));
117
+ if ('kept' in answer) console.info(`[grid] build's grid kept: ${answer.kept}`);
118
+ else console.info(`[grid] placement serial ${String(answer.serial)}: ${answer.added.map(cell => `${cell.instance} at (${cell.cell.join(',')})`).join(', ') || 'no new cell'}${answer.carded.length === 0 ? '' : `; carded from the catalogue ${answer.carded.join(', ')}`}${answer.left.length === 0 ? '' : `; left out ${answer.left.join('; ')}`}`);
119
+ } catch (error) { console.warn('[grid] placement file not read:', error); }
120
+ })();
121
+ const deadline = new Promise<void>(resolve => { entryScope.timeout(PLACED_DEADLINE_MS, () => { late.abort(); resolve(); }); });
122
+ return Promise.race([read, deadline]);
123
+ }
99
124
  async function enterPage(): Promise<unknown> {
125
+ await placedCells;
100
126
  const requested = search.get('chunk');
127
+ // SA36: a `/slug/<slug>` link opens that one shard's page; its PLAY leaves for `/?chunk=<slug>`, so a world never boots here.
128
+ // SA37: on every host, a world build too: PLAY's `/?chunk=` page enters the world's grid at the shard's cell (GO7 below)
129
+ const slugged = slugOfPath(location.pathname);
130
+ if (slugged !== null && requested === null) return showSlugPage(slugged);
101
131
  // An embedded author product has its own admission. A game URL must name a
102
132
  // listed world before any discovery, tables or renderer can be prepared.
103
133
  if (requested !== null && document.getElementById('ws-shardfile') === null && findTitleManifest(requested) === undefined) {
104
134
  document.documentElement.classList.add('title-first');
105
- return showPageTitle('This world is not listed. Choose a world from the list.');
135
+ return showPageTitle(UNLISTED);
106
136
  }
107
137
  await waitFor('Startup stylesheets', waitForLoadingStyles(entryScope), 'file');
108
138
  const { consumeGridRecovery, gridRecoveryRefused, pageGridRecovery, pendingGridEntry } = await bootTask('app:page-entry-import', () => import('@wildshard/engine/game/grid/pageEntry'));
@@ -118,6 +148,21 @@ async function enterPage(): Promise<unknown> {
118
148
  document.documentElement.classList.add('title-first');
119
149
  return showPageTitle();
120
150
  }
151
+ // OFFLINE OF3 (J298): a world build never enters a shard its world doesn't open (the grid doesn't place it, or the world's word leaves
152
+ // it out: the one heard on this page, else the device's kept one). The world would seat the page in another cell, so a link to it, a
153
+ // tap or a harness URL lands on the title with "Not in this world yet". Asked before the title-first rule, so a bare link says why too.
154
+ const world = (globalThis as { __WS_WORLD__?: unknown }).__WS_WORLD__;
155
+ const notInWorld = async (): Promise<boolean> => online && requested !== null && document.getElementById('ws-shardfile') === null
156
+ && !(await bootTask('app:one-way-in-import', () => import('@wildshard/engine/game/grid/oneWayIn'))).worldOpens(world)(requested);
157
+ const notInWorldTitle = async (slug: string): Promise<void> => {
158
+ consumeTitleArrival(slug);
159
+ history.replaceState(history.state, '', new URL('/', location.origin));
160
+ document.documentElement.classList.add('title-first');
161
+ const { dropGridEntry, notInWorldLine } = await import('@wildshard/engine/game/grid/oneWayIn');
162
+ dropGridEntry(slug);
163
+ return showPageTitle(notInWorldLine(findTitleManifest(slug)?.name ?? slug));
164
+ };
165
+ if (requested !== null && await notInWorld()) return notInWorldTitle(requested);
121
166
  const tapped = requested !== null && (pendingTitleArrival(requested) !== null || pendingGridEntry(requested));
122
167
  if (document.getElementById('ws-shardfile') === null && onlineTitleFirst(search, online, tapped)) {
123
168
  history.replaceState(history.state, '', new URL('/', location.origin));
@@ -130,7 +175,9 @@ async function enterPage(): Promise<unknown> {
130
175
  // a harness URL still opens the shard alone.
131
176
  if ((online || pendingTitleArrival(requested ?? '') !== null) && requested !== null && document.getElementById('ws-shardfile') === null) {
132
177
  const { enterByShard } = await bootTask('app:one-way-in-import', () => import('@wildshard/engine/game/grid/oneWayIn'));
133
- await bootTask('app:one-way-in', () => enterByShard({ online, slug: requested, kept: search.has('explore') || pendingGridEntry(requested) }, (globalThis as { __WS_WORLD__?: unknown }).__WS_WORLD__));
178
+ await bootTask('app:one-way-in', () => enterByShard({ online, slug: requested, kept: search.has('explore') || pendingGridEntry(requested) }, world));
179
+ // OF3 again: the one way in may have heard the world's word just now, and it may leave this shard out
180
+ if (await notInWorld()) return notInWorldTitle(requested);
134
181
  }
135
182
  const end = lastEnd();
136
183
  const named = search.get('chunk');
@@ -173,7 +220,10 @@ async function enterPage(): Promise<unknown> {
173
220
  import('@wildshard/engine/game/grid/menu'), import('@wildshard/engine/game/boot/spawnDownload')]));
174
221
  await tier.initializeTier();
175
222
  const slug = search.get('chunk');
176
- if (typeof slug === 'string') {
223
+ // SA43: a page that owns its inline shard (`wildshard dev`, `wildshard prepare` at `?chunk=`) has no catalogue download
224
+ // for it: that shard's spawn set isn't its download (as startSelected's `authored`)
225
+ const inlineShard = (menu.DEVSERVER || menu.PREPARATION_ONLY) && document.getElementById('ws-shardfile') !== null;
226
+ if (typeof slug === 'string' && !inlineShard) {
177
227
  const mode = menu.gridMode(menu.DEVSERVER), flow = pageGridRecovery() !== null || pendingGridEntry(slug) ? 'grid' : 'client';
178
228
  spawn.setSpawnPacks(runtimePacksOn());
179
229
  // LD2 (J208): a Start read this download holds (selected discovery behind the warm check) is named from the tap
@@ -217,6 +267,41 @@ async function showPageTitle(refusal = ''): Promise<void> {
217
267
  void startTitleWarmup(import('@wildshard/engine/boot/earlyPrograms'), entryScope, window);
218
268
  }
219
269
 
270
+ /**
271
+ * SA36 (Jake, grill Q14 to Q16): the `/slug/<slug>` page, one shard's card and hero (src/client/game/slugPage.ts). PLAY travels to
272
+ * `/?chunk=<slug>` as a Shard select tap does, so that page enters the grid at the shard's cell (grid/oneWayIn.ts); a shard the
273
+ * grid doesn't place keeps PLAY disabled. A slug no title row names goes to the title with the unlisted line.
274
+ */
275
+ async function showSlugPage(slug: string): Promise<void> {
276
+ document.documentElement.classList.add('title-first');
277
+ const manifest = findTitleManifest(slug);
278
+ // the page's query (`?sw=0`, `?tier=`, …) rides along to `/`, as a Shard select tap keeps it
279
+ const home = (): URL => new URL(`/${location.search}`, location.origin);
280
+ if (manifest === undefined) {
281
+ history.replaceState(history.state, '', home());
282
+ return showPageTitle(UNLISTED);
283
+ }
284
+ const [{ showStartTitle }, { buildSlugPage }, { installGridTitle }, { shardCell }, { travel }] = await Promise.all([
285
+ import('@wildshard/engine/ui/StartTitle'), import('@wildshard/engine/game/slugPage'), import('@wildshard/engine/game/mainMenu'),
286
+ import('@wildshard/engine/game/grid/oneWayIn'), import('@wildshard/engine/game/travel/travel')]);
287
+ const grid = installGridTitle();
288
+ const placed = shardCell(manifest.slug) !== undefined;
289
+ const leave = (mode: 'enter' | 'explore') => (card: { readonly slug: string }): void => {
290
+ // the shard's page is `/?chunk=`: travel keeps this document's path, so the link's path goes first
291
+ history.replaceState(history.state, '', home());
292
+ travel({ to: card.slug, mode });
293
+ };
294
+ showStartTitle(({ settings, notice }) => {
295
+ const lines = [notice ?? '', grid.note].filter((line) => line !== '').join('\n');
296
+ return buildSlugPage({ manifest, placed, onEnter: leave('enter'), onExplore: leave('explore'),
297
+ onSettings: () => { void (async () => { const { openTitleSettings } = await import('./titleSettings'); await openTitleSettings(settings); })(); },
298
+ ...(lines === '' ? {} : { notice: lines }) });
299
+ });
300
+ showDropOnTitle();
301
+ startTitleLowPowerProbe();
302
+ void startTitleWarmup(import('@wildshard/engine/boot/earlyPrograms'), entryScope, window);
303
+ }
304
+
220
305
  /**
221
306
  * The drop modal (Jake, 2026-11-12): a title the player did not ask for says why, once. Plain words for everyone, the real error
222
307
  * with Developer on; every drop also goes to Sentry where the page reports there (src/client/engine/boot/dropNotice.ts).
@@ -227,13 +312,8 @@ function showDrop(drop: ReturnType<typeof takeDrop>): void {
227
312
  void (async () => {
228
313
  const [{ showDropModal }, { isDev }] = await Promise.all([import('./dropModal'), import('@wildshard/engine/core/devMode')]);
229
314
  const abrupt = previousBootLine();
315
+ // Jake (17:52): every title nobody asked for is an error, so the modal's open reports it (SENTRY-TRIAGE S13, `screen:title-drop`)
230
316
  showDropModal(drop, entryScope, { dev: isDev(), ...(abrupt === '' ? {} : { extra: [abrupt] }) });
231
- // Jake (17:52): every title nobody asked for is an error, so every drop goes to Sentry
232
- const { captureBrowserError } = await import('@wildshard/engine/telemetry/browserErrors');
233
- const error = new Error(`${drop.what}: ${drop.reason}`);
234
- if (drop.stack !== '') error.stack = drop.stack;
235
- captureBrowserError(error, { system: 'title-drop', build: drop.build, shard: drop.world, bootStage: drop.step, fatal: true,
236
- diagnostic: { kind: drop.kind, message: drop.message, code: drop.code, end: drop.end, trail: drop.trail, route: drop.routeStack.slice(0, 1500) } });
237
317
  })().catch(() => undefined);
238
318
  }
239
319
 
@@ -294,7 +374,7 @@ async function startSelected(): Promise<void> {
294
374
  const moduleRows: unknown = moduleText === undefined ? undefined : JSON.parse(moduleText);
295
375
  const gridEntryModule = import('@wildshard/engine/game/grid/pageEntry');
296
376
  const gridMenuModule = import('@wildshard/engine/game/grid/menu');
297
- const [gridSelection, { gridMode, DEVSERVER }] = await Promise.all([gridEntryModule, gridMenuModule]);
377
+ const [gridSelection, { gridMode, DEVSERVER, PREPARATION_ONLY }] = await Promise.all([gridEntryModule, gridMenuModule]);
298
378
  const earlyPath = gridSelection.pageGridRecovery() !== null || gridSelection.pendingGridEntry(arrival.slug)
299
379
  ? 'grid' : 'shardfile';
300
380
  // MF4: one spawn manifest per shard / tier / flow (grid: per menu mode) is the whole download; the bar reads only it and
@@ -304,7 +384,10 @@ async function startSelected(): Promise<void> {
304
384
  setSpawnPacks(runtimePacksOn()); // DL16: Debug ▸ Loading & memory ▸ Level download
305
385
  // DL21: a read the whole-set hold stalls is named on the card as the spawn download, in its step
306
386
  observeSpawnHolds((held, path) => waitFor('Spawn download', held, 'file', `spawn-download:${path}`));
307
- const spawnMode = gridMode(DEVSERVER), spawnJob = startSpawnDownload(arrival.slug, earlyPath === 'grid' ? 'grid' : 'client', TIER,
387
+ // SA15: `wildshard dev`'s page carries the author's shard inline; the catalogue shard's spawn set isn't its download.
388
+ // SA43: so does `wildshard prepare`'s, a preparation-only production build; only those two builds own an inline shard
389
+ const inlineOwner = DEVSERVER || PREPARATION_ONLY, authored = inlineOwner && document.getElementById('ws-shardfile') !== null;
390
+ const spawnMode = gridMode(DEVSERVER), spawnJob = authored ? null : startSpawnDownload(arrival.slug, earlyPath === 'grid' ? 'grid' : 'client', TIER,
308
391
  `${Number(spawnMode.developer)}${Number(spawnMode.devserver)}${Number(spawnMode.nineDragon)}`);
309
392
  if (spawnJob !== null) void loading.setDownloadSource(spawnJob);
310
393
  // Read mandatory primary declarations while services and the yielding memory
@@ -357,7 +440,7 @@ async function startSelected(): Promise<void> {
357
440
  try {
358
441
  imports.check();
359
442
  loading.setPrefetchSource(gridPrefetchStatus);
360
- const source = pageGridRecovery() === null ? await bootTask('app:product-source-and-read', () => configuredShardfile(document, browserShardfileOptions(document.baseURI))) : null;
443
+ const source = pageGridRecovery() === null ? await bootTask('app:product-source-and-read', () => configuredShardfile(document, browserShardfileOptions(document.baseURI, inlineOwner))) : null;
361
444
  page = preparePageResidency(arrival, source?.identity.slug);
362
445
  // The script memory bank, sized by route: each reserve can cost JSC a full GC (e472f34069), so a grid page reserves
363
446
  // the full-ALL route's demand for its cell activations in play, and a standalone page, which builds its one world under
@@ -397,7 +480,7 @@ async function startSelected(): Promise<void> {
397
480
  if (spawnJob !== null) await waitFor('Spawn download', spawnJob.listed ?? spawnJob.ready, 'file');
398
481
  const manifest = await bootAwait('app:product-admission', source === null
399
482
  ? installManifestShardfile(arrival, { ...browserShardfileOptions(document.baseURI, true), memory: page.memory, progress: (progress) => { loading.paintAdmission(progress); } }, bindings, imports.ready)
400
- : installShardfileProduct(source, { ...browserShardfileOptions(document.baseURI), memory: page.memory, progress: (progress) => { loading.paintAdmission(progress); } }, bindings, imports.ready));
483
+ : installShardfileProduct(source, { ...browserShardfileOptions(document.baseURI, inlineOwner), memory: page.memory, progress: (progress) => { loading.paintAdmission(progress); } }, bindings, imports.ready));
401
484
  // Keep the seam out of code and descriptor admission; world construction
402
485
  // can overlap this read and retains its original full-geometry barrier.
403
486
  if (page.mode === 'grid') gridSelection.startGridEntryContent(page.instance ?? pageGridRecovery()?.instance ?? gridSelection.gridHome().instance);
@@ -0,0 +1,5 @@
1
+ /** SA36: the slug a `/slug/<slug>` path names (src/client/game/slugPage.ts is its page), or null for any other path. A leaf, so
2
+ * the entry reads it before anything loads; pages/worker.ts serves the page for the same paths. */
3
+ export function slugOfPath(pathname: string): string | null {
4
+ return /^\/slug\/([\w-]+)\/?$/u.exec(pathname)?.[1] ?? null;
5
+ }