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.

test(cache): assert post-crash protection and budget limits

yhh776c9563ba8d
diff --git a/docs/CACHE_BUDGET_REVIEW_2026-10-13.md b/docs/CACHE_BUDGET_REVIEW_2026-10-13.md
index ee30e24c5..58c802f95 100644
--- a/docs/CACHE_BUDGET_REVIEW_2026-10-13.md
+++ b/docs/CACHE_BUDGET_REVIEW_2026-10-13.md
@@ -18,8 +18,8 @@ candidate version contains two unfinished cards:
| Card | Board status | Decision |
|---|---|---|
-| RM-025 — disk cache budget / offline versions | Todo, P0 | Implement the shared runtime and editor workflow; this benefits 2D Web/mini-game delivery. |
-| RM-136 — GPU baking / adaptive sampling | Todo, P2 | Defer specialized 3D work according to the repository's 2D production priority. |
+| RM-025 — disk cache budget / offline versions | In Progress, P0 | Runtime/editor workflow implemented; physical acceptance remains pending. |
+| RM-136 — GPU baking / adaptive sampling | In Progress, P2 | Implemented the allowed incremental route after the 2D workflow; see the linked baking review. |
RM-025's earlier static description is outdated: mini-game byte caches and native
URL-to-safe-name mapping already exist. Cache names use XXH64, not SHA256. The
@@ -29,7 +29,8 @@ specified physical-device evidence; their status was not inferred from releases.
The changes are pushed for draft review and unmerged. The initial review found
no matching cache-budget PR; the two drafts above were subsequently created.
-No board completion or device acceptance is claimed and no remote card was changed.
+Both remote cards now contain implementation/verification evidence and are
+In Progress. No board completion or physical-device acceptance is claimed.
## Implemented
@@ -221,3 +222,10 @@ The same demonstration now runs in golden CI shard 3. Local output is
`output/cache-crash.log` in the combined worktree. This strengthens crash/restart
evidence for the Node filesystem contract; physical WeChat acceptance remains
pending and is not substituted by this run.
+
+The cache branch's complete Build run
+[38390256156](https://github.com/esengine/estella/actions/runs/38390256156)
+passed all 17 jobs on `dc3677b68`, including scale budgets after the report-write
+fix. Editor #20 and #21 checks passed at their recorded heads. The newer combined
+branch's crash demonstration runs locally and is being checked in CI; those
+pending checks are not claimed to have passed.
diff --git a/tools/fixtures/cache-budget-demo.ts b/tools/fixtures/cache-budget-demo.ts
index e76d35bb8..267dabd23 100644
--- a/tools/fixtures/cache-budget-demo.ts
+++ b/tools/fixtures/cache-budget-demo.ts
@@ -49,15 +49,23 @@ async function offline(scratch: string, root: string) {
if (a.updateStatus().revision !== 'v3' || current.some(b => b !== 3) || rollback.some(b => b !== 2)) throw Error('offline verification failed');
const report = await a.diskCacheReport();
const cleanup = await a.cleanDiskCache(16, true);
- if (report.versions.some(v => v.reason && v.missing) || cleanup.releaseBytes !== 8
+ const currentVersion = report.versions.find(v => v.revision === 'v3' && v.reason === 'current');
+ const rollbackVersion = report.versions.find(v => v.revision === 'v2' && v.reason === 'rollback');
+ if (!currentVersion || !rollbackVersion || report.versions.some(v => v.reason && v.missing)
+ || cleanup.releaseBytes !== 8 || cleanup.budgetMet !== false || cleanup.remainingBytes !== 24
|| cleanup.report.entries.filter(e => e.name.endsWith('.tmp')).length !== 1
|| cleanup.report.entries.some(e => e.name.endsWith('.tmp') && !e.protection.includes('unindexed'))) {
throw Error('crash recovery did not preserve protected versions and the interrupted temporary');
}
+ for (const v of [2, 3]) {
+ const stored = await nodeAdapter.readCacheFile(assetUrl(root, v));
+ if (!stored || stored.byteLength !== 8 || new Uint8Array(stored).some(b => b !== v))
+ throw Error('cleanup deleted or damaged a protected version after restart');
+ }
return { revision: a.updateStatus().revision, currentBytes: current.byteLength,
rollbackBytes: rollback.byteLength, networkAllowed: false, freshProcess: true,
protectedMissing: 0, releasedUncommittedBytes: cleanup.releaseBytes,
- interruptedTemporaryProtected: true, remainingBytes: cleanup.remainingBytes };
+ interruptedTemporaryProtected: true, remainingBytes: cleanup.remainingBytes, budgetMet: cleanup.budgetMet };
}
type CrashPhase = 'resource-rename' | 'manifest-rename';
@@ -114,7 +122,7 @@ function crash(scratch: string, bundle: string, root: string, phase: CrashPhase)
});
child.once('exit', (code, signal) => {
clearTimeout(timeout);
- if (failure || !marker || code === 0) reject(Error(`${failure || 'unexpected child exit'}: ${stderr}`));
+ if (failure || !marker || signal !== 'SIGKILL') reject(Error(`${failure || 'unexpected child exit'}: ${stderr}`));
else resolve({ ...marker, exitCode: code, signal, terminated: true });
});
});