@wildshard/engine 0.1.21 → 0.1.23
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/lint/engine-sides.json +5 -0
- package/lint/shardfile-boundaries.mjs +4 -2
- package/lint/sim-players.json +2 -13
- package/lint/wildshard-plugin.js +1 -1
- package/package.json +10 -2
- 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/audio-download-proof.mjs +1 -1
- package/scripts/check-spelled-paths.mjs +6 -3
- package/scripts/ci-pack.mjs +3 -3
- package/scripts/committed-fast-checks.mjs +2 -2
- package/scripts/engine-ci-shard.mjs +11 -0
- package/scripts/failmode-cases.mjs +1 -1
- package/scripts/failmode-proof.mjs +35 -11
- package/scripts/fight-page-census.mjs +131 -0
- package/scripts/goldens/board.py +44 -11
- package/scripts/goldens/native-residency.d.mts +1 -0
- package/scripts/goldens/native-residency.mjs +18 -4
- package/scripts/grid-crossing-walk-proof.mjs +3 -3
- package/scripts/hover-speed-probe.mjs +2 -2
- package/scripts/keep-copy.mjs +120 -0
- package/scripts/land.mjs +36 -6
- 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 +57 -7
- package/scripts/loading-flow/stalls.d.mts +2 -0
- package/scripts/loading-flow/stalls.mjs +13 -0
- package/scripts/mmo-bots.mjs +11 -5
- package/scripts/mmo-grid-proof.mjs +74 -0
- package/scripts/mmo-seat-proof.mjs +43 -0
- package/scripts/net-lag-proof.mjs +1 -1
- package/scripts/nightly-heads.ts +13 -13
- package/scripts/nightly-model.ts +26 -12
- package/scripts/nightly.proof.ts +18 -5
- package/scripts/nightly.ts +13 -8
- package/scripts/no-astc-boot.mjs +77 -0
- package/scripts/online-rig.mjs +7 -7
- package/scripts/parity/boot-smoke.mjs +1 -1
- 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/release-cook.mjs +6 -2
- package/scripts/ring3.proof.ts +71 -0
- package/scripts/ring3.ts +100 -0
- package/scripts/scratch-dir.mjs +31 -12
- package/scripts/scratch-sweep.mjs +15 -23
- package/scripts/server-release/items.d.mts +7 -0
- package/scripts/server-release/items.mjs +28 -0
- package/scripts/server-release/publish.mjs +9 -1
- package/scripts/side-parity.mjs +1 -1
- package/scripts/test-products.json +1 -21
- package/scripts/tsconfig.json +2 -0
- package/scripts/vitest-ci-files.ts +5 -1
- package/scripts/vps/cook-follow.d.mts +6 -0
- package/scripts/vps/cook-follow.mjs +45 -0
- package/scripts/vps/harden-apply.sh +10 -1
- package/scripts/vps/rebuild.sh +104 -36
- package/scripts/vps/wildshard-config +106 -3
- package/scripts/warm-native-chrome.mjs +9 -3
- package/scripts/worker-client-fights.mjs +9 -3
- package/scripts/worktree-reap.mjs +15 -131
- package/scripts/worktree.mjs +92 -12
- package/src/client/app/entry.ts +2 -3
- package/src/client/engine/audio/audioLog.ts +7 -2
- package/src/client/engine/boot/contentRead.ts +24 -4
- package/src/client/engine/boot/diagnostics.ts +69 -1
- package/src/client/engine/boot/downloadGiveUp.ts +34 -0
- package/src/client/engine/combat/EquipmentService.ts +2 -0
- package/src/client/engine/core/Game.ts +6 -2
- package/src/client/engine/core/ktx2.ts +5 -3
- package/src/client/engine/core/ktx2Zstd.ts +2 -1
- package/src/client/engine/pwa/sw.js +26 -8
- package/src/client/engine/render/dataLook.ts +14 -7
- package/src/client/engine/render/lookLight.ts +64 -20
- package/src/client/engine/ui/Loading.ts +6 -8
- package/src/client/engine/ui/downloadFailed.ts +54 -0
- package/src/client/engine/ui/lookLightOption.ts +1 -1
- package/src/client/game/audio/cueDirector.ts +2 -1
- package/src/client/game/boot/spawnDownload.ts +12 -1
- 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/copyPrompts.ts +3 -4
- package/src/client/game/grid/dataCellKit.ts +99 -0
- package/src/client/game/grid/enteredEquipment.ts +11 -2
- package/src/client/game/grid/live.ts +9 -299
- package/src/client/game/grid/liveSession.ts +31 -8
- package/src/client/game/grid/neighbourLife.ts +50 -32
- package/src/client/game/grid/products.ts +21 -7
- package/src/client/game/grid/reveal.ts +7 -2
- package/src/client/game/grid/session.ts +10 -74
- package/src/client/game/plugin/weaponFamily.ts +6 -0
- package/src/client/game/population/signals.ts +1 -1
- package/src/client/game/quest/chapterDirector.ts +1 -0
- package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
- package/src/client/game/shardfile/clientWorker.ts +35 -9
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/runtimeProduct.ts +9 -5
- 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 +37 -13
- 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/room.ts +2 -38
- package/src/server/game/grid/simulation.ts +5 -4
- package/src/server/game/plugin/mover.ts +18 -14
- package/src/server/game/shardfile/declaredKitItems.ts +39 -9
- package/src/server/host/bake/headlessWorker.ts +3 -3
- package/src/server/host/dedicated/cellHost.ts +2 -2
- package/src/server/host/dedicated/cellProtocol.ts +1 -1
- package/src/server/host/dedicated/cellWorker.ts +5 -3
- package/src/server/host/dedicated/dedicatedRoom.ts +8 -3
- package/src/server/host/dedicated/gridCells.ts +5 -3
- package/src/server/host/dedicated/main.ts +12 -7
- package/src/server/host/dedicated/packReader.ts +15 -2
- package/src/server/host/dedicated/playerStore.ts +1 -1
- package/src/server/host/dedicated/workerTable.ts +0 -10
- package/src/server/host/dedicated/world.ts +39 -5
- package/src/server/host/headlessRuntime.ts +11 -6
- package/src/server/host/standalone/cellWorld.ts +21 -7
- package/src/server/host/standalone/gridServer.ts +3 -1
- package/src/server/host/standalone/roadWorld.ts +6 -0
- package/src/shared/engine/physics/gridBorders.ts +15 -1
- package/src/shared/engine/saves/shape.ts +17 -2
- package/src/shared/engine/sim/snapshot.ts +5 -5
- package/src/shared/engine/strings.ts +10 -0
- package/src/shared/game/grid/placementRows.ts +4 -3
- 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/host/headlessJourney.ts +3 -3
- package/src/shared/host/headlessTape.ts +7 -6
- package/src/shared/host/releaseRows.ts +4 -1
- package/src/client/game/grid/cellLoading.ts +0 -110
- package/src/client/game/grid/cellScreens.ts +0 -48
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Standalone integration checks of the sender against a controlled GitHub API.
|
|
2
|
+
import {test} from 'node:test';
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import {prepare, runRing3, shardRepos, type Api} from './ring3.ts';
|
|
5
|
+
|
|
6
|
+
const candidate = 'a'.repeat(40), shard = 'b'.repeat(40);
|
|
7
|
+
interface Call {method: string; path: string; body?: unknown}
|
|
8
|
+
function fixture(options: {red?: string; malformed?: boolean; pending?: boolean; wrongRun?: boolean; denied?: string; existing?: boolean} = {}): {api: Api; calls: Call[]} {
|
|
9
|
+
const calls: Call[] = [];
|
|
10
|
+
const api: Api = (method, path, body) => Promise.resolve().then(() => {
|
|
11
|
+
calls.push({method, path, body});
|
|
12
|
+
const repo = path.split('/')[2];
|
|
13
|
+
if (repo === undefined || !shardRepos.includes(repo as typeof shardRepos[number])) throw new Error(`Unexpected repository: ${path}`);
|
|
14
|
+
const id = shardRepos.indexOf(repo as typeof shardRepos[number]) + 100;
|
|
15
|
+
if (method === 'POST' && path.endsWith('/dispatches')) {
|
|
16
|
+
if (repo === options.denied) throw new Error('HTTP 403');
|
|
17
|
+
assert.deepEqual(body, {ref: 'main', inputs: {engine: candidate}, return_run_details: true});
|
|
18
|
+
return options.malformed ? {} : {workflow_run_id: id};
|
|
19
|
+
}
|
|
20
|
+
if (method === 'GET' && path.endsWith(`/actions/runs/${id}`)) return {id: options.wrongRun ? id + 1 : id, event: 'workflow_dispatch', path: '.github/workflows/ci.yml', head_sha: shard, run_attempt: 1,
|
|
21
|
+
status: options.pending ? 'queued' : 'completed', conclusion: repo === options.red ? 'failure' : 'success'};
|
|
22
|
+
if (method === 'GET' && path.includes('/issues?')) return options.existing ? [{title: `[Ring 3] engine ${candidate}`, html_url: 'existing-issue'}] : [];
|
|
23
|
+
if (method === 'POST' && path.endsWith('/issues')) return {html_url: `https://github.com/project-wildshard/${repo}/issues/1`};
|
|
24
|
+
throw new Error(`Unexpected API call: ${method} ${path}`);
|
|
25
|
+
});
|
|
26
|
+
return {api, calls};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await test('all seven exact candidate dispatches must complete green on their returned run IDs', async () => {
|
|
30
|
+
const {api, calls} = fixture(), report = await runRing3(prepare(candidate, 'sender'), {api});
|
|
31
|
+
assert.equal(report.ok, true);
|
|
32
|
+
assert.deepEqual(report.rows.map(row => row.repo), shardRepos);
|
|
33
|
+
assert.equal(report.rows.every(row => row.shardSha === shard && row.status === 'success'), true);
|
|
34
|
+
assert.equal(calls.filter(call => call.method === 'POST').length, 7);
|
|
35
|
+
assert.equal(calls.some(call => call.path.includes('/runs?')), false, 'Never substitutes another candidate run');
|
|
36
|
+
});
|
|
37
|
+
await test('one red receiver holds the aggregate and files only that shard issue', async () => {
|
|
38
|
+
const {api, calls} = fixture({red: 'shard-dunes'}), report = await runRing3(prepare(candidate, 'sender'), {api});
|
|
39
|
+
assert.equal(report.ok, false);
|
|
40
|
+
assert.equal(report.rows.filter(row => row.status === 'success').length, 6);
|
|
41
|
+
assert.equal(report.rows[0].issue, 'https://github.com/project-wildshard/shard-dunes/issues/1');
|
|
42
|
+
assert.equal(calls.filter(call => call.method === 'POST' && call.path.endsWith('/issues')).length, 1);
|
|
43
|
+
});
|
|
44
|
+
await test('a repeat red candidate reuses its existing issue', async () => {
|
|
45
|
+
const {api, calls} = fixture({red: 'shard-dunes', existing: true}), report = await runRing3(prepare(candidate, 'sender'), {api});
|
|
46
|
+
assert.equal(report.rows[0].issue, 'existing-issue');
|
|
47
|
+
assert.equal(calls.filter(call => call.method === 'POST' && call.path.endsWith('/issues')).length, 0);
|
|
48
|
+
});
|
|
49
|
+
await test('a refused shard dispatch cannot prevent the other six receivers from running', async () => {
|
|
50
|
+
const {api} = fixture({denied: 'shard-dunes'}), report = await runRing3(prepare(candidate, 'sender'), {api});
|
|
51
|
+
assert.equal(report.ok, false);
|
|
52
|
+
assert.equal(report.rows[0].status, 'error');
|
|
53
|
+
assert.equal(report.rows.filter(row => row.status === 'success').length, 6);
|
|
54
|
+
});
|
|
55
|
+
await test('missing IDs and unrelated green runs can never qualify the candidate', async () => {
|
|
56
|
+
for (const option of [{malformed: true}, {wrongRun: true}]) {
|
|
57
|
+
const {api} = fixture(option), report = await runRing3(prepare(candidate, 'sender'), {api});
|
|
58
|
+
assert.equal(report.ok, false);
|
|
59
|
+
assert.equal(report.rows.every(row => row.status === 'error'), true);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
await test('queued receivers hit a bounded deadline and remain red with their run links', async () => {
|
|
63
|
+
let now = 0;
|
|
64
|
+
const {api} = fixture({pending: true}), report = await runRing3(prepare(candidate, 'sender'), {api, now: () => now, sleep: ms => {now += ms; return Promise.resolve();}, deadlineMs: 100, pollMs: 20});
|
|
65
|
+
assert.equal(now, 100);
|
|
66
|
+
assert.equal(report.ok, false);
|
|
67
|
+
assert.equal(report.rows.every(row => row.status === 'timeout' && row.runUrl !== undefined), true);
|
|
68
|
+
});
|
|
69
|
+
await test('moving refs and shell text refuse before a dispatch can be prepared', () => {
|
|
70
|
+
for (const ref of ['main', 'a'.repeat(39), '$(echo injected)', 'A'.repeat(40)]) assert.throws(() => prepare(ref, 'sender'), /full engine commit/u);
|
|
71
|
+
});
|
package/scripts/ring3.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Ring 3: dispatch the exact candidate, then follow the returned run ID.
|
|
2
|
+
// workflow_dispatch reaches the same receiver as engine-candidate, and its
|
|
3
|
+
// return_run_details response avoids guessing which concurrent run is ours.
|
|
4
|
+
import {mkdirSync, readFileSync, writeFileSync} from 'node:fs';
|
|
5
|
+
import {join} from 'node:path';
|
|
6
|
+
import {pathToFileURL} from 'node:url';
|
|
7
|
+
|
|
8
|
+
export const shardRepos = ['shard-dunes', 'shard-sky-reach', 'shard-nalati', 'shard-nine-dragon', 'shard-driftwood', 'shard-pine-hollow', 'shard-open-plots'] as const;
|
|
9
|
+
interface Row {repo: string; status: 'pending' | 'success' | 'failure' | 'error' | 'timeout'; runId?: number; runUrl?: string; shardSha?: string; conclusion?: string | null; issue?: string; error?: string}
|
|
10
|
+
export interface Aggregate {version: 1; engine: string; originRun: string; ok: boolean; rows: Row[]}
|
|
11
|
+
export type Api = (method: 'GET' | 'POST', path: string, body?: unknown) => Promise<unknown>;
|
|
12
|
+
interface Options {api: Api; now?: () => number; sleep?: (ms: number) => Promise<void>; deadlineMs?: number; pollMs?: number; checkpoint?: (report: Aggregate) => void}
|
|
13
|
+
const errorText = (error: unknown): string => String(error).replaceAll(/[\r\n]/gu, ' ').slice(0, 1000);
|
|
14
|
+
|
|
15
|
+
export function prepare(engine: string, originRun: string): Aggregate {
|
|
16
|
+
if (!/^[a-f0-9]{40}$/u.test(engine)) throw new Error('Ring 3 requires the full engine commit hash');
|
|
17
|
+
return {version: 1, engine, originRun, ok: false, rows: shardRepos.map(repo => ({repo, status: 'pending'}))};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function runRing3(report: Aggregate, options: Options): Promise<Aggregate> {
|
|
21
|
+
const {api, now = Date.now, sleep = (ms: number): Promise<void> => new Promise(resolve => {setTimeout(resolve, ms);}), deadlineMs = 20 * 60_000, pollMs = 15_000, checkpoint = () => { /* Embedded callers may omit persisted receipts. */ }} = options;
|
|
22
|
+
const until = now() + deadlineMs;
|
|
23
|
+
// All seven requests are independent; a refused shard must not hide the others.
|
|
24
|
+
await Promise.all(report.rows.map(async row => {
|
|
25
|
+
try {
|
|
26
|
+
const response = await api('POST', `repos/project-wildshard/${row.repo}/actions/workflows/ci.yml/dispatches`,
|
|
27
|
+
{ref: 'main', inputs: {engine: report.engine}, return_run_details: true}) as {workflow_run_id?: number; html_url?: string};
|
|
28
|
+
if (!Number.isSafeInteger(response.workflow_run_id) || (response.workflow_run_id ?? 0) <= 0) throw new Error('Dispatch returned no exact run ID; refusing to guess a run');
|
|
29
|
+
row.runId = response.workflow_run_id;
|
|
30
|
+
row.runUrl = `https://github.com/project-wildshard/${row.repo}/actions/runs/${row.runId}`;
|
|
31
|
+
} catch (error) {row.status = 'error'; row.error = errorText(error);}
|
|
32
|
+
checkpoint(report);
|
|
33
|
+
}));
|
|
34
|
+
while (report.rows.some(row => row.status === 'pending') && now() < until) {
|
|
35
|
+
await Promise.all(report.rows.filter(row => row.status === 'pending').map(async row => {
|
|
36
|
+
try {
|
|
37
|
+
const run = await api('GET', `repos/project-wildshard/${row.repo}/actions/runs/${row.runId}`) as {id: number; event: string; path: string; head_sha: string; status: string; conclusion: string | null; run_attempt: number};
|
|
38
|
+
if (run.id !== row.runId || run.event !== 'workflow_dispatch' || run.path.split('@')[0] !== '.github/workflows/ci.yml' || !/^[a-f0-9]{40}$/u.test(run.head_sha) || run.run_attempt !== 1) throw new Error('Receiver run identity changed; new qualification required');
|
|
39
|
+
row.shardSha = run.head_sha;
|
|
40
|
+
if (run.status === 'completed') {row.conclusion = run.conclusion; row.status = run.conclusion === 'success' ? 'success' : 'failure';}
|
|
41
|
+
} catch (error) {row.status = 'error'; row.error = errorText(error);}
|
|
42
|
+
checkpoint(report);
|
|
43
|
+
}));
|
|
44
|
+
if (report.rows.some(row => row.status === 'pending')) await sleep(Math.max(0, Math.min(pollMs, until - now())));
|
|
45
|
+
}
|
|
46
|
+
for (const row of report.rows) if (row.status === 'pending') {row.status = 'timeout'; row.error = 'Receiver did not complete within the Ring 3 deadline';}
|
|
47
|
+
// Deduplicate per candidate in each shard; cancelled/skipped/incomplete is never green.
|
|
48
|
+
await Promise.all(report.rows.filter(row => row.status !== 'success' && row.runId !== undefined).map(async row => {
|
|
49
|
+
try {
|
|
50
|
+
const title = `[Ring 3] engine ${report.engine}`;
|
|
51
|
+
const existing = await api('GET', `repos/project-wildshard/${row.repo}/issues?state=all&per_page=100&sort=created&direction=desc`) as {title: string; html_url: string; pull_request?: unknown}[];
|
|
52
|
+
const prior = existing.find(issue => issue.pull_request === undefined && issue.title === title);
|
|
53
|
+
if (prior !== undefined) row.issue = prior.html_url;
|
|
54
|
+
else {
|
|
55
|
+
const issue = await api('POST', `repos/project-wildshard/${row.repo}/issues`, {title,
|
|
56
|
+
body: `Engine candidate: \`${report.engine}\`\n\nReceiver: ${row.runUrl}\n\nShard commit: \`${row.shardSha ?? 'unavailable'}\`\n\nVerdict: ${row.status} (${row.conclusion ?? row.error ?? 'incomplete'}).\n\nSender: ${report.originRun}\n\nFix forward (J165); this candidate is not release-qualified.`}) as {html_url: string};
|
|
57
|
+
row.issue = issue.html_url;
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {row.error = `${row.error ?? ''} Issue creation failed: ${errorText(error)}`.trim();}
|
|
60
|
+
checkpoint(report);
|
|
61
|
+
}));
|
|
62
|
+
report.ok = report.rows.length === shardRepos.length && report.rows.every(row => row.status === 'success');
|
|
63
|
+
checkpoint(report);
|
|
64
|
+
return report;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function markdown(report: Aggregate): string {
|
|
68
|
+
return [`# Ring 3: ${report.ok ? 'GREEN' : 'RED — RELEASE HELD'}`, '', `Engine: \`${report.engine}\``, '',
|
|
69
|
+
'| Shard | Candidate run | Shard commit | Verdict | Issue |', '| --- | --- | --- | --- | --- |',
|
|
70
|
+
...report.rows.map(row => `| ${row.repo} | ${row.runUrl === undefined ? 'not dispatched' : `[${row.runId}](${row.runUrl})`} | ${row.shardSha?.slice(0, 12) ?? 'unknown'} | ${row.status} | ${row.issue === undefined ? '' : `[issue](${row.issue})`} |`),
|
|
71
|
+
'', ...report.rows.filter(row => row.error !== undefined).map(row => `- ${row.repo}: ${row.error?.replaceAll(/[|<>]/gu, ' ')}`),
|
|
72
|
+
'', 'This artifact aggregates candidate checks. It does not create a tag, release, upload or deployment.', ''].join('\n');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
76
|
+
const [command, directory = 'tmp/ring3'] = process.argv.slice(2);
|
|
77
|
+
const save = (report: Aggregate): void => {mkdirSync(directory, {recursive: true}); writeFileSync(join(directory, 'verdict.json'), `${JSON.stringify(report, null, 2)}\n`); writeFileSync(join(directory, 'summary.md'), markdown(report));};
|
|
78
|
+
if (command === 'prepare') save(prepare(process.env.RING3_ENGINE ?? '', process.env.RING3_ORIGIN_RUN ?? 'local'));
|
|
79
|
+
else if (command === 'run') {
|
|
80
|
+
const report = JSON.parse(readFileSync(join(directory, 'verdict.json'), 'utf8')) as Aggregate;
|
|
81
|
+
// Revalidate the persisted candidate before any write request.
|
|
82
|
+
if (JSON.stringify(report) !== JSON.stringify(prepare(report.engine, report.originRun))) throw new Error('Ring 3 must start from a fresh prepared aggregate');
|
|
83
|
+
const token = process.env.GH_TOKEN;
|
|
84
|
+
if (token === undefined || token === '') throw new Error('Ring 3 needs the dedicated nightly App token');
|
|
85
|
+
const api: Api = async (method, path, body) => {
|
|
86
|
+
const response = await fetch(`https://api.github.com/${path}`, {method, signal: AbortSignal.timeout(20_000),
|
|
87
|
+
headers: {accept: 'application/vnd.github+json', authorization: `Bearer ${token}`, 'x-github-api-version': '2022-11-28', ...(body === undefined ? {} : {'content-type': 'application/json'})},
|
|
88
|
+
...(body === undefined ? {} : {body: JSON.stringify(body)})});
|
|
89
|
+
if (!response.ok) throw new Error(`GitHub ${method} ${path}: HTTP ${response.status}; check nightly App installation and Actions/Issues permissions`);
|
|
90
|
+
return response.json();
|
|
91
|
+
};
|
|
92
|
+
await runRing3(report, {api, checkpoint: save});
|
|
93
|
+
console.log(markdown(report));
|
|
94
|
+
if (!report.ok) process.exitCode = 1;
|
|
95
|
+
} else if (command === 'report') {
|
|
96
|
+
const report = JSON.parse(readFileSync(join(directory, 'verdict.json'), 'utf8')) as Aggregate;
|
|
97
|
+
console.log(markdown(report));
|
|
98
|
+
if (!report.ok) process.exitCode = 1;
|
|
99
|
+
} else throw new Error('Use ring3.ts prepare|run|report [directory]');
|
|
100
|
+
}
|
package/scripts/scratch-dir.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// repo-kit's scratch folder maker (meta docs/plans/REPO-DISK-PLAN.md row DK3). One copy lives in repo-kit; every org
|
|
3
3
|
// repo and singleplayer carries a byte-identical copy at scripts/scratch-dir.mjs (DK8 checks the copies).
|
|
4
4
|
//
|
|
5
|
-
// node scripts/scratch-dir.mjs <task> "<purpose>"
|
|
5
|
+
// node scripts/scratch-dir.mjs <task> "<purpose>" [--row <plan-row>]
|
|
6
6
|
//
|
|
7
7
|
// creates <repo>/tmp/<task>/ and tmp/<task>/.owner, then prints the folder's absolute path. .owner is JSON: the session
|
|
8
8
|
// id ($CLAUDE_SESSION_ID, else $CLAUDE_CODE_SESSION_ID, else the Codex lane name in $WS_LANE_NAME), the lane name, the
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
// <task> is one plain folder name: letters, digits, '.', '_' and '-', not starting with '.', never containing '/' or
|
|
13
13
|
// '..'. The helper deletes nothing. It refuses a folder that already exists unless that folder's .owner names this
|
|
14
14
|
// same session (then it prints the path again), so it never takes over another lane's or an ownerless folder.
|
|
15
|
-
import { mkdirSync, readFileSync, rmdirSync, writeFileSync } from 'node:fs';
|
|
15
|
+
import { mkdirSync, readFileSync, renameSync, rmdirSync, statSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { homedir } from 'node:os';
|
|
16
17
|
import { join, resolve } from 'node:path';
|
|
17
18
|
import { pathToFileURL } from 'node:url';
|
|
18
19
|
|
|
@@ -31,14 +32,21 @@ export function refuseTask(task) {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/** The .owner record for a new folder.
|
|
34
|
-
* @param {string} task @param {string} purpose @param {NodeJS.ProcessEnv} env @param {Date} now
|
|
35
|
-
|
|
35
|
+
* @param {string} task @param {string} purpose @param {NodeJS.ProcessEnv} env @param {Date} now
|
|
36
|
+
* @param {string | null} row */
|
|
37
|
+
export function ownerRecord(task, purpose, env, now, row = null) {
|
|
36
38
|
const lane = env.WS_LANE_NAME || null;
|
|
39
|
+
let receiptOffset = null;
|
|
40
|
+
try { receiptOffset = statSync(env.WS_LANE_RECEIPTS ?? join(homedir(), '.cache/wildshard/lane-receipts.log')).size; }
|
|
41
|
+
catch (error) { if (error instanceof Error && 'code' in error && error.code === 'ENOENT') receiptOffset = 0; }
|
|
37
42
|
return {
|
|
38
43
|
task,
|
|
39
|
-
session: env.CLAUDE_SESSION_ID || env.CLAUDE_CODE_SESSION_ID || lane,
|
|
44
|
+
session: env.CLAUDE_SESSION_ID || env.CLAUDE_CODE_SESSION_ID || env.CODEX_THREAD_ID || lane,
|
|
40
45
|
lane,
|
|
41
46
|
pane: env.HERDR_PANE_ID || null,
|
|
47
|
+
agent: env.CLAUDE_SESSION_ID || env.CLAUDE_CODE_SESSION_ID ? 'claude' : env.CODEX_THREAD_ID || lane ? 'codex' : 'unknown',
|
|
48
|
+
row,
|
|
49
|
+
receiptOffset,
|
|
42
50
|
started: now.toISOString(),
|
|
43
51
|
purpose,
|
|
44
52
|
};
|
|
@@ -52,21 +60,29 @@ function readOwner(path) {
|
|
|
52
60
|
/** Make <root>/tmp/<task>/ and its .owner; returns the folder's absolute path. Throws on a refused name, an empty
|
|
53
61
|
* purpose, or a folder that exists and is not this session's.
|
|
54
62
|
* @param {string} task @param {string} purpose
|
|
55
|
-
* @param {{root?: string, env?: NodeJS.ProcessEnv, now?: Date}} [options] */
|
|
56
|
-
export function scratchDir(task, purpose, { root = ROOT, env = process.env, now = new Date() } = {}) {
|
|
63
|
+
* @param {{root?: string, env?: NodeJS.ProcessEnv, now?: Date, row?: string | null}} [options] */
|
|
64
|
+
export function scratchDir(task, purpose, { root = ROOT, env = process.env, now = new Date(), row = null } = {}) {
|
|
57
65
|
const refusal = refuseTask(task);
|
|
58
66
|
if (refusal) throw new Error(refusal);
|
|
59
67
|
if (typeof purpose !== 'string' || purpose.trim() === '') throw new Error('a purpose is required');
|
|
60
68
|
const tmp = join(resolve(root), 'tmp');
|
|
61
69
|
const dir = join(tmp, task);
|
|
62
|
-
|
|
70
|
+
if (row !== null && !/^[A-Z][A-Z0-9-]*\d+[a-z]?$/u.test(row)) throw new Error(`row "${row}" is not a plan row`);
|
|
71
|
+
const owner = ownerRecord(task, purpose.trim(), env, now, row);
|
|
63
72
|
mkdirSync(tmp, { recursive: true });
|
|
64
73
|
try {
|
|
65
74
|
mkdirSync(dir);
|
|
66
75
|
} catch (error) {
|
|
67
76
|
if (!(error instanceof Error && 'code' in error && error.code === 'EEXIST')) throw error;
|
|
68
77
|
const existing = readOwner(join(dir, '.owner'));
|
|
69
|
-
if (existing && owner.session && existing.session === owner.session)
|
|
78
|
+
if (existing && owner.session && existing.session === owner.session) {
|
|
79
|
+
// A lane name can outlive a task. Advance its cursor when it resumes,
|
|
80
|
+
// without ever exposing a half-written ownership record.
|
|
81
|
+
const next = join(dir, `.owner-${process.pid}`);
|
|
82
|
+
writeFileSync(next, `${JSON.stringify(owner, null, 2)}\n`, { flag: 'wx' });
|
|
83
|
+
renameSync(next, join(dir, '.owner'));
|
|
84
|
+
return dir;
|
|
85
|
+
}
|
|
70
86
|
throw new Error(existing
|
|
71
87
|
? `${dir} already belongs to session ${String(existing.session)}; pick another task name`
|
|
72
88
|
: `${dir} already exists with no .owner; pick another task name`);
|
|
@@ -82,12 +98,15 @@ export function scratchDir(task, purpose, { root = ROOT, env = process.env, now
|
|
|
82
98
|
|
|
83
99
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
84
100
|
const [task = '', purpose = '', ...rest] = process.argv.slice(2);
|
|
85
|
-
|
|
86
|
-
|
|
101
|
+
const rowAt = rest.indexOf('--row');
|
|
102
|
+
const row = rowAt === -1 ? null : rest[rowAt + 1] ?? null;
|
|
103
|
+
const other = rowAt === -1 ? rest : rest.filter((_, index) => index !== rowAt && index !== rowAt + 1);
|
|
104
|
+
if (other.length > 0 || task === '--help' || task === '-h' || rowAt !== -1 && row === null) {
|
|
105
|
+
console.error('usage: node scripts/scratch-dir.mjs <task> "<purpose>" [--row <plan-row>]');
|
|
87
106
|
process.exit(2);
|
|
88
107
|
}
|
|
89
108
|
try {
|
|
90
|
-
console.log(scratchDir(task, purpose));
|
|
109
|
+
console.log(scratchDir(task, purpose, { row }));
|
|
91
110
|
} catch (error) {
|
|
92
111
|
console.error(`scratch-dir: ${error instanceof Error ? error.message : String(error)}`);
|
|
93
112
|
process.exit(1);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// repo-kit's
|
|
2
|
+
// repo-kit's report-only scratch sweep (meta REPO-DISK-PLAN J358, was TEMP-HYGIENE T7). One copy lives in repo-kit; every org
|
|
3
3
|
// repo carries a byte-identical copy at scripts/scratch-sweep.mjs, beside scratch-dir.mjs (DK3) and vite-tmp.mjs.
|
|
4
4
|
//
|
|
5
|
-
// node scripts/scratch-sweep.mjs [--
|
|
5
|
+
// node scripts/scratch-sweep.mjs [--root <repo>] [--days <n>]
|
|
6
6
|
//
|
|
7
7
|
// It looks at each folder directly under <repo>/tmp/ and would remove one in which nothing (the folder or anything in
|
|
8
8
|
// it) changed for <n> days (3 by default), with or without a DK3 `.owner`. It keeps:
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
// - a folder that is, or holds, some process's cwd (lsof -d cwd; /proc on Linux); an unreadable table keeps all;
|
|
12
12
|
// - a folder holding a Git root with dirty files or commits no remote has (DS14's list: the reason names the root);
|
|
13
13
|
// - dot folders, symlinks, and `tmp/vitest` (vite-tmp.mjs's own).
|
|
14
|
-
//
|
|
15
|
-
//
|
|
14
|
+
// J358 cancelled the 11-20 go-live: this script never removes files. Every decision is appended to
|
|
15
|
+
// tmp/.sweep.log, one line each, and a summary line goes to stdout for a human daily audit.
|
|
16
16
|
import { spawnSync } from 'node:child_process';
|
|
17
|
-
import { appendFileSync, lstatSync, readdirSync, readFileSync, readlinkSync, realpathSync
|
|
17
|
+
import { appendFileSync, lstatSync, readdirSync, readFileSync, readlinkSync, realpathSync } from 'node:fs';
|
|
18
18
|
import { join, resolve, sep } from 'node:path';
|
|
19
19
|
import { pathToFileURL } from 'node:url';
|
|
20
|
+
import { laneLive } from './lane-live.mjs';
|
|
20
21
|
|
|
21
22
|
const DEFAULT_DAYS = 3;
|
|
22
23
|
const MINUTES_A_DAY = 1440;
|
|
@@ -138,23 +139,14 @@ export function plan({ root, days = DEFAULT_DAYS, cwds = processCwds() }) {
|
|
|
138
139
|
return rows;
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
/** Plans
|
|
142
|
-
* @param {{ root: string,
|
|
143
|
-
export function sweep({ root,
|
|
142
|
+
/** Plans and logs every row to tmp/.sweep.log. J358: humans, not this script, remove leftovers.
|
|
143
|
+
* @param {{ root: string, days?: number, cwds?: readonly string[] | null, now?: Date }} options */
|
|
144
|
+
export function sweep({ root, days = DEFAULT_DAYS, cwds, now = new Date() }) {
|
|
144
145
|
const rows = plan({ root, days, ...(cwds === undefined ? {} : { cwds }) });
|
|
145
146
|
const stamp = now.toISOString(), lines = [];
|
|
146
|
-
let removed = 0;
|
|
147
147
|
for (const row of rows) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
try {
|
|
151
|
-
rmSync(join(root, 'tmp', row.name), { recursive: true, force: true });
|
|
152
|
-
verb = 'removed';
|
|
153
|
-
removed += 1;
|
|
154
|
-
} catch (error) {
|
|
155
|
-
verb = `remove failed (${error instanceof Error ? error.message : String(error)})`;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
148
|
+
const liveness = laneLive(join(root, 'tmp', row.name));
|
|
149
|
+
const verb = row.action === 'keep' ? `keep (${row.reason}; ${liveness.state}: ${liveness.reason})` : `leftover (manual audit; ${liveness.state}: ${liveness.reason})`;
|
|
158
150
|
lines.push(`${stamp} ${verb} tmp/${row.name}${row.action === 'remove' ? ` (${row.reason})` : ''}\n`);
|
|
159
151
|
}
|
|
160
152
|
if (lines.length > 0) {
|
|
@@ -163,7 +155,7 @@ export function sweep({ root, live = false, days = DEFAULT_DAYS, cwds, now = new
|
|
|
163
155
|
} catch {}
|
|
164
156
|
}
|
|
165
157
|
const planned = rows.filter(row => row.action === 'remove').length;
|
|
166
|
-
return { rows, planned
|
|
158
|
+
return { rows, planned };
|
|
167
159
|
}
|
|
168
160
|
|
|
169
161
|
if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
@@ -175,8 +167,8 @@ if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.a
|
|
|
175
167
|
const days = Number(flag('--days') ?? DEFAULT_DAYS);
|
|
176
168
|
if (!Number.isInteger(days) || days < 1) throw new Error('--days takes a whole number of days, 1 or more');
|
|
177
169
|
const root = resolve(flag('--root') ?? resolve(import.meta.dirname, '..'));
|
|
178
|
-
|
|
179
|
-
const { rows, planned
|
|
170
|
+
if (args.includes('--live')) throw new Error('--live was removed by REPO-DISK J358: this command only reports leftovers');
|
|
171
|
+
const { rows, planned } = sweep({ root, days });
|
|
180
172
|
const keptRows = rows.filter(row => row.action === 'keep');
|
|
181
|
-
process.stdout.write(`scratch-sweep
|
|
173
|
+
process.stdout.write(`scratch-sweep report ${root}/tmp: ${String(planned)} leftover(s) for manual audit, kept ${String(keptRows.length)}; log tmp/.sweep.log\n`);
|
|
182
174
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import type { ReleaseFile } from '../../src/shared/host/releaseRows';
|
|
3
|
+
|
|
4
|
+
type ItemReference = NonNullable<ReleaseFile['items']>;
|
|
5
|
+
export function itemDigest(body: Uint8Array): string;
|
|
6
|
+
export function itemBytesMatch(body: Uint8Array, reference: ItemReference): boolean;
|
|
7
|
+
export function copyItemCatalogue(client: S3Client, bucket: string, read?: typeof fetch): Promise<ItemReference>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Q37: only publication contacts api-server. The running game reads this immutable R2 copy.
|
|
2
|
+
import {createHash} from 'node:crypto';
|
|
3
|
+
import {GetObjectCommand,PutObjectCommand,S3ServiceException} from '@aws-sdk/client-s3';
|
|
4
|
+
import {MAX_ITEM_CATALOGUE_BYTES,platformItemCatalogueBytes} from '../../src/shared/game/loot/platformCatalogue.ts';
|
|
5
|
+
|
|
6
|
+
/** @typedef {NonNullable<import('../../src/shared/host/releaseRows.ts').ReleaseFile['items']>} ItemReference */
|
|
7
|
+
/** @param {Uint8Array} body */
|
|
8
|
+
export const itemDigest=body=>createHash('sha256').update(body).digest('hex');
|
|
9
|
+
/** @param {Uint8Array} body @param {ItemReference} reference */
|
|
10
|
+
export const itemBytesMatch=(body,reference)=>body.byteLength===reference.bytes&&itemDigest(body)===reference.sha256;
|
|
11
|
+
|
|
12
|
+
/** Copy admitted, canonical API bytes before signing any channel. A hash-named object is never overwritten.
|
|
13
|
+
* @param {import('@aws-sdk/client-s3').S3Client} client @param {string} bucket @param {typeof fetch} [read] @returns {Promise<ItemReference>} */
|
|
14
|
+
export async function copyItemCatalogue(client,bucket,read=fetch){
|
|
15
|
+
const response=await read('https://api.wildshard.io/api/items.json',{cache:'no-store',signal:AbortSignal.timeout(30_000)});
|
|
16
|
+
if(!response.ok)throw new Error(`Item catalogue answered ${response.status}`);
|
|
17
|
+
const text=await response.text();
|
|
18
|
+
if(new TextEncoder().encode(text).byteLength>MAX_ITEM_CATALOGUE_BYTES)throw new Error('Item catalogue is too large');
|
|
19
|
+
const body=platformItemCatalogueBytes(JSON.parse(text)),sha256=itemDigest(body),reference={path:`assets/catalogue/items-${sha256}.json`,sha256,bytes:body.byteLength};
|
|
20
|
+
try{await client.send(new PutObjectCommand({Bucket:bucket,Key:reference.path,Body:body,ContentType:'application/json',CacheControl:'public,max-age=31536000,immutable',IfNoneMatch:'*'}));}
|
|
21
|
+
catch(error){
|
|
22
|
+
if(!(error instanceof S3ServiceException&&error.$metadata.httpStatusCode===412))throw error;
|
|
23
|
+
const existing=await client.send(new GetObjectCommand({Bucket:bucket,Key:reference.path}));
|
|
24
|
+
const kept=await existing.Body?.transformToByteArray();
|
|
25
|
+
if(kept===undefined||!itemBytesMatch(kept,reference))throw new Error('Existing item catalogue hash mismatch',{cause:error});
|
|
26
|
+
}
|
|
27
|
+
return reference;
|
|
28
|
+
}
|
|
@@ -8,6 +8,7 @@ import { GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client, S3Serv
|
|
|
8
8
|
import * as v from 'valibot';
|
|
9
9
|
import { readServerPackBook, serverPackBookPath } from '../../src/shared/game/shardfile/serverPack.ts';
|
|
10
10
|
import { bundleDescriptor, COMMIT, DEFAULT_SERVER_SHARDS, publication, readPublication, releasePublicKey, releaseShards, signRelease } from './sign.mjs';
|
|
11
|
+
import { copyItemCatalogue, itemBytesMatch } from './items.mjs';
|
|
11
12
|
|
|
12
13
|
/** @typedef {import('../../src/shared/host/releaseRows.ts').ReleaseFile} ReleaseFile */
|
|
13
14
|
/** @typedef {{client: S3Client, bucket: string, candidate: ReleaseFile, privateKey: string, publicKey: string, isAncestor: (older: string, newer: string) => boolean,
|
|
@@ -22,6 +23,12 @@ const missing = error => error instanceof S3ServiceException && (error.name ===
|
|
|
22
23
|
* no book strands every check behind it. Null when the book and every part the release's shards and grid need are in the bucket.
|
|
23
24
|
* @param {S3Client} client @param {string} bucket @param {ReleaseFile} release @returns {Promise<string | null>} */
|
|
24
25
|
export async function serverPacksReady(client, bucket, release) {
|
|
26
|
+
if (release.items !== undefined) {
|
|
27
|
+
let body;
|
|
28
|
+
try { body = await (await client.send(new GetObjectCommand({ Bucket: bucket, Key: release.items.path }))).Body?.transformToByteArray(); }
|
|
29
|
+
catch (error) { if (missing(error)) return `no item catalogue at ${release.items.path}`; throw error; }
|
|
30
|
+
if (body === undefined || !itemBytesMatch(body, release.items)) return `item catalogue hash mismatch at ${release.items.path}`;
|
|
31
|
+
}
|
|
25
32
|
const key = serverPackBookPath(release.engineBuild);
|
|
26
33
|
let text;
|
|
27
34
|
try { text = await (await client.send(new GetObjectCommand({ Bucket: bucket, Key: key }))).Body?.transformToString(); }
|
|
@@ -126,7 +133,8 @@ async function main() {
|
|
|
126
133
|
const client = new S3Client({ region: 'auto', endpoint: `https://${account}.r2.cloudflarestorage.com`, credentials });
|
|
127
134
|
try {
|
|
128
135
|
const packsReady = (/** @type {ReleaseFile} */ release) => serverPacksReady(client, bucket, release);
|
|
129
|
-
const
|
|
136
|
+
const items = await copyItemCatalogue(client, bucket);
|
|
137
|
+
const result = await publishChannel({ client, bucket, candidate: { ...candidate, items }, privateKey, publicKey, isAncestor, align, packsReady });
|
|
130
138
|
writeFileSync(values.out, `${result.signed}\n`);
|
|
131
139
|
console.log(JSON.stringify({ status: result.status, channel: result.release.channel, serial: result.release.serial, engineBuild: result.release.engineBuild, object: `releases/${result.release.channel}.json`,
|
|
132
140
|
...result.reason === undefined ? {} : { held: candidate.engineBuild, reason: result.reason } }));
|
package/scripts/side-parity.mjs
CHANGED
|
@@ -169,7 +169,7 @@ export function sideParityDiff(paged, server, at, allow = {}, { slack = 1, same
|
|
|
169
169
|
if (best !== null) { used.add(best); return; }
|
|
170
170
|
const shape = all.find(other => close(row, other));
|
|
171
171
|
const inside = (outer, inner) => [0, 1, 2].every(i => inner[i] >= outer[i] - slack && inner[i + 3] <= outer[i + 3] + slack);
|
|
172
|
-
if (shape === undefined && side === 'page' && !row.sensor && !row.dynamic && all.some(other => other.material === 'edge' && !other.sensor && inside(other.box, row.box))) return;
|
|
172
|
+
if (shape === undefined && side === 'page' && !row.sensor && !row.dynamic && all.some(other => other.material === 'edge' && !other.sensor && !Object.hasOwn(allow, allowKey(other)) && inside(other.box, row.box))) return;
|
|
173
173
|
if (shape === undefined) { note(`${side}|${matchKey(row)}|${row.dynamic}`, row.box, (count, box) => side === 'page'
|
|
174
174
|
? `${describe(row)}: ${count} page collider(s) with no server match, e.g. [${box.join(', ')}]`
|
|
175
175
|
: `${describe(row)}: ${count} server collider(s) near the page's player with no page match, e.g. [${box.join(', ')}]`); return; }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"test/admitted-product-cache.test.ts": [],
|
|
2
3
|
"test/net-link-play.test.ts": ["driftwood-isle"],
|
|
3
4
|
"test/engine-rule-successors.test.ts": ["pine-hollow", "nalati-grasslands", "driftwood-isle"],
|
|
4
5
|
"test/engine-rule-successors-titan.test.ts": ["nalati-grasslands"],
|
|
@@ -139,10 +140,6 @@
|
|
|
139
140
|
"test/sdk-rigged-hull-files.test.ts": [],
|
|
140
141
|
"test/frame-floor-output-entry.test.ts": [],
|
|
141
142
|
"test/texture-scope-lifetime.test.ts": [],
|
|
142
|
-
"test/chapter-director-product.test.ts": [
|
|
143
|
-
"pine-hollow",
|
|
144
|
-
"driftwood-isle"
|
|
145
|
-
],
|
|
146
143
|
"test/director-shipping-product.test.ts": [
|
|
147
144
|
"pine-hollow",
|
|
148
145
|
"driftwood-isle"
|
|
@@ -221,9 +218,6 @@
|
|
|
221
218
|
"sunscar-dunes",
|
|
222
219
|
"far-reach"
|
|
223
220
|
],
|
|
224
|
-
"test/pine-npc-figure-product.test.ts": [
|
|
225
|
-
"pine-hollow"
|
|
226
|
-
],
|
|
227
221
|
"test/scripts/_template-boss.test.ts": [
|
|
228
222
|
"_template"
|
|
229
223
|
],
|
|
@@ -272,10 +266,6 @@
|
|
|
272
266
|
"test/keyed-sky-platform.test.ts": [],
|
|
273
267
|
"test/streamed-cover-platform.test.ts": [],
|
|
274
268
|
"test/toon-look-platform.test.ts": [],
|
|
275
|
-
"test/pine-quest-actions-product.test.ts": [
|
|
276
|
-
"pine-hollow",
|
|
277
|
-
"driftwood-isle"
|
|
278
|
-
],
|
|
279
269
|
"test/world-scene-batch.test.ts": [],
|
|
280
270
|
"test/pine-crag-scenes.test.ts": [
|
|
281
271
|
"pine-hollow"
|
|
@@ -285,9 +275,6 @@
|
|
|
285
275
|
"driftwood-isle"
|
|
286
276
|
],
|
|
287
277
|
"test/world-scene-baked-model.test.ts": [],
|
|
288
|
-
"test/pine-prop-product.test.ts": [
|
|
289
|
-
"pine-hollow"
|
|
290
|
-
],
|
|
291
278
|
"test/driftwood-foliage-scenes.test.ts": [],
|
|
292
279
|
"test/quest-catalogue-sites.test.ts": [
|
|
293
280
|
"pine-hollow",
|
|
@@ -332,10 +319,6 @@
|
|
|
332
319
|
"test/quest-page-refs.test.ts": [],
|
|
333
320
|
"test/scene-motion-refs.test.ts": [],
|
|
334
321
|
"test/scene-buffers.test.ts": [],
|
|
335
|
-
"test/native-runtime-plan.test.ts": [
|
|
336
|
-
"far-reach",
|
|
337
|
-
"sunscar-dunes"
|
|
338
|
-
],
|
|
339
322
|
"test/native-runtime-observation.test.ts": [
|
|
340
323
|
"far-reach"
|
|
341
324
|
],
|
|
@@ -356,9 +339,6 @@
|
|
|
356
339
|
"test/boss-arena-room.test.ts": [],
|
|
357
340
|
"test/grapple-platform.test.ts": [],
|
|
358
341
|
"test/nalati-layout-bake.test.ts": [],
|
|
359
|
-
"test/template-map-generation.test.ts": [
|
|
360
|
-
"_template"
|
|
361
|
-
],
|
|
362
342
|
"test/stealth-detection.test.ts": [],
|
|
363
343
|
"test/held-weapon-laws.test.ts": [],
|
|
364
344
|
"test/nalati-riding-rules.test.ts": ["pine-hollow", "nalati-grasslands"],
|
package/scripts/tsconfig.json
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
],
|
|
38
38
|
"include": [
|
|
39
|
+
"../.agents/hooks/active-hours.mjs",
|
|
39
40
|
"**/*.mjs",
|
|
40
41
|
"**/*.ts",
|
|
41
42
|
"**/*.mts",
|
|
@@ -551,6 +552,7 @@
|
|
|
551
552
|
"webkit-mem-reading.mjs",
|
|
552
553
|
"webkit-render-smoke.mjs",
|
|
553
554
|
"worker-client-fights.mjs",
|
|
555
|
+
"fight-page-census.mjs",
|
|
554
556
|
"worker-client-moments.mjs",
|
|
555
557
|
"worker-client-play.mjs",
|
|
556
558
|
"worker-client-proof.mjs",
|
|
@@ -18,7 +18,11 @@ export const CI_NATIVE_GROUPS = {
|
|
|
18
18
|
// MP1C.4: a real crossing on the real clock, then a reboot; kept off sibling workers like net-fuzz's crossing.
|
|
19
19
|
'test/grid-crossing-crash.test.ts',
|
|
20
20
|
],
|
|
21
|
-
'native-direct-worker': [
|
|
21
|
+
'native-direct-worker': [
|
|
22
|
+
'test/headless-direct-worker.test.ts',
|
|
23
|
+
// Six real SDK workers, with a fixed 20 s parent fence: no sibling files.
|
|
24
|
+
'test/headless-verb-tape-worker.test.ts',
|
|
25
|
+
],
|
|
22
26
|
'native-host-transport': ['test/sim-transport.test.ts'],
|
|
23
27
|
'native-restores': [
|
|
24
28
|
'test/pinned-restore-play.test.ts',
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// MMO-SERVER MS2.4a: turn staging's signed release into the root-owned state
|
|
3
|
+
// that selects the cook checkout. cook.env deliberately contains credentials only.
|
|
4
|
+
import { createPublicKey, verify } from 'node:crypto';
|
|
5
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
6
|
+
import { dirname } from 'node:path';
|
|
7
|
+
import { pathToFileURL } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const BUILD = /^[0-9a-f]{40}$/u, TAG = /^server-staging-([0-9a-f]{40})$/u;
|
|
10
|
+
/** @param {string} text @param {string} name */
|
|
11
|
+
const value = (text, name) => [...text.matchAll(new RegExp(`^${name}=(.*)$`, 'gmu'))].pop()?.[1]?.trim().replaceAll(/^["']|["']$/gu, '') ?? '';
|
|
12
|
+
/** @param {string} name */
|
|
13
|
+
const argument = name => { const index = process.argv.indexOf(name), next = process.argv[index + 1]; if (index === -1 || next === undefined) throw new Error(`Missing ${name}`); return next; };
|
|
14
|
+
|
|
15
|
+
/** @param {string} text @param {string} key */
|
|
16
|
+
export function signedCookRelease(text, key) {
|
|
17
|
+
const signed = JSON.parse(text);
|
|
18
|
+
if (typeof signed?.body !== 'string' || typeof signed?.signature !== 'string' || !/^(?:[0-9a-f]{2})+$/u.test(signed.signature)) throw new Error('Invalid signed release');
|
|
19
|
+
const publicKey = createPublicKey({ key: Buffer.from(key, 'hex'), format: 'der', type: 'spki' });
|
|
20
|
+
if (!verify(null, Buffer.from(signed.body), publicKey, Buffer.from(signed.signature, 'hex'))) throw new Error('A release file has a bad signature');
|
|
21
|
+
const release = JSON.parse(signed.body), tag = typeof release?.bundle?.name === 'string' ? release.bundle.name.split('/')[0] : '';
|
|
22
|
+
if (release?.channel !== 'staging' || typeof release.engineBuild !== 'string' || !BUILD.test(release.engineBuild) || !TAG.test(tag) || tag.slice('server-staging-'.length) !== release.engineBuild) throw new Error('The signed staging release has no matching server tag and build');
|
|
23
|
+
return { tag, build: release.engineBuild };
|
|
24
|
+
}
|
|
25
|
+
/** @param {string} path @param {string} text */
|
|
26
|
+
function atomic(path, text) {
|
|
27
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o750 });
|
|
28
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
29
|
+
try { writeFileSync(temporary, text, { mode: 0o600 }); renameSync(temporary, path); }
|
|
30
|
+
finally { rmSync(temporary, { force: true }); }
|
|
31
|
+
}
|
|
32
|
+
async function main() {
|
|
33
|
+
const env = argument('--env'), state = argument('--state'), envText = readFileSync(env, 'utf8');
|
|
34
|
+
const check = process.argv.includes('--check');
|
|
35
|
+
const url = value(envText, 'RELEASE_URL'), key = value(envText, 'RELEASE_PUBLIC_KEY');
|
|
36
|
+
if (!url.startsWith('https://') || key === '') throw new Error('staging.env has no HTTPS signed release configuration');
|
|
37
|
+
const response = await fetch(url, { cache: 'no-store', signal: AbortSignal.timeout(20_000), redirect: 'error' });
|
|
38
|
+
if (!response.ok) throw new Error(`The signed staging release answered ${response.status}`);
|
|
39
|
+
const next = signedCookRelease(await response.text(), key), text = `COOK_ENGINE_REF=${next.tag}\nWILDSHARD_BUILD=${next.build}\n`;
|
|
40
|
+
if (check) { console.info('would'); return; }
|
|
41
|
+
let held = ''; try { held = readFileSync(state, 'utf8'); } catch (error) { if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) throw error; }
|
|
42
|
+
if (held === text) { console.info('unchanged'); return; }
|
|
43
|
+
atomic(state, text); console.info('changed');
|
|
44
|
+
}
|
|
45
|
+
if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) await main();
|
|
@@ -363,9 +363,18 @@ if put /usr/local/sbin/wildshard-alert 755 root:root VH14 <<'EOF'
|
|
|
363
363
|
# sudo runs PAM with an empty environment, so the path is its own.
|
|
364
364
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
365
365
|
[ "${PAM_TYPE:-open_session}" = open_session ] || exit 0
|
|
366
|
+
# SENTRY-TRIAGE S16: an SSH login over the tailnet (100.64.0.0/10, fd7a:115c:a1e0::/48) is our own operator or agent, so it sends
|
|
367
|
+
# nothing. A login from any other address, sudo, the console and fail2ban's bans (the failed logins) still report.
|
|
368
|
+
if [ $# -eq 0 ] && [ "${PAM_SERVICE:-}" = sshd ]; then
|
|
369
|
+
case ${PAM_RHOST:-} in
|
|
370
|
+
100.6[4-9].*|100.[7-9][0-9].*|100.1[01][0-9].*|100.12[0-7].*|[Ff][Dd]7[Aa]:115[Cc]:[Aa]1[Ee]0:*) exit 0 ;;
|
|
371
|
+
esac
|
|
372
|
+
fi
|
|
373
|
+
line=${1:-"${PAM_SERVICE:-?}: ${PAM_USER:-?}${PAM_RUSER:+ (by $PAM_RUSER)} from ${PAM_RHOST:-the box}"}
|
|
374
|
+
# Tests only: print the line instead of sending it. PAM and fail2ban never set it.
|
|
375
|
+
[ -z "${WILDSHARD_ALERT_PRINT:-}" ] || { printf '%s\n' "$line"; exit 0; }
|
|
366
376
|
dsn=$(sed -n 's/^SENTRY_CRON_DSN=//p' /etc/wildshard/ops.env 2>/dev/null | tail -n 1)
|
|
367
377
|
[ -n "$dsn" ] || exit 0
|
|
368
|
-
line=${1:-"${PAM_SERVICE:-?}: ${PAM_USER:-?}${PAM_RUSER:+ (by $PAM_RUSER)} from ${PAM_RHOST:-the box}"}
|
|
369
378
|
key=${dsn#*://} key=${key%%@*} rest=${dsn#*@}
|
|
370
379
|
body=$(python3 -I -c 'import json, sys, socket, uuid; print(json.dumps({"event_id": uuid.uuid4().hex, "level": "warning", "logger": "wildshard-auth", "platform": "other", "server_name": socket.gethostname(), "environment": "production", "message": {"formatted": sys.argv[1]}, "tags": {"kind": "auth"}}))' "$line" 2>/dev/null) || exit 0
|
|
371
380
|
( curl -fsS -m 5 -o /dev/null -H 'Content-Type: application/json' \
|