@wildshard/engine 0.1.22 → 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.
Files changed (100) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lint/engine-sides.json +2 -0
  3. package/lint/sim-players.json +2 -13
  4. package/package.json +9 -2
  5. package/scripts/apfs-clone.mjs +5 -2
  6. package/scripts/app-build/catalogue.ts +39 -8
  7. package/scripts/app-build/serviceWorker.ts +4 -1
  8. package/scripts/app-build/splitOutput.mjs +33 -11
  9. package/scripts/ci-pack.mjs +3 -3
  10. package/scripts/engine-ci-shard.mjs +11 -0
  11. package/scripts/fight-page-census.mjs +131 -0
  12. package/scripts/goldens/board.py +44 -11
  13. package/scripts/goldens/native-residency.d.mts +1 -0
  14. package/scripts/goldens/native-residency.mjs +18 -4
  15. package/scripts/keep-copy.mjs +120 -0
  16. package/scripts/land.mjs +36 -6
  17. package/scripts/lane-live.mjs +136 -0
  18. package/scripts/leftovers-report.mjs +47 -0
  19. package/scripts/loading-card-proof.mjs +42 -9
  20. package/scripts/loading-flow/benchmax.mjs +57 -7
  21. package/scripts/loading-flow/stalls.d.mts +2 -0
  22. package/scripts/loading-flow/stalls.mjs +13 -0
  23. package/scripts/mmo-bots.mjs +5 -3
  24. package/scripts/mmo-grid-proof.mjs +74 -0
  25. package/scripts/mmo-seat-proof.mjs +43 -0
  26. package/scripts/nightly-heads.ts +13 -13
  27. package/scripts/nightly-model.ts +26 -12
  28. package/scripts/nightly.proof.ts +18 -5
  29. package/scripts/nightly.ts +13 -8
  30. package/scripts/no-astc-boot.mjs +77 -0
  31. package/scripts/physics-route.json +6 -6
  32. package/scripts/pins-reuse.mjs +1 -0
  33. package/scripts/pins-staging.ts +54 -0
  34. package/scripts/pins.ts +5 -0
  35. package/scripts/ring3.proof.ts +71 -0
  36. package/scripts/ring3.ts +100 -0
  37. package/scripts/scratch-dir.mjs +31 -12
  38. package/scripts/scratch-sweep.mjs +15 -23
  39. package/scripts/server-release/items.d.mts +7 -0
  40. package/scripts/server-release/items.mjs +28 -0
  41. package/scripts/server-release/publish.mjs +9 -1
  42. package/scripts/side-parity.mjs +1 -1
  43. package/scripts/test-products.json +1 -0
  44. package/scripts/tsconfig.json +2 -0
  45. package/scripts/vitest-ci-files.ts +5 -1
  46. package/scripts/vps/wildshard-config +106 -1
  47. package/scripts/warm-native-chrome.mjs +9 -3
  48. package/scripts/worker-client-fights.mjs +9 -3
  49. package/scripts/worktree-reap.mjs +15 -131
  50. package/scripts/worktree.mjs +92 -12
  51. package/src/client/engine/audio/audioLog.ts +7 -2
  52. package/src/client/engine/boot/diagnostics.ts +69 -1
  53. package/src/client/engine/core/ktx2.ts +5 -3
  54. package/src/client/engine/core/ktx2Zstd.ts +2 -1
  55. package/src/client/engine/pwa/sw.js +26 -8
  56. package/src/client/engine/render/dataLook.ts +14 -7
  57. package/src/client/engine/render/lookLight.ts +64 -20
  58. package/src/client/engine/ui/Loading.ts +6 -8
  59. package/src/client/engine/ui/lookLightOption.ts +1 -1
  60. package/src/client/game/audio/cueDirector.ts +2 -1
  61. package/src/client/game/boss/arenaRoom.ts +4 -3
  62. package/src/client/game/boss/roamingProjection.ts +1 -1
  63. package/src/client/game/devScene/hook.ts +1 -1
  64. package/src/client/game/devScene/liveLook.ts +1 -1
  65. package/src/client/game/grid/dataCellKit.ts +9 -1
  66. package/src/client/game/grid/products.ts +21 -7
  67. package/src/client/game/grid/session.ts +6 -4
  68. package/src/client/game/population/signals.ts +1 -1
  69. package/src/client/game/quest/chapterDirector.ts +1 -0
  70. package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
  71. package/src/client/game/shardfile/clientWorker.ts +22 -6
  72. package/src/client/game/shardfile/look.ts +1 -1
  73. package/src/client/game/shardfile/runtimeProduct.ts +9 -5
  74. package/src/client/game/shardfile/wirePage.ts +5 -2
  75. package/src/client/game/shardfile/worldSceneTextures.ts +15 -9
  76. package/src/cook/game/cookWorker.ts +8 -5
  77. package/src/cook/game/tierTextures.ts +5 -3
  78. package/src/server/engine/net/simWorld.ts +3 -4
  79. package/src/server/game/grid/cellHome.ts +58 -0
  80. package/src/server/game/grid/simulation.ts +5 -4
  81. package/src/server/game/plugin/mover.ts +18 -14
  82. package/src/server/game/shardfile/declaredKitItems.ts +31 -7
  83. package/src/server/host/bake/headlessWorker.ts +3 -3
  84. package/src/server/host/dedicated/cellWorker.ts +4 -2
  85. package/src/server/host/dedicated/main.ts +7 -4
  86. package/src/server/host/dedicated/packReader.ts +15 -2
  87. package/src/server/host/dedicated/playerStore.ts +1 -1
  88. package/src/server/host/headlessRuntime.ts +11 -6
  89. package/src/server/host/standalone/cellWorld.ts +20 -6
  90. package/src/server/host/standalone/gridServer.ts +3 -1
  91. package/src/server/host/standalone/roadWorld.ts +6 -0
  92. package/src/shared/engine/physics/gridBorders.ts +15 -1
  93. package/src/shared/engine/sim/snapshot.ts +5 -5
  94. package/src/shared/game/ledger.ts +13 -4
  95. package/src/shared/game/loot/platformCatalogue.ts +14 -0
  96. package/src/shared/game/quest/ledger.ts +3 -3
  97. package/src/shared/game/shardfile/items.ts +9 -1
  98. package/src/shared/host/headlessJourney.ts +3 -3
  99. package/src/shared/host/headlessTape.ts +7 -6
  100. package/src/shared/host/releaseRows.ts +4 -1
