@wildshard/engine 0.1.18 → 0.1.19

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 (293) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +14 -0
  5. package/lint/ratchet.json +0 -68
  6. package/lint/ratchet.mjs +1 -4
  7. package/package.json +17 -15
  8. package/scripts/agent-sync.mjs +27 -8
  9. package/scripts/app-build/appCook.ts +8 -2
  10. package/scripts/app-build/catalogue.ts +10 -7
  11. package/scripts/app-build/gen.ts +22 -2
  12. package/scripts/app-build/isolation.d.mts +10 -0
  13. package/scripts/app-build/isolation.mjs +47 -0
  14. package/scripts/app-build/outputProducts.mjs +4 -0
  15. package/scripts/app-build/previousDeploy.d.mts +2 -0
  16. package/scripts/app-build/previousDeploy.mjs +10 -1
  17. package/scripts/app-build/serviceWorker.ts +10 -3
  18. package/scripts/app-build/splitOutput.mjs +4 -2
  19. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  20. package/scripts/app-build/standaloneOutput.mjs +5 -3
  21. package/scripts/app-build/titlePreloads.d.mts +8 -0
  22. package/scripts/app-build/titlePreloads.mjs +69 -0
  23. package/scripts/app-build/worldMapAtlas.ts +10 -6
  24. package/scripts/app-build-pipeline.mjs +31 -3
  25. package/scripts/built-product.mjs +1 -1
  26. package/scripts/cell-mem-bench.mjs +81 -23
  27. package/scripts/check-custom-sections-zero.mjs +1 -1
  28. package/scripts/check-devserver.mjs +2 -0
  29. package/scripts/check-models.mjs +2 -0
  30. package/scripts/check-paths.allow.json +0 -115
  31. package/scripts/check-paths.mjs +2 -2
  32. package/scripts/check-platform-ratchets.mjs +2 -3
  33. package/scripts/chromium-keychain.d.mts +1 -1
  34. package/scripts/ci-static.sh +1 -1
  35. package/scripts/committed-fast-checks.mjs +0 -2
  36. package/scripts/content-sw-proof.mjs +2 -1
  37. package/scripts/cook-worker.mjs +9 -3
  38. package/scripts/cook.mjs +18 -5
  39. package/scripts/docs-inputs-proof.mjs +6 -6
  40. package/scripts/e7-voice-staging-proof.mjs +1 -1
  41. package/scripts/gate-related-tests.mjs +1 -1
  42. package/scripts/git-source-view.mjs +1 -1
  43. package/scripts/goldens/capture.mjs +17 -5
  44. package/scripts/grid-crossing-nightly.mjs +59 -0
  45. package/scripts/grid-crossing-qa.mjs +44 -0
  46. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  47. package/scripts/grid-crossing-ratchet.mjs +52 -0
  48. package/scripts/grid-crossing-report.mjs +122 -0
  49. package/scripts/grid-crossing-stages.mjs +47 -0
  50. package/scripts/grid-crossing-tour.mjs +277 -0
  51. package/scripts/grid-crossing-walk-proof.mjs +124 -17
  52. package/scripts/host-ruler/roots.mjs +2 -2
  53. package/scripts/host-ruler.d.mts +91 -0
  54. package/scripts/host-ruler.mjs +565 -0
  55. package/scripts/live-prepush.py +3 -5
  56. package/scripts/loading-flow/benchmax.mjs +3 -1
  57. package/scripts/look-loop/test_look_loop.py +1 -38
  58. package/scripts/memory-proof.mjs +61 -6
  59. package/scripts/mmo-bots.mjs +8 -2
  60. package/scripts/net-lag-proof.mjs +219 -0
  61. package/scripts/night-market-kit-budget.mjs +2 -2
  62. package/scripts/offline-proof-rules.d.mts +2 -2
  63. package/scripts/offline-proof-rules.mjs +15 -4
  64. package/scripts/offline-proof.mjs +74 -13
  65. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  66. package/scripts/page-release/content.d.mts +9 -1
  67. package/scripts/page-release/content.mjs +131 -17
  68. package/scripts/page-release/flow.mjs +36 -10
  69. package/scripts/page-release/stamp-content.mjs +24 -0
  70. package/scripts/page-release.mjs +28 -6
  71. package/scripts/page-size.mjs +2 -1
  72. package/scripts/pin-packs.ts +1 -1
  73. package/scripts/pins.ts +4 -4
  74. package/scripts/precommit-checks.mjs +1 -7
  75. package/scripts/precommit-jobs.mjs +0 -1
  76. package/scripts/precommit-source.py +1 -9
  77. package/scripts/program-discovery.mjs +1 -1
  78. package/scripts/ring-cook.mjs +2 -1
  79. package/scripts/ring-step.ts +1 -1
  80. package/scripts/script-scenario-metrics.mjs +1 -1
  81. package/scripts/shard-output-content.d.mts +1 -1
  82. package/scripts/shard-output-content.mjs +2 -2
  83. package/scripts/shard-outputs.mjs +1 -1
  84. package/scripts/shard-public.mjs +1 -1
  85. package/scripts/shard-wire-meter.mjs +24 -9
  86. package/scripts/side-parity.mjs +4 -2
  87. package/scripts/standalone-smoke.mjs +8 -3
  88. package/scripts/tier-textures.mjs +22 -4
  89. package/scripts/tile-bake-report.mjs +1 -1
  90. package/scripts/tile-bakes.mjs +1 -1
  91. package/scripts/title-assets.generated.json +2 -0
  92. package/scripts/tsconfig.json +0 -2
  93. package/scripts/vendor/basisu/LICENSE +201 -0
  94. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  95. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  96. package/scripts/vitest-push-guards.config.ts +1 -1
  97. package/scripts/vps/harden-apply.sh +4 -1
  98. package/scripts/vps/harden-prometheus.sh +176 -0
  99. package/scripts/vps/harden.sh +16 -0
  100. package/scripts/vps/rebuild.sh +18 -0
  101. package/scripts/vps/wildshard-config +6 -2
  102. package/scripts/worker-client-play.mjs +6 -2
  103. package/scripts/worktree-reap.mjs +5 -5
  104. package/src/.oxlintrc.json +3 -182
  105. package/src/client/app/entry.ts +10 -2
  106. package/src/client/engine/boot/bootCache.ts +2 -2
  107. package/src/client/engine/boot/bootTrace.ts +12 -4
  108. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  109. package/src/client/engine/boot/clearDownloads.ts +5 -2
  110. package/src/client/engine/boot/contentRead.ts +11 -0
  111. package/src/client/engine/boot/gpuFiles.ts +4 -2
  112. package/src/client/engine/boot/lastEnd.ts +99 -12
  113. package/src/client/engine/boot/texturePack.ts +2 -2
  114. package/src/client/engine/net/netPlayer.ts +19 -2
  115. package/src/client/engine/net/otherPlayers.ts +55 -8
  116. package/src/client/engine/net/predictor.ts +33 -9
  117. package/src/client/engine/net/redial.ts +29 -6
  118. package/src/client/engine/pwa/cacheNames.ts +58 -1
  119. package/src/client/engine/pwa/sw.js +41 -11
  120. package/src/client/engine/render/dataLook.ts +152 -40
  121. package/src/client/engine/render/families/detail.ts +89 -0
  122. package/src/client/engine/render/families/pbr.ts +7 -1
  123. package/src/client/engine/render/look.ts +6 -0
  124. package/src/client/engine/render/lookLight.ts +103 -11
  125. package/src/client/engine/render/lookRender.ts +105 -0
  126. package/src/client/engine/saves/indexed.ts +2 -2
  127. package/src/client/engine/telemetry/browserErrors.ts +24 -3
  128. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  129. package/src/client/engine/ui/debugOptions.ts +1 -1
  130. package/src/client/engine/ui/lookLightOption.ts +10 -6
  131. package/src/client/engine/ui/namePrompt.ts +7 -0
  132. package/src/client/game/boot/audio.generated.ts +114 -114
  133. package/src/client/game/boot/bytes.generated.ts +118 -220
  134. package/src/client/game/boot/placedSpawn.ts +35 -0
  135. package/src/client/game/boot/spawnDownload.ts +25 -6
  136. package/src/client/game/boot/versions.generated.ts +7 -5
  137. package/src/client/game/devScene/hook.ts +291 -0
  138. package/src/client/game/grid/cellLoading.ts +12 -2
  139. package/src/client/game/grid/live.ts +112 -16
  140. package/src/client/game/grid/liveSession.ts +33 -2
  141. package/src/client/game/grid/mapAtlas.ts +18 -4
  142. package/src/client/game/grid/minimapBlend.ts +15 -5
  143. package/src/client/game/grid/oneWayIn.ts +5 -1
  144. package/src/client/game/grid/placedCells.ts +114 -12
  145. package/src/client/game/grid/placedContent.ts +85 -0
  146. package/src/client/game/grid/prefetch.ts +9 -1
  147. package/src/client/game/grid/productInputs.ts +3 -1
  148. package/src/client/game/grid/productLeases.ts +4 -1
  149. package/src/client/game/grid/products.ts +8 -4
  150. package/src/client/game/grid/roadLook.ts +24 -15
  151. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  152. package/src/client/game/grid/roadResources.ts +24 -0
  153. package/src/client/game/grid/roadSign.worker.ts +4 -3
  154. package/src/client/game/grid/roadSignPaint.ts +16 -5
  155. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  156. package/src/client/game/grid/roadSignScale.ts +8 -0
  157. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  158. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  159. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  160. package/src/client/game/grid/roadTileWriter.ts +2 -1
  161. package/src/client/game/grid/screenReports.ts +39 -0
  162. package/src/client/game/grid/session.ts +20 -4
  163. package/src/client/game/grid/softWallLook.ts +25 -8
  164. package/src/client/game/mainMenu.ts +6 -2
  165. package/src/client/game/plugin/context.ts +2 -1
  166. package/src/client/game/plugin/followedMovers.ts +7 -1
  167. package/src/client/game/quest/figures.ts +2 -0
  168. package/src/client/game/session/finish.ts +6 -0
  169. package/src/client/game/shardfile/assetCache.ts +4 -4
  170. package/src/client/game/shardfile/client.ts +4 -1
  171. package/src/client/game/shardfile/clientAssets.ts +9 -5
  172. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  173. package/src/client/game/shardfile/clientWater.ts +51 -9
  174. package/src/client/game/shardfile/clientWorker.ts +19 -7
  175. package/src/client/game/shardfile/look.ts +8 -3
  176. package/src/client/game/shardfile/product.ts +34 -7
  177. package/src/client/game/shardfile/productChecks.ts +2 -2
  178. package/src/client/game/shardfile/productCost.ts +2 -2
  179. package/src/client/game/shardfile/readAsset.ts +2 -2
  180. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  181. package/src/client/game/shardfile/seatGrace.ts +9 -0
  182. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  183. package/src/client/game/systems/npc/figureRows.ts +9 -0
  184. package/src/client/host/online/doctor.ts +2 -0
  185. package/src/client/host/online/linkScreens.ts +30 -4
  186. package/src/client/host/standalone/shell.ts +4 -0
  187. package/src/cook/game/astc6Encode.ts +55 -0
  188. package/src/cook/game/astc6Wasm.ts +176 -0
  189. package/src/cook/game/cookJob.ts +30 -6
  190. package/src/cook/game/cookWorker.ts +38 -11
  191. package/src/cook/game/entryTotals.ts +51 -24
  192. package/src/cook/game/shardCook.ts +35 -7
  193. package/src/cook/game/spawnParts.ts +33 -8
  194. package/src/cook/game/tierTextures.ts +87 -14
  195. package/src/server/engine/ai/bossContenders.ts +27 -3
  196. package/src/server/engine/ai/phases.ts +1 -1
  197. package/src/server/engine/entities/creatureRefill.ts +9 -2
  198. package/src/server/engine/net/ledgerBook.ts +2 -0
  199. package/src/server/engine/net/room.ts +15 -0
  200. package/src/server/engine/sim/respawn.ts +8 -0
  201. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  202. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  203. package/src/server/game/boss/native.ts +2 -1
  204. package/src/server/game/boss/nativeWake.ts +9 -5
  205. package/src/server/game/boss/openArenaNative.ts +2 -2
  206. package/src/server/game/boss/openArenaRoom.ts +3 -1
  207. package/src/server/game/grid/room.ts +44 -3
  208. package/src/server/game/grid/simulation.ts +23 -0
  209. package/src/server/game/population/mixedRoster.ts +11 -3
  210. package/src/server/game/population/nativeBake.ts +8 -3
  211. package/src/server/game/population/nativeReturns.ts +6 -3
  212. package/src/server/game/population/roster.ts +5 -3
  213. package/src/server/game/quest/eliteDrops.ts +15 -4
  214. package/src/server/game/quest/nativeChapter.ts +1 -1
  215. package/src/server/game/quest/nativeComposition.ts +5 -1
  216. package/src/server/game/riding/nativeTaming.ts +10 -6
  217. package/src/server/game/riding/wildRefill.ts +3 -2
  218. package/src/server/game/shardfile/bossRow.ts +4 -2
  219. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  220. package/src/server/host/bake/headlessWorker.ts +1 -1
  221. package/src/server/host/dedicated/cellHost.ts +98 -16
  222. package/src/server/host/dedicated/cellProtocol.ts +16 -1
  223. package/src/server/host/dedicated/cellWorker.ts +8 -5
  224. package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
  225. package/src/server/host/dedicated/gridCells.ts +15 -6
  226. package/src/server/host/dedicated/loopLag.ts +21 -0
  227. package/src/server/host/dedicated/main.ts +13 -5
  228. package/src/server/host/dedicated/packReader.ts +3 -3
  229. package/src/server/host/dedicated/placementFile.ts +3 -2
  230. package/src/server/host/dedicated/roadRoom.ts +34 -4
  231. package/src/server/host/dedicated/serverMetrics.ts +126 -0
  232. package/src/server/host/dedicated/socketPump.ts +21 -4
  233. package/src/server/host/dedicated/workerTable.ts +15 -4
  234. package/src/server/host/dedicated/world.ts +65 -7
  235. package/src/server/host/headless.ts +1 -1
  236. package/src/server/host/headlessRuntime.ts +1 -1
  237. package/src/server/host/standalone/roadWorld.ts +15 -3
  238. package/src/server/host/standalone/serverHost.ts +4 -1
  239. package/src/server/host/standalone/serverProduct.ts +41 -11
  240. package/src/shared/engine/ai/BossBrain.ts +8 -0
  241. package/src/shared/game/boss/wake.ts +6 -0
  242. package/src/shared/game/devColliders.ts +47 -0
  243. package/src/shared/game/eliteSystem.ts +8 -0
  244. package/src/shared/game/grid/allocator.ts +3 -0
  245. package/src/shared/game/grid/placementRows.ts +5 -2
  246. package/src/shared/game/plugin/bossRecord.ts +3 -2
  247. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  248. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  249. package/src/shared/game/shardfile/packReads.ts +28 -3
  250. package/src/shared/game/shardfile/serverPack.ts +9 -0
  251. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  252. package/src/shared/host/formatJsonSchema.ts +2 -2
  253. package/src/tsconfig.json +1 -27
  254. package/lint/host-reviews.json +0 -14
  255. package/lint/listed-view-code.json +0 -13
  256. package/lint/platform-pending-users.json +0 -2520
  257. package/lint/platform-pending-users.md +0 -18
  258. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  259. package/scripts/check-closed-components.d.mts +0 -7
  260. package/scripts/check-closed-components.mjs +0 -87
  261. package/scripts/g571-hosts.d.mts +0 -3
  262. package/scripts/g571-hosts.mjs +0 -54
  263. package/scripts/host-ruler/register-migrate.mjs +0 -242
  264. package/scripts/listed-view-code.d.mts +0 -7
  265. package/scripts/listed-view-code.mjs +0 -93
  266. package/scripts/look-loop/fit-lut.py +0 -142
  267. package/scripts/look-loop/palette-delta.py +0 -183
  268. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  269. package/scripts/look-loop/regions/far-reach.json +0 -225
  270. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  271. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  272. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  273. package/scripts/platform-chargebacks.d.mts +0 -9
  274. package/scripts/platform-chargebacks.mjs +0 -135
  275. package/scripts/shard-component-spans.d.mts +0 -15
  276. package/scripts/shard-component-spans.mjs +0 -18
  277. package/scripts/shard-components.d.mts +0 -16
  278. package/scripts/shard-components.mjs +0 -363
  279. package/scripts/shard-platform-hosts.d.mts +0 -2
  280. package/scripts/shard-platform-hosts.mjs +0 -93
  281. package/scripts/shard-platform-sections.d.mts +0 -2
  282. package/scripts/shard-platform-sections.mjs +0 -9
  283. package/scripts/shard-platform.d.mts +0 -76
  284. package/scripts/shard-platform.mjs +0 -1072
  285. package/src/.oxfmtrc.json +0 -48
  286. package/src/scripts/ask-new.sh +0 -29
  287. package/src/scripts/asks.mjs +0 -142
  288. package/src/scripts/herdr-prompt.sh +0 -34
  289. package/src/scripts/herdr-question-open.sh +0 -67
  290. package/src/scripts/md-wrap.mjs +0 -229
  291. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  292. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  293. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env bash
