Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(residency): the report says where its cells are, and the inventory closes

esengine68c9d3a61ad4
diff --git a/desktop b/desktop
index dede3f687..65e2b9a6f 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit dede3f6877dbe151a4c746bf1bdada69ec8f71a5
+Subproject commit 65e2b9a6f19721f484d0d72fc4d78a04ea8aab46
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index b699104d5..7bceb473d 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -10297,6 +10297,8 @@ cellCount: number
cellEntityCounts: Record<string, number>
cellRenderCounts: Record<string, number>
cellRows: Record<string, { id: number; entity: number; }[]>
+cellSize: number
+cells: { name: string; x: number; z: number; }[]
delivery: Record<string, CellDelivery>
desiredCells: string[]
lastDemandToResidentMs: number
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index c50dde2e7..9fb772cb5 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -10490,6 +10490,8 @@ cellCount: number
cellEntityCounts: Record<string, number>
cellRenderCounts: Record<string, number>
cellRows: Record<string, { id: number; entity: number; }[]>
+cellSize: number
+cells: { name: string; x: number; z: number; }[]
delivery: Record<string, CellDelivery>
desiredCells: string[]
lastDemandToResidentMs: number
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index b57e388b7..ffcf0c44a 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -10292,6 +10292,8 @@ cellCount: number
cellEntityCounts: Record<string, number>
cellRenderCounts: Record<string, number>
cellRows: Record<string, { id: number; entity: number; }[]>
+cellSize: number
+cells: { name: string; x: number; z: number; }[]
delivery: Record<string, CellDelivery>
desiredCells: string[]
lastDemandToResidentMs: number
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 5bb81243b..739d48ebd 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -10544,6 +10544,8 @@ cellCount: number
cellEntityCounts: Record<string, number>
cellRenderCounts: Record<string, number>
cellRows: Record<string, { id: number; entity: number; }[]>
+cellSize: number
+cells: { name: string; x: number; z: number; }[]
delivery: Record<string, CellDelivery>
desiredCells: string[]
lastDemandToResidentMs: number
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 54a2d0f89..51cd6e75c 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -10320,6 +10320,8 @@ cellCount: number
cellEntityCounts: Record<string, number>
cellRenderCounts: Record<string, number>
cellRows: Record<string, { id: number; entity: number; }[]>
+cellSize: number
+cells: { name: string; x: number; z: number; }[]
delivery: Record<string, CellDelivery>
desiredCells: string[]
lastDemandToResidentMs: number
diff --git a/sdk/src/residency/report.ts b/sdk/src/residency/report.ts
index 96f9991fd..0a95300d1 100644
--- a/sdk/src/residency/report.ts
+++ b/sdk/src/residency/report.ts
@@ -26,6 +26,16 @@ export interface WorldResidencyReport {
/** False when this build has no cooked world; every other field is empty. */
streamed: boolean;
cellCount: number;
+ /**
+ * Where the cells ARE, in manifest order — the ground each name stands for.
+ *
+ * Every other list here is names, and a name cannot be drawn. A reader that
+ * had to find the coordinates elsewhere would be reading a second copy of
+ * the partition, which agrees with this one only until one of them moves.
+ */
+ cells: Array<{ name: string; x: number; z: number }>;
+ /** Edge of one grid square, world units — what the coordinates above scale by. */
+ cellSize: number;
sourceCount: number;
desiredCells: string[];
/** Cells any source is close enough to speculate about. */
@@ -80,7 +90,7 @@ export interface WorldResidencyReport {
}
const EMPTY: WorldResidencyReport = {
- streamed: false, cellCount: 0, sourceCount: 0,
+ streamed: false, cellCount: 0, cells: [], cellSize: 0, sourceCount: 0,
desiredCells: [], prefetchCells: [], residentCells: [], preparedCells: [],
preparedWithRenderClaim: [], renderClaims: {},
loadingCells: [], unloadingCells: [],
@@ -134,6 +144,8 @@ export function worldResidencyReport(app: App): WorldResidencyReport {
return {
streamed: true,
cellCount: status.cellCount,
+ cells: manifest.cells.map((cell) => ({ name: cell.name, x: cell.x, z: cell.z })),
+ cellSize: manifest.cellSize,
sourceCount: status.sourceCount,
desiredCells: status.desiredCells,
prefetchCells: status.prefetchCells,
diff --git a/tools/check-decision-inventory.mjs b/tools/check-decision-inventory.mjs
index 96eb9d522..73b58f79f 100644
--- a/tools/check-decision-inventory.mjs
+++ b/tools/check-decision-inventory.mjs
@@ -77,6 +77,22 @@ for (const d of DECISIONS) {
if (surface.has && (surface.owed || surface.unavailable)) {
problems.push(`${d.id} → ${s} both claims a surface and explains its absence`);
}
+ // `unavailable` is a claim about the CODE, and prose carries no probe — so
+ // residency's premise outlived the release that removed it. This one holds
+ // the OPPOSITE way round: the premise still being findable keeps it true.
+ if (surface.unavailable) {
+ if (!surface.while) {
+ problems.push(`${d.id} → ${s} is unavailable with nothing to disprove it — add \`while\``);
+ } else if (!(!HAS_EDITOR && surface.while.path.startsWith('desktop/'))) {
+ claimed++;
+ const gone = probeHolds(surface.while);
+ if (gone) {
+ problems.push(
+ `${d.id} → ${s}: the premise for calling it unavailable is gone `
+ + `(${surface.while.path} ${gone}) — the surface may be buildable now`);
+ }
+ }
+ }
// Two defects, counted apart: one is a reader nobody wrote, the other is a
// fact this realm never produces. Only the first is a panel.
if (!surface.has) {
diff --git a/tools/check-residency-authority.mjs b/tools/check-residency-authority.mjs
index d1ce5697b..6a1a4c056 100644
--- a/tools/check-residency-authority.mjs
+++ b/tools/check-residency-authority.mjs
@@ -78,6 +78,32 @@ if (installs.length !== 1) {
say('sdk/src', `${installs.length} place(s) schedule the residency system — exactly one may`);
}
+// 6b. The editor READS residency and never derives it. A panel classifying a
+// cell from a source's radius is a second author of existence, so the
+// report's lists become a word in ONE editor file.
+const DERIVES = /\b(residentCells|preparedCells|loadingCells|unloadingCells)\b/;
+const DECIDES = /\b(desiredResidency|distanceToCell)\b/;
+const EDITOR_STATE_AUTHOR = 'desktop/src/engine/worldRuntimeStore.ts';
+if (existsSync(path.join(ROOT, 'desktop', 'src'))) {
+ for (const file of walk(path.join(ROOT, 'desktop', 'src'), /\.tsx?$/)) {
+ const rel = path.relative(ROOT, file).split(path.sep).join('/');
+ const text = readFileSync(file, 'utf8');
+ if (DECIDES.test(text)) {
+ say(rel, 'runs the residency decision — the editor shows what the streamer decided, it does not decide');
+ }
+ if (rel !== EDITOR_STATE_AUTHOR && DERIVES.test(text)) {
+ say(rel, `reads the report's cell lists directly — import cellState from ${EDITOR_STATE_AUTHOR}`);
+ }
+ }
+ // …and the author has to exist, or the rule above is satisfied by a codebase
+ // that dropped the reader entirely.
+ if (!existsSync(path.join(ROOT, EDITOR_STATE_AUTHOR))) {
+ say(EDITOR_STATE_AUTHOR, 'the editor\'s one residency reader is missing');
+ } else if (!DERIVES.test(read(EDITOR_STATE_AUTHOR))) {
+ say(EDITOR_STATE_AUTHOR, 'no longer derives a cell state from the report — the rule above now guards nothing');
+ }
+}
+
// 6. Reading residency cannot change it. A report that reconciled would make
// what exists depend on who looked.
const report = read('sdk/src/residency/report.ts');
@@ -87,13 +113,13 @@ for (const mutator of ['.update(', '.loadManifest(', '.clear(']) {
}
}
-function* walk(dir) {
+function* walk(dir, match = /\.ts$/) {
if (!existsSync(dir)) return;
for (const entry of readdirSync(dir, { withFileTypes: true })) {
if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;
const full = path.join(dir, entry.name);
- if (entry.isDirectory()) yield* walk(full);
- else if (/\.ts$/.test(entry.name)) yield full;
+ if (entry.isDirectory()) yield* walk(full, match);
+ else if (match.test(entry.name)) yield full;
}
}
@@ -102,4 +128,4 @@ if (problems.length > 0) {
console.error(`check-residency-authority: ${problems.length} finding(s).`);
process.exit(1);
}
-console.log('check-residency-authority: one author decides what exists, and unloading destroys.');
+console.log('check-residency-authority: one author decides what exists, one reader names it, and unloading destroys.');
diff --git a/tools/lib/runtimeDecisions.mjs b/tools/lib/runtimeDecisions.mjs
index ce3c18f4f..3539da246 100644
--- a/tools/lib/runtimeDecisions.mjs
+++ b/tools/lib/runtimeDecisions.mjs
@@ -61,16 +61,8 @@ export const DECISIONS = [
owner: { path: 'sdk/src/residency/cells.ts', probe: /export function desiredResidency/ },
// The whole explanation is already built, per cell, every frame.
runtime: { has: true, cite: { path: 'sdk/src/residency/report.ts', probe: /prefetchHits/ } },
- editor: {
- has: false,
- unavailable: 'the editor never runs the thing. Streaming turns on only when '
- + 'runtimeLoader is handed a COOKED world manifest (`config.worlds`), which only exportGame '
- + 'and the headless gameHost supply; neither the edit realm nor playHost passes one, so '
- + 'worldResidencyReport answers EMPTY in both. A panel reading it would show zeros for ever, '
- + 'and goldenProjects already records the split as deliberate ("the editor plays it whole"). '
- + 'The debt is a decision about Play, not a panel',
- },
- agent: { has: false, unavailable: 'same realm, same absence of a cooked world to report on' },
+ editor: { has: true, cite: { path: 'desktop/src/panels/WorldPanel.tsx', probe: /WorldRuntimeStore/ } },
+ agent: { has: true, cite: { path: 'desktop/shared/toolCatalog.mjs', probe: /'get_world_residency'/ } },
},
{
id: 'shadow.atlasAllocation',