@wildshard/engine 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +14 -0
  5. package/lint/ratchet.json +0 -68
  6. package/lint/ratchet.mjs +1 -4
  7. package/package.json +17 -15
  8. package/scripts/agent-sync.mjs +27 -8
  9. package/scripts/app-build/appCook.ts +8 -2
  10. package/scripts/app-build/catalogue.ts +10 -7
  11. package/scripts/app-build/gen.ts +22 -2
  12. package/scripts/app-build/isolation.d.mts +10 -0
  13. package/scripts/app-build/isolation.mjs +47 -0
  14. package/scripts/app-build/outputProducts.mjs +4 -0
  15. package/scripts/app-build/previousDeploy.d.mts +2 -0
  16. package/scripts/app-build/previousDeploy.mjs +10 -1
  17. package/scripts/app-build/serviceWorker.ts +10 -3
  18. package/scripts/app-build/splitOutput.mjs +4 -2
  19. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  20. package/scripts/app-build/standaloneOutput.mjs +5 -3
  21. package/scripts/app-build/titlePreloads.d.mts +8 -0
  22. package/scripts/app-build/titlePreloads.mjs +69 -0
  23. package/scripts/app-build/worldMapAtlas.ts +10 -6
  24. package/scripts/app-build-pipeline.mjs +31 -3
  25. package/scripts/built-product.mjs +1 -1
  26. package/scripts/cell-mem-bench.mjs +81 -23
  27. package/scripts/check-custom-sections-zero.mjs +1 -1
  28. package/scripts/check-devserver.mjs +2 -0
  29. package/scripts/check-models.mjs +2 -0
  30. package/scripts/check-paths.allow.json +0 -115
  31. package/scripts/check-paths.mjs +2 -2
  32. package/scripts/check-platform-ratchets.mjs +2 -3
  33. package/scripts/chromium-keychain.d.mts +1 -1
  34. package/scripts/ci-static.sh +1 -1
  35. package/scripts/committed-fast-checks.mjs +0 -2
  36. package/scripts/content-sw-proof.mjs +2 -1
  37. package/scripts/cook-worker.mjs +9 -3
  38. package/scripts/cook.mjs +18 -5
  39. package/scripts/docs-inputs-proof.mjs +6 -6
  40. package/scripts/e7-voice-staging-proof.mjs +1 -1
  41. package/scripts/gate-related-tests.mjs +1 -1
  42. package/scripts/git-source-view.mjs +1 -1
  43. package/scripts/goldens/capture.mjs +17 -5
  44. package/scripts/grid-crossing-nightly.mjs +59 -0
  45. package/scripts/grid-crossing-qa.mjs +44 -0
  46. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  47. package/scripts/grid-crossing-ratchet.mjs +52 -0
  48. package/scripts/grid-crossing-report.mjs +122 -0
  49. package/scripts/grid-crossing-stages.mjs +47 -0
  50. package/scripts/grid-crossing-tour.mjs +277 -0
  51. package/scripts/grid-crossing-walk-proof.mjs +124 -17
  52. package/scripts/host-ruler/roots.mjs +2 -2
  53. package/scripts/host-ruler.d.mts +91 -0
  54. package/scripts/host-ruler.mjs +565 -0
  55. package/scripts/live-prepush.py +3 -5
  56. package/scripts/loading-flow/benchmax.mjs +3 -1
  57. package/scripts/look-loop/test_look_loop.py +1 -38
  58. package/scripts/memory-proof.mjs +61 -6
  59. package/scripts/mmo-bots.mjs +8 -2
  60. package/scripts/net-lag-proof.mjs +219 -0
  61. package/scripts/night-market-kit-budget.mjs +2 -2
  62. package/scripts/offline-proof-rules.d.mts +2 -2
  63. package/scripts/offline-proof-rules.mjs +15 -4
  64. package/scripts/offline-proof.mjs +74 -13
  65. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  66. package/scripts/page-release/content.d.mts +9 -1
  67. package/scripts/page-release/content.mjs +131 -17
  68. package/scripts/page-release/flow.mjs +36 -10
  69. package/scripts/page-release/stamp-content.mjs +24 -0
  70. package/scripts/page-release.mjs +28 -6
  71. package/scripts/page-size.mjs +2 -1
  72. package/scripts/pin-packs.ts +1 -1
  73. package/scripts/pins.ts +4 -4
  74. package/scripts/precommit-checks.mjs +1 -7
  75. package/scripts/precommit-jobs.mjs +0 -1
  76. package/scripts/precommit-source.py +1 -9
  77. package/scripts/program-discovery.mjs +1 -1
  78. package/scripts/ring-cook.mjs +2 -1
  79. package/scripts/ring-step.ts +1 -1
  80. package/scripts/script-scenario-metrics.mjs +1 -1
  81. package/scripts/shard-output-content.d.mts +1 -1
  82. package/scripts/shard-output-content.mjs +2 -2
  83. package/scripts/shard-outputs.mjs +1 -1
  84. package/scripts/shard-public.mjs +1 -1
  85. package/scripts/shard-wire-meter.mjs +24 -9
  86. package/scripts/side-parity.mjs +4 -2
  87. package/scripts/standalone-smoke.mjs +8 -3
  88. package/scripts/tier-textures.mjs +22 -4
  89. package/scripts/tile-bake-report.mjs +1 -1
  90. package/scripts/tile-bakes.mjs +1 -1
  91. package/scripts/title-assets.generated.json +2 -0
  92. package/scripts/tsconfig.json +0 -2
  93. package/scripts/vendor/basisu/LICENSE +201 -0
  94. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  95. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  96. package/scripts/vitest-push-guards.config.ts +1 -1
  97. package/scripts/vps/harden-apply.sh +4 -1
  98. package/scripts/vps/harden-prometheus.sh +176 -0
  99. package/scripts/vps/harden.sh +16 -0
  100. package/scripts/vps/rebuild.sh +18 -0
  101. package/scripts/vps/wildshard-config +6 -2
  102. package/scripts/worker-client-play.mjs +6 -2
  103. package/scripts/worktree-reap.mjs +5 -5
  104. package/src/.oxlintrc.json +3 -182
  105. package/src/client/app/entry.ts +10 -2
  106. package/src/client/engine/boot/bootCache.ts +2 -2
  107. package/src/client/engine/boot/bootTrace.ts +12 -4
  108. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  109. package/src/client/engine/boot/clearDownloads.ts +5 -2
  110. package/src/client/engine/boot/contentRead.ts +11 -0
  111. package/src/client/engine/boot/gpuFiles.ts +4 -2
  112. package/src/client/engine/boot/lastEnd.ts +99 -12
  113. package/src/client/engine/boot/texturePack.ts +2 -2
  114. package/src/client/engine/net/netPlayer.ts +19 -2
  115. package/src/client/engine/net/otherPlayers.ts +55 -8
  116. package/src/client/engine/net/predictor.ts +33 -9
  117. package/src/client/engine/net/redial.ts +29 -6
  118. package/src/client/engine/pwa/cacheNames.ts +58 -1
  119. package/src/client/engine/pwa/sw.js +41 -11
  120. package/src/client/engine/render/dataLook.ts +152 -40
  121. package/src/client/engine/render/families/detail.ts +89 -0
  122. package/src/client/engine/render/families/pbr.ts +7 -1
  123. package/src/client/engine/render/look.ts +6 -0
  124. package/src/client/engine/render/lookLight.ts +103 -11
  125. package/src/client/engine/render/lookRender.ts +105 -0
  126. package/src/client/engine/saves/indexed.ts +2 -2
  127. package/src/client/engine/telemetry/browserErrors.ts +24 -3
  128. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  129. package/src/client/engine/ui/debugOptions.ts +1 -1
  130. package/src/client/engine/ui/lookLightOption.ts +10 -6
  131. package/src/client/engine/ui/namePrompt.ts +7 -0
  132. package/src/client/game/boot/audio.generated.ts +114 -114
  133. package/src/client/game/boot/bytes.generated.ts +118 -220
  134. package/src/client/game/boot/placedSpawn.ts +35 -0
  135. package/src/client/game/boot/spawnDownload.ts +25 -6
  136. package/src/client/game/boot/versions.generated.ts +7 -5
  137. package/src/client/game/devScene/hook.ts +291 -0
  138. package/src/client/game/grid/cellLoading.ts +12 -2
  139. package/src/client/game/grid/live.ts +112 -16
  140. package/src/client/game/grid/liveSession.ts +33 -2
  141. package/src/client/game/grid/mapAtlas.ts +18 -4
  142. package/src/client/game/grid/minimapBlend.ts +15 -5
  143. package/src/client/game/grid/oneWayIn.ts +5 -1
  144. package/src/client/game/grid/placedCells.ts +114 -12
  145. package/src/client/game/grid/placedContent.ts +85 -0
  146. package/src/client/game/grid/prefetch.ts +9 -1
  147. package/src/client/game/grid/productInputs.ts +3 -1
  148. package/src/client/game/grid/productLeases.ts +4 -1
  149. package/src/client/game/grid/products.ts +8 -4
  150. package/src/client/game/grid/roadLook.ts +24 -15
  151. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  152. package/src/client/game/grid/roadResources.ts +24 -0
  153. package/src/client/game/grid/roadSign.worker.ts +4 -3
  154. package/src/client/game/grid/roadSignPaint.ts +16 -5
  155. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  156. package/src/client/game/grid/roadSignScale.ts +8 -0
  157. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  158. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  159. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  160. package/src/client/game/grid/roadTileWriter.ts +2 -1
  161. package/src/client/game/grid/screenReports.ts +39 -0
  162. package/src/client/game/grid/session.ts +20 -4
  163. package/src/client/game/grid/softWallLook.ts +25 -8
  164. package/src/client/game/mainMenu.ts +6 -2
  165. package/src/client/game/plugin/context.ts +2 -1
  166. package/src/client/game/plugin/followedMovers.ts +7 -1
  167. package/src/client/game/quest/figures.ts +2 -0
  168. package/src/client/game/session/finish.ts +6 -0
  169. package/src/client/game/shardfile/assetCache.ts +4 -4
  170. package/src/client/game/shardfile/client.ts +4 -1
  171. package/src/client/game/shardfile/clientAssets.ts +9 -5
  172. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  173. package/src/client/game/shardfile/clientWater.ts +51 -9
  174. package/src/client/game/shardfile/clientWorker.ts +19 -7
  175. package/src/client/game/shardfile/look.ts +8 -3
  176. package/src/client/game/shardfile/product.ts +34 -7
  177. package/src/client/game/shardfile/productChecks.ts +2 -2
  178. package/src/client/game/shardfile/productCost.ts +2 -2
  179. package/src/client/game/shardfile/readAsset.ts +2 -2
  180. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  181. package/src/client/game/shardfile/seatGrace.ts +9 -0
  182. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  183. package/src/client/game/systems/npc/figureRows.ts +9 -0
  184. package/src/client/host/online/doctor.ts +2 -0
  185. package/src/client/host/online/linkScreens.ts +30 -4
  186. package/src/client/host/standalone/shell.ts +4 -0
  187. package/src/cook/game/astc6Encode.ts +55 -0
  188. package/src/cook/game/astc6Wasm.ts +176 -0
  189. package/src/cook/game/cookJob.ts +30 -6
  190. package/src/cook/game/cookWorker.ts +38 -11
  191. package/src/cook/game/entryTotals.ts +51 -24
  192. package/src/cook/game/shardCook.ts +35 -7
  193. package/src/cook/game/spawnParts.ts +33 -8
  194. package/src/cook/game/tierTextures.ts +87 -14
  195. package/src/server/engine/ai/bossContenders.ts +27 -3
  196. package/src/server/engine/ai/phases.ts +1 -1
  197. package/src/server/engine/entities/creatureRefill.ts +9 -2
  198. package/src/server/engine/net/ledgerBook.ts +2 -0
  199. package/src/server/engine/net/room.ts +15 -0
  200. package/src/server/engine/sim/respawn.ts +8 -0
  201. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  202. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  203. package/src/server/game/boss/native.ts +2 -1
  204. package/src/server/game/boss/nativeWake.ts +9 -5
  205. package/src/server/game/boss/openArenaNative.ts +2 -2
  206. package/src/server/game/boss/openArenaRoom.ts +3 -1
  207. package/src/server/game/grid/room.ts +44 -3
  208. package/src/server/game/grid/simulation.ts +23 -0
  209. package/src/server/game/population/mixedRoster.ts +11 -3
  210. package/src/server/game/population/nativeBake.ts +8 -3
  211. package/src/server/game/population/nativeReturns.ts +6 -3
  212. package/src/server/game/population/roster.ts +5 -3
  213. package/src/server/game/quest/eliteDrops.ts +15 -4
  214. package/src/server/game/quest/nativeChapter.ts +1 -1
  215. package/src/server/game/quest/nativeComposition.ts +5 -1
  216. package/src/server/game/riding/nativeTaming.ts +10 -6
  217. package/src/server/game/riding/wildRefill.ts +3 -2
  218. package/src/server/game/shardfile/bossRow.ts +4 -2
  219. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  220. package/src/server/host/bake/headlessWorker.ts +1 -1
  221. package/src/server/host/dedicated/cellHost.ts +98 -16
  222. package/src/server/host/dedicated/cellProtocol.ts +16 -1
  223. package/src/server/host/dedicated/cellWorker.ts +8 -5
  224. package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
  225. package/src/server/host/dedicated/gridCells.ts +15 -6
  226. package/src/server/host/dedicated/loopLag.ts +21 -0
  227. package/src/server/host/dedicated/main.ts +13 -5
  228. package/src/server/host/dedicated/packReader.ts +3 -3
  229. package/src/server/host/dedicated/placementFile.ts +3 -2
  230. package/src/server/host/dedicated/roadRoom.ts +34 -4
  231. package/src/server/host/dedicated/serverMetrics.ts +126 -0
  232. package/src/server/host/dedicated/socketPump.ts +21 -4
  233. package/src/server/host/dedicated/workerTable.ts +15 -4
  234. package/src/server/host/dedicated/world.ts +65 -7
  235. package/src/server/host/headless.ts +1 -1
  236. package/src/server/host/headlessRuntime.ts +1 -1
  237. package/src/server/host/standalone/roadWorld.ts +15 -3
  238. package/src/server/host/standalone/serverHost.ts +4 -1
  239. package/src/server/host/standalone/serverProduct.ts +41 -11
  240. package/src/shared/engine/ai/BossBrain.ts +8 -0
  241. package/src/shared/game/boss/wake.ts +6 -0
  242. package/src/shared/game/devColliders.ts +47 -0
  243. package/src/shared/game/eliteSystem.ts +8 -0
  244. package/src/shared/game/grid/allocator.ts +3 -0
  245. package/src/shared/game/grid/placementRows.ts +5 -2
  246. package/src/shared/game/plugin/bossRecord.ts +3 -2
  247. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  248. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  249. package/src/shared/game/shardfile/packReads.ts +28 -3
  250. package/src/shared/game/shardfile/serverPack.ts +9 -0
  251. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  252. package/src/shared/host/formatJsonSchema.ts +2 -2
  253. package/src/tsconfig.json +1 -27
  254. package/lint/host-reviews.json +0 -14
  255. package/lint/listed-view-code.json +0 -13
  256. package/lint/platform-pending-users.json +0 -2520
  257. package/lint/platform-pending-users.md +0 -18
  258. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  259. package/scripts/check-closed-components.d.mts +0 -7
  260. package/scripts/check-closed-components.mjs +0 -87
  261. package/scripts/g571-hosts.d.mts +0 -3
  262. package/scripts/g571-hosts.mjs +0 -54
  263. package/scripts/host-ruler/register-migrate.mjs +0 -242
  264. package/scripts/listed-view-code.d.mts +0 -7
  265. package/scripts/listed-view-code.mjs +0 -93
  266. package/scripts/look-loop/fit-lut.py +0 -142
  267. package/scripts/look-loop/palette-delta.py +0 -183
  268. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  269. package/scripts/look-loop/regions/far-reach.json +0 -225
  270. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  271. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  272. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  273. package/scripts/platform-chargebacks.d.mts +0 -9
  274. package/scripts/platform-chargebacks.mjs +0 -135
  275. package/scripts/shard-component-spans.d.mts +0 -15
  276. package/scripts/shard-component-spans.mjs +0 -18
  277. package/scripts/shard-components.d.mts +0 -16
  278. package/scripts/shard-components.mjs +0 -363
  279. package/scripts/shard-platform-hosts.d.mts +0 -2
  280. package/scripts/shard-platform-hosts.mjs +0 -93
  281. package/scripts/shard-platform-sections.d.mts +0 -2
  282. package/scripts/shard-platform-sections.mjs +0 -9
  283. package/scripts/shard-platform.d.mts +0 -76
  284. package/scripts/shard-platform.mjs +0 -1072
  285. package/src/.oxfmtrc.json +0 -48
  286. package/src/scripts/ask-new.sh +0 -29
  287. package/src/scripts/asks.mjs +0 -142
  288. package/src/scripts/herdr-prompt.sh +0 -34
  289. package/src/scripts/herdr-question-open.sh +0 -67
  290. package/src/scripts/md-wrap.mjs +0 -229
  291. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  292. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  293. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -15,7 +15,7 @@ import {VOICE_FULL_M} from '../src/client/engine/net/voiceNear.ts';
