@wildshard/engine 0.1.18 → 0.1.20

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 (334) 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 +18 -0
  5. package/lint/ratchet.json +0 -68
  6. package/lint/ratchet.mjs +1 -4
  7. package/package.json +19 -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 +33 -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 +83 -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 +284 -0
  51. package/scripts/grid-crossing-walk-proof.mjs +126 -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/land.mjs +2 -1
  56. package/scripts/live-prepush.py +3 -5
  57. package/scripts/loading-flow/benchmax.mjs +37 -12
  58. package/scripts/loading-flow/deskbench.mjs +276 -0
  59. package/scripts/loading-flow/stalls.d.mts +17 -3
  60. package/scripts/loading-flow/stalls.mjs +82 -3
  61. package/scripts/look-loop/test_look_loop.py +1 -38
  62. package/scripts/memory-proof.mjs +61 -6
  63. package/scripts/mmo-bots.mjs +8 -2
  64. package/scripts/net-lag-proof.mjs +219 -0
  65. package/scripts/night-market-kit-budget.mjs +2 -2
  66. package/scripts/nightly-model.ts +9 -6
  67. package/scripts/offline-proof-rules.d.mts +2 -2
  68. package/scripts/offline-proof-rules.mjs +15 -4
  69. package/scripts/offline-proof.mjs +80 -13
  70. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  71. package/scripts/page-release/content.d.mts +9 -1
  72. package/scripts/page-release/content.mjs +131 -17
  73. package/scripts/page-release/flow.mjs +36 -10
  74. package/scripts/page-release/stamp-content.mjs +24 -0
  75. package/scripts/page-release.mjs +28 -6
  76. package/scripts/page-size.mjs +2 -1
  77. package/scripts/parity/boot-smoke.mjs +13 -2
  78. package/scripts/pin-format.ts +5 -2
  79. package/scripts/pin-packs.ts +1 -1
  80. package/scripts/pins-reuse.d.mts +1 -0
  81. package/scripts/pins-reuse.mjs +22 -0
  82. package/scripts/pins.ts +4 -4
  83. package/scripts/precommit-checks.mjs +1 -7
  84. package/scripts/precommit-jobs.mjs +0 -1
  85. package/scripts/precommit-source.py +1 -9
  86. package/scripts/program-discovery.mjs +1 -1
  87. package/scripts/ring-cook.mjs +2 -1
  88. package/scripts/ring-step.ts +1 -1
  89. package/scripts/scratch-dir.mjs +95 -0
  90. package/scripts/scratch-sweep.mjs +182 -0
  91. package/scripts/script-scenario-metrics.mjs +1 -1
  92. package/scripts/shard-output-content.d.mts +1 -1
  93. package/scripts/shard-output-content.mjs +2 -2
  94. package/scripts/shard-outputs.mjs +1 -1
  95. package/scripts/shard-public.mjs +1 -1
  96. package/scripts/shard-wire-meter.mjs +24 -9
  97. package/scripts/side-parity.mjs +4 -2
  98. package/scripts/standalone-smoke.mjs +8 -3
  99. package/scripts/tier-textures.mjs +22 -4
  100. package/scripts/tile-bake-report.mjs +1 -1
  101. package/scripts/tile-bakes.mjs +1 -1
  102. package/scripts/title-assets.generated.json +2 -0
  103. package/scripts/tsconfig.json +2 -14
  104. package/scripts/vendor/basisu/LICENSE +201 -0
  105. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  106. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  107. package/scripts/vitest-push-guards.config.ts +1 -1
  108. package/scripts/vps/harden-apply.sh +4 -1
  109. package/scripts/vps/harden-prometheus.sh +179 -0
  110. package/scripts/vps/harden.sh +16 -0
  111. package/scripts/vps/rebuild.sh +18 -0
  112. package/scripts/vps/wildshard-config +6 -2
  113. package/scripts/worker-client-play.mjs +6 -2
  114. package/scripts/worktree-reap.mjs +59 -13
  115. package/scripts/worktree.mjs +19 -5
  116. package/src/.oxlintrc.json +3 -182
  117. package/src/client/app/entry.ts +10 -2
  118. package/src/client/engine/anim/rigParser.ts +2 -2
  119. package/src/client/engine/boot/bootCache.ts +2 -2
  120. package/src/client/engine/boot/bootTrace.ts +12 -4
  121. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  122. package/src/client/engine/boot/clearDownloads.ts +5 -2
  123. package/src/client/engine/boot/contentRead.ts +11 -0
  124. package/src/client/engine/boot/gpuFiles.ts +4 -2
  125. package/src/client/engine/boot/lastEnd.ts +99 -12
  126. package/src/client/engine/boot/texturePack.ts +2 -2
  127. package/src/client/engine/core/Game.ts +63 -19
  128. package/src/client/engine/core/gpuOnly.ts +10 -0
  129. package/src/client/engine/core/renderBudget.ts +134 -0
  130. package/src/client/engine/net/netPlayer.ts +19 -2
  131. package/src/client/engine/net/otherPlayers.ts +55 -8
  132. package/src/client/engine/net/predictor.ts +33 -9
  133. package/src/client/engine/net/redial.ts +68 -10
  134. package/src/client/engine/pwa/cacheNames.ts +58 -1
  135. package/src/client/engine/pwa/sw.js +41 -11
  136. package/src/client/engine/render/dataLook.ts +219 -44
  137. package/src/client/engine/render/families/detail.ts +89 -0
  138. package/src/client/engine/render/families/pbr.ts +9 -1
  139. package/src/client/engine/render/families/registry.ts +11 -2
  140. package/src/client/engine/render/families/sceneSurface.ts +116 -0
  141. package/src/client/engine/render/look.ts +12 -0
  142. package/src/client/engine/render/lookLight.ts +103 -11
  143. package/src/client/engine/render/lookRender.ts +105 -0
  144. package/src/client/engine/render/precompile.ts +4 -2
  145. package/src/client/engine/render/tiers.ts +4 -1
  146. package/src/client/engine/saves/indexed.ts +2 -2
  147. package/src/client/engine/telemetry/browserErrors.ts +24 -3
  148. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  149. package/src/client/engine/ui/debugOptions.ts +1 -1
  150. package/src/client/engine/ui/lookLightOption.ts +10 -6
  151. package/src/client/engine/ui/namePrompt.ts +7 -0
  152. package/src/client/engine/world/declaredProps.ts +5 -1
  153. package/src/client/engine/world/skyRig.ts +4 -1
  154. package/src/client/engine/world/terrainTileView.ts +64 -23
  155. package/src/client/game/boot/audio.generated.ts +114 -114
  156. package/src/client/game/boot/bytes.generated.ts +118 -220
  157. package/src/client/game/boot/placedSpawn.ts +35 -0
  158. package/src/client/game/boot/spawnDownload.ts +25 -6
  159. package/src/client/game/boot/versions.generated.ts +7 -5
  160. package/src/client/game/devScene/hook.ts +428 -0
  161. package/src/client/game/devScene/liveLook.ts +21 -0
  162. package/src/client/game/grid/cellLoading.ts +12 -2
  163. package/src/client/game/grid/live.ts +152 -19
  164. package/src/client/game/grid/liveSession.ts +53 -3
  165. package/src/client/game/grid/mapAtlas.ts +18 -4
  166. package/src/client/game/grid/minimapBlend.ts +15 -5
  167. package/src/client/game/grid/oneWayIn.ts +5 -1
  168. package/src/client/game/grid/pageEntry.ts +12 -1
  169. package/src/client/game/grid/placedCells.ts +114 -12
  170. package/src/client/game/grid/placedContent.ts +85 -0
  171. package/src/client/game/grid/prefetch.ts +9 -1
  172. package/src/client/game/grid/productInputs.ts +23 -10
  173. package/src/client/game/grid/productLeases.ts +4 -1
  174. package/src/client/game/grid/products.ts +8 -4
  175. package/src/client/game/grid/roadLook.ts +24 -15
  176. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  177. package/src/client/game/grid/roadResources.ts +24 -0
  178. package/src/client/game/grid/roadSign.worker.ts +4 -3
  179. package/src/client/game/grid/roadSignPaint.ts +16 -5
  180. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  181. package/src/client/game/grid/roadSignScale.ts +8 -0
  182. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  183. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  184. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  185. package/src/client/game/grid/roadTileWriter.ts +2 -1
  186. package/src/client/game/grid/screenReports.ts +39 -0
  187. package/src/client/game/grid/session.ts +32 -7
  188. package/src/client/game/grid/softWallLook.ts +25 -8
  189. package/src/client/game/mainMenu.ts +6 -2
  190. package/src/client/game/plugin/context.ts +2 -1
  191. package/src/client/game/plugin/followedMovers.ts +7 -1
  192. package/src/client/game/quest/figures.ts +2 -0
  193. package/src/client/game/session/finish.ts +9 -0
  194. package/src/client/game/shardfile/assetCache.ts +4 -4
  195. package/src/client/game/shardfile/client.ts +28 -8
  196. package/src/client/game/shardfile/clientAssets.ts +9 -5
  197. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  198. package/src/client/game/shardfile/clientPropMaterials.ts +4 -1
  199. package/src/client/game/shardfile/clientViews.ts +36 -8
  200. package/src/client/game/shardfile/clientWater.ts +51 -9
  201. package/src/client/game/shardfile/clientWorker.ts +19 -7
  202. package/src/client/game/shardfile/constructionCheckpoint.ts +2 -2
  203. package/src/client/game/shardfile/groundMerge.ts +57 -5
  204. package/src/client/game/shardfile/hybrid.ts +2 -0
  205. package/src/client/game/shardfile/look.ts +8 -3
  206. package/src/client/game/shardfile/product.ts +34 -7
  207. package/src/client/game/shardfile/productChecks.ts +2 -2
  208. package/src/client/game/shardfile/productCost.ts +2 -2
  209. package/src/client/game/shardfile/readAsset.ts +2 -2
  210. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  211. package/src/client/game/shardfile/seatGrace.ts +9 -0
  212. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  213. package/src/client/game/shardfile/slabLibrary.ts +115 -49
  214. package/src/client/game/shardfile/tileContent.ts +1 -1
  215. package/src/client/game/shardfile/tileDriver.ts +38 -11
  216. package/src/client/game/shardfile/wirePage.ts +7 -3
  217. package/src/client/game/shardfile/worldScenes.ts +17 -10
  218. package/src/client/game/systems/npc/figureRows.ts +9 -0
  219. package/src/client/host/online/doctor.ts +22 -7
  220. package/src/client/host/online/doctorView.ts +2 -0
  221. package/src/client/host/online/linkScreens.ts +109 -5
  222. package/src/client/host/online/shell.ts +13 -4
  223. package/src/client/host/standalone/shell.ts +40 -0
  224. package/src/cook/game/astc6Encode.ts +55 -0
  225. package/src/cook/game/astc6Wasm.ts +176 -0
  226. package/src/cook/game/cookJob.ts +30 -6
  227. package/src/cook/game/cookWorker.ts +38 -11
  228. package/src/cook/game/entryTotals.ts +51 -24
  229. package/src/cook/game/shardCook.ts +35 -7
  230. package/src/cook/game/spawnParts.ts +33 -8
  231. package/src/cook/game/tierTextures.ts +87 -14
  232. package/src/server/engine/ai/bossContenders.ts +27 -3
  233. package/src/server/engine/ai/phases.ts +1 -1
  234. package/src/server/engine/entities/creatureRefill.ts +9 -2
  235. package/src/server/engine/net/ledgerBook.ts +2 -0
  236. package/src/server/engine/net/room.ts +15 -0
  237. package/src/server/engine/sim/respawn.ts +8 -0
  238. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  239. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  240. package/src/server/game/boss/native.ts +2 -1
  241. package/src/server/game/boss/nativeWake.ts +9 -5
  242. package/src/server/game/boss/openArenaNative.ts +2 -2
  243. package/src/server/game/boss/openArenaRoom.ts +3 -1
  244. package/src/server/game/grid/room.ts +44 -3
  245. package/src/server/game/grid/simulation.ts +23 -0
  246. package/src/server/game/population/mixedRoster.ts +11 -3
  247. package/src/server/game/population/nativeBake.ts +8 -3
  248. package/src/server/game/population/nativeReturns.ts +6 -3
  249. package/src/server/game/population/roster.ts +5 -3
  250. package/src/server/game/quest/eliteDrops.ts +18 -3
  251. package/src/server/game/quest/nativeChapter.ts +1 -1
  252. package/src/server/game/quest/nativeComposition.ts +5 -1
  253. package/src/server/game/riding/nativeTaming.ts +22 -7
  254. package/src/server/game/riding/wildRefill.ts +3 -2
  255. package/src/server/game/shardfile/bossRow.ts +4 -2
  256. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  257. package/src/server/host/bake/headlessWorker.ts +1 -1
  258. package/src/server/host/dedicated/cellHost.ts +112 -18
  259. package/src/server/host/dedicated/cellProtocol.ts +18 -1
  260. package/src/server/host/dedicated/cellWorker.ts +8 -5
  261. package/src/server/host/dedicated/dedicatedRoom.ts +38 -11
  262. package/src/server/host/dedicated/gridCells.ts +15 -6
  263. package/src/server/host/dedicated/loopLag.ts +21 -0
  264. package/src/server/host/dedicated/main.ts +13 -5
  265. package/src/server/host/dedicated/packReader.ts +3 -3
  266. package/src/server/host/dedicated/placementFile.ts +3 -2
  267. package/src/server/host/dedicated/roadRoom.ts +34 -4
  268. package/src/server/host/dedicated/serverMetrics.ts +135 -0
  269. package/src/server/host/dedicated/socketPump.ts +21 -4
  270. package/src/server/host/dedicated/workerTable.ts +32 -14
  271. package/src/server/host/dedicated/world.ts +65 -7
  272. package/src/server/host/headless.ts +1 -1
  273. package/src/server/host/headlessRuntime.ts +1 -1
  274. package/src/server/host/standalone/roadWorld.ts +15 -3
  275. package/src/server/host/standalone/serverHost.ts +57 -8
  276. package/src/server/host/standalone/serverProduct.ts +48 -16
  277. package/src/server/host/standalone/serverRuntime.ts +1 -1
  278. package/src/shared/engine/ai/BossBrain.ts +8 -0
  279. package/src/shared/engine/core/framePacing.ts +12 -1
  280. package/src/shared/engine/physics/terrainTiles.ts +20 -4
  281. package/src/shared/game/boss/wake.ts +6 -0
  282. package/src/shared/game/devColliders.ts +107 -0
  283. package/src/shared/game/devGameplay.ts +41 -0
  284. package/src/shared/game/eliteSystem.ts +8 -0
  285. package/src/shared/game/grid/allocator.ts +3 -0
  286. package/src/shared/game/grid/placementRows.ts +5 -2
  287. package/src/shared/game/plugin/bossRecord.ts +3 -2
  288. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  289. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  290. package/src/shared/game/shardfile/packReads.ts +28 -3
  291. package/src/shared/game/shardfile/serverPack.ts +9 -0
  292. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  293. package/src/shared/host/formatJsonSchema.ts +2 -2
  294. package/src/tsconfig.json +1 -27
  295. package/lint/host-reviews.json +0 -14
  296. package/lint/listed-view-code.json +0 -13
  297. package/lint/platform-pending-users.json +0 -2520
  298. package/lint/platform-pending-users.md +0 -18
  299. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  300. package/scripts/check-closed-components.d.mts +0 -7
  301. package/scripts/check-closed-components.mjs +0 -87
  302. package/scripts/g571-hosts.d.mts +0 -3
  303. package/scripts/g571-hosts.mjs +0 -54
  304. package/scripts/host-ruler/register-migrate.mjs +0 -242
  305. package/scripts/listed-view-code.d.mts +0 -7
  306. package/scripts/listed-view-code.mjs +0 -93
  307. package/scripts/look-loop/fit-lut.py +0 -142
  308. package/scripts/look-loop/palette-delta.py +0 -183
  309. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  310. package/scripts/look-loop/regions/far-reach.json +0 -225
  311. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  312. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  313. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  314. package/scripts/platform-chargebacks.d.mts +0 -9
  315. package/scripts/platform-chargebacks.mjs +0 -135
  316. package/scripts/shard-component-spans.d.mts +0 -15
  317. package/scripts/shard-component-spans.mjs +0 -18
  318. package/scripts/shard-components.d.mts +0 -16
  319. package/scripts/shard-components.mjs +0 -363
  320. package/scripts/shard-platform-hosts.d.mts +0 -2
  321. package/scripts/shard-platform-hosts.mjs +0 -93
  322. package/scripts/shard-platform-sections.d.mts +0 -2
  323. package/scripts/shard-platform-sections.mjs +0 -9
  324. package/scripts/shard-platform.d.mts +0 -76
  325. package/scripts/shard-platform.mjs +0 -1072
  326. package/src/.oxfmtrc.json +0 -48
  327. package/src/scripts/ask-new.sh +0 -29
  328. package/src/scripts/asks.mjs +0 -142
  329. package/src/scripts/herdr-prompt.sh +0 -34
  330. package/src/scripts/herdr-question-open.sh +0 -67
  331. package/src/scripts/md-wrap.mjs +0 -229
  332. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  333. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  334. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -0,0 +1,284 @@
