@wildshard/engine 0.1.15 → 0.1.17

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.
Files changed (207) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/index.html +157 -11
  3. package/lint/engine-sides.json +16 -0
  4. package/lint/host-register.json +496 -0
  5. package/lint/ratchet.json +2 -2
  6. package/lint/shard-imports.d.mts +1 -0
  7. package/lint/shard-imports.mjs +56 -8
  8. package/lint/wildshard-plugin.js +22 -4
  9. package/package.json +16 -5
  10. package/scripts/app-build/buildIdentity.d.mts +3 -1
  11. package/scripts/app-build/buildIdentity.mjs +25 -5
  12. package/scripts/app-build/builtAt.d.mts +4 -0
  13. package/scripts/app-build/builtAt.mjs +21 -0
  14. package/scripts/app-build/serviceWorker.ts +16 -2
  15. package/scripts/app-build/versionFiles.ts +2 -1
  16. package/scripts/app-build-pipeline.mjs +4 -1
  17. package/scripts/audio-download-proof.mjs +843 -0
  18. package/scripts/build-app.mjs +4 -0
  19. package/scripts/build-mirror.d.mts +2 -0
  20. package/scripts/build-mirror.mjs +5 -4
  21. package/scripts/built-product.mjs +3 -3
  22. package/scripts/cell-mem/metrics-preload.mjs +65 -0
  23. package/scripts/cell-mem-bench.mjs +130 -0
  24. package/scripts/check-chunks.mjs +2 -1
  25. package/scripts/devserver-client.d.mts +5 -0
  26. package/scripts/devserver-client.mjs +68 -0
  27. package/scripts/engine-ci-budget.ts +7 -1
  28. package/scripts/format-lock.mjs +20 -11
  29. package/scripts/generate-title-launch.mjs +3 -2
  30. package/scripts/grid-crossing-walk-proof.mjs +16 -8
  31. package/scripts/heavy-lane.py +25 -1
  32. package/scripts/host-ruler/register-migrate.mjs +242 -0
  33. package/scripts/host-ruler/register.d.mts +36 -0
  34. package/scripts/host-ruler/register.mjs +116 -0
  35. package/scripts/host-ruler/roots.d.mts +29 -0
  36. package/scripts/host-ruler/roots.mjs +333 -0
  37. package/scripts/host-ruler/server-roots.d.mts +23 -0
  38. package/scripts/host-ruler/server-roots.mjs +272 -0
  39. package/scripts/main-watch.d.mts +1 -1
  40. package/scripts/main-watch.mjs +10 -6
  41. package/scripts/map-hash.mjs +3 -6
  42. package/scripts/mmo-bots.mjs +2 -2
  43. package/scripts/offline-proof-rules.d.mts +1 -0
  44. package/scripts/offline-proof-rules.mjs +22 -1
  45. package/scripts/online-rig.mjs +4 -4
  46. package/scripts/page-release/flow.d.mts +1 -0
  47. package/scripts/page-release/flow.mjs +6 -2
  48. package/scripts/page-release.mjs +5 -1
  49. package/scripts/physics-route.json +0 -71
  50. package/scripts/pins-catalogue.ts +103 -0
  51. package/scripts/pins-reuse.mjs +3 -1
  52. package/scripts/pins.ts +22 -14
  53. package/scripts/preview-grid.ts +203 -0
  54. package/scripts/road-preload-proof.mjs +167 -0
  55. package/scripts/server-release/publish.mjs +2 -2
  56. package/scripts/server-release/served-slug.d.mts +2 -0
  57. package/scripts/server-release/served-slug.mjs +10 -0
  58. package/scripts/server-release/sign.d.mts +1 -0
  59. package/scripts/server-release/sign.mjs +3 -7
  60. package/scripts/shard-components.mjs +0 -2
  61. package/scripts/shard-outputs.d.mts +8 -0
  62. package/scripts/shard-outputs.mjs +45 -11
  63. package/scripts/side-parity.d.mts +2 -1
  64. package/scripts/side-parity.mjs +25 -4
  65. package/scripts/test-amber.d.mts +1 -0
  66. package/scripts/test-amber.mjs +10 -0
  67. package/scripts/test-products.json +3 -3
  68. package/scripts/tracked-public.d.mts +1 -0
  69. package/scripts/tracked-public.mjs +17 -0
  70. package/src/cli/engine.mjs +8 -0
  71. package/src/client/app/bootRoute.ts +4 -1
  72. package/src/client/app/dropModal.ts +15 -2
  73. package/src/client/app/entry.ts +67 -11
  74. package/src/client/app/slugPath.ts +5 -0
  75. package/src/client/engine/audio/Audio.ts +20 -2
  76. package/src/client/engine/boot/bakedTextures.ts +3 -2
  77. package/src/client/engine/boot/bootTrace.ts +6 -1
  78. package/src/client/engine/boot/bytes.ts +4 -3
  79. package/src/client/engine/boot/clearDownloads.ts +1 -1
  80. package/src/client/engine/boot/contentRead.ts +4 -0
  81. package/src/client/engine/boot/dropNotice.ts +20 -6
  82. package/src/client/engine/boot/gpuFiles.ts +25 -2
  83. package/src/client/engine/boot/lastEnd.ts +8 -2
  84. package/src/client/engine/boot/shardPrefetch.ts +7 -1
  85. package/src/client/engine/boot/sw.ts +19 -0
  86. package/src/client/engine/core/Game.ts +11 -3
  87. package/src/client/engine/core/GpuRecovery.ts +7 -0
  88. package/src/client/engine/core/Volumetrics.ts +5 -0
  89. package/src/client/engine/core/assets.ts +27 -20
  90. package/src/client/engine/core/bootstrap.ts +1 -2
  91. package/src/client/engine/core/ktx2.ts +84 -11
  92. package/src/client/engine/explore/Compare.ts +2 -2
  93. package/src/client/engine/explore/TouchFly.ts +3 -5
  94. package/src/client/engine/input/dom.ts +12 -0
  95. package/src/client/engine/net/predictor.ts +6 -2
  96. package/src/client/engine/player/Player.ts +10 -2
  97. package/src/client/engine/player/TouchControls.ts +12 -4
  98. package/src/client/engine/pwa/sw.js +47 -8
  99. package/src/client/engine/render/drawCheck.ts +96 -0
  100. package/src/client/engine/saves/staleBuildNote.ts +46 -0
  101. package/src/client/engine/telemetry/browserErrors.ts +157 -20
  102. package/src/client/engine/telemetry/screenOutbox.ts +61 -0
  103. package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
  104. package/src/client/engine/ui/DeathFade.ts +99 -11
  105. package/src/client/engine/ui/ErrorModal.ts +13 -6
  106. package/src/client/engine/ui/Feedback.ts +2 -1
  107. package/src/client/engine/ui/Loading.ts +10 -6
  108. package/src/client/engine/ui/Map.ts +2 -1
  109. package/src/client/engine/ui/WeaponStrip.ts +2 -1
  110. package/src/client/engine/ui/backGuard.ts +104 -0
  111. package/src/client/engine/ui/hudAdapters.ts +30 -4
  112. package/src/client/engine/ui/loading.css +17 -0
  113. package/src/client/engine/ui/namePrompt.ts +6 -5
  114. package/src/client/engine/ui/styles/combat.css +12 -0
  115. package/src/client/engine/ui/styles/namePrompt.css +4 -2
  116. package/src/client/game/boot/audio.generated.ts +0 -294
  117. package/src/client/game/boot/bytes.generated.ts +0 -11
  118. package/src/client/game/boot/versions.generated.ts +0 -11
  119. package/src/client/game/compendium/keepsakes.ts +16 -6
  120. package/src/client/game/grapple/tool.ts +10 -7
  121. package/src/client/game/grid/cellLoading.ts +23 -12
  122. package/src/client/game/grid/cellScreens.ts +39 -74
  123. package/src/client/game/grid/liveSession.ts +40 -7
  124. package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
  125. package/src/client/game/grid/nearPlaceholderView.ts +9 -3
  126. package/src/client/game/grid/oneWayIn.ts +92 -27
  127. package/src/client/game/grid/pageEntry.ts +19 -0
  128. package/src/client/game/grid/pageShell.ts +1 -1
  129. package/src/client/game/grid/plotAudio.ts +114 -0
  130. package/src/client/game/grid/products.ts +55 -5
  131. package/src/client/game/grid/roadLookPlatform.ts +2 -2
  132. package/src/client/game/grid/session.ts +38 -22
  133. package/src/client/game/grid/spawnGround.ts +68 -0
  134. package/src/client/game/grid/voidLook.ts +29 -23
  135. package/src/client/game/loot/runtime.ts +3 -1
  136. package/src/client/game/mainMenu.ts +14 -6
  137. package/src/client/game/riding/hud.ts +6 -4
  138. package/src/client/game/session/finish.ts +17 -3
  139. package/src/client/game/session/play.ts +8 -2
  140. package/src/client/game/session/session.ts +4 -1
  141. package/src/client/game/shardfile/clientWorker.ts +41 -12
  142. package/src/client/game/shardfile/serverRoute.ts +10 -22
  143. package/src/client/game/slugPage.css +11 -0
  144. package/src/client/game/slugPage.ts +84 -0
  145. package/src/client/game/systems/viewmodel/heldView.ts +6 -3
  146. package/src/client/game/titleDeck.ts +55 -32
  147. package/src/client/host/online/doctor.ts +7 -6
  148. package/src/client/host/online/linkScreens.ts +16 -0
  149. package/src/client/host/online/release.ts +51 -5
  150. package/src/client/host/online/shell.ts +48 -27
  151. package/src/client/host/standalone/shell.ts +7 -3
  152. package/src/cook/game/audioReport.ts +57 -0
  153. package/src/cook/game/entryTotals.ts +26 -6
  154. package/src/cook/game/installedRuntimeReads.ts +3 -0
  155. package/src/server/engine/sim/respawn.ts +6 -1
  156. package/src/server/engine/sim.ts +3 -0
  157. package/src/server/game/grid/simulation.ts +35 -0
  158. package/src/server/game/loot/harvest.ts +2 -0
  159. package/src/server/game/loot/keepsakeProgression.ts +40 -0
  160. package/src/server/game/loot/playerOwned.ts +5 -1
  161. package/src/server/game/plugin/simulation.ts +4 -0
  162. package/src/server/game/population/nativeBake.ts +2 -1
  163. package/src/server/game/quest/chapterRecords.ts +2 -0
  164. package/src/server/game/quest/serverChapters.ts +4 -0
  165. package/src/server/game/quest/serverDoors.ts +11 -5
  166. package/src/server/game/roomRespawn.ts +4 -0
  167. package/src/server/game/shardfile/installedSides.ts +18 -0
  168. package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
  169. package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
  170. package/src/server/host/bake/headlessWorker.ts +5 -1
  171. package/src/server/host/dedicated/cellHost.ts +98 -29
  172. package/src/server/host/dedicated/cellProtocol.ts +11 -1
  173. package/src/server/host/dedicated/cellWorker.ts +9 -3
  174. package/src/server/host/dedicated/crossing.ts +6 -2
  175. package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
  176. package/src/server/host/dedicated/gridCells.ts +52 -9
  177. package/src/server/host/dedicated/main.ts +31 -12
  178. package/src/server/host/dedicated/placementFile.ts +72 -0
  179. package/src/server/host/dedicated/releaseFile.ts +17 -10
  180. package/src/server/host/dedicated/roadRoom.ts +21 -5
  181. package/src/server/host/dedicated/workerTable.ts +13 -1
  182. package/src/server/host/dedicated/world.ts +81 -9
  183. package/src/server/host/headlessRuntime.ts +10 -5
  184. package/src/server/host/installers.ts +62 -0
  185. package/src/server/host/openWorld.ts +59 -0
  186. package/src/server/host/ropeDecks.ts +2 -0
  187. package/src/server/host/standalone/cellWorld.ts +25 -19
  188. package/src/server/host/standalone/fallFloor.ts +2 -2
  189. package/src/server/host/standalone/gridServer.ts +7 -4
  190. package/src/server/host/standalone/roadWorld.ts +41 -4
  191. package/src/shared/engine/audio/bootAudio.ts +33 -0
  192. package/src/shared/engine/level/spec.ts +3 -3
  193. package/src/shared/engine/net/acts.ts +3 -0
  194. package/src/shared/engine/physics/query.ts +27 -0
  195. package/src/shared/engine/physics/terrain.ts +19 -28
  196. package/src/shared/engine/saves/saves.lock.json +15 -0
  197. package/src/shared/engine/sim/actRoutes.ts +2 -0
  198. package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
  199. package/src/shared/game/grid/catalogue.ts +12 -5
  200. package/src/shared/game/grid/catalogueSlot.ts +11 -0
  201. package/src/shared/game/grid/farProxy.ts +6 -5
  202. package/src/shared/game/grid/pageMode.ts +1 -1
  203. package/src/shared/game/grid/roadLayout.ts +26 -3
  204. package/src/shared/game/grid/singleplayer.json +0 -13
  205. package/src/shared/game/grid/voidFloor.ts +122 -0
  206. package/src/shared/game/strings.ts +15 -0
  207. package/src/shared/host/standalone/netInput.ts +2 -1