15
15
  const [base,build,key,out=new URL('../tmp/e7-voice-staging/',import.meta.url).pathname]=process.argv.slice(2);
16
16
  assert.equal(new URL(base).origin,'https://staging.wildshard.io','J205 requires the isolated staging page');
17
17
  assert.match(build,/^[a-f0-9]{40}$/u);assert.match(key,/^[a-f0-9]+$/u);mkdirSync(out,{recursive:true});
18
- const releaseURL='https://wildshard-packs.wildshard.workers.dev/releases/staging.json',sockets=['wss://rooms-staging.wildshard.io','wss://wildshard.tailb41b20.ts.net:8443'];
18
+ const releaseURL='https://packs.wildshard.io/releases/staging.json',sockets=['wss://rooms-staging.wildshard.io','wss://wildshard.tailb41b20.ts.net:8443'];
19
19
  const signed=await(await fetch(releaseURL,{cache:'no-store',redirect:'error',signal:AbortSignal.timeout(30000)})).json();
20
20
  assert.ok(verify(null,Buffer.from(signed.body),createPublicKey({key:Buffer.from(key,'hex'),format:'der',type:'spki'}),Buffer.from(signed.signature,'hex')));
21
21
  const release=JSON.parse(signed.body);assert.equal(release.channel,'staging');assert.equal(release.engineBuild,build);const socket=release.socket.replace(/\/$/u,'');assert.ok(sockets.includes(socket),socket);