1
+ #!/usr/bin/env node
2
+ // GRID-CROSSING GC3: every neighbouring pair of the grid, both ways, in one page. The page enters the grid on Driftwood's deck card,
3
+ // then tours the grid's border arcs (each pair once in each direction; the grid is the build's own catalogue `grid.cells`): for each
4
+ // arc the harness sets the walker 12 m inside the cell's edge on its entryway (probe.ts's harness pose, which only an in-page server
5
+ // hears: preview or a loopback page) and walks or boosts across by real input until it has control in the neighbour. Arcs toward +x
6
+ // or +z walk, arcs toward -x or -z boost, so every pair is crossed at both speeds once. A failed arc stays in its cell and the tour
7
+ // picks another; when a cell has no arc left it goes back over crossings that worked (scored too, marked `repeat`), and when none
8
+ // leads anywhere (a cell it can't leave) it enters again by the title.
9
+ // Per crossing, from the in-page samples (every 100 ms) and every frame: border to control, the longest run under 90 % of the
10
+ // approach speed (slow) and under 0.1 m per 100 ms with the key held (freeze), the time held at an unready neighbour (wall: phase
11
+ // preparing or blocked while frozen), the time the cell step screen shows, and frames over 33 and 50 ms within 3 s of the border.
12
+ // Not measured: grey stand-ins within 60 m (no reader yet).
13
+ // scripts/browser-lane.sh node scripts/grid-crossing-tour.mjs --base=https://preview.wildshard.io --out=<dir> [--engine=chromium|webkit]
14
+ // [--layout=phone] [--arcs=<from>:<to>,…] [--limit=<n crossings>] [--cold] [--lane=<name>] [--hold=<ms>] [--laps=<n>]
15
+ // --laps (GC14, the soak): cross every wanted arc, then again, n times; each row names its lap, with the memory at its control.
16
+ // --hold (GC13): after control, stand this long in the cell reached before the next crossing; each row then says when the cell left
17
+ // behind let its world go (`fromEvictedMs`) and the most the page's playing cost reached (`peakPlayingMB`).
18
+ // --cold (GC3's cold-cache pass): no HTTP cache and no service worker in any page, so every crossing fetches its cell from the
19
+ // network as a first visit does (Chromium: the DevTools cache switch; WebKit: service workers blocked only).
20
+ import { execFileSync } from 'node:child_process';
21
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
22
+ import { join, resolve as absolute } from 'node:path';
23
+ import { chromium, webkit } from 'playwright';
24
+ import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
25
+ import { saveFixture } from './debug-settings.mjs';
26
+
27
+ /** @param {string} name @param {string} fallback */
28
+ const flag = (name, fallback) => process.argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback;
29
+ const base = flag('base', '').replace(/\/$/u, ''), out = absolute(flag('out', '')), engineName = flag('engine', 'chromium'), phone = flag('layout', 'desktop') === 'phone';
30
+ // the harness pose is the in-page server's: preview or a loopback page only (never staging's or production's seats, J205)
31
+ if (!/^https:\/\/preview\.wildshard\.io$|^http:\/\/127\.0\.0\.1:\d+$/u.test(base) || out === absolute('')) throw new Error('usage: grid-crossing-tour.mjs --base=<preview or loopback url> --out=<dir> [--engine=chromium|webkit] [--layout=phone] [--arcs=a:b,…] [--limit=n]');
32
+ if (engineName !== 'chromium' && engineName !== 'webkit') throw new Error(`No engine ${engineName}`);
33
+ const limit = Number(flag('limit', '400')), only = flag('arcs', '').split(',').filter(Boolean), cold = process.argv.includes('--cold'), lane = flag('lane', 'opus-gcm2'), hold = Number(flag('hold', '0')), laps = Number(flag('laps', '1'));
34
+ // --viewport=<w>x<h>@<dpr> (desktop): Jake's window is 2992x1434@2 (QA 11-14 row 6)
35
+ const desk = (/^(\d+)x(\d+)@([\d.]+)$/u.exec(flag('viewport', '1440x900@1')) ?? [0, '1440', '900', '1']).slice(1).map(Number);
36
+ let currentLap = 1;
37
+ mkdirSync(out, { recursive: true });
38
+ const sleep = (/** @type {number} */ ms) => new Promise(resolve => { setTimeout(resolve, ms); });
39
+
40
+ // the grid at the build the base serves (its version.json), not this checkout's
41
+ const build = await fetch(`${base}/version.json`, { signal: AbortSignal.timeout(15_000) }).then(async found => String((await found.json()).build).split('-')[0] ?? '').catch(() => '');
42
+ const catalogueText = (() => {
43
+ try { return execFileSync('git', ['show', `${build}:src/shared/game/grid/singleplayer.json`], { cwd: join(import.meta.dirname, '..'), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }); }
44
+ catch { console.log(`build ${build} is not in this checkout: reading the working catalogue`); return readFileSync(join(import.meta.dirname, '../src/shared/game/grid/singleplayer.json'), 'utf8'); }
45
+ })();
46
+ /** @type {{ instance: string, slug: string, cell: [number, number] }[]} */
47
+ const cells = JSON.parse(catalogueText).grid.cells;
48
+ const at = new Map(cells.map(cell => [cell.cell.join(','), cell]));
49
+ /** @typedef {{ from: string, to: string, dx: number, dz: number, boost: boolean }} Arc */
50
+ /** @type {Arc[]} */
51
+ const arcs = [];
52
+ for (const cell of cells) for (const [dx, dz] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) {
53
+ const next = at.get(`${String(cell.cell[0] + dx)},${String(cell.cell[1] + dz)}`);
54
+ if (next !== undefined) arcs.push({ from: cell.instance, to: next.instance, dx, dz, boost: dx + dz < 0 });
55
+ }
56
+ const wanted = only.length === 0 ? arcs : arcs.filter(arc => only.includes(`${arc.from}:${arc.to}`));
57
+ // --in=<m>: how far inside its cell's edge each walk starts (default 12 m), so a walk from deeper in measures the pre-warm (GC6)
58
+ const HOME = 'driftwood-isle', HOME_CARD = 'Driftwood Isle', EDGE_IN = 250 - Number(flag('in', '12')), LEG_MS = 90_000, STUCK_MS = 1500;
59
+
60
+ /** @type {Record<string, unknown>[]} */
61
+ const crossings = [];
62
+ const result = { lane, base, build, cold, engine: engineName, layout: phone ? 'phone 402x874 touch' : `desktop ${String(desk[0])}x${String(desk[1])}@${String(desk[2])}`, at: new Date().toISOString(), arcs: wanted.length, crossings, errors: /** @type {string[]} */ ([]), console: /** @type {string[]} */ ([]), reloads: 0, reentries: 0, lostPage: /** @type {Record<string, unknown>[]} */ ([]), note: '', untried: /** @type {string[]} */ ([]) };
63
+ const save = () => writeFileSync(join(out, `${engineName}-${phone ? 'phone' : 'desktop'}-tour.json`), `${JSON.stringify(result, null, 2)}\n`);
64
+ const browser = await (engineName === 'webkit' ? webkit : chromium).launch({ headless: true, args: engineName === 'chromium' ? [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist', '--enable-precise-memory-info'] : [] });
65
+ let code = 1;
66
+ try {
67
+ // a fresh profile at each entry: the first, and again when the tour is stranded in a cell it can't leave (a grid page's title
68
+ // won't take a second Shard Select in the same profile)
69
+ /** @type {import('playwright').BrowserContext | null} */ let context = null;
70
+ /** @type {import('playwright').Page} */ let page = /** @type {any} */ (undefined);
71
+ let navigations = 0;
72
+ const profile = async () => {
73
+ await context?.close();
74
+ context = await browser.newContext(phone ? { viewport: { width: 402, height: 874 }, deviceScaleFactor: 3, isMobile: engineName === 'chromium', hasTouch: true,
75
+ 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', ...cold ? { serviceWorkers: 'block' } : {} }
76
+ : { viewport: { width: desk[0], height: desk[1] }, deviceScaleFactor: desk[2], ...cold ? { serviceWorkers: 'block' } : {} });
77
+ await saveFixture(context, { scope: 'device', key: 'firstPlayDone', data: true });
78
+ await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
79
+ await saveFixture(context, { scope: 'global', key: 'settings', merge: true, data: phone ? { tier: 'phone', volume: 0 } : { volume: 0 } });
80
+ page = await context.newPage();
81
+ if (cold && engineName === 'chromium') await (await context.newCDPSession(page)).send('Network.setCacheDisabled', { cacheDisabled: true });
82
+ const opened = page;
83
+ page.on('pageerror', error => { if (result.errors.length < 20) result.errors.push(error.message.slice(0, 240)); });
84
+ // GC6: the page's own warnings name a stuck entry preparation (`[grid] <cell>: entry preparation on the road`)
85
+ page.on('console', message => { if ((message.type() === 'warning' || message.type() === 'error') && result.console.length < 60) result.console.push(`${message.type()} ${message.text().slice(0, 300)}`); });
86
+ page.on('framenavigated', frame => { if (frame === opened.mainFrame()) navigations++; });
87
+ };
88
+ /** Into the grid by Driftwood's deck card, and the sampler on: at the start, and again when the tour is stranded in a cell it can't leave. */
89
+ const enter = async () => {
90
+ await profile();
91
+ await page.goto(`${base}/?mute=1&nolock=1`, { waitUntil: 'load' });
92
+ await page.locator('.ws-main-select').click({ timeout: 120_000 });
93
+ if (await page.locator('#ws-name-box input').waitFor({ timeout: 30_000 }).then(() => true).catch(() => false)) { await page.locator('#ws-name-box input').fill('walker'); await page.locator('#ws-name-box button[type=submit]').click(); }
94
+ await page.locator('.ws-menu-card').first().waitFor({ state: 'visible', timeout: 30_000 });
95
+ const index = await page.evaluate(card => [...document.querySelectorAll('.ws-menu-card')].findIndex(row => (row.textContent ?? '').includes(card)), HOME_CARD);
96
+ if (index < 0) throw new Error(`No ${HOME_CARD} card`);
97
+ await page.locator('.ws-menu-dots i').nth(index).click();
98
+ await page.locator('.ws-menu-play').click();
99
+ await page.waitForFunction(() => /** @type {any} */ (window).__wildshard?.shard?.grid?.state?.().live?.live?.gameplayReady === true, undefined, { timeout: 180_000, polling: 100 });
100
+ await sleep(2000);
101
+ await page.getByText('DONE', { exact: true }).click({ timeout: 2000 }).catch(() => undefined);
102
+ await page.evaluate(() => {
103
+ const W = /** @type {any} */ (window), q = W.__gc3 = { frames: /** @type {number[][]} */ ([]), samples: /** @type {any[]} */ ([]), longTasks: /** @type {number[][]} */ ([]), sentinel: 1, target: /** @type {string | undefined} */ (undefined) }, t0 = performance.now();
104
+ try { performance.setResourceTimingBufferSize(100_000); } catch { /* the default 250 entries */ }
105
+ // GC8: main-thread long tasks (Chromium only; WebKit has no longtask entries), as [start, duration] on the page clock
106
+ try { new PerformanceObserver(list => { for (const entry of list.getEntries()) { q.longTasks.push([Math.round(entry.startTime), Math.round(entry.duration)]); if (q.longTasks.length > 20_000) q.longTasks.splice(0, 10_000); } }).observe({ type: 'longtask', buffered: true }); } catch { /* no longtask entries */ }
107
+ let last = t0;
108
+ const raf = (/** @type {number} */ now) => { q.frames.push([Math.round(now - t0), Number((now - last).toFixed(1))]); last = now; if (q.frames.length > 60_000) q.frames.splice(0, 30_000); requestAnimationFrame(raf); };
109
+ requestAnimationFrame(raf);
110
+ setInterval(() => { try {
111
+ const st = W.__wildshard.shard.grid.state(), p = W.__wildshard.world.player, lv = st.live;
112
+ q.samples.push({ t: Math.round(performance.now() - t0), x: Number(p.position.x.toFixed(2)), y: Number(p.position.y.toFixed(2)), z: Number(p.position.z.toFixed(2)), inside: st.inside,
113
+ phase: lv?.crossing?.phase, ready: lv?.live?.gameplayReady, loading: st.cellLoading, step: st.cellStep?.step ?? null,
114
+ // GC6: whether the crossing's target world (colliders and sim) is resident yet, and the world built ahead (GC5)
115
+ built: q.target === undefined ? null : lv?.live?.residents?.includes(q.target) === true, ahead: lv?.live?.ahead?.instance ?? null, refused: lv?.live?.ahead?.refused ?? null, hy: st.hybrid ?? null, fc: W.__wildshard.world?.game?.frameCount ?? null, deferred: lv?.live?.ahead?.deferred ?? null, env: st.envelopeMB ?? null, pending: lv?.live?.pending ?? null,
116
+ // GC13: the cells whose worlds the page holds, and what playing costs
117
+ res: lv?.live?.residents ?? null, mb: st.playingMB ?? null,
118
+ // GC12: how many closed walls show (only the ones the walker stands at)
119
+ wall: st.softWalls?.shown ?? null });
120
+ if (q.samples.length > 20_000) q.samples.splice(0, 10_000);
121
+ } catch (error) { q.samples.push({ err: String(error).slice(0, 160) }); } }, 100);
122
+ });
123
+ await sleep(500);
124
+ };
125
+ await enter();
126
+ let navigationsBefore = navigations, lastWindowEnd = 0;
127
+ /** @returns {Promise<any>} */
128
+ const sample = () => page.evaluate(() => { const rows = /** @type {any[]} */ (/** @type {any} */ (window).__gc3.samples); for (let i = rows.length - 1; i >= 0; i--) if (rows[i].err === undefined) return rows[i]; return undefined; });
129
+ const face = (/** @type {number} */ yaw) => page.evaluate(wanted_ => { /** @type {any} */ (window).__wildshard.world.player.yaw = wanted_; }, yaw);
130
+
131
+ /** One crossing over `arc` from where the walker stands (in `arc.from`). @param {Arc} arc @param {boolean} repeat */
132
+ const cross = async (arc, repeat) => {
133
+ const row = /** @type {Record<string, any>} */ ({ from: arc.from, to: arc.to, boost: arc.boost, repeat, lap: currentLap, ok: false, why: '' });
134
+ crossings.push(row);
135
+ // GC8: the target's preparation work since the last crossing ended (a pre-warm starts inside the source, GC5)
136
+ const windowStart = lastWindowEnd;
137
+ await page.evaluate(target => { /** @type {any} */ (window).__gc3.target = target; }, arc.to);
138
+ const yaw = Math.atan2(-arc.dx, -arc.dz);
139
+ // the harness pose: probe.ts `told`, so the in-page server hears where the walker stands
140
+ const place = async (/** @type {number} */ inset) => {
141
+ const px = arc.dx * inset, pz = arc.dz * inset;
142
+ await page.evaluate(([x, z, y]) => { const p = /** @type {any} */ (window).__wildshard.world.player; p.spawn(x, z, y, 1.5); p.link?.place?.(p.position.x, p.position.y, p.position.z, y); }, [px, pz, yaw]);
143
+ await sleep(3000);
144
+ const at_ = await sample();
145
+ return { at_, ok: at_.inside === arc.from && Math.hypot(at_.x - px, at_.z - pz) <= 4 };
146
+ };
147
+ const { at_: placed, ok: placedOk } = await place(EDGE_IN);
148
+ row.placed = { x: placed.x, y: placed.y, z: placed.z, inside: placed.inside };
149
+ if (!placedOk) { row.why = `not placed on ${arc.from}'s entryway (inside ${String(placed.inside)})`; return row; }
150
+ await face(yaw);
151
+ const t1 = Date.now(), tFrom = (await sample()).t;
152
+ await page.keyboard.down('KeyW'); if (arc.boost) await page.keyboard.down('ShiftLeft');
153
+ let controlAt = 0, controlT = 0, jumps = 0, stuckSince = 0, last = placed, fell = false;
154
+ while (Date.now() - t1 < LEG_MS) {
155
+ await sleep(250);
156
+ const s = await sample();
157
+ if (s === undefined) continue;
158
+ const moved = Math.hypot(s.x - last.x, s.z - last.z), now = Date.now() - t1;
159
+ if (controlAt === 0) {
160
+ if (moved < 0.15) stuckSince ||= now; else stuckSince = 0;
161
+ if (stuckSince !== 0 && now - stuckSince > STUCK_MS && jumps < 4 && s.phase !== 'preparing') { await page.keyboard.press('Space'); jumps++; stuckSince = now; }
162
+ if (s.inside === arc.from && s.y < placed.y - 8) { fell = true; break; }
163
+ if (s.inside === arc.to && s.ready === true && (s.phase === undefined || s.phase === 'settled') && moved > 0.3) {
164
+ controlAt = now; controlT = s.t;
165
+ // GC14: the page's memory at each control, so the tour doubles as the long-walk soak
166
+ row.memory = await page.evaluate(() => { const W = /** @type {any} */ (window); let st = null; try { st = W.__wildshard.shard.grid.state(); } catch { /* no grid yet */ }
167
+ const perf = /** @type {any} */ (performance); return { playingMB: st?.playingMB ?? null, residentMB: st?.residentMB ?? null, heapMB: perf.memory ? Math.round(perf.memory.usedJSHeapSize / 1048576) : null }; }).catch(() => null);
168
+ }
169
+ } else if (now - controlAt > 2500) break;
170
+ last = s;
171
+ if (jumps >= 4 && stuckSince !== 0 && now - stuckSince > 10_000) break;
172
+ }
173
+ await page.keyboard.up('KeyW'); if (arc.boost) await page.keyboard.up('ShiftLeft');
174
+ // GC13 `--hold`: stand in the cell reached, so the page can let the cell behind go
175
+ await sleep(controlAt === 0 ? 400 : Math.max(400, hold));
176
+ const rows =/** @type {any[]} */ (await page.evaluate(t => /** @type {any} */ (window).__gc3.samples.filter((/** @type {any} */ r) => r.err === undefined && r.t >= t), tFrom));
177
+ const frames = /** @type {number[][]} */ (await page.evaluate(t => /** @type {any} */ (window).__gc3.frames.filter((/** @type {number[]} */ f) => (f[0] ?? 0) >= t), tFrom));
178
+ const entered = rows.find(r => r.inside === arc.to), roadAt = rows.find(r => r.inside === null);
179
+ /** longest run of consecutive samples (each ~100 ms) matching `test`, in ms, before control */
180
+ const untilT = controlAt === 0 ? Infinity : controlT;
181
+ const speeds = rows.slice(1).map((r, i) => { const p = rows[i]; return { t: r.t, v: Math.hypot(r.x - p.x, r.z - p.z) / Math.max(0.05, (r.t - p.t) / 1000), r }; });
182
+ const head = speeds.slice(2, 22).map(s => s.v).sort((a, b) => a - b), approach = head[Math.floor(head.length / 2)] ?? 0;
183
+ const longest = (/** @type {(s: { t: number, v: number, r: any }) => boolean} */ test) => { let best = 0, since = -1; for (const s of speeds) { if (s.t > untilT) break; if (test(s)) { if (since < 0) since = s.t; best = Math.max(best, s.t - since + 100); } else since = -1; } return best; };
184
+ const sum = (/** @type {(s: { t: number, v: number, r: any }) => boolean} */ test) => speeds.filter(s => s.t <= untilT && test(s)).length * 100;
185
+ // GC6: how long before the border the target's world stood built (negative: built only after the feet crossed)
186
+ const builtAt = rows.find(r => r.built === true)?.t;
187
+ row.builtBeforeBorderMs = builtAt === undefined || entered === undefined ? null : entered.t - builtAt;
188
+ row.prewarmed = rows.some(r => r.ahead === arc.to && r.inside === arc.from);
189
+ // GC13: how long after control the cell left behind still held its world (null: still held when the window ended), and the most
190
+ // the page's playing cost reached in the window
191
+ const evicted = controlAt === 0 ? undefined : rows.find(r => r.t >= controlT && Array.isArray(r.res) && !r.res.includes(arc.from));
192
+ row.fromEvictedMs = evicted === undefined ? null : evicted.t - controlT;
193
+ row.peakPlayingMB = Math.max(0, ...rows.map(r => (typeof r.mb === 'number' ? r.mb : 0)));
194
+ // GC12: how long a hex wall showed in this crossing (samples every 100 ms); only a cold crossing held at the edge should show one
195
+ row.wallShownMs = rows.filter(r => typeof r.wall === 'number' && r.wall > 0).length * 100;
196
+ const border = entered?.t ?? Infinity, near = frames.filter(f => Math.abs((f[0] ?? 0) - border) <= 3000).map(f => f[1] ?? 0);
197
+ Object.assign(row, { ok: controlAt !== 0, why: controlAt !== 0 ? '' : fell ? `fell off ${arc.from}'s entryway (no ground there)` : entered === undefined ? (roadAt === undefined ? `never left ${arc.from}` : `held on the road (${String(last.phase)})`) : 'in the cell, no control',
198
+ borderToControlMs: entered === undefined || controlAt === 0 ? null : controlT - entered.t, controlMs: controlAt === 0 ? null : controlAt, approachMps: Number(approach.toFixed(2)),
199
+ slowMs: approach > 0 ? longest(s => s.v < approach * 0.9) : null, freezeMs: longest(s => s.v * 0.1 < 0.1), wallMs: sum(s => (s.r.phase === 'preparing' || s.r.phase === 'blocked') && s.v * 0.1 < 0.1),
200
+ stepScreenMs: sum(s => s.r.loading !== null && s.r.loading !== undefined && s.r.loading !== false), over33: near.filter(ms => ms > 33).length, over50: near.filter(ms => ms > 50).length,
201
+ // GC8: how long each `cell` step stood on the loading screen in this crossing (samples every 100 ms; a build before GC8 reads none)
202
+ steps: speeds.reduce((/** @type {Record<string, number>} */ onScreen, x) => { if (x.t <= untilT && typeof x.r.step === 'string' && x.r.step !== '') onScreen[x.r.step] = (onScreen[x.r.step] ?? 0) + 100; return onScreen; }, {}),
203
+ worstFrameMs: Math.max(0, ...near), jumps, lowestY: Math.min(...rows.map(r => r.y)), end: { inside: last.inside, x: last.x, y: last.y, z: last.z, phase: last.phase } });
204
+ // GC6: each crossing keeps its samples (every 500 ms), so its cause can be read from the json
205
+ row.trace = rows.filter((_, i) => i % 5 === 0).map(r => ({ t: r.t - tFrom, x: r.x, z: r.z, inside: r.inside, phase: r.phase, ready: r.ready, step: r.step, built: r.built, ahead: r.ahead, refused: r.refused, hy: r.hy, fc: r.fc, deferred: r.deferred, mb: r.mb, env: r.env, pending: r.pending, res: r.res }));
206
+ // a failed crossing held on the road boosts back into the cell it left, so the tour goes on from there
207
+ if (!row.ok && last.inside !== arc.from && last.inside !== arc.to) {
208
+ await face(yaw + Math.PI); await page.keyboard.down('KeyW'); await page.keyboard.down('ShiftLeft');
209
+ for (const ends = Date.now() + 30_000; Date.now() < ends && (await sample())?.inside !== arc.from;) await sleep(250);
210
+ await page.keyboard.up('KeyW'); await page.keyboard.up('ShiftLeft'); await sleep(1500);
211
+ row.backIn = (await sample())?.inside === arc.from;
212
+ }
213
+ // GC8: what preparing the target cost in this window: its `wildshard.prepare:<slug>:<step>` spans (wall ms, developer pages
214
+ // only), the main thread's long tasks, and the bytes fetched under its shardfile folder (resource timing transfer sizes)
215
+ const slug = cells.find(cell => cell.instance === arc.to)?.slug ?? arc.to;
216
+ Object.assign(row, await page.evaluate(([from, name]) => {
217
+ const W = /** @type {any} */ (window), end = performance.now();
218
+ const spans = performance.getEntriesByType('measure').filter(entry => entry.name.startsWith(`wildshard.prepare:${name}:`) && entry.startTime >= from)
219
+ .map(entry => [entry.name.slice(`wildshard.prepare:${name}:`.length), Math.round(entry.startTime - from), Math.round(entry.duration)]);
220
+ const tasks = /** @type {number[][]} */ (W.__gc3.longTasks ?? []).filter(task => (task[0] ?? 0) >= from && (task[0] ?? 0) <= end);
221
+ const files = /** @type {PerformanceResourceTiming[]} */ (performance.getEntriesByType('resource')).filter(entry => entry.startTime >= from && entry.name.includes(`/${name}/`));
222
+ return { prepare: { windowMs: Math.round(end - from), spans: spans.slice(0, 200), longTasks: tasks.length, longTaskMs: tasks.reduce((total, task) => total + (task[1] ?? 0), 0),
223
+ files: files.length, bytes: files.reduce((total, entry) => total + (entry.transferSize || 0), 0), decodedBytes: files.reduce((total, entry) => total + (entry.decodedBodySize || 0), 0) }, windowEnd: end };
224
+ }, /** @type {[number, string]} */ ([windowStart, slug])).then(({ prepare, windowEnd }) => { lastWindowEnd = windowEnd; return { prepare }; }).catch(() => ({})));
225
+ if (!row.ok || row.wallMs > 0) await page.screenshot({ path: join(out, `${engineName}-${arc.from}-${arc.to}.png`) }).catch(() => undefined);
226
+ console.log(`${row.ok ? 'ok ' : 'FAIL'} ${arc.from} -> ${arc.to}${arc.boost ? ' boost' : ''}${repeat ? ' (repeat)' : ''} ${JSON.stringify({ why: row.why, b2c: row.borderToControlMs, wall: row.wallMs, freeze: row.freezeMs, over50: row.over50 })}`);
227
+ return row;
228
+ };
229
+
230
+ // the tour: from the cell the walker is in, the arc not yet crossed whose target has the most arcs left; else back over a crossed arc
231
+ let here = (await sample()).inside ?? HOME;
232
+ const left = new Set(wanted), good = /** @type {Arc[]} */ ([]);
233
+ for (let lap = 1; ; ) {
234
+ // GC14 `--laps`: once every arc is crossed, go round them all again (the soak), each row naming its lap
235
+ if (left.size === 0 && lap < laps && good.length > 0) { lap++; currentLap = lap; for (const arc of wanted) left.add(arc); }
236
+ if (left.size === 0 || crossings.length >= limit) break;
237
+ if (navigations !== navigationsBefore) { result.note = 'the page reloaded: tour stopped'; break; }
238
+ if (result.lostPage.length > 4) { result.note = 'the page was lost a fifth time: tour stopped'; break; }
239
+ const outs = [...left].filter(arc => arc.from === here);
240
+ let arc = outs.sort((a, b) => [...left].filter(o => o.from === b.to).length - [...left].filter(o => o.from === a.to).length)[0], repeat = false;
241
+ if (arc === undefined) {
242
+ // the shortest way over crossed arcs to a cell with arcs left
243
+ /** @type {Map<string, { from: string, to: string, dx: number, dz: number, boost: boolean } | null>} */ const via = new Map([[here, null]]); const queue = [here]; let goal = '';
244
+ while (queue.length > 0 && goal === '') { const cell = /** @type {string} */ (queue.shift()); for (const g of good.filter(o => o.from === cell && !via.has(o.to))) { via.set(g.to, g); queue.push(g.to); if ([...left].some(o => o.from === g.to)) { goal = g.to; break; } } }
245
+ if (goal === '') {
246
+ // stranded (a cell whose every way out failed, Far Reach's sky islands): back in by the title; the arcs out of here count as tried
247
+ for (const o of [...left].filter(row => row.from === here)) { left.delete(o); crossings.push({ from: o.from, to: o.to, boost: o.boost, repeat: false, ok: false, why: `not tried: stranded in ${here}` }); }
248
+ if (result.reentries >= 4) { result.note = `stranded in ${here} a fifth time: stopped`; break; }
249
+ // re-entry lands on HOME: stop when no arc left starts anywhere HOME's good arcs reach (one failure out of HOME otherwise re-enters four times for nothing)
250
+ const reach = new Set([HOME]); for (let grew = true; grew;) { grew = false; for (const g of good) if (reach.has(g.from) && !reach.has(g.to)) { reach.add(g.to); grew = true; } }
251
+ if (![...left].some(o => reach.has(o.from))) { result.note = `stranded in ${here}, and no arc left is reachable from ${HOME}: stopped`; break; }
252
+ result.reentries++; await enter(); navigationsBefore = navigations; lastWindowEnd = 0; here = (await sample())?.inside ?? HOME; continue;
253
+ }
254
+ let step = goal; while (via.get(step)?.from !== here) step = /** @type {Arc} */ (via.get(step)).from;
255
+ arc = /** @type {Arc} */ (via.get(step)); repeat = true;
256
+ }
257
+ left.delete(arc);
258
+ /** @type {Record<string, any>} */ let row;
259
+ try { row = await cross(arc, repeat); }
260
+ catch (error) {
261
+ // the tour's probe (window.__gc3) went with the document: the page navigated or reloaded under the crossing. Record what the
262
+ // game says about it (its own navigations write a reason first: lastEnd.ts `markReload` / `markUnload`), then enter again.
263
+ const lost = await page.evaluate(() => { const life = /** @type {Record<string, string>} */ ({}); for (let i = 0; i < localStorage.length; i++) { const key = localStorage.key(i) ?? ''; if (/life\.|selfReload/u.test(key)) life[key] = (localStorage.getItem(key) ?? '').slice(0, 400); }
264
+ return { probe: /** @type {any} */ (window).__gc3 !== undefined, url: location.href, life }; }).catch((/** @type {unknown} */ cause) => ({ probe: false, url: '', life: {}, unreadable: String(cause).slice(0, 200) }));
265
+ if (lost.probe) throw error;
266
+ const last = crossings.at(-1); if (last !== undefined && last.from === arc.from && last.to === arc.to) { last.ok = false; last.why = 'the page lost the tour probe (navigated or reloaded)'; }
267
+ result.lostPage.push({ arc: `${arc.from}:${arc.to}`, navigations: navigations - navigationsBefore, error: String(error).slice(0, 200), ...lost });
268
+ console.log(`LOST ${arc.from} -> ${arc.to}: ${JSON.stringify(lost).slice(0, 400)}`);
269
+ save(); result.reentries++; await enter(); navigationsBefore = navigations; lastWindowEnd = 0; here = (await sample())?.inside ?? HOME; continue;
270
+ }
271
+ save(); // after every crossing, so a run cut off by its timeout keeps what it measured
272
+ if (row.ok) { if (!repeat) good.push(arc); here = arc.to; } else { here = (await sample()).inside ?? here; if (repeat) good.splice(good.indexOf(arc), 1); }
273
+ }
274
+ result.reloads = navigations - navigationsBefore;
275
+ if (left.size > 0) result.untried = [...left].map(arc => `${arc.from}:${arc.to}`);
276
+ code = crossings.length > 0 && crossings.every(row => row.ok) && result.reloads === 0 ? 0 : 1;
277
+ await /** @type {import('playwright').BrowserContext | null} */ (/** @type {unknown} */ (context))?.close();
278
+ } catch (error) { result.note = `the run: ${String(error).slice(0, 400)}`; }
279
+ finally {
280
+ save();
281
+ await browser.close();
282
+ }
283
+ console.log(`grid-crossing tour: ${String(crossings.filter(row => row.ok).length)} of ${String(crossings.length)} crossings reached control; ${out}`);
284
+ process.exit(code);
@@ -4,32 +4,58 @@
4
4
  // from the deck's card, then walks into a same-worker neighbour (Sunscar, or Pine Hollow), boosts back into Driftwood and boosts out again, by
5
5
  // real input. Each leg passes with no stop (no 1.5 s under 0.15 m a sample while the key is held), no page reload, and control in the
6
6
  // target cell (the page inside it, gameplay ready, the player moving). It writes time-to-control per leg beside GC1's baseline.
7
- // scripts/browser-lane.sh node scripts/grid-crossing-walk-proof.mjs <app dist stamped with http://127.0.0.1:18799/release.json> <work dir> <key.json> [--engine=chromium|webkit] [--to=sunscar|pine|farreach|nalati] [--workers=2] [--base=<staging url>] [--out=<dir>]
7
+ // scripts/browser-lane.sh node scripts/grid-crossing-walk-proof.mjs <app dist stamped with http://127.0.0.1:18799/release.json> <work dir> <key.json> [--engine=chromium|webkit] [--to=sunscar|pine|farreach|nalati] [--workers=2] [--base=<staging url>] [--out=<dir>] [--layout=phone] [--solo]
8
+ // GRID-CROSSING GC24 (J311): --layout=phone walks at Jake's iPhone layout (402x874, pixel density 3, touch, phone tier), and each
9
+ // leg's control reads the page's memory (JS heap, the grid's resident and playing MB, the owner ledger, the memory warning);
10
+ // --solo then opens both shards' one-shard pages (?chunk=) in fresh profiles for the same read beside it.
8
11
  import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
9
12
  import { join, resolve as absolute } from 'node:path';
10
13
  import { chromium, webkit } from 'playwright';
11
14
  import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
12
15
  import { saveFixture } from './debug-settings.mjs';
16
+ import { pageMemoryAttributionExpression } from './memory-report-snapshot.mjs';
13
17
  import { openRig, WORLD_PORT } from './online-rig.mjs';
14
18
 
15
19
  const [dist = '', relativeWork = '', keyFile = ''] = process.argv.slice(2).filter(arg => !arg.startsWith('--')), work = relativeWork === '' ? '' : absolute(relativeWork);
16
20
  if (dist === '' || work === '' || keyFile === '') throw new Error('usage: grid-crossing-walk-proof.mjs <dist> <work> <key.json> [--engine=chromium|webkit] [--to=sunscar|pine|farreach|nalati] [--out=<dir>]');
17
21
  const engineName = process.argv.find(arg => arg.startsWith('--engine='))?.slice(9) ?? 'chromium', out = absolute(process.argv.find(arg => arg.startsWith('--out='))?.slice(6) ?? join(work, 'shots'));
18
22
  if (engineName !== 'chromium' && engineName !== 'webkit') throw new Error(`No engine ${engineName}`);
23
+ const phone = process.argv.includes('--layout=phone'), solo = process.argv.includes('--solo');
24
+ // GRID-CROSSING GC2: --breach, at the first wall a leg is held at (a neighbour still preparing: the page's loading wall), else when
25
+ // the last leg ends held (a cell on another worker, GC30's Far Reach wall), throws the breach cases at it by real input from where
26
+ // it stands: jump into it, jump along it both ways, and boost-jump into it. A case holds when the page never enters the target
27
+ // while its crossing is unready and the walker stays on the road, standing; entering once the neighbour is ready is the crossing.
28
+ const breach = process.argv.includes('--breach');
29
+ // GC6: --viewport=<w>x<h>@<dpr> (desktop): Jake's window is 2992x1434@2 (QA 11-14 row 6)
30
+ const desk = (/^--viewport=(\d+)x(\d+)@([\d.]+)$/u.exec(process.argv.find(arg => arg.startsWith('--viewport=')) ?? '') ?? [0, '1440', '900', '1']).slice(1).map(Number);
31
+ /** The page's memory now: JS heap (Chromium), the grid's resident and playing MB, the owner ledger's totals, the memory warning. */
32
+ const MEMORY_READ = `(() => { const api = window.__wildshard; let ledger = null; try { const mem = ${pageMemoryAttributionExpression}; ledger = mem?.totals ? { gpuMB: Math.round(mem.totals.gpu / 1048576), ramMB: Math.round(mem.totals.ram / 1048576) } : null; } catch {}
33
+ let grid = null; try { const st = api.shard.grid.state(); grid = { inside: st.inside, residentMB: st.residentMB, playingMB: st.playingMB }; } catch {}
34
+ const warning = document.querySelector('.ws-memory-warning');
35
+ return { heapMB: performance.memory ? Math.round(performance.memory.usedJSHeapSize / 1048576) : null, ledger, grid, memoryWarning: warning !== null && warning.getClientRects().length > 0 }; })()`;
36
+ /** @param {import('playwright').Browser} b */
37
+ const newContext = b => b.newContext(phone ? { viewport: { width: 402, height: 874 }, deviceScaleFactor: 3, isMobile: engineName === 'chromium', hasTouch: true,
38
+ 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' } : { viewport: { width: desk[0] ?? 1440, height: desk[1] ?? 900 }, deviceScaleFactor: desk[2] ?? 1 });
19
39
  mkdirSync(out, { recursive: true });
20
40
  /** Driftwood is cell [0, 0]; its same-worker neighbours Pine Hollow [0, 1] (+z, across the island from the spawn at z -194) and Sunscar
21
41
  * [-1, 0] (-x). Far Reach [0, -1] is sky islands: arriving at road height falls below its death floor (GC15b). */
22
42
  // Each edge is a bank from the sea floor (-3.4 m) up to the road (0 m) except its entryway, 8 m wide at the edge's middle
23
43
  // (`sections/world/edge.json`), so a crossing goes through it: `approach` are waypoints in Driftwood's frame, boosted and not scored,
24
44
  // that end in front of it; the legs then walk straight through it.
25
- const NEIGHBOURS = /** @type {Record<string, { slug: string, axis: 'x' | 'z', sign: number, approach: [number, number][] }>} */ ({
26
- pine: { slug: 'pine-hollow', axis: 'z', sign: 1, approach: [[-235, -194], [-235, 235], [0, 235]] }, sunscar: { slug: 'sunscar-dunes', axis: 'x', sign: -1, approach: [[-235, -194], [-235, 0]] },
45
+ const NEIGHBOURS = /** @type {Record<string, { slug: string, axis: 'x' | 'z', sign: number, approach: [number, number][], from?: { slug: string, card: string }, place?: boolean }>} */ ({
46
+ pine: { slug: 'pine-hollow', axis: 'z', sign: 1, approach: [[-235, -194], [-235, 0], [-200, 20], [-200, 235], [0, 235]] }, sunscar: { slug: 'sunscar-dunes', axis: 'x', sign: -1, approach: [[-235, -194], [-235, 0]] },
27
47
  // GC29 (Jake 11-13): his walk off the south dock toward Far Reach, and east into Nalati (staging: another worker).
28
- farreach: { slug: 'far-reach', axis: 'z', sign: -1, approach: [[0, -235]] }, nalati: { slug: 'nalati-grasslands', axis: 'x', sign: 1, approach: [[235, -194], [235, 0]] } });
48
+ farreach: { slug: 'far-reach', axis: 'z', sign: -1, approach: [[0, -235]] }, nalati: { slug: 'nalati-grasslands', axis: 'x', sign: 1, approach: [[235, -194], [235, 0]] },
49
+ // GC23 (J305): Night Market (open-plot-3-0, cell [1, -2]) from its north neighbour Nine Dragon [1, -1], entered by its own card.
50
+ // Nine Dragon's stack has no walkable route to its south entryway, so the approach is placed by the harness pose (not scored);
51
+ // the legs across the line are real input as everywhere else.
52
+ nightmarket: { slug: 'open-plot-3-0', axis: 'z', sign: -1, approach: [[0, -238]], from: { slug: 'nine-dragon-stack', card: 'Nine Dragon Stack' }, place: true } });
29
53
  const toName = process.argv.find(arg => arg.startsWith('--to='))?.slice(5) ?? 'sunscar', to = NEIGHBOURS[toName];
30
54
  if (to === undefined) throw new Error(`No neighbour ${toName}: ${Object.keys(NEIGHBOURS).join(', ')}`);
31
- const HOME = 'driftwood-isle', NEXT = to.slug, STUCK_MS = 1500, LEG_MS = 100_000;
32
- const LEGS = [{ name: `walk-to-${toName}`, target: NEXT, sign: 1, boost: false }, { name: 'boost-to-driftwood', target: HOME, sign: -1, boost: true }, { name: `boost-to-${toName}`, target: NEXT, sign: 1, boost: true }];
55
+ // a placed approach needs the in-page harness (preview or a loopback page): an online page can't place its seat (shell.ts place is idle)
56
+ const placed = to.place === true || process.argv.includes('--place');
57
+ const HOME = to.from?.slug ?? 'driftwood-isle', HOME_CARD = to.from?.card ?? 'Driftwood Isle', NEXT = to.slug, STUCK_MS = 1500, LEG_MS = 100_000;
58
+ const LEGS = [{ name: `walk-to-${toName}`, target: NEXT, sign: 1, boost: false }, { name: `boost-to-${HOME.split('-')[0] ?? HOME}`, target: HOME, sign: -1, boost: true }, { name: `boost-to-${toName}`, target: NEXT, sign: 1, boost: true }];
33
59
  /** @type {{ step: string, ok: boolean, detail?: unknown }[]} */
34
60
  const steps = [];
35
61
  /** @param {string} step @param {boolean} ok @param {unknown} [detail] */
@@ -46,14 +72,14 @@ const rig = served !== '' ? { base: served.replace(/\/$/, ''), close: () => Prom
46
72
  : await openRig({ dist, work, keyFile, pgBin: 'memory:', pgData: '', shard: HOME, more: ['pine-hollow', 'far-reach', 'sunscar-dunes', 'nalati-grasslands'], cells: 'grid', crossing: true, workers });
47
73
  let code = 1, browser = /** @type {import('playwright').Browser | null} */ (null);
48
74
  /** @type {Record<string, unknown>} */
49
- const result = { lane: 'opus-gc15c', engine: engineName, layout: 'desktop 1440x900', site: served !== '' ? served : 'local rig, WORLD_CELLS=grid, WORLD_CROSSING=worker, WORLD_WORKERS=2 (staging: Nalati alone, Driftwood with Pine Hollow, Sunscar and Far Reach)' };
75
+ const result = { lane: 'opus-gc15c', engine: engineName, layout: phone ? 'phone 402x874 touch' : `desktop ${String(desk[0])}x${String(desk[1])}@${String(desk[2])}`, site: served !== '' ? served : 'local rig, WORLD_CELLS=grid, WORLD_CROSSING=worker, WORLD_WORKERS=2 (staging: Nalati alone, Driftwood with Pine Hollow, Sunscar and Far Reach)' };
50
76
  try {
51
77
  let open = served !== '' ? { cells: 25 } : null;
52
78
  for (let tries = 0; tries < 300 && open === null; tries++) { open = await fetch(`http://127.0.0.1:${String(WORLD_PORT)}/health`).then(found => found.ok ? found.json() : null).catch(() => null); if (open === null) await sleep(200); }
53
79
  note('the world runs the grid', open !== null && open.cells > 1, served !== '' ? { skipped: 'a served site: not read' } : { cells: open?.cells });
54
80
  if (open === null) throw new Error(`The world did not start: see ${join(work, 'server.log')}`);
55
- browser = await (engineName === 'webkit' ? webkit : chromium).launch({ headless: true, args: engineName === 'chromium' ? [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist'] : [] });
56
- const context = await browser.newContext({ viewport: { width: 1440, height: 900 } }), page = await context.newPage(), errors = /** @type {string[]} */ ([]);
81
+ browser = await (engineName === 'webkit' ? webkit : chromium).launch({ headless: true, args: engineName === 'chromium' ? [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist', '--enable-precise-memory-info'] : [] });
82
+ const context = await newContext(browser), page = await context.newPage(), errors = /** @type {string[]} */ ([]);
57
83
  // RP4: every program's first use (three's uniform read after its link, where a link not yet finished blocks the frame),
58
84
  // counted so a leg's receipt says how many programs linked on the way (a cell's whole set relinking at its edge was 2.5 s)
59
85
  await context.addInitScript(() => {
@@ -69,20 +95,22 @@ try {
69
95
  page.on('framenavigated', frame => { if (frame === page.mainFrame()) navigations++; });
70
96
  await saveFixture(context, { scope: 'device', key: 'firstPlayDone', data: true });
71
97
  await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
98
+ if (phone) await saveFixture(context, { scope: 'global', key: 'settings', merge: true, data: { tier: 'phone', volume: 0 } });
72
99
  await page.goto(`${rig.base}/?mute=1&nolock=1`, { waitUntil: 'load' });
73
100
  await page.locator('.ws-main-select').click({ timeout: 120_000 });
74
101
  if (await page.locator('#ws-name-box input').waitFor({ timeout: 30_000 }).then(() => true).catch(() => false)) { await page.locator('#ws-name-box input').fill('walker'); await page.locator('#ws-name-box button[type=submit]').click(); }
75
102
  await page.locator('.ws-menu-card').first().waitFor({ state: 'visible', timeout: 30_000 });
76
- const index = await page.evaluate(() => [...document.querySelectorAll('.ws-menu-card')].findIndex(row => (row.textContent ?? '').includes('Driftwood Isle')));
77
- if (index < 0) throw new Error('No Driftwood Isle card');
103
+ const index = await page.evaluate(card => [...document.querySelectorAll('.ws-menu-card')].findIndex(row => (row.textContent ?? '').includes(card)), HOME_CARD);
104
+ if (index < 0) throw new Error(`No ${HOME_CARD} card`);
78
105
  await page.locator('.ws-menu-dots i').nth(index).click();
79
106
  const played = Date.now();
80
107
  await page.locator('.ws-menu-play').click();
81
108
  await page.waitForFunction(() => /** @type {any} */ (window).__wildshard?.shard?.grid?.state?.().live?.live?.gameplayReady === true, undefined, { timeout: 180_000, polling: 100 });
82
109
  result.playToReadyMs = Date.now() - played;
83
- note('Driftwood: gameplay ready after Play', true, { ms: result.playToReadyMs });
110
+ note(`${HOME_CARD}: gameplay ready after Play`, true, { ms: result.playToReadyMs });
84
111
  await sleep(2000);
85
112
  await page.getByText('DONE', { exact: true }).click({ timeout: 2000 }).catch(() => undefined);
113
+ result.memoryAtHome = await page.evaluate(MEMORY_READ);
86
114
  const navigationsBefore = navigations;
87
115
  await page.evaluate(() => {
88
116
  const W = /** @type {any} */ (window), q = W.__gc15c = { frames: /** @type {number[][]} */ ([]), samples: /** @type {unknown[]} */ ([]), sentinel: 1 }, t0 = performance.now();
@@ -93,7 +121,7 @@ try {
93
121
  setInterval(() => { try {
94
122
  const st = W.__wildshard.shard.grid.state(), p = W.__wildshard.world.player, lv = st.live, wire = W.__workerClient?.();
95
123
  q.samples.push({ t: Math.round(performance.now() - t0), x: Number(p.position.x.toFixed(2)), y: Number(p.position.y.toFixed(2)), z: Number(p.position.z.toFixed(2)), inside: st.inside, phase: lv?.crossing?.phase, target: lv?.crossing?.target, issue: lv?.crossing?.issue, site: W.__workerClient?.().site,
96
- ready: lv?.live?.gameplayReady, loading: st.cellLoading, closed: st.softWalls?.closed, feet: st.feet, frames: wire?.frames, own: wire?.own });
124
+ ready: lv?.live?.gameplayReady, loading: st.cellLoading, stage: st.cellStage, step: st.cellStep?.step ?? null, closed: st.softWalls?.closed, feet: st.feet, frames: wire?.frames, own: wire?.own });
97
125
  } catch (error) { q.samples.push({ err: String(error).slice(0, 160) }); } }, 100);
98
126
  });
99
127
  await sleep(500);
@@ -111,7 +139,7 @@ try {
111
139
  const toward = async (/** @type {number} */ x, /** @type {number} */ z) => { const at = await sample(); await face(Math.atan2(at.x - x, at.z - z)); return Math.hypot(at.x - x, at.z - z); };
112
140
  const approached = Date.now();
113
141
  await page.keyboard.down('ShiftLeft');
114
- for (const [x, z] of to.approach) {
142
+ for (const [x, z] of placed ? [] : to.approach) {
115
143
  await page.keyboard.down('KeyW');
116
144
  let near = Infinity, stuck = 0, before = await sample();
117
145
  for (const ends = Date.now() + 90_000; Date.now() < ends && near > 3; await sleep(250)) {
@@ -123,6 +151,13 @@ try {
123
151
  await page.keyboard.up('KeyW');
124
152
  note(`the approach reaches (${String(x)}, ${String(z)})`, near <= 3, { near: Math.round(near), at: { x: before.x, z: before.z } });
125
153
  }
154
+ // a placed approach: the in-page harness pose (probe.ts `told`), so the in-page server hears where the walker stands
155
+ if (placed) for (const [x, z] of to.approach) {
156
+ await page.evaluate(([px, pz]) => { const p = /** @type {any} */ (window).__wildshard.world.player; p.spawn(px, pz, p.yaw, 1.5); p.link?.place?.(p.position.x, p.position.y, p.position.z, p.yaw); }, [x, z]);
157
+ await sleep(4000);
158
+ const at = await sample();
159
+ note(`the harness places the walker at (${String(x)}, ${String(z)})`, Math.hypot(at.x - x, at.z - z) <= 3 && at.inside === HOME, { at: { x: at.x, y: at.y, z: at.z }, inside: at.inside });
160
+ }
126
161
  await page.keyboard.up('ShiftLeft'); await sleep(600);
127
162
  result.approachMs = Date.now() - approached;
128
163
  // The yaw that walks toward the neighbour: the page's motor faces atan2(own - target) (ui.ts faceToward), so +z is π and -x is π/2;
@@ -130,6 +165,41 @@ try {
130
165
  let north = to.axis === 'z' ? (to.sign > 0 ? Math.PI : 0) : (to.sign > 0 ? -Math.PI / 2 : Math.PI / 2);
131
166
  { await face(north); const a = await sample(); await page.keyboard.down('KeyW'); await sleep(1200); await page.keyboard.up('KeyW'); await sleep(300); const b = await sample();
132
167
  if ((b[to.axis] - a[to.axis]) * to.sign < 0) north += Math.PI; result.probe = { axis: to.axis, from: a[to.axis], to: b[to.axis], yaw: north }; }
168
+ /** GC2: the breach cases at the wall the walker is held at, by real input, facing `yaw` toward `target`. A case is a breach when
169
+ * the page enters the target while its crossing is still unready (preparing or blocked: the wall was closed), or the walker
170
+ * falls off the road. Run once a walk: at the first leg held at a preparing neighbour (the in-page loading wall), else at the end. */
171
+ const breachCases = async (/** @type {string} */ where, /** @type {number} */ yaw, /** @type {string} */ target) => {
172
+ /** @type {Record<string, unknown>[]} */ const cases = []; result.breach = { where, cases };
173
+ const keys = /** @type {Record<string, string[]>} */ ({ 'jump into it': ['KeyW'], 'jump along it, right': ['KeyW', 'KeyD'], 'jump along it, left': ['KeyW', 'KeyA'], 'boost-jump into it': ['KeyW', 'ShiftLeft'] });
174
+ await face(yaw);
175
+ for (const [name, held_] of Object.entries(keys)) {
176
+ const start = await sample(), sign = target === NEXT ? to.sign : -to.sign;
177
+ // the wall opened under an earlier case (the neighbour got ready): the walker is across, nothing is left to breach
178
+ if (start.inside === target) { cases.push({ name, skipped: 'the wall opened: the walker is in the target' }); note(`breach (${where}): ${name}`, true, { skipped: 'the wall opened' }); continue; }
179
+ let entered = false, breached = false, lowest = Infinity, furthest = -Infinity, last = start, closedSamples = 0, samples = 0;
180
+ for (const key of held_) await page.keyboard.down(key);
181
+ for (let jump = 0; jump < 8; jump++) {
182
+ await page.keyboard.press('Space');
183
+ for (let tick = 0; tick < 3; tick++) {
184
+ await sleep(250);
185
+ const at = await sample();
186
+ if (at === undefined || at.err !== undefined) continue;
187
+ samples++; if (at.phase === 'preparing' || at.phase === 'blocked' || (at.closed ?? 0) > 0) closedSamples++;
188
+ if (at.inside === target && last.inside !== target) { entered = true; breached ||= last.phase === 'preparing' || last.phase === 'blocked'; }
189
+ lowest = Math.min(lowest, at.y); furthest = Math.max(furthest, at[to.axis] * sign); last = at;
190
+ }
191
+ }
192
+ for (const key of held_) await page.keyboard.up(key);
193
+ await sleep(800);
194
+ const end = await sample();
195
+ await page.screenshot({ path: join(out, `${engineName}-breach-${name.replaceAll(/[^a-z]+/gu, '-')}.png`) });
196
+ const row = { name, entered, breached, closedShare: samples === 0 ? null : Number((closedSamples / samples).toFixed(2)), past: Number((furthest - start[to.axis] * sign).toFixed(2)), lowest: Number(lowest.toFixed(2)),
197
+ start: { x: start.x, y: start.y, z: start.z, phase: start.phase, closed: start.closed }, end: { inside: end.inside, x: end.x, y: end.y, z: end.z, phase: end.phase } };
198
+ cases.push(row);
199
+ // entering once the neighbour is ready is the crossing working, not a breach; a held wall must also keep the walker on the road
200
+ note(`breach (${where}): ${name} holds`, !breached && lowest > -2 && (entered || end.inside === null), row);
201
+ }
202
+ };
133
203
  /** @type {Record<string, unknown>[]} */
134
204
  const legs = [];
135
205
  for (const leg of LEGS) {
@@ -138,7 +208,7 @@ try {
138
208
  /** @type {Record<string, unknown>[]} */
139
209
  const events = [];
140
210
  let stuckSince = 0, stuckMs = 0, worstStuck = 0, last = start, enteredAt = 0, controlAt = 0, roadAt = 0, jumps = 0;
141
- const t1 = Date.now(), framesFrom = await page.evaluate(() => /** @type {any} */ (window).__gc15c.frames.length), linksFrom = await page.evaluate(() => /** @type {any} */ (window).__programLinks);
211
+ const t1 = Date.now(), samplesFrom = await page.evaluate(() => /** @type {any} */ (window).__gc15c.samples.length), framesFrom = await page.evaluate(() => /** @type {any} */ (window).__gc15c.frames.length), linksFrom = await page.evaluate(() => /** @type {any} */ (window).__programLinks);
142
212
  await face(yaw);
143
213
  await page.keyboard.down('KeyW'); if (leg.boost) await page.keyboard.down('ShiftLeft');
144
214
  while (Date.now() - t1 < LEG_MS) {
@@ -151,8 +221,14 @@ try {
151
221
  if (s.inside === leg.target && enteredAt === 0) enteredAt = at;
152
222
  if (controlAt === 0) {
153
223
  if (moved < 0.15) { stuckSince ||= at; } else { if (stuckSince !== 0) { stuckMs += at - stuckSince; worstStuck = Math.max(worstStuck, at - stuckSince); } stuckSince = 0; }
224
+ if (breach && result.breach === undefined && stuckSince !== 0 && at - stuckSince > STUCK_MS && s.inside !== leg.target && s.phase === 'preparing') {
225
+ await page.keyboard.up('KeyW'); if (leg.boost) await page.keyboard.up('ShiftLeft');
226
+ await breachCases(`${leg.name}, held at ${leg.target} while it prepares`, yaw, leg.target);
227
+ await face(yaw); await page.keyboard.down('KeyW'); if (leg.boost) await page.keyboard.down('ShiftLeft');
228
+ stuckSince = 0; last = await sample(); continue;
229
+ }
154
230
  if (stuckSince !== 0 && at - stuckSince > STUCK_MS && jumps < 4) { if (jumps === 0) { events.push({ at, stuck: true, x: s.x, z: s.z, inside: s.inside, closed: s.closed, phase: s.phase }); await page.screenshot({ path: join(out, `${engineName}-${leg.name}-stuck.png`) }); } await page.keyboard.press('Space'); jumps++; }
155
- if (s.inside === leg.target && s.ready === true && (s.phase === undefined || s.phase === 'settled') && moved > 0.3) { controlAt = at; events.push({ at, control: true, x: s.x, z: s.z }); }
231
+ if (s.inside === leg.target && s.ready === true && (s.phase === undefined || s.phase === 'settled') && moved > 0.3) { controlAt = at; events.push({ at, control: true, x: s.x, z: s.z, memory: await page.evaluate(MEMORY_READ) }); }
156
232
  }
157
233
  last = s;
158
234
  if (controlAt !== 0 && at - controlAt > 2500) break;
@@ -164,17 +240,50 @@ try {
164
240
  const end = await sample(), frames = /** @type {number[][]} */ (await page.evaluate(n => /** @type {any} */ (window).__gc15c.frames.slice(n), framesFrom));
165
241
  await page.screenshot({ path: join(out, `${engineName}-${leg.name}-after.png`) });
166
242
  const programLinks = await page.evaluate(() => /** @type {any} */ (window).__programLinks) - linksFrom;
167
- const deltas = frames.map(row => row[1] ?? 0), row = { name: leg.name, programLinks, from, target: leg.target, boost: leg.boost, roadAtMs: roadAt, enteredAtMs: enteredAt, controlAtMs: controlAt,
243
+ // NET-LAG NL7: the crossing as numbers. From the page's 100 ms samples: the border (the first sample outside the cell the leg
244
+ // left) to the target's gameplay ready, each loading-card row's time on screen, and the longest the feet stood still while the
245
+ // key was held (the stop above, at 250 ms)
246
+ const legSamples = /** @type {any[]} */ (await page.evaluate(n => /** @type {any} */ (window).__gc15c.samples.slice(n), samplesFrom)).filter(entry => entry.err === undefined);
247
+ const border = legSamples.find(entry => entry.inside !== from), ready = legSamples.find(entry => entry.inside === leg.target && entry.ready === true && (entry.phase === undefined || entry.phase === 'settled'));
248
+ /** @type {Record<string, number>} */
249
+ const stages = {};
250
+ for (const [at, entry] of legSamples.entries()) { const next = legSamples[at + 1]; if (next !== undefined && typeof entry.stage === 'string') stages[entry.stage] = (stages[entry.stage] ?? 0) + next.t - entry.t; }
251
+ const deltas = frames.map(row => row[1] ?? 0), row = { name: leg.name, borderToReadyMs: border === undefined || ready === undefined ? null : Math.max(0, ready.t - border.t), stages, programLinks, from, target: leg.target, boost: leg.boost, roadAtMs: roadAt, enteredAtMs: enteredAt, controlAtMs: controlAt,
168
252
  borderToControlMs: enteredAt === 0 || controlAt === 0 ? null : controlAt - enteredAt, worstStopMs: worstStuck, stoppedMs: stuckMs, jumps, frames: deltas.length,
169
253
  over50: deltas.filter(ms => ms > 50).length, over100: deltas.filter(ms => ms > 100).length, worstFrameMs: Math.max(0, ...deltas), events, end };
170
254
  legs.push(row);
171
255
  note(`${leg.name}: arrives in ${leg.target} with control`, controlAt !== 0, { enteredAt, controlAt, end: { inside: end.inside, z: end.z, ready: end.ready } });
172
256
  note(`${leg.name}: no stop or wall on the way`, worstStuck <= STUCK_MS && jumps === 0, { worstStuck, jumps });
173
257
  }
258
+ if (breach && result.breach === undefined) {
259
+ const held = /** @type {any} */ (legs.at(-1));
260
+ if (held === undefined || held.controlAtMs !== 0) note('breach: a leg is held at a wall', false, { skipped: 'no leg was held at a closed wall: nothing to test' });
261
+ else await breachCases('the last leg, held at a wall', north, NEXT);
262
+ }
174
263
  const sentinel = await page.evaluate(() => /** @type {any} */ (window).__gc15c?.sentinel === 1).catch(() => false);
175
264
  note('no page reload through every crossing', sentinel && navigations === navigationsBefore, { sentinel, navigations: navigations - navigationsBefore });
176
265
  note('no page errors', errors.length === 0, errors.slice(0, 5));
177
266
  result.legs = legs;
267
+ note('no memory warning at home or any control', /** @type {{ memoryWarning?: boolean } | undefined} */ (result.memoryAtHome)?.memoryWarning !== true && !legs.some(row => /** @type {any[]} */ (row.events).some(e => e.memory?.memoryWarning === true)));
268
+ if (solo) {
269
+ // the same two shards' one-shard pages, each in a fresh profile at the same layout, read 10 s after their world boots
270
+ /** @type {Record<string, any>} */ const pages = {}; result.solo = pages;
271
+ for (const slug of [HOME, NEXT]) {
272
+ const alone = await newContext(browser), one = await alone.newPage();
273
+ await saveFixture(alone, { scope: 'device', key: 'firstPlayDone', data: true });
274
+ if (phone) await saveFixture(alone, { scope: 'global', key: 'settings', merge: true, data: { tier: 'phone', volume: 0 } });
275
+ try {
276
+ await one.goto(`${rig.base}/?chunk=${slug}&skipintro=1&mute=1&nolock=1`, { waitUntil: 'load' });
277
+ if (await one.locator('#ws-name-box input').waitFor({ timeout: 20_000 }).then(() => true).catch(() => false)) { await one.locator('#ws-name-box input').fill('walker'); await one.locator('#ws-name-box button[type=submit]').click(); }
278
+ await one.waitForFunction(() => { const W = /** @type {any} */ (window); return typeof W.__workerClient === 'function' && W.__workerClient().frames > 0 && Array.isArray(W.__bootTiming?.entries) && W.__bootTiming.entries.some((/** @type {{ operation: string }} */ row) => row.operation === 'app:loader-complete'); }, undefined, { timeout: 180_000, polling: 250 });
279
+ await sleep(10_000);
280
+ pages[slug] = { url: one.url(), ...await one.evaluate(MEMORY_READ) };
281
+ await one.screenshot({ path: join(out, `${engineName}-solo-${slug}.png`) });
282
+ } catch (error) { pages[slug] = { error: String(error).slice(0, 300) }; }
283
+ note(`one-shard page ${slug} read`, pages[slug].error === undefined, pages[slug]);
284
+ await alone.close();
285
+ }
286
+ }
178
287
  const samples = await page.evaluate(() => /** @type {any} */ (window).__gc15c.samples);
179
288
  writeFileSync(join(out, `${engineName}-samples.json`), JSON.stringify(samples));
180
289
  await context.close();
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // HOST-RULER HR1 (meta docs/plans/HOST-RULER-PLAN.md): the page and section roots one built product reaches.
3
- // Not a revival of shard-platform.mjs: its roots walked src/shards/ and pre-J122 paths. A product reaches engine code
3
+ // Not a revival of the old census (retired by HR9): its roots walked src/shards/ and pre-J122 paths. A product reaches engine code
4
4
  // only through what it declares: its `client/plan` kinds and its section names. A kind roots the import() targets of
5
5
  // its one CLIENT_FEATURES entry (never the whole table); a section roots its row in SECTION_HOSTS. clientPlan.ts's own
6
6
  // static imports are one shared root, `@client-plan`, reached by every product with a `client/plan`.
@@ -15,7 +15,7 @@ export const CLIENT_PLAN_ROOT = '@client-plan';
15
15
 
16
16
  /** Section name -> the host bindings that execute it, side-first (J122). `@wildshard/format/x` resolves through the
17
17
  * pinned format package's exports map. An empty row is metadata read by another section's host: it roots nothing.
18
- * Moved from shard-platform-hosts.mjs (old `<layer>/<side>/x` selectors -> `src/<side>/<layer>/x.ts`). Fixed there:
18
+ * Moved from the old census's section table (old `<layer>/<side>/x` selectors -> `src/<side>/<layer>/x.ts`). Fixed there:
19
19
  * `game/server/shardfile/items` -> src/shared/game/shardfile/items.ts; `game/shardfile/directorClient` is gone, its
20
20
  * rows run in bindShardfileSim's DirectorStageLane. `client/plan` no longer roots `clientPlan#installClientPhase` (the
21
21
  * whole dispatch table, HA0 a) or `declaredEntry#declaredRuntimeEntry` (gone): it roots `@client-plan` and its kinds. */