@@ -3,7 +3,7 @@ export interface State {judged:number[];dispatched:string[]}
3
3
  export interface Verdict {kind:'green'|'red'|'superseded'|'dispatch';run:Run;from?:string|null;by?:string}
4
4
  export interface Pane {pane_id:string;label?:string;cwd?:string;foreground_cwd?:string}
5
5
  export interface Io {
6
- repo:string;state:string;runs:()=>Run[];failed:(id:number)=>string[];ambers:(id:number)=>{file:string;ms:number;budget:number}[];tip:()=>string;
6
+ repo:string;state:string;runs:()=>Run[];failed:(id:number)=>string[];annotations:(id:number)=>string;tip:()=>string;
7
7
  commits:(from:string|null,to:string)=>string[];contains:(ancestor:string,descendant:string)=>boolean;
8
8
  receipts:()=>string;receipt:(line:string)=>void;panes:()=>Pane[];send:(pane:string,text:string)=>boolean;dispatch:()=>void;
9
9
  }
@@ -14,14 +14,15 @@
14
14
  // (~/.cache/wildshard/main-watch.json) keeps the judged run ids, so a run is reported once however often this runs.
15
15
  // A green run that carries AMBER files (J295: a test file over its time budget, scripts/test-amber.mjs) also gives
16
16
  // one `main AMBER <sha> <file> <ms>/<budget>` receipt per file: the coordinator hands each out as a queue-skipping
