@wildshard/engine 0.1.17 → 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 (343) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +21 -0
  5. package/lint/host-callback-syntax.mjs +2 -1
  6. package/lint/host-callbacks.mjs +3 -3
  7. package/lint/host-files.mjs +5 -4
  8. package/lint/no-base64.mjs +3 -1
  9. package/lint/ratchet.json +0 -68
  10. package/lint/ratchet.mjs +1 -4
  11. package/lint/shard-imports.mjs +6 -7
  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 +22 -23
  18. package/package.json +25 -16
  19. package/scripts/agent-sync.mjs +27 -8
  20. package/scripts/app-build/appCook.ts +8 -2
  21. package/scripts/app-build/catalogue.ts +10 -7
  22. package/scripts/app-build/gen.ts +22 -2
  23. package/scripts/app-build/isolation.d.mts +10 -0
  24. package/scripts/app-build/isolation.mjs +47 -0
  25. package/scripts/app-build/outputProducts.d.mts +3 -0
  26. package/scripts/app-build/outputProducts.mjs +35 -0
  27. package/scripts/app-build/previousDeploy.d.mts +2 -0
  28. package/scripts/app-build/previousDeploy.mjs +10 -1
  29. package/scripts/app-build/serviceWorker.ts +10 -3
  30. package/scripts/app-build/splitOutput.mjs +4 -2
  31. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  32. package/scripts/app-build/standaloneOutput.mjs +5 -3
  33. package/scripts/app-build/titlePreloads.d.mts +8 -0
  34. package/scripts/app-build/titlePreloads.mjs +69 -0
  35. package/scripts/app-build/worldMapAtlas.ts +10 -6
  36. package/scripts/app-build-pipeline.mjs +34 -3
  37. package/scripts/built-product.mjs +1 -1
  38. package/scripts/cell-mem-bench.mjs +81 -23
  39. package/scripts/check-custom-sections-zero.mjs +1 -1
  40. package/scripts/check-devserver.mjs +3 -1
  41. package/scripts/check-models.mjs +2 -0
  42. package/scripts/check-paths.allow.json +0 -115
  43. package/scripts/check-paths.mjs +2 -2
  44. package/scripts/check-platform-ratchets.mjs +2 -3
  45. package/scripts/chromium-keychain-check.mjs +4 -2
  46. package/scripts/chromium-keychain.d.mts +1 -1
  47. package/scripts/chromium-keychain.mjs +3 -1
  48. package/scripts/ci-static.sh +1 -1
  49. package/scripts/committed-fast-checks.mjs +0 -2
  50. package/scripts/content-sw-proof.mjs +2 -1
  51. package/scripts/cook-worker.mjs +9 -3
  52. package/scripts/cook.mjs +20 -3
  53. package/scripts/devices.d.mts +4 -0
  54. package/scripts/devices.mjs +39 -0
  55. package/scripts/devserver-client.d.mts +4 -2
  56. package/scripts/devserver-client.mjs +25 -8
  57. package/scripts/docs-inputs-proof.mjs +6 -6
  58. package/scripts/doctor-proof.mjs +1 -1
  59. package/scripts/e2e-faults.mjs +159 -0
  60. package/scripts/e7-voice-staging-proof.mjs +1 -1
  61. package/scripts/gate-related-tests.mjs +1 -1
  62. package/scripts/git-source-view.mjs +1 -1
  63. package/scripts/goldens/capture.mjs +17 -5
  64. package/scripts/grid-crossing-nightly.mjs +59 -0
  65. package/scripts/grid-crossing-qa.mjs +44 -0
  66. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  67. package/scripts/grid-crossing-ratchet.mjs +52 -0
  68. package/scripts/grid-crossing-report.mjs +122 -0
  69. package/scripts/grid-crossing-stages.mjs +47 -0
  70. package/scripts/grid-crossing-tour.mjs +277 -0
  71. package/scripts/grid-crossing-walk-proof.mjs +136 -18
  72. package/scripts/host-ruler/roots.mjs +2 -2
  73. package/scripts/host-ruler.d.mts +91 -0
  74. package/scripts/host-ruler.mjs +565 -0
  75. package/scripts/live-prepush.py +3 -5
  76. package/scripts/loading-flow/benchmax.mjs +3 -1
  77. package/scripts/look-loop/test_look_loop.py +1 -38
  78. package/scripts/memory-proof.mjs +213 -0
  79. package/scripts/mmo-bots.mjs +8 -2
  80. package/scripts/net-lag-proof.mjs +219 -0
  81. package/scripts/night-market-kit-budget.mjs +2 -2
  82. package/scripts/offline-proof-rules.d.mts +5 -3
  83. package/scripts/offline-proof-rules.mjs +34 -7
  84. package/scripts/offline-proof.mjs +88 -18
  85. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  86. package/scripts/page-release/content.d.mts +9 -1
  87. package/scripts/page-release/content.mjs +131 -17
  88. package/scripts/page-release/flow.mjs +36 -10
  89. package/scripts/page-release/stamp-content.mjs +24 -0
  90. package/scripts/page-release.mjs +28 -6
  91. package/scripts/page-size.mjs +2 -1
  92. package/scripts/pin-packs.ts +1 -1
  93. package/scripts/pins.ts +4 -4
  94. package/scripts/precommit-checks.mjs +1 -7
  95. package/scripts/precommit-jobs.mjs +0 -1
  96. package/scripts/precommit-source.py +1 -9
  97. package/scripts/program-discovery.mjs +1 -1
  98. package/scripts/ring-cook.mjs +2 -1
  99. package/scripts/ring-step.ts +1 -1
  100. package/scripts/script-scenario-metrics.mjs +1 -1
  101. package/scripts/shard-output-content.d.mts +1 -1
  102. package/scripts/shard-output-content.mjs +2 -2
  103. package/scripts/shard-outputs.mjs +1 -1
  104. package/scripts/shard-public.mjs +1 -1
  105. package/scripts/shard-wire-meter.mjs +24 -9
  106. package/scripts/side-parity.mjs +4 -2
  107. package/scripts/standalone-smoke.mjs +8 -3
  108. package/scripts/tier-textures-proof.mjs +101 -0
  109. package/scripts/tier-textures.mjs +78 -0
  110. package/scripts/tile-bake-report.mjs +1 -1
  111. package/scripts/tile-bakes.mjs +1 -1
  112. package/scripts/title-assets.generated.json +2 -0
  113. package/scripts/tsconfig.json +1 -2
  114. package/scripts/vendor/basisu/LICENSE +201 -0
  115. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  116. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  117. package/scripts/vitest-push-guards.config.ts +1 -1
  118. package/scripts/vps/harden-apply.sh +4 -1
  119. package/scripts/vps/harden-prometheus.sh +176 -0
  120. package/scripts/vps/harden.sh +16 -0
  121. package/scripts/vps/rebuild.sh +18 -0
  122. package/scripts/vps/wildshard-config +84 -24
  123. package/scripts/worker-client-play.mjs +7 -2
  124. package/scripts/worker-client-proof.mjs +1 -1
  125. package/scripts/worker-client-slug.mjs +44 -0
  126. package/scripts/worktree-reap.mjs +5 -5
  127. package/src/.oxlintrc.json +3 -182
  128. package/src/client/app/entry.ts +47 -12
  129. package/src/client/engine/boot/bootCache.ts +2 -2
  130. package/src/client/engine/boot/bootTrace.ts +12 -4
  131. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  132. package/src/client/engine/boot/clearDownloads.ts +5 -2
  133. package/src/client/engine/boot/contentRead.ts +11 -0
  134. package/src/client/engine/boot/gpuFiles.ts +4 -2
  135. package/src/client/engine/boot/lastEnd.ts +99 -12
  136. package/src/client/engine/boot/parsedPages.ts +127 -58
  137. package/src/client/engine/boot/texturePack.ts +2 -2
  138. package/src/client/engine/build.d.ts +2 -0
  139. package/src/client/engine/core/Game.ts +18 -0
  140. package/src/client/engine/core/bootstrap.ts +4 -1
  141. package/src/client/engine/debug/probe.ts +18 -1
  142. package/src/client/engine/fx/LightPool.ts +41 -1
  143. package/src/client/engine/net/netPlayer.ts +19 -2
  144. package/src/client/engine/net/otherPlayers.ts +55 -8
  145. package/src/client/engine/net/predictor.ts +33 -9
  146. package/src/client/engine/net/redial.ts +29 -6
  147. package/src/client/engine/pwa/cacheNames.ts +58 -1
  148. package/src/client/engine/pwa/sw.js +53 -14
  149. package/src/client/engine/render/dataLook.ts +152 -40
  150. package/src/client/engine/render/families/detail.ts +89 -0
  151. package/src/client/engine/render/families/pbr.ts +7 -1
  152. package/src/client/engine/render/look.ts +6 -0
  153. package/src/client/engine/render/lookLight.ts +103 -11
  154. package/src/client/engine/render/lookRender.ts +105 -0
  155. package/src/client/engine/render/precompile.ts +20 -14
  156. package/src/client/engine/saves/indexed.ts +2 -2
  157. package/src/client/engine/telemetry/browserErrors.ts +28 -4
  158. package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
  159. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  160. package/src/client/engine/ui/debugOptions.ts +1 -1
  161. package/src/client/engine/ui/lookLightOption.ts +10 -6
  162. package/src/client/engine/ui/namePrompt.ts +7 -0
  163. package/src/client/game/boot/audio.generated.ts +114 -216
  164. package/src/client/game/boot/bytes.generated.ts +118 -238
  165. package/src/client/game/boot/placedSpawn.ts +35 -0
  166. package/src/client/game/boot/spawnDownload.ts +25 -6
  167. package/src/client/game/boot/versions.generated.ts +7 -7
  168. package/src/client/game/devScene/hook.ts +291 -0
  169. package/src/client/game/grid/area.ts +38 -0
  170. package/src/client/game/grid/cellLoading.ts +12 -2
  171. package/src/client/game/grid/live.ts +134 -12
  172. package/src/client/game/grid/liveSession.ts +47 -5
  173. package/src/client/game/grid/mapAtlas.ts +18 -4
  174. package/src/client/game/grid/menu.ts +4 -0
  175. package/src/client/game/grid/minimapBlend.ts +15 -5
  176. package/src/client/game/grid/neighbourPanels.ts +10 -1
  177. package/src/client/game/grid/oneWayIn.ts +5 -1
  178. package/src/client/game/grid/placedCards.ts +55 -0
  179. package/src/client/game/grid/placedCells.ts +233 -0
  180. package/src/client/game/grid/placedContent.ts +85 -0
  181. package/src/client/game/grid/prefetch.ts +9 -1
  182. package/src/client/game/grid/productInputs.ts +3 -1
  183. package/src/client/game/grid/productLeases.ts +4 -1
  184. package/src/client/game/grid/products.ts +8 -4
  185. package/src/client/game/grid/regionalRuntime.ts +6 -0
  186. package/src/client/game/grid/regionalWorld.ts +15 -2
  187. package/src/client/game/grid/roadCull.ts +44 -14
  188. package/src/client/game/grid/roadLook.ts +24 -15
  189. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  190. package/src/client/game/grid/roadResources.ts +24 -0
  191. package/src/client/game/grid/roadSign.worker.ts +4 -3
  192. package/src/client/game/grid/roadSignPaint.ts +16 -5
  193. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  194. package/src/client/game/grid/roadSignScale.ts +8 -0
  195. package/src/client/game/grid/roadTileBacking.ts +13 -3
  196. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  197. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  198. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  199. package/src/client/game/grid/roadTileWriter.ts +2 -1
  200. package/src/client/game/grid/screenReports.ts +39 -0
  201. package/src/client/game/grid/session.ts +29 -4
  202. package/src/client/game/grid/shardfileFar.ts +9 -3
  203. package/src/client/game/grid/softWallLook.ts +25 -8
  204. package/src/client/game/mainMenu.ts +6 -2
  205. package/src/client/game/plugin/context.ts +2 -1
  206. package/src/client/game/plugin/followedMovers.ts +7 -1
  207. package/src/client/game/quest/figures.ts +2 -0
  208. package/src/client/game/session/finish.ts +11 -1
  209. package/src/client/game/shard/titleList.ts +6 -2
  210. package/src/client/game/shardfile/assetCache.ts +4 -4
  211. package/src/client/game/shardfile/client.ts +4 -1
  212. package/src/client/game/shardfile/clientAssets.ts +9 -5
  213. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  214. package/src/client/game/shardfile/clientWater.ts +51 -9
  215. package/src/client/game/shardfile/clientWorker.ts +21 -8
  216. package/src/client/game/shardfile/look.ts +8 -3
  217. package/src/client/game/shardfile/product.ts +34 -7
  218. package/src/client/game/shardfile/productChecks.ts +2 -2
  219. package/src/client/game/shardfile/productCost.ts +2 -2
  220. package/src/client/game/shardfile/readAsset.ts +2 -2
  221. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  222. package/src/client/game/shardfile/seatGrace.ts +9 -0
  223. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  224. package/src/client/game/systems/npc/figureRows.ts +9 -0
  225. package/src/client/game/titleDeck.ts +4 -3
  226. package/src/client/host/online/doctor.ts +2 -0
  227. package/src/client/host/online/linkScreens.ts +30 -4
  228. package/src/client/host/online/shell.ts +14 -0
  229. package/src/client/host/standalone/shell.ts +4 -0
  230. package/src/cook/game/astc6Encode.ts +55 -0
  231. package/src/cook/game/astc6Wasm.ts +176 -0
  232. package/src/cook/game/cookJob.ts +30 -6
  233. package/src/cook/game/cookWorker.ts +38 -11
  234. package/src/cook/game/entryTotals.ts +51 -24
  235. package/src/cook/game/shardCook.ts +67 -9
  236. package/src/cook/game/spawnParts.ts +33 -8
  237. package/src/cook/game/tierTextures.ts +349 -0
  238. package/src/e2e/smoke/game.ts +19 -14
  239. package/src/e2e/smoke/page-globals.d.ts +9 -8
  240. package/src/e2e/smoke/template2.spec.ts +8 -7
  241. package/src/server/engine/ai/bossContenders.ts +27 -3
  242. package/src/server/engine/ai/phases.ts +1 -1
  243. package/src/server/engine/entities/creatureRefill.ts +9 -2
  244. package/src/server/engine/net/ledgerBook.ts +2 -0
  245. package/src/server/engine/net/room.ts +15 -0
  246. package/src/server/engine/sim/respawn.ts +8 -0
  247. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  248. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  249. package/src/server/game/boss/native.ts +2 -1
  250. package/src/server/game/boss/nativeWake.ts +9 -5
  251. package/src/server/game/boss/openArenaNative.ts +2 -2
  252. package/src/server/game/boss/openArenaRoom.ts +3 -1
  253. package/src/server/game/grid/room.ts +44 -3
  254. package/src/server/game/grid/simulation.ts +23 -0
  255. package/src/server/game/population/mixedRoster.ts +11 -3
  256. package/src/server/game/population/nativeBake.ts +8 -3
  257. package/src/server/game/population/nativeReturns.ts +6 -3
  258. package/src/server/game/population/roster.ts +5 -3
  259. package/src/server/game/quest/eliteDrops.ts +15 -4
  260. package/src/server/game/quest/nativeChapter.ts +1 -1
  261. package/src/server/game/quest/nativeComposition.ts +5 -1
  262. package/src/server/game/riding/nativeTaming.ts +10 -6
  263. package/src/server/game/riding/wildRefill.ts +3 -2
  264. package/src/server/game/shardfile/bossRow.ts +4 -2
  265. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  266. package/src/server/host/bake/headlessWorker.ts +1 -1
  267. package/src/server/host/dedicated/cellHost.ts +98 -16
  268. package/src/server/host/dedicated/cellProtocol.ts +16 -1
  269. package/src/server/host/dedicated/cellWorker.ts +8 -5
  270. package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
  271. package/src/server/host/dedicated/gridCells.ts +15 -6
  272. package/src/server/host/dedicated/loopLag.ts +21 -0
  273. package/src/server/host/dedicated/main.ts +13 -5
  274. package/src/server/host/dedicated/packReader.ts +3 -3
  275. package/src/server/host/dedicated/placementFile.ts +4 -19
  276. package/src/server/host/dedicated/roadRoom.ts +34 -4
  277. package/src/server/host/dedicated/serverMetrics.ts +126 -0
  278. package/src/server/host/dedicated/socketPump.ts +21 -4
  279. package/src/server/host/dedicated/socketTransport.ts +2 -1
  280. package/src/server/host/dedicated/workerTable.ts +15 -4
  281. package/src/server/host/dedicated/world.ts +95 -8
  282. package/src/server/host/headless.ts +1 -1
  283. package/src/server/host/headlessRuntime.ts +1 -1
  284. package/src/server/host/standalone/roadWorld.ts +15 -3
  285. package/src/server/host/standalone/serverHost.ts +4 -1
  286. package/src/server/host/standalone/serverProduct.ts +41 -11
  287. package/src/shared/engine/ai/BossBrain.ts +8 -0
  288. package/src/shared/engine/net/deviceWord.ts +138 -0
  289. package/src/shared/engine/net/socketFrames.ts +7 -4
  290. package/src/shared/game/boss/wake.ts +6 -0
  291. package/src/shared/game/devColliders.ts +47 -0
  292. package/src/shared/game/eliteSystem.ts +8 -0
  293. package/src/shared/game/grid/allocator.ts +3 -0
  294. package/src/shared/game/grid/catalogueSlot.ts +7 -0
  295. package/src/shared/game/grid/placementRows.ts +36 -0
  296. package/src/shared/game/plugin/bossRecord.ts +3 -2
  297. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  298. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  299. package/src/shared/game/shardfile/packReads.ts +28 -3
  300. package/src/shared/game/shardfile/serverPack.ts +9 -0
  301. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  302. package/src/shared/host/formatJsonSchema.ts +2 -2
  303. package/src/tsconfig.json +1 -27
  304. package/lint/host-reviews.json +0 -14
  305. package/lint/listed-view-code.json +0 -13
  306. package/lint/platform-pending-users.json +0 -2520
  307. package/lint/platform-pending-users.md +0 -18
  308. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  309. package/scripts/check-closed-components.d.mts +0 -7
  310. package/scripts/check-closed-components.mjs +0 -87
  311. package/scripts/g571-hosts.d.mts +0 -3
  312. package/scripts/g571-hosts.mjs +0 -54
  313. package/scripts/host-ruler/register-migrate.mjs +0 -242
  314. package/scripts/listed-view-code.d.mts +0 -7
  315. package/scripts/listed-view-code.mjs +0 -93
  316. package/scripts/look-loop/fit-lut.py +0 -142
  317. package/scripts/look-loop/palette-delta.py +0 -183
  318. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  319. package/scripts/look-loop/regions/far-reach.json +0 -225
  320. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  321. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  322. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  323. package/scripts/platform-chargebacks.d.mts +0 -9
  324. package/scripts/platform-chargebacks.mjs +0 -135
  325. package/scripts/shard-component-spans.d.mts +0 -15
  326. package/scripts/shard-component-spans.mjs +0 -18
  327. package/scripts/shard-components.d.mts +0 -16
  328. package/scripts/shard-components.mjs +0 -363
  329. package/scripts/shard-platform-hosts.d.mts +0 -2
  330. package/scripts/shard-platform-hosts.mjs +0 -93
  331. package/scripts/shard-platform-sections.d.mts +0 -2
  332. package/scripts/shard-platform-sections.mjs +0 -9
  333. package/scripts/shard-platform.d.mts +0 -76
  334. package/scripts/shard-platform.mjs +0 -1072
  335. package/src/.oxfmtrc.json +0 -48
  336. package/src/scripts/ask-new.sh +0 -29
  337. package/src/scripts/asks.mjs +0 -142
  338. package/src/scripts/herdr-prompt.sh +0 -34
  339. package/src/scripts/herdr-question-open.sh +0 -67
  340. package/src/scripts/md-wrap.mjs +0 -229
  341. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  342. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  343. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env python3