2
+ # SERVER-CELLS SC2 (J328; Jake, 2026-11-13, grill Q9: "now or you do it"): a box-local Prometheus, loopback only.
3
+ # The distro's prometheus and prometheus-node-exporter, each held to 127.0.0.1 by a systemd drop-in written before the
4
+ # package installs, so even the first start never listens anywhere else. 15 days of samples, no remote write: nothing leaves
5
+ # the box. Every 15 s it scrapes production's and staging's `/metrics` (SC1: the server's METRICS_PORT, which this sets in
6
+ # each channel's .settings when it is absent) and the node's. Agents read it on the box without sudo:
7
+ # curl -s 127.0.0.1:9090/api/v1/targets curl -s '127.0.0.1:9090/api/v1/query?query=wildshard_cells_resident'
8
+ # harden-prometheus.sh --print print every file it writes and stop (the engine's test reads them)
9
+ # Run by harden-apply.sh as root. A rerun on a box that has it changes nothing and restarts nothing.
10
+ set -euo pipefail
11
+ say() { printf '%-7s %-5s %s\n' "$1" "$2" "$3"; }
12
+ # Each channel's METRICS_PORT; wildshard-config pins the same two (the engine's test holds them equal).
13
+ PRODUCTION_METRICS=9790 STAGING_METRICS=9791
14
+ PROMETHEUS=127.0.0.1:9090 NODE=127.0.0.1:9100
15
+ CONFIG=/etc/prometheus/wildshard.yml
16
+ PROMETHEUS_DROPIN=/etc/systemd/system/prometheus.service.d/90-wildshard.conf
17
+ NODE_DROPIN=/etc/systemd/system/prometheus-node-exporter.service.d/90-wildshard.conf
18
+ # The engine's test hands it a made-up /etc/wildshard for the settings step; never as root.
19
+ TEST=
20
+ if [ "$(id -u)" != 0 ] && [ -n "${WILDSHARD_PROMETHEUS_TEST_ROOT:-}" ]; then TEST=$WILDSHARD_PROMETHEUS_TEST_ROOT; fi
21
+ ETC=$TEST/etc/wildshard
22
+
23
+ config() {
24
+ cat <<EOF
25
+ # SERVER-CELLS SC2: written by harden-prometheus.sh; a hand edit is undone by the next harden.
26
+ # Loopback targets only, and no remote write: nothing leaves the box.
27
+ global:
28
+ scrape_interval: 15s
29
+ evaluation_interval: 15s
30
+ scrape_configs:
31
+ - job_name: wildshard
32
+ static_configs:
33
+ - targets: ['127.0.0.1:$PRODUCTION_METRICS']
34
+ labels:
35
+ channel: production
36
+ - targets: ['127.0.0.1:$STAGING_METRICS']
37
+ labels:
38
+ channel: staging
39
+ - job_name: node
40
+ static_configs:
41
+ - targets: ['$NODE']
42
+ EOF
43
+ }
44
+ # The packaged units read \$ARGS from /etc/default; these replace the whole command line, so nothing there can widen a bind.
45
+ prometheus_dropin() {
46
+ cat <<EOF
47
+ # SERVER-CELLS SC2: loopback only, 15 days kept (harden-prometheus.sh).
48
+ [Service]
49
+ ExecStart=
50
+ ExecStart=/usr/bin/prometheus --config.file=$CONFIG --storage.tsdb.path=/var/lib/prometheus/metrics2/ --storage.tsdb.retention.time=15d --web.listen-address=$PROMETHEUS
51
+ MemoryMax=2G
52
+ EOF
53
+ }
54
+ node_dropin() {
55
+ cat <<EOF
56
+ # SERVER-CELLS SC2: loopback only (harden-prometheus.sh).
57
+ [Service]
58
+ ExecStart=
59
+ ExecStart=/usr/bin/prometheus-node-exporter --web.listen-address=$NODE
60
+ MemoryMax=256M
61
+ EOF
62
+ }
63
+
64
+ # Each channel's METRICS_PORT, added to its settings file only when the file names none: a value an agent set, blank (off)
65
+ # included, stays. The server reads it at its next start; this never restarts a game server.
66
+ metrics_setting() {
67
+ local channel=$1 port=$2 file temporary
68
+ file=$ETC/$channel.settings
69
+ if [ ! -d "$ETC" ]; then say wait SC2 "no $ETC yet: $channel's METRICS_PORT waits for setup.sh"; return; fi
70
+ # wildshard-config's own lock, so a `set` (or its rollback) running now never loses this row or loses its own.
71
+ if command -v flock >/dev/null 2>&1; then
72
+ exec 9>>"$ETC/.$channel.settings.lock"; chmod 600 "$ETC/.$channel.settings.lock"; flock 9
73
+ fi
74
+ if [ -L "$file" ]; then say stop SC2 "$file is a link; not written"; exit 1; fi
75
+ # A METRICS_PORT anywhere the unit reads it, the root-only .env included (its name only, never its value), is left alone.
76
+ if grep -Eqs '^[[:space:]]*METRICS_PORT[[:space:]]*=' "$file" "$ETC/$channel.env"; then
77
+ say ok SC2 "$channel names METRICS_PORT"; exec 9>&-; return
78
+ fi
79
+ temporary=$(umask 077; mktemp "$ETC/.harden-prometheus.XXXXXX")
80
+ if [ -f "$file" ]; then
81
+ cat "$file" > "$temporary"
82
+ if [ -s "$temporary" ] && [ -n "$(tail -c 1 "$temporary")" ]; then printf '\n' >> "$temporary"; fi
83
+ else
84
+ printf '%s\n' "# MMO-SERVER-PLAN MS3.5 (J266): this channel's non-secret settings, read after its .env. Change them with" \
85
+ '# `sudo wildshard-config set <channel> <KEY> <value>`; secrets stay in the .env.' > "$temporary"
86
+ fi
87
+ printf 'METRICS_PORT=%s\n' "$port" >> "$temporary"
88
+ chmod 640 "$temporary"
89
+ if [ -z "$TEST" ]; then chown "root:wildshard-$channel" "$temporary"; fi
90
+ mv -f -- "$temporary" "$file"
91
+ exec 9>&-
92
+ say doing SC2 "$channel METRICS_PORT=$port: its /metrics comes on at its next start (a release, or sudo -n systemctl restart wildshard-server@$channel)"
93
+ }
94
+
95
+ case "${1:-}" in
96
+ --print)
97
+ printf '# --- %s\n' "$CONFIG"; config
98
+ printf '# --- %s\n' "$PROMETHEUS_DROPIN"; prometheus_dropin
99
+ printf '# --- %s\n' "$NODE_DROPIN"; node_dropin
100
+ exit 0 ;;
101
+ --settings)
102
+ if [ -z "$TEST" ]; then say stop SC2 '--settings is the engine test'"'"'s; harden.sh runs the whole step'; exit 1; fi
103
+ metrics_setting production "$PRODUCTION_METRICS"; metrics_setting staging "$STAGING_METRICS"; exit 0 ;;
104
+ '') ;;
105
+ *) say stop SC2 'usage: harden-prometheus.sh [--print]'; exit 1 ;;
106
+ esac
107
+ if [ "$(id -u)" != 0 ]; then say stop SC2 'Run with sudo (harden.sh runs it)'; exit 1; fi
108
+
109
+ # Write stdin to a path unless it already says that: 0 wrote, 1 already so. Any failure stops the whole script, so a drop-in
110
+ # that did not land never lets the package start on every address. With a check command, the new text is checked in its
111
+ # temporary file before it replaces the old one.
112
+ put() {
113
+ local path=$1 check=${2:-} text temporary
114
+ text=$(cat)
115
+ if [ -r "$path" ] && [ "$(cat "$path")" = "$text" ]; then chmod 644 "$path" && chown root:root "$path" || exit 1; say ok SC2 "$path"; return 1; fi
116
+ say doing SC2 "write $path"
117
+ mkdir -p "$(dirname "$path")" || exit 1
118
+ temporary=$(umask 077; mktemp "$(dirname "$path")/.harden.XXXXXX") || exit 1
119
+ { printf '%s\n' "$text" > "$temporary" && chmod 644 "$temporary" && chown root:root "$temporary"; } || { rm -f "$temporary"; exit 1; }
120
+ if [ -n "$check" ] && ! $check "$temporary" >/dev/null 2>&1; then
121
+ $check "$temporary" 2>&1 | tail -3 || true
122
+ rm -f "$temporary"; say stop SC2 "$path does not check; the old one stays"; exit 1
123
+ fi
124
+ mv -f -- "$temporary" "$path" || exit 1
125
+ }
126
+ units_changed=0 config_changed=0
127
+ if put "$PROMETHEUS_DROPIN" < <(prometheus_dropin); then units_changed=1; fi
128
+ if put "$NODE_DROPIN" < <(node_dropin); then units_changed=1; fi
129
+ # promtool comes with the package, so the very first config is checked after the install, before anything restarts.
130
+ check=; if command -v promtool >/dev/null 2>&1; then check='promtool check config'; fi
131
+ if put "$CONFIG" "$check" < <(config); then config_changed=1; fi
132
+ if [ "$units_changed" = 1 ]; then systemctl daemon-reload; fi
133
+
134
+ installed() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -q 'ok installed'; }
135
+ missing=()
136
+ for name in prometheus prometheus-node-exporter; do installed "$name" || missing+=("$name"); done
137
+ if [ "${#missing[@]}" != 0 ]; then
138
+ # No recommends: no Alertmanager, no Pushgateway, no textfile collectors with their own timers. needrestart only lists, so
139
+ # an install never restarts a game server or PostgreSQL that holds an old library.
140
+ say doing SC2 "install ${missing[*]}"
141
+ apt-get update -qq
142
+ NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends "${missing[@]}"
143
+ fi
144
+ if ! promtool check config "$CONFIG" >/dev/null 2>&1; then
145
+ promtool check config "$CONFIG" 2>&1 | tail -3 || true
146
+ systemctl stop prometheus.service || true
147
+ say stop SC2 "$CONFIG does not check; Prometheus is stopped"; exit 1
148
+ fi
149
+
150
+ systemctl enable --quiet prometheus.service prometheus-node-exporter.service
151
+ for unit in prometheus-node-exporter.service prometheus.service; do
152
+ if [ "$units_changed" = 1 ] || ! systemctl is-active --quiet "$unit"; then systemctl restart "$unit"; say doing SC2 "restart $unit"
153
+ elif [ "$unit" = prometheus.service ] && [ "$config_changed" = 1 ]; then systemctl reload "$unit"; say doing SC2 "reload $unit"
154
+ else say ok SC2 "$unit running"; fi
155
+ done
156
+
157
+ metrics_setting production "$PRODUCTION_METRICS"
158
+ metrics_setting staging "$STAGING_METRICS"
159
+
160
+ # The proof, once both have bound: Prometheus and the node's metrics listen on loopback alone. A wider bind stops both units;
161
+ # a game server's /metrics off loopback is reported (harden.sh --check fails it too), and the rest of harden goes on.
162
+ listeners() { ss -ltnH | awk '{print $4}' | sed -E 's/%[^]:]+//'; }
163
+ for _ in 1 2 3 4 5 6 7 8 9 10; do
164
+ if listeners | grep -qx "$PROMETHEUS" && listeners | grep -qx "$NODE"; then break; fi
165
+ sleep 1
166
+ done
167
+ off_loopback() { listeners | grep -E ":($1)\$" | grep -Ev '^(127\.0\.0\.1|\[::1\]):' | tr '\n' ' ' | sed 's/ $//' || true; }
168
+ exposed=$(off_loopback '9090|9100')
169
+ if [ -n "$exposed" ]; then
170
+ systemctl stop prometheus.service prometheus-node-exporter.service
171
+ say stop SC2 "Prometheus or the node exporter listens off loopback, so both are stopped: $exposed"; exit 1
172
+ fi
173
+ servers=$(off_loopback "$PRODUCTION_METRICS|$STAGING_METRICS")
174
+ if [ -n "$servers" ]; then say warn SC2 "a game server's /metrics listens off loopback: $servers"; fi
175
+ if listeners | grep -qx "$PROMETHEUS" && listeners | grep -qx "$NODE"; then say ok SC2 "Prometheus on $PROMETHEUS only, node metrics on $NODE only"
176
+ else say warn SC2 "Prometheus or the node exporter is not listening yet: journalctl -u prometheus -u prometheus-node-exporter"; fi
@@ -212,6 +212,22 @@ if [ "$LISTENERS_OK" = 1 ]; then
212
212
  # ss writes a device suffix (`%tailscale0`) inside or after the brackets; it is dropped before the address is judged.