17
- // fix row the same day (meta HOW-WE-BUILD-PLAN.md).
17
+ // fix row the same day (meta HOW-WE-BUILD-PLAN.md). AUDIO AU6 (J303): a shard whose audio is over 6 MB gives the same
18
+ // kind of receipt, `main AMBER <sha> audio <shard> <tier> <MB>/6.00 MB`, from the cook report's test; never a red main.
18
19
  import {execFileSync} from 'node:child_process';
19
20
  import {appendFileSync,existsSync,mkdirSync,readFileSync,renameSync,rmSync,writeFileSync} from 'node:fs';
20
21
  import {homedir} from 'node:os';
21
22
  import {dirname,join,resolve} from 'node:path';
22
23
  import {setTimeout} from 'node:timers/promises';
23
24
  import {pathToFileURL} from 'node:url';
24
- import {AMBER,parseAmber} from './test-amber.mjs';
25
+ import {AMBER,parseAmber,parseAudioAmber} from './test-amber.mjs';
25
26
 
26
27
  export const REPO='project-wildshard/engine';
27
28
  const KEEP=500;
@@ -134,10 +135,10 @@ export function liveIo(env=process.env){
134
135
  .filter((/** @type {Run} */row)=>row.event==='push'||row.event==='workflow_dispatch')),
135
136
  failed:(/** @type {number} */id)=>/** @type {{name:string,conclusion:string|null}[]} */(JSON.parse(run('gh',['api',`repos/${repo}/actions/runs/${id}/jobs?per_page=100`])).jobs)
136
137
  .filter(job=>job.conclusion==='failure'||job.conclusion==='timed_out').map(job=>job.name),
137
- // The AMBER warnings on a run's blocking tests and its timings job; quarantine's are its own (J193).
138
- ambers:(/** @type {number} */id)=>parseAmber(/** @type {{id:number,name:string}[]} */(JSON.parse(run('gh',['api',`repos/${repo}/actions/runs/${id}/jobs?per_page=100`])).jobs)
138
+ // The annotations (their AMBER lines) on a run's blocking tests and its timings job; quarantine's are its own (J193).
139
+ annotations:(/** @type {number} */id)=>/** @type {{id:number,name:string}[]} */(JSON.parse(run('gh',['api',`repos/${repo}/actions/runs/${id}/jobs?per_page=100`])).jobs)
139
140
  .filter(job=>job.name.startsWith('tests')||job.name==='timings')
140
- .map(job=>/** @type {{message:string}[]} */(JSON.parse(run('gh',['api',`repos/${repo}/check-runs/${job.id}/annotations?per_page=100`]))).map(row=>row.message).join('\n')).join('\n')),
141
+ .map(job=>/** @type {{message:string}[]} */(JSON.parse(run('gh',['api',`repos/${repo}/check-runs/${job.id}/annotations?per_page=100`]))).map(row=>row.message).join('\n')).join('\n'),
141
142
  tip:()=>{run('git',['fetch','--quiet','origin','main']);return run('git',['rev-parse','origin/main']).trim();},
