Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: admit game manifest and record publication
[._.]/ Adam Eivy419c013283a8
diff --git a/docs/BACKUP.md b/docs/BACKUP.mdindex cf16236ade..e7fa695b64 100644--- a/docs/BACKUP.md+++ b/docs/BACKUP.md@@ -108,6 +108,7 @@ Admission inventory (`withBackupAssetPublication`):| Time Capsule snapshots (`timeCapsule.js`) | Covered (#9982 partial): snapshot creation and deletion lease the file and index entry together, acquiring before the shared index write tail || CoS raw recording compression and purge (`cosAgentStorage.js`) | Covered (#9982 partial): verified gzip publication, storage manifest and plain-file removal share a lease; purge intent and unlinks also share a lease because the manifest is file-primary || CoS agent archive/index publication (`cosAgentLifecycle.js`, `cosAgentArchive.js`, `cosAgentIndex.js`) | Covered (#9982 partial): completion, zombie/stale archival, deletion and legacy layout migration lease directory changes through state and index publication; state-locked workflows acquire admission first |+| Game compiled manifests (`games/compile.js`) | Covered (#9982 partial): versioned manifest and game compiled/history pointers hold one lease before the per-game queue || Durable replacement/deletion owners not yet classified | Outstanding (#9982) || Snapshot consistency claim (`backupAssetOwners.js`, see below) | Covered (#9982 partial) || Database restore execution and backend-cutover acceptance (`backup.js`, `databasePreflight.js`) | Covered (#9983) |diff --git a/server/lib/backupAssetOwners.js b/server/lib/backupAssetOwners.jsindex eedb713337..7a28ddd268 100644--- a/server/lib/backupAssetOwners.js+++ b/server/lib/backupAssetOwners.js@@ -429,6 +429,13 @@ export const BACKUP_ASSET_OWNERS = Object.freeze([status: 'admitted',modules: ['services/cosAgentLifecycle.js', 'services/cosAgentArchive.js', 'services/cosAgentIndex.js'],},+ {+ // Versioned manifest plus the compiledManifest/history pointers in the+ // game row; admission precedes the per-game write tail.+ id: 'game-compiled-manifest',+ status: 'admitted',+ modules: ['services/games/compile.js'],+ },// Anything the sweep did not reach. A new asset owner lands here until it is// classified; the claim cannot become `global` while this entry exists.{ id: 'unclassified-durable-owners', status: 'outstanding', modules: [] },diff --git a/server/services/games/compile.backupAdmission.test.js b/server/services/games/compile.backupAdmission.test.jsnew file mode 100644index 0000000000..a81413bb47--- /dev/null+++ b/server/services/games/compile.backupAdmission.test.js@@ -0,0 +1,63 @@+import { afterAll, beforeEach, expect, it, vi } from 'vitest';+import { mkdir, readFile, readdir, rm } from 'node:fs/promises';+import { join } from 'node:path';+import { createFileWriteQueue } from '../../lib/fileWriteQueue.js';+const f = await vi.hoisted(async () => {+ const { mkdtemp } = await import('node:fs/promises');+ const { tmpdir } = await import('node:os');+ const { join } = await import('node:path');+ return { root: await mkdtemp(join(tmpdir(), 'game-compile-backup-')), row: null, beforeRow: null, bypass: false };+});+const queue = createFileWriteQueue();+vi.mock('./store.js', () => ({+ gameRecordDir: () => f.root, isValidGameId: () => true,+ queueGameWrite: (_id, fn) => queue(fn), readRaw: async () => f.row,+ writeRaw: async (_id, next) => { await f.beforeRow?.(); f.row = next; },+}));+vi.mock('./records.js', () => ({ GAME_HISTORY_LIMIT: 20, sanitizeGame: game => game }));+vi.mock('./integrity.js', () => ({ resolveGameAssets: async () => ({+ issues: [], sprites: [], music: [], artwork: [], inputSha256: 'example', schemaVersion: 1, verifiedFileCount: 0,+}) }));+vi.mock('../apps.js', () => ({ getAppById: async () => ({ id: 'example-app' }) }));+vi.mock('../../lib/backupSnapshotBoundary.js', async importOriginal => {+ const actual = await importOriginal();+ return { ...actual, withBackupAssetPublication: work => f.bypass ? work() : actual.withBackupAssetPublication(work) };+});+const { compileGameAssets } = await import('./compile.js');+const { acquireBackupSnapshotCut } = await import('../../lib/backupSnapshotBoundary.js');+const deferred = () => { let resolve; const promise = new Promise(done => { resolve = done; }); return { promise, resolve }; };+const settle = () => new Promise(resolve => setImmediate(resolve));+const files = () => readdir(join(f.root, 'manifests'));+const assertPair = async () => expect(JSON.parse(await readFile(join(f.root, f.row.compiledManifest.manifestPath), 'utf8')).game.id).toBe('game-example');+beforeEach(async () => {+ await rm(f.root, { recursive: true, force: true }); await mkdir(join(f.root, 'manifests'), { recursive: true });+ f.row = { id: 'game-example', name: 'Example', appId: 'example-app', compileHistory: [] };+ f.beforeRow = null; f.bypass = false;+});+afterAll(() => rm(f.root, { recursive: true, force: true }));+it('blocks manifest and row changes during a cut', async () => {+ const release = await acquireBackupSnapshotCut();+ const work = compileGameAssets('game-example');+ try { await settle(); expect(await files()).toEqual([]); expect(f.row.compiledManifest).toBeUndefined(); }+ finally { release(); }+ await work; await assertPair();+});+it('drains a manifest already written through its pointer commit', async () => {+ const reached = deferred(); const commit = deferred();+ f.beforeRow = async () => { reached.resolve(); await commit.promise; };+ const work = compileGameAssets('game-example'); await reached.promise;+ expect(await files()).toHaveLength(1);+ let ready = false; const cut = acquireBackupSnapshotCut().then(release => { ready = true; return release; });+ try { await settle(); expect(ready).toBe(false); } finally { commit.resolve(); }+ await work; const release = await cut;+ try { await assertPair(); } finally { release(); }+});+it('negative control exposes a dumped pointer missing from the prior file copy', async () => {+ f.bypass = true;+ const release = await acquireBackupSnapshotCut();+ try {+ const copiedFiles = await files(); await compileGameAssets('game-example');+ expect(copiedFiles).not.toContain(f.row.compiledManifest.manifestPath.split('/').at(-1));+ await assertPair();+ } finally { release(); }+});diff --git a/server/services/games/compile.js b/server/services/games/compile.jsindex 754d7c59ee..6d33f4f133 100644--- a/server/services/games/compile.js+++ b/server/services/games/compile.js@@ -7,6 +7,7 @@*/import { join } from 'path';+import { withBackupAssetPublication } from '../../lib/backupSnapshotBoundary.js';import { ServerError } from '../../lib/errorHandler.js';import { atomicWrite, pathExists, sha256File, sha256Text } from '../../lib/fileUtils.js';import { canonicalStringify } from '../../lib/objects.js';@@ -22,7 +23,7 @@ export async function compileGameAssets(id) {throw new ServerError('Game not found', { status: 404, code: 'NOT_FOUND' });}let result;- await queueGameWrite(id, async () => {+ await withBackupAssetPublication(() => queueGameWrite(id, async () => {const game = sanitizeGame(await readRaw(id));if (!game) throw new ServerError('Game not found', { status: 404, code: 'NOT_FOUND' });const app = await getAppById(game.appId);@@ -89,6 +90,6 @@ export async function compileGameAssets(id) {});await writeRaw(id, next);result = { ...pointer, created: true };- });+ }));return result;}