213
213
  exposed=$(printf '%s\n' "$LISTENERS" | grep -E ':(8790|8791|8792)$' | sed -E 's/%[^]:]+//' | grep -Ev "^(127\.0\.0\.1|\[::1\]${tails:+|\[?($tails)\]?}):" | tr '\n' ' ' | sed 's/ $//')
214
214
  if [ -z "$exposed" ]; then ok VH8 'game and cook ports listen on loopback or the tailnet only'; else bad VH8 "game or cook port on a public address: $exposed"; fi
215
+ # SERVER-CELLS SC2: Prometheus, the node exporter and both channels' /metrics answer on loopback alone, not even the tailnet.
216
+ metrics=$(printf '%s\n' "$LISTENERS" | grep -E ':(9090|9100|9790|9791)$' | sed -E 's/%[^]:]+//' | grep -Ev '^(127\.0\.0\.1|\[::1\]):' | tr '\n' ' ' | sed 's/ $//')
217
+ if [ -z "$metrics" ]; then ok SC2 'Prometheus and metrics ports listen on loopback only'; else bad SC2 "metrics port off loopback: $metrics"; fi
218
+ fi
219
+ # SERVER-CELLS SC2: the box's Prometheus runs, held to loopback by its drop-ins, and sends nothing off the box.
220
+ if [ -f "$R/etc/prometheus/wildshard.yml" ]; then
221
+ if grep -Eq '^[[:space:]]*remote_(write|read):' "$R/etc/prometheus/wildshard.yml"; then bad SC2 'wildshard.yml has a remote_write or remote_read'; else ok SC2 'wildshard.yml sends nothing off the box'; fi
222
+ for dropin in prometheus.service.d prometheus-node-exporter.service.d; do
223
+ if grep -q -- '--web.listen-address=127.0.0.1:' "$R/etc/systemd/system/$dropin/90-wildshard.conf" 2>/dev/null; then ok SC2 "$dropin holds it to loopback"; else bad SC2 "$dropin/90-wildshard.conf is missing or not loopback"; fi
224
+ done
225
+ if has systemctl; then
226
+ for unit in prometheus.service prometheus-node-exporter.service; do
227
+ if systemctl is-active --quiet "$unit" 2>/dev/null; then ok SC2 "$unit active"; else bad SC2 "$unit is not active"; fi
228
+ done
229
+ fi
230
+ else info SC2 'no box Prometheus yet (harden.sh installs it)'
215
231
  fi