142
143
  commits:(/** @type {string|null} */from,/** @type {string} */to)=>{
143
144
  try{return run('git',['rev-list','--max-count=200',from===null?to:`${from}..${to}`]).trim().split('\n').filter(Boolean);}catch{return [to];}
@@ -185,8 +186,11 @@ export function sweep(io,hint={}){
185
186
  if(verdict.kind==='green'){
186
187
  lines.push(`main green ${short(run.head_sha)} (run ${run.id}; ${range}; landed by ${named})`);
187
188
  /** @type {{file:string,ms:number,budget:number}[]} */let ambers=[];
188
- try{ambers=io.ambers(run.id);}catch(error){lines.push(`main AMBER ${short(run.head_sha)} unknown (run ${run.id}; its annotations were unreadable: ${error instanceof Error?error.message.split('\n')[0]:String(error)})`);}
189
+ /** @type {ReturnType<typeof parseAudioAmber>} */let audio=[];
190
+ try{const text=io.annotations(run.id);ambers=parseAmber(text);audio=parseAudioAmber(text);}catch(error){lines.push(`main AMBER ${short(run.head_sha)} unknown (run ${run.id}; its annotations were unreadable: ${error instanceof Error?error.message.split('\n')[0]:String(error)})`);}
189
191
  for(const row of ambers)lines.push(`main AMBER ${short(run.head_sha)} ${row.file} ${row.ms}/${row.budget} (run ${run.id}; J295: a queue-skipping fix row today; red at ${AMBER.redFactor}x, after ${AMBER.redAfterHours} h or ${AMBER.redAfterRuns} amber main runs)`);
192
+ const mb=(/** @type {number} */bytes)=>(bytes/1e6).toFixed(2);
193
+ for(const row of audio)lines.push(`main AMBER ${short(run.head_sha)} audio ${row.shard} ${row.tier} ${mb(row.bytes)} MB/${mb(row.budget)} MB (run ${run.id}; J303${row.level==='red'?`, over the ${mb(row.red)} MB red line`:''}: its AUDIO-PLAN source pass; never a red main)`);
190
194
  }
191
195
  else{
192
196
  const failed=io.failed(run.id).join(' | ')||'see the run',url=`https://github.com/${io.repo}/actions/runs/${run.id}`,panes=io.panes();
@@ -6,6 +6,7 @@ import { createHash } from 'node:crypto';
6
6
  import { createRequire } from 'node:module';
7
7
  import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
8
8
  import { join, relative, resolve } from 'node:path';
9
+ import { shardSourceDir, shardSourceFolders } from './shard-outputs.mjs';
9
10
 
10
11
  // Sharp resolves from this file: engine's own devDependency here, the consumer's through the optional
11
12
  // `sharp` peer when a shard repo or sharddev runs this script from its install of engine.
@@ -125,13 +126,9 @@ export function mapTilesHash(shardDir) {
125
126
  return hash.digest('hex');
126
127
  }
127
128
 
128
- /** Every shard folder with a shardfile project. @param {string} repoRoot @returns {{slug: string, dir: string}[]} */
129
+ /** Every shard folder with a shardfile project: under src/shards, or a single-shard repo's src/ (SA42). @param {string} repoRoot @returns {{slug: string, dir: string}[]} */
129
130
  export function mapShards(repoRoot) {
130
- const shards = resolve(repoRoot, 'src/shards');
131
- return readdirSync(shards, { withFileTypes: true })
132
- .filter((entry) => entry.isDirectory() && existsSync(join(shards, entry.name, 'shard.config.ts')))
133
- .map((entry) => ({ slug: entry.name, dir: join(shards, entry.name) }))
134
- .sort((a, b) => a.slug.localeCompare(b.slug));
131
+ return shardSourceFolders(repoRoot, ['shard.config.ts']).map((slug) => ({ slug, dir: shardSourceDir(repoRoot, slug) }));
135
132
  }
136
133
 
137
134
  /** Publish one official map bake and its existing authored-product companion together.
@@ -96,7 +96,7 @@ mkdirSync(tree, { recursive: true });
96
96
  const source = serverFrom ?? release.engineBuild;
97
97
  if (serverFrom !== undefined) try { git(['merge-base', '--is-ancestor', release.engineBuild, serverFrom]); } catch { throw new Error(`--server-from ${serverFrom} does not descend from the release's ${release.engineBuild}`); }
98
98
  execFileSync('tar', ['-x', '-C', tree], { input: git(['archive', source]) });
99
- for (const name of ['mmoBotsEntry.ts', 'mmoBotsGuard.ts']) copyFileSync(join(ROOT, 'test/fixtures/dedicated', name), join(tree, 'test/fixtures/dedicated', name));
99
+ for (const name of ['mmoBotsEntry.ts', 'mmoBotsGuard.ts', 'mmoBotsStats.ts']) copyFileSync(join(ROOT, 'test/fixtures/dedicated', name), join(tree, 'test/fixtures/dedicated', name));
100
100
  let begun = performance.now();
101
101
  // CI=1 keeps the install non-interactive; --config.ci=false keeps the global store on, which pnpm drops under ci (GVS G9)
102
102
  execFileSync('pnpm', ['install', '--frozen-lockfile', '--prefer-offline', '--ignore-scripts', '--reporter=silent', '--config.ci=false'], { cwd: tree, stdio: 'inherit', env: { ...process.env, CI: '1' } });
@@ -232,7 +232,7 @@ const report = { ...JSON.parse(readFileSync(result, 'utf8')), mode, exit: code,
232
232
  ...(full.length === 0 ? {} : { server: { windows: full.length, worstP95: Math.max(...full.map(row => row.p95)), meanP95: Number((full.reduce((sum, row) => sum + row.p95, 0) / full.length).toFixed(3)),
233
233
  max: Math.max(...full.map(row => row.max)), drops: full.reduce((sum, row) => sum + row.drops, 0), minTicksPerSecond: Math.min(...full.map(row => row.ticksPerSecond)), rssMB: Math.round(Math.max(...full.map(row => row.rss)) / 1048576) } }) };
234
234
  writeFileSync(join(work, 'report.json'), `${JSON.stringify(report, null, 2)}\n`);
235
- note({ step: 'done', exit: code, seated: report.seated, steady: report.steady, walked: report.walked, sawEveryone: report.sawEveryone, server: report.server ?? null, report: join(work, 'report.json') });
235
+ note({ step: 'done', exit: code, seated: report.seated, steady: report.steady, walked: report.walked, sawEveryone: report.sawEveryone, interArrivalMs: report.interArrivalMs ?? null, server: report.server ?? null, report: join(work, 'report.json') });
236
236
  process.exitCode = Number(code);
237
237
  } finally {
238
238
  await stopRoom();
@@ -15,6 +15,7 @@ export const RAW_STRINGS: readonly string[];
15
15
  export const CRITICAL_PHASES: readonly string[];
16
16
  export function mayFail(url: string): boolean;
17
17
  export function pathOf(url: string): string;
18
+ export function textureForm(path: string): { name: string; form: 'img' | 'ktx2' } | undefined;
18
19
  export function judge(run: {
19
20
  shard: string; channel: 'staging' | 'preview'; mode: string; entry: string; rows: readonly RequestRow[];
20
21
  samples: readonly ScreenSample[]; outcome: Outcome; warm?: ReadonlySet<string>; layout?: boolean; walkthrough?: boolean;
@@ -10,7 +10,7 @@ export const DECK_SHARDS = Object.freeze([
10
10
  { slug: 'pastel-plain', card: 'Pastel Plain' }, { slug: 'ink-cel-valley', card: 'Ink & Cel Valley' },
11
11
  ]);
12
12
  /** Open Plots have no deck card (the open-plots audit): a player reaches them by a deep link with Developer on, or a resume. */
13
- export const OPEN_PLOTS = Object.freeze(['open-plot-showcase-template', 'open-plot-night-market', 'open-plot-mosslight-ruins']);
13
+ export const OPEN_PLOTS = Object.freeze(['open-plot-thin-ice', 'open-plot-night-market', 'open-plot-mosslight-ruins']);
14
14
  /** Every shard the proof covers, in run order. */
15
15
  export const ALL_SHARDS = Object.freeze([...DECK_SHARDS.map(shard => shard.slug), ...OPEN_PLOTS]);
16
16
 
@@ -45,6 +45,16 @@ export function mayFail(url) {
45
45
  || host === 'api.wildshard.io' || host.endsWith('.sentry.io') || host.endsWith('.ingest.sentry.io');
46
46
  }
47
47
 
48
+ /** OF17: a texture's name in either form, `/assets/<name>.<webp|jpg|png>` (the image) or `/assets/gpu/<name>-<hash8>.ktx2`
49
+ * (its KTX2 stand-in), or undefined for any other path. @param {string} path
50
+ * @returns {{ name: string, form: 'img' | 'ktx2' } | undefined} */
51
+ export function textureForm(path) {
52
+ const ktx2 = /^\/assets\/gpu\/(.+)-[0-9a-f]{8}\.ktx2$/u.exec(path);
53
+ if (ktx2?.[1] !== undefined) return { name: ktx2[1], form: 'ktx2' };
54
+ const image = /^\/assets\/(?!gpu\/)(.+)\.(?:webp|jpe?g|png)$/u.exec(path);
55
+ return image?.[1] === undefined ? undefined : { name: image[1], form: 'img' };
56
+ }
57
+
48
58
  /** A URL's path, the key the warm visit's read set holds. @param {string} url */
49
59
  export const pathOf = url => new URL(url).pathname;
50
60
 
@@ -111,6 +121,17 @@ export function judge(run) {
111
121
  if (run.outcome !== 'play') out.push({ shard, rule: 'walkthrough-not-in-world', detail: run.outcome });
112
122
  if (!samples.some(sample => sample.player && sample.failCard !== '')) out.push({ shard, rule: 'walkthrough-no-connection-card' });
113
123
  }
124
+ // 9. OF17: one texture form per device and tier. An image the warm visit read only as its KTX2 stand-in is never held.
125
+ if (warm !== undefined) {
126
+ /** @type {Record<'img' | 'ktx2', Set<string>>} */
127
+ const read = { img: new Set(), ktx2: new Set() };
128
+ for (const path of warm) { const texture = textureForm(path); if (texture !== undefined) read[texture.form].add(texture.name); }
129
+ for (const row of rows) {
130
+ const texture = row.origin === 'page' ? textureForm(pathOf(row.url)) : undefined;
131
+ if (texture?.form === 'img' && read.ktx2.has(texture.name) && !read.img.has(texture.name))
132
+ out.push({ shard, rule: 'texture-form-not-warm', url: row.url, detail: `${row.phase}/${row.step}: the warm visit read its KTX2 stand-in` });
133
+ }
134
+ }
114
135
  return out;
115
136
  }
116
137
 
@@ -46,11 +46,11 @@ export async function intoWorld(page) {
46
46
 
47
47
  /** `pgBin` 'memory:' keeps the saves in the server's memory, for a proof that never reads them back (voice-proof.mjs): no Postgres.
48
48
  * `more` are other shards the release names, `cells` the server's `WORLD_CELLS` (default `shard`), and `socket` the address the
49
- * release names when a proof puts its own front door before the server (grid-gate-proof.mjs). `crossing` sets `WORLD_CROSSING=worker`
50
- * (GC15): each worker hosts the road between its cells from the grid pack the bake left in this checkout (grid-crossing-walk-proof.mjs),
49
+ * release names when a proof puts its own front door before the server (grid-gate-proof.mjs). `crossing` (on by default, GC35 / J322; false sets
50
+ * `WORLD_CROSSING=off`, a bench's lone cells) is `WORLD_CROSSING=worker` (GC15): each worker hosts the road between its cells from the grid pack the bake left in this checkout (grid-crossing-walk-proof.mjs),
51
51
  * and `workers` sets `WORLD_WORKERS` (the rig's release is production's, 4 by default; staging runs 2).
52
52
  * @param {{ dist: string, nextDist?: string, work: string, keyFile: string, pgBin: string, pgData: string, shard?: string, seats?: number, more?: string[], cells?: string, socket?: string, crossing?: boolean, workers?: number }} options */
53
- export async function openRig({ dist, nextDist = '', work, keyFile, pgBin, pgData, shard = 'driftwood-isle', seats, more = [], cells = shard, socket = `ws://127.0.0.1:${String(WORLD_PORT)}/`, crossing = false, workers }) {
53
+ export async function openRig({ dist, nextDist = '', work, keyFile, pgBin, pgData, shard = 'driftwood-isle', seats, more = [], cells = shard, socket = `ws://127.0.0.1:${String(WORLD_PORT)}/`, crossing = true, workers }) {
54
54
  const memory = pgBin === 'memory:';
55
55
  const key = JSON.parse(readFileSync(keyFile, 'utf8')), build = buildOf(dist), nextBuild = nextDist === '' ? '' : buildOf(nextDist), DATABASE = memory ? 'memory:' : database('saves_online');
56
56
  mkdirSync(work, { recursive: true });
@@ -81,7 +81,7 @@ export async function openRig({ dist, nextDist = '', work, keyFile, pgBin, pgDat
81
81
 
82
82
  const world = (running = build) => {
83
83
  const room = spawn(process.execPath, [join(server, 'main.mjs')], { cwd: ROOT, stdio: ['ignore', 'pipe', 'pipe'],
84
- env: { ...process.env, RELEASE_URL: `http://127.0.0.1:${String(RELEASE_PORT)}/release.json`, RELEASE_PUBLIC_KEY: key.public, PACK_ORIGIN: `file://${origin}/`, PACK_CACHE: join(work, 'packs'), DATABASE_URL: DATABASE, SEAT_SECRET: 'online-proof', HOST: '127.0.0.1', PORT: String(WORLD_PORT), ALLOWED_ORIGINS: `http://127.0.0.1:${String(PAGE_PORT)}`, WILDSHARD_BUILD: running, WORLD_CELLS: cells, RELEASE_POLL_MS: '500', GRACE_MS: '6000', ...seats === undefined ? {} : { WORLD_SEATS: String(seats) }, ...crossing ? { WORLD_CROSSING: 'worker' } : {}, ...workers === undefined ? {} : { WORLD_WORKERS: String(workers) } } });
84
+ env: { ...process.env, RELEASE_URL: `http://127.0.0.1:${String(RELEASE_PORT)}/release.json`, RELEASE_PUBLIC_KEY: key.public, PACK_ORIGIN: `file://${origin}/`, PACK_CACHE: join(work, 'packs'), DATABASE_URL: DATABASE, SEAT_SECRET: 'online-proof', HOST: '127.0.0.1', PORT: String(WORLD_PORT), ALLOWED_ORIGINS: `http://127.0.0.1:${String(PAGE_PORT)}`, WILDSHARD_BUILD: running, WORLD_CELLS: cells, RELEASE_POLL_MS: '500', GRACE_MS: '6000', ...seats === undefined ? {} : { WORLD_SEATS: String(seats) }, WORLD_CROSSING: crossing ? 'worker' : 'off', ...workers === undefined ? {} : { WORLD_WORKERS: String(workers) } } });
85
85
  room.stdout.pipe(log, { end: false }); room.stderr.pipe(log, { end: false });
86
86
  return room;
87
87
  };
@@ -48,6 +48,7 @@ export interface Deps {
48
48
  pollMs?: number;
49
49
  afterStagingProofs?: boolean;
50
50
  releaseKey?: string;
51
+ catalogue?: string;
51
52
  }
52
53
  export const PACKS_ORIGIN: string;
53
54
  export const RELEASE_PUBLIC_KEY: string;
@@ -106,6 +106,8 @@ export class RefusedError extends Error {
106
106
  * @property {number} [pollMs]
107
107
  * @property {boolean} [afterStagingProofs] Production go-live: the strict staging proofs passed on this build.
108
108
  * @property {string} [releaseKey] Defaults to RELEASE_PUBLIC_KEY; tests sign with their own.
109
+ * @property {string} [catalogue] Preview only (SA35): the catalogue the page bakes, staging's borrowed grid (scripts/preview-grid.ts);
110
+ * default the pinned `test/pins/catalogue.json`.
109
111
  */
110
112
 
111
113
  const sha256 = (/** @type {Uint8Array} */ bytes) => createHash('sha256').update(bytes).digest('hex');
@@ -136,13 +138,14 @@ export async function runPhase(phase, deps) {
136
138
  if (deps.git.head() !== deps.build) refuse(`HEAD ${deps.git.head()} is not build ${deps.build}`);
137
139
  if (!deps.git.clean()) refuse('the release tree is not clean (one clean clone per channel)');
138
140
  if (!(deps.manifest.saveEpoch >= 1)) refuse('save-epoch.json must be at least 1');
141
+ if (deps.catalogue !== undefined && !channel.solo) refuse(`--catalogue is preview's (SA35): ${channel.channel} bakes the pinned catalogue`);
139
142
  deps.log(`${channel.channel} ${phase} ${deps.build} v${deps.manifest.version} epoch ${deps.manifest.saveEpoch} on ${deps.host.name}${dry ? ' (dry run)' : ''}`);
140
143
 
141
144
  if (phase === 'build') {
142
145
  const env = buildEnv(channel, deps);
143
146
  for (const line of deps.host.describe('prepare', context)) plan(line);
144
147
  if (!dry) await deps.host.prepare(context);
145
- plan(`run pnpm build:game with ${channel.solo ? 'no release file (solo)' : `WILDSHARD_RELEASE_URL=${env.WILDSHARD_RELEASE_URL}`} WS_BUILD_ID=${deps.build} WS_CHANNEL=${channel.channel}`);
148
+ plan(`run pnpm build:game with ${channel.solo ? 'no release file (solo)' : `WILDSHARD_RELEASE_URL=${env.WILDSHARD_RELEASE_URL}`} WILDSHARD_CATALOGUE=${env.WILDSHARD_CATALOGUE} WS_BUILD_ID=${deps.build} WS_CHANNEL=${channel.channel}`);
146
149
  if (!dry) deps.run('pnpm', ['build:game'], {...env, ...deps.host.buildEnv(context)});
147
150
  // PAGE-SIZE PZ4: build:game splits the page (dist/) from its content (dist-content/). No channel stamps a contentBase
148
151
  // yet, so each page still serves its own content: join the two before packaging, until PZ8 ships the split.
@@ -247,7 +250,8 @@ export async function runPhase(phase, deps) {
247
250
  /** @param {ChannelConfig} channel @param {Deps} deps @returns {Record<string, string>} */
248
251
  export function buildEnv(channel, deps) {
249
252
  const common = {
250
- WS_BUILD_ID: deps.build, WILDSHARD_CATALOGUE: 'test/pins/catalogue.json',
253
+ // SA35: preview bakes the grid it borrowed from staging when the workflow names one; staging and production bake the pin.
254
+ WS_BUILD_ID: deps.build, WILDSHARD_CATALOGUE: (channel.solo ? deps.catalogue : undefined) ?? 'test/pins/catalogue.json',
251
255
  WS_PREVIOUS_DEPLOY_ORIGIN: channel.origin, WS_RELEASE: '1', WS_CHANNEL: channel.channel,
252
256
  // API-CLOUDFLARE AC11: errors, telemetry and the inbox go to the api-server Worker on every channel.
253
257
  VITE_API_ORIGIN: API_ORIGIN,
@@ -12,6 +12,8 @@
12
12
  // --after-staging-proofs production go-live: the strict staging proofs passed on this exact build
13
13
  // --content upload: publish the page's content set to packs.wildshard.io first (PAGE-SIZE PZ2,
14
14
  // page-release/content.mjs); off until PZ4 and PZ6 stamp contentBase into the page
15
+ // --catalogue=<file> preview build: bake this catalogue, the grid borrowed from staging (SHARD-AUTHORING SA35,
16
+ // scripts/preview-grid.ts); default test/pins/catalogue.json. Refused on staging and production
15
17
  //
16
18
  // The flow and its gates are scripts/page-release/flow.mjs; the page hosts are scripts/page-release/hosts/*.mjs.
17
19
  // Phase results go to <root>/tmp/page-release/<channel>-<sha>.json, which the next phase reads.
@@ -31,7 +33,7 @@ const value = (/** @type {string} */ name) => flag(name)?.split('=').slice(1).jo
31
33
  const [channel, phaseList] = args.filter(arg => !arg.startsWith('--'));
32
34
  const hostName = value('host') ?? 'workers';
33
35
  if (channel === undefined || phaseList === undefined || hostName !== 'workers') {
34
- console.error('usage: node scripts/page-release.mjs <preview|staging|production> <build|upload|check|go-live>[,...] [--host=workers] [--root=<dir>] [--dry-run] [--wait=<minutes>] [--after-staging-proofs] [--content]');
36
+ console.error('usage: node scripts/page-release.mjs <preview|staging|production> <build|upload|check|go-live>[,...] [--host=workers] [--root=<dir>] [--dry-run] [--wait=<minutes>] [--after-staging-proofs] [--content] [--catalogue=<file>]');
35
37
  process.exit(2);
36
38
  }
37
39
  const git = (/** @type {string[]} */ argv, /** @type {string} */ cwd) => execFileSync('git', argv, {cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe']}).trim();
@@ -90,6 +92,8 @@ try {
90
92
  dryRun: flag('dry-run') !== undefined,
91
93
  waitMs: Number(value('wait') ?? 45) * 60_000,
92
94
  afterStagingProofs: flag('after-staging-proofs') !== undefined,
95
+ // the build runs in `root`, so a relative path is the caller's
96
+ ...(value('catalogue') === undefined ? {} : {catalogue: resolve(value('catalogue') ?? '')}),
93
97
  });
94
98
  if (refusals.length > 0) log(`DRY-RUN ${channel} ${phase}: ${refusals.length} gate(s) would refuse today`);
95
99
  }
@@ -4325,76 +4325,5 @@
4325
4325
  "timeout": 180,
4326
4326
  "notes": "OP20: provisional OP3 scaffold route, south entry along the avenue and full plaza perimeter on tile seams, then south approach. Continuous fixed-step walking; no hovering or per-waypoint teleport. Not yet walked or qualified against the future Opus theme geometry; its visual owner must adapt and run the maintained route before activation closeout."
4327
4327
  }
4328
- ],
4329
- "open-plot-showcase-template": [
4330
- {
4331
- "name": "road-avenue-plaza-scaffold",
4332
- "start": {
4333
- "x": 0,
4334
- "z": -245,
4335
- "y": 0.2,
4336
- "yaw": 3.141592653589793
4337
- },
4338
- "waypoints": [
4339
- {
4340
- "x": 0,
4341
- "z": -220
4342
- },
4343
- {
4344
- "x": 0,
4345
- "z": -187.5
4346
- },
4347
- {
4348
- "x": 0,
4349
- "z": -125
4350
- },
4351
- {
4352
- "x": 0,
4353
- "z": -62.5
4354
- },
4355
- {
4356
- "x": -62.5,
4357
- "z": -62.5
4358
- },
4359
- {
4360
- "x": -62.5,
4361
- "z": 0
4362
- },
4363
- {
4364
- "x": -62.5,
4365
- "z": 62.5
4366
- },
4367
- {
4368
- "x": 0,
4369
- "z": 62.5
4370
- },
4371
- {
4372
- "x": 62.5,
4373
- "z": 62.5
4374
- },
4375
- {
4376
- "x": 62.5,
4377
- "z": 0
4378
- },
4379
- {
4380
- "x": 62.5,
4381
- "z": -62.5
4382
- },
4383
- {
4384
- "x": 0,
4385
- "z": -62.5
4386
- },
4387
- {
4388
- "x": 0,
4389
- "z": -50
4390
- },
4391
- {
4392
- "x": 0,
4393
- "z": -62.5
4394
- }
4395
- ],
4396
- "timeout": 180,
4397
- "notes": "OP5: provisional OP3 scaffold route, south entry along the avenue and full plaza perimeter on tile seams, then south approach. Continuous fixed-step walking; no hovering or per-waypoint teleport. Not yet walked or qualified against the future Opus theme geometry; its visual owner must adapt and run the maintained route before activation closeout."
4398
- }
4399
4328
  ]
4400
4329
  }
@@ -0,0 +1,103 @@
1
+ // SHARD-DELETE DEL9 (meta J310): nothing engine pins or releases names a shard the API deleted. A deleted slug leaves
2
+ // `GET /api/catalogue`, so every slug engine names has to be one that list holds:
3
+ // - `test/pins/shardfiles.json`, the pinned heads every build installs;
4
+ // - `E7_STAGING_SHARDS` and `E7_PRODUCTION_SHARDS`, the GitHub variables a server release reads (empty: the default pair);
5
+ // - the pinned catalogue document's shards, placements and grid cells.
6
+ // Names compare by the folder a slug serves under (`template` pins as `_template`), as the release and the grid name them.
7
+ //
8
+ // node scripts/pins-catalogue.ts check CI (job 1, before install): the pins and both release variables against the live
9
+ // GET /api/catalogue; the offline half is test/pins-catalogue.test.ts
10
+ // `pins.ts refresh` refuses the same way before it writes a pin. Node built-ins only, so CI runs it before `pnpm install`.
11
+ import { readFileSync } from 'node:fs';
12
+ import { resolve } from 'node:path';
13
+ import { pathToFileURL } from 'node:url';
14
+ import { DEFAULT_SERVER_SHARDS, servedSlug } from './server-release/served-slug.mjs';
15
+
16
+ const PINS = 'test/pins/shardfiles.json';
17
+
18
+ /** One slug engine names that the catalogue doesn't list, and what named it. */
19
+ export interface Unlisted { readonly slug: string; readonly source: string }
20
+
21
+ /** The slugs a `GET /api/catalogue` body lists. A body with no shards array throws: an empty list must never pass for one. */
22
+ export function catalogueSlugs(body: unknown): ReadonlySet<string> {
23
+ const shards = (body as { shards?: unknown } | null)?.shards;
24
+ if (!Array.isArray(shards)) throw new Error('GET /api/catalogue: expected { shards: [...] }');
25
+ return new Set(shards.map((row: unknown) => {
26
+ const slug = (row as { slug?: unknown } | null)?.slug;
27
+ if (typeof slug !== 'string' || slug === '') throw new Error('GET /api/catalogue: a shard row has no slug');
28
+ return servedSlug(slug);
29
+ }));
30
+ }
31
+
32
+ /** A release variable's slugs; unset or empty selects the release's default pair, as `publish.mjs` does. */
33
+ export function releaseNames(value: string | undefined): readonly string[] {
34
+ const names = value === undefined || value.trim() === '' ? DEFAULT_SERVER_SHARDS : value;
35
+ return names.split(',').map(name => name.trim()).filter(Boolean);
36
+ }
37
+
38
+ /** The slugs a pins file names. */
39
+ export function pinnedSlugs(pins: unknown): readonly string[] {
40
+ const shards = (pins as { shards?: unknown } | null)?.shards;
41
+ if (!Array.isArray(shards)) throw new Error('test/pins/shardfiles.json: expected { shards: [...] }');
42
+ return shards.map((row: unknown) => {
43
+ const slug = (row as { slug?: unknown } | null)?.slug;
44
+ if (typeof slug !== 'string' || slug === '') throw new Error('test/pins/shardfiles.json: a pin has no slug');
45
+ return slug;
46
+ });
47
+ }
48
+
49
+ /** The slugs a catalogue document (`GET /api/catalogue.json`) names in its shards, placements and grid cells. */
50
+ export function documentSlugs(document: unknown): readonly string[] {
51
+ const doc = document as { shards?: { slug: string }[]; placements?: { slug: string }[]; grid?: { cells?: { slug: string }[] } };
52
+ return [...doc.shards ?? [], ...doc.placements ?? [], ...doc.grid?.cells ?? []].map(row => row.slug);
53
+ }
54
+
55
+ /** Every named slug the catalogue doesn't list, once per source and slug, in the order named. */
56
+ export function unlistedSlugs(listed: ReadonlySet<string>, named: Readonly<Record<string, readonly string[]>>): readonly Unlisted[] {
57
+ const seen = new Set<string>();
58
+ return Object.entries(named).flatMap(([source, slugs]) => slugs.flatMap(slug => {
59
+ const key = `${source}\0${slug}`;
60
+ if (listed.has(servedSlug(slug)) || seen.has(key)) return [];
61
+ seen.add(key);
62
+ return [{ slug, source }];
63
+ }));
64
+ }
65
+
66
+ /** One line per unlisted slug, naming who still names it and what to do. An API document is the API's to fix, not engine's. */
67
+ export function unlistedMessage(rows: readonly Unlisted[]): string {
68
+ return rows.map(({ slug, source }) => {
69
+ const fix = source.startsWith('GET ') ? 'the API disagrees with itself; report it to api-server' : `drop it from ${source}`;
70
+ return `${source} names ${slug}, which GET /api/catalogue no longer lists (deleted, DEL9): ${fix}`;
71
+ }).join('\n');
72
+ }
73
+
74
+ /** What engine names that a release reads, beside the pins: the default pair and each E7 shards variable `env` sets to a list (an
75
+ * unset GitHub variable reaches a step as '', which is the default pair, already named). */
76
+ export function releaseNamed(env: NodeJS.ProcessEnv): Record<string, readonly string[]> {
77
+ const named: Record<string, readonly string[]> = { 'the default release shards (server-release/served-slug.mjs)': releaseNames(undefined) };
78
+ for (const name of ['E7_STAGING_SHARDS', 'E7_PRODUCTION_SHARDS']) if ((env[name] ?? '').trim() !== '') named[name] = releaseNames(env[name]);
79
+ return named;
80
+ }
81
+
82
+ /** CI's online half of DEL9: the pins and both release variables name only slugs the live `GET /api/catalogue` lists. A catalogue the
83
+ * API can't serve is a warning, not a red: an API outage isn't a deleted shard. */
84
+ async function check(): Promise<void> {
85
+ const { WILDSHARD_API: api = 'https://api.wildshard.io' } = process.env;
86
+ const catalogue = await fetch(`${api}/api/catalogue`, { signal: AbortSignal.timeout(30_000) })
87
+ .then(response => { if (!response.ok) throw new Error(`HTTP ${response.status}`); return response.json() as Promise<unknown>; })
88
+ .catch((error: unknown) => error instanceof Error ? error : new Error(String(error)));
89
+ let listed: ReadonlySet<string> | Error;
90
+ try { listed = catalogue instanceof Error ? catalogue : catalogueSlugs(catalogue); } catch (error) { listed = error instanceof Error ? error : new Error(String(error)); }
91
+ if (listed instanceof Error) { console.log(`::warning title=catalogue check skipped::GET /api/catalogue failed: ${listed.message}`); return; }
92
+ const named = releaseNamed(process.env);
93
+ const unlisted = unlistedSlugs(listed, { [PINS]: pinnedSlugs(JSON.parse(readFileSync(PINS, 'utf8'))), ...named });
94
+ // This reads the live API, not the commit: a shard deleted on the API reds every branch until engine drops it, so say so.
95
+ if (unlisted.length > 0) throw new Error(`${unlistedMessage(unlisted)}\nA shard was deleted on the API, not by this commit: drop it`
96
+ + ' (pins: node scripts/pins.ts refresh --drop <slug>; a release variable: gh variable set) and push the fix.');
97
+ console.log(`catalogue check: ${PINS}, ${Object.keys(named).join(', ')} name only slugs GET /api/catalogue lists`);
98
+ }
99
+
100
+ if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
101
+ if (process.argv[2] === 'check') await check();
102
+ else throw new Error('usage: pins-catalogue.ts check');
103
+ }
@@ -39,7 +39,7 @@ const HEX=/^[a-f0-9]{64}$/u;
39
39
  * imports is here unless KEY_EXEMPT says why its bytes can't change out/ or public/ (pins-reuse.test.mjs checks). */
40
40
  export const KEY_SOURCES=Object.freeze(['scripts/pins.ts','scripts/pin-packs.ts','scripts/pin-assets.ts','scripts/pin-format.ts',
41
41
  'scripts/bake-loader.mjs','scripts/format-hook.mjs','scripts/shardfile-validation-revision.mjs','scripts/pins-reuse.mjs',
42
- PINS,'test/pins/assets.json']);
42
+ 'scripts/tracked-public.mjs',PINS,'test/pins/assets.json']);
43
43
  export const KEY_EXEMPT=Object.freeze({
44
44
  'scripts/pins-exclude.mjs':'writes Git\'s exclude file only',
45
45
  'scripts/apfs-clone.mjs':'clones bytes that are then hashed against the manifest',
@@ -47,6 +47,8 @@ export const KEY_EXEMPT=Object.freeze({
47
47
  'src/cook/game/shardCook.ts':'slice command only',
48
48
  'scripts/renderer-revision.mjs':'names a printed preparation label only (J262); no byte under out/',
49
49
  'src/shared/game/shardfile/ktx2Targets.ts':'hashed already: the validation revision in the key covers src/shared/game/shardfile (S11)',
50
+ 'scripts/pins-catalogue.ts':'refresh check only (DEL9): refuses before the pins are written; no byte under out/',
51
+ 'scripts/server-release/served-slug.mjs':'refresh check only (DEL9): names a slug\'s served folder for the catalogue compare',
50
52
  });
51
53
 
52
54
  /** @typedef {{version:number,key:string,products:Record<string,Record<string,string>>,mounts:Record<string,string>}} Manifest */
package/scripts/pins.ts CHANGED
@@ -2,7 +2,9 @@
2
2
  // J65: engine's products are pinned real shardfiles, not a shard build. `test/pins/shardfiles.json` names each one by the
3
3
  // hash `api.wildshard.io` serves, and `test/pins/catalogue.json` is the catalogue document those heads came from.
4
4
  //
5
- // node scripts/pins.ts refresh re-pin to the live heads (read only: GETs)
5
+ // node scripts/pins.ts refresh re-pin to the live heads (read only: GETs); refuses while a pin, the default
6
+ // release pair or a set E7_*_SHARDS names a slug GET /api/catalogue no longer
7
+ // lists (DEL9); `--drop <slug>` lets refresh drop a deleted pin
6
8
  // node scripts/pins.ts install [slug...] fetch, check, validate, then write out/<folder> and publish its mounts
7
9
  // node scripts/pins.ts install --ring 1 Ring 1: pinned Template 1 and Dunes, dependency Template 2, and server slices
8
10
  // node scripts/pins.ts install --from-format <slug> a frozen dependency product (blender-template, brasscap-mesa),
@@ -30,7 +32,6 @@
30
32
  // mirror serves it. Coverage rows 4 and 5.
31
33
  // oxlint-disable-next-line import/no-unassigned-import -- Its hooks are the point, and they must run first.
32
34
  import './bake-loader.mjs';
33
- import { execFileSync } from 'node:child_process';
34
35
  import { createHash } from 'node:crypto';
35
36
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
36
37
  import { homedir } from 'node:os';
@@ -42,6 +43,9 @@ import { dropManifest, folderName, insideTree, lockPins, mountPath, pinsKey, reu
42
43
  import type { PackedIndex } from './pin-packs.ts';
43
44
  import { fetchPinnedPublicAssets, pinnedPublicAssets } from './pin-assets.ts';
44
45
  import { assertKtx2TableTargets } from '../src/shared/game/shardfile/ktx2Targets.ts';
46
+ import { trackedPublic } from './tracked-public.mjs';
47
+ import { catalogueSlugs, documentSlugs, pinnedSlugs, releaseNamed, unlistedMessage, unlistedSlugs } from './pins-catalogue.ts';
48
+ import { servedSlug } from './server-release/served-slug.mjs';
45
49
 
46
50
  interface Pin { readonly slug: string; readonly revision: number; readonly hash: string; readonly bytes: number }
47
51
  interface PinFile { readonly api: string; readonly shards: readonly Pin[] }
@@ -102,9 +106,17 @@ async function getJson(path: string): Promise<unknown> {
102
106
  return response.json();
103
107
  }
104
108
 
105
- /** Re-pin to the catalogue's live heads. */
106
- async function refresh(): Promise<void> {
109
+ /** Re-pin to the catalogue's live heads. A slug the catalogue no longer lists (DEL9: deleted) is refused, never silently
110
+ * dropped: whatever names it (a ring, a release variable, a proof list) has to drop it first, then `--drop <slug>`. */
111
+ async function refresh(drop: readonly string[]): Promise<void> {
107
112
  const [catalogue, listed, document] = await Promise.all([getJson('/api/catalogue'), getJson('/api/shardfiles'), getJson('/api/catalogue.json?stage=live')]);
113
+ const pinned = existsSync(PINS) ? pinnedSlugs(readJson(PINS)) : [], liveSlugs = catalogueSlugs(catalogue);
114
+ const wrongDrop = drop.filter(slug => !pinned.includes(slug) || liveSlugs.has(servedSlug(slug)));
115
+ if (wrongDrop.length > 0) throw new Error(`pins refresh refused: --drop ${wrongDrop.join(',')} names no pin, or one GET /api/catalogue still lists`);
116
+ const held = pinned.filter(slug => !drop.includes(slug));
117
+ const unlisted = unlistedSlugs(liveSlugs, { [PINS]: held, 'GET /api/catalogue.json?stage=live': documentSlugs(document), ...releaseNamed(process.env) });
118
+ if (unlisted.length > 0) throw new Error(`pins refresh refused, nothing written:\n${unlistedMessage(unlisted)}\n`
119
+ + `A deleted pin: drop it from what names it, then run pins.ts refresh --drop <slug>.`);
108
120
  const { shards } = catalogue as { shards: readonly CatalogueRow[] }, rows = Array.isArray(listed) ? listed as readonly ListedRow[] : (listed as { shardfiles: readonly ListedRow[] }).shardfiles;
109
121
  const sizes = new Map(rows.map(row => [row.hash, row.bytes]));
110
122
  const pins = shards.flatMap(({ slug, live }): Pin[] => (live === undefined ? [] : [{ slug, revision: live.revision, hash: live.hash, bytes: sizes.get(live.hash) ?? 0 }]));
@@ -181,13 +193,6 @@ function preparationOf(files: ReadonlyMap<string, Uint8Array>, root: string): 'c
181
193
  return cook.renderer === ownRenderer ? 'current' : 'stale';
182
194
  }
183
195
 
184
- function tracked(): ReadonlySet<string> {
185
- try {
186
- return new Set(execFileSync('git', ['ls-files', '-z', 'public'], { encoding: 'utf8', maxBuffer: 1 << 28 }).split('\0'));
187
- } catch {
188
- return new Set();
189
- }
190
- }
191
196
 
192
197
  /** The public paths an installed product published: its files under mounts/assets|programs and its cook.json rows. */
193
198
  function mountsOf(folder: string): Set<string> {
@@ -261,7 +266,7 @@ async function installLocked(only: readonly string[], source: 'pins' | 'format'
261
266
  insideTree(root, dirname(path));
262
267
  rmSync(path, { force: true });
263
268
  }
264
- const shared = tracked(), published = new Map<string, string>(), publicUrls = new Set(publicAssets.map(asset => asset.url));
269
+ const shared = trackedPublic(), published = new Map<string, string>(), publicUrls = new Set(publicAssets.map(asset => asset.url));
265
270
  const publish = (url: string, body: Uint8Array): void => {
266
271
  if (!mountPath(url)) throw new Error(`A pin publishes ${url}, outside public/`);
267
272
  const hash = digest(body), held = published.get(url);
@@ -456,7 +461,10 @@ function status(): void {
456
461
  }
457
462
 
458
463
  const [command = 'status', ...rest] = process.argv.slice(2);
459
- if (command === 'refresh') await refresh();
464
+ if (command === 'refresh') {
465
+ if (rest.some((arg, at) => arg.startsWith('-') ? arg !== '--drop' : rest[at - 1] !== '--drop')) throw new Error('usage: pins.ts refresh [--drop slug[,slug]]...');
466
+ await refresh(rest.flatMap((arg, at) => rest[at - 1] === '--drop' ? arg.split(',') : []));
467
+ }
460
468
  else if (command === 'install' && rest[0] === '--ring') await installRing(rest[1] ?? '1');
461
469
  else if (command === 'install' && rest[0] === '--from-format') await install(rest.slice(1), 'format');
462
470
  else if (command === 'install') await install(rest);
@@ -465,4 +473,4 @@ else if (command === 'verify-slices') await slice(true);
465
473
  else if (command === 'install-saves') await installSaves(rest);
466
474
  else if (command === 'keep') await keep(rest[0] ?? 'tmp/pins-release');
467
475
  else if (command === 'status') status();
468
- else throw new Error('usage: pins.ts refresh | install [slug...] | install --ring 1 | install-saves [slug...] | slice | verify-slices | keep <dir> | status');
476
+ else throw new Error('usage: pins.ts refresh [--drop slug] | install [slug...] | install --ring 1 | install-saves [slug...] | slice | verify-slices | keep <dir> | status');