package/CHANGELOG.md CHANGED
@@ -9,6 +9,14 @@ run `../repo-kit/release.sh vX.Y.Z --prepare` and `--finish` as before (the help
9
9
  `scripts/changelog.mjs` checks the format; the pre-push hook and CI refuse a push whose `package.json` version has no
10
10
  valid section, and a `vX.Y.Z` tag whose commit has none.
11
11
 
12
+ ## v0.1.23 (2026-11-15)
13
+
14
+ - New and updated shards are cooked for the world again: since Saturday the cook refused every upload as over its space.
15
+ - Lamps carried by players and creatures move their light with them, and the 16 nearest lamps light the scene.
16
+ - Brasscap Mesa keeps its far view from the road, and a shard's creatures respawn where they were placed.
17
+ - You can take a melee weapon from its rack, and creatures in a shared shard stay in their own cell.
18
+ - The game's files now come from our content network, so the page is smaller and loads faster, and cached files survive a release.
19
+
12
20
  ## v0.1.22 (2026-11-15)
13
21
 
14
22
  - Brasscap Mesa: you walk in with the lever-action in hand, its rack restocks your rounds, and every bandit and beast in the cell is drawn.
@@ -1219,6 +1219,7 @@
1219
1219
  "src/server/game/boss/slotsNative.ts": "server",
1220
1220
  "src/server/game/boss/windEliteNative.ts": "server",
1221
1221
  "src/server/game/grapple/native.ts": "server",
1222
+ "src/server/game/grid/cellHome.ts": "server",
1222
1223
  "src/server/game/grid/durability.ts": "server",
1223
1224
  "src/server/game/grid/room.ts": "server",
1224
1225
  "src/server/game/grid/roomNet.ts": "server",
@@ -1691,6 +1692,7 @@
1691
1692
  "src/shared/game/loot/exchange.ts": "shared",
1692
1693
  "src/shared/game/loot/Owned.ts": "shared",
1693
1694
  "src/shared/game/loot/ownedRows.ts": "shared",
1695
+ "src/shared/game/loot/platformCatalogue.ts": "shared",
1694
1696
  "src/shared/game/loot/Purse.ts": "shared",
1695
1697
  "src/shared/game/loot/tableRows.ts": "shared",
1696
1698
  "src/shared/game/newGame.ts": "shared",
@@ -1,17 +1,6 @@
1
1
  {
2
2
  "about": "P1-E5.2a: per-file reads of a one-player SimHost member (`members`, which ended at 0) and leadPlayer binds (`lead`: systems not yet per-player) in non-test source, by type, not by spelling (scripts/check-sim-players.mjs). They never rise.",
3
3
  "members": 0,
4
- "lead": 13,
5
- "files": {
6
- "src/server/engine/net/simWorld.ts": 1,
7
- "src/shared/engine/sim/snapshot.ts": 3,
8
- "src/client/game/grid/copyPrompts.ts": 1,
9
- "src/client/game/grid/neighbourPanels.ts": 1,
10
- "src/server/game/grid/simulation.ts": 1,
11
- "src/server/game/plugin/mover.ts": 2,
12
- "src/server/host/bake/headlessWorker.ts": 1,
13
- "src/shared/host/headlessJourney.ts": 1,
14
- "src/server/host/headlessRuntime.ts": 1,
15
- "src/shared/host/headlessTape.ts": 1
16
- }
4
+ "lead": 0,
5
+ "files": {}
17
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/engine",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "The Wildshard engine: one repo with shared, client, server and cook code and three build targets (client, dedicated server, standalone listen server), shaped like Unreal or Source.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -67,7 +67,7 @@
67
67
  "@sentry/browser": "11.0.0",
68
68
  "@sentry/core": "11.0.0",
69
69
  "@valibot/to-json-schema": "1.8.0",
70
- "@wildshard/format": "npm:@wildshard/shard-format@^0.5.7",
70
+ "@wildshard/format": "npm:@wildshard/shard-format@^0.5.9",
71
71
  "@wildshard/wire": "^0.1.0",
72
72
  "ajv": "6.15.0",
73
73
  "fflate": "0.8.3",
@@ -84,6 +84,7 @@
84
84
  "peerDependencies": {
85
85
  "@types/three": "*",
86
86
  "@typescript/typescript6": "6.0.2",
87
+ "playwright": "1.65.0",
87
88
  "sharp": "0.35.5",
88
89
  "vite": "8.3.0"
89
90
  },
@@ -91,6 +92,9 @@
91
92
  "@types/three": {
92
93
  "optional": true
93
94
  },
95
+ "playwright": {
96
+ "optional": true
97
+ },
94
98
  "sharp": {
95
99
  "optional": true
96
100
  }
@@ -820,6 +824,9 @@
820
824
  "./game/population/perchBody": "./src/server/game/population/perchBody.ts",
821
825
  "./game/population/productCreatures": "./src/client/game/population/productCreatures.ts",
822
826
  "./game/quest/ledger": "./src/shared/game/quest/ledger.ts",
827
+ "./game/ledger": "./src/shared/game/ledger.ts",
828
+ "./game/grid/cellHome": "./src/server/game/grid/cellHome.ts",
829
+ "./game/loot/platformCatalogue": "./src/shared/game/loot/platformCatalogue.ts",
823
830
  "./game/quest/legacyRecords": "./src/shared/game/quest/legacyRecords.ts",
824
831
  "./game/shardfile/pageWater": "./src/client/game/shardfile/pageWater.ts",
825
832
  "./game/shardfile/pagePreparation": "./src/client/game/shardfile/pagePreparation.ts",
@@ -48,10 +48,11 @@ function copyPair(source,target){
48
48
  * Clone each `[source, target]` pair. Returns `clone` when every pair is an APFS clone, `copy` when some were copied.
49
49
  * Throws when a source is a link, missing or neither a file nor a directory, or a target exists; a pair cloned before
50
50
  * the failure stays.
51
- * @param {readonly (readonly [string,string])[]} pairs @param {{platform?:string}} [options]
51
+ * `copy:false` refuses unsupported cloning instead of allocating a full copy.
52
+ * @param {readonly (readonly [string,string])[]} pairs @param {{platform?:string,copy?:boolean}} [options]
52
53
  * @returns {'clone'|'copy'|'none'}
53
54
  */
54
- export function clonePaths(pairs,{platform=process.platform}={}){
55
+ export function clonePaths(pairs,{platform=process.platform,copy=true}={}){
55
56
  if(pairs.length===0)return 'none';
56
57
  let rest=pairs;
57
58
  if(platform==='darwin'){
@@ -62,6 +63,8 @@ export function clonePaths(pairs,{platform=process.platform}={}){
62
63
  if(!/Operation not supported|Cross-device link/u.test(reason))throw new Error(`clonefile: ${reason}`);
63
64
  rest=pairs.filter(([,target])=>{try{lstatSync(target);return false;}catch{return true;}});
64
65
  }
66
+ if(!copy&&rest.length>0)throw new Error('clonefile unavailable; copy disabled');
67
+ if(!copy)return 'clone';
65
68
  for(const [source,target] of rest)copyPair(source,target);
66
69
  return 'copy';
67
70
  }
@@ -39,11 +39,14 @@ const readTitleRows = (outDir: string): readonly TitleManifest[] => {
39
39
  };
40
40
  const hash8 = (bytes: Uint8Array): string => createHash('sha256').update(bytes).digest('hex').slice(0, 8);
41
41
  /** A title row from a shard's discovery document: `home` is an origin for a shard cooked to R2 (J138). */
42
- export function titleRowOf(bytes: Uint8Array, home = ''): TitleManifest {
42
+ export function titleRowOf(bytes: Uint8Array, home = '', resourceSlug?: string): TitleManifest {
43
43
  const {data} = JSON.parse(new TextDecoder().decode(bytes)) as {readonly data: TitleManifest};
44
- const at = (url: string): string => (url.startsWith('/shardfiles/') ? `${home}${url}` : url);
44
+ const base = home.replace(/\/$/u, ''), from = `/shardfiles/${data.slug}/`, to = `/shardfiles/${resourceSlug ?? data.slug}/`;
45
+ // A stored cook serves blobs under its canonical identity (template),
46
+ // while an older discovery can still name its authored folder (_template).
47
+ const at = (url: string): string => (url.startsWith(from) ? `${base}${to}${url.slice(from.length)}` : url.startsWith('/shardfiles/') ? `${base}${url}` : url);
45
48
  const {thumb, portrait, landscape} = data.card;
46
- return {...titleMetadata(data), card: {thumb: at(thumb), portrait: at(portrait), landscape: at(landscape)}, discovery: `${home}/shardfiles/${data.slug}/discovery.json?v=${hash8(bytes)}`};
49
+ return {...titleMetadata(data), ...(data.shardfile === undefined ? {} : {shardfile: at(data.shardfile)}), card: {thumb: at(thumb), portrait: at(portrait), landscape: at(landscape)}, discovery: `${base}/shardfiles/${data.slug}/discovery.json?v=${hash8(bytes)}`};
47
50
  }
48
51
  /** Every built product's title row, in title order. */
49
52
  export function productTitleRows(products: string, outDir?: string): readonly TitleManifest[] {
@@ -141,14 +144,42 @@ export function addCookedShards(outDir: string, shards: readonly CookedShard[],
141
144
  writeFileSync(serverFile, JSON.stringify(servers));
142
145
  }
143
146
  html = html.replace(expression, () => `<script type="application/json" id="boot-module-files">${JSON.stringify(bank).replaceAll('<', String.raw`\u003c`)}</script>`);
144
- const stamp = /globalThis\.__WS_SHARDFILE_VERDICTS__=(\[.*?\]);?<\/script>/su, stamped = stamp.exec(html);
145
- if (stamped?.[1] === undefined) throw new Error('Missing validation verdicts');
146
- const before = JSON.parse(stamped[1]) as unknown[];
147
- writeFileSync(file, html.replace(stamp, () => `globalThis.__WS_SHARDFILE_VERDICTS__=${JSON.stringify([...before, ...verdicts]).replaceAll('<', String.raw`\u003c`)};</script>`));
148
- const added = shards.flatMap(row => (row.discovery === undefined ? [] : [titleRowOf(row.discovery, home?.shards.includes(row.slug) === true ? home.base : '')]));
147
+ writeFileSync(file, appendValidationVerdicts(html, verdicts));
148
+ const added = shards.flatMap(row => {
149
+ if (row.discovery === undefined) return [];
150
+ const stored = home?.shards.includes(row.slug) === true;
151
+ return [titleRowOf(row.discovery, stored ? home.base : '', stored ? row.slug : undefined)];
152
+ });
149
153
  if (added.length > 0) writeTitleRows(outDir, [...readTitleRows(outDir).filter(row => !added.some(next => next.slug === row.slug)), ...added]);
150
154
  }
151
155
 
156
+ /** The verdict array shares a script with build labels and other stamps.
157
+ * Find its JSON boundary without consuming or executing those assignments. */
158
+ export function appendValidationVerdicts(html: string, verdicts: readonly unknown[]): string {
159
+ const marker = 'globalThis.__WS_SHARDFILE_VERDICTS__=', start = html.indexOf(marker);
160
+ if (start === -1) throw new Error('Missing validation verdicts');
161
+ const from = start + marker.length;
162
+ let depth = 0, quoted = false, escaped = false;
163
+ for (let at = from; at < html.length; at++) {
164
+ const char = html[at];
165
+ if (quoted) {
166
+ if (escaped) escaped = false;
167
+ else if (char === '\\') escaped = true;
168
+ else if (char === '"') quoted = false;
169
+ } else if (char === '"') quoted = true;
170
+ else if (char === '[' || char === '{') depth++;
171
+ else if (char === ']' || char === '}') {
172
+ depth--;
173
+ if (depth === 0) {
174
+ const before: unknown = JSON.parse(html.slice(from, at + 1));
175
+ if (!Array.isArray(before)) throw new Error('Invalid validation verdicts');
176
+ return html.slice(0, from) + JSON.stringify([...before, ...verdicts]).replaceAll('<', String.raw`\u003c`) + html.slice(at + 1);
177
+ }
178
+ }
179
+ }
180
+ throw new Error('Unclosed validation verdicts');
181
+ }
182
+
152
183
  /** What a page takes on trust for one tarball: a verdict is earned here, by this build's format validator, whichever validator
153
184
  * stamped its receipt, because a page trusts it by its index hash. */
154
185
  export async function productVerdict(tarball: Uint8Array, out: string): Promise<{readonly verdict: unknown; readonly discovery?: Uint8Array}> {
@@ -8,6 +8,7 @@ import { ASSET_CACHE_NAME } from '../../src/client/engine/pwa/cacheNames';
8
8
  import { serverPackBookPath } from '../../src/shared/game/shardfile/serverPack';
9
9
  import { packsBookPath } from '../../src/shared/game/shardfile/spawnManifest';
10
10
  import { titleAssetURLs } from '../title-assets.mjs';
11
+ import { staticAssetHashes, contentNamed } from './assetHashes';
11
12
  import { documentIsolation } from './isolation.mjs';
12
13
  import { writtenBundle, type EmittedFile } from './writtenBundle';
13
14
 
@@ -101,11 +102,13 @@ export async function serviceWorkerCore(bundle: Readonly<Record<string, EmittedF
101
102
  content = [...new Set(moved)].map(path => new URL(`.${path}`, base).href);
102
103
  files = files.filter(path => !isContentPath(path)); shellList = shellList.filter(path => !isContentPath(path));
103
104
  }
105
+ const versions = base === '' ? {} : Object.fromEntries(Object.entries(staticAssetHashes(root)).filter(([path]) => isContentPath(path) && !contentNamed(path)));
106
+ digest.update(JSON.stringify(versions));
104
107
  const build = `${buildId}-${digest.digest('hex').slice(0, 10)}`;
105
108
  const core = source.replaceAll('__BUILD_ID__', build).replaceAll('__ASSET_CACHE__', ASSET_CACHE_NAME)
106
109
  .replace(/['"]__FILES__['"]/u, () => JSON.stringify(JSON.stringify(files)))
107
110
  .replace(/['"]__SHELL_FILES__['"]/u, () => JSON.stringify(JSON.stringify(shellList)))
108
- .replace(/['"]__CONTENT__['"]/u, () => JSON.stringify(JSON.stringify({ base, files: content })))
111
+ .replace(/['"]__CONTENT__['"]/u, () => JSON.stringify(JSON.stringify({ base, files: content, ...base === '' ? {} : {versions} })))
109
112
  .replace(/['"]__DOCUMENT__['"]/u, () => JSON.stringify(html))
110
113
  // PZ12: the page origin's COOP and COEP on the baked document, so a load the worker serves is isolated like the network's
111
114
  .replace(/['"]__DOCUMENT_HEADERS__['"]/u, () => JSON.stringify(JSON.stringify(documentHeaders)));
@@ -6,7 +6,7 @@
6
6
  // joins before it packages, and the jobs that serve the whole game from dist (nightly, hover contract) join too.
7
7
  //
8
8
  // node scripts/app-build/splitOutput.mjs [dist] [--join]
9
- import {existsSync, lstatSync, mkdirSync, readdirSync, renameSync, rmSync, rmdirSync, writeFileSync} from 'node:fs';
9
+ import {existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, rmdirSync, writeFileSync} from 'node:fs';
10
10
  import {dirname, join, resolve} from 'node:path';
11
11
  import {pathToFileURL} from 'node:url';
12
12
  import {carriedPaths, classify, shardNames} from '../page-size.mjs';
@@ -38,12 +38,21 @@ function files(root) {
38
38
 
39
39
  /** Move each path from one root to the other, then drop the folders the moves emptied.
40
40
  * @param {string} from @param {string} to @param {readonly {path: string, bytes: number}[]} rows */
41
- function move(from, to, rows) {
41
+ function move(from, to, rows, reuse = false) {
42
42
  for (const {path} of rows) {
43
- const target = join(to, path);
44
- if (existsSync(target)) throw new Error(`splitOutput: ${target} already exists`);
43
+ const source = join(from, path), target = join(to, path);
44
+ let old;
45
+ try { old = lstatSync(target); } catch { /* A new generated path. */ }
46
+ if (old) {
47
+ if (!reuse) throw new Error(`splitOutput: ${target} already exists`);
48
+ const next = lstatSync(source);
49
+ const same = old.isFile() && next.isFile() && old.size === next.size && readFileSync(target).equals(readFileSync(source))
50
+ || old.isSymbolicLink() && next.isSymbolicLink() && readlinkSync(target) === readlinkSync(source);
51
+ if (same) { rmSync(source); continue; }
52
+ rmSync(target, {recursive: true, force: true});
53
+ }
45
54
  mkdirSync(dirname(target), {recursive: true});
46
- renameSync(join(from, path), target);
55
+ renameSync(source, target);
47
56
  }
48
57
  const folders = new Set(rows.flatMap(({path}) => path.split('/').slice(0, -1).map((_, at, parts) => parts.slice(0, at + 1).join('/'))));
49
58
  for (const folder of [...folders].sort((a, b) => b.length - a.length)) {
@@ -61,22 +70,35 @@ function disjoint(root, content) {
61
70
  if (root === content || content.startsWith(`${root}/`) || root.startsWith(`${content}/`)) throw new Error(`splitOutput: ${content} and ${root} overlap`);
62
71
  }
63
72
 
64
- /** Split a freshly built page. A dist-content left by an earlier build is replaced; one an interrupted split of this page
73
+ /** Split a freshly built page. Unchanged content retains its inode/APFS blocks; stale paths are replaced. An interrupted split
65
74
  * left (the page still holds SPLITTING) is kept and finished. A page that holds no content is already split.
66
75
  * @param {string} dist @param {string} [content] @returns {{files: number, bytes: number}} */
67
76
  export function splitOutput(dist, content = contentDirOf(dist)) {
68
77
  const root = resolve(dist), target = resolve(content), mark = join(root, SPLITTING);
69
78
  disjoint(root, target);
79
+ try {
80
+ if (!lstatSync(target).isDirectory() || lstatSync(target).isSymbolicLink()) throw new Error('splitOutput: content root must be a real directory');
81
+ } catch (error) { if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) throw error; }
70
82
  if (!existsSync(join(root, 'index.html'))) throw new Error(`splitOutput: ${root} holds no index.html; give a built page`);
71
83
  // a kept build's content (MF2 carry, PZ5: an unmarked build reads it from the page) stays on the page until it ages out
72
84
  const carried = carriedPaths(root)?.paths ?? new Set();
73
- const shards = shardNames(root), rows = files(root).filter(row => row.path !== SPLITTING && !carried.has(row.path) && isContent(row.path, shards));
74
- if (rows.length > 0) {
75
- if (!existsSync(mark)) rmSync(target, {recursive: true, force: true});
76
- writeFileSync(mark, '');
85
+ const shards = shardNames(root), rows = files(root).filter(row => row.path !== SPLITTING && row.path !== `${SPLITTING}.tmp` && !carried.has(row.path) && isContent(row.path, shards));
86
+ // The full desired path list makes pruning resumable too. An empty mark
87
+ // from the previous implementation already had its old target removed.
88
+ if (rows.length > 0 && !existsSync(mark)) {
89
+ writeFileSync(`${mark}.tmp`, JSON.stringify(rows.map(row => row.path)));
90
+ renameSync(`${mark}.tmp`, mark);
91
+ }
92
+ if (existsSync(mark) && readFileSync(mark, 'utf8') !== '') {
93
+ let paths;
94
+ try { paths = JSON.parse(readFileSync(mark, 'utf8')); } catch { throw new Error('splitOutput: invalid interrupted path list; inspect output and remove .splitting to restart'); }
95
+ if (!Array.isArray(paths) || !paths.every(path => typeof path === 'string')) throw new Error('splitOutput: invalid interrupted path list; inspect output and remove .splitting to restart');
96
+ const desired = new Set(paths);
97
+ for (const {path} of files(target)) if (!desired.has(path)) rmSync(join(target, path));
77
98
  }
78
- const moved = move(root, target, rows);
99
+ const moved = move(root, target, rows, true);
79
100
  rmSync(mark, {force: true});
101
+ rmSync(`${mark}.tmp`, {force: true});
80
102
  return moved;
81
103
  }
82
104
 
@@ -15,10 +15,10 @@
15
15
  // in its job. With more than one job it starts the last job (EV3), so it never lands behind job 1's
16
16
  // shards (that made job 1 the long pole, p50 12.6 min against 9.1); the other units pack over every job,
17
17
  // and the last takes shards once it is the least loaded (EV3b: alone it ran 5.2-8.1 min against 9.6-11.3).
18
- // boundaries engine-boundaries' push half, cook-to-play on Ring 1's products: report-only (J186), so non-blocking.
18
+ // boundaries engine-boundaries' push half, cook-to-play on Ring 1's products; blocking after TS15's green soak.
19
19
  // It needs the full pins (its Ring 1 cook reads raw tarballs only `pnpm pins` fetches, run 43303094170),
20
20
  // then installs Ring 1's and Chromium itself and builds its own tree, so it needs no other unit: ci.yml
21
- // runs it as its own non-blocking job from t=0 (EV3b; after products in job 6 it took that job to 13.7
21
+ // runs it as its own blocking job from t=0 (TS15/EV3b; after products in job 6 it took that job to 13.7
22
22
  // min). Packed with products, it still follows products into products' job
23
23
  // Phases run in order: before pins (up to C units at once), `pnpm pins && pnpm gen:inputs`, the shards ONE AT A TIME,
24
24
  // then products and boundaries. A shard has the runner to itself, as its plan assumes: two at once on the 4-vCPU runner
@@ -46,7 +46,7 @@ const FOLLOWS=Object.freeze(/** @type {Record<string,string>} */({boundaries:'pr
46
46
  * 2026-11-12): that job then packs like the rest, so the shards fill the 2-4 min products leaves free there. Alone it ran
47
47
  * 5.2-8.1 min while jobs 1-5 ran 9.6-11.3 (runs 43313302390 .. 43315974456). Its shards still run before products. */
48
48
  const OWN_JOB=new Set(['products']);
49
- const NONBLOCKING=new Set(['quarantine','boundaries']);
49
+ const NONBLOCKING=new Set(['quarantine']);
50
50
  const SHARD_LIMIT_MS=300_000;
51
51
  /** @typedef {{name:string,phase:number,seconds:number,blocking:boolean}} Unit */
52
52
  /** @typedef {{name:string,phase:number,blocking:boolean,started:number,charged:number,ended:number,seconds:number,code:number}} UnitResult */
@@ -10,10 +10,21 @@ const index=Number(process.env.WS_CI_SHARD),shard=plan.shards[index-1];
10
10
  if(shard===undefined)throw new Error('Missing matrix shard');
11
11
  const started=Date.now();let failed=false;
12
12
  mkdirSync('tmp/engine-ci',{recursive:true});
13
+ // TS8: warm the selected browser once outside the file's native deadlines.
14
+ // Its I/O remains charged to this shard, including the final wall check.
15
+ const warmStarted=Date.now();
16
+ const chrome=shard.native.includes('test/tooling/parity/browser-escape.test.mjs')
17
+ ?await import('./warm-native-chrome.mjs').then(({nativeChromeExecutable,warmNativeChrome})=>warmNativeChrome(nativeChromeExecutable())):null;
18
+ if(chrome!==null)console.log(JSON.stringify({preparation:'native Chrome files read',shard:index,milliseconds:Date.now()-warmStarted,bytes:chrome.bytes}));
13
19
  for(const phase of /** @type {const} */ (['native','ordinary'])){
14
20
  if(shard[phase].length===0)continue;
15
21
  const report=resolve(`tmp/engine-ci/shard-${index}-${phase}.json`);
16
22
  /** @type {NodeJS.ProcessEnv} */ const env={...process.env,WS_CI_PHASE:phase,WS_CI_TIMINGS:report};
23
+ if(chrome!==null){
24
+ env.WS_CI_NATIVE_CHROME_WARM=chrome.executable;
25
+ if(phase==='native')env.CHROME_PATH=chrome.executable;
26
+ }
27
+ else Reflect.deleteProperty(env,'WS_CI_NATIVE_CHROME_WARM');
17
28
  if(plan.ring==='1')env.WILDSHARD_RING='1';else Reflect.deleteProperty(env,'WILDSHARD_RING');
18
29
  const result=spawnSync('python3',['scripts/heavy-lane.py','full-test','--',process.execPath,'scripts/vitest-tmp.ts','run','--config','scripts/engine-ci.config.ts','--reporter=default','--reporter=./scripts/engine-ci-budget.ts'],{env,stdio:'inherit',timeout:300000});
19
30
  if(result.error!==undefined||result.status!==0)failed=true;
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ // EG-15 (meta docs/plans/test-coverage/ENGINE.md, TEST-COVERAGE row 32): fight-page-census. What a server says, a page draws.
3
+ // It runs `worker-client-fights` journeys on four full heads (Nalati, Pine, Far Reach, Dunes) and holds, per head:
4
+ // heard every view word the server said to a page (`__workerClient().heard`, counted at the wire);
5
+ // drawn what the page drew of them (`__workerClient().drawn`, counted where a view applies a word);
6
+ // offstage words for a view the page hasn't built, a room nobody entered (`__workerClient().offstage`): not drawn, and not dark;
7
+ // bodies every fight the page shows a bar for has a body drawn (`__workerClientFights().shown`, or an open arena's own body): BUG-28;
8
+ // audio every directed cue and score change that asked for a sound, and whether one played (`window.__audioTally`): N1, N2.
9
+ // A word heard that the page never drew is dark, unless WORDS below says why it draws nothing. A dark word, a bar with no body, a cue that
10
+ // found no sound or a step that failed is red. Digests and verb tapes can't see any of these: they never run a page.
11
+ // scripts/browser-lane.sh node scripts/fight-page-census.mjs --base=http://127.0.0.1:4401/ [--heads=nalati,pine,far,dunes] [--journeys=titan] [--out=tmp/census/census.json]
12
+ import { mkdirSync, writeFileSync } from 'node:fs';
13
+ import { dirname } from 'node:path';
14
+ import { chromium, devices } from 'playwright';
15
+ import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
16
+ import { fights, pageCensus } from './worker-client-fights.mjs';
17
+
18
+ const arg = (key, fallback) => process.argv.find(value => value.startsWith(`--${key}=`))?.slice(key.length + 3) ?? fallback;
19
+ const base = arg('base', ''), out = arg('out', 'tmp/census/census.json');
20
+ if (base === '') throw new Error('Requires --base');
21
+
22
+ /** Each head and the journeys that fight on it (`fights(…, only)`). Flags the journeys read off argv go on with them. `qara` is left
23
+ * out: its captain comes only after a night patrol is thinned, and some runs it never comes (`sweep`'s Argymaq draws an elite lane). */
24
+ export const HEADS = {
25
+ nalati: { slug: 'nalati-grasslands', journeys: ['titan', 'sweep'], flags: ['--titanlook'] },
26
+ pine: { slug: 'pine-hollow', journeys: ['rig', 'pine'], flags: [] },
27
+ far: { slug: 'far-reach', journeys: ['roc', 'farreach'], flags: [] },
28
+ dunes: { slug: 'sunscar-dunes', journeys: ['sunscar'], flags: [] },
29
+ };
30
+ /** View words a page hears and rightly draws nothing for, and why. Everything else heard must be drawn. */
31
+ export const WORDS = [
32
+ // Exact words, not a prefix: a lane-sheet boss's strike must still be drawn (clientBossTelegraph.ts).
33
+ ['boss.strike.far.roc.stoop', 'the Roc\'s presentation is marked and names no strike: no page view takes it, its body plays the attack off its row'],
34
+ ['boss.strike.sunscar.matriarch.dive', 'the Matriarch\'s presentation is marked and names no strike: no page view takes it, its body plays the attack off its row'],
35
+ ];
36
+ const silent = name => WORDS.find(([word]) => name === word)?.[1] ?? null;
37
+ /** One row per kind of word. A pose is a pose whatever body and field it names (one taken is the census's proof that poses land);
38
+ * an elite's words are drawn each frame under its kind (`Elite.ts`: `elite lane`), so its heard words count there. */
39
+ export const family = name => name.startsWith('pose.') ? 'pose' : name.replace(/^elite\.(\w+):.*$/u, 'elite $1');
40
+
41
+ const picked = arg('heads', Object.keys(HEADS).join(',')).split(','), only = arg('journeys', '').split(',').filter(Boolean);
42
+ for (const name of picked) if (HEADS[name] === undefined) throw new Error(`Unknown head ${name}: ${Object.keys(HEADS).join(', ')}`);
43
+ const { defaultBrowserType: _engine, ...phone } = devices['iPhone 16 Pro'];
44
+ const launched = await chromium.launch({ args: [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist'] });
45
+ const browser = { close: () => launched.close(), newContext: options => launched.newContext(options) };
46
+
47
+ /** One sample of a page's fights: each in progress, whether its bar shows, and whether a body for it is drawn. */
48
+ const sampleFights = page => page.evaluate(() => {
49
+ const shown = selector => [...document.querySelectorAll(selector)].some(node => node.classList.contains('show'));
50
+ const bar = shown('[class*="ws-boss"]') || shown('[class*="ws-elite"]');
51
+ const open = Object.values(window.__wildshard?.shard ?? {}).flatMap(script => { try { const body = script?.openFight?.body; return body === undefined ? [] : [body.visible === true]; } catch { return []; } });
52
+ return (window.__workerClientFights?.() ?? []).filter(row => row.state === 'fight').map(row => ({ id: row.id, bar, body: row.shown ?? open.some(Boolean) }));
53
+ });
54
+ const readPage = page => page.evaluate(() => {
55
+ const report = window.__workerClient();
56
+ return { heard: report.heard ?? {}, drawn: report.drawn, offstage: report.offstage ?? {}, audio: window.__audioTally ?? {}, said: window.__said ?? [] };
57
+ });
58
+
59
+ const census = {};
60
+ for (const head of picked) {
61
+ const { slug, journeys, flags } = HEADS[head];
62
+ const row = census[head] = { slug, steps: [], heard: {}, drawn: {}, offstage: {}, audio: {}, bodies: {}, pages: 0 };
63
+ const sampling = new Map();
64
+ pageCensus.sink = {
65
+ opened(_slug, page) {
66
+ const timer = setInterval(() => {
67
+ void sampleFights(page).then(seen => {
68
+ for (const { id, bar, body } of seen) {
69
+ const fight = row.bodies[id] ??= { samples: 0, bar: 0, bodiless: 0 };
70
+ fight.samples++; if (bar) fight.bar++; if (bar && !body) fight.bodiless++;
71
+ }
72
+ return undefined;
73
+ }, () => undefined);
74
+ }, 1500);
75
+ sampling.set(page, timer);
76
+ },
77
+ async closing(_slug, page) {
78
+ clearInterval(sampling.get(page)); sampling.delete(page);
79
+ const seen = await readPage(page).catch(() => null);
80
+ if (seen === null) return;
81
+ row.pages++;
82
+ for (const [name, count] of Object.entries(seen.heard)) row.heard[family(name)] = (row.heard[family(name)] ?? 0) + count;
83
+ for (const [name, count] of Object.entries(seen.drawn)) row.drawn[family(name)] = (row.drawn[family(name)] ?? 0) + count;
84
+ for (const [name, count] of Object.entries(seen.offstage)) row.offstage[family(name)] = (row.offstage[family(name)] ?? 0) + count;
85
+ for (const [name, { played, silent: quiet }] of Object.entries(seen.audio)) { const sound = row.audio[name] ??= { played: 0, silent: 0 }; sound.played += played; sound.silent += quiet; }
86
+ },
87
+ };
88
+ process.argv.push(...flags);
89
+ for (const journey of only.length === 0 ? journeys : journeys.filter(name => only.includes(name))) {
90
+ await fights(browser, phone, base, journey, async (name, run) => {
91
+ const started = Date.now();
92
+ let result;
93
+ try { result = await run(); } catch (error) { result = { ok: false, error: String(error?.message ?? error).slice(0, 300) }; }
94
+ row.steps.push({ name, ok: result?.ok === true, seconds: Math.round((Date.now() - started) / 1000) });
95
+ console.log(`${result?.ok === true ? 'ok ' : 'FAIL'} ${head} ${name}${result?.ok === true ? '' : ` ${JSON.stringify(result).slice(0, 400)}`}`);
96
+ });
97
+ }
98
+ for (const flag of flags) process.argv.splice(process.argv.indexOf(flag), 1);
99
+ pageCensus.sink = null;
100
+ }
101
+ await browser.close();
102
+
103
+ /** The verdict: each head's words heard against drawn, its bodies and its sounds. */
104
+ const red = [];
105
+ for (const [head, row] of Object.entries(census)) {
106
+ console.log(`\n${head} (${row.slug}): ${row.pages} pages, ${row.steps.filter(step => step.ok).length}/${row.steps.length} steps`);
107
+ console.log(`${' word'.padEnd(44)}${'heard'.padStart(8)}${'drawn'.padStart(8)} verdict`);
108
+ for (const name of [...new Set([...Object.keys(row.heard), ...Object.keys(row.drawn)])].sort()) {
109
+ const heard = row.heard[name] ?? 0, drawn = row.drawn[name] ?? 0, offstage = row.offstage[name] ?? 0, why = silent(name);
110
+ // offstage: every word of it was for a view this page hadn't built (a room nobody entered)
111
+ const verdict = heard === 0 ? 'drawn only' : drawn > 0 ? 'drawn' : offstage === heard ? 'offstage: its room was never built' : why !== null ? `silent: ${why}` : 'DARK';
112
+ if (verdict === 'DARK') red.push(`${head}: ${name} heard ${heard}, drawn 0`);
113
+ console.log(` ${name.slice(0, 41).padEnd(42)}${String(heard).padStart(8)}${String(drawn).padStart(8)} ${verdict}`);
114
+ }
115
+ for (const [id, fight] of Object.entries(row.bodies)) {
116
+ console.log(` fight ${id}: ${fight.samples} samples, bar on ${fight.bar}, bar with no body ${fight.bodiless}`);
117
+ if (fight.bodiless > 0) red.push(`${head}: ${id} showed a bar with no body in ${fight.bodiless} of ${fight.bar} samples`);
118
+ }
119
+ for (const [name, sound] of Object.entries(row.audio).sort(([a], [b]) => a.localeCompare(b))) {
120
+ if (!name.startsWith('cue ') && !name.startsWith('music ')) continue;
121
+ console.log(` audio ${name}: played ${sound.played}, silent ${sound.silent}`);
122
+ if (name.startsWith('cue ') && sound.played === 0) red.push(`${head}: ${name} asked for a sound ${sound.silent} times and none played`);
123
+ }
124
+ // N2: a boss fight the page showed scores it. A sting before the first gesture finds no audio rig yet, so stings only report.
125
+ if (Object.values(row.bodies).some(fight => fight.bar > 0) && (row.audio['music mode:combat']?.played ?? 0) === 0) red.push(`${head}: a boss fight showed its bar and the score never went to combat`);
126
+ for (const step of row.steps) if (!step.ok) red.push(`${head}: step failed: ${step.name}`);
127
+ }
128
+ mkdirSync(dirname(out), { recursive: true });
129
+ writeFileSync(out, `${JSON.stringify({ base, census, red }, null, 1)}\n`);
130
+ console.log(red.length === 0 ? '\ncensus green' : `\ncensus RED (${red.length}):\n${red.map(line => ` ${line}`).join('\n')}`);
131
+ process.exit(red.length === 0 ? 0 : 1);
@@ -10,6 +10,9 @@ A shard (24 cameras). <goldens> is a shard repo's art/goldens/: cameras24.json,
10
10
  An open plot (8 views). <goldens> holds <plot>/cameras.json and <plot>/<n>-<view>.jpg:
11
11
  python3 scripts/goldens/board.py --goldens <goldens> --plot <plot> --now <dir> --out <dir> [...]
12
12
  NOW frames: <now>/<plot>/<n>-<view>.png|.jpg. Columns: GOLDEN | NOW.
13
+ Plot mask: when <n>-<view>-iso.png (other cells hidden) and <n>-<view>-bare.png (every cell hidden) sit beside a NOW
14
+ frame, the pixels where they differ are the plot's own. SSIM and the colour guard count only those, so a neighbour
15
+ the grid layout moved never scores, and a SCORED column shows NOW with everything else dimmed.
13
16
 
14
17
  Writes <out>/<id>.jpg (one big labelled row per camera: read every one) and <out>/board-<slug>.jpg (every camera on one
15
18
  labelled board, <= 500 KB; --red burns a red frame and RED onto those cameras). Prints SSIM per camera: a guide only,
@@ -45,15 +48,32 @@ def blur(a):
45
48
  return sum(k[i] * rows[:, i:i + a.shape[1]] for i in range(11))
46
49
 
47
50
 
48
- def ssim(a_img, b_img):
49
- """Luma SSIM at 402 x 681, the G859 page's measure."""
51
+ def fitted_mask(mask, size):
52
+ """A boolean mask resized to size (w, h)."""
53
+ return np.asarray(Image.fromarray(mask.astype(np.uint8) * 255).resize(size, Image.NEAREST)) > 127
54
+
55
+
56
+ def ssim(a_img, b_img, mask=None):
57
+ """Luma SSIM at 402 x 681, the G859 page's measure; with a mask, the mean over its pixels."""
50
58
  size = (402, 681)
51
59
  a, b = luma(a_img.resize(size, Image.BILINEAR)), luma(b_img.resize(size, Image.BILINEAR))
60
+ if mask is not None: # the same flat fill outside the plot in both, so edge windows never see a neighbour
61
+ inside = fitted_mask(mask, size); fill = b[inside].mean()
62
+ a, b = np.where(inside, a, fill), np.where(inside, b, fill)
52
63
  c1, c2 = (0.01 * 255) ** 2, (0.03 * 255) ** 2
53
64
  ma, mb = blur(a), blur(b)
54
65
  va, vb, cov = blur(a * a) - ma * ma, blur(b * b) - mb * mb, blur(a * b) - ma * mb
55
66
  m = ((2 * ma * mb + c1) * (2 * cov + c2)) / ((ma * ma + mb * mb + c1) * (va + vb + c2))
56
- return float(m.mean())
67
+ return float(m[fitted_mask(mask, size)].mean() if mask is not None else m.mean())
68
+
69
+
70
+ def plot_mask(iso, bare):
71
+ """Where the plot draws: other-cells-hidden against every-cell-hidden, a per-channel step over 24 (sky drift
72
+ and dithering stay under it), smoothed so single noisy pixels drop out. None when the two frames don't pair."""
73
+ if iso is None or bare is None or iso.size != bare.size: return None
74
+ a, b = (np.asarray(x.convert('RGB'), dtype=np.int16) for x in (iso, bare))
75
+ differs = (np.abs(a - b).max(axis=2) > 24).astype(np.float64)
76
+ return blur(differs) > 0.5
57
77
 
58
78
 
59
79
  def font(size):
@@ -98,19 +118,21 @@ def cameras(a):
98
118
  golden = Image.open(os.path.join(g, 'shardfile', f'{cid}.jpg')).convert('RGB')
99
119
  cols.append(('SHARDFILE golden', golden.crop((0, STRIP, golden.width, golden.height))))
100
120
  now = find(os.path.join(a.now, a.shard), (f'{cid}-shardfile.png', f'{cid}.png', f'{cid}.jpg'))
101
- out.append((c['n'], cid, cols, now))
121
+ out.append((c['n'], cid, cols, now, None))
102
122
  else:
103
123
  for v in json.load(open(os.path.join(g, a.plot, 'cameras.json')))['views']:
104
124
  vid = f'{v["n"]}-{v["name"]}'
105
125
  golden = Image.open(os.path.join(g, a.plot, f'{vid}.jpg')).convert('RGB')
106
- now = find(os.path.join(a.now, a.plot), (f'{vid}.png', f'{vid}.jpg'))
107
- out.append((v['n'], vid, [('GOLDEN', golden)], now))
126
+ base = os.path.join(a.now, a.plot)
127
+ now = find(base, (f'{vid}.png', f'{vid}.jpg'))
128
+ mask = plot_mask(find(base, (f'{vid}-iso.png',)), find(base, (f'{vid}-bare.png',)))
129
+ out.append((v['n'], vid, [('GOLDEN', golden)], now, mask))
108
130
  return out
109
131
 
110
132
 
111
133
  def promote(a, cams):
112
134
  if not a.shard or not a.source: raise SystemExit('--promote needs --shard and --source "<sha10> <ruling>"')
113
- for n, cid, _, now in cams:
135
+ for n, cid, _, now, _mask in cams:
114
136
  if n not in a.promote: continue
115
137
  if now is None: raise SystemExit(f'no NOW frame for {cid}')
116
138
  img, f = fit(now, 540), font(12)
@@ -136,20 +158,31 @@ def main():
136
158
  if not a.out: raise SystemExit('--out is required')
137
159
  os.makedirs(a.out, exist_ok=True)
138
160
  big, small, missing = [], [], []
139
- for n, cid, goldens, now in cams:
161
+ for n, cid, goldens, now, mask in cams:
140
162
  if now is None: missing.append(cid); continue
141
- s = ssim(goldens[-1][1], now)
142
- pixels = lambda image: image.convert('RGB').resize((128, 217), Image.BILINEAR).getdata()
163
+ if mask is not None and not mask.any(): mask = None # nothing of the plot in view: score the frame
164
+ s = ssim(goldens[-1][1], now, mask)
165
+ small_px = lambda image: np.asarray(image.convert('RGB').resize((128, 217), Image.BILINEAR)).reshape(-1, 3)
166
+ keep = fitted_mask(mask, (128, 217)).reshape(-1) if mask is not None else slice(None)
167
+ pixels = lambda image: [tuple(p) for p in small_px(image)[keep].tolist()]
143
168
  colour = colour_shift(pixels(goldens[-1][1]), pixels(now))
144
169
  if colour['red']: red.add(n)
145
170
  is_red = n in red
146
171
  shift = f'dY {colour["luma_delta"]:+.3f} dS {colour["saturation_delta"]:+.3f}'
172
+ if mask is not None: shift += f' plot {mask.mean():.0%}'
147
173
  flag = ' RED COLOUR' if colour['red'] else ' RED' if is_red else ''
148
174
  print(f'{cid:28s} {s:.3f} {shift}{flag}')
149
175
  for w, size, sink, title in ((360, 13, big, f'{slug} {cid} SSIM {s:.2f} {shift}'), (120, 9, small, f'{cid} {s:.2f}')):
150
176
  f = font(size)
151
177
  cells = [labelled(fit(img, w), label, INK, w, f) for label, img in goldens]
152
178
  cells.append(labelled(fit(now, w), a.label, RED if is_red else INK, w, f))
179
+ if any(c[4] is not None for c in cams):
180
+ scored = fit(now, w)
181
+ if mask is not None:
182
+ keep_w = fitted_mask(mask, scored.size)[..., None]
183
+ arr = np.asarray(scored, dtype=np.float64)
184
+ scored = Image.fromarray(np.where(keep_w, arr, arr * 0.2 + 8).astype(np.uint8))
185
+ cells.append(labelled(scored, 'SCORED (plot mask)' if mask is not None else 'SCORED (whole frame)', INK, w, f))
153
186
  sink.append(row(cells, title + flag, w, is_red, f))
154
187
  big[-1].save(os.path.join(a.out, f'{cid}.jpg'), quality=82)
155
188
  if missing: print('MISSING NOW frames:', ', '.join(missing))
@@ -157,7 +190,7 @@ def main():
157
190
  cols = 4; tw, th = small[0].width, max(t.height for t in small)
158
191
  f = font(16); head = 2 * f.size + 24
159
192
  board = Image.new('RGB', (cols * (tw + 4) + 4, head + -(-len(small) // cols) * (th + 4) + 4), BG)
160
- columns = ' . '.join([label for label, _ in cams[0][2]] + [a.label])
193
+ columns = ' . '.join([label for label, _ in cams[0][2]] + [a.label] + (['SCORED'] if any(c[4] is not None for c in cams) else []))
161
194
  draw = ImageDraw.Draw(board)
162
195
  draw.text((6, 6), f'GOLDEN RERUN {slug} | {columns}', fill=INK, font=f)
163
196
  status = f'RED: {",".join(map(str, sorted(red)))}' if red else 'No mean colour-shift flags; VISUAL REVIEW REQUIRED'
@@ -3,6 +3,7 @@ export function workingGoldenPreviewFolder(record:string):string;
3
3
  export function goldenRefinementBinding(base:string,source:{build:string;sha:string}):Promise<{
4
4
  initializerExport:string;classExport:string;sha:string;build:string;preview:string;nineIndexSHA256:string;chunk:string;chunkSHA256:string;
5
5
  }>;
6
+ export function buildCodeChunks(root:string,build:string):string[];
6
7
  export function refinementExports(source:string):{initializerExport:string;classExport:string};
7
8
  export function observeRefinement<T extends readonly unknown[]>(proto:{add:(...args:T)=>Promise<boolean>}):{
8
9
  jobs:{id:T[0];at:T[1];state:string;error?:string}[];