216
232
 
217
233
  # --- VH9: the proxy.
@@ -20,6 +20,7 @@ ETC=/etc/wildshard HOME_DIR=/var/lib/wildshard SYSTEMD=/etc/systemd/system
20
20
  PG_VERSION=16 NODE=/usr/bin/node NODE_MAJOR=24 PNPM=pnpm@10.34.9
21
21
  KEY_DIR=/home/raynos/wildshard-e7 KEY_FILE=/home/raynos/wildshard-e7/release-public-key.hex
22
22
  COOK_ENV=/etc/wildshard/cook.env COOK_HOME=/var/lib/wildshard-cook COOK_SRC=/opt/wildshard/engine COOK_LIB=/usr/local/lib/wildshard-cook
23
+ COOK_GROUP=wildshard-cook
23
24
  # 8790 and 8791 are the game's loopback ports; the cook worker's own default was 8791 too.
24
25
  COOK_PORT=8792
25
26
  ENGINE_GIT=https://github.com/project-wildshard/engine.git
@@ -454,10 +455,24 @@ make_cook_source() {
454
455
  printf '%s %s\n' "$COOK_REF" "$(cook_commit)" > "$COOK_SRC/.wildshard-installed"
455
456
  chmod -R go-w "$COOK_SRC"
456
457
  }