2
- """The look loop's Python logic: CIEDE2000 against Sharma, Wu and Dalal's (2005) reference pairs, the sRGB to Lab
3
- conversion, capture-pattern globbing, and targets.py's capture finding and seed-mode prompts. Run by
2
+ """The look loop's Python logic: targets.py's capture finding, seed-mode prompts and job polling. Run by
4
3
  test/look-loop.test.ts; standalone: python3 scripts/look-loop/test_look_loop.py"""
5
4
  import importlib.util
6
5
  import tempfile
@@ -17,47 +16,11 @@ def load(name, file):
17
16
  return mod
18
17
 
19
18
 
20
- try: # palette-delta.py needs numpy and Pillow; hosted CI's Python has neither, so its checks run where they exist
21
- import numpy, PIL # noqa: F401
22
- PD = load('palette_delta', 'palette-delta.py')
23
- except ImportError:
24
- PD = None
25
19
  TG = load('targets', 'targets.py')
26
20
  SCRATCH = HERE.parent.parent / 'tmp' if (HERE.parent.parent / 'tmp').is_dir() else None # the repo's tmp/, not /tmp
27
- NEEDS = unittest.skipUnless(PD, 'numpy and Pillow are not installed')
28
-
29
-
30
- @NEEDS
31
- class DeltaE(unittest.TestCase):
32
- def test_sharma_pairs(self):
33
- pairs = [
34
- ((50.0, 2.6772, -79.7751), (50.0, 0.0, -82.7485), 2.0425),
35
- ((50.0, 0.0, 0.0), (50.0, -1.0, 2.0), 2.3669),
36
- ((50.0, 2.5, 0.0), (73.0, 25.0, -18.0), 27.1492),
37
- ((60.2574, -34.0099, 36.2677), (60.4626, -34.1751, 39.4387), 1.2644),
38
- ]
39
- for a, b, want in pairs:
40
- self.assertAlmostEqual(PD.ciede2000(a, b), want, places=3)
41
- self.assertAlmostEqual(PD.ciede2000(b, a), want, places=3)
42
-
43
- def test_identity_and_lab(self):
44
- self.assertEqual(PD.ciede2000((40, 10, -5), (40, 10, -5)), 0.0)
45
- L, a, b = PD.srgb_to_lab((255, 255, 255))
46
- self.assertAlmostEqual(L, 100, delta=0.05); self.assertAlmostEqual(a, 0, delta=0.05); self.assertAlmostEqual(b, 0, delta=0.05)
47
- L, a, b = PD.srgb_to_lab((255, 0, 0))
48
- self.assertAlmostEqual(L, 53.24, delta=0.1); self.assertAlmostEqual(a, 80.09, delta=0.2); self.assertAlmostEqual(b, 67.20, delta=0.2)
49
21
 
50
22
 
51
23
  class Files(unittest.TestCase):
52
- @NEEDS
53
- def test_frame_path(self):
54
- with tempfile.TemporaryDirectory(dir=SCRATCH) as d:
55
- for name in ['capture-1-fp-front.jpg', 'r2-capture-1-fp-front.jpg']:
56
- (Path(d) / name).write_bytes(b'x')
57
- self.assertEqual(PD.frame_path(f'{d}/capture-{{n}}-*.jpg', 1).name, 'capture-1-fp-front.jpg')
58
- self.assertIsNone(PD.frame_path(f'{d}/capture-{{n}}-*.jpg', 2))
59
- self.assertEqual(PD.frame_path(f'{d}/r2-capture-{{n}}-*.jpg', 1).name, 'r2-capture-1-fp-front.jpg')
60
-
61
24
  def test_captures(self):
62
25
  with tempfile.TemporaryDirectory(dir=SCRATCH) as d:
63
26
  for name in ['capture-1-fp-front.jpg', 'capture-5-top.jpg', 'r2-capture-1-fp-front.jpg', 'mockup-1-fp-front.jpg']:
@@ -0,0 +1,213 @@
1
+ #!/usr/bin/env node
2
+ // IOSMEM (meta PAGE-SIZE-PLAN): the iPhone page-memory proof for Driftwood Isle, after WILDSHARD-GAME-8G (Jake 2026-11-13:
3
+ // staging v0.1.16 restarted while Playing on Driftwood on his iPhone 17 Pro, the page killed for memory). One command reads
4
+ // the page's memory at boot (title), in Playing on Driftwood, and at Driftwood's west edge where Sunscar's cell prepares:
5
+ // the owner ledger (`__wildshard.memory()`, GPU and RAM bytes by owner and kind), three.js's counts, the texture form this
6
+ // device loads, the grid's resident cells and claims, the JS heap (Chromium) and, on Chromium, the renderer and GPU
7
+ // process footprints. Phone tier, iPhone 17 Pro viewport (402x874, 3x pixel density), headless.
8
+ // scripts/browser-lane.sh node scripts/memory-proof.mjs --base=<staging or loopback url> [--engine=chromium|webkit]
9
+ // [--out=tmp/<lane>/memory-proof] [--label=<name>] [--edge=0] [--budget-mb=<n>] [--dump]
10
+ // --inspector-buffers=keep: the old launch, whose DevTools Network sessions buffer every response body (~500 MB here).
11
+ // --dump (Chromium, PZ24): a memory-infra dump at every phase, the renderer's footprint by allocator (V8, PartitionAlloc's
12
+ // array buffers, malloc, Oilpan, Skia, GPU shared memory), so what holds the process is read, not guessed.
13
+ // --budget-mb fails the run (exit 1) when the ledger's GPU+RAM peak passes n MB: the gate a later lane can hold.
14
+ import { spawnSync } from 'node:child_process';
15
+ import { mkdirSync, writeFileSync } from 'node:fs';
16
+ import { join, resolve as absolute } from 'node:path';
17
+ import { chromium, webkit } from 'playwright';
18
+ import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
19
+ import { launchMemoryBrowser } from './chromium-memory-browser.mjs';
20
+ import { saveFixture } from './debug-settings.mjs';
21
+ import { pageMemoryAttributionExpression } from './memory-report-snapshot.mjs';
22
+
23
+ /** @type {Record<string, string>} */
24
+ const args = Object.fromEntries(process.argv.slice(2).map(arg => /^--([^=]+)(?:=(.*))?$/u.exec(arg)).filter(match => match !== null).map(match => [match[1], match.at(2) ?? '1']));
25
+ const base = (args.base ?? '').replace(/\/$/u, '');
26
+ if (!/^https:\/\/(staging|preview)\.wildshard\.io$|^http:\/\/(127\.0\.0\.1|localhost):\d+$/u.test(base)) throw new Error('--base takes staging, preview or a loopback page: never production (J205)');
27
+ const engineName = args.engine ?? 'chromium';
28
+ if (engineName !== 'chromium' && engineName !== 'webkit') throw new Error(`No engine ${engineName}`);
29
+ const label = args.label ?? `${engineName}-${new URL(base).host.replaceAll(/[^a-z0-9]+/giu, '-')}`;
30
+ const out = absolute(args.out ?? 'tmp/memory-proof');
31
+ const budgetMB = args['budget-mb'] === undefined ? null : Number(args['budget-mb']);
32
+ const edge = args.edge !== '0';
33
+ mkdirSync(out, { recursive: true });
34
+ const MB = 1048576;
35
+ /** @param {number} ms */
36
+ const sleep = ms => new Promise(resolve => { setTimeout(resolve, ms); });
37
+
38
+ const FOOTPRINT = String.raw`
39
+ import ctypes, json, sys
40
+ class R(ctypes.Structure):
41
+ _fields_ = [('uuid', ctypes.c_ubyte * 16)] + [(n, ctypes.c_uint64) for n in ('user_time','system_time','pkg_idle_wkups','interrupt_wkups','pageins','wired_size','resident_size','phys_footprint','proc_start_abstime','proc_exit_abstime')]
42
+ lib = ctypes.CDLL('/usr/lib/libproc.dylib'); out = {}
43
+ for p in sys.argv[1:]:
44
+ u = R()
45
+ out[p] = u.phys_footprint if lib.proc_pid_rusage(int(p), 0, ctypes.byref(u)) == 0 else None
46
+ print(json.dumps(out))
47
+ `;
48
+
49
+ /** In-page reader: plain data only, never a resource getter that could rebuild a retired resource. */
50
+ const PAGE_READ = `(() => {
51
+ const api = window.__wildshard, mem = (() => { try { return ${pageMemoryAttributionExpression}; } catch (e) { return { error: String(e) }; } })();
52
+ const group = (rows, key) => { const m = new Map(); for (const r of rows) { const k = key(r); const v = m.get(k) ?? { bytes: 0, n: 0 }; v.bytes += r.bytes; v.n++; m.set(k, v); }
53
+ return [...m.entries()].map(([k, v]) => ({ k, mb: Math.round(v.bytes / 1048576 * 10) / 10, n: v.n })).sort((a, b) => b.mb - a.mb).slice(0, 25); };
54
+ const rows = Array.isArray(mem?.allocations) ? mem.allocations : [];
55
+ let grid = null; try { const g = api?.shard?.grid; if (g) { const st = g.state(), res = g.residency?.();
56
+ grid = { inside: st.inside, home: st.home, feet: st.feet, residentMB: st.residentMB, playingMB: st.playingMB, strips: st.strips,
57
+ cells: st.cells.map(c => ({ slug: c.slug, cell: c.cell, shows: c.shows, drawn: c.drawn })), rings: { far: st.rings.far, l1: st.rings.l1, l0: st.rings.l0, inFlight: st.rings.inFlight, queued: st.rings.queued },
58
+ near: st.near, claims: res ? res.claims.map(c => ({ id: c.id ?? c.instance ?? c.key, bytes: c.bytes, kind: c.kind ?? c.category })) : null, cost: res?.cost ?? null }; } } catch (e) { grid = { error: String(e).slice(0, 200) }; }
59
+ let three = null; try { const r = api.requireWorld().game.renderer; three = { textures: r.info.memory.textures, geometries: r.info.memory.geometries, programs: r.info.programs?.length ?? null, pixelRatio: r.getPixelRatio() }; } catch {}
60
+ let textures = null; try { const t = api.textures?.(); textures = t ? { mode: t.mode, why: t.why, families: t.probe?.families ?? null } : null; } catch (e) { textures = { error: String(e).slice(0, 120) }; }
61
+ let audio = null; try { audio = api.requireWorld().audio.census(); } catch {}
62
+ return { href: location.href, heapMB: performance.memory ? Math.round(performance.memory.usedJSHeapSize / 1048576) : null,
63
+ totalsMB: mem?.totals ? { gpu: Math.round(mem.totals.gpu / 1048576), ram: Math.round(mem.totals.ram / 1048576) } : null,
64
+ unattributedMB: mem?.unattributed ? { gpu: Math.round(mem.unattributed.gpu / 1048576), ram: Math.round(mem.unattributed.ram / 1048576) } : null,
65
+ byOwner: group(rows, r => r.domain + ' ' + r.owner), byKind: group(rows, r => r.domain + ' ' + r.kind), byAsset: group(rows, r => r.domain + ' ' + r.owner + ' ' + r.asset),
66
+ // PZ22: each texture of 1 MB or more, whole, so a texture form change is read per texture, not only in the total
67
+ texRows: rows.filter(r => r.domain === 'gpu' && r.kind === 'texture' && r.bytes >= 1048576).sort((a, b) => b.bytes - a.bytes).slice(0, 40).map(r => JSON.parse(JSON.stringify(r))),
68
+ three, textures, grid, audio };
69
+ })()`;
70
+
71
+ /** @type {Record<string, unknown>} */
72
+ const result = { lane: 'opus-iosmem', engine: engineName, base, label, at: new Date().toISOString(), phases: [], errors: [] };
73
+ // PZ24: Chromium through launchMemoryBrowser, so Playwright's Network sessions (the page's and every worker's) keep no
74
+ // response bodies. Before, DevTools' NetworkResourcesData held ~500 MB of the game's fetched bytes in the renderer's
75
+ // buffer partition (memory-infra, after a full GC), a cost a player's phone, with no inspector attached, never has.
76
+ const chromiumArgs = ['--use-angle=metal', '--ignore-gpu-blocklist', '--enable-precise-memory-info', ...args.dump === undefined ? [] : ['--js-flags=--expose-gc']];
77
+ const launched = engineName === 'webkit' ? webkit.launch({ headless: true }).then(browser => ({ browser, close: () => browser.close() }))
78
+ : args['inspector-buffers'] === 'keep' ? chromium.launch({ headless: true, args: [...KEYCHAIN_ARGS, ...chromiumArgs] }).then(browser => ({ browser, close: () => browser.close() }))
79
+ : launchMemoryBrowser(chromiumArgs);
80
+ const { browser, close: closeBrowser } = await launched;
81
+ let code = 0;
82
+ try {
83
+ const context = await browser.newContext({ viewport: { width: 402, height: 874 }, deviceScaleFactor: 3, isMobile: engineName === 'chromium', hasTouch: true,
84
+ userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/27.0.1 Mobile/15E148 Safari/604.1' });
85
+ await saveFixture(context, { scope: 'device', key: 'firstPlayDone', data: true });
86
+ await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
87
+ await saveFixture(context, { scope: 'global', key: 'settings', merge: true, data: { tier: 'phone', volume: 0 } });
88
+ await context.route('**/api/errors', route => route.fulfill({ status: 204, body: '' }));
89
+ const page = await context.newPage(); page.setDefaultTimeout(240_000);
90
+ page.on('pageerror', error => { /** @type {string[]} */ (result.errors).push(error.message.slice(0, 240)); });
91
+ const cdp = engineName === 'chromium' ? await browser.newBrowserCDPSession() : null;
92
+ const pageCdp = engineName === 'chromium' ? await context.newCDPSession(page) : null;
93
+ const heapProfile = args['heap-profile'] !== undefined && pageCdp !== null;
94
+ /** Chromium only: the live JS heap after a full collection, so garbage awaiting GC is told apart from what is held. */
95
+ const heapAfterGc = async () => { if (pageCdp === null) return null; await pageCdp.send('HeapProfiler.collectGarbage');
96
+ // --dump: the workers' isolates too (an idle worker may never collect on its own)
97
+ if (args.dump !== undefined) for (const worker of page.workers()) await worker.evaluate('globalThis.gc?.()').catch(() => undefined); return Math.round((await pageCdp.send('Runtime.getHeapUsage')).usedSize / MB); };
98
+ const footprint = async () => {
99
+ if (cdp === null) return null;
100
+ const info = await cdp.send('SystemInfo.getProcessInfo'), pids = info.processInfo.filter(row => row.type === 'renderer' || row.type === 'GPU');
101
+ const sizes = JSON.parse(spawnSync('python3', ['-c', FOOTPRINT, ...pids.map(row => String(row.id))], { encoding: 'utf8' }).stdout || '{}');
102
+ const mb = (/** @type {string} */ type) => Math.round(pids.filter(row => row.type === type).reduce((sum, row) => sum + (sizes[String(row.id)] ?? 0), 0) / MB);
103
+ return { rendererMB: mb('renderer'), gpuMB: mb('GPU') };
104
+ };
105
+ /** PZ24: the renderer's memory-infra allocators at this moment (before the GC heapAfterGc runs), in MB. */
106
+ const allocators = async (deterministic = false) => {
107
+ if (cdp === null || args.dump === undefined) return null;
108
+ /** @type {any[]} */ const events = [];
109
+ const onData = (/** @type {any} */ data) => { events.push(...data.value); };
110
+ cdp.on('Tracing.dataCollected', onData);
111
+ let dumped = { success: false };
112
+ try {
113
+ const done = new Promise(resolve => { cdp.once('Tracing.tracingComplete', resolve); });
114
+ await cdp.send('Tracing.start', { traceConfig: { includedCategories: ['disabled-by-default-memory-infra'],
115
+ // no periodic dumps: only the one requested below (Playwright types the config as string pairs)
116
+ memoryDumpConfig: /** @type {Record<string, string>} */ (/** @type {unknown} */ ({ triggers: [] })) }, transferMode: 'ReportEvents' });
117
+ // deterministic: Chrome collects every isolate (page and workers) first, so freed buffers are not counted
118
+ try { dumped = await cdp.send('Tracing.requestMemoryDump', { deterministic, levelOfDetail: 'detailed' }); }
119
+ finally { await cdp.send('Tracing.end'); await done; }
120
+ } finally { cdp.off('Tracing.dataCollected', onData); }
121
+ const info = await cdp.send('SystemInfo.getProcessInfo'), renderers = new Set(info.processInfo.filter(row => row.type === 'renderer').map(row => row.id));
122
+ /** @type {Record<string, number>} */ const sizes = {};
123
+ for (const event of events) {
124
+ if (event.ph !== 'v' || !renderers.has(event.pid)) continue;
125
+ const all = event.args?.dumps?.allocators ?? {};
126
+ for (const [name, node] of Object.entries(all)) {
127
+ const depth = name.split('/').length; if (depth > 3 && !(args.dump === 'buckets' && name.startsWith('partition_alloc/partitions/'))) continue;
128
+ const size = node.attrs?.size?.value; if (size === undefined) continue;
129
+ sizes[name] = (sizes[name] ?? 0) + Number.parseInt(size, 16);
130
+ }
131
+ }
132
+ return { ok: dumped.success, mb: Object.fromEntries(Object.entries(sizes).filter(([, b]) => b >= MB).sort((a, b) => b[1] - a[1]).map(([k, b]) => [k, Math.round(b / MB * 10) / 10])) };
133
+ };
134
+ const phase = async (/** @type {string} */ name) => {
135
+ const dump = await allocators();
136
+ const row = { phase: name, ...await page.evaluate(PAGE_READ), process: await footprint(), dump, heapAfterGcMB: await heapAfterGc() };
137
+ if (dump !== null) console.log(` allocators ${JSON.stringify(Object.fromEntries(Object.entries(dump.mb).filter(([k]) => k.split('/').length === 1)))}`);
138
+ row.processAfterGc = pageCdp === null ? null : await footprint();
139
+ row.dumpAfterGc = await allocators(true);
140
+ if (row.dumpAfterGc !== null) console.log(` after GC ${JSON.stringify(Object.fromEntries(Object.entries(row.dumpAfterGc.mb).filter(([k]) => k.split('/').length === 1 || /partitions\/[a-z_]+$|v8\/[a-z]+$/u.test(k))))} workers ${page.workers().length}`);
141
+ /** @type {unknown[]} */ (result.phases).push(row);
142
+ await page.screenshot({ path: join(out, `${label}-${name}.jpg`), type: 'jpeg', quality: 60 }).catch(() => undefined);
143
+ const t = row.totalsMB;
144
+ console.log(`${name}: ledger gpu ${t?.gpu ?? '?'} MB ram ${t?.ram ?? '?'} MB, heap ${row.heapMB ?? '-'} MB (after GC ${row.heapAfterGcMB ?? '-'}), process ${JSON.stringify(row.process)}, three ${JSON.stringify(row.three)}, tex ${row.textures?.mode ?? '?'}, cells ${row.grid?.cells?.map((/** @type {any} */ c) => `${c.slug}:${JSON.stringify(c.shows)}`).join(' ') ?? '-'}`);
145
+ for (const top of row.byOwner.slice(0, 8)) console.log(` ${top.k} ${top.mb} MB (${top.n})`);
146
+ return row;
147
+ };
148
+ await page.goto(`${base}/?mute=1&nolock=1`, { waitUntil: 'load' });
149
+ await page.locator('.ws-main-select').waitFor({ state: 'visible', timeout: 120_000 });
150
+ await sleep(3000);
151
+ await phase('boot');
152
+ await page.locator('.ws-main-select').click();
153
+ if (await page.locator('#ws-name-box input').waitFor({ timeout: 15_000 }).then(() => true).catch(() => false)) { await page.locator('#ws-name-box input').fill('memproof'); await page.locator('#ws-name-box button[type=submit]').click(); }
154
+ await page.locator('.ws-menu-card').first().waitFor({ state: 'visible', timeout: 30_000 });
155
+ const index = await page.evaluate(() => [...document.querySelectorAll('.ws-menu-card')].findIndex(row => (row.textContent ?? '').includes('Driftwood Isle')));
156
+ if (index < 0) throw new Error('No Driftwood Isle card');
157
+ await page.locator('.ws-menu-dots i').nth(index).click();
158
+ if (heapProfile) { await pageCdp.send('HeapProfiler.enable'); await pageCdp.send('HeapProfiler.startSampling', { samplingInterval: 65536, includeObjectsCollectedByMajorGC: args['heap-profile'] === 'alloc', includeObjectsCollectedByMinorGC: args['heap-profile'] === 'alloc' }); }
159
+ await page.locator('.ws-menu-play').click();
160
+ await page.waitForFunction(() => /** @type {any} */ (window).__wildshard?.shard?.grid?.state?.().live?.live?.gameplayReady === true, undefined, { timeout: 240_000, polling: 250 });
161
+ await sleep(2000);
162
+ await page.getByText('DONE', { exact: true }).click({ timeout: 2000 }).catch(() => undefined);
163
+ await sleep(10_000);
164
+ await phase('playing');
165
+ if (args.snapshot !== undefined && pageCdp !== null) {
166
+ // --snapshot: the page's heap at Playing (written beside the json), for a holder the ledger does not name. V8 keeps
167
+ // tracking object moves after it, so the later phases of a --snapshot run read a little high (result.snapshot).
168
+ result.snapshot = true;
169
+ const { createWriteStream } = await import('node:fs'), file = createWriteStream(join(out, `${label}-playing.heapsnapshot`));
170
+ const onChunk = (/** @type {any} */ c) => { file.write(c.chunk); };
171
+ pageCdp.on('HeapProfiler.addHeapSnapshotChunk', onChunk);
172
+ await pageCdp.send('HeapProfiler.takeHeapSnapshot', { reportProgress: false, captureNumericValue: false, exposeInternals: true });
173
+ pageCdp.off('HeapProfiler.addHeapSnapshotChunk', onChunk); await new Promise(resolve => { file.end(resolve); });
174
+ }
175
+ // 40 s more without moving: a page that keeps growing while the player stands still is the leak, not the walk.
176
+ /** @type {unknown[]} */ const still = []; result.still = still;
177
+ for (let i = 0; i < 4; i++) { await sleep(10_000); const at = await page.evaluate(() => ({ heapMB: (() => { const memory = /** @type {any} */ (performance).memory; return memory ? Math.round(memory.usedJSHeapSize / 1048576) : null; })(), loading: /** @type {any} */ (window).__wildshard.shard.grid.state().cells.filter((/** @type {any} */ c) => c.shows === 'loading').length })); still.push({ s: (i + 1) * 10, ...at, process: await footprint() }); console.log(`still +${(i + 1) * 10}s ${JSON.stringify(still.at(-1))}`); }
178
+ await phase('still');
179
+ if (heapProfile) {
180
+ const { profile } = await pageCdp.send('HeapProfiler.stopSampling');
181
+ /** @type {Map<string, number>} */ const self = new Map(), total = new Map();
182
+ const walk = (/** @type {any} */ node, /** @type {string[]} */ stack) => {
183
+ const f = node.callFrame, key = `${f.functionName === '' ? '(anon)' : f.functionName} ${f.url.split('/').pop()}:${f.lineNumber + 1}:${f.columnNumber + 1}`;
184
+ self.set(key, (self.get(key) ?? 0) + node.selfSize);
185
+ const next = [...stack, key]; for (const k of new Set(next)) total.set(k, (total.get(k) ?? 0) + node.selfSize);
186
+ for (const child of node.children) walk(child, next);
187
+ };
188
+ walk(profile.head, []);
189
+ const top = (/** @type {Map<string, number>} */ m) => [...m.entries()].sort((a, b) => b[1] - a[1]).slice(0, 60).map(([k, b]) => ({ k, mb: Math.round(b / MB * 10) / 10 }));
190
+ result.heapSelf = top(self); result.heapTotal = top(total);
191
+ console.log('heap self (live sampled):'); for (const row of /** @type {any[]} */ (result.heapSelf).slice(0, 25)) console.log(` ${row.mb} MB ${row.k}`);
192
+ }
193
+ if (edge) {
194
+ // Driftwood's west entryway toward Sunscar (grid-crossing-walk-proof's approach), placed by the harness pose, then 20 s for the neighbour to prepare.
195
+ for (const [x, z] of [[-235, -194], [-235, 0], [-245, 0]]) {
196
+ // the online page's server owns the position: place tells it (probe.ts `told`)
197
+ await page.evaluate(([px, pz]) => { const p = /** @type {any} */ (window).__wildshard.world.player; p.spawn(px, pz, p.yaw, Math.max(p.position.y, 0.5)); p.link?.place?.(p.position.x, p.position.y, p.position.z, p.yaw); }, [x, z]);
198
+ await sleep(4000);
199
+ }
200
+ await sleep(16_000);
201
+ await phase('edge');
202
+ }
203
+ const peak = Math.max(...(/** @type {any[]} */ (result.phases)).map(row => (row.totalsMB?.gpu ?? 0) + (row.totalsMB?.ram ?? 0)));
204
+ result.peakLedgerMB = peak;
205
+ if (budgetMB !== null && peak > budgetMB) { code = 1; console.log(`FAIL ledger peak ${peak} MB > budget ${budgetMB} MB`); }
206
+ await context.close();
207
+ } catch (error) { code = 1; /** @type {string[]} */ (result.errors).push(String(error).slice(0, 400)); console.log(`FAIL ${String(error).slice(0, 400)}`); }
208
+ finally {
209
+ writeFileSync(join(out, `${label}.json`), `${JSON.stringify(result, null, 2)}\n`);
210
+ await closeBrowser();
211
+ }
212
+ console.log(`memory proof ${label}: ${code === 0 ? 'done' : 'FAIL'} → ${join(out, `${label}.json`)}`);
213
+ process.exit(code);
@@ -6,6 +6,7 @@
6
6
  // node scripts/mmo-bots.mjs replica [--remote wildshard] --server-from <main commit> ... (MP1.2: that commit's server code)
7
7
  // node scripts/mmo-bots.mjs replica --remote wildshard-agent --bots-on-host [--bot-cpus 14-15] ... (MP1.2: bots on the box too)
8
8
  // node scripts/mmo-bots.mjs staging [--bots 2] [--seconds 60] (at most 4: one address)
9
+ // node scripts/mmo-bots.mjs staging --tailnet ... (NET-LAG NL3: the same, over staging's tailnet Serve address, no Cloudflare)
9
10
  // Both read the signed staging release file and check it against the public key setup.sh pins. The bots are built from that
10
11
  // release's own commit (its tree, an offline install, build-server's `--entry`), so their build and wire are the server's.
11
12
  // `replica` runs that release's exact server bundle (downloaded, SHA-256 checked) on loopback, with production's shape: its
@@ -46,7 +47,7 @@ const [mode = '', ...rest] = process.argv.slice(2);
46
47
  const { values } = parseArgs({ args: rest, options: { bots: { type: 'string' }, seconds: { type: 'string' }, seats: { type: 'string', default: '32' }, workers: { type: 'string', default: '4' },
47
48
  cells: { type: 'string', default: 'driftwood-isle' }, database: { type: 'string', default: 'memory:' }, keep: { type: 'boolean', default: false },
48
49
  remote: { type: 'string' }, cpus: { type: 'string', default: '9-13' }, 'server-from': { type: 'string' },
49
- 'bots-on-host': { type: 'boolean', default: false }, 'bot-cpus': { type: 'string', default: '14-15' } } });
50
+ 'bots-on-host': { type: 'boolean', default: false }, 'bot-cpus': { type: 'string', default: '14-15' }, tailnet: { type: 'boolean', default: false } } });
50
51
  const serverFrom = values['server-from'];
51
52
  if (serverFrom !== undefined && (mode !== 'replica' || !/^[0-9a-f]{40}$/u.test(serverFrom))) throw new Error('--server-from is a full commit, for a replica');
52
53
  // These reach the host's shell inside the replica's env line: only slugs and whole numbers.
@@ -152,7 +153,12 @@ process.once('exit', () => { for (const child of [botsChild, room]) if (child !=
152
153
  try {
153
154
  /** @type {{ players: number, p95: number, max: number, drops: number, ticksPerSecond: number, rss: number }[]} */
154
155
  const readings = [];
155
- let url = release.socket.replace(/\/$/u, '');
156
+ // NET-LAG NL3: `staging --tailnet` dials staging's tailnet Serve address (the other door on the staging list) instead of the one
157
+ // the release names, so the same bots measure the wire without Cloudflare
158
+ if (values.tailnet && mode !== 'staging') throw new Error('--tailnet is for staging');
159
+ const tailnetDoor = STAGING_SOCKETS[1];
160
+ if (values.tailnet && tailnetDoor === undefined) throw new Error('No tailnet door on the staging list');
161
+ let url = values.tailnet && tailnetDoor !== undefined ? tailnetDoor : release.socket.replace(/\/$/u, '');
156
162
  if (mode === 'replica') {
157
163
  const tarball = join(work, 'server.tar.gz'), served = join(work, 'server');
158
164
  const bytes = serverBundle !== null ? readFileSync(serverBundle) : Buffer.from(await (await fetch(`${BUNDLES}/${release.bundle.name}`, { signal: AbortSignal.timeout(300_000) })).arrayBuffer());
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env node
2
+ // NET-LAG NL8 (meta docs/plans/NET-LAG-PLAN.md): "buttery" walking and running, read by numbers. Per engine, layout and deck
3
+ // shard, a headless page enters the shard, walks, sprints and boosts (hoverboard, Shift) for `--seconds` each, and prints the
4
+ // plan's bar per run; any miss exits 1.
5
+ // B1 drawn frames (the renderer's own, so a 30 fps cap reads as 30): none over 2x the frame budget nor over 50 ms, p99 at
6
+ // most 1.25x it. Budget = 1000 / min(display Hz, the tier's cap), read from the drawn rate before moving.
7
+ // B2 own character on foot (walk and sprint): at most 2 corrections a minute, worst render offset at most 0.10 m.
8
+ // B3 others: interpolation delay at most 120 ms from 10 s after entry, and no frame held past the buffer (`interpHeld`, from entry).
9
+ // B4 Driftwood only: the rope bridge crossed with forced 60 ms frames, the feet never under its planks, no fall.
10
+ // J205: staging, preview or a loopback page only, never production; the page's sockets are held to the one door.
11
+ // node scripts/net-lag-proof.mjs [--base=https://staging.wildshard.io] [--socket=wss://rooms-staging.wildshard.io]
12
+ // [--engines=chromium,webkit] [--layouts=desktop,phone] [--shards=driftwood-isle,...] [--seconds=20] [--out=<dir>]
13
+ // [--delay-ms=<one way>] [--rig=<app dist>,<work dir>,<key.json>] [--no-bridge]
14
+ // `--rig` opens engine's loopback room (online-rig.mjs) per shard, with a dist stamped for http://127.0.0.1:18799/release.json;
15
+ // `--delay-ms=90` holds every frame each way in the page for 90 ms: a 180 ms round trip on the loopback rig (NL12).
16
+ import { mkdirSync, writeFileSync } from 'node:fs';
17
+ import { join, resolve as absolute } from 'node:path';
18
+ import { chromium, webkit } from 'playwright';
19
+ import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
20
+ import { saveFixture } from './debug-settings.mjs';
21
+ import { guardStagingSockets } from './staging-proof-lines.mjs';
22
+
23
+ const arg = (/** @type {string} */ name, /** @type {string} */ fallback) => process.argv.find(value => value.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback;
24
+ const DECK = ['driftwood-isle', 'sunscar-dunes', 'nalati-grasslands', 'far-reach', 'pine-hollow', 'nine-dragon-stack'];
25
+ const TITLES = /** @type {Record<string, string>} */ ({ 'pine-hollow': 'PINE HOLLOW', 'nalati-grasslands': 'NALATI GRASSLANDS', 'nine-dragon-stack': 'NINE DRAGON STACK', 'sunscar-dunes': 'SIGNAL DUNES', 'far-reach': 'SKY REACH', 'driftwood-isle': 'DRIFTWOOD ISLE' });
26
+ const rigArg = arg('rig', ''), base = arg('base', rigArg === '' ? 'https://staging.wildshard.io' : '').replace(/\/$/u, '');
27
+ if (rigArg === '' && !/^https:\/\/(staging|preview)\.wildshard\.io$|^http:\/\/127\.0\.0\.1:\d+$/u.test(base)) throw new Error('--base takes staging, preview or a loopback page only: never production (J205)');
28
+ const engines = arg('engines', 'chromium,webkit').split(','), layouts = arg('layouts', 'desktop,phone').split(','), shards = arg('shards', DECK.join(',')).split(',');
29
+ const SECONDS = Number(arg('seconds', '20')), DELAY_MS = Number(arg('delay-ms', '0')), out = absolute(arg('out', 'tmp/net-lag-proof')), bridge = !process.argv.includes('--no-bridge');
30
+ if (!Number.isFinite(SECONDS) || SECONDS < 5 || !Number.isFinite(DELAY_MS) || DELAY_MS < 0) throw new Error('--seconds is at least 5 and --delay-ms at least 0');
31
+ mkdirSync(out, { recursive: true });
32
+ const IPHONE = { viewport: { width: 402, height: 874 }, deviceScaleFactor: 3, hasTouch: true, userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 26_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1' };
33
+ /** Driftwood's way from the pier to the rope bridge (test/fixtures/headless/driftwood-optional-run.ts) and across it (NL5's route). */
34
+ const TO_BRIDGE = [[0, -186.5], [-8, -172], [-17, -161], [-20, -150], [-30, -142], [-30, -130], [-30, -118], [-30, -106], [-30, -104], [-24, -80], [-22, -71.5], [-8, -50], [10.8, -27.8], [15.4, -8.6], [15.6, -7], [13.88, 11.88]];
35
+ const ACROSS = [[15.29, 13.29], [23.99, 21.99], [31.98, 29.98], [34.38, 32.38], [35.8, 33.8]], SPAN = { a: { x: 15.29, z: 13.29 }, b: { x: 34.38, z: 32.38 } };
36
+ /** @param {number} ms */
37
+ const sleep = ms => new Promise(resolve => { setTimeout(resolve, ms); });
38
+
39
+ /** In the page: drawn frames (page frames that rendered), a forced-slow-frame switch, and the socket delay. Self-contained. @param {number} delay */
40
+ function pageProbe(delay) {
41
+ const W = /** @type {any} */ (window), S = W.__netLag = { on: false, drawn: /** @type {number[]} */ ([]), last: 0, slowMs: 0, rendered: false, worst: 0 };
42
+ // a drawn frame is a page frame that rendered at least once (a frame may render offscreen passes too; a capped one renders none)
43
+ // B2's worst render offset, over the window the proof opens (the client's own `worstOffset` runs from entry)
44
+ const frame = (/** @type {number} */ now) => { const offset = W.__wildshard?.world?.player?.renderOffset; if (S.on && offset !== undefined) S.worst = Math.max(S.worst, offset.length()); if (S.rendered) { if (S.on && S.last !== 0) S.drawn.push(now - S.last); S.last = now; S.rendered = false; } requestAnimationFrame(frame); };
45
+ requestAnimationFrame(frame);
46
+ const hook = () => {
47
+ const renderer = W.__wildshard?.world?.game?.renderer;
48
+ if (renderer === undefined || renderer.__netLag === true) return;
49
+ renderer.__netLag = true;
50
+ const render = renderer.render.bind(renderer);
51
+ renderer.render = (/** @type {unknown} */ scene, /** @type {unknown} */ camera) => {
52
+ if (S.slowMs > 0 && !S.rendered) { const until = performance.now() + S.slowMs; while (performance.now() < until) { /* NL5's forced long frame */ } }
53
+ S.rendered = true;
54
+ return render(scene, camera);
55
+ };
56
+ };
57
+ setInterval(hook, 250);
58
+ if (delay > 0) {
59
+ const P = WebSocket.prototype, held = new WeakMap();
60
+ const raw = /** @type {any} */ (P), sendFn = raw.send, addFn = raw.addEventListener, removeFn = raw.removeEventListener;
61
+ P.send = function send(/** @type {any} */ data) { setTimeout(() => { if (this.readyState === 1) sendFn.call(this, data); }, delay); };
62
+ P.addEventListener = function addEventListener(/** @type {string} */ type, /** @type {any} */ listener, /** @type {any} */ options) {
63
+ if (type !== 'message' || typeof listener !== 'function') { addFn.call(this, type, listener, options); return; }
64
+ const late = (/** @type {Event} */ event) => { setTimeout(() => { listener.call(this, event); }, delay); };
65
+ held.set(listener, late);
66
+ addFn.call(this, type, late, options);
67
+ };
68
+ P.removeEventListener = function removeEventListener(/** @type {string} */ type, /** @type {any} */ listener, /** @type {any} */ options) { removeFn.call(this, type, held.get(listener) ?? listener, options); };
69
+ }
70
+ }
71
+
72
+ /** @param {number[]} list @param {number} p */
73
+ const at = (list, p) => { const sorted = [...list].sort((a, b) => a - b); return sorted.length === 0 ? 0 : Number((sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * p))] ?? 0).toFixed(1)); };
74
+
75
+ /** One run: enter `slug` on `engineName` at `layout`, walk, sprint, boost (and the bridge on Driftwood). @param {import('playwright').Browser} browser @param {string} engineName @param {string} layout @param {string} slug @param {string} site @param {string} socket */
76
+ async function runOne(browser, engineName, layout, slug, site, socket) {
77
+ const context = await browser.newContext(layout === 'phone' ? { ...IPHONE, isMobile: engineName === 'chromium' } : { viewport: { width: 1280, height: 800 }, deviceScaleFactor: 1 });
78
+ if (socket !== '') await context.addInitScript(guardStagingSockets, socket);
79
+ await context.addInitScript(pageProbe, DELAY_MS);
80
+ await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
81
+ await saveFixture(context, { scope: 'global', key: 'settings', data: { music: false, sfx: false, volume: 0 }, merge: true });
82
+ const page = await context.newPage(), errors = /** @type {string[]} */ ([]), row = /** @type {Record<string, any>} */ ({ engine: engineName, layout, slug, delayMs: DELAY_MS * 2 });
83
+ page.on('pageerror', error => { errors.push(error.message.slice(0, 200)); });
84
+ const t0 = Date.now();
85
+ /** @type {ReturnType<typeof setInterval> | undefined} */
86
+ let sampler;
87
+ try {
88
+ await page.goto(`${site}/?chunk=${slug}&mute=1&nolock=1&skipintro=1`, { waitUntil: 'load', timeout: 90_000 });
89
+ for (const ends = Date.now() + 120_000; Date.now() < ends;) {
90
+ if (await page.locator('#ws-name-box input').isVisible().catch(() => false)) break;
91
+ const clicked = await page.evaluate(title => {
92
+ const all = [...document.querySelectorAll('body *')], head = all.find(e => e.children.length === 0 && (e.textContent ?? '').trim().toUpperCase() === title);
93
+ for (let up = head?.parentElement; up; up = up.parentElement) {
94
+ const load = [...up.querySelectorAll('*')].find(e => e.children.length === 0 && (e.textContent ?? '').trim().toUpperCase() === 'LOAD');
95
+ if (load !== undefined) { /** @type {HTMLElement} */ (load.closest('button') ?? load).click(); return true; }
96
+ }
97
+ return false;
98
+ }, TITLES[slug] ?? slug.toUpperCase().replaceAll('-', ' ')).catch(() => false);
99
+ if (await page.getByText(/could not load/iu).isVisible().catch(() => false)) throw new Error('the shard could not load');
100
+ await sleep(clicked ? 6000 : 1000);
101
+ }
102
+ await page.locator('#ws-name-box input').fill(`Lag ${engineName[0] ?? 'x'}${Date.now().toString(36).slice(-3)}`);
103
+ await page.locator('#ws-name-box button[type=submit]').click();
104
+ await page.waitForFunction(() => typeof window.__workerClient === 'function' && /** @type {any} */ (window).__wildshard?.world?.player !== undefined, undefined, { timeout: 150_000 });
105
+ await page.evaluate(() => /** @type {any} */ (window).__wildshard?.world?.hud.enterNow());
106
+ await page.waitForFunction(() => (window.__workerClient?.().frames ?? 0) > 30, undefined, { timeout: 90_000 });
107
+ if (await page.evaluate(() => /** @type {any} */ (window).__wildshard?.world?.game.app.clock.paused === true)) await page.getByRole('button', { name: /^resume$/iu }).click().catch(() => undefined);
108
+ row.enterMs = Date.now() - t0;
109
+ const entered = Date.now(), delays = /** @type {{ t: number, delay: number }[]} */ ([]), heldFrom = await page.evaluate(() => window.__workerClient?.().interpHeld ?? 0);
110
+ const report = () => page.evaluate(() => { const w = window.__workerClient?.(); return w === undefined ? null : { corrections: w.corrections, worst: w.worstOffset, delay: w.delayMs, held: w.interpHeld, falls: w.falls, missed: { ...w.missed } }; });
111
+ sampler = setInterval(() => { void report().then(r => { if (r !== null) delays.push({ t: Date.now() - entered, delay: r.delay }); return undefined; }).catch(() => undefined); }, 250);
112
+ await sleep(2000);
113
+ // the budget: the drawn rate standing still, against the display's 60 Hz (headless)
114
+ await page.evaluate(() => { const S = /** @type {any} */ (window).__netLag; S.drawn.length = 0; S.on = true; });
115
+ await sleep(2000);
116
+ const idle = await page.evaluate(() => /** @type {any} */ (window).__netLag.drawn.slice());
117
+ row.budgetMs = at(idle, 0.5) > 25 ? 1000 / 30 : 1000 / 60;
118
+ // B4 first, from the spawn on the pier, where its route starts
119
+ if (bridge && slug === 'driftwood-isle') row.bridge = await crossBridge(page);
120
+ await page.evaluate(() => { /** @type {any} */ (window).__netLag.worst = 0; });
121
+ const before = await report();
122
+ const phase = async (/** @type {string} */ name, /** @type {string[]} */ keys) => {
123
+ await page.evaluate(() => { const S = /** @type {any} */ (window).__netLag; S.drawn.length = 0; });
124
+ const from = await report();
125
+ for (const key of keys) await page.keyboard.down(key);
126
+ for (let left = SECONDS * 1000, turn = 0; left > 0; left -= 1000, turn++) {
127
+ await sleep(1000);
128
+ if (turn % 5 === 2) { const side = turn % 10 === 2 ? 'KeyA' : 'KeyD'; await page.keyboard.down(side); await sleep(300); await page.keyboard.up(side); }
129
+ }
130
+ for (const key of [...keys].reverse()) await page.keyboard.up(key);
131
+ const drawn = await page.evaluate(() => /** @type {any} */ (window).__netLag.drawn.slice()), to = await report();
132
+ // what this phase's corrections disagreed on (position, grounded, board, swim, ride), for the row a miss becomes
133
+ const missed = Object.fromEntries(Object.entries(to?.missed ?? {}).filter(([key]) => key !== 'gap').map(([key, value]) => [key, value - (/** @type {Record<string, number> | undefined} */ (from?.missed)?.[key] ?? 0)]).filter(([, value]) => value !== 0));
134
+ return { name, corrections: (to?.corrections ?? 0) - (from?.corrections ?? 0), missed, frames: drawn.length, p50: at(drawn, 0.5), p99: at(drawn, 0.99), max: at(drawn, 1), over2x: drawn.filter((/** @type {number} */ ms) => ms > 2 * row.budgetMs).length, over50: drawn.filter((/** @type {number} */ ms) => ms > 50).length };
135
+ };
136
+ row.walk = await phase('walk', ['KeyW']);
137
+ row.sprint = await phase('sprint', ['KeyW', 'ShiftLeft']);
138
+ const foot = await report(), footWorst = await page.evaluate(() => /** @type {any} */ (window).__netLag.worst);
139
+ await page.keyboard.press('KeyH'); await sleep(600);
140
+ row.boost = await phase('boost', ['KeyW', 'ShiftLeft']);
141
+ await page.keyboard.press('KeyH'); await sleep(600);
142
+ const after = await report();
143
+ const footMinutes = (2 * SECONDS) / 60, late = delays.filter(sample => sample.t >= 10_000);
144
+ row.b1 = { budgetMs: Number(row.budgetMs.toFixed(1)), over2x: row.walk.over2x + row.sprint.over2x + row.boost.over2x, over50: row.walk.over50 + row.sprint.over50 + row.boost.over50, p99: Math.max(row.walk.p99, row.sprint.p99, row.boost.p99) };
145
+ row.b1.ok = row.b1.over2x === 0 && row.b1.over50 === 0 && row.b1.p99 <= 1.25 * row.budgetMs;
146
+ row.b2 = { perMinute: Number((((foot?.corrections ?? 0) - (before?.corrections ?? 0)) / footMinutes).toFixed(1)), worst: Number(footWorst.toFixed(3)) };
147
+ row.b2.ok = row.b2.perMinute <= 2 && row.b2.worst <= 0.1;
148
+ row.b3 = { delayMaxAfter10s: late.length === 0 ? null : Math.max(...late.map(sample => sample.delay)), held: (after?.held ?? 0) - heldFrom };
149
+ row.b3.ok = row.b3.delayMaxAfter10s !== null && row.b3.delayMaxAfter10s <= 120 && row.b3.held === 0;
150
+ if (row.bridge !== undefined) row.b4 = { ok: row.bridge.reached && row.bridge.under === 0 && row.bridge.falls === 0, ...row.bridge };
151
+ row.ok = row.b1.ok && row.b2.ok && row.b3.ok && (row.b4?.ok ?? true);
152
+ await page.screenshot({ path: join(out, `${engineName}-${layout}-${slug}.png`) }).catch(() => undefined);
153
+ } catch (error) {
154
+ row.error = String(error instanceof Error ? error.message : error).slice(0, 300); row.ok = false;
155
+ await page.screenshot({ path: join(out, `${engineName}-${layout}-${slug}-error.png`) }).catch(() => undefined);
156
+ }
157
+ clearInterval(sampler);
158
+ row.errors = errors.slice(0, 5);
159
+ await context.close();
160
+ return row;
161
+ }
162
+
163
+ /** B4: walk Driftwood's pier to the rope bridge, then cross it with every drawn frame forced to 60 ms. @param {import('playwright').Page} page */
164
+ async function crossBridge(page) {
165
+ const where = () => page.evaluate(() => { const p = /** @type {any} */ (window).__wildshard.world.player.position; return { x: p.x, y: p.y, z: p.z }; });
166
+ const steer = (/** @type {number} */ x, /** @type {number} */ z, /** @type {boolean} */ sprint) => page.evaluate(([toX, toZ, fast]) => { const p = /** @type {any} */ (window).__wildshard.world.player; p.yaw = Math.atan2(-(toX - p.position.x), -(toZ - p.position.z)); p.touchMove.y = 1; p.touchMove.x = 0; p.touchSprint = fast === 1; }, [x, z, sprint ? 1 : 0]);
167
+ const stop = () => page.evaluate(() => { const p = /** @type {any} */ (window).__wildshard.world.player; p.touchMove.y = 0; p.touchSprint = false; });
168
+ let lowest = Infinity, under = 0;
169
+ const go = async (/** @type {number} */ x, /** @type {number} */ z, /** @type {boolean} */ sprint, /** @type {boolean} */ watch) => {
170
+ for (const ends = Date.now() + 20_000; Date.now() < ends;) {
171
+ const p = await where();
172
+ if (watch) {
173
+ const along = ((p.x - SPAN.a.x) * (SPAN.b.x - SPAN.a.x) + (p.z - SPAN.a.z) * (SPAN.b.z - SPAN.a.z)) / ((SPAN.b.x - SPAN.a.x) ** 2 + (SPAN.b.z - SPAN.a.z) ** 2);
174
+ if (along > 0.1 && along < 0.9) { lowest = Math.min(lowest, p.y); if (p.y < 3) under++; } // NL5: the planks stay over 5 m; the gully floor is under 0
175
+ }
176
+ if (Math.hypot(p.x - x, p.z - z) < 0.7) return true;
177
+ await steer(x, z, sprint); await sleep(50);
178
+ }
179
+ return false;
180
+ };
181
+ const fallsBefore = await page.evaluate(() => window.__workerClient?.().falls ?? 0);
182
+ for (const [x = 0, z = 0] of TO_BRIDGE) if (!await go(x, z, true, false)) { await stop(); return { reached: false, at: await where(), under: 0, falls: 0, lowest: null }; }
183
+ await page.evaluate(() => { /** @type {any} */ (window).__netLag.slowMs = 60; });
184
+ let reached = true;
185
+ for (const [index, [x = 0, z = 0]] of ACROSS.entries()) reached = await go(x, z, index % 2 === 1, true) && reached;
186
+ for (const [x = 0, z = 0] of [...ACROSS].reverse().slice(1)) reached = await go(x, z, true, true) && reached;
187
+ await page.evaluate(() => { /** @type {any} */ (window).__netLag.slowMs = 0; });
188
+ await stop();
189
+ const falls = (await page.evaluate(() => window.__workerClient?.().falls ?? 0)) - fallsBefore;
190
+ return { reached, under, falls, lowest: Number.isFinite(lowest) ? Number(lowest.toFixed(2)) : null };
191
+ }
192
+
193
+ const rows = /** @type {Record<string, any>[]} */ ([]);
194
+ for (const engineName of engines) {
195
+ const browser = await (engineName === 'webkit' ? webkit : chromium).launch({ headless: true, args: engineName === 'chromium' ? [...KEYCHAIN_ARGS, '--use-angle=metal', '--ignore-gpu-blocklist', '--autoplay-policy=user-gesture-required'] : [] });
196
+ try {
197
+ for (const slug of shards) {
198
+ /** @type {{ base: string, close: () => Promise<void> }} */
199
+ let site = { base, close: () => Promise.resolve() }, socket = /^https:\/\/(staging|preview)\./u.test(base) ? arg('socket', 'wss://rooms-staging.wildshard.io') : arg('socket', '');
200
+ if (rigArg !== '') {
201
+ const [dist = '', work = '', keyFile = ''] = rigArg.split(','), { openRig, WORLD_PORT } = await import('./online-rig.mjs');
202
+ site = await openRig({ dist: absolute(dist), work: absolute(work, slug), keyFile, pgBin: 'memory:', pgData: '', shard: slug, crossing: false });
203
+ socket = `ws://127.0.0.1:${String(WORLD_PORT)}`;
204
+ }
205
+ try {
206
+ for (const layout of layouts) {
207
+ const row = await runOne(browser, engineName, layout, slug, site.base, socket);
208
+ rows.push(row);
209
+ const { walk: _w, sprint: _s, boost: _b, bridge: _r, ...brief } = row;
210
+ console.log(`${row.ok === true ? 'ok ' : 'MISS'} ${JSON.stringify(brief)}`);
211
+ }
212
+ } finally { await site.close(); }
213
+ }
214
+ } finally { await browser.close(); }
215
+ }
216
+ writeFileSync(join(out, 'net-lag-proof.json'), `${JSON.stringify({ base: rigArg !== '' ? 'loopback rig' : base, delayMs: DELAY_MS * 2, seconds: SECONDS, rows }, null, 1)}\n`);
217
+ const missed = rows.filter(row => row.ok !== true);
218
+ console.log(`net-lag proof: ${String(rows.length - missed.length)}/${String(rows.length)} runs buttery${missed.length === 0 ? '' : `; missed: ${missed.map(row => `${String(row.engine)} ${String(row.layout)} ${String(row.slug)} ${['b1', 'b2', 'b3', 'b4'].filter(key => row[key]?.ok === false).join('+') || 'error'}`).join(', ')}`}`);
219
+ process.exit(missed.length === 0 ? 0 : 1);
@@ -6,10 +6,10 @@ import { resolve } from 'node:path';
6
6
  import { pathToFileURL } from 'node:url';
7
7
  import * as v from 'valibot';
8
8
  import { readBuiltShardfile } from './built-product.mjs';
9
- import { outputFormat } from './shard-platform-format.mjs';
9
+ import { outputFormat } from './node-format.mjs';
10
10
  import { tileBakeCensus } from './tile-bakes.mjs';
11
11
 
12
- // Use the existing format-only Node resolver installed by shard-platform-format, as tile-bakes does.
12
+ // Use the existing format-only Node resolver installed by node-format.mjs, as tile-bakes does.
13
13
  const { TilesSchema } = await import('@wildshard/format/shardSections');
14
14
  const product = 'open-plot-night-market';
15
15
  /** @param {Uint8Array} bytes */
@@ -2,12 +2,14 @@ export interface RequestRow {
2
2
  n: number; t: number; url: string; type: string; origin: 'page' | 'sw'; phase: string; step: string;
3
3
  servedBy: 'service-worker' | 'network' | 'failed' | 'pending'; status: number; fail: string;
4
4
  }
5
- export interface ScreenSample { t: number; phase: string; step: string; card: boolean; title: boolean; player: boolean; failCard: string; text: string }
5
+ export interface ScreenSample { t: number; phase: string; step: string; card: boolean; title: boolean; player: boolean; failCard: string; text: string; inside?: string | null }
6
6
  export interface Failure { shard: string; rule: string; url?: string; detail?: string }
7
- export type Outcome = 'play' | 'seat-wait' | 'title' | 'stalled' | 'error' | 'no-resume';
7
+ export type Outcome = 'play' | 'seat-wait' | 'title' | 'stalled' | 'error' | 'no-resume' | 'outside-world';
8
8
  export const DECK_SHARDS: readonly { slug: string; card: string }[];
9
9
  export const OPEN_PLOTS: readonly string[];
10
10
  export const ALL_SHARDS: readonly string[];
11
+ export function gridPlaces(slug: string, catalogue: { grid?: { cells?: readonly { slug?: unknown }[] } }): boolean;
12
+ export function screenKey(screen: { phase: string; step: string; error: string; failCard: string; title: boolean; player: boolean; progress: string }): string;
11
13
  export const SOLO_ONLY: RegExp;
12
14
  export const CLIENT_MANIFEST: RegExp;
13
15
  export const GRID_LAYOUT: RegExp;
@@ -19,6 +21,6 @@ export function textureForm(path: string): { name: string; form: 'img' | 'ktx2'
19
21
  export function judge(run: {
20
22
  shard: string; channel: 'staging' | 'preview'; mode: string; entry: string; rows: readonly RequestRow[];
21
23
  samples: readonly ScreenSample[]; outcome: Outcome; warm?: ReadonlySet<string>; layout?: boolean; walkthrough?: boolean;
22
- requireWorld?: boolean; proofError?: string; leaks?: number;
24
+ requireWorld?: boolean; proofError?: string; leaks?: number; placed?: boolean; linked?: boolean;
23
25
  }): Failure[];
24
26
  export function servedCounts(rows: readonly RequestRow[]): Record<string, number>;