@@ -37,7 +37,7 @@ export function pushGuards(changed) {
37
37
  return [
38
38
  ...(changed.some(file => /^src\/(?:format|sdk|sharddev)\//u.test(file)) ? ['test/schema-reference.test.ts'] : []),
39
39
  'test/host-callbacks.test.ts', 'test/shardfile-boundaries.test.ts',
40
- 'test/platform-chargebacks.test.ts', 'test/manifest-declarations.test.ts',
40
+ 'test/manifest-declarations.test.ts',
41
41
  ];
42
42
  }
43
43
 
@@ -203,7 +203,7 @@ export function deriveGitDiscovery(view,path) {
203
203
  genShards(process.cwd());
204
204
  console.log(JSON.stringify(Object.fromEntries(outputs.map(file=>[file,createHash('sha256').update(readFileSync(file)).digest('hex')]))));
205
205
  `;
206
- const output=execFileSync(process.execPath,['--experimental-transform-types','--import','./scripts/shard-platform-format.mjs','--input-type=module','--eval',source,'--',JSON.stringify(job.nativeOutputs)],{cwd:view.root,encoding:'utf8',maxBuffer:8*1024*1024,
206
+ const output=execFileSync(process.execPath,['--experimental-transform-types','--import','./scripts/node-format.mjs','--input-type=module','--eval',source,'--',JSON.stringify(job.nativeOutputs)],{cwd:view.root,encoding:'utf8',maxBuffer:8*1024*1024,
207
207
  env:{...process.env,WS_GIT_CHECK_ROOT:view.root,WS_GIT_CHECK_REV:view.revision}});
208
208
  const line=output.trim().split('\n').at(-1);
209
209
  if(line===undefined)throw new Error('Missing generated-output proof');
@@ -18,9 +18,9 @@
18
18
  // and turns the board back on. ON_FOOT: a board that shows in the frame. It stows Sky's fan and fills its hover decks, and
19
19
  // its goldens have neither, so a player hovering there for its streaming steps off for the shot.
20
20
  import {chromium,webkit,devices} from 'playwright';
21
- import {readFileSync,writeFileSync,mkdirSync} from 'node:fs';
21
+ import {existsSync,readFileSync,statSync,writeFileSync,mkdirSync} from 'node:fs';
22
22
  import {readFile} from 'node:fs/promises';
23
- import {saveFixture,developerSettings,hideDeveloperOverlays,levelDownloadFixtures} from '../debug-settings.mjs';
23
+ import {saveFixture,developerSettings,hideDeveloperOverlays,levelDownloadFixtures,NAME_ASKED} from '../debug-settings.mjs';
24
24
  import {loadingCardIndex} from '../loading-benchmark/catalogue.mjs';
25
25
  import {pressEscape} from '../parity/browser-escape.mjs';
26
26
  import {KEYCHAIN_ARGS} from '../chromium-keychain.mjs';
@@ -49,6 +49,10 @@ const hideAstc=()=>{const ext='WEBGL_compressed_texture_astc';for(const gl of [W
49
49
  gl.prototype.getSupportedExtensions=function(){return getSupportedExtensions.call(this)?.filter(name=>name!==ext)??null;};}};
50
50
  // --level-download=packs|shardfile (DL16): Debug ▸ Loading & memory ▸ Level download for every capture (default: the build's)
51
51
  const LEVEL_DOWNLOAD=arg('level-download','');if(!['','packs','shardfile'].includes(LEVEL_DOWNLOAD))throw Error(`--level-download=${LEVEL_DOWNLOAD}`);
52
+ // --serve-over=<dir> (S12c): answer a request whose path is a file under <dir> from that file, so a cook's phone textures (laid
53
+ // out at the URLs they stand in for) are judged on a served build. Pair it with --level-download=shardfile: a pack part is not a request.
54
+ const SERVE_OVER=arg('serve-over',''),overHits=new Set();
55
+ const DIRECT=process.argv.includes('--direct');
52
56
  mkdirSync(root,{recursive:true});
53
57
 
54
58
  // --engine=webkit: Playwright's WebKit (muted by the game's volume 0; its Escape is a plain key press)
@@ -90,6 +94,7 @@ try{for(const slug of slugs){
90
94
  await developerSettings(context,{tier:'phone',volume:0,time:'midday',weather:'clear'});
91
95
  await saveFixture(context,{scope:'global',key:'gfx',data:{dpr:'2',aa:'auto'}});
92
96
  await saveFixture(context,{scope:'device',key:'debug.global.holdLoading',data:'off'});
97
+ await saveFixture(context,NAME_ASKED);// MP2.4: the Name prompt otherwise covers SHARD SELECT
93
98
  if (LEVEL_DOWNLOAD!=='') for (const fixture of levelDownloadFixtures(LEVEL_DOWNLOAD)) await saveFixture(context,fixture);
94
99
  // --device-save=<key>=<value>: a Debug row's device slot for a look A / B (D227's debug.gltfMips=on); repeatable
95
100
  for (const pair of process.argv.filter(x=>x.startsWith('--device-save=')).map(x=>x.slice(14))) {
@@ -98,6 +103,8 @@ try{for(const slug of slugs){
98
103
  }
99
104
  await context.addInitScript(hideDeveloperOverlays);
100
105
  if(NO_ASTC)await context.addInitScript(hideAstc);
106
+ if(SERVE_OVER)await context.route(()=>true,async route=>{const path=new URL(route.request().url()).pathname,file=`${SERVE_OVER}${decodeURIComponent(path)}`;
107
+ if(!path.includes('..')&&existsSync(file)&&statSync(file).isFile()){overHits.add(path);await route.fulfill({status:200,body:readFileSync(file),headers:{'content-type':'application/octet-stream'}});}else await route.fallback();});
101
108
  await context.addInitScript(textures=>{window.__wildshardHarness={seed:357,capture:null,...(textures===''?{}:{textures})};},TEXTURES);
102
109
  if (slug==='nine-dragon-stack'&&nativeBinding!==null) await context.addInitScript(`window.__installGoldenResidency=()=>window.__goldenResidencyPromise??=(async()=>{
103
110
  try {
@@ -120,7 +127,9 @@ try{for(const slug of slugs){
120
127
  const version=await(await page.request.get(new URL('/version.json',base).href)).json();
121
128
  const actual=goldenPreviewIdentity(version,arg('sha',''));
122
129
  if(actual.build!==source.build)throw Error(`Preview changed from ${source.build} to ${actual.build}`);row.build=actual.build;
123
- await page.goto(base,{waitUntil:'load'});
130
+ // --direct (S12c): enter by the shard's own URL (`?chunk=<slug>`), as scripts/tier-textures-proof.mjs does. Since J300's Shard select
131
+ // enters the grid at a shard's cell (a42f92b6), the title's card no longer reaches a grid-hosted shard's one-shard page.
132
+ await page.goto(DIRECT?`${base.replace(/\/$/u,'')}/?chunk=${slug}&skipintro&mute=1&nolock=1`:base,{waitUntil:'load'});
124
133
  if (slug==='nine-dragon-stack'&&nativeBinding!==null) {
125
134
  // The per-document DOM-ready hook also covers SHARD SELECT's fresh-page
126
135
  // navigation. The title's explicit handshake precedes every menu action.
@@ -129,13 +138,16 @@ try{for(const slug of slugs){
129
138
  const failure=await page.evaluate(()=>window.__goldenResidencyFailure);if(failure)throw new Error(failure);
130
139
  row.nativeBinding={...nativeBinding,installed:'per-document-dom-ready-before-world-entry'};
131
140
  }
141
+ let clicker;if(DIRECT)clicker=setInterval(()=>{void page.locator('.ws-load-play').click({timeout:500}).catch(()=>undefined);},1000);else{
132
142
  await page.locator('.ws-main-select').click();
133
143
  const names=await page.locator('.ws-menu-card b').allTextContents();
134
144
  await page.locator(`.ws-menu-dots i[data-i="${loadingCardIndex(names,slug)}"]`).click();
135
145
  // ENTER WORLD, the one entry (the shardfile, G531; QD7 LD5 removed the LEGACY / SHARDFILE pair)
136
146
  const button=page.locator('.ws-menu-play');
137
147
  if(await button.isDisabled())throw Error(`${mode} entry disabled`);await button.click();
148
+ }
138
149
  await page.waitForFunction(()=>!!window.__wildshard?.world?.hud?.entered&&!document.querySelector('.ws-load')&&window.__wildshard.world.game.frameGate(),undefined,{timeout:180000});
150
+ clearInterval(clicker);
139
151
  if (slug==='nine-dragon-stack'&&nativeBinding!==null) {
140
152
  await page.waitForFunction(()=>window.__goldenResidency!==undefined||window.__goldenResidencyFailure!==undefined);
141
153
  const failure=await page.evaluate(()=>window.__goldenResidencyFailure);if(failure)throw new Error(failure);
@@ -208,7 +220,7 @@ try{for(const slug of slugs){
208
220
  }
209
221
  row.status=row.errors.length===0?'complete':'errors';
210
222
  }catch(error){row.status='failed';row.failure=String(error);if(page)await page.screenshot({path:`${dir}/failure.jpg`,type:'jpeg',quality:80,scale:'css'}).catch(()=>{});}
211
- finally{rows.push(row);writeFileSync(`${root}/receipts-${slug}.json`,JSON.stringify(row,null,1));writeFileSync(`${root}/receipts.json`,JSON.stringify(rows,null,2));await context.close();
212
- console.log(JSON.stringify({slug,status:row.status,poses:row.poses.length,idle:row.poses.map(p=>p.idle.settled),failure:row.failure,errors:row.errors.slice(0,3),warnings:Object.values(row.warnings).reduce((n,c)=>n+c,0)}));}
223
+ finally{if(SERVE_OVER)row.servedOver=[...overHits].sort();rows.push(row);writeFileSync(`${root}/receipts-${slug}.json`,JSON.stringify(row,null,1));writeFileSync(`${root}/receipts.json`,JSON.stringify(rows,null,2));await context.close();
224
+ console.log(JSON.stringify({slug,status:row.status,poses:row.poses.length,idle:row.poses.map(p=>p.idle.settled),failure:row.failure,errors:row.errors.slice(0,3),warnings:Object.values(row.warnings).reduce((n,c)=>n+c,0),...(SERVE_OVER?{servedOver:overHits.size}:{})}));}
213
225
  if(row.status==='failed')process.exitCode=1;
214
226
  }}finally{try{await browser.close();}finally{await owner?.close();}}
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ // GRID-CROSSING GC17: GC3's crossing run every night and after every staging release, from this Mac until MAC-MINI-RUNNER MR7 takes it.
3
+ // One call decides what is due and runs it (a launchd agent calls it every hour):
4
+ // release staging's signed release file (packs.wildshard.io/releases/staging.json) names a serial no run has read: the online walks
5
+ // (`grid-crossing-qa.mjs`, Driftwood's exits, Chromium and WebKit, desktop and phone) on staging
6
+ // nightly after 03:00 (this Mac's clock) and none yet today: the every-pair tour (`grid-crossing-tour.mjs`, Chromium desktop) on preview
7
+ // Each run writes `grid-crossing-report.mjs`'s report under <root>/<kind>-<stamp>/report and checks the ratchet: a pair worse than
8
+ // `test/grid-crossing-ratchet.json` is red. Every run appends one line to ~/.cache/wildshard/lane-receipts.log (`grid-nightly DONE` or
9
+ // `grid-nightly RED`, naming the red pairs), which the coordinator reads to open a QA-FEEDBACK row. State (the last serial and night) is
10
+ // <root>/state.json.
11
+ // node scripts/grid-crossing-nightly.mjs [--root=<dir>] [--force=release|nightly] [--dry-run]
12
+ // --root defaults to ~/.cache/wildshard/plan-artifacts/grid/nightly. --dry-run prints what is due and runs nothing.
13
+ import { spawnSync } from 'node:child_process';
14
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
15
+ import { homedir } from 'node:os';
16
+ import { join } from 'node:path';
17
+
18
+ /** @param {string} name @param {string} fallback */
19
+ const flag = (name, fallback) => process.argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback;
20
+ const root = flag('root', join(homedir(), '.cache/wildshard/plan-artifacts/grid/nightly')), force = flag('force', ''), dry = process.argv.includes('--dry-run');
21
+ const RECEIPTS = join(homedir(), '.cache/wildshard/lane-receipts.log'), STATE = join(root, 'state.json'), here = join(import.meta.dirname, '..');
22
+ mkdirSync(root, { recursive: true });
23
+ /** @type {{ serial: number | null, night: string | null }} */
24
+ const state = existsSync(STATE) ? JSON.parse(readFileSync(STATE, 'utf8')) : { serial: null, night: null };
25
+
26
+ const now = new Date(), pad = (/** @type {number} */ n) => String(n).padStart(2, '0');
27
+ const today = `${String(now.getFullYear())}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`, stamp = `${today}T${pad(now.getHours())}${pad(now.getMinutes())}`;
28
+ const signed = /** @type {{ body: string }} */ (await (await fetch('https://packs.wildshard.io/releases/staging.json', { cache: 'no-store' })).json());
29
+ const serial = /** @type {{ serial: number }} */ (JSON.parse(signed.body)).serial;
30
+
31
+ /** @type {('release' | 'nightly')[]} */
32
+ const due = [];
33
+ if (force === 'release' || (force === '' && Number.isFinite(serial) && serial !== state.serial)) due.push('release');
34
+ if (force === 'nightly' || (force === '' && now.getHours() >= 3 && state.night !== today)) due.push('nightly');
35
+ console.log(`grid-crossing nightly: staging serial ${String(serial)} (last read ${String(state.serial)}), night ${today} (last ${String(state.night)}); due: ${due.join(', ') || 'nothing'}`);
36
+ if (dry || due.length === 0) process.exit(0);
37
+
38
+ /** @param {string[]} args */
39
+ const run = (args) => spawnSync(join(here, 'scripts/browser-lane.sh'), ['--max', '90', 'node', ...args], { cwd: here, stdio: 'inherit' }).status;
40
+ const clock = () => { const d = new Date(); return `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())} UTC`; };
41
+ let red = false;
42
+ for (const kind of due) {
43
+ const dir = join(root, `${kind}-${stamp}`);
44
+ mkdirSync(dir, { recursive: true });
45
+ const walked = kind === 'release'
46
+ ? run(['scripts/grid-crossing-qa.mjs', '--base=https://staging.wildshard.io', `--out=${join(dir, 'walks')}`])
47
+ : run(['scripts/grid-crossing-tour.mjs', '--base=https://preview.wildshard.io', `--out=${join(dir, 'tour')}`, '--lane=grid-nightly']);
48
+ const runs = kind === 'release' ? join(dir, 'walks/rows.json') : join(dir, 'tour');
49
+ const report = spawnSync('node', ['scripts/grid-crossing-report.mjs', join(dir, 'report'), `--runs=${runs}`], { cwd: here, encoding: 'utf8' });
50
+ writeFileSync(join(dir, 'report.log'), `${report.stdout}${report.stderr}`);
51
+ const worse = report.stdout.split('\n').filter(line => line.startsWith('WORSE ')).slice(0, 8).join('; ');
52
+ const ok = report.status === 0;
53
+ red ||= !ok;
54
+ const what = kind === 'release' ? `staging serial ${String(serial)} walks` : 'preview every-pair tour';
55
+ appendFileSync(RECEIPTS, `${clock()} grid-nightly ${ok ? 'DONE' : 'RED'}: GC17 ${kind} ${what}, ${ok ? 'no pair worse than the ratchet' : `ratchet broken: ${worse || 'see report.log'}`}${walked === 0 ? '' : ' (the run itself exited non-zero)'}, ${join(dir, 'report/report.html')}\n`);
56
+ if (kind === 'release') state.serial = serial; else state.night = today;
57
+ writeFileSync(STATE, `${JSON.stringify(state, null, 2)}\n`);
58
+ }
59
+ process.exit(red ? 1 : 0);
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ // GRID-CROSSING GC1: the crossing harness, one command. It runs `grid-crossing-walk-proof.mjs` (enter the grid by the deck card,
3
+ // approach a named neighbour's entryway, then walk out, boost back home and boost out, by real input) in Chromium and WebKit at the
4
+ // desktop and phone layouts, one after another inside the browser lane, and writes one JSON row per browser and layout to
5
+ // <out>/rows.json: per leg the time from the line to control, the worst stop, frames over 50 and 100 ms, programs linked, and the
6
+ // page's memory at control (JS heap, the grid's resident and playing MB, the memory warning), plus each run's shots under <out>/<run>/.
7
+ // Staging, preview or a loopback page only (the walk proof refuses production, J205).
8
+ // node scripts/grid-crossing-qa.mjs --base=https://staging.wildshard.io [--to=sunscar|pine|farreach|nalati|nightmarket]
9
+ // [--engines=chromium,webkit] [--layouts=desktop,phone] [--out=~/.cache/wildshard/plan-artifacts/grid-crossing/<stamp>]
10
+ import { spawnSync } from 'node:child_process';
11
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
12
+ import { homedir } from 'node:os';
13
+ import { join, resolve as absolute } from 'node:path';
14
+
15
+ /** @param {string} name @param {string} fallback */
16
+ const flag = (name, fallback) => process.argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback;
17
+ const base = flag('base', ''), to = flag('to', 'sunscar');
18
+ if (base === '') throw new Error('usage: grid-crossing-qa.mjs --base=<staging, preview or loopback url> [--to=…] [--engines=…] [--layouts=…] [--out=…]');
19
+ const stamp = new Date().toISOString().replaceAll(/[:.]/gu, '-').slice(0, 19);
20
+ const out = absolute(flag('out', join(homedir(), '.cache/wildshard/plan-artifacts/grid-crossing', `${stamp}-${to}`)));
21
+ mkdirSync(out, { recursive: true });
22
+ const root = join(import.meta.dirname, '..');
23
+ /** @type {Record<string, unknown>[]} */
24
+ const rows = [];
25
+ for (const engine of flag('engines', 'chromium,webkit').split(',')) {
26
+ for (const layout of flag('layouts', 'desktop,phone').split(',')) {
27
+ const run = `${engine}-${layout}`, dir = join(out, run);
28
+ const args = [join(root, 'scripts/grid-crossing-walk-proof.mjs'), 'x', dir, 'x', `--base=${base}`, `--to=${to}`, `--engine=${engine}`, `--out=${dir}`,
29
+ ...layout === 'phone' ? ['--layout=phone'] : []];
30
+ const done = spawnSync(join(root, 'scripts/browser-lane.sh'), ['--max', '20', process.execPath, ...args], { cwd: root, stdio: 'inherit' });
31
+ const file = join(dir, `${engine}-gc15c-walk.json`);
32
+ /** @type {any} */
33
+ const walk = existsSync(file) ? JSON.parse(readFileSync(file, 'utf8')) : null;
34
+ rows.push({ run, engine, layout, base, to, pass: done.status === 0, playToReadyMs: walk?.playToReadyMs ?? null, memoryAtHome: walk?.memoryAtHome ?? null,
35
+ legs: (walk?.legs ?? []).map((/** @type {any} */ leg) => ({ name: leg.name, from: leg.from, target: leg.target, boost: leg.boost, borderToControlMs: leg.borderToControlMs, enteredAtMs: leg.enteredAtMs, controlAtMs: leg.controlAtMs,
36
+ worstStopMs: leg.worstStopMs, jumps: leg.jumps, over50: leg.over50, over100: leg.over100, worstFrameMs: leg.worstFrameMs, programLinks: leg.programLinks,
37
+ memory: leg.events?.find((/** @type {any} */ event) => event.control === true)?.memory ?? null })),
38
+ failed: (walk?.steps ?? []).filter((/** @type {any} */ step) => !step.ok).map((/** @type {any} */ step) => step.step) });
39
+ }
40
+ }
41
+ writeFileSync(join(out, 'rows.json'), `${JSON.stringify(rows, null, 2)}\n`);
42
+ for (const row of rows) console.log(`${row.pass === true ? 'PASS' : 'FAIL'} ${String(row.run)} ${JSON.stringify(row.failed)}`);
43
+ console.log(`grid-crossing qa: ${out}/rows.json`);
44
+ process.exit(rows.every(row => row.pass === true) ? 0 : 1);
@@ -0,0 +1,6 @@
1
+ export interface PairNumbers { ok: boolean; borderToControlMs?: number | null; freezeMs?: number | null; wallMs?: number | null; over50?: number | null }
2
+ export type Ratchet = Record<string, PairNumbers>;
3
+ export declare const MEASURES: { readonly borderToControlMs: { slack: number; factor: number }; readonly freezeMs: { slack: number; factor: number }; readonly wallMs: { slack: number; factor: number }; readonly over50: { slack: number; factor: number } };
4
+ export declare function pairKey(site: string, run: string, from: string, to: string): string;
5
+ export declare function worse(ratchet: Ratchet, now: Record<string, PairNumbers>): { key: string; measure: string; held: unknown; now: unknown }[];
6
+ export declare function tighten(ratchet: Ratchet, now: Record<string, PairNumbers>): Ratchet;
@@ -0,0 +1,52 @@
1
+ // GRID-CROSSING GC3: the per-pair ratchet (`test/grid-crossing-ratchet.json`). Each crossing run (site, browser and layout, from
2
+ // cell to cell) keeps its best-known numbers; a later run may only match or beat them, within a noise allowance. Tightening only
3
+ // ever lowers a number (or turns a failed pair into a passing one), so the ratchet moves toward the goal table and never back.
4
+
5
+ /** The measures a pair is held to, and the noise a run may add before it counts as worse. */
6
+ export const MEASURES = /** @type {const} */ ({ borderToControlMs: { slack: 1500, factor: 1.5 }, freezeMs: { slack: 500, factor: 1.5 }, wallMs: { slack: 500, factor: 1.5 }, over50: { slack: 3, factor: 1.5 } });
7
+
8
+ /** @typedef {{ ok: boolean, borderToControlMs?: number | null, freezeMs?: number | null, wallMs?: number | null, over50?: number | null }} PairNumbers */
9
+ /** @typedef {Record<string, PairNumbers>} Ratchet */
10
+
11
+ /** The ratchet key of one crossing. @param {string} site @param {string} run @param {string} from @param {string} to */
12
+ export const pairKey = (site, run, from, to) => `${site}/${run}/${from}:${to}`;
13
+
14
+ /**
15
+ * What got worse than the ratchet: a pair that passed now fails, or a measure past `max(held × factor, held + slack)`. A pair the
16
+ * ratchet doesn't hold, or a run that didn't try a held pair, is not worse (a partial run passes).
17
+ * @param {Ratchet} ratchet @param {Record<string, PairNumbers>} now @returns {{ key: string, measure: string, held: unknown, now: unknown }[]}
18
+ */
19
+ export function worse(ratchet, now) {
20
+ /** @type {{ key: string, measure: string, held: unknown, now: unknown }[]} */
21
+ const found = [];
22
+ for (const [key, run] of Object.entries(now)) {
23
+ const held = ratchet[key];
24
+ if (held === undefined) continue;
25
+ if (held.ok && !run.ok) { found.push({ key, measure: 'ok', held: true, now: false }); continue; }
26
+ if (!run.ok) continue;
27
+ for (const [measure, { slack, factor }] of Object.entries(MEASURES)) {
28
+ const was = held[/** @type {keyof PairNumbers} */ (measure)], is = run[/** @type {keyof PairNumbers} */ (measure)];
29
+ if (typeof was !== 'number' || typeof is !== 'number') continue;
30
+ if (is > Math.max(was * factor, was + slack)) found.push({ key, measure, held: was, now: is });
31
+ }
32
+ }
33
+ return found;
34
+ }
35
+
36
+ /** The ratchet after a run: new pairs join, a pair that now passes is held to passing, and each measure only goes down. @param {Ratchet} ratchet @param {Record<string, PairNumbers>} now @returns {Ratchet} */
37
+ export function tighten(ratchet, now) {
38
+ /** @type {Ratchet} */
39
+ const next = { ...ratchet };
40
+ for (const [key, run] of Object.entries(now)) {
41
+ const held = next[key];
42
+ if (held === undefined || (!held.ok && run.ok)) { next[key] = { ...run }; continue; }
43
+ if (!run.ok) continue;
44
+ /** @type {PairNumbers} */ const kept = { ...held };
45
+ for (const measure of Object.keys(MEASURES)) {
46
+ const name = /** @type {'borderToControlMs' | 'freezeMs' | 'wallMs' | 'over50'} */ (measure), was = held[name], is = run[name];
47
+ if (typeof is === 'number' && (typeof was !== 'number' || is < was)) kept[name] = is;
48
+ }
49
+ next[key] = kept;
50
+ }
51
+ return Object.fromEntries(Object.entries(next).sort(([a], [b]) => a.localeCompare(b)));
52
+ }
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env node
2
+ // GRID-CROSSING GC3: one report for every pair. Reads the in-page tours (`grid-crossing-tour.mjs`, `*-tour.json`, every pair both ways
3
+ // on preview or a loopback page) and the online walks (`grid-crossing-qa.mjs`'s `rows.json` on staging: the pairs a walker can reach by
4
+ // input), writes report.html (pairs × the goal's measures, worst first, and thumbnails of the failed or walled crossings in shots/) and checks every
5
+ // crossing against the ratchet `test/grid-crossing-ratchet.json`: a pair worse than its ratchet makes the run exit 1.
6
+ // node scripts/grid-crossing-report.mjs <out dir> --runs=<tour dir or rows.json>,… [--tighten]
7
+ // --tighten writes the ratchet after the run (new pairs join, numbers only go down); without it the ratchet is read only.
8
+ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
9
+ import { basename, dirname, join, resolve as absolute } from 'node:path';
10
+ import sharp from 'sharp';
11
+ import { pairKey, tighten, worse } from './grid-crossing-ratchet.mjs';
12
+
13
+ /** @param {string} name @param {string} fallback */
14
+ const flag = (name, fallback) => process.argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback;
15
+ const out = absolute(process.argv.slice(2).find(arg => !arg.startsWith('--')) ?? '');
16
+ const sources = flag('runs', '').split(',').filter(Boolean).map(path => absolute(path));
17
+ if (out === absolute('') || sources.length === 0) throw new Error('usage: grid-crossing-report.mjs <out dir> --runs=<tour dir or rows.json>,… [--tighten]');
18
+ const RATCHET = join(import.meta.dirname, '../test/grid-crossing-ratchet.json');
19
+
20
+ /** @typedef {{ site: string, run: string, from: string, to: string, boost: boolean, repeat: boolean, ok: boolean, why: string, borderToControlMs: number | null, freezeMs: number | null, wallMs: number | null, over50: number | null, over33: number | null, build: string, shot: string | null }} Row */
21
+ /** @type {Row[]} */
22
+ const rows = [];
23
+ const siteOf = (/** @type {string} */ base) => base.includes('staging') ? 'staging' : base.includes('preview') ? 'preview' : 'local';
24
+ for (const source of sources) {
25
+ const files = statSync(source).isDirectory() ? readdirSync(source).filter(name => name.endsWith('-tour.json')).map(name => join(source, name)) : [source];
26
+ for (const file of files) {
27
+ const data = JSON.parse(readFileSync(file, 'utf8'));
28
+ if (Array.isArray(data)) {
29
+ // grid-crossing-qa rows: the walk proof's legs online
30
+ for (const run of data) for (const leg of run.legs ?? []) {
31
+ if (typeof leg.from !== 'string' || typeof leg.target !== 'string') continue;
32
+ rows.push({ site: siteOf(run.base), run: run.run, from: leg.from, to: leg.target, boost: leg.boost === true, repeat: false, ok: typeof leg.controlAtMs === 'number' && leg.controlAtMs > 0,
33
+ why: '', borderToControlMs: leg.borderToControlMs ?? null, freezeMs: leg.worstStopMs ?? null, wallMs: null, over50: leg.over50 ?? null, over33: null, build: '', shot: null });
34
+ }
35
+ continue;
36
+ }
37
+ const run = `${String(data.engine)}-${String(data.layout).startsWith('phone') ? 'phone' : 'desktop'}`;
38
+ for (const c of data.crossings ?? []) {
39
+ const shot = join(dirname(file), `${String(data.engine)}-${String(c.from)}-${String(c.to)}.png`);
40
+ rows.push({ site: siteOf(data.base), run, from: c.from, to: c.to, boost: c.boost, repeat: c.repeat, ok: c.ok, why: c.why ?? '', borderToControlMs: c.borderToControlMs ?? null,
41
+ freezeMs: c.freezeMs ?? null, wallMs: c.wallMs ?? null, over50: c.over50 ?? null, over33: c.over33 ?? null, build: data.build ?? '', shot: existsSync(shot) ? shot : null });
42
+ }
43
+ }
44
+ }
45
+ // a pair's first crossing in a run is its score; a repeat stands in only for an arc the run never scored
46
+ /** @type {Map<string, Row>} */
47
+ const scored = new Map();
48
+ for (const row of rows) { const key = pairKey(row.site, row.run, row.from, row.to), had = scored.get(key); if (had === undefined || (had.repeat && !row.repeat)) scored.set(key, row); }
49
+ const now = Object.fromEntries([...scored].map(([key, row]) => [key, { ok: row.ok, borderToControlMs: row.borderToControlMs, freezeMs: row.freezeMs, wallMs: row.wallMs, over50: row.over50 }]));
50
+ const ratchet = existsSync(RATCHET) ? JSON.parse(readFileSync(RATCHET, 'utf8')) : {};
51
+ const worsened = worse(ratchet, now);
52
+ if (process.argv.includes('--tighten')) writeFileSync(RATCHET, `${JSON.stringify(tighten(ratchet, now), null, 2)}\n`);
53
+
54
+ // the goal table's bars (meta GRID-CROSSING-PLAN "The goal"): no stop, no wall, no frame over 50 ms on desktop (1 on the phone)
55
+ // a stop is read from samples 100 ms apart, so one sample (100 ms) is the floor of the reading, not a stop
56
+
57
+ const meets = (/** @type {Row} */ row) => row.ok && (row.freezeMs ?? 0) <= 100 && (row.wallMs ?? 0) === 0 && (row.over50 ?? 0) <= (row.run.endsWith('phone') ? 1 : 0);
58
+ const badness = (/** @type {Row} */ row) => (row.ok ? 0 : 1e9) + (row.wallMs ?? 0) * 10 + (row.freezeMs ?? 0) + (row.over50 ?? 0) * 50 + (row.borderToControlMs ?? 0) / 100;
59
+ const pairs = [...new Set([...scored.values()].map(row => `${row.from}:${row.to}`))];
60
+ const runs = [...new Set([...scored.values()].map(row => `${row.site}/${row.run}`))].sort();
61
+ const cellOf = (/** @type {string} */ pair, /** @type {string} */ run) => scored.get(`${run}/${pair}`);
62
+ pairs.sort((a, b) => Math.max(...runs.map(run => { const r = cellOf(b, run); return r === undefined ? -1 : badness(r); })) - Math.max(...runs.map(run => { const r = cellOf(a, run); return r === undefined ? -1 : badness(r); })));
63
+
64
+ const esc = (/** @type {unknown} */ text) => String(text).replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
65
+ const ms = (/** @type {number | null} */ value) => value === null ? '–' : value >= 1000 ? `${(value / 1000).toFixed(1)} s` : `${String(value)} ms`;
66
+ const short = (/** @type {string} */ instance) => instance.replace(/^open-plot-/u, 'plot ');
67
+ /** @type {Map<string, string>} */
68
+ const thumbs = new Map();
69
+ // thumbnails beside the report (`shots/`), published with it as the artifact's own files
70
+ mkdirSync(join(out, 'shots'), { recursive: true });
71
+ for (const row of scored.values()) if (row.shot !== null && thumbs.size < 60) {
72
+ const name = `shots/${row.run}-${basename(row.shot, '.png')}.jpg`;
73
+ await sharp(row.shot).resize({ width: 360 }).jpeg({ quality: 62 }).toFile(join(out, name));
74
+ thumbs.set(row.shot, name);
75
+ }
76
+ const cell = (/** @type {Row | undefined} */ row) => {
77
+ if (row === undefined) return '<td class="none">not run</td>';
78
+ const state = !row.ok ? 'fail' : meets(row) ? 'meets' : 'passes';
79
+ const bits = row.ok ? `<b>${ms(row.borderToControlMs)}</b><span>stop ${ms(row.freezeMs)} · wall ${ms(row.wallMs)} · &gt;50 ms ${row.over50 === null ? '–' : String(row.over50)}</span>` : `<b>no control</b><span>${esc(row.why)}</span>`;
80
+ return `<td class="${state}">${bits}${row.boost ? '<i>boost</i>' : '<i>walk</i>'}${row.repeat ? '<i>repeat</i>' : ''}</td>`;
81
+ };
82
+ const all = [...scored.values()], failed = all.filter(row => !row.ok), walled = all.filter(row => row.ok && (row.wallMs ?? 0) > 0), meeting = all.filter(meets);
83
+ const builds = [...new Set(all.map(row => row.build).filter(Boolean))].join(', ');
84
+ const html = `<title>Grid Crossing Pairs</title>
85
+ <meta name="claude:viewport-fit-sides" content="cover">
86
+ <style>
87
+ /* layout: one summary band, then a wide pair table that scrolls inside itself, then the shots of what failed */
88
+ :root { --bg: #f3f5f7; --panel: #ffffff; --fg: #18202a; --muted: #5b6876; --line: #d5dce3; --accent: #1f6fb2; --meets: #1d7a46; --meets-bg: #e3f3ea; --passes: #8a6100; --passes-bg: #fbf1d9; --fail: #b3261e; --fail-bg: #fbe4e2;
89
+ --head: 'Space Grotesk', system-ui, sans-serif; --body: 'Inter', system-ui, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace }
90
+ @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #10151b; --panel: #171e26; --fg: #e4e9ee; --muted: #93a1af; --line: #2a3541; --accent: #6cb2ec; --meets: #6fd39b; --meets-bg: #15301f; --passes: #e6bd5c; --passes-bg: #33290f; --fail: #f08a82; --fail-bg: #3a1714; color-scheme: dark } }
91
+ :root[data-theme="dark"] { --bg: #10151b; --panel: #171e26; --fg: #e4e9ee; --muted: #93a1af; --line: #2a3541; --accent: #6cb2ec; --meets: #6fd39b; --meets-bg: #15301f; --passes: #e6bd5c; --passes-bg: #33290f; --fail: #f08a82; --fail-bg: #3a1714; color-scheme: dark }
92
+ body { background: var(--bg); color: var(--fg); font-family: var(--body); padding-block: 24px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
93
+ main { display: grid; gap: 24px; max-width: 1400px; margin: 0 auto }
94
+ h1, h2 { font-family: var(--head); text-wrap: balance; margin: 0 } h1 { font-size: 1.9rem } h2 { font-size: 1.25rem }
95
+ p { max-width: 70ch; line-height: 1.5; margin: 0; color: var(--muted) } code { font-family: var(--mono); font-size: .85em }
96
+ .sum { display: flex; flex-wrap: wrap; gap: 12px } .sum div { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; min-width: 0 }
97
+ .sum b { display: block; font: 600 1.5rem var(--head); font-variant-numeric: tabular-nums } .sum span { color: var(--muted); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase }
98
+ .wide { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px }
99
+ table { border-collapse: collapse; font-size: .8rem; font-variant-numeric: tabular-nums } th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top }
100
+ th { font-family: var(--head); position: sticky; top: 0; background: var(--panel); white-space: nowrap } th.pair { white-space: nowrap }
101
+ td b { display: block; font-weight: 600 } td span { display: block; color: var(--muted); max-width: 26ch } td i { font-style: normal; font-size: .7rem; color: var(--muted); margin-right: 6px; text-transform: uppercase; letter-spacing: .05em }
102
+ td.meets { background: var(--meets-bg) } td.meets b { color: var(--meets) } td.passes { background: var(--passes-bg) } td.passes b { color: var(--passes) } td.fail { background: var(--fail-bg) } td.fail b { color: var(--fail) } td.none { color: var(--muted) }
103
+ .worse { border-left: 3px solid var(--fail); padding-left: 10px } .worse li { font-family: var(--mono); font-size: .8rem }
104
+ .shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px } figure { margin: 0; min-width: 0 } figure img { width: 100%; border-radius: 4px; border: 1px solid var(--line) } figcaption { font-size: .75rem; color: var(--muted); padding-top: 4px }
105
+ </style>
106
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=JetBrains+Mono&family=Space+Grotesk:wght@600&display=swap">
107
+ <main>
108
+ <header style="display:grid;gap:8px"><h1>Grid crossing, every pair</h1>
109
+ <p>Each cell is one crossing by real input from 12 m inside a cell's edge to control in its neighbour: <b>border to control</b>, the longest stop (under 0.1 m per 100 ms with the key held), the time held at an unready neighbour's wall, and frames over 50 ms within 3 s of the border. Green meets the plan's goal bars, amber reaches control but misses a bar, red never got control. Built ${esc(builds || 'unknown')}, ${esc(new Date().toISOString().slice(0, 16).replace('T', ' '))} UTC.</p></header>
110
+ <section class="sum"><div><b>${String(pairs.length)}</b><span>pairs (directed)</span></div><div><b>${String(all.length)}</b><span>crossings scored</span></div><div><b>${String(meeting.length)}</b><span>meet every bar</span></div><div><b>${String(walled.length)}</b><span>held at a wall</span></div><div><b>${String(failed.length)}</b><span>no control</span></div><div><b>${String(worsened.length)}</b><span>worse than ratchet</span></div></section>
111
+ ${worsened.length === 0 ? '' : `<section class="worse"><h2>Worse than the ratchet</h2><ul>${worsened.map(row => `<li>${esc(row.key)} ${esc(row.measure)}: ${esc(row.held)} → ${esc(row.now)}</li>`).join('')}</ul></section>`}
112
+ <section style="display:grid;gap:8px"><h2>Pairs, worst first</h2><div class="wide"><table><thead><tr><th class="pair">From → to</th>${runs.map(run => `<th>${esc(run)}</th>`).join('')}</tr></thead><tbody>
113
+ ${pairs.map(pair => { const [from = '', to = ''] = pair.split(':'); return `<tr><th class="pair">${esc(short(from))} → ${esc(short(to))}</th>${runs.map(run => cell(cellOf(pair, run))).join('')}</tr>`; }).join('\n')}
114
+ </tbody></table></div></section>
115
+ ${thumbs.size === 0 ? '' : `<section style="display:grid;gap:8px"><h2>Failed or walled crossings</h2><div class="shots">${[...scored.values()].filter(row => row.shot !== null && thumbs.has(row.shot)).map(row => `<figure><img alt="${esc(row.from)} to ${esc(row.to)}" src="${thumbs.get(/** @type {string} */ (row.shot)) ?? ''}"><figcaption>${esc(row.run)}: ${esc(short(row.from))} → ${esc(short(row.to))}, ${row.ok ? `wall ${ms(row.wallMs)}` : esc(row.why)}</figcaption></figure>`).join('')}</div></section>`}
116
+ <p>Not measured yet: grey stand-ins within 60 m of the player. Online pairs are only those a walker reaches by input (an online page can't place its seat); the in-page tour covers every pair. Sources: ${sources.map(source => `<code>${esc(basename(source))}</code>`).join(', ')}.</p>
117
+ </main>
118
+ `;
119
+ writeFileSync(join(out, 'report.html'), html);
120
+ for (const row of worsened) console.log(`WORSE ${row.key} ${row.measure}: ${String(row.held)} -> ${String(row.now)}`);
121
+ console.log(`grid-crossing report: ${String(all.length)} crossings, ${String(meeting.length)} meet the bars, ${String(failed.length)} without control, ${String(worsened.length)} worse than the ratchet; ${join(out, 'report.html')}`);
122
+ process.exit(worsened.length === 0 ? 0 : 1);
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ // GRID-CROSSING GC8: stage attribution from the crossing tour (`grid-crossing-tour.mjs`, its `prepare` per crossing). For each
3
+ // preparation span the page measured for the crossing's target (`wildshard.prepare:<slug>:<step>`, developer pages; the cell's
4
+ // instance in a step name reads `<cell>`), its wall time cold (the first crossing into that cell in a tour) and warm (a later
5
+ // one), and per crossing the main thread's long tasks and the bytes fetched under the target's shardfile folder (transfer
6
+ // size is 0 for a cache hit or a loopback page: decoded size beside it). Wall time,
7
+ // not CPU: spans overlap and include their awaits (preparationTiming.ts). Prints a markdown table.
8
+ // node scripts/grid-crossing-stages.mjs <tour json or dir>,…
9
+ import { readdirSync, readFileSync, statSync } from 'node:fs';
10
+ import { join } from 'node:path';
11
+
12
+ const files = process.argv.slice(2).flatMap(path => path.split(',')).filter(Boolean)
13
+ .flatMap(path => statSync(path).isDirectory() ? readdirSync(path).filter(name => name.endsWith('-tour.json')).map(name => join(path, name)) : [path]);
14
+ if (files.length === 0) throw new Error('usage: grid-crossing-stages.mjs <tour json or dir>,…');
15
+ /** @type {Map<string, { cold: number[], warm: number[] }>} */
16
+ const steps = new Map();
17
+ /** @type {{ run: string, from: string, to: string, boost: boolean, cold: boolean, wallMs: number, longTasks: number, longTaskMs: number, bytes: number, decoded: number, files: number, slowest: string }[]} */
18
+ const crossings = [];
19
+ for (const file of files) {
20
+ const tour = JSON.parse(readFileSync(file, 'utf8')), run = `${String(tour.engine)} ${String(tour.layout).split(' ')[0]}${tour.cold === true ? ' cold' : ''}`, seen = new Set(['driftwood-isle']);
21
+ for (const crossing of tour.crossings ?? []) {
22
+ const prepare = crossing.prepare; if (prepare === undefined) continue;
23
+ // a `--cold` tour (no HTTP cache, no service worker) fetches every crossing as a first visit
24
+ const cold = tour.cold === true || !seen.has(crossing.to); if (crossing.ok === true) seen.add(crossing.to);
25
+ let slowest = '', slowestMs = -1;
26
+ for (const [name, , ms] of prepare.spans ?? []) {
27
+ const step = String(name).replaceAll(crossing.to, '<cell>');
28
+ const row = steps.get(step) ?? { cold: [], warm: [] }; steps.set(step, row);
29
+ (cold ? row.cold : row.warm).push(ms);
30
+ if (ms > slowestMs) { slowestMs = ms; slowest = `${step} ${String(ms)} ms`; }
31
+ }
32
+ crossings.push({ run, from: crossing.from, to: crossing.to, boost: crossing.boost === true, cold, wallMs: crossing.wallMs ?? 0, longTasks: prepare.longTasks ?? 0,
33
+ longTaskMs: prepare.longTaskMs ?? 0, bytes: prepare.bytes ?? 0, decoded: prepare.decodedBytes ?? 0, files: prepare.files ?? 0, slowest });
34
+ }
35
+ }
36
+ const median = (/** @type {number[]} */ values) => { if (values.length === 0) return '-'; const sorted = [...values].sort((a, b) => a - b); return String(sorted[Math.floor(sorted.length / 2)]); };
37
+ const max = (/** @type {number[]} */ values) => values.length === 0 ? '-' : String(Math.max(...values));
38
+ console.log('| Step (span) | Cold n | Cold median ms | Cold max ms | Warm n | Warm median ms | Warm max ms |');
39
+ console.log('|---|---|---|---|---|---|---|');
40
+ for (const [step, row] of [...steps].sort((a, b) => Math.max(0, ...b[1].cold, ...b[1].warm) - Math.max(0, ...a[1].cold, ...a[1].warm))) {
41
+ console.log(`| \`${step}\` | ${String(row.cold.length)} | ${median(row.cold)} | ${max(row.cold)} | ${String(row.warm.length)} | ${median(row.warm)} | ${max(row.warm)} |`);
42
+ }
43
+ console.log('\n| Run | Crossing | Cold | Wall ms | Long tasks (ms) | Files (transfer KB / decoded MB) | Slowest span |');
44
+ console.log('|---|---|---|---|---|---|---|');
45
+ for (const c of crossings) {
46
+ console.log(`| ${c.run} | ${c.from} to ${c.to}${c.boost ? ' (boost)' : ''} | ${c.cold ? 'cold' : 'warm'} | ${String(c.wallMs)} | ${String(c.longTasks)} (${String(c.longTaskMs)}) | ${String(c.files)} (${String(Math.round(c.bytes / 1024))} / ${String(Math.round(c.decoded / 1048576))}) | ${c.slowest} |`);
47
+ }