458
+ # MMO-SERVER MS2.4b: root clones under the box's umask 027, so the checkout came out 750 root:root and the cook, its own user,
459
+ # could not enter its WorkingDirectory (200/CHDIR). Root keeps owning it; the cook's group reads and traverses, and neither the
460
+ # group nor anyone else writes. The worker's own hash of cook.env stays root's. Symlinks (pnpm's) carry no mode of their own.
461
+ cook_unreadable() {
462
+ find "$COOK_SRC" -name .wildshard-env -prune -o ! -type l \( ! -group "$COOK_GROUP" -o ! -perm -g+r -o -perm -g+w -o -perm -o+w \
463
+ -o \( -type d ! -perm -g+x \) \) -print -quit
464
+ }
465
+ have_cook_read() { [ -d "$COOK_SRC" ] && [ -z "$(cook_unreadable)" ]; }
466
+ make_cook_read() {
467
+ find "$COOK_SRC" -name .wildshard-env -prune -o -exec chgrp -h "$COOK_GROUP" {} + || return 1
468
+ find "$COOK_SRC" -name .wildshard-env -prune -o ! -type l -exec chmod g+rX,g-w,o-w {} +
469
+ }
457
470
  COOK_SOURCE_CHANGED=0
458
471
  if [ "$COOK_READY" = 1 ]; then
459
472
  if [ "$CHECK" = 0 ] && ! have_cook_source; then COOK_SOURCE_CHANGED=1; fi
460
473
  step "cook source $COOK_SRC at $COOK_REF" have_cook_source make_cook_source
474
+ if [ "$CHECK" = 0 ] && ! have_cook_read; then COOK_SOURCE_CHANGED=1; fi
475
+ step "cook source readable by $COOK_GROUP" have_cook_read make_cook_read
461
476
  fi
462
477
  # What the running worker last read of cook.env, as a hash in its root-owned checkout: a changed file restarts it.
463
478
  cook_env_hash() { sha256sum < "$COOK_ENV" | cut -d' ' -f1; }
@@ -475,6 +490,9 @@ User=wildshard-cook
475
490
  Group=wildshard-cook
476
491
  WorkingDirectory=$COOK_SRC
477
492
  EnvironmentFile=$COOK_ENV
493
+ # MS2.4b: the checkout is root's and the worker runs git in it as wildshard-cook, which git refuses ("dubious ownership")
494
+ # unless the path is a safe.directory. Set here, not in a gitconfig the worker's home would have to hold.
495
+ Environment=GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=safe.directory GIT_CONFIG_VALUE_0=$COOK_SRC
478
496
  Environment=COOK_PORT=$COOK_PORT
479
497
  Environment=COOK_HOST=127.0.0.1
480
498
  Environment=COOK_SCRATCH=$COOK_HOME/scratch
@@ -14,7 +14,8 @@
14
14
  # Installed root-owned as /usr/local/sbin/wildshard-config by harden.sh; the sudo allowlist names that path only.
15
15
  import os, re, subprocess, sys, tempfile, time, urllib.request
16
16
 
