@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
|
@@ -13,23 +13,28 @@
|
|
|
13
13
|
// commit, and `origin plan/<slug>` deleted (`git push --delete`, which the pre-push lets through without a gate)
|
|
14
14
|
// only if the remote branch is landed too, under a lease on the SHA it had. A worktree that fails any check is kept
|
|
15
15
|
// and named with the reason; an unlanded branch, local or remote, is never touched. Every run appends one receipt.
|
|
16
|
+
// REPO-DISK DK11: a removed worktree takes its tmp/ and build output with it (they are ignored files inside it), and
|
|
17
|
+
// a real run's receipt records the `df` bytes it freed (other writers move df too, so it is a measure, not a ledger).
|
|
18
|
+
// A worktree kept because it is unlanded or dirty and untouched for --stale hours (default 72) is named in the
|
|
19
|
+
// receipt with its `du` size, so the coordinator's brief can put it to its owner.
|
|
16
20
|
import {execFileSync,spawnSync} from 'node:child_process';
|
|
17
|
-
import {appendFileSync,existsSync,mkdirSync,readdirSync,readlinkSync,realpathSync,statSync} from 'node:fs';
|
|
21
|
+
import {appendFileSync,existsSync,mkdirSync,readdirSync,readlinkSync,realpathSync,statSync,statfsSync} from 'node:fs';
|
|
18
22
|
import {homedir} from 'node:os';
|
|
19
23
|
import {basename,dirname,join,resolve,sep} from 'node:path';
|
|
20
24
|
import {pidLock} from './pid-lock.mjs';
|
|
21
25
|
import {WORKTREES} from './worktree-ignore.mjs';
|
|
22
26
|
|
|
23
|
-
const REAP_USAGE='usage: node scripts/worktree.mjs reap [--dry-run] [--grace=HOURS] [--no-remote]';
|
|
27
|
+
const REAP_USAGE='usage: node scripts/worktree.mjs reap [--dry-run] [--grace=HOURS] [--stale=HOURS] [--no-remote]';
|
|
24
28
|
|
|
25
|
-
/** @param {string[]} argv the arguments after `reap` @returns {{dryRun:boolean,graceHours:number,remote:boolean}} */
|
|
29
|
+
/** @param {string[]} argv the arguments after `reap` @returns {{dryRun:boolean,graceHours:number,staleHours:number,remote:boolean}} */
|
|
26
30
|
export function parseReapArgs(argv){
|
|
27
|
-
const options={dryRun:false,graceHours:24,remote:true};
|
|
31
|
+
const options={dryRun:false,graceHours:24,staleHours:72,remote:true};
|
|
28
32
|
for(const arg of argv){
|
|
29
33
|
const [name,value]=arg.split('=',2);
|
|
30
34
|
if(arg==='--dry-run')options.dryRun=true;
|
|
31
35
|
else if(arg==='--no-remote')options.remote=false;
|
|
32
36
|
else if(name==='--grace'&&value!==undefined&&/^\d+(?:\.\d+)?$/u.test(value))options.graceHours=Number(value);
|
|
37
|
+
else if(name==='--stale'&&value!==undefined&&/^\d+(?:\.\d+)?$/u.test(value))options.staleHours=Number(value);
|
|
33
38
|
else throw new Error(`unknown option ${arg}\n${REAP_USAGE}`);
|
|
34
39
|
}
|
|
35
40
|
return options;
|
|
@@ -103,21 +108,39 @@ export function stopWorktreeProcesses(tree,options={}){
|
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
/** Newest change in the worktree's own Git state, in ms. @param {string} tree @param {string} gitDir */
|
|
106
|
-
function lastActivity(tree,gitDir){
|
|
111
|
+
export function lastActivity(tree,gitDir){
|
|
107
112
|
let newest=Number(git(tree,['log','-1','--format=%ct','HEAD']).trim())*1000;
|
|
108
113
|
for(const file of ['index','HEAD','logs/HEAD'])try{newest=Math.max(newest,statSync(join(gitDir,file)).mtimeMs);}catch{/* Not there. */}
|
|
109
114
|
return newest;
|
|
110
115
|
}
|
|
111
116
|
|
|
117
|
+
/** Free bytes on the volume holding `path` (what `df` shows as available). @param {string} path */
|
|
118
|
+
export function freeBytes(path){
|
|
119
|
+
const volume=statfsSync(path);
|
|
120
|
+
return volume.bavail*volume.bsize;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** `du -sk` of `path` as GiB text, within `budgetMs` (all of a run's `du` calls share one budget), or why not.
|
|
124
|
+
* @param {string} path @param {number} budgetMs */
|
|
125
|
+
function duSize(path,budgetMs){
|
|
126
|
+
if(budgetMs<1000)return 'size not measured (du budget spent)';
|
|
127
|
+
const listed=spawnSync('du',['-sk',path],{encoding:'utf8',timeout:budgetMs});
|
|
128
|
+
const kib=Number((listed.stdout??'').split('\t')[0]);
|
|
129
|
+
return listed.status===0&&Number.isFinite(kib)&&kib>0?`${(kib/1_048_576).toFixed(1)} GiB`:'size unknown';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Signed MiB text for a byte count; the sign is taken after rounding, so a tiny change reads +0. @param {number} bytes */
|
|
133
|
+
const mib=bytes=>{const size=Math.round(bytes/1_048_576);return `${size<0?'-':'+'}${Math.abs(size).toLocaleString('en-US')} MiB`;};
|
|
134
|
+
|
|
112
135
|
/** Is `sha` on origin/main itself? @param {string} canonical @param {string} sha */
|
|
113
|
-
const onMain=(canonical,sha)=>sha!==''&&tryGit(canonical,['merge-base','--is-ancestor',sha,'origin/main']).status===0;
|
|
136
|
+
export const onMain=(canonical,sha)=>sha!==''&&tryGit(canonical,['merge-base','--is-ancestor',sha,'origin/main']).status===0;
|
|
114
137
|
/** Commits of `sha` that origin/main lacks. @param {string} canonical @param {string} sha */
|
|
115
138
|
const aheadOfMain=(canonical,sha)=>Number(tryGit(canonical,['rev-list','--count',`origin/main..${sha}`]).stdout.trim()||'0');
|
|
116
139
|
|
|
117
140
|
/** @typedef {{path:string,head:string,branch:string}} Worktree */
|
|
118
141
|
|
|
119
142
|
/** Linked worktrees of the repo from `git worktree list --porcelain -z`. @param {string} canonical @returns {Worktree[]} */
|
|
120
|
-
function linkedWorktrees(canonical){
|
|
143
|
+
export function linkedWorktrees(canonical){
|
|
121
144
|
/** @type {Worktree[]} */const trees=[];
|
|
122
145
|
/** @type {Partial<Worktree>} */let current={};
|
|
123
146
|
for(const field of [...git(canonical,['worktree','list','--porcelain','-z']).split('\0'),'']){
|
|
@@ -141,9 +164,30 @@ export function reap(canonical,options,env,say){
|
|
|
141
164
|
const fetched=tryGit(canonical,['fetch','--quiet','origin','+refs/heads/main:refs/remotes/origin/main']);
|
|
142
165
|
if(fetched.status!==0){say(`reap STOP cannot fetch origin main: ${fetched.stderr.trim()}`);return 1;}
|
|
143
166
|
const directories=processDirectories();
|
|
144
|
-
const realRoot=realpathSync(canonical),now=Date.now();
|
|
167
|
+
const realRoot=realpathSync(canonical),now=Date.now(),freeBefore=freeBytes(canonical);
|
|
145
168
|
/** @type {string[]} */const reaped=[];
|
|
146
169
|
/** @type {string[]} */const kept=[];
|
|
170
|
+
/** @type {string[]} */const stale=[];
|
|
171
|
+
const duUntil=now+60_000;
|
|
172
|
+
/** DK11: an unlanded or dirty worktree untouched for --stale hours goes on the receipt with its size. Untouched
|
|
173
|
+
* means no Git activity, no change to a dirty path, and no process inside.
|
|
174
|
+
* @param {string} slug @param {string} path @param {string} why @param {string[]} [dirty] porcelain lines */
|
|
175
|
+
const staleCheck=(slug,path,why,dirty=[])=>{
|
|
176
|
+
let gitDir='',physical='';
|
|
177
|
+
try{gitDir=git(path,['rev-parse','--absolute-git-dir']).trim();physical=realpathSync(path);}catch{return;}
|
|
178
|
+
if(directories===undefined||[...directories.values()].some(cwd=>cwd===physical||cwd.startsWith(`${physical}${sep}`)))return;
|
|
179
|
+
let newest=0;
|
|
180
|
+
try{newest=lastActivity(path,gitDir);}catch{return;}
|
|
181
|
+
for(const line of dirty.slice(0,500)){
|
|
182
|
+
const name=line.slice(3).split(' -> ').at(-1)??'';
|
|
183
|
+
try{newest=Math.max(newest,statSync(join(path,name.replaceAll(/^"|"$/gu,''))).mtimeMs);}catch{/* Deleted: no mtime. */}
|
|
184
|
+
}
|
|
185
|
+
const idle=(now-newest)/3_600_000;
|
|
186
|
+
if(idle<options.staleHours)return;
|
|
187
|
+
const entry=`${slug} (${duSize(path,duUntil-Date.now())}, idle ${(idle/24).toFixed(1)} d, ${why})`;
|
|
188
|
+
stale.push(entry);
|
|
189
|
+
say(`stale ${entry}`);
|
|
190
|
+
};
|
|
147
191
|
/** @type {string[]} */const remotes=[];
|
|
148
192
|
for(const tree of linkedWorktrees(canonical)){
|
|
149
193
|
const slug=basename(tree.path),branch=`refs/heads/plan/${slug}`;
|
|
@@ -156,9 +200,9 @@ export function reap(canonical,options,env,say){
|
|
|
156
200
|
if(tree.branch!==branch){keep(`on ${tree.branch===''?'a detached HEAD':tree.branch}, not plan/${slug}`);continue;}
|
|
157
201
|
if(!existsSync(tree.path)){keep('its folder is gone; `git worktree prune` clears it');continue;}
|
|
158
202
|
// Landed means the tip is on main itself (land fast-forwards): \`git cherry\` would miss a merge's own changes.
|
|
159
|
-
if(!onMain(canonical,tree.head)){
|
|
160
|
-
const dirty=git(tree.path,['status','--porcelain','--untracked-files=all']).split('\n').filter(Boolean);
|
|
161
|
-
if(dirty.length>0){
|
|
203
|
+
if(!onMain(canonical,tree.head)){const why=`${String(aheadOfMain(canonical,tree.head))} commit(s) not on main`;keep(why);staleCheck(slug,tree.path,why);continue;}
|
|
204
|
+
const dirty=git(tree.path,['--no-optional-locks','status','--porcelain','--untracked-files=all']).split('\n').filter(Boolean);
|
|
205
|
+
if(dirty.length>0){const why=`${String(dirty.length)} uncommitted path(s)`;keep(`${why}, first ${dirty[0]?.slice(3)}`);staleCheck(slug,tree.path,why,dirty);continue;}
|
|
162
206
|
const gitDir=git(tree.path,['rev-parse','--absolute-git-dir']).trim();
|
|
163
207
|
const busy=(/** @type {Map<number,string>|undefined} */ seen)=>seen===undefined?'cannot list process working directories'
|
|
164
208
|
:[...seen].filter(([,path])=>path===physical||path.startsWith(`${physical}${sep}`)).map(([pid])=>String(pid)).join(', ');
|
|
@@ -180,7 +224,7 @@ export function reap(canonical,options,env,say){
|
|
|
180
224
|
if(stopped.length>0)say(`${options.dryRun?'would stop':'stopped '} ${slug}: orphaned pid ${stopped.join(', ')}`);
|
|
181
225
|
}
|
|
182
226
|
const head=tryGit(tree.path,['rev-parse','HEAD']).stdout.trim();
|
|
183
|
-
const now2=git(tree.path,['status','--porcelain','--untracked-files=all']).trim();
|
|
227
|
+
const now2=git(tree.path,['--no-optional-locks','status','--porcelain','--untracked-files=all']).trim();
|
|
184
228
|
const seen2=processDirectories();
|
|
185
229
|
const using2=busy(seen2===undefined||!options.dryRun?seen2:new Map([...seen2].filter(([pid])=>!orphans.has(pid))));
|
|
186
230
|
const why=head!==tree.head?`HEAD moved to ${head.slice(0,10)} during the check`:now2!==''?'edited during the check':using2!==''?`in use during the check (${using2})`
|
|
@@ -206,8 +250,10 @@ export function reap(canonical,options,env,say){
|
|
|
206
250
|
else{remotes.push(`${slug} delete failed`);say(` ${slug}: origin plan/${slug} not deleted: ${pushed.stderr.trim()}`);}
|
|
207
251
|
}
|
|
208
252
|
if(!options.dryRun)tryGit(canonical,['worktree','prune']);
|
|
253
|
+
const freed=options.dryRun?'':`; df ${mib(freeBytes(canonical)-freeBefore)}`;
|
|
254
|
+
if(freed!=='')say(`df free changed ${freed.slice(5)} during the run`);
|
|
209
255
|
const lane=/^[a-z][a-z0-9_-]*$/u.test(env.WS_LANE_NAME??'')?String(env.WS_LANE_NAME):'reaper';
|
|
210
|
-
const line=`${new Date().toISOString().slice(11,16)} UTC ${lane} worktree reap ${basename(canonical)}${options.dryRun?' (dry run)':''}: ${reaped.length===0?'none':`${options.dryRun?'would reap':'reaped'} ${reaped.join(', ')}`}; kept ${kept.length===0?'none':kept.join(', ')}${remotes.length===0?'':`; origin ${remotes.join(', ')}`}`;
|
|
256
|
+
const line=`${new Date().toISOString().slice(11,16)} UTC ${lane} worktree reap ${basename(canonical)}${options.dryRun?' (dry run)':''}: ${reaped.length===0?'none':`${options.dryRun?'would reap':'reaped'} ${reaped.join(', ')}`}; kept ${kept.length===0?'none':kept.join(', ')}${remotes.length===0?'':`; origin ${remotes.join(', ')}`}${freed}${stale.length===0?'':`; stale ${String(options.staleHours)} h+: ${stale.join(', ')}`}`;
|
|
211
257
|
const file=resolve(env.WS_LANE_RECEIPTS??join(homedir(),'.cache/wildshard/lane-receipts.log'));
|
|
212
258
|
try{mkdirSync(dirname(file),{recursive:true});appendFileSync(file,`${line}\n`);}catch(error){say(`reap receipt unavailable: ${String(error)}`);}
|
|
213
259
|
return 0;
|
package/scripts/worktree.mjs
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Never copied: .env*, tmp/, .review/, .cache/, browser profiles, leases, ports, push proofs; the worktree gets
|
|
15
15
|
// only tracked files and its own install. Each step's seconds go to <worktree>/tmp/worktree-setup.json and, with
|
|
16
|
-
// WS_LANE_NAME set, one line in ~/.cache/wildshard/lane-receipts.log.
|
|
16
|
+
// WS_LANE_NAME set, one line in ~/.cache/wildshard/lane-receipts.log. REPO-DISK DK10: the record and the receipt also
|
|
17
|
+
// carry the volume's `df` free bytes before and after and the worktree's `du`: build output inside a worktree costs
|
|
18
|
+
// nothing until written (clones), so `df` shows the real cost and `du` the apparent one. Removal is DS13's reaper: `reap`
|
|
17
19
|
// (scripts/worktree-reap.mjs) removes landed, clean, idle worktrees with their branches, local and on origin.
|
|
18
20
|
import {execFileSync,spawn,spawnSync} from 'node:child_process';
|
|
19
21
|
import {randomBytes} from 'node:crypto';
|
|
@@ -22,7 +24,7 @@ import {homedir} from 'node:os';
|
|
|
22
24
|
import {basename,dirname,join,resolve} from 'node:path';
|
|
23
25
|
import {pathToFileURL} from 'node:url';
|
|
24
26
|
import {WORKTREES} from './worktree-ignore.mjs';
|
|
25
|
-
import {parseReapArgs,reap} from './worktree-reap.mjs';
|
|
27
|
+
import {freeBytes,parseReapArgs,reap} from './worktree-reap.mjs';
|
|
26
28
|
|
|
27
29
|
export const SLUG=/^[a-z0-9][a-z0-9._-]{0,63}$/u;
|
|
28
30
|
const REGULAR=/^100(?:644|755)$/u;
|
|
@@ -247,12 +249,22 @@ function run(cwd,command,args,env){
|
|
|
247
249
|
if(result.status!==0)throw new StopError(`${command} ${args.join(' ')} exited ${String(result.status)}`);
|
|
248
250
|
}
|
|
249
251
|
|
|
252
|
+
/** DK10: what the new worktree cost the volume (`df` free before minus after; other writers move it too) and what
|
|
253
|
+
* `du` counts in it (clones in full). @param {string} tree @param {number} freeBefore free bytes before setup */
|
|
254
|
+
export function diskCost(tree,freeBefore){
|
|
255
|
+
const freeAfter=freeBytes(tree),listed=spawnSync('du',['-sk',tree],{encoding:'utf8',timeout:120_000});
|
|
256
|
+
const kib=Number((listed.stdout??'').split('\t')[0]),duKib=listed.status===0&&Number.isFinite(kib)?kib:undefined;
|
|
257
|
+
const cost=freeBefore-freeAfter,costMib=Math.round(cost/1_048_576);
|
|
258
|
+
const text=`df ${costMib<0?'gained':'cost'} ${Math.abs(costMib).toLocaleString('en-US')} MiB, du ${duKib===undefined?'unknown':`${(duKib/1_048_576).toFixed(2)} GiB`}, free ${(freeAfter/2**30).toFixed(1)} GiB`;
|
|
259
|
+
return {freeBefore,freeAfter,dfCostBytes:cost,duKib,text};
|
|
260
|
+
}
|
|
261
|
+
|
|
250
262
|
/** @param {string[]} argv @param {string} [cwd] @param {NodeJS.ProcessEnv} [env] @returns {number} */
|
|
251
263
|
export function worktreeNew(argv,cwd=process.cwd(),env=process.env){
|
|
252
264
|
const options=parseArgs(argv),canonical=canonicalRoot(cwd),common=join(canonical,'.git');
|
|
253
265
|
const relative=`${WORKTREES}/${options.slug}`,tree=join(canonical,relative),branch=`plan/${options.slug}`;
|
|
254
266
|
/** @type {{step:string,seconds:number,detail?:string}[]} */const steps=[];
|
|
255
|
-
const began=performance.now();
|
|
267
|
+
const began=performance.now(),freeBefore=freeBytes(canonical);
|
|
256
268
|
/** @param {string} step @param {() => (string|void)} work */
|
|
257
269
|
const timed=(step,work)=>{
|
|
258
270
|
const started=performance.now(),detail=work();
|
|
@@ -307,13 +319,15 @@ export function worktreeNew(argv,cwd=process.cwd(),env=process.env){
|
|
|
307
319
|
catch(error){process.stderr.write(`worktree: timings refresh not started (${error instanceof Error?error.message:String(error)})\n`);}
|
|
308
320
|
}
|
|
309
321
|
const total=Number(((performance.now()-began)/1000).toFixed(2));
|
|
310
|
-
const
|
|
322
|
+
const disk=diskCost(tree,freeBefore);
|
|
323
|
+
process.stdout.write(`worktree disk ${disk.text}\n`);
|
|
324
|
+
const record={slug:options.slug,branch,base,tree,total,steps,disk,finished:new Date().toISOString()};
|
|
311
325
|
mkdirSync(join(tree,'tmp'),{recursive:true});
|
|
312
326
|
writeFileSync(join(tree,'tmp/worktree-setup.json'),`${JSON.stringify(record,null,2)}\n`);
|
|
313
327
|
const lane=/^[a-z][a-z0-9_-]*$/u.test(env.WS_LANE_NAME??'')?String(env.WS_LANE_NAME):'';
|
|
314
328
|
if(lane!==''){
|
|
315
329
|
const file=resolve(env.WS_LANE_RECEIPTS??join(homedir(),'.cache/wildshard/lane-receipts.log'));
|
|
316
|
-
try{mkdirSync(dirname(file),{recursive:true});appendFileSync(file,`${new Date().toISOString().slice(11,16)} UTC ${lane} worktree new ${basename(canonical)}/${relative} on ${branch} from ${base.slice(0,10)} in ${total.toFixed(1)} s (${steps.map(row=>`${row.step} ${row.seconds.toFixed(1)}`).join(', ')})\n`);}
|
|
330
|
+
try{mkdirSync(dirname(file),{recursive:true});appendFileSync(file,`${new Date().toISOString().slice(11,16)} UTC ${lane} worktree new ${basename(canonical)}/${relative} on ${branch} from ${base.slice(0,10)} in ${total.toFixed(1)} s (${steps.map(row=>`${row.step} ${row.seconds.toFixed(1)}`).join(', ')}); ${disk.text}\n`);}
|
|
317
331
|
catch(error){process.stderr.write(`worktree receipt unavailable: ${String(error)}\n`);}
|
|
318
332
|
}
|
|
319
333
|
const name=lane===''?'<lane>':lane;
|
package/src/.oxlintrc.json
CHANGED
|
@@ -1,190 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
"unicorn",
|
|
6
|
-
"oxc",
|
|
7
|
-
"import",
|
|
8
|
-
"promise",
|
|
9
|
-
"node",
|
|
10
|
-
"react",
|
|
11
|
-
"react-perf",
|
|
12
|
-
"jsx-a11y"
|
|
13
|
-
],
|
|
14
|
-
// Strictest of greenroom (every category denied) and wildshard-singleplayer
|
|
15
|
-
// (these options, and import/no-nodejs-modules outside Node-side folders).
|
|
16
|
-
"options": {
|
|
17
|
-
"typeAware": true,
|
|
18
|
-
"denyWarnings": true,
|
|
19
|
-
"reportUnusedDisableDirectives": "error"
|
|
20
|
-
},
|
|
21
|
-
"categories": {
|
|
22
|
-
"correctness": "deny",
|
|
23
|
-
"suspicious": "deny",
|
|
24
|
-
"pedantic": "deny",
|
|
25
|
-
"perf": "deny",
|
|
26
|
-
"style": "deny",
|
|
27
|
-
"restriction": "deny",
|
|
28
|
-
"nursery": "deny"
|
|
29
|
-
},
|
|
2
|
+
"$schema": "../node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"extends": ["../kit/.oxlintrc.json"],
|
|
4
|
+
// oxlint does not inherit ignorePatterns through extends (K11, J329).
|
|
30
5
|
"ignorePatterns": [
|
|
31
|
-
// Plain-JS repo scripts, outside the TS project; covered by
|
|
32
|
-
// `pnpm test:hooks` instead. (.githooks/ sits outside src/.)
|
|
33
6
|
"scripts/**",
|
|
34
7
|
"dist/**",
|
|
35
|
-
"node_modules/**",
|
|
36
8
|
"test-results/**",
|
|
37
9
|
"playwright-report/**"
|
|
38
|
-
],
|
|
39
|
-
"rules": {
|
|
40
|
-
"typescript/explicit-function-return-type": [
|
|
41
|
-
"deny",
|
|
42
|
-
{
|
|
43
|
-
"allowExpressions": false,
|
|
44
|
-
"allowTypedFunctionExpressions": false,
|
|
45
|
-
"allowHigherOrderFunctions": false,
|
|
46
|
-
"allowDirectConstAssertionInArrowFunctions": false,
|
|
47
|
-
"allowConciseArrowFunctionExpressionsStartingWithVoid": false,
|
|
48
|
-
"allowFunctionsWithoutTypeParameters": false,
|
|
49
|
-
"allowIIFEs": false
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"typescript/explicit-module-boundary-types": [
|
|
53
|
-
"deny",
|
|
54
|
-
{
|
|
55
|
-
"allowArgumentsExplicitlyTypedAsAny": false,
|
|
56
|
-
"allowDirectConstAssertionInArrowFunctions": false,
|
|
57
|
-
"allowHigherOrderFunctions": false,
|
|
58
|
-
"allowTypedFunctionExpressions": false
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
"typescript/no-floating-promises": [
|
|
62
|
-
"deny",
|
|
63
|
-
{
|
|
64
|
-
"allowForKnownSafeCalls": [
|
|
65
|
-
{
|
|
66
|
-
"from": "package",
|
|
67
|
-
"package": "node:test",
|
|
68
|
-
"name": ["describe", "it", "suite", "test"]
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
"typescript/prefer-readonly-parameter-types": [
|
|
74
|
-
"deny",
|
|
75
|
-
{
|
|
76
|
-
"treatMethodsAsReadonly": true,
|
|
77
|
-
// Framework objects that are mutable by design and only ever passed in.
|
|
78
|
-
"allow": [
|
|
79
|
-
{ "from": "package", "package": "hono", "name": "Context" },
|
|
80
|
-
{ "from": "package", "package": "node:test", "name": "TestContext" },
|
|
81
|
-
{
|
|
82
|
-
"from": "package",
|
|
83
|
-
"package": "http",
|
|
84
|
-
"name": ["IncomingMessage", "ServerResponse"]
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
// A test drives one page through its own handle (src/e2e/smoke/).
|
|
88
|
-
"from": "package",
|
|
89
|
-
"package": "playwright-core",
|
|
90
|
-
"name": ["Page", "Route", "ConsoleMessage"]
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"from": "package",
|
|
94
|
-
"package": "playwright",
|
|
95
|
-
"name": [
|
|
96
|
-
"PlaywrightTestArgs",
|
|
97
|
-
"PlaywrightTestOptions",
|
|
98
|
-
"PlaywrightWorkerArgs",
|
|
99
|
-
"PlaywrightWorkerOptions"
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
],
|
|
105
|
-
"eslint/func-style": [
|
|
106
|
-
"deny",
|
|
107
|
-
"declaration",
|
|
108
|
-
{ "allowArrowFunctions": true }
|
|
109
|
-
],
|
|
110
|
-
"eslint/no-duplicate-imports": [
|
|
111
|
-
"deny",
|
|
112
|
-
{ "allowSeparateTypeImports": true }
|
|
113
|
-
],
|
|
114
|
-
// `return await` everywhere keeps stack traces and squares require-await with promise-function-async.
|
|
115
|
-
"typescript/return-await": ["deny", "always"],
|
|
116
|
-
// `void promise` is the marker no-floating-promises asks for.
|
|
117
|
-
"eslint/no-void": ["deny", { "allowAsStatement": true }],
|
|
118
|
-
// Continuation lines of a multi-line comment start mid-sentence.
|
|
119
|
-
"eslint/capitalized-comments": [
|
|
120
|
-
"deny",
|
|
121
|
-
"always",
|
|
122
|
-
{ "ignoreConsecutiveComments": true }
|
|
123
|
-
],
|
|
124
|
-
"react/jsx-filename-extension": ["deny", { "extensions": [".tsx"] }],
|
|
125
|
-
|
|
126
|
-
// Disabled: each contradicts another rule or fights the stack.
|
|
127
|
-
"eslint/sort-imports": "off", // oxfmt's sortImports owns import order; two sorters fight
|
|
128
|
-
"eslint/sort-keys": "off", // key order carries meaning (schemas, options); not autofixable
|
|
129
|
-
"eslint/one-var": "off", // one binding per declaration is how oxfmt lays code out
|
|
130
|
-
"eslint/no-undef": "off", // tsc reports undefined names; this misreads type-only globals
|
|
131
|
-
"eslint/no-undefined": "off", // contradicts unicorn/no-null; undefined is the absent value
|
|
132
|
-
"eslint/no-ternary": "off", // JSX conditional rendering needs it; no-nested-ternary stays on
|
|
133
|
-
"import/no-named-export": "off", // contradicts import/no-default-export; named exports win
|
|
134
|
-
"import/prefer-default-export": "off", // contradicts import/no-default-export
|
|
135
|
-
"import/no-relative-parent-imports": "off", // #subpath imports break the tsc build's extension rewrite
|
|
136
|
-
"node/no-top-level-await": "off", // contradicts unicorn/prefer-top-level-await; ESM-only, never require()d
|
|
137
|
-
"oxc/no-async-await": "off", // contradicts typescript/promise-function-async and require-await
|
|
138
|
-
"oxc/no-optional-chaining": "off", // contradicts typescript/prefer-optional-chain
|
|
139
|
-
"oxc/no-rest-spread-properties": "off", // ES5-compat ban; target is es2024
|
|
140
|
-
"react/react-in-jsx-scope": "off", // contradicts the react-jsx automatic runtime
|
|
141
|
-
"react/jsx-no-literals": "off" // i18n-only rule; no translations yet
|
|
142
|
-
},
|
|
143
|
-
"overrides": [
|
|
144
|
-
{
|
|
145
|
-
// Node programs may import node: modules; everything else (shared, client,
|
|
146
|
-
// web code) may not, as in wildshard-singleplayer.
|
|
147
|
-
"files": [
|
|
148
|
-
"cli/**",
|
|
149
|
-
"server/**",
|
|
150
|
-
"tools/**",
|
|
151
|
-
"test/**",
|
|
152
|
-
"e2e/**",
|
|
153
|
-
"cook/**",
|
|
154
|
-
"**/*.test.ts",
|
|
155
|
-
"*.config.ts",
|
|
156
|
-
"**/*.config.ts"
|
|
157
|
-
],
|
|
158
|
-
"rules": {
|
|
159
|
-
"import/no-nodejs-modules": "off"
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"files": ["*.config.ts", "**/*.config.ts"],
|
|
164
|
-
"rules": {
|
|
165
|
-
"import/no-default-export": "off", // playwright loads the default export
|
|
166
|
-
"node/no-process-env": "off" // config reads CI from the environment
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
// A journey spec is one story in test.step blocks, and it reads the page's own double-underscore globals.
|
|
171
|
-
"files": ["e2e/smoke/**"],
|
|
172
|
-
"rules": {
|
|
173
|
-
"eslint/max-statements": "off",
|
|
174
|
-
"eslint/max-lines-per-function": "off",
|
|
175
|
-
"eslint/no-underscore-dangle": [
|
|
176
|
-
"error",
|
|
177
|
-
{ "allow": ["__wildshard", "__workerClientRow", "__workerClient"] }
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"files": ["**/*.test.ts", "test/**", "e2e/**"],
|
|
183
|
-
"rules": {
|
|
184
|
-
"eslint/no-magic-numbers": "off", // assertions compare against literal expected values
|
|
185
|
-
"node/no-sync": "off", // test fixtures set up git repos synchronously
|
|
186
|
-
"node/no-process-env": "off" // the git helper isolates git from the developer's env
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
10
|
]
|
|
190
11
|
}
|
package/src/client/app/entry.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { inspectPreviousBoot, previousBootLine, previousBootLevel } from '@wilds
|
|
|
33
33
|
import { Scope } from '@wildshard/engine/app/scope';
|
|
34
34
|
import { bootRoute, onlineTitleFirst } from './bootRoute';
|
|
35
35
|
import { consumeTitleArrival, pendingTitleArrival } from '@wildshard/engine/boot/titleArrival';
|
|
36
|
-
import { lastEnd } from '@wildshard/engine/boot/lastEnd';
|
|
36
|
+
import { lastEnd, settleLastEnd } from '@wildshard/engine/boot/lastEnd';
|
|
37
37
|
import { installDropNotes, markDropStep, recordDrop, takeDrop } from '@wildshard/engine/boot/dropNotice';
|
|
38
38
|
import { consumeCrashResume, type CrashResume } from '@wildshard/engine/game/session/crashResume';
|
|
39
39
|
import { bootAwait, bootMark, bootTask, bootTiming, endBootOperation } from '@wildshard/engine/boot/timing';
|
|
@@ -110,6 +110,9 @@ function learnPlacedCellsOnce(): Promise<void> {
|
|
|
110
110
|
const late = new AbortController();
|
|
111
111
|
const read = (async (): Promise<void> => {
|
|
112
112
|
try {
|
|
113
|
+
// a page with no world and no placement stamp (preview, solo) reads none and imports nothing (PAGE-SIZE: the title waits here)
|
|
114
|
+
const stamps = globalThis as { __WS_WORLD__?: unknown; __WS_PLACEMENTS__?: unknown };
|
|
115
|
+
if (stamps.__WS_WORLD__ === undefined && stamps.__WS_PLACEMENTS__ === undefined) return;
|
|
113
116
|
const { learnPlacedCells, placementsOf } = await import('@wildshard/engine/game/grid/placedCells');
|
|
114
117
|
const url = placementsOf(globalThis as { __WS_WORLD__?: unknown; __WS_PLACEMENTS__?: unknown });
|
|
115
118
|
if (url === null || late.signal.aborted) return;
|
|
@@ -122,6 +125,8 @@ function learnPlacedCellsOnce(): Promise<void> {
|
|
|
122
125
|
return Promise.race([read, deadline]);
|
|
123
126
|
}
|
|
124
127
|
async function enterPage(): Promise<unknown> {
|
|
128
|
+
// S20: a crash read off another tab's live beat is no crash; asked now, answered (at most 500 ms) before the title reads it
|
|
129
|
+
const settled = settleLastEnd();
|
|
125
130
|
await placedCells;
|
|
126
131
|
const requested = search.get('chunk');
|
|
127
132
|
// SA36: a `/slug/<slug>` link opens that one shard's page; its PLAY leaves for `/?chunk=<slug>`, so a world never boots here.
|
|
@@ -135,6 +140,7 @@ async function enterPage(): Promise<unknown> {
|
|
|
135
140
|
return showPageTitle(UNLISTED);
|
|
136
141
|
}
|
|
137
142
|
await waitFor('Startup stylesheets', waitForLoadingStyles(entryScope), 'file');
|
|
143
|
+
await settled;
|
|
138
144
|
const { consumeGridRecovery, gridRecoveryRefused, pageGridRecovery, pendingGridEntry } = await bootTask('app:page-entry-import', () => import('@wildshard/engine/game/grid/pageEntry'));
|
|
139
145
|
// QA row 16 (GO1): an online level seats a body the world sees, so only a tap enters one. Crash resume is the solo build's.
|
|
140
146
|
const online = (globalThis as { __WS_WORLD__?: unknown }).__WS_WORLD__ !== undefined;
|
|
@@ -243,7 +249,8 @@ async function enterPage(): Promise<unknown> {
|
|
|
243
249
|
})();
|
|
244
250
|
}
|
|
245
251
|
async function showPageTitle(refusal = ''): Promise<void> {
|
|
246
|
-
|
|
252
|
+
// S20: the title's ended note reads lastEnd(), settled (the imports take longer than the lock query)
|
|
253
|
+
const [{ showStartTitle }, { buildTitleMenu, installGridTitle }, { travel }] = await Promise.all([import('@wildshard/engine/ui/StartTitle'), import('@wildshard/engine/game/mainMenu'), import('@wildshard/engine/game/travel/travel'), settleLastEnd()]);
|
|
247
254
|
// SF21a: a tap or validated recovery selects a grid; unrecorded process loss returns to title
|
|
248
255
|
const grid = installGridTitle();
|
|
249
256
|
// the composition root wires the game's main menu (over its shard deck) into the engine's title (E405)
|
|
@@ -274,6 +281,7 @@ async function showPageTitle(refusal = ''): Promise<void> {
|
|
|
274
281
|
*/
|
|
275
282
|
async function showSlugPage(slug: string): Promise<void> {
|
|
276
283
|
document.documentElement.classList.add('title-first');
|
|
284
|
+
await settleLastEnd(); // S20: its ended note reads lastEnd()
|
|
277
285
|
const manifest = findTitleManifest(slug);
|
|
278
286
|
// the page's query (`?sw=0`, `?tier=`, …) rides along to `/`, as a Shard select tap keeps it
|
|
279
287
|
const home = (): URL => new URL(`/${location.search}`, location.origin);
|
|
@@ -5,7 +5,7 @@ import { installGltfKtx2 } from '../core/ktx2';
|
|
|
5
5
|
import { pageScope } from '../../../shared/engine/app/resources';
|
|
6
6
|
import { waitFor } from '../../../shared/engine/boot/waits';
|
|
7
7
|
import { buildYield, WORK_SLICE_MS, workSlice, type WorkSlice } from '../../../shared/engine/core/workSlice';
|
|
8
|
-
import { buildHeld, frameBudgetSpent, frameDue, presenting } from '../../../shared/engine/core/framePacing';
|
|
8
|
+
import { buildHeld, buildUrgent, frameBudgetSpent, frameDue, presenting } from '../../../shared/engine/core/framePacing';
|
|
9
9
|
|
|
10
10
|
// FileLoader starts every network read immediately. Only the parser's temporary
|
|
11
11
|
// meshopt/image/geometry allocations share this page-wide decode slot.
|
|
@@ -38,7 +38,7 @@ class BoundedRigLoader extends GLTFLoader implements RigLoader {
|
|
|
38
38
|
// The previous read/consumer can span drawn frames. Its wall clock
|
|
39
39
|
// cannot charge that wait to this parse's current live CPU budget.
|
|
40
40
|
const pause = presenting()
|
|
41
|
-
? (buildHeld() || !frameDue()) && !frameBudgetSpent(WORK_SLICE_MS) ? undefined : buildYield(pageScope)
|
|
41
|
+
? (buildHeld() || buildUrgent() || !frameDue()) && !frameBudgetSpent(WORK_SLICE_MS) ? undefined : buildYield(pageScope)
|
|
42
42
|
: (decodeSlice ??= workSlice(undefined, pageScope)).check();
|
|
43
43
|
await waitFor('GLTF decode pacing', Promise.resolve(pause), 'work');
|
|
44
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assetCacheName } from '../pwa/cacheNames';
|
|
2
2
|
|
|
3
3
|
/** Publish a complete immutable native response after an uncontrolled read.
|
|
4
4
|
* No metadata owner or protocol: the next worker reads the same absolute URL.
|
|
@@ -10,7 +10,7 @@ export async function publishBootResponse(path: string, response: Response): Pro
|
|
|
10
10
|
const url = new URL(path, location.href);
|
|
11
11
|
if (url.origin !== location.origin || url.searchParams.has('sw')
|
|
12
12
|
|| !(/-[a-f0-9]{8,64}\.[a-z0-9]+$/u.test(url.pathname) || /^[a-f0-9]{8,64}$/u.test(url.searchParams.get('v') ?? ''))) return;
|
|
13
|
-
await (await caches.open(
|
|
13
|
+
await (await caches.open(assetCacheName())).put(url.href, response);
|
|
14
14
|
} catch { /* Quota, disabled storage and publication failure keep the native read usable. */ }
|
|
15
15
|
finally { void response.body?.cancel().catch(() => undefined); }
|
|
16
16
|
}
|
|
@@ -2,7 +2,7 @@ import { pageScope } from '../../../shared/engine/app/resources';
|
|
|
2
2
|
import { saveStorage } from '../saves/slots';
|
|
3
3
|
/** A small durable breadcrumb for an enabled level boot. A terminated WebContent process cannot run a final handler. */
|
|
4
4
|
import { deliverBrowserError, flushScreenReports, screenReportsEnabled } from '../telemetry/browserErrors';
|
|
5
|
-
import { reportStaleBuild } from '../telemetry/staleBuildReport';
|
|
5
|
+
import { reportSelfReload, reportStaleBuild, selfReloadClaim } from '../telemetry/staleBuildReport';
|
|
6
6
|
import type { ProgressView } from './plan';
|
|
7
7
|
import { markDropStep } from './dropNotice';
|
|
8
8
|
|
|
@@ -49,7 +49,8 @@ export interface BootTrace {
|
|
|
49
49
|
bootTraceActive: () => boolean;
|
|
50
50
|
previousBootLevel: () => string;
|
|
51
51
|
flushBootReports: () => Promise<void>;
|
|
52
|
-
|
|
52
|
+
/** `markedReload`: the page before marked its reload (lastEnd.ts), so a self-reload claim is never index.html's (S18) */
|
|
53
|
+
inspectPreviousBoot: (markedReload?: boolean) => void;
|
|
53
54
|
previousBootLine: () => string;
|
|
54
55
|
bootDiagnostic: () => Record<string, unknown>;
|
|
55
56
|
bootDiagnosticJson: () => string;
|
|
@@ -81,6 +82,8 @@ export function createBootTrace(transports: BootTraceTransports = PAGE_TRANSPORT
|
|
|
81
82
|
interface PendingReport { record: BootRecord; reason: string; inbox: boolean; sentry: boolean }
|
|
82
83
|
let flushing = false;
|
|
83
84
|
let retryListener = false;
|
|
85
|
+
/** S18: index.html's self-reload claim as this page found it, and whether the page before marked its reload */
|
|
86
|
+
let selfReload: { claim: string | null; marked: boolean } | undefined;
|
|
84
87
|
|
|
85
88
|
function reports(): PendingReport[] {
|
|
86
89
|
try {
|
|
@@ -181,7 +184,12 @@ export function createBootTrace(transports: BootTraceTransports = PAGE_TRANSPORT
|
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
/** Called by lastEnd on every new document, before its own boot can replace the old record. */
|
|
184
|
-
function inspectPreviousBoot(): void {
|
|
187
|
+
function inspectPreviousBoot(markedReload = false): void {
|
|
188
|
+
// S18: the claim, read before an online settle clears it; lastEnd and entry.ts both call this, one report a page
|
|
189
|
+
const firstCall = selfReload === undefined;
|
|
190
|
+
selfReload ??= { claim: selfReloadClaim(), marked: false };
|
|
191
|
+
if (markedReload) selfReload.marked = true;
|
|
192
|
+
const self = selfReload;
|
|
185
193
|
if (!retryListener && typeof window !== 'undefined') {
|
|
186
194
|
retryListener = true;
|
|
187
195
|
pageScope.listen(window, 'online', () => { void flushBootReports(); });
|
|
@@ -209,7 +217,7 @@ export function createBootTrace(transports: BootTraceTransports = PAGE_TRANSPORT
|
|
|
209
217
|
// SENTRY-TRIAGE S13: an error screen an earlier page opened and could not deliver goes now, off the boot's hot path (title too).
|
|
210
218
|
// STALE-BUILD SB6: a stale-build screen an earlier page showed (index.html's note) joins the outbox first.
|
|
211
219
|
// No DSN (dev, tests): nothing can be sent, so no timer joins the page's own (the sw tests count them).
|
|
212
|
-
if (typeof window !== 'undefined' && screenReportsEnabled()) pageScope.timeout(8000, () => { reportStaleBuild(); flushScreenReports(); });
|
|
220
|
+
if (typeof window !== 'undefined' && screenReportsEnabled()) pageScope.timeout(8000, () => { reportStaleBuild(); if (firstCall) reportSelfReload(() => (self.marked ? null : self.claim)); flushScreenReports(); });
|
|
213
221
|
}
|
|
214
222
|
|
|
215
223
|
/** Shown in the loader and the Loading & memory Debug row after a restart. */
|
|
@@ -5,6 +5,7 @@ import { beginLoadingWait, finishLoadingWait } from '../../../shared/engine/boot
|
|
|
5
5
|
import { markReload, type ReloadReason } from './lastEnd';
|
|
6
6
|
import { leaveAfterPaint } from './leaveAfterPaint';
|
|
7
7
|
import { createChunkRecovery, reloadIntoNewerBuild, type ChunkRecoveryPorts } from './chunkRecovery';
|
|
8
|
+
import { captureBrowserError, engineScreenTags } from '../telemetry/browserErrors';
|
|
8
9
|
|
|
9
10
|
declare const __BUILD_ID__: string;
|
|
10
11
|
function bootSelfReloadClaimed(): boolean {
|
|
@@ -104,6 +105,9 @@ export async function reloadIfStaleBuild(): Promise<boolean> {
|
|
|
104
105
|
if (store.getItem('boot.staleBuild') === __BUILD_ID__) return false;
|
|
105
106
|
store.setItem('boot.staleBuild', __BUILD_ID__);
|
|
106
107
|
} catch { return false; }
|
|
108
|
+
// SENTRY-TRIAGE S18: the cover is a screen of a fault; the outbox keeps the report across the reload below
|
|
109
|
+
try { captureBrowserError(new Error(`stale build ${__BUILD_ID__}: its files are gone; the server runs ${live}`), engineScreenTags('stale-reload', 'chunk-recovery', 'running', { live })); }
|
|
110
|
+
catch { /* a report never holds the reload */ }
|
|
107
111
|
const cover = showReloadingSoon('This build is out of date · getting the new one');
|
|
108
112
|
void leavePastWorker('stale build: its files are gone from the server', cover);
|
|
109
113
|
return true;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { saveStorage,jsonSlot } from '../saves/slots';
|
|
2
2
|
import { contentBase } from './contentBase';
|
|
3
|
+
import { isForeign, pageCacheChannel, PRODUCTION_MARK } from '../pwa/cacheNames';
|
|
3
4
|
// oxlint-disable-next-line import/no-empty-named-blocks, unicorn/require-module-specifiers -- Its ambient Window type is the point.
|
|
4
5
|
import type {} from './shardPrefetch'; // Window.__ws_prefetch, for a program that reaches this file alone.
|
|
5
6
|
/**
|
|
@@ -75,11 +76,13 @@ export async function clearDownloads(): Promise<ClearReport> {
|
|
|
75
76
|
workers = done.filter(Boolean).length;
|
|
76
77
|
} catch { /* no worker API here: nothing registered */ }
|
|
77
78
|
}
|
|
78
|
-
// 3. every cache; a put that was already under way can re-create one, so look again until none
|
|
79
|
+
// 3. every cache of this page's channel; a put that was already under way can re-create one, so look again until none
|
|
80
|
+
// is left. OFFLINE OF12: another channel's caches on this origin (a local proof serving two channels) are left alone.
|
|
79
81
|
let deleted = 0;
|
|
80
82
|
if (typeof caches !== 'undefined') {
|
|
83
|
+
const channel = pageCacheChannel(), productionHere = await caches.has(PRODUCTION_MARK);
|
|
81
84
|
for (;;) {
|
|
82
|
-
const keys = await caches.keys();
|
|
85
|
+
const keys = (await caches.keys()).filter(key => !isForeign(key, channel, productionHere));
|
|
83
86
|
if (keys.length === 0) break;
|
|
84
87
|
let removed = false;
|
|
85
88
|
for (const k of keys) if (await caches.delete(k)) { deleted++; removed = true; }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Scope } from '../../../shared/engine/app/scope';
|
|
2
|
+
import { captureBrowserError, engineScreenTags } from '../telemetry/browserErrors';
|
|
2
3
|
import { beginLoadingWait, finishLoadingWait } from '../../../shared/engine/boot/loadingWaits';
|
|
3
4
|
import { currentLoadingTimeline } from '../../../shared/engine/boot/timeline';
|
|
4
5
|
import { bootProgress } from '../../../shared/engine/boot/timing';
|
|
@@ -97,6 +98,15 @@ function shellRetry(scope: Scope, error: ContentReadError, retry: () => void): v
|
|
|
97
98
|
button.hidden = false;
|
|
98
99
|
scope.listen(button, 'click', retry);
|
|
99
100
|
}
|
|
101
|
+
/** pages whose card has offered RETRY once already: RETRY rounds while still offline must not fill the screen outbox (8 kept) */
|
|
102
|
+
const stallReported = new WeakSet<Document>();
|
|
103
|
+
/** SENTRY-TRIAGE S18: the card's RETRY is a screen of a fault; its first offer on this page reports, once, at warning level */
|
|
104
|
+
function reportStall(target: Document, error: ContentReadError, step: string | null): void {
|
|
105
|
+
if (stallReported.has(target)) return;
|
|
106
|
+
stallReported.add(target);
|
|
107
|
+
try { captureBrowserError(error, engineScreenTags('loading-stall', 'content-read', step ?? 'loading', { url: error.url })); }
|
|
108
|
+
catch { /* a report never holds the retry */ }
|
|
109
|
+
}
|
|
100
110
|
async function retryFromCard(error: ContentReadError, signal?: AbortSignal): Promise<void> {
|
|
101
111
|
if (typeof document === 'undefined') throw error;
|
|
102
112
|
const target = document, timeline = currentLoadingTimeline(), scope = new Scope('content-read-button');
|
|
@@ -109,6 +119,7 @@ async function retryFromCard(error: ContentReadError, signal?: AbortSignal): Pro
|
|
|
109
119
|
if (signal?.aborted === true) { reject(abortReason(signal)); return; }
|
|
110
120
|
if (signal !== undefined) scope.listen(signal, 'abort', () => { reject(abortReason(signal)); }, { once: true });
|
|
111
121
|
resume = resolve; pending.add(resolve);
|
|
122
|
+
reportStall(target, error, timeline?.snapshot().current ?? null);
|
|
112
123
|
id = beginLoadingWait(error.message, { kind: 'file', resource: error.url,
|
|
113
124
|
owner: timeline?.waitOwner ?? null, step: timeline?.snapshot().current ?? null,
|
|
114
125
|
retry: () => {for (const retry of pending) retry();}, retryNavigation: false });
|
|
@@ -135,9 +135,11 @@ let resolving = false;
|
|
|
135
135
|
/** A phone-tier GPU that can't sample raw ASTC: absent, or read wrong by the probe (the iOS Simulator has the extension and
|
|
136
136
|
* zeroes sRGB mips). No verdict (no page, or a measurement pin) changes nothing. The transcoder reads this same probe. */
|
|
137
137
|
const noRawAstc = (probe: Ktx2Probe): boolean => probe.ran && probe.families.astc !== true;
|
|
138
|
-
/** S4: an overlay's raw ASTC 6×6 files have no transcode, so a phone-tier GPU that can't sample ASTC loads images.
|
|
138
|
+
/** S4: an overlay's raw ASTC 6×6 files have no transcode, so a phone-tier GPU that can't sample ASTC loads images.
|
|
139
|
+
* S12d: the cook's phone files (`<name>.t<size>-<hash8>.<ext>`) are 6×6 too, and replace the hand-made overlay. */
|
|
140
|
+
const RAW_ASTC = /\/astc6\/|\.t[0-9]+-[a-f0-9]{8}\.(?:ktx2|glb)$/u;
|
|
139
141
|
export function rawAstcVeto(probe: Ktx2Probe): string | null {
|
|
140
|
-
if (TIER !== 'phone' || !noRawAstc(probe) || ![...registered.phone].some(url =>
|
|
142
|
+
if (TIER !== 'phone' || !noRawAstc(probe) || ![...registered.phone].some(url => RAW_ASTC.test(url))) return null;
|
|
141
143
|
return 'this table names raw ASTC 6×6 and the GPU has no ASTC';
|
|
142
144
|
}
|
|
143
145
|
/** S4: which tier's splat layers this device draws. A phone's are raw ASTC 6×6, so a phone that can't sample ASTC draws the
|