@wildshard/engine 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/budgets/shard-size-baseline.json +10 -4
- package/index.html +6 -4
- package/lint/engine-sides.json +21 -0
- package/lint/host-callback-syntax.mjs +2 -1
- package/lint/host-callbacks.mjs +3 -3
- package/lint/host-files.mjs +5 -4
- package/lint/no-base64.mjs +3 -1
- package/lint/ratchet.json +0 -68
- package/lint/ratchet.mjs +1 -4
- package/lint/shard-imports.mjs +6 -7
- package/lint/shard-source.d.mts +9 -0
- package/lint/shard-source.mjs +91 -0
- package/lint/shardfile-boundaries.mjs +10 -8
- package/lint/sim-closure.mjs +6 -3
- package/lint/wildshard-plugin.d.ts +4 -0
- package/lint/wildshard-plugin.js +22 -23
- package/package.json +25 -16
- package/scripts/agent-sync.mjs +27 -8
- package/scripts/app-build/appCook.ts +8 -2
- package/scripts/app-build/catalogue.ts +10 -7
- package/scripts/app-build/gen.ts +22 -2
- package/scripts/app-build/isolation.d.mts +10 -0
- package/scripts/app-build/isolation.mjs +47 -0
- package/scripts/app-build/outputProducts.d.mts +3 -0
- package/scripts/app-build/outputProducts.mjs +35 -0
- package/scripts/app-build/previousDeploy.d.mts +2 -0
- package/scripts/app-build/previousDeploy.mjs +10 -1
- package/scripts/app-build/serviceWorker.ts +10 -3
- package/scripts/app-build/splitOutput.mjs +4 -2
- package/scripts/app-build/standaloneOutput.d.mts +1 -1
- package/scripts/app-build/standaloneOutput.mjs +5 -3
- package/scripts/app-build/titlePreloads.d.mts +8 -0
- package/scripts/app-build/titlePreloads.mjs +69 -0
- package/scripts/app-build/worldMapAtlas.ts +10 -6
- package/scripts/app-build-pipeline.mjs +34 -3
- package/scripts/built-product.mjs +1 -1
- package/scripts/cell-mem-bench.mjs +81 -23
- package/scripts/check-custom-sections-zero.mjs +1 -1
- package/scripts/check-devserver.mjs +3 -1
- package/scripts/check-models.mjs +2 -0
- package/scripts/check-paths.allow.json +0 -115
- package/scripts/check-paths.mjs +2 -2
- package/scripts/check-platform-ratchets.mjs +2 -3
- package/scripts/chromium-keychain-check.mjs +4 -2
- package/scripts/chromium-keychain.d.mts +1 -1
- package/scripts/chromium-keychain.mjs +3 -1
- package/scripts/ci-static.sh +1 -1
- package/scripts/committed-fast-checks.mjs +0 -2
- package/scripts/content-sw-proof.mjs +2 -1
- package/scripts/cook-worker.mjs +9 -3
- package/scripts/cook.mjs +20 -3
- package/scripts/devices.d.mts +4 -0
- package/scripts/devices.mjs +39 -0
- package/scripts/devserver-client.d.mts +4 -2
- package/scripts/devserver-client.mjs +25 -8
- package/scripts/docs-inputs-proof.mjs +6 -6
- package/scripts/doctor-proof.mjs +1 -1
- package/scripts/e2e-faults.mjs +159 -0
- package/scripts/e7-voice-staging-proof.mjs +1 -1
- package/scripts/gate-related-tests.mjs +1 -1
- package/scripts/git-source-view.mjs +1 -1
- package/scripts/goldens/capture.mjs +17 -5
- package/scripts/grid-crossing-nightly.mjs +59 -0
- package/scripts/grid-crossing-qa.mjs +44 -0
- package/scripts/grid-crossing-ratchet.d.mts +6 -0
- package/scripts/grid-crossing-ratchet.mjs +52 -0
- package/scripts/grid-crossing-report.mjs +122 -0
- package/scripts/grid-crossing-stages.mjs +47 -0
- package/scripts/grid-crossing-tour.mjs +277 -0
- package/scripts/grid-crossing-walk-proof.mjs +136 -18
- package/scripts/host-ruler/roots.mjs +2 -2
- package/scripts/host-ruler.d.mts +91 -0
- package/scripts/host-ruler.mjs +565 -0
- package/scripts/live-prepush.py +3 -5
- package/scripts/loading-flow/benchmax.mjs +3 -1
- package/scripts/look-loop/test_look_loop.py +1 -38
- package/scripts/memory-proof.mjs +213 -0
- package/scripts/mmo-bots.mjs +8 -2
- package/scripts/net-lag-proof.mjs +219 -0
- package/scripts/night-market-kit-budget.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +5 -3
- package/scripts/offline-proof-rules.mjs +34 -7
- package/scripts/offline-proof.mjs +88 -18
- package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
- package/scripts/page-release/content.d.mts +9 -1
- package/scripts/page-release/content.mjs +131 -17
- package/scripts/page-release/flow.mjs +36 -10
- package/scripts/page-release/stamp-content.mjs +24 -0
- package/scripts/page-release.mjs +28 -6
- package/scripts/page-size.mjs +2 -1
- package/scripts/pin-packs.ts +1 -1
- package/scripts/pins.ts +4 -4
- package/scripts/precommit-checks.mjs +1 -7
- package/scripts/precommit-jobs.mjs +0 -1
- package/scripts/precommit-source.py +1 -9
- package/scripts/program-discovery.mjs +1 -1
- package/scripts/ring-cook.mjs +2 -1
- package/scripts/ring-step.ts +1 -1
- package/scripts/script-scenario-metrics.mjs +1 -1
- package/scripts/shard-output-content.d.mts +1 -1
- package/scripts/shard-output-content.mjs +2 -2
- package/scripts/shard-outputs.mjs +1 -1
- package/scripts/shard-public.mjs +1 -1
- package/scripts/shard-wire-meter.mjs +24 -9
- package/scripts/side-parity.mjs +4 -2
- package/scripts/standalone-smoke.mjs +8 -3
- package/scripts/tier-textures-proof.mjs +101 -0
- package/scripts/tier-textures.mjs +78 -0
- package/scripts/tile-bake-report.mjs +1 -1
- package/scripts/tile-bakes.mjs +1 -1
- package/scripts/title-assets.generated.json +2 -0
- package/scripts/tsconfig.json +1 -2
- package/scripts/vendor/basisu/LICENSE +201 -0
- package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
- package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
- package/scripts/vitest-push-guards.config.ts +1 -1
- package/scripts/vps/harden-apply.sh +4 -1
- package/scripts/vps/harden-prometheus.sh +176 -0
- package/scripts/vps/harden.sh +16 -0
- package/scripts/vps/rebuild.sh +18 -0
- package/scripts/vps/wildshard-config +84 -24
- package/scripts/worker-client-play.mjs +7 -2
- package/scripts/worker-client-proof.mjs +1 -1
- package/scripts/worker-client-slug.mjs +44 -0
- package/scripts/worktree-reap.mjs +5 -5
- package/src/.oxlintrc.json +3 -182
- package/src/client/app/entry.ts +47 -12
- package/src/client/engine/boot/bootCache.ts +2 -2
- package/src/client/engine/boot/bootTrace.ts +12 -4
- package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
- package/src/client/engine/boot/clearDownloads.ts +5 -2
- package/src/client/engine/boot/contentRead.ts +11 -0
- package/src/client/engine/boot/gpuFiles.ts +4 -2
- package/src/client/engine/boot/lastEnd.ts +99 -12
- package/src/client/engine/boot/parsedPages.ts +127 -58
- package/src/client/engine/boot/texturePack.ts +2 -2
- package/src/client/engine/build.d.ts +2 -0
- package/src/client/engine/core/Game.ts +18 -0
- package/src/client/engine/core/bootstrap.ts +4 -1
- package/src/client/engine/debug/probe.ts +18 -1
- package/src/client/engine/fx/LightPool.ts +41 -1
- package/src/client/engine/net/netPlayer.ts +19 -2
- package/src/client/engine/net/otherPlayers.ts +55 -8
- package/src/client/engine/net/predictor.ts +33 -9
- package/src/client/engine/net/redial.ts +29 -6
- package/src/client/engine/pwa/cacheNames.ts +58 -1
- package/src/client/engine/pwa/sw.js +53 -14
- package/src/client/engine/render/dataLook.ts +152 -40
- package/src/client/engine/render/families/detail.ts +89 -0
- package/src/client/engine/render/families/pbr.ts +7 -1
- package/src/client/engine/render/look.ts +6 -0
- package/src/client/engine/render/lookLight.ts +103 -11
- package/src/client/engine/render/lookRender.ts +105 -0
- package/src/client/engine/render/precompile.ts +20 -14
- package/src/client/engine/saves/indexed.ts +2 -2
- package/src/client/engine/telemetry/browserErrors.ts +28 -4
- package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
- package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
- package/src/client/engine/ui/debugOptions.ts +1 -1
- package/src/client/engine/ui/lookLightOption.ts +10 -6
- package/src/client/engine/ui/namePrompt.ts +7 -0
- package/src/client/game/boot/audio.generated.ts +114 -216
- package/src/client/game/boot/bytes.generated.ts +118 -238
- package/src/client/game/boot/placedSpawn.ts +35 -0
- package/src/client/game/boot/spawnDownload.ts +25 -6
- package/src/client/game/boot/versions.generated.ts +7 -7
- package/src/client/game/devScene/hook.ts +291 -0
- package/src/client/game/grid/area.ts +38 -0
- package/src/client/game/grid/cellLoading.ts +12 -2
- package/src/client/game/grid/live.ts +134 -12
- package/src/client/game/grid/liveSession.ts +47 -5
- package/src/client/game/grid/mapAtlas.ts +18 -4
- package/src/client/game/grid/menu.ts +4 -0
- package/src/client/game/grid/minimapBlend.ts +15 -5
- package/src/client/game/grid/neighbourPanels.ts +10 -1
- package/src/client/game/grid/oneWayIn.ts +5 -1
- package/src/client/game/grid/placedCards.ts +55 -0
- package/src/client/game/grid/placedCells.ts +233 -0
- package/src/client/game/grid/placedContent.ts +85 -0
- package/src/client/game/grid/prefetch.ts +9 -1
- package/src/client/game/grid/productInputs.ts +3 -1
- package/src/client/game/grid/productLeases.ts +4 -1
- package/src/client/game/grid/products.ts +8 -4
- package/src/client/game/grid/regionalRuntime.ts +6 -0
- package/src/client/game/grid/regionalWorld.ts +15 -2
- package/src/client/game/grid/roadCull.ts +44 -14
- package/src/client/game/grid/roadLook.ts +24 -15
- package/src/client/game/grid/roadLookPlatform.ts +4 -2
- package/src/client/game/grid/roadResources.ts +24 -0
- package/src/client/game/grid/roadSign.worker.ts +4 -3
- package/src/client/game/grid/roadSignPaint.ts +16 -5
- package/src/client/game/grid/roadSignPreparation.ts +4 -3
- package/src/client/game/grid/roadSignScale.ts +8 -0
- package/src/client/game/grid/roadTileBacking.ts +13 -3
- package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
- package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
- package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
- package/src/client/game/grid/roadTileWriter.ts +2 -1
- package/src/client/game/grid/screenReports.ts +39 -0
- package/src/client/game/grid/session.ts +29 -4
- package/src/client/game/grid/shardfileFar.ts +9 -3
- package/src/client/game/grid/softWallLook.ts +25 -8
- package/src/client/game/mainMenu.ts +6 -2
- package/src/client/game/plugin/context.ts +2 -1
- package/src/client/game/plugin/followedMovers.ts +7 -1
- package/src/client/game/quest/figures.ts +2 -0
- package/src/client/game/session/finish.ts +11 -1
- package/src/client/game/shard/titleList.ts +6 -2
- package/src/client/game/shardfile/assetCache.ts +4 -4
- package/src/client/game/shardfile/client.ts +4 -1
- package/src/client/game/shardfile/clientAssets.ts +9 -5
- package/src/client/game/shardfile/clientLibrary.ts +1 -1
- package/src/client/game/shardfile/clientWater.ts +51 -9
- package/src/client/game/shardfile/clientWorker.ts +21 -8
- package/src/client/game/shardfile/look.ts +8 -3
- package/src/client/game/shardfile/product.ts +34 -7
- package/src/client/game/shardfile/productChecks.ts +2 -2
- package/src/client/game/shardfile/productCost.ts +2 -2
- package/src/client/game/shardfile/readAsset.ts +2 -2
- package/src/client/game/shardfile/reflectingWater.ts +73 -0
- package/src/client/game/shardfile/seatGrace.ts +9 -0
- package/src/client/game/shardfile/skinPlayback.ts +1 -1
- package/src/client/game/systems/npc/figureRows.ts +9 -0
- package/src/client/game/titleDeck.ts +4 -3
- package/src/client/host/online/doctor.ts +2 -0
- package/src/client/host/online/linkScreens.ts +30 -4
- package/src/client/host/online/shell.ts +14 -0
- package/src/client/host/standalone/shell.ts +4 -0
- package/src/cook/game/astc6Encode.ts +55 -0
- package/src/cook/game/astc6Wasm.ts +176 -0
- package/src/cook/game/cookJob.ts +30 -6
- package/src/cook/game/cookWorker.ts +38 -11
- package/src/cook/game/entryTotals.ts +51 -24
- package/src/cook/game/shardCook.ts +67 -9
- package/src/cook/game/spawnParts.ts +33 -8
- package/src/cook/game/tierTextures.ts +349 -0
- package/src/e2e/smoke/game.ts +19 -14
- package/src/e2e/smoke/page-globals.d.ts +9 -8
- package/src/e2e/smoke/template2.spec.ts +8 -7
- package/src/server/engine/ai/bossContenders.ts +27 -3
- package/src/server/engine/ai/phases.ts +1 -1
- package/src/server/engine/entities/creatureRefill.ts +9 -2
- package/src/server/engine/net/ledgerBook.ts +2 -0
- package/src/server/engine/net/room.ts +15 -0
- package/src/server/engine/sim/respawn.ts +8 -0
- package/src/server/game/boss/arenaRoomEntry.ts +5 -1
- package/src/server/game/boss/arenaRoomNative.ts +2 -0
- package/src/server/game/boss/native.ts +2 -1
- package/src/server/game/boss/nativeWake.ts +9 -5
- package/src/server/game/boss/openArenaNative.ts +2 -2
- package/src/server/game/boss/openArenaRoom.ts +3 -1
- package/src/server/game/grid/room.ts +44 -3
- package/src/server/game/grid/simulation.ts +23 -0
- package/src/server/game/population/mixedRoster.ts +11 -3
- package/src/server/game/population/nativeBake.ts +8 -3
- package/src/server/game/population/nativeReturns.ts +6 -3
- package/src/server/game/population/roster.ts +5 -3
- package/src/server/game/quest/eliteDrops.ts +15 -4
- package/src/server/game/quest/nativeChapter.ts +1 -1
- package/src/server/game/quest/nativeComposition.ts +5 -1
- package/src/server/game/riding/nativeTaming.ts +10 -6
- package/src/server/game/riding/wildRefill.ts +3 -2
- package/src/server/game/shardfile/bossRow.ts +4 -2
- package/src/server/game/shardfile/homeKeeper.ts +4 -2
- package/src/server/host/bake/headlessWorker.ts +1 -1
- package/src/server/host/dedicated/cellHost.ts +98 -16
- package/src/server/host/dedicated/cellProtocol.ts +16 -1
- package/src/server/host/dedicated/cellWorker.ts +8 -5
- package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
- package/src/server/host/dedicated/gridCells.ts +15 -6
- package/src/server/host/dedicated/loopLag.ts +21 -0
- package/src/server/host/dedicated/main.ts +13 -5
- package/src/server/host/dedicated/packReader.ts +3 -3
- package/src/server/host/dedicated/placementFile.ts +4 -19
- package/src/server/host/dedicated/roadRoom.ts +34 -4
- package/src/server/host/dedicated/serverMetrics.ts +126 -0
- package/src/server/host/dedicated/socketPump.ts +21 -4
- package/src/server/host/dedicated/socketTransport.ts +2 -1
- package/src/server/host/dedicated/workerTable.ts +15 -4
- package/src/server/host/dedicated/world.ts +95 -8
- package/src/server/host/headless.ts +1 -1
- package/src/server/host/headlessRuntime.ts +1 -1
- package/src/server/host/standalone/roadWorld.ts +15 -3
- package/src/server/host/standalone/serverHost.ts +4 -1
- package/src/server/host/standalone/serverProduct.ts +41 -11
- package/src/shared/engine/ai/BossBrain.ts +8 -0
- package/src/shared/engine/net/deviceWord.ts +138 -0
- package/src/shared/engine/net/socketFrames.ts +7 -4
- package/src/shared/game/boss/wake.ts +6 -0
- package/src/shared/game/devColliders.ts +47 -0
- package/src/shared/game/eliteSystem.ts +8 -0
- package/src/shared/game/grid/allocator.ts +3 -0
- package/src/shared/game/grid/catalogueSlot.ts +7 -0
- package/src/shared/game/grid/placementRows.ts +36 -0
- package/src/shared/game/plugin/bossRecord.ts +3 -2
- package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
- package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
- package/src/shared/game/shardfile/packReads.ts +28 -3
- package/src/shared/game/shardfile/serverPack.ts +9 -0
- package/src/shared/game/systems/looks/trampleField.ts +2 -0
- package/src/shared/host/formatJsonSchema.ts +2 -2
- package/src/tsconfig.json +1 -27
- package/lint/host-reviews.json +0 -14
- package/lint/listed-view-code.json +0 -13
- package/lint/platform-pending-users.json +0 -2520
- package/lint/platform-pending-users.md +0 -18
- package/scripts/cell-mem/metrics-preload.mjs +0 -65
- package/scripts/check-closed-components.d.mts +0 -7
- package/scripts/check-closed-components.mjs +0 -87
- package/scripts/g571-hosts.d.mts +0 -3
- package/scripts/g571-hosts.mjs +0 -54
- package/scripts/host-ruler/register-migrate.mjs +0 -242
- package/scripts/listed-view-code.d.mts +0 -7
- package/scripts/listed-view-code.mjs +0 -93
- package/scripts/look-loop/fit-lut.py +0 -142
- package/scripts/look-loop/palette-delta.py +0 -183
- package/scripts/look-loop/regions/driftwood-isle.json +0 -25
- package/scripts/look-loop/regions/far-reach.json +0 -225
- package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
- package/scripts/look-loop/regions/pine-hollow.json +0 -22
- package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
- package/scripts/platform-chargebacks.d.mts +0 -9
- package/scripts/platform-chargebacks.mjs +0 -135
- package/scripts/shard-component-spans.d.mts +0 -15
- package/scripts/shard-component-spans.mjs +0 -18
- package/scripts/shard-components.d.mts +0 -16
- package/scripts/shard-components.mjs +0 -363
- package/scripts/shard-platform-hosts.d.mts +0 -2
- package/scripts/shard-platform-hosts.mjs +0 -93
- package/scripts/shard-platform-sections.d.mts +0 -2
- package/scripts/shard-platform-sections.mjs +0 -9
- package/scripts/shard-platform.d.mts +0 -76
- package/scripts/shard-platform.mjs +0 -1072
- package/src/.oxfmtrc.json +0 -48
- package/src/scripts/ask-new.sh +0 -29
- package/src/scripts/asks.mjs +0 -142
- package/src/scripts/herdr-prompt.sh +0 -34
- package/src/scripts/herdr-question-open.sh +0 -67
- package/src/scripts/md-wrap.mjs +0 -229
- /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
- /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
- /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
|
@@ -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('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
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)} · >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
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
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
|
+
let currentLap = 1;
|
|
35
|
+
mkdirSync(out, { recursive: true });
|
|
36
|
+
const sleep = (/** @type {number} */ ms) => new Promise(resolve => { setTimeout(resolve, ms); });
|
|
37
|
+
|
|
38
|
+
// the grid at the build the base serves (its version.json), not this checkout's
|
|
39
|
+
const build = await fetch(`${base}/version.json`, { signal: AbortSignal.timeout(15_000) }).then(async found => String((await found.json()).build).split('-')[0] ?? '').catch(() => '');
|
|
40
|
+
const catalogueText = (() => {
|
|
41
|
+
try { return execFileSync('git', ['show', `${build}:src/shared/game/grid/singleplayer.json`], { cwd: join(import.meta.dirname, '..'), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }); }
|
|
42
|
+
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'); }
|
|
43
|
+
})();
|
|
44
|
+
/** @type {{ instance: string, slug: string, cell: [number, number] }[]} */
|
|
45
|
+
const cells = JSON.parse(catalogueText).grid.cells;
|
|
46
|
+
const at = new Map(cells.map(cell => [cell.cell.join(','), cell]));
|
|
47
|
+
/** @typedef {{ from: string, to: string, dx: number, dz: number, boost: boolean }} Arc */
|
|
48
|
+
/** @type {Arc[]} */
|
|
49
|
+
const arcs = [];
|
|
50
|
+
for (const cell of cells) for (const [dx, dz] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) {
|
|
51
|
+
const next = at.get(`${String(cell.cell[0] + dx)},${String(cell.cell[1] + dz)}`);
|
|
52
|
+
if (next !== undefined) arcs.push({ from: cell.instance, to: next.instance, dx, dz, boost: dx + dz < 0 });
|
|
53
|
+
}
|
|
54
|
+
const wanted = only.length === 0 ? arcs : arcs.filter(arc => only.includes(`${arc.from}:${arc.to}`));
|
|
55
|
+
const HOME = 'driftwood-isle', HOME_CARD = 'Driftwood Isle', EDGE_IN = 238, LEG_MS = 90_000, STUCK_MS = 1500;
|
|
56
|
+
|
|
57
|
+
/** @type {Record<string, unknown>[]} */
|
|
58
|
+
const crossings = [];
|
|
59
|
+
const result = { lane, base, build, cold, engine: engineName, layout: phone ? 'phone 402x874 touch' : 'desktop 1440x900', at: new Date().toISOString(), arcs: wanted.length, crossings, errors: /** @type {string[]} */ ([]), reloads: 0, reentries: 0, lostPage: /** @type {Record<string, unknown>[]} */ ([]), note: '', untried: /** @type {string[]} */ ([]) };
|
|
60
|
+
const save = () => writeFileSync(join(out, `${engineName}-${phone ? 'phone' : 'desktop'}-tour.json`), `${JSON.stringify(result, null, 2)}\n`);
|
|
61
|
+
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'] : [] });
|
|
62
|
+
let code = 1;
|
|
63
|
+
try {
|
|
64
|
+
// 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
|
|
65
|
+
// won't take a second Shard Select in the same profile)
|
|
66
|
+
/** @type {import('playwright').BrowserContext | null} */ let context = null;
|
|
67
|
+
/** @type {import('playwright').Page} */ let page = /** @type {any} */ (undefined);
|
|
68
|
+
let navigations = 0;
|
|
69
|
+
const profile = async () => {
|
|
70
|
+
await context?.close();
|
|
71
|
+
context = await browser.newContext(phone ? { viewport: { width: 402, height: 874 }, deviceScaleFactor: 3, isMobile: engineName === 'chromium', hasTouch: true,
|
|
72
|
+
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' } : {} }
|
|
73
|
+
: { viewport: { width: 1440, height: 900 }, ...cold ? { serviceWorkers: 'block' } : {} });
|
|
74
|
+
await saveFixture(context, { scope: 'device', key: 'firstPlayDone', data: true });
|
|
75
|
+
await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
|
|
76
|
+
await saveFixture(context, { scope: 'global', key: 'settings', merge: true, data: phone ? { tier: 'phone', volume: 0 } : { volume: 0 } });
|
|
77
|
+
page = await context.newPage();
|
|
78
|
+
if (cold && engineName === 'chromium') await (await context.newCDPSession(page)).send('Network.setCacheDisabled', { cacheDisabled: true });
|
|
79
|
+
const opened = page;
|
|
80
|
+
page.on('pageerror', error => { if (result.errors.length < 20) result.errors.push(error.message.slice(0, 240)); });
|
|
81
|
+
page.on('framenavigated', frame => { if (frame === opened.mainFrame()) navigations++; });
|
|
82
|
+
};
|
|
83
|
+
/** 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. */
|
|
84
|
+
const enter = async () => {
|
|
85
|
+
await profile();
|
|
86
|
+
await page.goto(`${base}/?mute=1&nolock=1`, { waitUntil: 'load' });
|
|
87
|
+
await page.locator('.ws-main-select').click({ timeout: 120_000 });
|
|
88
|
+
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(); }
|
|
89
|
+
await page.locator('.ws-menu-card').first().waitFor({ state: 'visible', timeout: 30_000 });
|
|
90
|
+
const index = await page.evaluate(card => [...document.querySelectorAll('.ws-menu-card')].findIndex(row => (row.textContent ?? '').includes(card)), HOME_CARD);
|
|
91
|
+
if (index < 0) throw new Error(`No ${HOME_CARD} card`);
|
|
92
|
+
await page.locator('.ws-menu-dots i').nth(index).click();
|
|
93
|
+
await page.locator('.ws-menu-play').click();
|
|
94
|
+
await page.waitForFunction(() => /** @type {any} */ (window).__wildshard?.shard?.grid?.state?.().live?.live?.gameplayReady === true, undefined, { timeout: 180_000, polling: 100 });
|
|
95
|
+
await sleep(2000);
|
|
96
|
+
await page.getByText('DONE', { exact: true }).click({ timeout: 2000 }).catch(() => undefined);
|
|
97
|
+
await page.evaluate(() => {
|
|
98
|
+
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();
|
|
99
|
+
try { performance.setResourceTimingBufferSize(100_000); } catch { /* the default 250 entries */ }
|
|
100
|
+
// GC8: main-thread long tasks (Chromium only; WebKit has no longtask entries), as [start, duration] on the page clock
|
|
101
|
+
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 */ }
|
|
102
|
+
let last = t0;
|
|
103
|
+
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); };
|
|
104
|
+
requestAnimationFrame(raf);
|
|
105
|
+
setInterval(() => { try {
|
|
106
|
+
const st = W.__wildshard.shard.grid.state(), p = W.__wildshard.world.player, lv = st.live;
|
|
107
|
+
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,
|
|
108
|
+
phase: lv?.crossing?.phase, ready: lv?.live?.gameplayReady, loading: st.cellLoading, step: st.cellStep?.step ?? null,
|
|
109
|
+
// GC6: whether the crossing's target world (colliders and sim) is resident yet, and the world built ahead (GC5)
|
|
110
|
+
built: q.target === undefined ? null : lv?.live?.residents?.includes(q.target) === true, ahead: lv?.live?.ahead?.instance ?? null,
|
|
111
|
+
// GC13: the cells whose worlds the page holds, and what playing costs
|
|
112
|
+
res: lv?.live?.residents ?? null, mb: st.playingMB ?? null,
|
|
113
|
+
// GC12: how many closed walls show (only the ones the walker stands at)
|
|
114
|
+
wall: st.softWalls?.shown ?? null });
|
|
115
|
+
if (q.samples.length > 20_000) q.samples.splice(0, 10_000);
|
|
116
|
+
} catch (error) { q.samples.push({ err: String(error).slice(0, 160) }); } }, 100);
|
|
117
|
+
});
|
|
118
|
+
await sleep(500);
|
|
119
|
+
};
|
|
120
|
+
await enter();
|
|
121
|
+
let navigationsBefore = navigations, lastWindowEnd = 0;
|
|
122
|
+
/** @returns {Promise<any>} */
|
|
123
|
+
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; });
|
|
124
|
+
const face = (/** @type {number} */ yaw) => page.evaluate(wanted_ => { /** @type {any} */ (window).__wildshard.world.player.yaw = wanted_; }, yaw);
|
|
125
|
+
|
|
126
|
+
/** One crossing over `arc` from where the walker stands (in `arc.from`). @param {Arc} arc @param {boolean} repeat */
|
|
127
|
+
const cross = async (arc, repeat) => {
|
|
128
|
+
const row = /** @type {Record<string, any>} */ ({ from: arc.from, to: arc.to, boost: arc.boost, repeat, lap: currentLap, ok: false, why: '' });
|
|
129
|
+
crossings.push(row);
|
|
130
|
+
// GC8: the target's preparation work since the last crossing ended (a pre-warm starts inside the source, GC5)
|
|
131
|
+
const windowStart = lastWindowEnd;
|
|
132
|
+
await page.evaluate(target => { /** @type {any} */ (window).__gc3.target = target; }, arc.to);
|
|
133
|
+
const yaw = Math.atan2(-arc.dx, -arc.dz);
|
|
134
|
+
// the harness pose: probe.ts `told`, so the in-page server hears where the walker stands
|
|
135
|
+
const place = async (/** @type {number} */ inset) => {
|
|
136
|
+
const px = arc.dx * inset, pz = arc.dz * inset;
|
|
137
|
+
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]);
|
|
138
|
+
await sleep(3000);
|
|
139
|
+
const at_ = await sample();
|
|
140
|
+
return { at_, ok: at_.inside === arc.from && Math.hypot(at_.x - px, at_.z - pz) <= 4 };
|
|
141
|
+
};
|
|
142
|
+
const { at_: placed, ok: placedOk } = await place(EDGE_IN);
|
|
143
|
+
row.placed = { x: placed.x, y: placed.y, z: placed.z, inside: placed.inside };
|
|
144
|
+
if (!placedOk) { row.why = `not placed on ${arc.from}'s entryway (inside ${String(placed.inside)})`; return row; }
|
|
145
|
+
await face(yaw);
|
|
146
|
+
const t1 = Date.now(), tFrom = (await sample()).t;
|
|
147
|
+
await page.keyboard.down('KeyW'); if (arc.boost) await page.keyboard.down('ShiftLeft');
|
|
148
|
+
let controlAt = 0, controlT = 0, jumps = 0, stuckSince = 0, last = placed, fell = false;
|
|
149
|
+
while (Date.now() - t1 < LEG_MS) {
|
|
150
|
+
await sleep(250);
|
|
151
|
+
const s = await sample();
|
|
152
|
+
if (s === undefined) continue;
|
|
153
|
+
const moved = Math.hypot(s.x - last.x, s.z - last.z), now = Date.now() - t1;
|
|
154
|
+
if (controlAt === 0) {
|
|
155
|
+
if (moved < 0.15) stuckSince ||= now; else stuckSince = 0;
|
|
156
|
+
if (stuckSince !== 0 && now - stuckSince > STUCK_MS && jumps < 4 && s.phase !== 'preparing') { await page.keyboard.press('Space'); jumps++; stuckSince = now; }
|
|
157
|
+
if (s.inside === arc.from && s.y < placed.y - 8) { fell = true; break; }
|
|
158
|
+
if (s.inside === arc.to && s.ready === true && (s.phase === undefined || s.phase === 'settled') && moved > 0.3) {
|
|
159
|
+
controlAt = now; controlT = s.t;
|
|
160
|
+
// GC14: the page's memory at each control, so the tour doubles as the long-walk soak
|
|
161
|
+
row.memory = await page.evaluate(() => { const W = /** @type {any} */ (window); let st = null; try { st = W.__wildshard.shard.grid.state(); } catch { /* no grid yet */ }
|
|
162
|
+
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);
|
|
163
|
+
}
|
|
164
|
+
} else if (now - controlAt > 2500) break;
|
|
165
|
+
last = s;
|
|
166
|
+
if (jumps >= 4 && stuckSince !== 0 && now - stuckSince > 10_000) break;
|
|
167
|
+
}
|
|
168
|
+
await page.keyboard.up('KeyW'); if (arc.boost) await page.keyboard.up('ShiftLeft');
|
|
169
|
+
// GC13 `--hold`: stand in the cell reached, so the page can let the cell behind go
|
|
170
|
+
await sleep(controlAt === 0 ? 400 : Math.max(400, hold));
|
|
171
|
+
const rows =/** @type {any[]} */ (await page.evaluate(t => /** @type {any} */ (window).__gc3.samples.filter((/** @type {any} */ r) => r.err === undefined && r.t >= t), tFrom));
|
|
172
|
+
const frames = /** @type {number[][]} */ (await page.evaluate(t => /** @type {any} */ (window).__gc3.frames.filter((/** @type {number[]} */ f) => (f[0] ?? 0) >= t), tFrom));
|
|
173
|
+
const entered = rows.find(r => r.inside === arc.to), roadAt = rows.find(r => r.inside === null);
|
|
174
|
+
/** longest run of consecutive samples (each ~100 ms) matching `test`, in ms, before control */
|
|
175
|
+
const untilT = controlAt === 0 ? Infinity : controlT;
|
|
176
|
+
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 }; });
|
|
177
|
+
const head = speeds.slice(2, 22).map(s => s.v).sort((a, b) => a - b), approach = head[Math.floor(head.length / 2)] ?? 0;
|
|
178
|
+
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; };
|
|
179
|
+
const sum = (/** @type {(s: { t: number, v: number, r: any }) => boolean} */ test) => speeds.filter(s => s.t <= untilT && test(s)).length * 100;
|
|
180
|
+
// GC6: how long before the border the target's world stood built (negative: built only after the feet crossed)
|
|
181
|
+
const builtAt = rows.find(r => r.built === true)?.t;
|
|
182
|
+
row.builtBeforeBorderMs = builtAt === undefined || entered === undefined ? null : entered.t - builtAt;
|
|
183
|
+
row.prewarmed = rows.some(r => r.ahead === arc.to && r.inside === arc.from);
|
|
184
|
+
// GC13: how long after control the cell left behind still held its world (null: still held when the window ended), and the most
|
|
185
|
+
// the page's playing cost reached in the window
|
|
186
|
+
const evicted = controlAt === 0 ? undefined : rows.find(r => r.t >= controlT && Array.isArray(r.res) && !r.res.includes(arc.from));
|
|
187
|
+
row.fromEvictedMs = evicted === undefined ? null : evicted.t - controlT;
|
|
188
|
+
row.peakPlayingMB = Math.max(0, ...rows.map(r => (typeof r.mb === 'number' ? r.mb : 0)));
|
|
189
|
+
// 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
|
|
190
|
+
row.wallShownMs = rows.filter(r => typeof r.wall === 'number' && r.wall > 0).length * 100;
|
|
191
|
+
const border = entered?.t ?? Infinity, near = frames.filter(f => Math.abs((f[0] ?? 0) - border) <= 3000).map(f => f[1] ?? 0);
|
|
192
|
+
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',
|
|
193
|
+
borderToControlMs: entered === undefined || controlAt === 0 ? null : controlT - entered.t, controlMs: controlAt === 0 ? null : controlAt, approachMps: Number(approach.toFixed(2)),
|
|
194
|
+
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),
|
|
195
|
+
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,
|
|
196
|
+
// GC8: how long each `cell` step stood on the loading screen in this crossing (samples every 100 ms; a build before GC8 reads none)
|
|
197
|
+
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; }, {}),
|
|
198
|
+
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 } });
|
|
199
|
+
// a failed crossing held on the road boosts back into the cell it left, so the tour goes on from there
|
|
200
|
+
if (!row.ok && last.inside !== arc.from && last.inside !== arc.to) {
|
|
201
|
+
await face(yaw + Math.PI); await page.keyboard.down('KeyW'); await page.keyboard.down('ShiftLeft');
|
|
202
|
+
for (const ends = Date.now() + 30_000; Date.now() < ends && (await sample())?.inside !== arc.from;) await sleep(250);
|
|
203
|
+
await page.keyboard.up('KeyW'); await page.keyboard.up('ShiftLeft'); await sleep(1500);
|
|
204
|
+
row.backIn = (await sample())?.inside === arc.from;
|
|
205
|
+
}
|
|
206
|
+
// GC8: what preparing the target cost in this window: its `wildshard.prepare:<slug>:<step>` spans (wall ms, developer pages
|
|
207
|
+
// only), the main thread's long tasks, and the bytes fetched under its shardfile folder (resource timing transfer sizes)
|
|
208
|
+
const slug = cells.find(cell => cell.instance === arc.to)?.slug ?? arc.to;
|
|
209
|
+
Object.assign(row, await page.evaluate(([from, name]) => {
|
|
210
|
+
const W = /** @type {any} */ (window), end = performance.now();
|
|
211
|
+
const spans = performance.getEntriesByType('measure').filter(entry => entry.name.startsWith(`wildshard.prepare:${name}:`) && entry.startTime >= from)
|
|
212
|
+
.map(entry => [entry.name.slice(`wildshard.prepare:${name}:`.length), Math.round(entry.startTime - from), Math.round(entry.duration)]);
|
|
213
|
+
const tasks = /** @type {number[][]} */ (W.__gc3.longTasks ?? []).filter(task => (task[0] ?? 0) >= from && (task[0] ?? 0) <= end);
|
|
214
|
+
const files = /** @type {PerformanceResourceTiming[]} */ (performance.getEntriesByType('resource')).filter(entry => entry.startTime >= from && entry.name.includes(`/${name}/`));
|
|
215
|
+
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),
|
|
216
|
+
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 };
|
|
217
|
+
}, /** @type {[number, string]} */ ([windowStart, slug])).then(({ prepare, windowEnd }) => { lastWindowEnd = windowEnd; return { prepare }; }).catch(() => ({})));
|
|
218
|
+
if (!row.ok || row.wallMs > 0) await page.screenshot({ path: join(out, `${engineName}-${arc.from}-${arc.to}.png`) }).catch(() => undefined);
|
|
219
|
+
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 })}`);
|
|
220
|
+
return row;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// 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
|
|
224
|
+
let here = (await sample()).inside ?? HOME;
|
|
225
|
+
const left = new Set(wanted), good = /** @type {Arc[]} */ ([]);
|
|
226
|
+
for (let lap = 1; ; ) {
|
|
227
|
+
// GC14 `--laps`: once every arc is crossed, go round them all again (the soak), each row naming its lap
|
|
228
|
+
if (left.size === 0 && lap < laps && good.length > 0) { lap++; currentLap = lap; for (const arc of wanted) left.add(arc); }
|
|
229
|
+
if (left.size === 0 || crossings.length >= limit) break;
|
|
230
|
+
if (navigations !== navigationsBefore) { result.note = 'the page reloaded: tour stopped'; break; }
|
|
231
|
+
if (result.lostPage.length > 4) { result.note = 'the page was lost a fifth time: tour stopped'; break; }
|
|
232
|
+
const outs = [...left].filter(arc => arc.from === here);
|
|
233
|
+
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;
|
|
234
|
+
if (arc === undefined) {
|
|
235
|
+
// the shortest way over crossed arcs to a cell with arcs left
|
|
236
|
+
/** @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 = '';
|
|
237
|
+
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; } } }
|
|
238
|
+
if (goal === '') {
|
|
239
|
+
// 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
|
|
240
|
+
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}` }); }
|
|
241
|
+
if (result.reentries >= 4) { result.note = `stranded in ${here} a fifth time: stopped`; break; }
|
|
242
|
+
// 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)
|
|
243
|
+
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; } }
|
|
244
|
+
if (![...left].some(o => reach.has(o.from))) { result.note = `stranded in ${here}, and no arc left is reachable from ${HOME}: stopped`; break; }
|
|
245
|
+
result.reentries++; await enter(); navigationsBefore = navigations; lastWindowEnd = 0; here = (await sample())?.inside ?? HOME; continue;
|
|
246
|
+
}
|
|
247
|
+
let step = goal; while (via.get(step)?.from !== here) step = /** @type {Arc} */ (via.get(step)).from;
|
|
248
|
+
arc = /** @type {Arc} */ (via.get(step)); repeat = true;
|
|
249
|
+
}
|
|
250
|
+
left.delete(arc);
|
|
251
|
+
/** @type {Record<string, any>} */ let row;
|
|
252
|
+
try { row = await cross(arc, repeat); }
|
|
253
|
+
catch (error) {
|
|
254
|
+
// the tour's probe (window.__gc3) went with the document: the page navigated or reloaded under the crossing. Record what the
|
|
255
|
+
// game says about it (its own navigations write a reason first: lastEnd.ts `markReload` / `markUnload`), then enter again.
|
|
256
|
+
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); }
|
|
257
|
+
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) }));
|
|
258
|
+
if (lost.probe) throw error;
|
|
259
|
+
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)'; }
|
|
260
|
+
result.lostPage.push({ arc: `${arc.from}:${arc.to}`, navigations: navigations - navigationsBefore, error: String(error).slice(0, 200), ...lost });
|
|
261
|
+
console.log(`LOST ${arc.from} -> ${arc.to}: ${JSON.stringify(lost).slice(0, 400)}`);
|
|
262
|
+
save(); result.reentries++; await enter(); navigationsBefore = navigations; lastWindowEnd = 0; here = (await sample())?.inside ?? HOME; continue;
|
|
263
|
+
}
|
|
264
|
+
save(); // after every crossing, so a run cut off by its timeout keeps what it measured
|
|
265
|
+
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); }
|
|
266
|
+
}
|
|
267
|
+
result.reloads = navigations - navigationsBefore;
|
|
268
|
+
if (left.size > 0) result.untried = [...left].map(arc => `${arc.from}:${arc.to}`);
|
|
269
|
+
code = crossings.length > 0 && crossings.every(row => row.ok) && result.reloads === 0 ? 0 : 1;
|
|
270
|
+
await /** @type {import('playwright').BrowserContext | null} */ (/** @type {unknown} */ (context))?.close();
|
|
271
|
+
} catch (error) { result.note = `the run: ${String(error).slice(0, 400)}`; }
|
|
272
|
+
finally {
|
|
273
|
+
save();
|
|
274
|
+
await browser.close();
|
|
275
|
+
}
|
|
276
|
+
console.log(`grid-crossing tour: ${String(crossings.filter(row => row.ok).length)} of ${String(crossings.length)} crossings reached control; ${out}`);
|
|
277
|
+
process.exit(code);
|