17
- CHANNELS = {'production': {'port': 8790, 'cpus': 9, 'host': 0}, 'staging': {'port': 8791, 'cpus': 4, 'host': 1}}
17
+ # 'metrics' is the channel's METRICS_PORT (SC1's /metrics on 127.0.0.1), the one harden-prometheus.sh scrapes (SC2).
18
+ CHANNELS = {'production': {'port': 8790, 'cpus': 9, 'host': 0, 'metrics': 9790}, 'staging': {'port': 8791, 'cpus': 4, 'host': 1, 'metrics': 9791}}
18
19
  # The pages that open the game (engine doorTrust DEFAULT_ALLOWED_ORIGINS); each channel's own is at its 'host' index.
19
20
  GAME_HOSTS = ('https://play.wildshard.io', 'https://staging.wildshard.io', 'https://preview.wildshard.io')
20
21
  CELL = r'[a-z0-9][a-z0-9-]{0,63}'
@@ -44,6 +45,8 @@ SETTINGS = {
44
45
  'WORLD_CROSSING': lambda value, channel: value in ('off', 'worker'),
45
46
  'PLACEMENT_URL': lambda value, channel: value in ('', placements(channel)),
46
47
  'PLACEMENT_PUBLIC_KEY': lambda value, channel: value in ('', PLACEMENT_PUBLIC_KEY),
48
+ # SC2: the channel's own port, which the box's Prometheus scrapes, or blank (off). The server binds it on 127.0.0.1 only.
49
+ 'METRICS_PORT': lambda value, channel: value in ('', str(CHANNELS[channel]['metrics'])),
47
50
  }
48
51
  RULES = {'WORLD_CELLS': "'grid' or comma-separated cell names (a-z, 0-9, -), none twice",
49
52
  'WORLD_WORKERS': 'a whole number from 1 to the channel\'s pinned CPUs (production 9, staging 4)',
@@ -52,7 +55,8 @@ RULES = {'WORLD_CELLS': "'grid' or comma-separated cell names (a-z, 0-9, -), non
52
55
  "https://preview.wildshard.io, keeping the channel's own (production play, staging staging)",
53
56
  'WORLD_CROSSING': 'off or worker',
54
57
  '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'}
58
+ 'PLACEMENT_PUBLIC_KEY': f'the API placement key {PLACEMENT_PUBLIC_KEY}, or blank',
59
+ 'METRICS_PORT': "the channel's own metrics port (production 9790, staging 9791), or blank (off)"}
56
60
 
57
61
  # The engine's tests hand it a made-up /etc and no systemctl; never as root, so sudo (which drops the environment anyway) cannot.
58
62
  TEST = os.geteuid() != 0 and os.environ.get('WILDSHARD_CONFIG_TEST_ROOT')
@@ -1,6 +1,6 @@
1
1
  // J130: the row played through, as the flip's real checklist. Each step stands alone: one that fails is listed and the next still runs.
2
2
  // Driftwood's opening quest, a fight and its coins; a ride on Nalati; a grapple; the other shards; a crossing; save, reload, resume.
3
- import { saveFixture } from './debug-settings.mjs';
3
+ import { NAME_ASKED, saveFixture } from './debug-settings.mjs';
4
4
  import { floorGridBenchmarkUrl, FLOOR_GRID_ENTER } from './frame-floor-navigation.mjs';
5
5
 
6
6
  /** Open one page with the row on. */
@@ -9,6 +9,9 @@ async function open(browser, phone, base, path) {
9
9
  page.on('pageerror', error => { errors.push(error.message.slice(0, 300)); });
10
10
  page.on('console', line => { if (line.type() === 'error') errors.push(line.text().slice(0, 300)); });
11
11
  await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
12
+ // MP2.4: a device's first world entry asks for the Name, and on a world build (staging) nothing here answers it; mark it
13
+ // asked, as scripts/goldens/capture.mjs does
14
+ await saveFixture(context, NAME_ASKED);
12
15
  await page.goto(new URL(path, base).href, { waitUntil: 'load' });
13
16
  return { context, page, errors };
14
17
  }
