@wildshard/engine 0.1.22 → 0.1.24
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 +15 -0
- package/index.html +17 -4
- package/lint/engine-sides.json +9 -0
- package/lint/sim-players.json +2 -13
- package/package.json +36 -3
- package/scripts/apfs-clone.mjs +5 -2
- package/scripts/app-build/catalogue.ts +39 -8
- package/scripts/app-build/serviceWorker.ts +4 -1
- package/scripts/app-build/splitOutput.mjs +33 -11
- package/scripts/app-build/titlePreloads.mjs +8 -5
- package/scripts/bake-road-surfaces.entry.ts +18 -0
- package/scripts/bake-road-surfaces.mjs +44 -0
- package/scripts/changelog.mjs +2 -1
- package/scripts/ci-pack.mjs +3 -3
- package/scripts/engine-ci-shard.mjs +11 -0
- package/scripts/fight-page-census.mjs +131 -0
- package/scripts/goldens/board.py +44 -11
- package/scripts/goldens/capture.mjs +18 -6
- package/scripts/goldens/native-residency.d.mts +2 -0
- package/scripts/goldens/native-residency.mjs +31 -4
- package/scripts/grid-road-lag.mjs +209 -0
- package/scripts/keep-copy.mjs +172 -0
- package/scripts/land.d.mts +4 -1
- package/scripts/land.mjs +121 -9
- package/scripts/lane-live.mjs +136 -0
- package/scripts/leftovers-report.mjs +47 -0
- package/scripts/loading-card-proof.mjs +42 -9
- package/scripts/loading-flow/benchmax.mjs +59 -7
- package/scripts/loading-flow/stalls.d.mts +2 -0
- package/scripts/loading-flow/stalls.mjs +13 -0
- package/scripts/map-hash.mjs +1 -1
- package/scripts/mmo-bots.mjs +5 -3
- package/scripts/mmo-grid-proof.mjs +74 -0
- package/scripts/mmo-seat-proof.mjs +43 -0
- package/scripts/nightly-heads.ts +13 -13
- package/scripts/nightly-model.ts +26 -12
- package/scripts/nightly-tag.mjs +2 -4
- package/scripts/nightly.proof.ts +18 -5
- package/scripts/nightly.ts +13 -8
- package/scripts/no-astc-boot.mjs +77 -0
- package/scripts/page-release/content.mjs +19 -10
- package/scripts/page-release/flow.d.mts +3 -2
- package/scripts/page-release/flow.mjs +31 -21
- package/scripts/page-release/packs.d.mts +5 -0
- package/scripts/page-release/packs.mjs +13 -3
- package/scripts/page-release/preview.d.mts +2 -0
- package/scripts/page-release/preview.mjs +74 -0
- package/scripts/page-release.mjs +13 -5
- package/scripts/physics-route.json +6 -6
- package/scripts/pins-reuse.mjs +1 -0
- package/scripts/pins-staging.ts +54 -0
- package/scripts/pins.ts +5 -0
- package/scripts/ring3.proof.ts +71 -0
- package/scripts/ring3.ts +100 -0
- package/scripts/road-drive-proof.mjs +269 -0
- package/scripts/road-memory-probe.mjs +129 -0
- package/scripts/scratch-dir.mjs +33 -14
- package/scripts/scratch-sweep.mjs +15 -23
- package/scripts/server-release/github.mjs +59 -26
- package/scripts/server-release/items.d.mts +7 -0
- package/scripts/server-release/items.mjs +28 -0
- package/scripts/server-release/publish.mjs +24 -2
- package/scripts/server-release/sign.mjs +8 -4
- package/scripts/side-parity.mjs +1 -1
- package/scripts/test-products.json +1 -0
- package/scripts/test_prebuilt_output.py +3 -1
- package/scripts/tsconfig.json +2 -0
- package/scripts/turn-in-shots.mjs +83 -0
- package/scripts/vitest-bench-observe-proof.py +168 -0
- package/scripts/vitest-bench.py +122 -77
- package/scripts/vitest-ci-files.ts +5 -1
- package/scripts/vps/rebuild.sh +3 -1
- package/scripts/vps/wildshard-config +106 -1
- package/scripts/warm-native-chrome.mjs +9 -3
- package/scripts/worker-client-fights.mjs +9 -3
- package/scripts/worktree-reap.mjs +36 -140
- package/scripts/worktree.mjs +92 -12
- package/scripts/zone-gate-proof.mjs +93 -0
- package/src/client/engine/audio/audioLog.ts +7 -2
- package/src/client/engine/boot/diagnostics.ts +69 -1
- package/src/client/engine/boot/sw.ts +3 -1
- package/src/client/engine/core/ktx2.ts +33 -10
- package/src/client/engine/core/ktx2Zstd.ts +2 -1
- package/src/client/engine/models/place.ts +7 -5
- package/src/client/engine/pwa/sw.js +83 -10
- package/src/client/engine/render/dataLook.ts +14 -7
- package/src/client/engine/render/lookLight.ts +64 -20
- package/src/client/engine/render/precompile.ts +6 -0
- package/src/client/engine/render/tiers.ts +9 -0
- package/src/client/engine/ui/Loading.ts +6 -8
- package/src/client/engine/ui/lookLightOption.ts +1 -1
- package/src/client/engine/ui/playerReload.ts +5 -5
- package/src/client/game/audio/cueDirector.ts +2 -1
- package/src/client/game/boot/bytes.generated.ts +4 -1
- package/src/client/game/boot/versions.generated.ts +8 -5
- package/src/client/game/boss/arenaRoom.ts +4 -3
- package/src/client/game/boss/roamingProjection.ts +1 -1
- package/src/client/game/devScene/hook.ts +1 -1
- package/src/client/game/devScene/liveLook.ts +1 -1
- package/src/client/game/grid/cellClip.ts +70 -6
- package/src/client/game/grid/dataCellKit.ts +9 -1
- package/src/client/game/grid/gateCard.css +9 -0
- package/src/client/game/grid/gateCard.ts +67 -0
- package/src/client/game/grid/live.ts +17 -3
- package/src/client/game/grid/liveSession.ts +15 -5
- package/src/client/game/grid/neighbourLife.ts +10 -1
- package/src/client/game/grid/neighbourPanels.ts +29 -2
- package/src/client/game/grid/pageEntry.ts +21 -0
- package/src/client/game/grid/products.ts +21 -7
- package/src/client/game/grid/regionalWorld.ts +5 -0
- package/src/client/game/grid/roadCompressedSurfaces.ts +69 -0
- package/src/client/game/grid/roadLook.ts +5 -73
- package/src/client/game/grid/roadLookPlatform.ts +11 -6
- package/src/client/game/grid/roadSurfaceMaps.ts +80 -0
- package/src/client/game/grid/roadTilePool.ts +4 -0
- package/src/client/game/grid/session.ts +58 -16
- package/src/client/game/grid/softWallLook.ts +6 -1
- package/src/client/game/plugin/ui.ts +3 -0
- package/src/client/game/population/signals.ts +1 -1
- package/src/client/game/quest/chapterDirector.ts +1 -0
- package/src/client/game/session/play.ts +3 -0
- package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
- package/src/client/game/shardfile/clientSource.ts +5 -2
- package/src/client/game/shardfile/clientWorker.ts +25 -8
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/runtimeProduct.ts +9 -5
- package/src/client/game/shardfile/slabLibrary.ts +37 -0
- package/src/client/game/shardfile/slabRanges.ts +145 -0
- package/src/client/game/shardfile/wirePage.ts +5 -2
- package/src/client/game/shardfile/worldSceneTextures.ts +15 -9
- package/src/client/host/online/shell.ts +2 -2
- package/src/client/host/standalone/shell.ts +4 -1
- package/src/cook/game/cookWorker.ts +8 -5
- package/src/cook/game/tierTextures.ts +5 -3
- package/src/server/engine/net/simWorld.ts +3 -4
- package/src/server/game/grid/cellHome.ts +58 -0
- package/src/server/game/grid/simulation.ts +32 -8
- package/src/server/game/plugin/mover.ts +18 -14
- package/src/server/game/plugin/simulation.ts +2 -0
- package/src/server/game/shardfile/dataRespawn.ts +47 -0
- package/src/server/game/shardfile/declaredKitItems.ts +31 -7
- package/src/server/host/bake/headlessWorker.ts +3 -3
- package/src/server/host/dedicated/cellWorker.ts +4 -2
- package/src/server/host/dedicated/main.ts +7 -4
- package/src/server/host/dedicated/packReader.ts +15 -2
- package/src/server/host/dedicated/playerStore.ts +1 -1
- package/src/server/host/headlessRuntime.ts +11 -6
- package/src/server/host/standalone/cellWorld.ts +20 -6
- package/src/server/host/standalone/gridServer.ts +20 -6
- package/src/server/host/standalone/roadWorld.ts +36 -0
- package/src/server/host/standalone/serverHost.ts +2 -2
- package/src/shared/engine/entities/AnimalSim.ts +10 -0
- package/src/shared/engine/physics/gridBorders.ts +15 -1
- package/src/shared/engine/physics/transferWalls.ts +9 -4
- package/src/shared/engine/sim/snapshot.ts +5 -5
- package/src/shared/game/grid/allocator.ts +8 -1
- package/src/shared/game/grid/gateCount.ts +27 -0
- package/src/shared/game/grid/zoneWalls.ts +64 -0
- package/src/shared/game/ledger.ts +13 -4
- package/src/shared/game/loot/platformCatalogue.ts +14 -0
- package/src/shared/game/quest/ledger.ts +3 -3
- package/src/shared/game/shardfile/items.ts +9 -1
- package/src/shared/game/strings.ts +2 -0
- package/src/shared/host/headlessJourney.ts +3 -3
- package/src/shared/host/headlessTape.ts +7 -6
- package/src/shared/host/releaseRows.ts +4 -1
- package/src/shared/host/standalone/harnessPlace.ts +4 -0
- package/src/test/engine/simState.ts +134 -0
- package/src/test/game/builtProduct.ts +6 -0
- package/src/test/game/headless/admittedProductCache.ts +61 -0
- package/src/test/game/headless/checkedReplayPipeline.ts +21 -0
- package/src/test/game/headless/nativeBounds.ts +27 -0
- package/src/test/game/headless/processUsage.ts +22 -0
- package/src/test/game/headless/productSession.ts +39 -0
- package/src/test/game/headless/ropeBodies.ts +60 -0
- package/src/test/game/headless/worker.ts +34 -0
- package/src/test/game/headlessNative.ts +114 -0
- package/src/test/game/headlessWorker.ts +43 -0
- package/src/test/tsconfig.game.json +3 -0
package/scripts/nightly-tag.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Optional promotion helper.
|
|
2
|
+
// Optional promotion helper. A nightly selects a release cut point; release.sh owns branches and tags.
|
|
3
3
|
// J167: require the downloaded exact-SHA green nightly verdict before any network/write.
|
|
4
4
|
// A commit that already has a version tag is left alone: an unchanged tree needs no second release.
|
|
5
5
|
import { execFileSync } from 'node:child_process';
|
|
@@ -25,8 +25,6 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
25
25
|
if (git('tag', '--points-at', 'HEAD').split('\n').some((tag) => /^v\d/u.test(tag))) console.log('This commit is already tagged');
|
|
26
26
|
else {
|
|
27
27
|
const tag = nextTag(git('tag', '--list', 'v*').split('\n'));
|
|
28
|
-
git('
|
|
29
|
-
git('push', 'origin', tag);
|
|
30
|
-
console.log(`Tagged ${tag}`);
|
|
28
|
+
console.log(`release.sh ${tag} --prepare --from ${git('rev-parse', 'HEAD')}`);
|
|
31
29
|
}
|
|
32
30
|
}
|
package/scripts/nightly.proof.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {join, resolve} from 'node:path';
|
|
|
7
7
|
import {browsers, partition, phases, plan, read, requireBuild, requireGreen, requireLatest, type HeadsReport, type Plan, type TestsReport, type Verdict} from './nightly-model.ts';
|
|
8
8
|
|
|
9
9
|
interface Execution {status: number | null; report: Verdict; summary: string}
|
|
10
|
-
interface Fixture {root: string; heads: HeadsReport[]; suite: TestsReport; expected: Plan;
|
|
10
|
+
interface Fixture {root: string; heads: HeadsReport[]; suite: TestsReport; suites: TestsReport[]; expected: Plan;
|
|
11
11
|
execute: (baseline?: string, env?: NodeJS.ProcessEnv) => Execution; write: (path: string, value: unknown) => void}
|
|
12
12
|
|
|
13
13
|
const cli = resolve('scripts/nightly.ts'), tagger = resolve('scripts/nightly-tag.mjs');
|
|
@@ -23,19 +23,23 @@ function fixture(run: (context: Fixture) => void): void {
|
|
|
23
23
|
const expected = plan(root);
|
|
24
24
|
const heads: HeadsReport[] = browsers.flatMap(browser => Array.from({length: 4}, (_, group) => ({...expected, kind: 'heads' as const, browser, group,
|
|
25
25
|
results: partition(expected.heads, group).map(head => ({slug: head.slug, hash: head.hash, phases: phases.map(name => ({name, ok: true}))}))})));
|
|
26
|
-
const suite: TestsReport = {...expected, kind: 'tests', exitCode: 0, kitExitCode: 0, totalTests: 1, files: [{path: 'test/journey.test.ts', ok: true, assertions: 1, skipped: 0}]};
|
|
26
|
+
const suite: TestsReport = {...expected, kind: 'tests', group: 0, groups: 2, exitCode: 0, kitExitCode: 0, totalTests: 1, files: [{path: 'test/journey.test.ts', ok: true, assertions: 1, skipped: 0}]};
|
|
27
|
+
const suites: TestsReport[] = [suite, {...suite, group: 1, files: [{path: 'test/ordinary.test.ts', ok: true, assertions: 1, skipped: 0}]}];
|
|
27
28
|
const execute = (baseline?: string, env: NodeJS.ProcessEnv = {}): Execution => {
|
|
29
|
+
rmSync(join(root, 'reports'), {recursive: true, force: true});
|
|
28
30
|
for (const report of heads) write(`reports/heads-${report.browser}-${report.group}.json`, report);
|
|
29
|
-
write(
|
|
31
|
+
for (const [index, report] of suites.entries()) write(`reports/tests-${index}.json`, report);
|
|
30
32
|
const child = spawnSync(process.execPath, [cli, 'report', join(root, 'reports'), ...(baseline === undefined ? [] : [baseline])], {cwd: root, encoding: 'utf8', env: {...process.env, ...env}});
|
|
31
33
|
return {status: child.status, report: read(join(root, 'reports/verdict.json')) as Verdict, summary: readFileSync(join(root, 'reports/summary.md'), 'utf8')};
|
|
32
34
|
};
|
|
33
|
-
run({root, heads, suite, expected, execute, write});
|
|
35
|
+
run({root, heads, suite, suites, expected, execute, write});
|
|
34
36
|
} finally {rmSync(root, {recursive: true, force: true});}
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
await test('complete real report files admit the exact commit, but never another commit or repeated row', () => fixture(({expected, execute}) => {
|
|
38
40
|
const result = execute(); assert.equal(result.status, 0); requireGreen(result.report, expected);
|
|
41
|
+
assert.throws(() => requireGreen({...result.report, version: 1}, expected), /J167/u);
|
|
42
|
+
assert.throws(() => requireGreen({...result.report, tests: result.report.tests.slice(0, 1)}, expected), /J167/u);
|
|
39
43
|
requireBuild(`${expected.sha.slice(0, 7)}-proof`, expected);
|
|
40
44
|
assert.throws(() => requireBuild('0000000-stale', expected), /stale/u);
|
|
41
45
|
assert.throws(() => requireGreen(result.report, {...expected, sha: 'wrong'}), /J167/u);
|
|
@@ -64,6 +68,15 @@ await test('ordinary suite skips retain existing policy while listed journeys mu
|
|
|
64
68
|
suite.files.push({path: 'test/ordinary-platform.test.ts', ok: true, assertions: 0, skipped: 1});
|
|
65
69
|
assert.equal(execute().status, 0);
|
|
66
70
|
}));
|
|
71
|
+
await test('missing, duplicate, malformed or overlapping suite partitions hold an otherwise green night', () => {
|
|
72
|
+
const mutations: ((suites: TestsReport[]) => void)[] = [suites => {suites.pop();}, suites => {suites[1].group = 0;}, suites => {suites[1].groups = 1;}, suites => {suites[1].files = [...suites[0].files];}, suites => {suites[1].files = [];}];
|
|
73
|
+
for (const mutate of mutations) fixture(({suites, execute, expected}) => {
|
|
74
|
+
mutate(suites);
|
|
75
|
+
const result = execute();
|
|
76
|
+
assert.equal(result.status, 1);
|
|
77
|
+
assert.throws(() => requireGreen(result.report, expected), /J167/u);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
67
80
|
await test('an empty artifact directory never produces green', () => fixture(({root}) => {
|
|
68
81
|
mkdirSync(join(root, 'empty'));
|
|
69
82
|
const result = spawnSync(process.execPath, [cli, 'report', join(root, 'empty')], {cwd: root, encoding: 'utf8'});
|
|
@@ -77,7 +90,7 @@ await test('a failed Actions job holds the tag even if every uploaded phase pass
|
|
|
77
90
|
}));
|
|
78
91
|
await test('prior nightly failures are compared by head hash, browser and phase', () => fixture(({heads, execute, root, write}) => {
|
|
79
92
|
heads[0].results[0].phases[0].ok = false;
|
|
80
|
-
const first = execute(); write('previous.json', first.report);
|
|
93
|
+
const first = execute(); write('previous.json', {...first.report, version: 1});
|
|
81
94
|
heads[0].results[0].phases[0].ok = true; heads[1].results[0].phases[1].ok = false;
|
|
82
95
|
const next = execute(join(root, 'previous.json'));
|
|
83
96
|
assert.equal(next.report.resolved.length, 1); assert.equal(next.report.newFailures.length, 1);
|
package/scripts/nightly.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {spawnSync} from 'node:child_process';
|
|
3
3
|
import {existsSync, mkdirSync, readdirSync, writeFileSync} from 'node:fs';
|
|
4
4
|
import {join, relative, resolve} from 'node:path';
|
|
5
|
-
import {browsers, groups, markdown, partition, plan, read, requirePublishedGreen, verdict, type Receipt, type TestsReport, type Verdict} from './nightly-model.ts';
|
|
5
|
+
import {browsers, groups, markdown, partition, plan, read, requirePublishedGreen, testGroups, verdict, type Receipt, type TestsReport, type Verdict} from './nightly-model.ts';
|
|
6
6
|
|
|
7
7
|
interface VitestResult {numTotalTests?: number; testResults?: {name: string; status: string; assertionResults?: {status: string}[]}[]}
|
|
8
8
|
|
|
@@ -13,24 +13,29 @@ if (command === 'plan') {
|
|
|
13
13
|
console.log(JSON.stringify({include: browsers.flatMap(browser => Array.from({length: groups}, (_, group) => ({browser, group,
|
|
14
14
|
os: browser === 'webkit' ? 'macos-15' : 'ubuntu-24.04', heads: partition(expected.heads, group).map(row => row.slug).join(',')})))}));
|
|
15
15
|
} else if (command === 'tests') {
|
|
16
|
+
const group = Number(process.env.NIGHTLY_TEST_GROUP ?? '-1');
|
|
17
|
+
if (!Number.isInteger(group) || group < 0 || group >= testGroups) throw new Error('Set NIGHTLY_TEST_GROUP to 0 or 1; the verdict requires both suite partitions');
|
|
16
18
|
mkdirSync(out, {recursive: true});
|
|
17
|
-
const json = join(out,
|
|
19
|
+
const json = join(out, `vitest-${group}.json`);
|
|
18
20
|
const kit = spawnSync('pnpm', ['test:kit'], {stdio: 'inherit', timeout: 120000});
|
|
19
|
-
//
|
|
21
|
+
// The two jobs cover the entire admitted suite once, including every slow
|
|
22
|
+
// Ring 2 entry. Keep each job's existing 25-minute process limit.
|
|
20
23
|
const child = spawnSync('python3', ['scripts/heavy-lane.py', 'full-test', '--', process.execPath, 'scripts/vitest-tmp.ts', 'run',
|
|
21
|
-
'--maxWorkers=2', '--reporter=default', '--reporter=json', `--outputFile.json=${json}`],
|
|
24
|
+
'--maxWorkers=2', `--shard=${group + 1}/${testGroups}`, '--reporter=default', '--reporter=json', `--outputFile.json=${json}`],
|
|
22
25
|
{stdio: 'inherit', timeout: 1500000, env: {...process.env, WS_FULL_SUITE: '1', WILDSHARD_RING: '2'}});
|
|
23
26
|
const raw: VitestResult = existsSync(json) ? (read(json) as VitestResult) : {};
|
|
24
27
|
const files = (raw.testResults ?? []).map(file => ({path: relative(process.cwd(), file.name).replaceAll('\\', '/'),
|
|
25
28
|
ok: file.status !== 'failed' && file.assertionResults?.every(row => row.status !== 'failed') === true,
|
|
26
29
|
assertions: file.assertionResults?.filter(row => row.status === 'passed').length ?? 0,
|
|
27
30
|
skipped: file.assertionResults?.filter(row => row.status !== 'passed' && row.status !== 'failed').length ?? 0}));
|
|
28
|
-
const report: TestsReport = {...expected, kind: 'tests', exitCode: child.status ?? 1, kitExitCode: kit.status ?? 1, totalTests: raw.numTotalTests ?? 0, files};
|
|
29
|
-
write(
|
|
30
|
-
|
|
31
|
+
const report: TestsReport = {...expected, kind: 'tests', group, groups: testGroups, exitCode: child.status ?? 1, kitExitCode: kit.status ?? 1, totalTests: raw.numTotalTests ?? 0, files};
|
|
32
|
+
write(`tests-${group}.json`, report);
|
|
33
|
+
// Listed journeys in either partition are checked together by report;
|
|
34
|
+
// a partition must still fail for any ordinary or listed test failure.
|
|
35
|
+
if (report.exitCode !== 0 || report.kitExitCode !== 0 || report.totalTests < 1 || files.some(file => !file.ok)) process.exitCode = 1;
|
|
31
36
|
} else if (command === 'report') {
|
|
32
37
|
mkdirSync(out, {recursive: true});
|
|
33
|
-
const receipts = readdirSync(out).filter(name => /^(heads-|tests
|
|
38
|
+
const receipts = readdirSync(out).filter(name => /^(heads-|tests[-.])/u.test(name) && name.endsWith('.json')).map(name => (read(join(out, name)) as Receipt));
|
|
34
39
|
const jobs = {plan: process.env.NIGHTLY_PLAN_RESULT, tests: process.env.NIGHTLY_TESTS_RESULT, heads: process.env.NIGHTLY_HEADS_RESULT};
|
|
35
40
|
const report = {...verdict(expected, receipts, baseline !== undefined && existsSync(baseline) ? (read(baseline) as Verdict) : undefined, jobs), run: process.env.GITHUB_RUN_ID ?? null};
|
|
36
41
|
write('verdict.json', report);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// EG-16 (meta docs/plans/test-coverage/ENGINE.md, TEST-COVERAGE row 32): the `--no-astc` boot. A phone with no ASTC draws (BUG-9).
|
|
3
|
+
// Chromium at the phone tier (an iPhone profile), with WEBGL_compressed_texture_astc hidden as capture.mjs --no-astc hides it (S4),
|
|
4
|
+
// enters a head with a phone set by its own URL and holds:
|
|
5
|
+
// hidden textures load as images, the reason names the raw-ASTC veto (src/client/engine/boot/gpuFiles.ts `rawAstcVeto`), no raw
|
|
6
|
+
// ASTC 6x6 file is read, the world is entered with frames running, the frame isn't black, and nothing fatal shows;
|
|
7
|
+
// shown the control: the same page with ASTC reads raw ASTC files, so the hidden pass proves a choice, not an empty table.
|
|
8
|
+
// BUG-9's fault, planted at the source (`rawAstcVeto` returning null), turns the hidden pass red: the page reads Pine's raw ASTC
|
|
9
|
+
// phone set on a GPU that can't sample it. A harness texture pin is no plant: the veto overrules a pin too.
|
|
10
|
+
// scripts/browser-lane.sh node scripts/no-astc-boot.mjs --base=http://127.0.0.1:4401/ [--slug=pine-hollow] [--out=tmp/no-astc]
|
|
11
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import { chromium, devices } from 'playwright';
|
|
14
|
+
import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
|
|
15
|
+
import { frameFailure, screenshotPixels } from './parity/black-frame.mjs';
|
|
16
|
+
|
|
17
|
+
/** @param {string} key @param {string} fallback */
|
|
18
|
+
const arg = (key, fallback) => process.argv.find(value => value.startsWith(`--${key}=`))?.slice(key.length + 3) ?? fallback;
|
|
19
|
+
const base = arg('base', ''), slug = arg('slug', 'pine-hollow'), out = arg('out', 'tmp/no-astc');
|
|
20
|
+
if (!/^http:\/\/(127\.0\.0\.1|localhost)(:\d+)?\/$/u.test(base)) throw new Error('Requires --base=<a local served build>/ (scripts/serve-build.sh)');
|
|
21
|
+
/** The cook's raw ASTC 6x6 files and the hand-made overlays (gpuFiles.ts RAW_ASTC). */
|
|
22
|
+
const RAW_ASTC = /\/astc6\/|\.t[0-9]+-[a-f0-9]{8}\.(?:ktx2|glb)$/u;
|
|
23
|
+
const hideAstc = () => {
|
|
24
|
+
const ext = 'WEBGL_compressed_texture_astc';
|
|
25
|
+
for (const gl of [WebGLRenderingContext, WebGL2RenderingContext]) {
|
|
26
|
+
const proto = gl.prototype, realExtension = Reflect.get(proto, 'getExtension'), realList = Reflect.get(proto, 'getSupportedExtensions');
|
|
27
|
+
proto.getExtension = function getExtension(name) { return name === ext ? null : Reflect.apply(realExtension, this, [name]); };
|
|
28
|
+
proto.getSupportedExtensions = function getSupportedExtensions() { return Reflect.apply(realList, this, [])?.filter(name => name !== ext) ?? null; };
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const angle = process.platform === 'darwin' ? 'metal' : 'swiftshader';
|
|
32
|
+
const browser = await chromium.launch({ args: [...KEYCHAIN_ARGS, '--mute-audio', '--ignore-gpu-blocklist', `--use-angle=${angle}`] });
|
|
33
|
+
const { defaultBrowserType: _engine, ...phone } = devices['iPhone 16 Pro'];
|
|
34
|
+
|
|
35
|
+
/** One boot of `slug` on a fresh phone; what it chose, read and drew. @param {boolean} astc */
|
|
36
|
+
async function boot(astc) {
|
|
37
|
+
const context = await browser.newContext(phone), page = await context.newPage();
|
|
38
|
+
/** @type {string[]} */ const raw = [];
|
|
39
|
+
/** @type {string[]} */ const fatal = [];
|
|
40
|
+
if (!astc) await context.addInitScript(hideAstc);
|
|
41
|
+
page.on('response', response => { const path = new URL(response.url()).pathname; if (RAW_ASTC.test(path)) raw.push(path); });
|
|
42
|
+
page.on('pageerror', error => { fatal.push(error.message.slice(0, 300)); });
|
|
43
|
+
page.on('console', line => { if (line.type() === 'error' || /\brefused\b/iu.test(line.text())) fatal.push(line.text().slice(0, 300)); });
|
|
44
|
+
try {
|
|
45
|
+
await page.goto(new URL(`?chunk=${slug}&skipintro&mute=1&nolock=1`, base).href, { waitUntil: 'load' });
|
|
46
|
+
const play = setInterval(() => { void page.locator('.ws-load-play').click({ timeout: 500 }).catch(() => undefined); }, 1000);
|
|
47
|
+
const entered = await page.waitForFunction(() => window.__wildshard?.world?.hud?.entered === true && document.querySelector('.ws-load') === null && window.__wildshard.world.game.frameGate(), undefined, { timeout: 180_000 })
|
|
48
|
+
.then(() => true, () => false);
|
|
49
|
+
clearInterval(play);
|
|
50
|
+
await page.waitForTimeout(4000);
|
|
51
|
+
const seen = await page.evaluate(() => {
|
|
52
|
+
const api = window.__wildshard, gl = document.createElement('canvas').getContext('webgl2');
|
|
53
|
+
return { textures: api?.textures?.() ?? null, astc: gl?.getExtension('WEBGL_compressed_texture_astc') !== null,
|
|
54
|
+
errors: [...document.querySelectorAll('#wserr,.ws-load-error,.ws-game-dev-alert,[data-boot-fatal]')].map(node => (node.textContent ?? '').slice(0, 200)) };
|
|
55
|
+
});
|
|
56
|
+
const shot = await page.screenshot();
|
|
57
|
+
mkdirSync(out, { recursive: true }); writeFileSync(join(out, `${slug}-${astc ? 'astc' : 'no-astc'}.png`), shot);
|
|
58
|
+
const pixels = await page.evaluate(screenshotPixels, Array.from(shot));
|
|
59
|
+
return { entered, ...seen, raw: raw.length, rawSample: raw.slice(0, 3), black: frameFailure(pixels), darkShare: Math.round(pixels.darkShare * 100) / 100, fatal: [...new Set([...fatal, ...seen.errors])].slice(0, 6) };
|
|
60
|
+
} finally { await context.close(); }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @type {string[]} */ const failures = [];
|
|
64
|
+
const hidden = await boot(false), shown = await boot(true);
|
|
65
|
+
await browser.close();
|
|
66
|
+
/** @param {boolean} ok @param {string} what */
|
|
67
|
+
const check = (ok, what) => { if (!ok) failures.push(what); };
|
|
68
|
+
check(!hidden.astc && shown.astc, 'the extension was not hidden on one page and shown on the other');
|
|
69
|
+
check(hidden.entered, 'no-ASTC: the world never opened');
|
|
70
|
+
check(hidden.textures?.mode === 'img' && /overruled: .*no ASTC/u.test(hidden.textures.why), `no-ASTC: textures are ${JSON.stringify(hidden.textures)}, not images by the raw-ASTC veto`);
|
|
71
|
+
check(hidden.raw === 0, `no-ASTC: read ${hidden.raw} raw ASTC files (${hidden.rawSample.join(', ')})`);
|
|
72
|
+
check(hidden.black === null, `no-ASTC: ${hidden.black}`);
|
|
73
|
+
check(hidden.fatal.length === 0, `no-ASTC: ${hidden.fatal.join(' | ')}`);
|
|
74
|
+
check(shown.entered && shown.raw > 0, `control: with ASTC the page read ${shown.raw} raw ASTC files, so ${slug} has no phone set to choose against`);
|
|
75
|
+
console.log(JSON.stringify({ test: 'no-astc-boot', slug, hidden, shown }, null, 1));
|
|
76
|
+
console.log(failures.length === 0 ? `no-astc-boot green: ${slug} draws on a phone with no ASTC` : `no-astc-boot RED:\n${failures.map(line => ` ${line}`).join('\n')}`);
|
|
77
|
+
process.exit(failures.length === 0 ? 0 : 1);
|
|
@@ -123,8 +123,17 @@ const mb = bytes => (bytes / 1e6).toFixed(1);
|
|
|
123
123
|
|
|
124
124
|
/** @template T @param {readonly T[]} items @param {number} width @param {(item: T) => Promise<void>} each */
|
|
125
125
|
async function pool(items, width, each) {
|
|
126
|
-
let next = 0;
|
|
127
|
-
|
|
126
|
+
let next = 0, failed = false;
|
|
127
|
+
/** @type {unknown} */ let failure;
|
|
128
|
+
await Promise.all(Array.from({length: Math.min(width, items.length)}, async () => {
|
|
129
|
+
while (!failed && next < items.length) {
|
|
130
|
+
const item = items[next++];
|
|
131
|
+
try { if (item !== undefined) await each(item); }
|
|
132
|
+
catch (error) { failed = true; failure = error; }
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
// Drain every already-started request before a retry can create another pool.
|
|
136
|
+
if (failed) throw failure;
|
|
128
137
|
}
|
|
129
138
|
|
|
130
139
|
/** A key read back: 200, the game's CORS, the decoded bytes. A 404 right after upload is retried (the CDN caches 404s
|
|
@@ -170,7 +179,7 @@ export async function publishContent({dir, store, scratch, origin = GAME_ORIGIN,
|
|
|
170
179
|
let wrong = 0;
|
|
171
180
|
// A present key is held only when it reads back with this file's bytes and the game's CORS; anything else (a wrong or
|
|
172
181
|
// short object left by an earlier run, say) is uploaded again over it. Set keys are content-named, so that is safe.
|
|
173
|
-
await pool(files,
|
|
182
|
+
await pool(files, 8, async file => {
|
|
174
183
|
const key = contentKey(set, file.path);
|
|
175
184
|
if (!await store.exists(key)) { missing.push(file); return; }
|
|
176
185
|
const read = await store.read(key, origin);
|
|
@@ -196,7 +205,7 @@ export async function publishContent({dir, store, scratch, origin = GAME_ORIGIN,
|
|
|
196
205
|
} catch (error) {
|
|
197
206
|
if (round >= 6) throw error;
|
|
198
207
|
/** @type {ContentFile[]} */ const still = [];
|
|
199
|
-
await pool(left,
|
|
208
|
+
await pool(left, 8, async file => { if (!await store.exists(contentKey(set, file.path))) still.push(file); });
|
|
200
209
|
log(`content ${set}: put failed (${error instanceof Error ? error.message : String(error)}); ${still.length} still missing, retrying`);
|
|
201
210
|
left = still.sort((a, b) => (a.path < b.path ? -1 : 1));
|
|
202
211
|
// The API answers 429 under load (seen on the first real run): back off longer each round.
|
|
@@ -204,7 +213,7 @@ export async function publishContent({dir, store, scratch, origin = GAME_ORIGIN,
|
|
|
204
213
|
}
|
|
205
214
|
}
|
|
206
215
|
let read = 0;
|
|
207
|
-
await pool(missing,
|
|
216
|
+
await pool(missing, 4, async file => {
|
|
208
217
|
await readBack(store, contentKey(set, file.path), file.decoded, origin, sleep);
|
|
209
218
|
if (++read % 1000 === 0) log(`content ${set}: ${read}/${missing.length} read back`);
|
|
210
219
|
});
|
|
@@ -244,7 +253,7 @@ export async function copyFromSets({set, missing, store, origin, log, sleep}) {
|
|
|
244
253
|
}
|
|
245
254
|
/** @type {ContentFile[]} */ const copied = [];
|
|
246
255
|
let failed = 0;
|
|
247
|
-
await pool(missing.filter(file => held.has(`${file.sha256}:${file.bytes}`)),
|
|
256
|
+
await pool(missing.filter(file => held.has(`${file.sha256}:${file.bytes}`)), 8, async file => {
|
|
248
257
|
const from = held.get(`${file.sha256}:${file.bytes}`) ?? '';
|
|
249
258
|
try { await copy(from, contentKey(set, file.path), contentHeaders(file.path), file.bytes); copied.push(file); }
|
|
250
259
|
catch (error) { failed++; log(`content ${set}: copy ${from} failed (${error instanceof Error ? error.message : String(error)}); uploading it`); }
|
|
@@ -262,14 +271,14 @@ export async function copyFromSets({set, missing, store, origin, log, sleep}) {
|
|
|
262
271
|
* PZ6: R2's S3 API on the packs bucket, for the store's `sets` and `copy`. Credentials from the environment
|
|
263
272
|
* (R2_ACCOUNT_ID, R2_PACKS_ACCESS_KEY_ID, R2_PACKS_SECRET_ACCESS_KEY: server-release's bucket-scoped keys), else none.
|
|
264
273
|
* @param {NodeJS.ProcessEnv} env
|
|
265
|
-
* With them the store also puts through S3 (
|
|
274
|
+
* With them the store also puts through S3 (4 at a time), not `wrangler r2 bulk put`, so a CI token needs no R2 write.
|
|
266
275
|
* @returns {{sets: () => Promise<string[]>, copy: (from: string, to: string, headers: Headers, bytes: number) => Promise<void>, put: (puts: readonly Put[]) => Promise<void>, secrets: string[], close: () => void} | undefined}
|
|
267
276
|
*/
|
|
268
277
|
export function r2Copies(env) {
|
|
269
278
|
const account = env.R2_ACCOUNT_ID?.trim(), accessKeyId = env.R2_PACKS_ACCESS_KEY_ID?.trim(), secretAccessKey = env.R2_PACKS_SECRET_ACCESS_KEY?.trim();
|
|
270
279
|
if (account === undefined || accessKeyId === undefined || secretAccessKey === undefined || account === '' || accessKeyId === '' || secretAccessKey === '') return undefined;
|
|
271
280
|
if (!/^[0-9a-f]{32}$/u.test(account)) throw new Error('Invalid R2_ACCOUNT_ID');
|
|
272
|
-
const client = new S3Client({region: 'auto', endpoint: `https://${account}.r2.cloudflarestorage.com`, credentials: {accessKeyId, secretAccessKey}});
|
|
281
|
+
const client = new S3Client({region: 'auto', maxAttempts: 6, endpoint: `https://${account}.r2.cloudflarestorage.com`, credentials: {accessKeyId, secretAccessKey}});
|
|
273
282
|
return {
|
|
274
283
|
secrets: [accessKeyId, secretAccessKey],
|
|
275
284
|
close: () => client.destroy(),
|
|
@@ -293,7 +302,7 @@ export function r2Copies(env) {
|
|
|
293
302
|
return complete.sort((a, b) => b.at - a.at).map(row => row.set);
|
|
294
303
|
},
|
|
295
304
|
async put(puts) {
|
|
296
|
-
await pool(puts,
|
|
305
|
+
await pool(puts, 4, async item => {
|
|
297
306
|
await client.send(new PutObjectCommand({Bucket: BUCKET, Key: item.key, Body: readFileSync(item.file),
|
|
298
307
|
ContentType: item.headers.type, CacheControl: item.headers.cache, ...(item.headers.encoding === undefined ? {} : {ContentEncoding: item.headers.encoding})}));
|
|
299
308
|
});
|
|
@@ -366,7 +375,7 @@ export function r2Content({root, scratch, token, fetch: get = fetch, exec = runR
|
|
|
366
375
|
/** @type {Headers} */ const headers = JSON.parse(id);
|
|
367
376
|
const list = join(scratch, `bulk-${createHash('sha256').update(id).digest('hex').slice(0, 8)}.json`);
|
|
368
377
|
writeFileSync(list, JSON.stringify(items.map(item => ({key: item.key, file: item.file}))));
|
|
369
|
-
const args = ['r2', 'bulk', 'put', BUCKET, '--remote', '--filename', list, '--content-type', headers.type, '--cache-control', headers.cache, '--concurrency', '
|
|
378
|
+
const args = ['r2', 'bulk', 'put', BUCKET, '--remote', '--filename', list, '--content-type', headers.type, '--cache-control', headers.cache, '--concurrency', '2', '--force'];
|
|
370
379
|
if (headers.encoding !== undefined) args.push('--content-encoding', headers.encoding);
|
|
371
380
|
try {
|
|
372
381
|
exec(join(root, 'node_modules/.bin/wrangler'), args, {cwd: root, env: {...process.env, CLOUDFLARE_ACCOUNT_ID: CLOUDFLARE_ACCOUNT}, timeout: 3 * 60 * 60_000}, secrets);
|
|
@@ -2,7 +2,7 @@ export type WorldChannel = 'staging' | 'production';
|
|
|
2
2
|
export type Channel = WorldChannel | 'preview';
|
|
3
3
|
export type Phase = 'build' | 'upload' | 'check' | 'go-live';
|
|
4
4
|
export interface WorldChannelConfig { channel: WorldChannel; solo: false; other: WorldChannel; origin: string; release: string; socket: string; health: string }
|
|
5
|
-
export interface SoloChannelConfig { channel: 'preview'; solo: true; origin: string }
|
|
5
|
+
export interface SoloChannelConfig { channel: 'preview'; solo: true; origin: string; release: string }
|
|
6
6
|
export type ChannelConfig = WorldChannelConfig | SoloChannelConfig;
|
|
7
7
|
export interface Deployment { id: string; url: string }
|
|
8
8
|
export interface HostContext { root: string; channel: ChannelConfig; build: string; saveEpoch: number; version: string; deployment?: Deployment }
|
|
@@ -52,10 +52,11 @@ export interface Deps {
|
|
|
52
52
|
}
|
|
53
53
|
export const PACKS_ORIGIN: string;
|
|
54
54
|
export const RELEASE_PUBLIC_KEY: string;
|
|
55
|
+
export function pinnedReleaseKey(configured?: string): string;
|
|
55
56
|
export const PHASES: readonly Phase[];
|
|
56
57
|
export const CHECKED_DOCUMENTS: readonly ['version.json', 'index.html', 'sw.js', 'deploy-chunks.json'];
|
|
57
58
|
export const CHANNELS: { staging: WorldChannelConfig; production: WorldChannelConfig; preview: SoloChannelConfig };
|
|
58
59
|
export class RefusedError extends Error { constructor(message: string) }
|
|
59
60
|
export function runPhase(phase: Phase, deps: Deps): Promise<{ refusals: string[] }>;
|
|
60
61
|
export function buildEnv(channel: ChannelConfig, deps: Deps): Record<string, string>;
|
|
61
|
-
export function readGate(channel:
|
|
62
|
+
export function readGate(channel: ChannelConfig, deps: Deps): Promise<{ serial?: number; problem?: string }>;
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// the producer's signed serial to name this build and the channel's /health to show that build and serial.
|
|
9
9
|
// go-live the alias move, LAST: refused without a fresh signed-release and /health match.
|
|
10
10
|
//
|
|
11
|
-
// Preview (the solo build of green main, J274
|
|
12
|
-
//
|
|
11
|
+
// Preview (the solo build of green main, J274) signs releases/preview.json as a deployment gate (PZ6 D2).
|
|
12
|
+
// Its document has no world stamp or release URL: the offline page still runs its server in a worker.
|
|
13
13
|
//
|
|
14
14
|
// The flow owns order and gates; the host (hosts/workers.mjs, page-release.mjs --host) owns how a
|
|
15
15
|
// page is packaged, uploaded, read back and aliased. Every dependency comes in through `deps`, so the tests drive a fake host.
|
|
@@ -30,13 +30,13 @@ export const CHECKED_DOCUMENTS = /** @type {const} */ (['version.json', 'index.h
|
|
|
30
30
|
/** @typedef {WorldChannel|'preview'} Channel */
|
|
31
31
|
/** @typedef {typeof PHASES[number]} Phase */
|
|
32
32
|
/** @typedef {{channel: WorldChannel, solo: false, other: WorldChannel, origin: string, release: string, socket: string, health: string}} WorldChannelConfig */
|
|
33
|
-
/** @typedef {{channel: 'preview', solo: true, origin: string}} SoloChannelConfig */
|
|
33
|
+
/** @typedef {{channel: 'preview', solo: true, origin: string, release: string}} SoloChannelConfig */
|
|
34
34
|
/** @typedef {WorldChannelConfig|SoloChannelConfig} ChannelConfig */
|
|
35
35
|
|
|
36
36
|
/** @type {{staging: WorldChannelConfig, production: WorldChannelConfig, preview: SoloChannelConfig}} */
|
|
37
37
|
export const CHANNELS = {
|
|
38
38
|
// SHELL-CUTOVER SC1: the solo build of the newest green main, no world stamp, so the in-page server runs.
|
|
39
|
-
preview: {channel: 'preview', solo: true, origin: 'https://preview.wildshard.io'},
|
|
39
|
+
preview: {channel: 'preview', solo: true, origin: 'https://preview.wildshard.io', release: `${PACKS_ORIGIN}/releases/preview.json`},
|
|
40
40
|
staging: {
|
|
41
41
|
channel: 'staging', solo: false, other: 'production', origin: 'https://staging.wildshard.io',
|
|
42
42
|
release: `${PACKS_ORIGIN}/releases/staging.json`, socket: 'wss://rooms-staging.wildshard.io',
|
|
@@ -55,6 +55,14 @@ export class RefusedError extends Error {
|
|
|
55
55
|
constructor(message) { super(message); this.name = 'RefusedError'; }
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/** Configuration may confirm the reviewed trust root, never replace it.
|
|
59
|
+
* @param {string|undefined} configured @returns {string} */
|
|
60
|
+
export function pinnedReleaseKey(configured) {
|
|
61
|
+
const value = configured?.trim();
|
|
62
|
+
if (value !== undefined && value !== '' && value !== RELEASE_PUBLIC_KEY) throw new RefusedError('E7_RELEASE_PUBLIC_KEY differs from the pinned release key');
|
|
63
|
+
return RELEASE_PUBLIC_KEY;
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
/**
|
|
59
67
|
* @typedef {{id: string, url: string}} Deployment
|
|
60
68
|
* @typedef {{algorithm: 'sha1'|'sha256', digest: string}} Digest
|
|
@@ -221,19 +229,17 @@ export async function runPhase(phase, deps) {
|
|
|
221
229
|
for (const line of deps.host.describe('deployedDigests', deployed)) plan(line);
|
|
222
230
|
if (!dry) await checkDeployed(deps, deployed, refuse);
|
|
223
231
|
if (channel.solo) {
|
|
224
|
-
|
|
225
|
-
if (dry)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
232
|
+
plan(`sign ${channel.release} after the page and its content are uploaded (no socket or server bundle)`);
|
|
233
|
+
if (!dry) deps.run('node', ['--import', './scripts/bake-loader.mjs', 'scripts/page-release/preview.mjs', `--build=${deps.build}`], {});
|
|
234
|
+
} else {
|
|
235
|
+
plan(`verify the server book and parts on ${PACKS_ORIGIN} answer with CORS ${channel.origin}`);
|
|
236
|
+
if (!dry) await deps.packs.verify({root: deps.root, build: deps.build, cors: channel.origin});
|
|
229
237
|
}
|
|
230
|
-
plan(`
|
|
231
|
-
if (!dry) await deps.packs.verify({root: deps.root, build: deps.build, cors: channel.origin});
|
|
232
|
-
plan(`wait for ${channel.release} to sign ${deps.build} and ${channel.health} to match its serial`);
|
|
238
|
+
plan(`wait for ${channel.release} to sign ${deps.build}${channel.solo ? ' (solo deployment gate)' : ` and ${channel.health} to match its serial`}`);
|
|
233
239
|
const gate = await waitForGate(channel, deps, refuse);
|
|
234
240
|
if (dry) return {refusals};
|
|
235
241
|
deps.state.write('check', {build: deps.build, channel: channel.channel, deployment, serial: gate.serial});
|
|
236
|
-
deps.log(`PASS ${channel.channel} check ${deployment.id}: deployed bytes equal,
|
|
242
|
+
deps.log(`PASS ${channel.channel} check ${deployment.id}: deployed bytes equal, serial ${gate.serial} signed${channel.solo ? ', solo deployment gate' : ', packs public and healthy'}; alias not moved`);
|
|
237
243
|
return {refusals};
|
|
238
244
|
}
|
|
239
245
|
|
|
@@ -244,8 +250,8 @@ export async function runPhase(phase, deps) {
|
|
|
244
250
|
if (!dry) await checkDeployed(deps, deployed, refuse);
|
|
245
251
|
/** @type {{serial?: number, problem?: string}} */
|
|
246
252
|
let gate = {};
|
|
247
|
-
|
|
248
|
-
plan(`re-read ${channel.release} and ${channel.health}:
|
|
253
|
+
{
|
|
254
|
+
plan(`re-read ${channel.release}${channel.solo ? '' : ` and ${channel.health}`}: must name ${deps.build} and one serial`);
|
|
249
255
|
gate = await readGate(channel, deps);
|
|
250
256
|
if (gate.problem !== undefined) refuse(gate.problem);
|
|
251
257
|
else if (checked !== undefined && gate.serial !== checked.serial) deps.log(`note: serial moved ${checked.serial} -> ${gate.serial} since check, still ${deps.build}`);
|
|
@@ -256,7 +262,7 @@ export async function runPhase(phase, deps) {
|
|
|
256
262
|
deps.log(`ALIAS MOVED ${channel.origin} -> ${deployment.id}; checking the domain`);
|
|
257
263
|
await waitForDomain(channel, deps, refuse);
|
|
258
264
|
deps.state.write('go-live', {build: deps.build, channel: channel.channel, deployment, ...(gate.serial === undefined ? {} : {serial: gate.serial})});
|
|
259
|
-
deps.log(`PASS ${channel.origin} -> ${deps.build} ${deployment.id} ${channel.solo ? 'solo
|
|
265
|
+
deps.log(`PASS ${channel.origin} -> ${deps.build} ${deployment.id} after matching serial ${gate.serial}${channel.solo ? ' (solo)' : ''} (alias last)`);
|
|
260
266
|
deps.log(channel.solo ? `next: node scripts/e7-doctor-proof.mjs ${channel.origin} ${deps.build} --human-static`
|
|
261
267
|
: channel.channel === 'staging'
|
|
262
268
|
? `next: strict staging proofs, then production. node scripts/e7-doctor-proof.mjs ${channel.origin} ${deps.build} ${RELEASE_PUBLIC_KEY}; node scripts/e7-live-staging-proof.mjs ${channel.origin} ${deps.build} ${RELEASE_PUBLIC_KEY} chromium|webkit`
|
|
@@ -271,7 +277,7 @@ export function buildEnv(channel, deps) {
|
|
|
271
277
|
WS_BUILD_ID: deps.build, WILDSHARD_CATALOGUE: (channel.solo ? deps.catalogue : undefined) ?? 'test/pins/catalogue.json',
|
|
272
278
|
WS_PREVIOUS_DEPLOY_ORIGIN: channel.origin, WS_RELEASE: '1', WS_CHANNEL: channel.channel,
|
|
273
279
|
// API-CLOUDFLARE AC11: errors, telemetry and the inbox go to the api-server Worker on every channel.
|
|
274
|
-
VITE_API_ORIGIN: API_ORIGIN,
|
|
280
|
+
VITE_API_ORIGIN: API_ORIGIN, WILDSHARD_RELEASE_KEY: deps.releaseKey ?? RELEASE_PUBLIC_KEY,
|
|
275
281
|
};
|
|
276
282
|
// Preview is the solo game: no release file, so the build stamps no world (app-build-pipeline.mjs E7.2d).
|
|
277
283
|
return channel.solo ? common
|
|
@@ -340,8 +346,8 @@ async function productionGates(phase, deps, refuse) {
|
|
|
340
346
|
}
|
|
341
347
|
|
|
342
348
|
/**
|
|
343
|
-
* The signed
|
|
344
|
-
* @param {
|
|
349
|
+
* The signed file names this build. Online channels also require matching /health; preview forbids a socket.
|
|
350
|
+
* @param {ChannelConfig} channel @param {Deps} deps
|
|
345
351
|
* @returns {Promise<{serial?: number, problem?: string}>}
|
|
346
352
|
*/
|
|
347
353
|
export async function readGate(channel, deps) {
|
|
@@ -354,10 +360,14 @@ export async function readGate(channel, deps) {
|
|
|
354
360
|
createPublicKey({key: Buffer.from(deps.releaseKey ?? RELEASE_PUBLIC_KEY, 'hex'), format: 'der', type: 'spki'}), Buffer.from(signed.signature, 'hex'));
|
|
355
361
|
} catch { valid = false; }
|
|
356
362
|
if (!valid) return {problem: `${channel.release} signature does not verify`};
|
|
357
|
-
|
|
363
|
+
let release;
|
|
364
|
+
try { release = JSON.parse(signed.body); } catch { return {problem: `${channel.release} body is not JSON`}; }
|
|
365
|
+
if (release === null || typeof release !== 'object' || !Number.isSafeInteger(release.serial) || release.serial < 1) return {problem: `${channel.release} has an invalid serial`};
|
|
358
366
|
if (release.channel !== channel.channel) return {problem: `${channel.release} is channel ${release.channel}`};
|
|
359
367
|
if (release.engineBuild !== deps.build) return {problem: `${channel.release} serial ${release.serial} signs ${release.engineBuild}, not ${deps.build}`};
|
|
360
368
|
if (release.saveEpoch !== deps.manifest.saveEpoch) return {problem: `${channel.release} save epoch ${release.saveEpoch} is not ${deps.manifest.saveEpoch}`};
|
|
369
|
+
if (channel.solo) return release.socket === undefined && release.bundle === undefined
|
|
370
|
+
? {serial: release.serial} : {problem: `${channel.release} must be solo (no socket or server bundle)`};
|
|
361
371
|
if (String(release.socket).replace(/\/$/u, '') !== channel.socket) return {problem: `${channel.release} socket ${release.socket} is not ${channel.socket}`};
|
|
362
372
|
/** @type {any} */
|
|
363
373
|
let health;
|
|
@@ -366,7 +376,7 @@ export async function readGate(channel, deps) {
|
|
|
366
376
|
return {serial: release.serial};
|
|
367
377
|
}
|
|
368
378
|
|
|
369
|
-
/** @param {
|
|
379
|
+
/** @param {ChannelConfig} channel @param {Deps} deps @param {(message: string) => void} refuse */
|
|
370
380
|
async function waitForGate(channel, deps, refuse) {
|
|
371
381
|
const deadline = deps.now() + (deps.dryRun ? 0 : deps.waitMs ?? 45 * 60_000);
|
|
372
382
|
for (let last = '';;) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type {execFileSync} from 'node:child_process';
|
|
2
|
+
import type {PackStore} from './flow.mjs';
|
|
3
|
+
|
|
4
|
+
export function serverPackOutputRoot(root: string, bookPath: string): string;
|
|
5
|
+
export function r2Packs(options: {log: (line: string) => void; exec?: typeof execFileSync; fetch?: typeof fetch; sleep?: (ms: number) => Promise<void>}): PackStore;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {execFileSync} from 'node:child_process';
|
|
8
8
|
import {setTimeout as delay} from 'node:timers/promises';
|
|
9
9
|
import {createHash} from 'node:crypto';
|
|
10
|
-
import {readFileSync} from 'node:fs';
|
|
10
|
+
import {existsSync, readFileSync} from 'node:fs';
|
|
11
11
|
import {join, resolve} from 'node:path';
|
|
12
12
|
import {pathToFileURL} from 'node:url';
|
|
13
13
|
import {brotliDecompressSync} from 'node:zlib';
|
|
@@ -17,6 +17,16 @@ export const BUCKET = 'wildshard-packs';
|
|
|
17
17
|
export const CLOUDFLARE_ACCOUNT = '0a870ffdd1b0bca67f7fedad77f67957';
|
|
18
18
|
const sha256 = (/** @type {Uint8Array} */ bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
19
19
|
|
|
20
|
+
/** Server books/parts move together into dist-content/ on a split page release.
|
|
21
|
+
* @param {string} root @param {string} bookPath */
|
|
22
|
+
export function serverPackOutputRoot(root, bookPath) {
|
|
23
|
+
for (const name of ['dist', 'dist-content']) {
|
|
24
|
+
const dir = join(root, name);
|
|
25
|
+
if (existsSync(join(dir, bookPath))) return dir;
|
|
26
|
+
}
|
|
27
|
+
throw new Error(`Server book ${bookPath} is missing from dist/ and dist-content/`);
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
* @param {{log: (line: string) => void, exec?: typeof execFileSync, fetch?: typeof fetch, sleep?: (ms: number) => Promise<void>}} options
|
|
22
32
|
* @returns {import('./flow.mjs').PackStore}
|
|
@@ -54,9 +64,9 @@ export function r2Packs({log, exec = execFileSync, fetch: get = fetch, sleep = d
|
|
|
54
64
|
}
|
|
55
65
|
/** @param {{root: string, build: string}} context */
|
|
56
66
|
async function load({root, build}) {
|
|
57
|
-
const dist = join(root, 'dist');
|
|
58
67
|
const {readServerPackBook, serverPackBookPath} = await import(pathToFileURL(join(root, 'src/shared/game/shardfile/serverPack.ts')).href);
|
|
59
|
-
const bookPath = serverPackBookPath(build),
|
|
68
|
+
const bookPath = serverPackBookPath(build), dist = serverPackOutputRoot(root, bookPath);
|
|
69
|
+
const bookBytes = readFileSync(join(dist, bookPath)), book = readServerPackBook(JSON.parse(bookBytes.toString('utf8')));
|
|
60
70
|
if (book.build !== build) throw new Error(`${bookPath} names ${book.build}`);
|
|
61
71
|
/** @type {Map<string, {url: string, bytes: number, hash: string, wireBytes: number, files: readonly (readonly [string, number, number])[]}>} */
|
|
62
72
|
const parts = new Map();
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// PZ6 D2: a deployment-only signed preview release. The solo page never reads it.
|
|
2
|
+
import {execFileSync, spawnSync} from 'node:child_process';
|
|
3
|
+
import {readFileSync} from 'node:fs';
|
|
4
|
+
import {parseArgs} from 'node:util';
|
|
5
|
+
import {resolve} from 'node:path';
|
|
6
|
+
import * as v from 'valibot';
|
|
7
|
+
import {HeadObjectCommand, S3Client} from '@aws-sdk/client-s3';
|
|
8
|
+
import {publishChannel} from '../server-release/publish.mjs';
|
|
9
|
+
import {COMMIT, releaseShards} from '../server-release/sign.mjs';
|
|
10
|
+
import {pinnedReleaseKey} from './flow.mjs';
|
|
11
|
+
|
|
12
|
+
const UploadState = v.object({
|
|
13
|
+
build: v.object({build: v.string(), contentBase: v.optional(v.string())}),
|
|
14
|
+
upload: v.object({build: v.string(), channel: v.literal('preview'),
|
|
15
|
+
deployment: v.object({id: v.pipe(v.string(), v.minLength(1))}), content: v.optional(v.object({base: v.string()}))}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/** Validate the completed page upload before granting the signer any work.
|
|
19
|
+
* @param {unknown} state @param {string} build @param {boolean} onMain @returns {string|undefined} */
|
|
20
|
+
export function previewUpload(state, build, onMain) {
|
|
21
|
+
if (!COMMIT.test(build) || !onMain) throw new Error('Preview build must be a full commit on origin/main');
|
|
22
|
+
const row = v.parse(UploadState, state);
|
|
23
|
+
if (row.build.build !== build || row.upload.build !== build) throw new Error('Preview must upload this page before signing');
|
|
24
|
+
const base = row.build.contentBase;
|
|
25
|
+
if (base !== undefined && (!/^https:\/\/packs\.wildshard\.io\/content\/[0-9a-f]{16}\/$/u.test(base)
|
|
26
|
+
|| row.upload.content?.base !== base)) throw new Error('Preview content upload does not match the built page');
|
|
27
|
+
return base;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function main() {
|
|
31
|
+
const {values} = parseArgs({options: {build: {type: 'string'}}});
|
|
32
|
+
const build = values.build;
|
|
33
|
+
if (build === undefined || !COMMIT.test(build)) throw new Error('Preview needs --build=<full SHA>');
|
|
34
|
+
if (execFileSync('git', ['rev-parse', 'HEAD'], {encoding: 'utf8'}).trim() !== build) throw new Error('Preview build must be HEAD');
|
|
35
|
+
const onMain = spawnSync('git', ['merge-base', '--is-ancestor', build, 'origin/main'], {stdio: 'ignore'}).status === 0;
|
|
36
|
+
const base = previewUpload(JSON.parse(readFileSync(`tmp/page-release/preview-${build}.json`, 'utf8')), build, onMain);
|
|
37
|
+
const need = (/** @type {string} */ name) => {
|
|
38
|
+
const value = process.env[name]?.trim();
|
|
39
|
+
if (value === undefined || value === '') throw new Error(`Missing ${name}`);
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
const account = need('R2_ACCOUNT_ID');
|
|
43
|
+
if (!/^[0-9a-f]{32}$/u.test(account)) throw new Error('Invalid R2_ACCOUNT_ID');
|
|
44
|
+
const privateKey = need('E7_RELEASE_SIGNING_KEY');
|
|
45
|
+
const publicKey = pinnedReleaseKey(process.env.E7_RELEASE_PUBLIC_KEY);
|
|
46
|
+
const client = new S3Client({region: 'auto', endpoint: `https://${account}.r2.cloudflarestorage.com`,
|
|
47
|
+
credentials: {accessKeyId: need('R2_PACKS_ACCESS_KEY_ID'), secretAccessKey: need('R2_PACKS_SECRET_ACCESS_KEY')}});
|
|
48
|
+
const pins = JSON.parse(readFileSync('test/pins/shardfiles.json', 'utf8'));
|
|
49
|
+
try {
|
|
50
|
+
const result = await publishChannel({client, bucket: 'wildshard-packs', privateKey, publicKey,
|
|
51
|
+
candidate: {channel: 'preview', serial: 1, engineBuild: build,
|
|
52
|
+
saveEpoch: JSON.parse(readFileSync('save-epoch.json', 'utf8')).saveEpoch,
|
|
53
|
+
shards: releaseShards(pins, pins.shards.map((/** @type {{slug: string}} */ row) => row.slug).join(','))},
|
|
54
|
+
isAncestor: (older, newer) => {
|
|
55
|
+
const check = spawnSync('git', ['merge-base', '--is-ancestor', older, newer], {stdio: 'ignore'});
|
|
56
|
+
if (check.status !== 0 && check.status !== 1) throw new Error('Cannot read preview commit history');
|
|
57
|
+
return check.status === 0;
|
|
58
|
+
},
|
|
59
|
+
packsReady: async () => {
|
|
60
|
+
// The index is the publisher's completion marker, written after every content file is verified.
|
|
61
|
+
if (base !== undefined) await client.send(new HeadObjectCommand({Bucket: 'wildshard-packs', Key: `${new URL(base).pathname.slice(1)}content.json`}));
|
|
62
|
+
return null;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
if (!['published', 'unchanged'].includes(result.status) || result.release.engineBuild !== build) throw new Error('Preview publication is stale; alias stays unchanged');
|
|
66
|
+
console.log(`preview ${result.status}: ${build} signed at serial ${result.release.serial}, no socket`);
|
|
67
|
+
} finally { client.destroy(); }
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (process.argv[1] !== undefined && resolve(process.argv[1]) === import.meta.filename) {
|
|
72
|
+
try { await main(); }
|
|
73
|
+
catch (error) { console.error(error instanceof Error ? error.message : 'Preview publication failed'); process.exitCode = 1; }
|
|
74
|
+
}
|