@wildshard/engine 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/budgets/shard-size-baseline.json +10 -4
- package/index.html +6 -4
- package/lint/engine-sides.json +18 -0
- package/lint/ratchet.json +0 -68
- package/lint/ratchet.mjs +1 -4
- package/package.json +19 -15
- 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 +33 -2
- package/scripts/app-build/isolation.d.mts +10 -0
- package/scripts/app-build/isolation.mjs +47 -0
- package/scripts/app-build/outputProducts.mjs +4 -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 +31 -3
- package/scripts/built-product.mjs +1 -1
- package/scripts/cell-mem-bench.mjs +83 -23
- package/scripts/check-custom-sections-zero.mjs +1 -1
- package/scripts/check-devserver.mjs +2 -0
- 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.d.mts +1 -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 +18 -5
- package/scripts/docs-inputs-proof.mjs +6 -6
- 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 +284 -0
- package/scripts/grid-crossing-walk-proof.mjs +126 -17
- 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/land.mjs +2 -1
- package/scripts/live-prepush.py +3 -5
- package/scripts/loading-flow/benchmax.mjs +37 -12
- package/scripts/loading-flow/deskbench.mjs +276 -0
- package/scripts/loading-flow/stalls.d.mts +17 -3
- package/scripts/loading-flow/stalls.mjs +82 -3
- package/scripts/look-loop/test_look_loop.py +1 -38
- package/scripts/memory-proof.mjs +61 -6
- 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/nightly-model.ts +9 -6
- package/scripts/offline-proof-rules.d.mts +2 -2
- package/scripts/offline-proof-rules.mjs +15 -4
- package/scripts/offline-proof.mjs +80 -13
- 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/parity/boot-smoke.mjs +13 -2
- package/scripts/pin-format.ts +5 -2
- package/scripts/pin-packs.ts +1 -1
- package/scripts/pins-reuse.d.mts +1 -0
- package/scripts/pins-reuse.mjs +22 -0
- 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/scratch-dir.mjs +95 -0
- package/scripts/scratch-sweep.mjs +182 -0
- 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.mjs +22 -4
- 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 +2 -14
- 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 +179 -0
- package/scripts/vps/harden.sh +16 -0
- package/scripts/vps/rebuild.sh +18 -0
- package/scripts/vps/wildshard-config +6 -2
- package/scripts/worker-client-play.mjs +6 -2
- package/scripts/worktree-reap.mjs +59 -13
- package/scripts/worktree.mjs +19 -5
- package/src/.oxlintrc.json +3 -182
- package/src/client/app/entry.ts +10 -2
- package/src/client/engine/anim/rigParser.ts +2 -2
- 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/texturePack.ts +2 -2
- package/src/client/engine/core/Game.ts +63 -19
- package/src/client/engine/core/gpuOnly.ts +10 -0
- package/src/client/engine/core/renderBudget.ts +134 -0
- 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 +68 -10
- package/src/client/engine/pwa/cacheNames.ts +58 -1
- package/src/client/engine/pwa/sw.js +41 -11
- package/src/client/engine/render/dataLook.ts +219 -44
- package/src/client/engine/render/families/detail.ts +89 -0
- package/src/client/engine/render/families/pbr.ts +9 -1
- package/src/client/engine/render/families/registry.ts +11 -2
- package/src/client/engine/render/families/sceneSurface.ts +116 -0
- package/src/client/engine/render/look.ts +12 -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 +4 -2
- package/src/client/engine/render/tiers.ts +4 -1
- package/src/client/engine/saves/indexed.ts +2 -2
- package/src/client/engine/telemetry/browserErrors.ts +24 -3
- 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/engine/world/declaredProps.ts +5 -1
- package/src/client/engine/world/skyRig.ts +4 -1
- package/src/client/engine/world/terrainTileView.ts +64 -23
- package/src/client/game/boot/audio.generated.ts +114 -114
- package/src/client/game/boot/bytes.generated.ts +118 -220
- 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 -5
- package/src/client/game/devScene/hook.ts +428 -0
- package/src/client/game/devScene/liveLook.ts +21 -0
- package/src/client/game/grid/cellLoading.ts +12 -2
- package/src/client/game/grid/live.ts +152 -19
- package/src/client/game/grid/liveSession.ts +53 -3
- package/src/client/game/grid/mapAtlas.ts +18 -4
- package/src/client/game/grid/minimapBlend.ts +15 -5
- package/src/client/game/grid/oneWayIn.ts +5 -1
- package/src/client/game/grid/pageEntry.ts +12 -1
- package/src/client/game/grid/placedCells.ts +114 -12
- 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 +23 -10
- package/src/client/game/grid/productLeases.ts +4 -1
- package/src/client/game/grid/products.ts +8 -4
- 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/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 +32 -7
- 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 +9 -0
- package/src/client/game/shardfile/assetCache.ts +4 -4
- package/src/client/game/shardfile/client.ts +28 -8
- package/src/client/game/shardfile/clientAssets.ts +9 -5
- package/src/client/game/shardfile/clientLibrary.ts +1 -1
- package/src/client/game/shardfile/clientPropMaterials.ts +4 -1
- package/src/client/game/shardfile/clientViews.ts +36 -8
- package/src/client/game/shardfile/clientWater.ts +51 -9
- package/src/client/game/shardfile/clientWorker.ts +19 -7
- package/src/client/game/shardfile/constructionCheckpoint.ts +2 -2
- package/src/client/game/shardfile/groundMerge.ts +57 -5
- package/src/client/game/shardfile/hybrid.ts +2 -0
- 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/shardfile/slabLibrary.ts +115 -49
- package/src/client/game/shardfile/tileContent.ts +1 -1
- package/src/client/game/shardfile/tileDriver.ts +38 -11
- package/src/client/game/shardfile/wirePage.ts +7 -3
- package/src/client/game/shardfile/worldScenes.ts +17 -10
- package/src/client/game/systems/npc/figureRows.ts +9 -0
- package/src/client/host/online/doctor.ts +22 -7
- package/src/client/host/online/doctorView.ts +2 -0
- package/src/client/host/online/linkScreens.ts +109 -5
- package/src/client/host/online/shell.ts +13 -4
- package/src/client/host/standalone/shell.ts +40 -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 +35 -7
- package/src/cook/game/spawnParts.ts +33 -8
- package/src/cook/game/tierTextures.ts +87 -14
- 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 +18 -3
- 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 +22 -7
- 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 +112 -18
- package/src/server/host/dedicated/cellProtocol.ts +18 -1
- package/src/server/host/dedicated/cellWorker.ts +8 -5
- package/src/server/host/dedicated/dedicatedRoom.ts +38 -11
- 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 +3 -2
- package/src/server/host/dedicated/roadRoom.ts +34 -4
- package/src/server/host/dedicated/serverMetrics.ts +135 -0
- package/src/server/host/dedicated/socketPump.ts +21 -4
- package/src/server/host/dedicated/workerTable.ts +32 -14
- package/src/server/host/dedicated/world.ts +65 -7
- 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 +57 -8
- package/src/server/host/standalone/serverProduct.ts +48 -16
- package/src/server/host/standalone/serverRuntime.ts +1 -1
- package/src/shared/engine/ai/BossBrain.ts +8 -0
- package/src/shared/engine/core/framePacing.ts +12 -1
- package/src/shared/engine/physics/terrainTiles.ts +20 -4
- package/src/shared/game/boss/wake.ts +6 -0
- package/src/shared/game/devColliders.ts +107 -0
- package/src/shared/game/devGameplay.ts +41 -0
- package/src/shared/game/eliteSystem.ts +8 -0
- package/src/shared/game/grid/allocator.ts +3 -0
- package/src/shared/game/grid/placementRows.ts +5 -2
- 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,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// PAGE-SIZE PZ6 (meta docs/plans/PAGE-SIZE-PLAN.md, J276): a split page (`dist/`, its content in `dist-content/`) reads its
|
|
3
|
+
// content from the CDN. The content set is named by the files content.mjs publishes from `dist-content/`, so the base is
|
|
4
|
+
// known before the upload: stamp it into `dist/index.html`, then bake the service worker again from the stamped document
|
|
5
|
+
// (content-sw-proof's order; the worker's precache lists move to CDN URLs). page-release.mjs runs this in the build phase
|
|
6
|
+
// when it publishes content, and its upload phase refuses a published set whose base differs from the stamped one.
|
|
7
|
+
//
|
|
8
|
+
// node --import ./scripts/bake-loader.mjs scripts/page-release/stamp-content.mjs <dist>
|
|
9
|
+
import {existsSync, readFileSync, writeFileSync} from 'node:fs';
|
|
10
|
+
import {join, resolve} from 'node:path';
|
|
11
|
+
import {stampContentBase} from '../app-build/contentBase.mjs';
|
|
12
|
+
import {contentBaseOf, contentSet, scanContent} from './content.mjs';
|
|
13
|
+
|
|
14
|
+
const dist = process.argv[2];
|
|
15
|
+
if (dist === undefined) throw new Error('usage: node --import ./scripts/bake-loader.mjs scripts/page-release/stamp-content.mjs <dist>');
|
|
16
|
+
const page = resolve(dist), content = `${page}-content`, root = resolve(import.meta.dirname, '../..');
|
|
17
|
+
if (!existsSync(content)) throw new Error(`${content} is missing: stamp a split page (pnpm build:game splits it)`);
|
|
18
|
+
const files = scanContent(content);
|
|
19
|
+
if (files.length === 0) throw new Error(`${content} holds no content`);
|
|
20
|
+
const base = contentBaseOf(contentSet(files));
|
|
21
|
+
writeFileSync(join(page, 'index.html'), stampContentBase(readFileSync(join(page, 'index.html'), 'utf8'), base));
|
|
22
|
+
const {writeServiceWorker} = await import('../app-build/serviceWorker.ts');
|
|
23
|
+
await writeServiceWorker(page, root);
|
|
24
|
+
console.log(`stamped ${dist}/index.html with ${base} (${files.length} content files) and baked its service worker again`);
|
package/scripts/page-release.mjs
CHANGED
|
@@ -10,21 +10,27 @@
|
|
|
10
10
|
// --dry-run print every step and read the live gate; build, upload and alias nothing
|
|
11
11
|
// --wait=<minutes> check: how long to wait for the signed serial and /health (default 45)
|
|
12
12
|
// --after-staging-proofs production go-live: the strict staging proofs passed on this exact build
|
|
13
|
-
// --content
|
|
14
|
-
//
|
|
13
|
+
// --content build: stamp the content set's base into dist/ and keep the split (PZ6); upload: publish
|
|
14
|
+
// dist-content/ to packs.wildshard.io first (PAGE-SIZE PZ2,
|
|
15
|
+
// page-release/content.mjs); preview.yml passes it (PZ6), staging and production with PZ8
|
|
15
16
|
// --catalogue=<file> preview build: bake this catalogue, the grid borrowed from staging (SHARD-AUTHORING SA35,
|
|
16
17
|
// scripts/preview-grid.ts); default test/pins/catalogue.json. Refused on staging and production
|
|
17
18
|
//
|
|
19
|
+
// node scripts/page-release.mjs --print-env <preview|staging|production> [--root=<dir>] [--catalogue=<file>]
|
|
20
|
+
// print the channel's build environment for the root's HEAD (--catalogue on preview only),
|
|
21
|
+
// one sorted KEY=value a line, and run nothing (PAGE-SIZE PZ6: the three channels' builds
|
|
22
|
+
// differ only in named keys)
|
|
23
|
+
//
|
|
18
24
|
// The flow and its gates are scripts/page-release/flow.mjs; the page hosts are scripts/page-release/hosts/*.mjs.
|
|
19
25
|
// Phase results go to <root>/tmp/page-release/<channel>-<sha>.json, which the next phase reads.
|
|
20
26
|
import {execFileSync} from 'node:child_process';
|
|
21
27
|
import {setTimeout as delay} from 'node:timers/promises';
|
|
22
28
|
import {existsSync, mkdirSync, readFileSync, writeFileSync} from 'node:fs';
|
|
23
29
|
import {join, resolve} from 'node:path';
|
|
24
|
-
import {RefusedError, runPhase} from './page-release/flow.mjs';
|
|
30
|
+
import {CHANNELS, RefusedError, buildEnv, runPhase} from './page-release/flow.mjs';
|
|
25
31
|
import {workersHost} from './page-release/hosts/workers.mjs';
|
|
26
32
|
import {r2Packs} from './page-release/packs.mjs';
|
|
27
|
-
import {publishContent, r2Content} from './page-release/content.mjs';
|
|
33
|
+
import {publishContent, r2Content, r2Copies} from './page-release/content.mjs';
|
|
28
34
|
|
|
29
35
|
const args = process.argv.slice(2);
|
|
30
36
|
const flag = (/** @type {string} */ name) => args.find(arg => arg === `--${name}` || arg.startsWith(`--${name}=`));
|
|
@@ -32,6 +38,19 @@ const value = (/** @type {string} */ name) => flag(name)?.split('=').slice(1).jo
|
|
|
32
38
|
/** Every channel is on Cloudflare Workers (OFF-VERCEL OV6 preview, OV7 staging, OV8 production), so `--host` has one value. */
|
|
33
39
|
const [channel, phaseList] = args.filter(arg => !arg.startsWith('--'));
|
|
34
40
|
const hostName = value('host') ?? 'workers';
|
|
41
|
+
if (flag('print-env') !== undefined) {
|
|
42
|
+
const config = channel !== undefined && Object.hasOwn(CHANNELS, channel) ? Reflect.get(CHANNELS, channel) : undefined;
|
|
43
|
+
const catalogue = value('catalogue');
|
|
44
|
+
if (config === undefined || phaseList !== undefined || (catalogue !== undefined && !config.solo)) {
|
|
45
|
+
console.error('usage: node scripts/page-release.mjs --print-env <preview|staging|production> [--root=<dir>] [--catalogue=<file>, preview only]');
|
|
46
|
+
process.exit(2);
|
|
47
|
+
}
|
|
48
|
+
const cwd = resolve(value('root') ?? '.');
|
|
49
|
+
const head = execFileSync('git', ['rev-parse', 'HEAD'], {cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe']}).trim();
|
|
50
|
+
const env = buildEnv(config, /** @type {any} */ ({build: head, ...(catalogue === undefined ? {} : {catalogue: resolve(catalogue)})}));
|
|
51
|
+
for (const name of Object.keys(env).sort()) console.log(`${name}=${env[name]}`);
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
35
54
|
if (channel === undefined || phaseList === undefined || hostName !== 'workers') {
|
|
36
55
|
console.error('usage: node scripts/page-release.mjs <preview|staging|production> <build|upload|check|go-live>[,...] [--host=workers] [--root=<dir>] [--dry-run] [--wait=<minutes>] [--after-staging-proofs] [--content] [--catalogue=<file>]');
|
|
37
56
|
process.exit(2);
|
|
@@ -56,6 +75,9 @@ async function fetch200(url) {
|
|
|
56
75
|
}
|
|
57
76
|
|
|
58
77
|
const host = workersHost({token: () => cloudflareToken, log});
|
|
78
|
+
// PZ6: a content publish copies unchanged files from an older set on R2 when the bucket's S3 keys are in the environment
|
|
79
|
+
const contentCopies = flag('content') === undefined ? undefined : r2Copies(process.env);
|
|
80
|
+
if (contentCopies !== undefined) secrets.push(...contentCopies.secrets);
|
|
59
81
|
|
|
60
82
|
let phase = '';
|
|
61
83
|
try {
|
|
@@ -65,7 +87,7 @@ try {
|
|
|
65
87
|
packs: r2Packs({log}),
|
|
66
88
|
...(flag('content') === undefined ? {} : {content: {
|
|
67
89
|
publish: ({dir, cors, dryRun}) => publishContent({dir, origin: cors, dryRun, log,
|
|
68
|
-
scratch: join(root, 'tmp/page-release/content'), store: r2Content({root, scratch: join(root, 'tmp/page-release/content'), token: cloudflareToken})}),
|
|
90
|
+
scratch: join(root, 'tmp/page-release/content'), store: r2Content({root, scratch: join(root, 'tmp/page-release/content'), token: cloudflareToken, copies: contentCopies})}),
|
|
69
91
|
}}),
|
|
70
92
|
run: (file, argv, env) => { execFileSync(file, argv, {cwd: root, env: {...process.env, ...env}, stdio: 'inherit'}); },
|
|
71
93
|
fetchJSON: async url => (await fetch200(url)).json(),
|
|
@@ -102,4 +124,4 @@ try {
|
|
|
102
124
|
console.error(redact(error instanceof RefusedError ? error.message : `${channel} ${phase} failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
103
125
|
console.error('the alias did not move unless an ALIAS MOVED line is above');
|
|
104
126
|
process.exitCode = 1;
|
|
105
|
-
}
|
|
127
|
+
} finally { contentCopies?.close(); }
|
package/scripts/page-size.mjs
CHANGED
|
@@ -152,7 +152,8 @@ export const PAGE_LIMITS = Object.freeze({files: 1000, bytes: 100e6});
|
|
|
152
152
|
export function gatePage(report, limits = PAGE_LIMITS) {
|
|
153
153
|
const errors = [], zero = tally(), maps = report.kinds.maps ?? zero;
|
|
154
154
|
const content = [report.kinds['shard content'] ?? zero, report.kinds['engine art'] ?? zero];
|
|
155
|
-
|
|
155
|
+
// a kept build's content stays on the page until it ages out (splitOutput): only this build's content is refused
|
|
156
|
+
const contentFiles = content.reduce((sum, row) => sum + row.files - row.carriedFiles, 0), contentBytes = content.reduce((sum, row) => sum + row.bytes - row.carriedBytes, 0);
|
|
156
157
|
if (contentFiles > 0) errors.push(`page-size gate: dist/ holds ${n(contentFiles)} content files (${mb(contentBytes)} MB); shard content and engine art go to dist-content/ (node scripts/app-build/splitOutput.mjs)`);
|
|
157
158
|
const pageFiles = report.total.files - maps.files, bytes = report.total.bytes - maps.bytes;
|
|
158
159
|
if (pageFiles > limits.files) errors.push(`page-size gate: the page holds ${n(pageFiles)} files, past the ${n(limits.files)} a page may hold (PAGE-SIZE D1)`);
|
|
@@ -12,7 +12,7 @@ import { captureBootFrame } from './black-frame.mjs';
|
|
|
12
12
|
import { observeTitleCapture } from './title-trace.mjs';
|
|
13
13
|
import { gridBootWaitHistory } from './grid-boot-waits.mjs';
|
|
14
14
|
import { gridFloorDocumentIdentity, runFloorGridRoute, gridFloorWitnessFailures } from '../frame-floor-grid.mjs';
|
|
15
|
-
import { finishStallProfile, startStallProfile } from '../loading-flow/stalls.mjs';
|
|
15
|
+
import { finishPlayProfile, finishStallProfile, startStallProfile } from '../loading-flow/stalls.mjs';
|
|
16
16
|
|
|
17
17
|
/** A locked experimental card is not a public gameplay entry. Its direct chunk
|
|
18
18
|
* page must still hydrate under the unwaived public playing envelope (call44).
|
|
@@ -530,14 +530,25 @@ export async function bootCase(browser, base, mode, out, shard = 'driftwood-isle
|
|
|
530
530
|
const overhead = await page.evaluate(spawnOverhead);
|
|
531
531
|
if (overhead !== null) throw new Error(`grid spawn is under a collider: ${JSON.stringify(overhead)}`);
|
|
532
532
|
}
|
|
533
|
+
// NINE-DRAGON-BENCHMAX NB6 (play): the ten gameplay frames are profiled too, and a stretch in which the main thread
|
|
534
|
+
// worked without a break (a 2 s busy sleep in a frame) is refused, whatever the GPU (scripts/loading-flow/stalls.mjs)
|
|
535
|
+
const playProfile = await startStallProfile(page), playFrom = Number(await page.evaluate('performance.now()'));
|
|
533
536
|
await until(page, faults, async () => (await page.evaluate(bootObservation)).frame >= initial.frame + 10, 'ten live gameplay frames', deadline);
|
|
534
537
|
gameplayFrames.final = (await page.evaluate(bootObservation)).frame;
|
|
538
|
+
/** @type {{ from: number, busyMs: number, playMs: number, leaves: string[] } | null} */ let playStall = null;
|
|
539
|
+
// report only in Ring 1 (2026-11-14): on CI's SwiftShader (frames 1-2.4 s apart) two lands' play windows read 1.5 s busy
|
|
540
|
+
// in script with no sleep (sunscar-dunes, blender-template), so the line names the window's leaves and Ring 1 stays
|
|
541
|
+
// green; desktop enforces it through `deskbench --capped --stalls`, and the props stall above still fails Ring 1
|
|
542
|
+
if (playProfile !== null) {
|
|
543
|
+
const read = await finishPlayProfile(page, playProfile, playFrom); playStall = { ...read.stall, leaves: read.leaves };
|
|
544
|
+
if (read.faults.length > 0) console.log(`${shard}: play stall (report only): ${read.faults.join('; ')} · ${read.leaves.join(', ')}`);
|
|
545
|
+
}
|
|
535
546
|
phases.framesCompleteMs = Date.now() - started;
|
|
536
547
|
await captureBootFrame(page, mode === 'grid' ? 'grid HOME' : `${shard} gameplay`, deadline, frames);
|
|
537
548
|
const roadDeadline = Date.now() + 90000;
|
|
538
549
|
const templateRoad = mode === 'grid' ? await bootTemplateRoad(page, faults, frames, roadDeadline) : null;
|
|
539
550
|
const road = mode === 'grid' ? await bootSignalRoad(page, faults, frames, roadDeadline) : null;
|
|
540
|
-
const result = { mode, phases, frames, gameplayFrames, stalls, gridWaits: gridWaits.samples, templateRoad, road, telemetryPosts, lifecycleReports, gridNavigationObserved, elapsedMs: Date.now() - started, ...await page.evaluate(bootObservation), faults, reports };
|
|
551
|
+
const result = { mode, phases, frames, gameplayFrames, stalls, playStall, gridWaits: gridWaits.samples, templateRoad, road, telemetryPosts, lifecycleReports, gridNavigationObserved, elapsedMs: Date.now() - started, ...await page.evaluate(bootObservation), faults, reports };
|
|
541
552
|
if (faults.length > 0 || result.fatal.length > 0) throw new Error(JSON.stringify(result));
|
|
542
553
|
if (afterGameplay !== null) await afterGameplay(page);
|
|
543
554
|
if (faults.length > 0) throw new Error(JSON.stringify(faults));
|
package/scripts/pin-format.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** J233: Template 2 is published in the frozen format dependency. This reads
|
|
2
2
|
* that installed product without a producer checkout, cook or network.
|
|
3
3
|
* BM-2: Brasscap Mesa, Template 2's own product, sits beside Template 1's
|
|
4
|
-
* `blender-template` in shardfile's corpus and is admitted the same way.
|
|
4
|
+
* `blender-template` in shardfile's corpus and is admitted the same way.
|
|
5
|
+
* SHARD-SOURCE SS4: its folder is `corpus/exports/brasscap-mesa`, shard-format's
|
|
6
|
+
* export of a pinned shard-brasscap commit (built by `wildshard build`, pinned
|
|
7
|
+
* by `corpus/exports/brasscap-mesa.pin.json`), not a hand-written source. */
|
|
5
8
|
import {createHash} from 'node:crypto';
|
|
6
9
|
import {readFileSync, readdirSync} from 'node:fs';
|
|
7
10
|
import {dirname, join, resolve} from 'node:path';
|
|
@@ -17,7 +20,7 @@ interface FormatTemplate {
|
|
|
17
20
|
/** Each product the format dependency ships, by slug: its folder under the package root. */
|
|
18
21
|
export const FORMAT_PRODUCTS: Readonly<Record<string, string>> = Object.freeze({
|
|
19
22
|
'blender-template': 'corpus/handwritten',
|
|
20
|
-
'brasscap-mesa': 'corpus/brasscap-mesa',
|
|
23
|
+
'brasscap-mesa': 'corpus/exports/brasscap-mesa',
|
|
21
24
|
});
|
|
22
25
|
export function formatTemplate(slug: string): FormatTemplate {
|
|
23
26
|
const folder = Object.hasOwn(FORMAT_PRODUCTS, slug) ? FORMAT_PRODUCTS[slug] : undefined;
|
package/scripts/pin-packs.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// C0: a tarball leaves its packs out, because every member keeps its own path. Whoever serves a product rebuilds them, and a
|
|
2
2
|
// pinned tree serves its products to the page and to the grid bake.
|
|
3
|
-
import { packFromMembers } from '@wildshard/format/
|
|
3
|
+
import { packFromMembers } from '@wildshard/format/shardfile-reads';
|
|
4
4
|
|
|
5
5
|
type Members = Parameters<typeof packFromMembers>[1];
|
|
6
6
|
type Pack = Parameters<typeof packFromMembers>[0];
|
package/scripts/pins-reuse.d.mts
CHANGED
|
@@ -17,6 +17,7 @@ export interface Reused {
|
|
|
17
17
|
}
|
|
18
18
|
export function pinsKey(root: string, revision: string): string;
|
|
19
19
|
export function dropManifest(root: string): void;
|
|
20
|
+
export function stalePinProducts(root: string): { folder: string; revision: unknown }[];
|
|
20
21
|
export function verifiedPinsOutputs(root: string): { paths: Set<string>; key: string };
|
|
21
22
|
export function writeManifest(root: string, key: string, products: Manifest['products'], mounts: Manifest['mounts']): void;
|
|
22
23
|
export function lockPins(root: string, options?: { wait?: boolean }): (() => void) | undefined;
|
package/scripts/pins-reuse.mjs
CHANGED
|
@@ -198,6 +198,28 @@ function pinHashes(root){
|
|
|
198
198
|
return (shards??[]).map(row=>String(row.hash));
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* The products under `out/` whose receipt names a pin `root`'s pins no longer name (`out/<folder>`, with the revision its
|
|
203
|
+
* receipt says), e.g. a worktree installed before a pin bump and rebased past it. Their mounts under public/ are that old
|
|
204
|
+
* revision's, so the boot stamps gen:inputs writes from public/ would carry the old files (Far Reach rev 1's 21 rows,
|
|
205
|
+
* re-added by lands from such worktrees, 2026-11-14). A tree with no `out/` or no pins file has none.
|
|
206
|
+
* @param {string} root @returns {{folder:string,revision:unknown}[]}
|
|
207
|
+
*/
|
|
208
|
+
export function stalePinProducts(root){
|
|
209
|
+
let want;
|
|
210
|
+
try{want=new Set(pinHashes(root));}catch{return [];}
|
|
211
|
+
let folders;
|
|
212
|
+
try{folders=readdirSync(join(root,'out'),{withFileTypes:true}).filter(entry=>entry.isDirectory()).map(entry=>entry.name);}catch{return [];}
|
|
213
|
+
/** @type {{folder:string,revision:unknown}[]} */const stale=[];
|
|
214
|
+
for(const folder of folders.sort()){
|
|
215
|
+
/** @type {unknown} */let pin;
|
|
216
|
+
try{pin=JSON.parse(readFileSync(join(root,'out',folder,'validation.json'),'utf8')).pin;}catch{continue;}
|
|
217
|
+
if(typeof pin!=='object'||pin===null||!('hash'in pin)||typeof pin.hash!=='string')continue;
|
|
218
|
+
if(!want.has(pin.hash))stale.push({folder,revision:'revision'in pin?pin.revision:undefined});
|
|
219
|
+
}
|
|
220
|
+
return stale;
|
|
221
|
+
}
|
|
222
|
+
|
|
201
223
|
/** Every file under `directory` as a path relative to it with its size, or a refusal: an entry that is neither a
|
|
202
224
|
* directory nor a regular file, an executable file, or a directory the owner can't write and enter.
|
|
203
225
|
* @param {string} directory @returns {Map<string,number>|string} */
|
package/scripts/pins.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
//
|
|
16
16
|
// `install` is what a build runs first. For each pin, in order:
|
|
17
17
|
// 1. The tarball comes from the cache, the mirror or the API, and its sha256 has to be the pin.
|
|
18
|
-
// 2. This tree's format validator admits it: files, hashes, schemas, budgets (`
|
|
18
|
+
// 2. This tree's format validator admits it: files, hashes, schemas, budgets (`validateShardfileFolder`).
|
|
19
19
|
// 3. Its product goes to `out/<folder>`, with any pack a tarball left out rebuilt from its members, so a page and the
|
|
20
20
|
// grid bake read what they would from a build. Its receipt is issued under this tree's validator revision, by this file, only
|
|
21
21
|
// after step 2 passed, as `productVerdict` earns one for a head a build never made. The cost numbers stay the
|
|
@@ -237,8 +237,8 @@ async function installLocked(only: readonly string[], source: 'pins' | 'format'
|
|
|
237
237
|
// The validator hashes most members already; the manifest reuses those digests rather than hashing twice.
|
|
238
238
|
const digests = new WeakMap<Uint8Array, string>();
|
|
239
239
|
const digest = (bytes: Uint8Array): string => { let held = digests.get(bytes); if (held === undefined) { held = sha256(bytes); digests.set(bytes, held); } return held; };
|
|
240
|
-
const { prepareAssetDecoders } = await import('@wildshard/format/
|
|
241
|
-
const {
|
|
240
|
+
const { prepareAssetDecoders } = await import('@wildshard/format/shardfileAssets');
|
|
241
|
+
const { validateShardfileFolder } = await import('@wildshard/format/shardfileValidation');
|
|
242
242
|
const { readTar } = await import('@wildshard/format/tar');
|
|
243
243
|
const { restorePacks } = await import('./pin-packs.ts');
|
|
244
244
|
await prepareAssetDecoders();
|
|
@@ -286,7 +286,7 @@ async function installLocked(only: readonly string[], source: 'pins' | 'format'
|
|
|
286
286
|
const started = performance.now(), files = readTar(bytes);
|
|
287
287
|
const fileNamed = (path: string): Uint8Array => { const body = files.get(path); if (body === undefined) throw new Error(`${pin.slug}: no ${path}`); return body; };
|
|
288
288
|
try {
|
|
289
|
-
const { warnings } =
|
|
289
|
+
const { warnings } = validateShardfileFolder(
|
|
290
290
|
{ read: (path, maximum) => { const body = fileNamed(path); if (body.length > maximum) throw new Error(`${path} is over its cap`); return body; }, paths: () => files.keys() },
|
|
291
291
|
{ hash: digest },
|
|
292
292
|
);
|
|
@@ -72,7 +72,7 @@ export async function stagedRatchet(files, executable, repository) {
|
|
|
72
72
|
if (repository === undefined) throw new Error('Missing HEAD repository for staged ratchet comparison');
|
|
73
73
|
const head = resolve('.commit-head');
|
|
74
74
|
const prepared = spawnSync('python3', [resolve(import.meta.dirname, 'precommit-source.py'), repository, head,
|
|
75
|
-
String(Date.now() / 1000 + 5), 'HEAD', JSON.stringify({ files: missing, guards: [],
|
|
75
|
+
String(Date.now() / 1000 + 5), 'HEAD', JSON.stringify({ files: missing, guards: [], deleted: false })],
|
|
76
76
|
{ encoding: 'utf8', maxBuffer: 1 << 30 });
|
|
77
77
|
if (prepared.error !== undefined) throw prepared.error;
|
|
78
78
|
if (prepared.status !== 0) throw new Error(`HEAD ratchet source failed: ${prepared.stderr}`);
|
|
@@ -104,12 +104,6 @@ if (import.meta.main) {
|
|
|
104
104
|
const { deletedReferences } = await import('./push-checks.mjs');
|
|
105
105
|
const errors = deletedReferences(process.cwd(), JSON.parse(readFileSync('.commit-deleted.json', 'utf8')));
|
|
106
106
|
if (errors.length > 0) throw new Error(errors.join('\n'));
|
|
107
|
-
} else if (mode === 'closed') {
|
|
108
|
-
if (!existsSync('lint/ratchet.json')) throw new Error('Missing staged closed-component policy');
|
|
109
|
-
const policy = JSON.parse(readFileSync('lint/ratchet.json', 'utf8'));
|
|
110
|
-
const { closedComponentSources } = await import('./check-closed-components.mjs');
|
|
111
|
-
const errors = closedComponentSources(process.cwd(), policy.closedComponents);
|
|
112
|
-
if (errors.length > 0) throw new Error(errors.join('\n'));
|
|
113
107
|
} else throw new Error('Unknown pre-commit guard');
|
|
114
108
|
} catch (error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; }
|
|
115
109
|
}
|
|
@@ -69,7 +69,6 @@ export function commitGuards(changed) {
|
|
|
69
69
|
...(touches(/^src\/(?:format|sdk|sharddev)\//u) ? ['test/schema-reference.test.ts'] : []),
|
|
70
70
|
...(touches(/^(?:lint\/(?:host-callbacks\.mjs|wildshard-plugin\.js)|scripts\/gen-host-catalogue\.mjs|test\/host-callbacks\.test\.ts)$/u) ? ['test/host-callbacks.test.ts'] : []),
|
|
71
71
|
...(touches(/^(?:lint\/(?:shardfile-boundaries\.mjs|wildshard-plugin\.js)|test\/shardfile-boundaries\.test\.ts)$/u) ? ['test/shardfile-boundaries.test.ts'] : []),
|
|
72
|
-
...(touches(/^(?:src\/(?:engine|game|format|sdk|sharddev)\/|scripts\/(?:platform-chargebacks|inline-platform|host-approvals|g571-hosts|shard-components|shard-platform)[^/]*\.|docs\/HOST-BAR\.md$|test\/platform-chargebacks\.test\.ts$)/u) ? ['test/platform-chargebacks.test.ts'] : []),
|
|
73
72
|
...(touches(/^(?:src\/shards\/(?:nalati-grasslands|nine-dragon-stack)\/|src\/(?:client|cook|server|shared)\/game\/shard\/manifest\.ts$|scripts\/(?:authored-manifest|manifest-declaration)\.|test\/(?:manifest-declarations\.test\.ts|fixtures\/manifest-declarations\.json)$)/u) ? ['test/manifest-declarations.test.ts'] : []),
|
|
74
73
|
];
|
|
75
74
|
}
|
|
@@ -160,14 +160,6 @@ def required_sources(blobs, specification, tree=None, executable=None, staged_pa
|
|
|
160
160
|
if specification.get('deleted'):
|
|
161
161
|
# Every active tracked reader is an input to the deleted-path grep.
|
|
162
162
|
selected.update(name for name in blobs if name.split('/')[0] in ROOTS)
|
|
163
|
-
if specification.get('closed'):
|
|
164
|
-
for name in blobs:
|
|
165
|
-
path = PurePosixPath(name)
|
|
166
|
-
if len(path.parts) > 3 and path.parts[:2] == ('src', 'shards') and not path.parts[2].endswith('-legacy'):
|
|
167
|
-
if path.suffix in {'.ts', '.tsx', '.glsl'} and '/generators/' not in name and not re.search(r'\.d\.ts$|\.(?:test|spec)\.tsx?$|/test/', name):
|
|
168
|
-
selected.add(name)
|
|
169
|
-
selected.update(name for name in blobs if re.search(r'/(?:generators/)?bake-[^/]+\.(?:mjs|ts)$', name))
|
|
170
|
-
selected.add('scripts/source-generation-outputs.json')
|
|
171
163
|
if 'test/schema-reference.test.ts' in specification.get('guards', []):
|
|
172
164
|
for layer in ['sdk', 'sharddev']:
|
|
173
165
|
manifest = json.loads(blobs.get(f'src/{layer}/package.json', b'{}'))
|
|
@@ -212,7 +204,7 @@ def required_sources(blobs, specification, tree=None, executable=None, staged_pa
|
|
|
212
204
|
data = blobs[name] if name in blobs else (tree / name).read_bytes()
|
|
213
205
|
if PurePosixPath(name).suffix not in {'.ts', '.tsx', '.mts', '.js', '.mjs', '.cjs', '.json'}:
|
|
214
206
|
continue
|
|
215
|
-
if name.endswith('.json')
|
|
207
|
+
if name.endswith('.json'):
|
|
216
208
|
continue
|
|
217
209
|
text = data.decode('utf8')
|
|
218
210
|
imported = set() if name.endswith('.json') else imports(name, text)
|
|
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import * as v from 'valibot';
|
|
5
5
|
import { readBuiltShardfile } from './built-product.mjs';
|
|
6
|
-
import { discoveryFormat, outputFormat } from './
|
|
6
|
+
import { discoveryFormat, outputFormat } from './node-format.mjs';
|
|
7
7
|
import { encodeCanonicalJson } from '@wildshard/engine/host/immutable';
|
|
8
8
|
|
|
9
9
|
/** @param {unknown} value @returns {value is Record<string, unknown>} */
|
package/scripts/ring-cook.mjs
CHANGED
|
@@ -11,6 +11,7 @@ const { createCookWorker, indexKey } = await import('../src/cook/game/cookWorker
|
|
|
11
11
|
const { folderStore } = await import('../src/cook/game/packStore.ts');
|
|
12
12
|
const { cookRevision } = await import('./cook-revision.ts');
|
|
13
13
|
const { rendererRevision } = await import('./renderer-revision.mjs');
|
|
14
|
+
const { shardfileValidationRevision } = await import('./shardfile-validation-revision.mjs');
|
|
14
15
|
const { values } = parseArgs({ options: { out: {type:'string',default:'tmp/ring-cook'}, build: {type:'string',default:'ring-local'},
|
|
15
16
|
only: {type:'string'}, ring2: {type:'boolean',default:false}, 'timeout-ms': {type:'string',default:'120000'} } });
|
|
16
17
|
const timeout = Number(values['timeout-ms']);
|
|
@@ -31,7 +32,7 @@ const heads = selected.map(slug => {
|
|
|
31
32
|
});
|
|
32
33
|
const store = folderStore(join(out,'store'));
|
|
33
34
|
// A fresh run owns its empty cache. At least its first product always encodes cold.
|
|
34
|
-
const worker = createCookWorker({ build: values.build, store, serverPacks: join(out,'server'), scratch: join(out,'jobs'),
|
|
35
|
+
const worker = createCookWorker({ build: values.build, store, serverPacks: join(out,'server'), scratch: join(out,'jobs'), validator: shardfileValidationRevision(root),
|
|
35
36
|
source: { heads: () => Promise.resolve(heads.map(row => ({...row, revision:1}))), download: hash => Promise.resolve(readFileSync(join(cache,`${hash}.tar`))) },
|
|
36
37
|
launcher: { root, execPath: process.execPath, loader:join(root,'scripts/bake-loader.mjs'), script:join(root,'scripts/cook-job.mjs'),
|
|
37
38
|
wrap:[], limits:{seconds:timeout/1000,memoryMB:4096,heapMB:2048}, renderer: rendererRevision(root) } });
|
package/scripts/ring-step.ts
CHANGED
|
@@ -27,7 +27,7 @@ const sha256 = (text: string): string => createHash('sha256').update(text).diges
|
|
|
27
27
|
const line = (tick: number): HeadlessCommand => ({ kind: 'player', moveX: 0.3 * Math.sin(tick / 90), moveZ: -1, yaw: 0, ...(tick % 47 === 0 ? { jump: true as const } : {}), ...(tick % 97 === 0 ? { dodge: true as const } : {}) });
|
|
28
28
|
const only = option('only')?.split(',');
|
|
29
29
|
|
|
30
|
-
const { prepareAssetDecoders } = await import('@wildshard/format/
|
|
30
|
+
const { prepareAssetDecoders } = await import('@wildshard/format/shardfileAssets');
|
|
31
31
|
const { loadRapier } = await import('../src/shared/engine/physics/rapier.ts');
|
|
32
32
|
const { loadHeadlessProduct } = await import('../src/server/host/headlessProduct.ts');
|
|
33
33
|
const { createTrustedHeadlessResident } = await import('../src/server/host/headlessRuntime.ts');
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// repo-kit's scratch folder maker (meta docs/plans/REPO-DISK-PLAN.md row DK3). One copy lives in repo-kit; every org
|
|
3
|
+
// repo and singleplayer carries a byte-identical copy at scripts/scratch-dir.mjs (DK8 checks the copies).
|
|
4
|
+
//
|
|
5
|
+
// node scripts/scratch-dir.mjs <task> "<purpose>"
|
|
6
|
+
//
|
|
7
|
+
// creates <repo>/tmp/<task>/ and tmp/<task>/.owner, then prints the folder's absolute path. .owner is JSON: the session
|
|
8
|
+
// id ($CLAUDE_SESSION_ID, else $CLAUDE_CODE_SESSION_ID, else the Codex lane name in $WS_LANE_NAME), the lane name, the
|
|
9
|
+
// herdr pane ($HERDR_PANE_ID), the start time and the purpose. DK4's SessionEnd hook removes the folders whose .owner
|
|
10
|
+
// names the ending session; a .keep file in the folder (one line: why to keep it) stops that and DK6's 3-day sweep.
|
|
11
|
+
//
|
|
12
|
+
// <task> is one plain folder name: letters, digits, '.', '_' and '-', not starting with '.', never containing '/' or
|
|
13
|
+
// '..'. The helper deletes nothing. It refuses a folder that already exists unless that folder's .owner names this
|
|
14
|
+
// same session (then it prints the path again), so it never takes over another lane's or an ownerless folder.
|
|
15
|
+
import { mkdirSync, readFileSync, rmdirSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { join, resolve } from 'node:path';
|
|
17
|
+
import { pathToFileURL } from 'node:url';
|
|
18
|
+
|
|
19
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
20
|
+
const TASK = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/u;
|
|
21
|
+
|
|
22
|
+
/** Why a task name is refused, or null when it is a plain folder name.
|
|
23
|
+
* @param {string} task @returns {string | null} */
|
|
24
|
+
export function refuseTask(task) {
|
|
25
|
+
if (typeof task !== 'string' || task === '') return 'a task name is required';
|
|
26
|
+
if (task.includes('/') || task.includes('\\')) return `task "${task}" contains a path separator`;
|
|
27
|
+
if (task.includes('..')) return `task "${task}" contains ".."`;
|
|
28
|
+
if (task.length > 100) return `task "${task}" is longer than 100 characters`;
|
|
29
|
+
if (!TASK.test(task)) return `task "${task}" must be letters, digits, ".", "_" and "-", not starting with "."`;
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The .owner record for a new folder.
|
|
34
|
+
* @param {string} task @param {string} purpose @param {NodeJS.ProcessEnv} env @param {Date} now */
|
|
35
|
+
export function ownerRecord(task, purpose, env, now) {
|
|
36
|
+
const lane = env.WS_LANE_NAME || null;
|
|
37
|
+
return {
|
|
38
|
+
task,
|
|
39
|
+
session: env.CLAUDE_SESSION_ID || env.CLAUDE_CODE_SESSION_ID || lane,
|
|
40
|
+
lane,
|
|
41
|
+
pane: env.HERDR_PANE_ID || null,
|
|
42
|
+
started: now.toISOString(),
|
|
43
|
+
purpose,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** @param {string} path @returns {{session?: unknown} | null} */
|
|
48
|
+
function readOwner(path) {
|
|
49
|
+
try { return JSON.parse(readFileSync(path, 'utf8')); } catch { return null; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Make <root>/tmp/<task>/ and its .owner; returns the folder's absolute path. Throws on a refused name, an empty
|
|
53
|
+
* purpose, or a folder that exists and is not this session's.
|
|
54
|
+
* @param {string} task @param {string} purpose
|
|
55
|
+
* @param {{root?: string, env?: NodeJS.ProcessEnv, now?: Date}} [options] */
|
|
56
|
+
export function scratchDir(task, purpose, { root = ROOT, env = process.env, now = new Date() } = {}) {
|
|
57
|
+
const refusal = refuseTask(task);
|
|
58
|
+
if (refusal) throw new Error(refusal);
|
|
59
|
+
if (typeof purpose !== 'string' || purpose.trim() === '') throw new Error('a purpose is required');
|
|
60
|
+
const tmp = join(resolve(root), 'tmp');
|
|
61
|
+
const dir = join(tmp, task);
|
|
62
|
+
const owner = ownerRecord(task, purpose.trim(), env, now);
|
|
63
|
+
mkdirSync(tmp, { recursive: true });
|
|
64
|
+
try {
|
|
65
|
+
mkdirSync(dir);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'EEXIST')) throw error;
|
|
68
|
+
const existing = readOwner(join(dir, '.owner'));
|
|
69
|
+
if (existing && owner.session && existing.session === owner.session) return dir;
|
|
70
|
+
throw new Error(existing
|
|
71
|
+
? `${dir} already belongs to session ${String(existing.session)}; pick another task name`
|
|
72
|
+
: `${dir} already exists with no .owner; pick another task name`);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
writeFileSync(join(dir, '.owner'), `${JSON.stringify(owner, null, 2)}\n`, { flag: 'wx' });
|
|
76
|
+
} catch (error) {
|
|
77
|
+
rmdirSync(dir); // only the empty folder this call just made
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
return dir;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
84
|
+
const [task = '', purpose = '', ...rest] = process.argv.slice(2);
|
|
85
|
+
if (rest.length > 0 || task === '--help' || task === '-h') {
|
|
86
|
+
console.error('usage: node scripts/scratch-dir.mjs <task> "<purpose>"');
|
|
87
|
+
process.exit(2);
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
console.log(scratchDir(task, purpose));
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error(`scratch-dir: ${error instanceof Error ? error.message : String(error)}`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// repo-kit's 3-day scratch sweep (meta REPO-DISK-PLAN DK6, was TEMP-HYGIENE T7). One copy lives in repo-kit; every org
|
|
3
|
+
// repo carries a byte-identical copy at scripts/scratch-sweep.mjs, beside scratch-dir.mjs (DK3) and vite-tmp.mjs.
|
|
4
|
+
//
|
|
5
|
+
// node scripts/scratch-sweep.mjs [--live] [--root <repo>] [--days <n>]
|
|
6
|
+
//
|
|
7
|
+
// It looks at each folder directly under <repo>/tmp/ and would remove one in which nothing (the folder or anything in
|
|
8
|
+
// it) changed for <n> days (3 by default), with or without a DK3 `.owner`. It keeps:
|
|
9
|
+
// - a folder holding `.keep`, or named in `tmp/keep` (one name per line, `#` comments); `tmp/keep` itself when it is a
|
|
10
|
+
// folder (singleplayer keeps hand-kept work there);
|
|
11
|
+
// - a folder that is, or holds, some process's cwd (lsof -d cwd; /proc on Linux); an unreadable table keeps all;
|
|
12
|
+
// - a folder holding a Git root with dirty files or commits no remote has (DS14's list: the reason names the root);
|
|
13
|
+
// - dot folders, symlinks, and `tmp/vitest` (vite-tmp.mjs's own).
|
|
14
|
+
// Dry run is the default until Jake's yes (REPO-DISK decision 1) and a week of dry-run log; `--live` removes. Every
|
|
15
|
+
// decision is appended to tmp/.sweep.log, one line each, and a summary line goes to stdout.
|
|
16
|
+
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import { appendFileSync, lstatSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync } from 'node:fs';
|
|
18
|
+
import { join, resolve, sep } from 'node:path';
|
|
19
|
+
import { pathToFileURL } from 'node:url';
|
|
20
|
+
|
|
21
|
+
const DEFAULT_DAYS = 3;
|
|
22
|
+
const MINUTES_A_DAY = 1440;
|
|
23
|
+
const OWNED_ELSEWHERE = new Set(['vitest']);
|
|
24
|
+
|
|
25
|
+
/** Every process cwd as a real path, or null when the table can't be read (the same read as scratch-end.mjs). */
|
|
26
|
+
export function processCwds() {
|
|
27
|
+
if (process.platform === 'linux') {
|
|
28
|
+
let pids;
|
|
29
|
+
try {
|
|
30
|
+
pids = readdirSync('/proc').filter(name => /^\d+$/u.test(name));
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const cwds = [];
|
|
35
|
+
for (const pid of pids) {
|
|
36
|
+
try {
|
|
37
|
+
cwds.push(readlinkSync(`/proc/${pid}/cwd`).replace(/ \(deleted\)$/u, ''));
|
|
38
|
+
} catch {}
|
|
39
|
+
}
|
|
40
|
+
return cwds;
|
|
41
|
+
}
|
|
42
|
+
// A timed-out or failed lsof printed only part of the table: treat it as unreadable.
|
|
43
|
+
const lsof = spawnSync('lsof', ['-nP', '-w', '-d', 'cwd', '-Fn'], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: 10_000 });
|
|
44
|
+
if (lsof.error || lsof.signal || lsof.status !== 0) return null;
|
|
45
|
+
const cwds = (lsof.stdout || '').split('\n').filter(line => line.startsWith('n')).map(line => line.slice(1));
|
|
46
|
+
return cwds.length > 0 ? cwds : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @param {string} path */
|
|
50
|
+
function stat(path) {
|
|
51
|
+
try {
|
|
52
|
+
return lstatSync(path);
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Names in tmp/keep. @param {string} tmp */
|
|
59
|
+
function keepList(tmp) {
|
|
60
|
+
let text = '';
|
|
61
|
+
try {
|
|
62
|
+
text = readFileSync(join(tmp, 'keep'), 'utf8');
|
|
63
|
+
} catch {
|
|
64
|
+
return new Set();
|
|
65
|
+
}
|
|
66
|
+
return new Set(text.split('\n').map(line => line.replace(/#.*/u, '').trim()).filter(Boolean));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** True when anything under `dir` (itself included) changed in the last `days` days, or the walk failed.
|
|
70
|
+
* @param {string} dir @param {number} days */
|
|
71
|
+
function touched(dir, days) {
|
|
72
|
+
const find = spawnSync('find', [dir, '-mmin', `-${String(days * MINUTES_A_DAY)}`, '-print', '-quit'], { encoding: 'utf8', maxBuffer: 1024 * 1024 });
|
|
73
|
+
return find.status !== 0 || find.stdout.trim() !== '';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @param {string} root @param {readonly string[]} args */
|
|
77
|
+
function git(root, args) {
|
|
78
|
+
// GIT_OPTIONAL_LOCKS=0: `git status` must not refresh the index, or reading a stale clone would touch it.
|
|
79
|
+
const run = spawnSync('git', ['-C', root, ...args], { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024, env: { ...process.env, GIT_OPTIONAL_LOCKS: '0' } });
|
|
80
|
+
return run.status === 0 ? run.stdout.trim() : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The first Git root under `dir` with dirty files or unpublished commits, and why; a Git error counts as unpublished.
|
|
84
|
+
* @param {string} dir @returns {string | null} */
|
|
85
|
+
function unpublished(dir) {
|
|
86
|
+
const find = spawnSync('find', [dir, '-maxdepth', '4', '-name', '.git', '-prune', '-print'], { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 });
|
|
87
|
+
if (find.status !== 0) return `${dir}: Git roots unreadable`;
|
|
88
|
+
for (const marker of find.stdout.split('\n').filter(Boolean)) {
|
|
89
|
+
const root = resolve(marker, '..');
|
|
90
|
+
const status = git(root, ['status', '--porcelain', '--ignore-submodules']);
|
|
91
|
+
if (status === null) return `${root}: git status failed`;
|
|
92
|
+
if (status !== '') return `${root}: dirty files`;
|
|
93
|
+
const ahead = git(root, ['log', '--branches', '--tags', '--not', '--remotes', '--oneline', '-1']);
|
|
94
|
+
if (ahead === null) return `${root}: git log failed`;
|
|
95
|
+
if (ahead !== '') return `${root}: commits no remote has`;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Each tmp/ folder and what the sweep does with it, removing nothing.
|
|
101
|
+
* @param {{ root: string, days?: number, cwds?: readonly string[] | null }} options
|
|
102
|
+
* @returns {{ name: string, action: 'remove' | 'keep', reason: string }[]} */
|
|
103
|
+
export function plan({ root, days = DEFAULT_DAYS, cwds = processCwds() }) {
|
|
104
|
+
const tmp = join(root, 'tmp');
|
|
105
|
+
const rows = [];
|
|
106
|
+
let names = [];
|
|
107
|
+
try {
|
|
108
|
+
names = readdirSync(tmp).toSorted();
|
|
109
|
+
} catch {
|
|
110
|
+
return rows;
|
|
111
|
+
}
|
|
112
|
+
const kept = keepList(tmp);
|
|
113
|
+
const real = cwds?.map(cwd => {
|
|
114
|
+
try {
|
|
115
|
+
return realpathSync(cwd);
|
|
116
|
+
} catch {
|
|
117
|
+
return cwd;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
for (const name of names) {
|
|
121
|
+
const dir = join(tmp, name), info = stat(dir);
|
|
122
|
+
if (info === null || !info.isDirectory() || name.startsWith('.') || OWNED_ELSEWHERE.has(name)) continue;
|
|
123
|
+
const at = realpathSync(dir);
|
|
124
|
+
/** @param {string} reason */
|
|
125
|
+
const keep = reason => rows.push({ name, action: /** @type {const} */ ('keep'), reason });
|
|
126
|
+
if (stat(join(dir, '.keep')) !== null) keep('.keep');
|
|
127
|
+
else if (kept.has(name)) keep('tmp/keep');
|
|
128
|
+
else if (name === 'keep') keep('tmp/keep is a folder of kept work');
|
|
129
|
+
else if (real === undefined || real === null) keep('process table unreadable');
|
|
130
|
+
else if (real.some(cwd => cwd === at || cwd.startsWith(at + sep))) keep('busy: a process cwd inside');
|
|
131
|
+
else if (touched(dir, days)) keep(`changed within ${String(days)} days`);
|
|
132
|
+
else {
|
|
133
|
+
const why = unpublished(dir);
|
|
134
|
+
if (why === null) rows.push({ name, action: /** @type {const} */ ('remove'), reason: `untouched ${String(days)} days` });
|
|
135
|
+
else keep(`unpublished (DS14): ${why}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return rows;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Plans, logs every row to tmp/.sweep.log, and removes the planned folders when live.
|
|
142
|
+
* @param {{ root: string, live?: boolean, days?: number, cwds?: readonly string[] | null, now?: Date }} options */
|
|
143
|
+
export function sweep({ root, live = false, days = DEFAULT_DAYS, cwds, now = new Date() }) {
|
|
144
|
+
const rows = plan({ root, days, ...(cwds === undefined ? {} : { cwds }) });
|
|
145
|
+
const stamp = now.toISOString(), lines = [];
|
|
146
|
+
let removed = 0;
|
|
147
|
+
for (const row of rows) {
|
|
148
|
+
let verb = row.action === 'keep' ? `keep (${row.reason})` : 'would remove';
|
|
149
|
+
if (row.action === 'remove' && live) {
|
|
150
|
+
try {
|
|
151
|
+
rmSync(join(root, 'tmp', row.name), { recursive: true, force: true });
|
|
152
|
+
verb = 'removed';
|
|
153
|
+
removed += 1;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
verb = `remove failed (${error instanceof Error ? error.message : String(error)})`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
lines.push(`${stamp} ${verb} tmp/${row.name}${row.action === 'remove' ? ` (${row.reason})` : ''}\n`);
|
|
159
|
+
}
|
|
160
|
+
if (lines.length > 0) {
|
|
161
|
+
try {
|
|
162
|
+
appendFileSync(join(root, 'tmp/.sweep.log'), lines.join(''));
|
|
163
|
+
} catch {}
|
|
164
|
+
}
|
|
165
|
+
const planned = rows.filter(row => row.action === 'remove').length;
|
|
166
|
+
return { rows, planned, removed };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
170
|
+
const args = process.argv.slice(2);
|
|
171
|
+
const flag = (/** @type {string} */ name) => {
|
|
172
|
+
const at = args.indexOf(name);
|
|
173
|
+
return at === -1 ? undefined : args[at + 1];
|
|
174
|
+
};
|
|
175
|
+
const days = Number(flag('--days') ?? DEFAULT_DAYS);
|
|
176
|
+
if (!Number.isInteger(days) || days < 1) throw new Error('--days takes a whole number of days, 1 or more');
|
|
177
|
+
const root = resolve(flag('--root') ?? resolve(import.meta.dirname, '..'));
|
|
178
|
+
const live = args.includes('--live');
|
|
179
|
+
const { rows, planned, removed } = sweep({ root, live, days });
|
|
180
|
+
const keptRows = rows.filter(row => row.action === 'keep');
|
|
181
|
+
process.stdout.write(`scratch-sweep ${live ? 'live' : '(dry run)'} ${root}/tmp: ${live ? `removed ${String(removed)} of ${String(planned)}` : `would remove ${String(planned)}`}, kept ${String(keptRows.length)}; log tmp/.sweep.log\n`);
|
|
182
|
+
}
|