@@ -468,7 +471,8 @@ export async function play(browser, phone, base, only = '') {
468
471
 
469
472
  // Every other shard boots on the row, its sky and fights on rows, with no page error
470
473
  if (runs('shards')) for (const slug of ['pine-hollow', 'sunscar-dunes', 'far-reach', 'driftwood-isle', 'nalati-grasslands', 'nine-dragon-stack']) {
471
- const shard = await open(browser, phone, base, `/?chunk=${slug}&mute=1&nolock=1`);
474
+ // a world build (staging) sends a bare `?chunk=` link to the title first (bootRoute.ts onlineTitleFirst); `skipintro` enters
475
+ const shard = await open(browser, phone, base, `/?chunk=${slug}&mute=1&nolock=1&skipintro`);
472
476
  await step(`${slug} plays on the row`, async () => {
473
477
  await entered(shard.page);
474
478
  await shard.page.evaluate(() => { const { player } = window.__wildshard.world; player.touchMove.y = 1; });
@@ -103,21 +103,21 @@ export function stopWorktreeProcesses(tree,options={}){
103
103
  }
104
104
 
105
105
  /** Newest change in the worktree's own Git state, in ms. @param {string} tree @param {string} gitDir */
106
- function lastActivity(tree,gitDir){
106
+ export function lastActivity(tree,gitDir){
107
107
  let newest=Number(git(tree,['log','-1','--format=%ct','HEAD']).trim())*1000;
108
108
  for(const file of ['index','HEAD','logs/HEAD'])try{newest=Math.max(newest,statSync(join(gitDir,file)).mtimeMs);}catch{/* Not there. */}
109
109
  return newest;
110
110
  }
111
111
 
112
112
  /** Is `sha` on origin/main itself? @param {string} canonical @param {string} sha */
113
- const onMain=(canonical,sha)=>sha!==''&&tryGit(canonical,['merge-base','--is-ancestor',sha,'origin/main']).status===0;
113
+ export const onMain=(canonical,sha)=>sha!==''&&tryGit(canonical,['merge-base','--is-ancestor',sha,'origin/main']).status===0;
114
114
  /** Commits of `sha` that origin/main lacks. @param {string} canonical @param {string} sha */
115
115
  const aheadOfMain=(canonical,sha)=>Number(tryGit(canonical,['rev-list','--count',`origin/main..${sha}`]).stdout.trim()||'0');
116
116
 
117
117
  /** @typedef {{path:string,head:string,branch:string}} Worktree */
118
118
 
119
119
  /** Linked worktrees of the repo from `git worktree list --porcelain -z`. @param {string} canonical @returns {Worktree[]} */
120
- function linkedWorktrees(canonical){
120
+ export function linkedWorktrees(canonical){
121
121
  /** @type {Worktree[]} */const trees=[];
122
122
  /** @type {Partial<Worktree>} */let current={};
123
123
  for(const field of [...git(canonical,['worktree','list','--porcelain','-z']).split('\0'),'']){
@@ -157,7 +157,7 @@ export function reap(canonical,options,env,say){
157
157
  if(!existsSync(tree.path)){keep('its folder is gone; `git worktree prune` clears it');continue;}
158
158
  // Landed means the tip is on main itself (land fast-forwards): \`git cherry\` would miss a merge's own changes.
159
159
  if(!onMain(canonical,tree.head)){keep(`${String(aheadOfMain(canonical,tree.head))} commit(s) not on main`);continue;}
160
- const dirty=git(tree.path,['status','--porcelain','--untracked-files=all']).split('\n').filter(Boolean);
160
+ const dirty=git(tree.path,['--no-optional-locks','status','--porcelain','--untracked-files=all']).split('\n').filter(Boolean);
161
161
  if(dirty.length>0){keep(`${String(dirty.length)} uncommitted path(s), first ${dirty[0]?.slice(3)}`);continue;}
162
162
  const gitDir=git(tree.path,['rev-parse','--absolute-git-dir']).trim();
163
163
  const busy=(/** @type {Map<number,string>|undefined} */ seen)=>seen===undefined?'cannot list process working directories'
@@ -180,7 +180,7 @@ export function reap(canonical,options,env,say){
180
180
  if(stopped.length>0)say(`${options.dryRun?'would stop':'stopped '} ${slug}: orphaned pid ${stopped.join(', ')}`);
181
181
  }
182
182
  const head=tryGit(tree.path,['rev-parse','HEAD']).stdout.trim();
183
- const now2=git(tree.path,['status','--porcelain','--untracked-files=all']).trim();
183
+ const now2=git(tree.path,['--no-optional-locks','status','--porcelain','--untracked-files=all']).trim();
184
184
  const seen2=processDirectories();
185
185
  const using2=busy(seen2===undefined||!options.dryRun?seen2:new Map([...seen2].filter(([pid])=>!orphans.has(pid))));
186
186
  const why=head!==tree.head?`HEAD moved to ${head.slice(0,10)} during the check`:now2!==''?'edited during the check':using2!==''?`in use during the check (${using2})`
@@ -1,190 +1,11 @@
1
1
  {
2
- "$schema": "./node_modules/oxlint/configuration_schema.json",
3
- "plugins": [
4
- "typescript",
5
- "unicorn",
6
- "oxc",
7
- "import",
8
- "promise",
9
- "node",
10
- "react",
11
- "react-perf",
12
- "jsx-a11y"
13
- ],
14
- // Strictest of greenroom (every category denied) and wildshard-singleplayer
15
- // (these options, and import/no-nodejs-modules outside Node-side folders).
16
- "options": {
17
- "typeAware": true,
18
- "denyWarnings": true,
19
- "reportUnusedDisableDirectives": "error"
20
- },
21
- "categories": {
22
- "correctness": "deny",
23
- "suspicious": "deny",
24
- "pedantic": "deny",
25
- "perf": "deny",
26
- "style": "deny",
27
- "restriction": "deny",
28
- "nursery": "deny"
29
- },
2
+ "$schema": "../node_modules/oxlint/configuration_schema.json",
3
+ "extends": ["../kit/.oxlintrc.json"],
4
+ // oxlint does not inherit ignorePatterns through extends (K11, J329).
30
5
  "ignorePatterns": [
31
- // Plain-JS repo scripts, outside the TS project; covered by
32
- // `pnpm test:hooks` instead. (.githooks/ sits outside src/.)
33
6
  "scripts/**",
34
7
  "dist/**",
35
- "node_modules/**",
36
8
  "test-results/**",
37
9
  "playwright-report/**"
38
- ],
39
- "rules": {
40
- "typescript/explicit-function-return-type": [
41
- "deny",
42
- {
43
- "allowExpressions": false,
44
- "allowTypedFunctionExpressions": false,
45
- "allowHigherOrderFunctions": false,
46
- "allowDirectConstAssertionInArrowFunctions": false,
47
- "allowConciseArrowFunctionExpressionsStartingWithVoid": false,
48
- "allowFunctionsWithoutTypeParameters": false,
49
- "allowIIFEs": false
50
- }
51
- ],
52
- "typescript/explicit-module-boundary-types": [
53
- "deny",
54
- {
55
- "allowArgumentsExplicitlyTypedAsAny": false,
56
- "allowDirectConstAssertionInArrowFunctions": false,
57
- "allowHigherOrderFunctions": false,
58
- "allowTypedFunctionExpressions": false
59
- }
60
- ],
61
- "typescript/no-floating-promises": [
62
- "deny",
63
- {
64
- "allowForKnownSafeCalls": [
65
- {
66
- "from": "package",
67
- "package": "node:test",
68
- "name": ["describe", "it", "suite", "test"]
69
- }
70
- ]
71
- }
72
- ],
73
- "typescript/prefer-readonly-parameter-types": [
74
- "deny",
75
- {
76
- "treatMethodsAsReadonly": true,
77
- // Framework objects that are mutable by design and only ever passed in.
78
- "allow": [
79
- { "from": "package", "package": "hono", "name": "Context" },
80
- { "from": "package", "package": "node:test", "name": "TestContext" },
81
- {
82
- "from": "package",
83
- "package": "http",
84
- "name": ["IncomingMessage", "ServerResponse"]
85
- },
86
- {
87
- // A test drives one page through its own handle (src/e2e/smoke/).
88
- "from": "package",
89
- "package": "playwright-core",
90
- "name": ["Page", "Route", "ConsoleMessage"]
91
- },
92
- {
93
- "from": "package",
94
- "package": "playwright",
95
- "name": [
96
- "PlaywrightTestArgs",
97
- "PlaywrightTestOptions",
98
- "PlaywrightWorkerArgs",
99
- "PlaywrightWorkerOptions"
100
- ]
101
- }
102
- ]
103
- }
104
- ],
105
- "eslint/func-style": [
106
- "deny",
107
- "declaration",
108
- { "allowArrowFunctions": true }
109
- ],
110
- "eslint/no-duplicate-imports": [
111
- "deny",
112
- { "allowSeparateTypeImports": true }
113
- ],
114
- // `return await` everywhere keeps stack traces and squares require-await with promise-function-async.
115
- "typescript/return-await": ["deny", "always"],
116
- // `void promise` is the marker no-floating-promises asks for.
117
- "eslint/no-void": ["deny", { "allowAsStatement": true }],
118
- // Continuation lines of a multi-line comment start mid-sentence.
119
- "eslint/capitalized-comments": [
120
- "deny",
121
- "always",
122
- { "ignoreConsecutiveComments": true }
123
- ],
124
- "react/jsx-filename-extension": ["deny", { "extensions": [".tsx"] }],
125
-
126
- // Disabled: each contradicts another rule or fights the stack.
127
- "eslint/sort-imports": "off", // oxfmt's sortImports owns import order; two sorters fight
128
- "eslint/sort-keys": "off", // key order carries meaning (schemas, options); not autofixable
129
- "eslint/one-var": "off", // one binding per declaration is how oxfmt lays code out
130
- "eslint/no-undef": "off", // tsc reports undefined names; this misreads type-only globals
131
- "eslint/no-undefined": "off", // contradicts unicorn/no-null; undefined is the absent value
132
- "eslint/no-ternary": "off", // JSX conditional rendering needs it; no-nested-ternary stays on
133
- "import/no-named-export": "off", // contradicts import/no-default-export; named exports win
134
- "import/prefer-default-export": "off", // contradicts import/no-default-export
135
- "import/no-relative-parent-imports": "off", // #subpath imports break the tsc build's extension rewrite
136
- "node/no-top-level-await": "off", // contradicts unicorn/prefer-top-level-await; ESM-only, never require()d
137
- "oxc/no-async-await": "off", // contradicts typescript/promise-function-async and require-await
138
- "oxc/no-optional-chaining": "off", // contradicts typescript/prefer-optional-chain
139
- "oxc/no-rest-spread-properties": "off", // ES5-compat ban; target is es2024
140
- "react/react-in-jsx-scope": "off", // contradicts the react-jsx automatic runtime
141
- "react/jsx-no-literals": "off" // i18n-only rule; no translations yet
142
- },
143
- "overrides": [
144
- {
145
- // Node programs may import node: modules; everything else (shared, client,
146
- // web code) may not, as in wildshard-singleplayer.
147
- "files": [
148
- "cli/**",
149
- "server/**",
150
- "tools/**",
151
- "test/**",
152
- "e2e/**",
153
- "cook/**",
154
- "**/*.test.ts",
155
- "*.config.ts",
156
- "**/*.config.ts"
157
- ],
158
- "rules": {
159
- "import/no-nodejs-modules": "off"
160
- }
161
- },
162
- {
163
- "files": ["*.config.ts", "**/*.config.ts"],
164
- "rules": {
165
- "import/no-default-export": "off", // playwright loads the default export
166
- "node/no-process-env": "off" // config reads CI from the environment
167
- }
168
- },
169
- {
170
- // A journey spec is one story in test.step blocks, and it reads the page's own double-underscore globals.
171
- "files": ["e2e/smoke/**"],
172
- "rules": {
173
- "eslint/max-statements": "off",
174
- "eslint/max-lines-per-function": "off",
175
- "eslint/no-underscore-dangle": [
176
- "error",
177
- { "allow": ["__wildshard", "__workerClientRow", "__workerClient"] }
178
- ]
179
- }
180
- },
181
- {
182
- "files": ["**/*.test.ts", "test/**", "e2e/**"],
183
- "rules": {
184
- "eslint/no-magic-numbers": "off", // assertions compare against literal expected values
185
- "node/no-sync": "off", // test fixtures set up git repos synchronously
186
- "node/no-process-env": "off" // the git helper isolates git from the developer's env
187
- }
188
- }
189
10
  ]
190
11
  }
@@ -33,7 +33,7 @@ import { inspectPreviousBoot, previousBootLine, previousBootLevel } from '@wilds
33
33
  import { Scope } from '@wildshard/engine/app/scope';
34
34
  import { bootRoute, onlineTitleFirst } from './bootRoute';
35
35
  import { consumeTitleArrival, pendingTitleArrival } from '@wildshard/engine/boot/titleArrival';
36
- import { lastEnd } from '@wildshard/engine/boot/lastEnd';
36
+ import { lastEnd, settleLastEnd } 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';
@@ -110,6 +110,9 @@ function learnPlacedCellsOnce(): Promise<void> {
110
110
  const late = new AbortController();
111
111
  const read = (async (): Promise<void> => {
112
112
  try {
113
+ // a page with no world and no placement stamp (preview, solo) reads none and imports nothing (PAGE-SIZE: the title waits here)
114
+ const stamps = globalThis as { __WS_WORLD__?: unknown; __WS_PLACEMENTS__?: unknown };
115
+ if (stamps.__WS_WORLD__ === undefined && stamps.__WS_PLACEMENTS__ === undefined) return;
113
116
  const { learnPlacedCells, placementsOf } = await import('@wildshard/engine/game/grid/placedCells');
114
117
  const url = placementsOf(globalThis as { __WS_WORLD__?: unknown; __WS_PLACEMENTS__?: unknown });
115
118
  if (url === null || late.signal.aborted) return;
@@ -122,6 +125,8 @@ function learnPlacedCellsOnce(): Promise<void> {
122
125
  return Promise.race([read, deadline]);
123
126
  }
124
127
  async function enterPage(): Promise<unknown> {
128
+ // S20: a crash read off another tab's live beat is no crash; asked now, answered (at most 500 ms) before the title reads it
129
+ const settled = settleLastEnd();
125
130
  await placedCells;
126
131
  const requested = search.get('chunk');
127
132
  // SA36: a `/slug/<slug>` link opens that one shard's page; its PLAY leaves for `/?chunk=<slug>`, so a world never boots here.
@@ -135,6 +140,7 @@ async function enterPage(): Promise<unknown> {
135
140
  return showPageTitle(UNLISTED);
136
141
  }
137
142
  await waitFor('Startup stylesheets', waitForLoadingStyles(entryScope), 'file');
143
+ await settled;
138
144
  const { consumeGridRecovery, gridRecoveryRefused, pageGridRecovery, pendingGridEntry } = await bootTask('app:page-entry-import', () => import('@wildshard/engine/game/grid/pageEntry'));
139
145
  // QA row 16 (GO1): an online level seats a body the world sees, so only a tap enters one. Crash resume is the solo build's.
140
146
  const online = (globalThis as { __WS_WORLD__?: unknown }).__WS_WORLD__ !== undefined;
@@ -243,7 +249,8 @@ async function enterPage(): Promise<unknown> {
243
249
  })();
244
250
  }
245
251
  async function showPageTitle(refusal = ''): Promise<void> {
246
- const [{ showStartTitle }, { buildTitleMenu, installGridTitle }, { travel }] = await Promise.all([import('@wildshard/engine/ui/StartTitle'), import('@wildshard/engine/game/mainMenu'), import('@wildshard/engine/game/travel/travel')]);
252
+ // S20: the title's ended note reads lastEnd(), settled (the imports take longer than the lock query)
253
+ const [{ showStartTitle }, { buildTitleMenu, installGridTitle }, { travel }] = await Promise.all([import('@wildshard/engine/ui/StartTitle'), import('@wildshard/engine/game/mainMenu'), import('@wildshard/engine/game/travel/travel'), settleLastEnd()]);
247
254
  // SF21a: a tap or validated recovery selects a grid; unrecorded process loss returns to title
248
255
  const grid = installGridTitle();
249
256
  // the composition root wires the game's main menu (over its shard deck) into the engine's title (E405)
@@ -274,6 +281,7 @@ async function showPageTitle(refusal = ''): Promise<void> {
274
281
  */
275
282
  async function showSlugPage(slug: string): Promise<void> {
276
283
  document.documentElement.classList.add('title-first');
284
+ await settleLastEnd(); // S20: its ended note reads lastEnd()
277
285
  const manifest = findTitleManifest(slug);
278
286
  // the page's query (`?sw=0`, `?tier=`, …) rides along to `/`, as a Shard select tap keeps it
279
287
  const home = (): URL => new URL(`/${location.search}`, location.origin);
@@ -1,4 +1,4 @@
1
- import { ASSET_CACHE_NAME } from '../pwa/cacheNames';
1
+ import { assetCacheName } from '../pwa/cacheNames';
2
2
 
3
3
  /** Publish a complete immutable native response after an uncontrolled read.
4
4
  * No metadata owner or protocol: the next worker reads the same absolute URL.
@@ -10,7 +10,7 @@ export async function publishBootResponse(path: string, response: Response): Pro
10
10
  const url = new URL(path, location.href);
11
11
  if (url.origin !== location.origin || url.searchParams.has('sw')
12
12
  || !(/-[a-f0-9]{8,64}\.[a-z0-9]+$/u.test(url.pathname) || /^[a-f0-9]{8,64}$/u.test(url.searchParams.get('v') ?? ''))) return;
13
- await (await caches.open(ASSET_CACHE_NAME)).put(url.href, response);
13
+ await (await caches.open(assetCacheName())).put(url.href, response);
14
14
  } catch { /* Quota, disabled storage and publication failure keep the native read usable. */ }
15
15
  finally { void response.body?.cancel().catch(() => undefined); }
16
16
  }